Gdb scripting: execute commands at the selected breakpoint

I would like to predefine some breakpoints in the gdb script and call some special commands on these breakpoints, and then automatically continue the program. So, ideally, I would like to have a gdb script as follows:

b someFunction ... if breakpoint from above reached do: print var1 call someOtherFunction continue done 

Also, unfortunately, I cannot rely on the python interface to use breakpoints, since the version of gdb on the server I'm currently running on is too old!

+21
scripting breakpoints gdb
Dec 18 '12 at 14:48
source share
1 answer

You should take a look at the command , which allows you to add gdb commands as a breakpoint. See the breakpoint command list section in the gdb manual.

For example:

 break someFunction commands print var1 end 

will be when a breakpoint on someFunction is clicked, automatically print var1 .

+29
Dec 18 '12 at 15:56
source share



All Articles