← Back to team overview

maria-developers team mailing list archive

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


Hi, one correction below:


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.

After writing this, I decided to recheck the above statement, and
discovered that the latest GDB (7.1) has fixed this problem.
It *is* possible to just detach from a crashed process, and then
reattach to a new one.

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 >
document bsave
store actual breakpoints

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

The credits go to this page:

Happy debugging,

Mailing list: https://launchpad.net/~maria-developers
Post to : maria-developers@xxxxxxxxxxxxxxxxxxx
Unsubscribe : https://launchpad.net/~maria-developers
More help : https://help.launchpad.net/ListHelp