这个答案已经过时了。GDB现在支持直接保存。看到这个答案。
您可以使用日志记录:
(gdb) b main
Breakpoint 1 at 0x8049329
(gdb) info break
Num Type Disp Enb Address What
1 breakpoint keep y 0x08049329 <main+16>
(gdb) set logging file breaks.txt
(gdb) set logging on
Copying output to breaks.txt.
(gdb) info break
Num Type Disp Enb Address What
1 breakpoint keep y 0x08049329 <main+16>
(gdb) q
文件breaks.txt现在包含:
Num Type Disp Enb Address What
1 breakpoint keep y 0x08049329 <main+16>
编写AWK脚本将其转换为对.gdbinit
或--command
文件有用的格式很容易。或者甚至可以使脚本--eval-command
向GDB命令行发出单独的。
将此小宏添加到.gdbinit可以帮助您做到这一点:
# Call with dump_breaks file.txt
define dump_breaks
set logging file $arg0
set logging redirect on
set logging on
info breakpoints
set logging off
set logging redirect off
end
Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]