I have a class with a regrettable number of methods. I would like gdb to break whenever I enter the class, so through any of the methods. Is there a way to do this without setting break points individually for each method?
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.
This applies to breakpoints set with the break command as well as to internal breakpoints set by commands like next and finish . For breakpoints set with hbreak , GDB will always use hardware breakpoints. You can control this automatic behaviour with the following commands: set breakpoint auto-hw on.
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.
To skip a breakpoint a certain number of times, we use the ignore command. The ignore command takes two arguments: the breakpoint number to skip, and the number of times to skip it. (gdb) ignore 2 5 Will ignore next 5 crossings of breakpoint 2.
I never tried it myself, but it seems you can try the rbreak
command :
rbreak regex
Set breakpoints on all functions matching the regular expression regex. This command sets an unconditional breakpoint on all matches, printing a list of all breakpoints it set. Once these breakpoints are set, they are treated just like the breakpoints set with the break command.
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