gdb的一些技巧

转自:http://blog.csdn.net/playerl/article/details/7433410

【设置断点方法】

[python]  view plain copy
  1. break  函数名  
  2. break  行号  
  3. break  文件名:行号  
  4. break  文件名:函数名  
  5. break  *地址  
  6. break  <point> thread <threadno>  

【显示】

[cpp]  view plain copy
  1. p/格式    变量  
  2. x/格式    地址  
  3. u    无符号十进制  
  4. o    八进制  
  5. t     二进制  
  6. a     地址  
  7. c     字符(ASCII)  
  8. f     浮点小数  
  9. s     字符串  
  10. i     机器语言  

 

【反汇编】

[cpp]  view plain copy
  1. disass  
  2. disass  函数名  
  3. disass  程序计数器  
  4. disass  开始地址    结束地址  

【监视点】

[cpp]  view plain copy
  1. watch  <表达式>    表达式发生变化时暂停运行, 此处<表达式>的意思是常量或变量等  
  2. awatch <表达式>    被访问、改变时暂停运行  
  3. rwatch <表达式>    被访问时暂停运行  


【改变变量的值】

[cpp]  view plain copy
  1. set  variable  <变量>=<表达式>  


【条件断点】

[cpp]  view plain copy
  1. break   断点   if   条件     [b  iseq_compile  if  node==0]  
  2. condition   断点编号         [删除指定编号断点的触发条件]  
  3. condition   断点编号  条件    [给断点添加触发条件]  


【函数栈】




【参数获取】

32位的程序原则上参数都在栈中,因此进入函数内部第一条汇编指令之前,可以通过以下方式访问每一个参数

[cpp]  view plain copy
  1. p  *(int*)($esp+4)  
  2. p  *(int*)($esp+8)  
  3. p  *(int*)($esp+12)  
  4. x/s  $esp+16  


x86_64位的程序中,整型和指针型的参数会从左至右一次保存到rdi、rsi、rdx、rcx、r8、r9中,浮点行参数会保存到xmm0、xmm1,多于这些寄存器的参数会保存到栈上


【让程序不退出产生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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值