目录
GDB简介
GDB是GNU开源组织发布的一个强大的Linux下的程序调试工具。 一般来说,GDB主要帮助你完成下面四个方面的功能:
1、启动你的程序,可以按照你的自定义的要求随心所欲的运行程序(按着自己的想法运行)。
2、可让被调试的程序在你所指定的调置的断点处停住。(断点可以是条件表达式)
3、当程序被停住时,可以检查此时你的程序中所发生的事。
4、你可以改变你的程序,将一个BUG产生的影响修正从而测试其他BUG。
GDB基本命令
Here are some of the most frequently needed GDB commands:
break [file:]function
设置断点
Set a breakpoint at function (in file).
run [arglist]
运行程序
Start your program (with arglist, if specified).
bt Backtrace: display the program stack.
查看栈信息
print expr
打印
Display the value of an expression.
c Continue running your program (after stopping, e.g. at a
继续运行
breakpoint).
next
单步运行
Execute next program line (after stopping); step over any function
calls in the line.
edit [file:]function
停止信息
look at the program line where it is presently stopped.
list [file:]function
查看代码信息
type the text of the program in the vicinity of where it is
presently stopped.
step
查看函数内部内容
Execute next program line (after stopping); step into any function
calls in the line.
help [name]
帮助手册
Show information about GDB command name, or general information
about using GDB.
quit
退出
Exit from GDB.
调试core文件
调试正在运行的进程