Gcc+gdb
Gcc+gdb
gcc
1
gcc -g -o hello hello.c // -g 生成可执行文件,其中包含调试信息。
gdb
- 查看
- list(l) 列出源代码(未列全、回车继续显示, +数值 从头显示)
- watch [变量] 监视变量
- print [变量] 打印变量的值
- display [变量] 一直打印
- undisplay
- (backtrace)bt 查看执行到第几行
- 断点
- break(b) [行号] [if] 设置断点
- continue(c) 继续到下个断点
- delete [断点号]
- condition [序号] [条件:x=1]
- until [行号n] 直到n行停止
- info break 显示断点
- next(n) 单步执行
- step(s) 进入函数内部
- finish 退出函数
- kill 终止调试中的程序
- quit 退出gdb
This post is licensed under CC BY 4.0 by the author.