April 6, 2018

GDB Command Files

A favorite feature of mine in GDB is the command file. A command file is a simple text file used to store GDB commands.

I usually use these files to store breakpoints which simplifies the set up of the debugging session.

For example, from within gdb run:

source command.txt

where command.txt contains:

set breakpoint pending on
b main

I use breakpoint pending on to permit deferred loading of shared libraries.

The fantastic thing about these files is that you can store them under revision control and build them up while you chase down an issue. And then use them to confirm the correction.

comments powered by Disqus