casualcoder casualcoder - 1 year ago 94
C Question

Getting gdb to save a list of breakpoints?

OK, info break lists the breakpoints, but not in a format that would work well with reusing them using the --command as in this question. Does gdb have a method for dumping them into a file acceptable for input again? Sometimes in a debugging session, it is necessary to restart gdb after building up a set of breakpoints for testing.

Edit: the .gdbinit file has the same problem as --command. The info break command does not list commands, but rather a table for human consumption.

To elaborate, here is a sample from info break:

(gdb) info break
Num Type Disp Enb Address What
1 breakpoint keep y 0x08048517 <foo::bar(void)+7>

Answer Source

As of gdb 7.2 you can now use the save breakpoints command.

save breakpoints <filename>
  Save all current breakpoint definitions to a file suitable for use
  in a later debugging session.  To read the saved breakpoint
  definitions, use the `source' command.