编译时加入 -g
选项(必须):
-g
gcc -g -o test test.c
开始调试:
gdb test
加入断点:
b test.c:10
运行:
run
逐语句:
s
逐过程:
n
退出:
q
更多命令可参考:
- GDB调试命令详解
- GDB Tutorial