Automagically setup breakpoints with gdb

When you are trying to debug a project you don’t know you’ll probably end up recompiling a few times, then restarting your debugging session. This can be quite frustrating, when you have gdb workset full of breakpoints, watch expressions and all that stuff.

Luckily you can easily restore your state if you just write all the gdb commands you need into a file, then start gdb with “–command=state.gdb”. Magic! All your breakpoints are there.

Alternatively, an even better solution: just don’t exit gdb after recompiling, simply “kill” your currently under-debug process (ie type “kill” inside gdb, do not kill gdb itself!) and gdb will be smart enough to reload your binary if it changed.

Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s