gdb 调试 程序执行脚本信息

在使用gdb 调试 程序 的时候,有时候需要设定多个断点,重复执行某些操作,而这些操作写起来比较麻烦,这个时候就应该想起来用gdb命令 脚本了,它能够很好的完成这些工作。
以设置多个断点为例,我写的命令脚本为
---------------------------------------------------
#filename: .gdbinit
#gdb will read it when starting
file test_gdbscript
set args hello
b main
b foo
r
---------------------------------------------------
有两种方式来使用这个脚本: 
1)启动gdb时候
gdb在启动的时候,会在当前目录 下查找".gdbinit"这个文件 ,并把它的内容作为gdb命令进行解释,所以如果我把脚本命名为".gdbinit",这样在启动的时候就会处理这些命令。
2)gdb运行期间
可以使用 source script-file 来解释gdb命令脚本script-file

 

 

在.gdbinit里面设置了断点,但是如果这些断点在某些动态库里 ,gdb会报错:

Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal ]

可以这样解决这个问题

"set breakpoint pending on" 

(gdb) help set breakpoint pending 
Set debugger's behavior regarding pending breakpoints. 
If on, an unrecognized breakpoint location will cause gdb to create a 
pending breakpoint. If off, an unrecognized breakpoint location results in 
an error. If auto, an unrecognized breakpoint location results in a 
user-query to see if a pending breakpoint should be created.

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值