gdb scripting: execute commands at selected breakpoint

You should take a look at the command command, which enables you to add gdb commands as a breakpoint is hit. See the breakpoint command list section of the gdb manual.

For example:

break someFunction
print var1

will, when the breakpoint on someFunction is hit, automatically print var1.

Leave a Comment