gdb 调试器的使用

gdb 调试器的使用:
在用gcc编译程序时,加上 –g 参数,然后执行 (gdb 可执行程序名) 就进入gdb调试模式
常用指令:
1. l (list)   列出程序清单
2. r (run) 运行程序

3. b(breakpoint) 设置断点,格式: b  [行号/函数名]
4. b  num  if  i==20 设置断点的触发条件
5. condition num(断点号) i==50 改变断点的触发条件
6. info b 查看断点信息
7. clear  [行号] , 清除断点

8. c (continue) 继续运行程序

9. s (step)  单步运行,step into
10. n (next) 单步运行,step over
11. finish   跳出函数,   step out

12. print  变量/表达式 , 显示变量或表达式的值
13. display 变量/表达式 ,每次程序停止运行是都显示变量或表达式的值
14.q 退出gdb

原文地址:https://www.cnblogs.com/qinkai/p/2429704.html