转自:http://blog.csdn.net/playerl/article/details/7433410
【设置断点方法】
- break 函数名
- break 行号
- break 文件名:行号
- break 文件名:函数名
- break *地址
- break <point> thread <threadno>
【显示】
- p/格式 变量
- x/格式 地址
- u 无符号十进制
- o 八进制
- t 二进制
- a 地址
- c 字符(ASCII)
- f 浮点小数
- s 字符串
- i 机器语言
【反汇编】
- disass
- disass 函数名
- disass 程序计数器
- disass 开始地址 结束地址
【监视点】
- watch <表达式> 表达式发生变化时暂停运行, 此处<表达式>的意思是常量或变量等
- awatch <表达式> 被访问、改变时暂停运行
- rwatch <表达式> 被访问时暂停运行
【改变变量的值】
- set variable <变量>=<表达式>
【条件断点】
- break 断点 if 条件 [b iseq_compile if node==0]
- condition 断点编号 [删除指定编号断点的触发条件]
- condition 断点编号 条件 [给断点添加触发条件]
【函数栈】
【参数获取】
32位的程序原则上参数都在栈中,因此进入函数内部第一条汇编指令之前,可以通过以下方式访问每一个参数
- p *(int*)($esp+4)
- p *(int*)($esp+8)
- p *(int*)($esp+12)
- x/s $esp+16
【让程序不退出产生core文件】
generate-core-file /tmp/core.1234
GDB: Program received signal SIGPIPE, Broken pipe.
By default, gdb captures SIGPIPE of a process and pauses it. However, some program ignores SIGPIPE. So, the default behavour of gdb is not desired when debugging those program. To avoid gdb stopping in SIGPIPE, use the following command in gdb:
handle SIGPIPE nostop noprint pass