3 <title>Debugging with GDB
</title>
4 <meta http-equiv=
"Content-Type" content=
"text/html">
5 <meta name=
"description" content=
"Debugging with GDB">
6 <meta name=
"generator" content=
"makeinfo 4.3">
7 <link href=
"http://www.gnu.org/software/texinfo/" rel=
"generator-home">
12 Node:
<a name=
"Breakpoints">Breakpoints
</a>,
13 Next:
<a rel=
"next" accesskey=
"n" href=
"Continuing-and-Stepping.html#Continuing%20and%20Stepping">Continuing and Stepping
</a>,
14 Up:
<a rel=
"up" accesskey=
"u" href=
"Stopping.html#Stopping">Stopping
</a>
18 <h3 class=
"section">Breakpoints, watchpoints, and catchpoints
</h3>
20 <p>A
<dfn>breakpoint
</dfn> makes your program stop whenever a certain point in
21 the program is reached. For each breakpoint, you can add conditions to
22 control in finer detail whether your program stops. You can set
23 breakpoints with the
<code>break
</code> command and its variants (see
<a href=
"Set-Breaks.html#Set%20Breaks">Setting breakpoints
</a>), to specify the place where your program
24 should stop by line number, function name or exact address in the
27 <p>In HP-UX, SunOS
4.x, SVR4, and Alpha OSF/
1 configurations, you can set
28 breakpoints in shared libraries before the executable is run. There is
29 a minor limitation on HP-UX systems: you must wait until the executable
30 is run in order to set breakpoints in shared library routines that are
31 not called directly by the program (for example, routines that are
32 arguments in a
<code>pthread_create
</code> call).
34 <p>A
<dfn>watchpoint
</dfn> is a special breakpoint that stops your program
35 when the value of an expression changes. You must use a different
36 command to set watchpoints (see
<a href=
"Set-Watchpoints.html#Set%20Watchpoints">Setting watchpoints
</a>), but aside from that, you can manage a watchpoint like
37 any other breakpoint: you enable, disable, and delete both breakpoints
38 and watchpoints using the same commands.
40 <p>You can arrange to have values from your program displayed automatically
41 whenever GDB stops at a breakpoint. See
<a href=
"Auto-Display.html#Auto%20Display">Automatic display
</a>.
43 <p>A
<dfn>catchpoint
</dfn> is another special breakpoint that stops your program
44 when a certain kind of event occurs, such as the throwing of a C
<tt>++
</tt>
45 exception or the loading of a library. As with watchpoints, you use a
46 different command to set a catchpoint (see
<a href=
"Set-Catchpoints.html#Set%20Catchpoints">Setting catchpoints
</a>), but aside from that, you can manage a catchpoint like any
47 other breakpoint. (To stop when your program receives a signal, use the
48 <code>handle
</code> command; see
<a href=
"Signals.html#Signals">Signals
</a>.)
50 GDB assigns a number to each breakpoint, watchpoint, or
51 catchpoint when you create it; these numbers are successive integers
52 starting with one. In many of the commands for controlling various
53 features of breakpoints you use the breakpoint number to say which
54 breakpoint you want to change. Each breakpoint may be
<dfn>enabled
</dfn> or
55 <dfn>disabled
</dfn>; if disabled, it has no effect on your program until you
58 <p>Some GDB commands accept a range of breakpoints on which to
59 operate. A breakpoint range is either a single breakpoint number, like
60 <code>5</code>, or two such numbers, in increasing order, separated by a
61 hyphen, like
<code>5-
7</code>. When a breakpoint range is given to a command,
62 all breakpoint in that range are operated on.
65 <li><a accesskey=
"1" href=
"Set-Breaks.html#Set%20Breaks">Set Breaks
</a>: Setting breakpoints
66 <li><a accesskey=
"2" href=
"Set-Watchpoints.html#Set%20Watchpoints">Set Watchpoints
</a>: Setting watchpoints
67 <li><a accesskey=
"3" href=
"Set-Catchpoints.html#Set%20Catchpoints">Set Catchpoints
</a>: Setting catchpoints
68 <li><a accesskey=
"4" href=
"Delete-Breaks.html#Delete%20Breaks">Delete Breaks
</a>: Deleting breakpoints
69 <li><a accesskey=
"5" href=
"Disabling.html#Disabling">Disabling
</a>: Disabling breakpoints
70 <li><a accesskey=
"6" href=
"Conditions.html#Conditions">Conditions
</a>: Break conditions
71 <li><a accesskey=
"7" href=
"Break-Commands.html#Break%20Commands">Break Commands
</a>: Breakpoint command lists
72 <li><a accesskey=
"8" href=
"Breakpoint-Menus.html#Breakpoint%20Menus">Breakpoint Menus
</a>: Breakpoint menus
73 <li><a accesskey=
"9" href=
"Error-in-Breakpoints.html#Error%20in%20Breakpoints">Error in Breakpoints
</a>: ``Cannot insert breakpoints''