← Back to team overview

maria-developers team mailing list archive

Ever wanted to save/restore your GDB breakpoints? Here's a solution.

 

Hi,

Today I got really annoyed while debugging a server crash with GDB.
I never managed to make the same GDB reattach to a new process after
a crash. This means that after each crash one has to restart GDB, and
reattach to the new process.

As a result all breakpoints are lost, and need to be set each time,
which is pretty annoying. Today I thought that others might have been
equally annoyed, and might have figured a solution. Indeed, Google is
our friend, and I found the following short snippet that should be
added to .gdbinit:

define bsave
    shell rm -f brestore.txt
    set logging file brestore.txt
    set logging on
    info break
    set logging off
    # reformat on-the-fly to a valid gdb command file
    shell perl -n -e 'print "break $1\n" if /^\d+.+?(\S+)$/g' brestore.txt > brestore.gdb
end
document bsave
  store actual breakpoints
end

define brestore
  source brestore.gdb
end
document brestore
  restore breakpoints saved by bsave
end


The credits go to this page:
http://stackoverflow.com/questions/501486/getting-gdb-to-save-a-list-of-breakpoints


Happy debugging,
Timour



Follow ups