gdb
Table of Contents
1 命令:
gdb [可执行文件] 没有输入可执行文件可进入gdb后用file命令加载
需编译时打开-g选项
2 设置断点(Break Points)
break
3 设置观察点(WatchPoint)
watch <expr> 为表达式(变量)expr设置一个观察点。一表达式值有变化时,马上停住程序。 rwatch <expr> 当表达式(变量)expr被读时,停住程序。 awatch <expr> 当表达式(变量)的值被读或被写时,停住程序。 info watchpoints
4 设置捕捉点(CatchPoint)
catch <event>
5 维护停止点
delete、clear、disable、enable这几个命令来进行维护: clear 清除所有的已定义的停止点。 clear <function> clear <filename:function>
6 恢复程序运行和单步调试
continue [ignore-count] c [ignore-count] fg [ignore-count] step <count> next <count> set step-mode set step-mode on set step-mod off finish until 或 u stepi 或 si nexti 或 ni
7 查看栈信息
backtrace bt
8 显示源代码
list
9 源代码的内存
info line disassemble
10 查看运行时数据
11 查看寄存器
info registers 查看寄存器的情况。(除了浮点寄存器) info all-registers 查看所有寄存器的情况。(包括浮点寄存器) info registers <regname …>