gdb scripting: execute commands at selected breakpoint
Solution 1:
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
commands
print var1
end
will, when the breakpoint on someFunction
is hit, automatically print var1
.