Breakpoints are set with the
break command (abbreviated
b). The debugger convenience variable `$bpnum' records the
number of the breakpoints you've set most recently; see section Convenience variables, for a discussion of what you can do with
You have several ways to say where the breakpoint should go.
breaksets a breakpoint at the next instruction to be executed in the selected stack frame (see section Examining the Stack). In any selected frame but the innermost, this makes your program stop as soon as control returns to that frame. This is similar to the effect of a
finishcommand in the frame inside the selected frame--except that
finishdoes not leave an active breakpoint. If you use
breakwithout an argument in the innermost frame, GDB stops the next time it reaches the current location; this may be useful inside loops. GDB normally ignores breakpoints when it resumes execution, until at least one instruction has been executed. If it did not do this, you would be unable to proceed past a breakpoint without first disabling the breakpoint. This rule applies whether or not the breakpoint already existed when your program stopped.
break ... if cond
breakcommand, and the breakpoint is set in the same way, but the breakpoint is automatically deleted after the first time your program stops there. See section Disabling breakpoints.
breakcommand and the breakpoint is set in the same way, but the breakpoint requires hardware support and some target hardware may not have this support. The main purpose of this is EPROM/ROM code debugging, so you can set a breakpoint at an instruction without changing the instruction. This can be used with the new trap-generation provided by SPARClite DSU. DSU will generate traps when a program accesses some date or instruction address that is assigned to the debug registers. However the hardware breakpoint registers can only take two data breakpoints, and GDB will reject this command if more than two are used. Delete or disable usused hardware breakpoints before setting new ones. See section Break conditions.
hbreakcommand and the breakpoint is set in the same way. However, like the
tbreakcommand, the breakpoint is automatically deleted after the first time your program stops there. Also, like the
hbreakcommand, the breakpoint requires hardware support and some target hardware may not have this support. See section Disabling breakpoints. Also See section Break conditions.
breakcommand. You can delete them, disable them, or make them conditional the same way as any other breakpoint. When debugging C++ programs,
rbreakis useful for setting breakpoints on overloaded functions that are not members of any special classes.
info breakpoints [n]
info break [n]
info watchpoints [n]
info breakshows the condition on the line following the affected breakpoint; breakpoint commands, if any, are listed after that.
info breakwith a breakpoint number n as argument lists only that breakpoint. The convenience variable
$_and the default examining-address for the
xcommand are set to the address of the last breakpoint listed (see section Examining memory).
info breaknow displays a count of the number of times the breakpoint has been hit. This is especially useful in conjunction with the
ignorecommand. You can ignore a large number of breakpoint hits, look at the breakpoint info to see how many times the breakpoint was hit, and then run again, ignoring one less than that number. This will get you quickly to the last hit of that breakpoint.
GDB allows you to set any number of breakpoints at the same place in your program. There is nothing silly or meaningless about this. When the breakpoints are conditional, this is even useful (see section Break conditions).
GDB itself sometimes sets breakpoints in your program for special
purposes, such as proper handling of
longjmp (in C programs).
These internal breakpoints are assigned negative numbers, starting with
-1; `info breakpoints' does not display them.
You can see these breakpoints with the GDB maintenance command `maint info breakpoints'.
maint info breakpoints
Go to the first, previous, next, last section, table of contents.