gdb断点保存

例如,你每次启动gdb,想在main 函数处设断点 

编辑一个文件比如叫   a 
a中输入   
br   main 
保存 

gdb   你的可执行文件   -x   a就自动执行设断点了。 

这相当于是gdb的一个批处理功能,你还可以在文件中加上其他你经常要用到的命令 

只要用-x   参数加批处理文件运行就可以了

 

 

 

Share: gdb断点保存
调试大的程序时,经常会设置很多断点。但一旦退出gdb,这些断点会全部丢失,再调试时又得重新设置断点,费时费力。

我们可能利用gdb的-x参数来载入所有预设的断点,步骤如下:

1.将断点保存到一个文件中,如bp.list;

2.用gdb调试时,加-x参数载入上述文件。这相当于是gdb的一个批处理功能,因此你还可以在上述文件中加上其他你经常要用到的命令。

For example:

bash-3.00$ cat bp.list 
b main
b 8

bash-3.00$ g++ -g test.cpp
bash-3.00$ gdb ./a.out -x bp.list -tui

GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "sparc-sun-solaris2.10"...
Breakpoint 1 at 0x11000: file test.cpp, line 26.
Breakpoint 2 at 0x10e28: file test.cpp, line 8.

(gdb)

Enjoy it~

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值