I'd like to predefine some breakpoints in a gdb script and to invoke some special commands at these breakpoints and afterwards to automatically continue the program execution. So, ideally, I'd like to have a gdb script like the following:
b someFunction ... if breakpoint from above reached do: print var1 call someOtherFunction continue done
Additionally an unfortunate fact is, that I can't rely on the python interface for using breakpoints, as the gdb version at the server I currently work at is too old!
You can also set breakpoints on function names. To do this, just type "break [functionname]". gdb will stop your program just before that function is called. Breakpoints stay set when your program ends, so you do not have to reset them unless you quit gdb and restart it.
Explanation: None. 8. Which GDB command can be used to put a breakpoint at the beginning of the program? Explanation: None.
c file listed in Example 7.1, “Compiling a C Program With Debugging Information” with debugging information, you can set a new breakpoint at line 7 by running the following command: (gdb) break 7 Breakpoint 2 at 0x4004e3: file fibonacci.
A breakpoint makes your program stop whenever a certain point in the program is reached. For each breakpoint, you can add conditions to control in finer detail whether your program stops.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With