C++ – Getting GDB to save a list of breakpoints

breakpointscdebugginggdb

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.

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>

Best Answer

As of GDB 7.2 (2011-08-23) 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.

Use source <filename> to restore the saved breakpoints from the file.

Related Topic