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=
"GDB%2fMI%20Breakpoint%20Table%20Commands">GDB/MI Breakpoint Table Commands
</a>,
13 Next:
<a rel=
"next" accesskey=
"n" href=
"GDB-MI-Data-Manipulation.html#GDB%2fMI%20Data%20Manipulation">GDB/MI Data Manipulation
</a>,
14 Previous:
<a rel=
"previous" accesskey=
"p" href=
"GDB-MI-Command-Description-Format.html#GDB%2fMI%20Command%20Description%20Format">GDB/MI Command Description Format
</a>,
15 Up:
<a rel=
"up" accesskey=
"u" href=
"GDB-MI.html#GDB%2fMI">GDB/MI
</a>
19 <h3 class=
"section"><small>GDB/MI
</small> Breakpoint table commands
</h3>
21 <p>This section documents
<small>GDB/MI
</small> commands for manipulating
24 <h4 class=
"subheading">The
<code>-break-after
</code> Command
</h4>
26 <h5 class=
"subsubheading">Synopsis
</h5>
28 <pre class=
"example"> -break-after
<var>number
</var> <var>count
</var>
31 <p>The breakpoint number
<var>number
</var> is not in effect until it has been
32 hit
<var>count
</var> times. To see how this is reflected in the output of
33 the
<code>-break-list
</code> command, see the description of the
34 <code>-break-list
</code> command below.
36 <h5 class=
"subsubheading">GDB Command
</h5>
38 <p>The corresponding GDB command is
<code>ignore
</code>.
40 <h5 class=
"subsubheading">Example
</h5>
42 <pre class=
"smallexample"> (gdb)
44 ^done,bkpt={
number=
"1",
addr=
"0x000100d0",
file=
"hello.c",
line=
"5"}
51 ^done,BreakpointTable={
nr_rows=
"1",
nr_cols=
"6",
52 hdr=[{
width=
"3",
alignment=
"-1",
col_name=
"number",
colhdr=
"Num"},
53 {
width=
"14",
alignment=
"-1",
col_name=
"type",
colhdr=
"Type"},
54 {
width=
"4",
alignment=
"-1",
col_name=
"disp",
colhdr=
"Disp"},
55 {
width=
"3",
alignment=
"-1",
col_name=
"enabled",
colhdr=
"Enb"},
56 {
width=
"10",
alignment=
"-1",
col_name=
"addr",
colhdr=
"Address"},
57 {
width=
"40",
alignment=
"2",
col_name=
"what",
colhdr=
"What"}],
58 body=[bkpt={
number=
"1",
type=
"breakpoint",
disp=
"keep",
enabled=
"y",
59 addr=
"0x000100d0",
func=
"main",
file=
"hello.c",
line=
"5",
times=
"0",
64 <h4 class=
"subheading">The
<code>-break-condition
</code> Command
</h4>
66 <h5 class=
"subsubheading">Synopsis
</h5>
68 <pre class=
"example"> -break-condition
<var>number
</var> <var>expr
</var>
71 <p>Breakpoint
<var>number
</var> will stop the program only if the condition in
72 <var>expr
</var> is true. The condition becomes part of the
73 <code>-break-list
</code> output (see the description of the
<code>-break-list
</code>
76 <h5 class=
"subsubheading">GDB Command
</h5>
78 <p>The corresponding GDB command is
<code>condition
</code>.
80 <h5 class=
"subsubheading">Example
</h5>
82 <pre class=
"smallexample"> (gdb)
87 ^done,BreakpointTable={
nr_rows=
"1",
nr_cols=
"6",
88 hdr=[{
width=
"3",
alignment=
"-1",
col_name=
"number",
colhdr=
"Num"},
89 {
width=
"14",
alignment=
"-1",
col_name=
"type",
colhdr=
"Type"},
90 {
width=
"4",
alignment=
"-1",
col_name=
"disp",
colhdr=
"Disp"},
91 {
width=
"3",
alignment=
"-1",
col_name=
"enabled",
colhdr=
"Enb"},
92 {
width=
"10",
alignment=
"-1",
col_name=
"addr",
colhdr=
"Address"},
93 {
width=
"40",
alignment=
"2",
col_name=
"what",
colhdr=
"What"}],
94 body=[bkpt={
number=
"1",
type=
"breakpoint",
disp=
"keep",
enabled=
"y",
95 addr=
"0x000100d0",
func=
"main",
file=
"hello.c",
line=
"5",
cond=
"1",
96 times=
"0",
ignore=
"3"}]}
100 <h4 class=
"subheading">The
<code>-break-delete
</code> Command
</h4>
102 <h5 class=
"subsubheading">Synopsis
</h5>
104 <pre class=
"example"> -break-delete (
<var>breakpoint
</var> )+
107 <p>Delete the breakpoint(s) whose number(s) are specified in the argument
108 list. This is obviously reflected in the breakpoint list.
110 <h5 class=
"subsubheading">GDB command
</h5>
112 <p>The corresponding GDB command is
<code>delete
</code>.
114 <h5 class=
"subsubheading">Example
</h5>
116 <pre class=
"example"> (gdb)
121 ^done,BreakpointTable={
nr_rows=
"0",
nr_cols=
"6",
122 hdr=[{
width=
"3",
alignment=
"-1",
col_name=
"number",
colhdr=
"Num"},
123 {
width=
"14",
alignment=
"-1",
col_name=
"type",
colhdr=
"Type"},
124 {
width=
"4",
alignment=
"-1",
col_name=
"disp",
colhdr=
"Disp"},
125 {
width=
"3",
alignment=
"-1",
col_name=
"enabled",
colhdr=
"Enb"},
126 {
width=
"10",
alignment=
"-1",
col_name=
"addr",
colhdr=
"Address"},
127 {
width=
"40",
alignment=
"2",
col_name=
"what",
colhdr=
"What"}],
132 <h4 class=
"subheading">The
<code>-break-disable
</code> Command
</h4>
134 <h5 class=
"subsubheading">Synopsis
</h5>
136 <pre class=
"example"> -break-disable (
<var>breakpoint
</var> )+
139 <p>Disable the named
<var>breakpoint
</var>(s). The field
<code>enabled
</code> in the
140 break list is now set to
<code>n
</code> for the named
<var>breakpoint
</var>(s).
142 <h5 class=
"subsubheading">GDB Command
</h5>
144 <p>The corresponding GDB command is
<code>disable
</code>.
146 <h5 class=
"subsubheading">Example
</h5>
148 <pre class=
"smallexample"> (gdb)
153 ^done,BreakpointTable={
nr_rows=
"1",
nr_cols=
"6",
154 hdr=[{
width=
"3",
alignment=
"-1",
col_name=
"number",
colhdr=
"Num"},
155 {
width=
"14",
alignment=
"-1",
col_name=
"type",
colhdr=
"Type"},
156 {
width=
"4",
alignment=
"-1",
col_name=
"disp",
colhdr=
"Disp"},
157 {
width=
"3",
alignment=
"-1",
col_name=
"enabled",
colhdr=
"Enb"},
158 {
width=
"10",
alignment=
"-1",
col_name=
"addr",
colhdr=
"Address"},
159 {
width=
"40",
alignment=
"2",
col_name=
"what",
colhdr=
"What"}],
160 body=[bkpt={
number=
"2",
type=
"breakpoint",
disp=
"keep",
enabled=
"n",
161 addr=
"0x000100d0",
func=
"main",
file=
"hello.c",
line=
"5",
times=
"0"}]}
165 <h4 class=
"subheading">The
<code>-break-enable
</code> Command
</h4>
167 <h5 class=
"subsubheading">Synopsis
</h5>
169 <pre class=
"example"> -break-enable (
<var>breakpoint
</var> )+
172 <p>Enable (previously disabled)
<var>breakpoint
</var>(s).
174 <h5 class=
"subsubheading">GDB Command
</h5>
176 <p>The corresponding GDB command is
<code>enable
</code>.
178 <h5 class=
"subsubheading">Example
</h5>
180 <pre class=
"smallexample"> (gdb)
185 ^done,BreakpointTable={
nr_rows=
"1",
nr_cols=
"6",
186 hdr=[{
width=
"3",
alignment=
"-1",
col_name=
"number",
colhdr=
"Num"},
187 {
width=
"14",
alignment=
"-1",
col_name=
"type",
colhdr=
"Type"},
188 {
width=
"4",
alignment=
"-1",
col_name=
"disp",
colhdr=
"Disp"},
189 {
width=
"3",
alignment=
"-1",
col_name=
"enabled",
colhdr=
"Enb"},
190 {
width=
"10",
alignment=
"-1",
col_name=
"addr",
colhdr=
"Address"},
191 {
width=
"40",
alignment=
"2",
col_name=
"what",
colhdr=
"What"}],
192 body=[bkpt={
number=
"2",
type=
"breakpoint",
disp=
"keep",
enabled=
"y",
193 addr=
"0x000100d0",
func=
"main",
file=
"hello.c",
line=
"5",
times=
"0"}]}
197 <h4 class=
"subheading">The
<code>-break-info
</code> Command
</h4>
199 <h5 class=
"subsubheading">Synopsis
</h5>
201 <pre class=
"example"> -break-info
<var>breakpoint
</var>
204 <p>Get information about a single breakpoint.
206 <h5 class=
"subsubheading">GDB command
</h5>
208 <p>The corresponding GDB command is
<code>info break
</code><var>breakpoint
</var><code></code>.
210 <h5 class=
"subsubheading">Example
</h5>
214 <h4 class=
"subheading">The
<code>-break-insert
</code> Command
</h4>
216 <h5 class=
"subsubheading">Synopsis
</h5>
218 <pre class=
"example"> -break-insert [ -t ] [ -h ] [ -r ]
219 [ -c
<var>condition
</var> ] [ -i
<var>ignore-count
</var> ]
220 [ -p
<var>thread
</var> ] [
<var>line
</var> |
<var>addr
</var> ]
223 <p>If specified,
<var>line
</var>, can be one of:
228 <li>filename:function
232 <p>The possible optional parameters of this command are:
236 <dd>Insert a tempoary breakpoint.
237 <br><dt><code>-h
</code>
238 <dd>Insert a hardware breakpoint.
239 <br><dt><code>-c
</code><var>condition
</var><code></code>
240 <dd>Make the breakpoint conditional on
<var>condition
</var>.
241 <br><dt><code>-i
</code><var>ignore-count
</var><code></code>
242 <dd>Initialize the
<var>ignore-count
</var>.
243 <br><dt><code>-r
</code>
244 <dd>Insert a regular breakpoint in all the functions whose names match the
245 given regular expression. Other flags are not applicable to regular
249 <h5 class=
"subsubheading">Result
</h5>
251 <p>The result is in the form:
253 <pre class=
"example"> ^done,
bkptno=
"<var>number</var>",
func=
"<var>funcname</var>",
254 file=
"<var>filename</var>",
line=
"<var>lineno</var>"
257 <p>where
<var>number
</var> is the GDB number for this breakpoint,
<var>funcname
</var>
258 is the name of the function where the breakpoint was inserted,
259 <var>filename
</var> is the name of the source file which contains this
260 function, and
<var>lineno
</var> is the source line number within that file.
262 <p>Note: this format is open to change.
264 <h5 class=
"subsubheading">GDB Command
</h5>
266 <p>The corresponding GDB commands are
<code>break
</code>,
<code>tbreak
</code>,
267 <code>hbreak
</code>,
<code>thbreak
</code>, and
<code>rbreak
</code>.
269 <h5 class=
"subsubheading">Example
</h5>
271 <pre class=
"smallexample"> (gdb)
273 ^done,bkpt={
number=
"1",
addr=
"0x0001072c",
file=
"recursive2.c",
line=
"4"}
276 ^done,bkpt={
number=
"2",
addr=
"0x00010774",
file=
"recursive2.c",
line=
"11"}
279 ^done,BreakpointTable={
nr_rows=
"2",
nr_cols=
"6",
280 hdr=[{
width=
"3",
alignment=
"-1",
col_name=
"number",
colhdr=
"Num"},
281 {
width=
"14",
alignment=
"-1",
col_name=
"type",
colhdr=
"Type"},
282 {
width=
"4",
alignment=
"-1",
col_name=
"disp",
colhdr=
"Disp"},
283 {
width=
"3",
alignment=
"-1",
col_name=
"enabled",
colhdr=
"Enb"},
284 {
width=
"10",
alignment=
"-1",
col_name=
"addr",
colhdr=
"Address"},
285 {
width=
"40",
alignment=
"2",
col_name=
"what",
colhdr=
"What"}],
286 body=[bkpt={
number=
"1",
type=
"breakpoint",
disp=
"keep",
enabled=
"y",
287 addr=
"0x0001072c",
func=
"main",
file=
"recursive2.c",
line=
"4",
times=
"0"},
288 bkpt={
number=
"2",
type=
"breakpoint",
disp=
"del",
enabled=
"y",
289 addr=
"0x00010774",
func=
"foo",
file=
"recursive2.c",
line=
"11",
times=
"0"}]}
291 -break-insert -r foo.*
293 ^done,bkpt={
number=
"3",
addr=
"0x00010774",
file=
"recursive2.c",
line=
"11"}
297 <h4 class=
"subheading">The
<code>-break-list
</code> Command
</h4>
299 <h5 class=
"subsubheading">Synopsis
</h5>
301 <pre class=
"example"> -break-list
304 <p>Displays the list of inserted breakpoints, showing the following fields:
307 <dt><code>Number
</code>
308 <dd>number of the breakpoint
309 <br><dt><code>Type
</code>
310 <dd>type of the breakpoint:
<code>breakpoint
</code> or
<code>watchpoint
</code>
311 <br><dt><code>Disposition
</code>
312 <dd>should the breakpoint be deleted or disabled when it is hit:
<code>keep
</code>
313 or
<code>nokeep
</code>
314 <br><dt><code>Enabled
</code>
315 <dd>is the breakpoint enabled or no:
<code>y
</code> or
<code>n
</code>
316 <br><dt><code>Address
</code>
317 <dd>memory location at which the breakpoint is set
318 <br><dt><code>What
</code>
319 <dd>logical location of the breakpoint, expressed by function name, file
321 <br><dt><code>Times
</code>
322 <dd>number of times the breakpoint has been hit
325 <p>If there are no breakpoints or watchpoints, the
<code>BreakpointTable
</code>
326 <code>body
</code> field is an empty list.
328 <h5 class=
"subsubheading">GDB Command
</h5>
330 <p>The corresponding GDB command is
<code>info break
</code>.
332 <h5 class=
"subsubheading">Example
</h5>
334 <pre class=
"smallexample"> (gdb)
336 ^done,BreakpointTable={
nr_rows=
"2",
nr_cols=
"6",
337 hdr=[{
width=
"3",
alignment=
"-1",
col_name=
"number",
colhdr=
"Num"},
338 {
width=
"14",
alignment=
"-1",
col_name=
"type",
colhdr=
"Type"},
339 {
width=
"4",
alignment=
"-1",
col_name=
"disp",
colhdr=
"Disp"},
340 {
width=
"3",
alignment=
"-1",
col_name=
"enabled",
colhdr=
"Enb"},
341 {
width=
"10",
alignment=
"-1",
col_name=
"addr",
colhdr=
"Address"},
342 {
width=
"40",
alignment=
"2",
col_name=
"what",
colhdr=
"What"}],
343 body=[bkpt={
number=
"1",
type=
"breakpoint",
disp=
"keep",
enabled=
"y",
344 addr=
"0x000100d0",
func=
"main",
file=
"hello.c",
line=
"5",
times=
"0"},
345 bkpt={
number=
"2",
type=
"breakpoint",
disp=
"keep",
enabled=
"y",
346 addr=
"0x00010114",
func=
"foo",
file=
"hello.c",
line=
"13",
times=
"0"}]}
350 <p>Here's an example of the result when there are no breakpoints:
352 <pre class=
"smallexample"> (gdb)
354 ^done,BreakpointTable={
nr_rows=
"0",
nr_cols=
"6",
355 hdr=[{
width=
"3",
alignment=
"-1",
col_name=
"number",
colhdr=
"Num"},
356 {
width=
"14",
alignment=
"-1",
col_name=
"type",
colhdr=
"Type"},
357 {
width=
"4",
alignment=
"-1",
col_name=
"disp",
colhdr=
"Disp"},
358 {
width=
"3",
alignment=
"-1",
col_name=
"enabled",
colhdr=
"Enb"},
359 {
width=
"10",
alignment=
"-1",
col_name=
"addr",
colhdr=
"Address"},
360 {
width=
"40",
alignment=
"2",
col_name=
"what",
colhdr=
"What"}],
365 <h4 class=
"subheading">The
<code>-break-watch
</code> Command
</h4>
367 <h5 class=
"subsubheading">Synopsis
</h5>
369 <pre class=
"example"> -break-watch [ -a | -r ]
372 <p>Create a watchpoint. With the
<code>-a
</code> option it will create an
373 <dfn>access
</dfn> watchpoint, i.e. a watchpoint that triggers either on a
374 read from or on a write to the memory location. With the
<code>-r
</code>
375 option, the watchpoint created is a
<dfn>read
</dfn> watchpoint, i.e. it will
376 trigger only when the memory location is accessed for reading. Without
377 either of the options, the watchpoint created is a regular watchpoint,
378 i.e. it will trigger when the memory location is accessed for writing.
379 See
<a href=
"Set-Watchpoints.html#Set%20Watchpoints">Setting watchpoints
</a>.
381 <p>Note that
<code>-break-list
</code> will report a single list of watchpoints and
382 breakpoints inserted.
384 <h5 class=
"subsubheading">GDB Command
</h5>
386 <p>The corresponding GDB commands are
<code>watch
</code>,
<code>awatch
</code>, and
389 <h5 class=
"subsubheading">Example
</h5>
391 <p>Setting a watchpoint on a variable in the
<code>main
</code> function:
393 <pre class=
"smallexample"> (gdb)
395 ^done,wpt={
number=
"2",
exp=
"x"}
399 ^done,
reason=
"watchpoint-trigger",wpt={
number=
"2",
exp=
"x"},
400 value={
old=
"-268439212",
new=
"55"},
401 frame={
func=
"main",args=[],
file=
"recursive2.c",
line=
"5"}
405 <p>Setting a watchpoint on a variable local to a function. GDB will stop
406 the program execution twice: first for the variable changing value, then
407 for the watchpoint going out of scope.
409 <pre class=
"smallexample"> (gdb)
411 ^done,wpt={
number=
"5",
exp=
"C"}
415 ^done,
reason=
"watchpoint-trigger",
416 wpt={
number=
"5",
exp=
"C"},value={
old=
"-276895068",
new=
"3"},
417 frame={
func=
"callee4",args=[],
418 file=
"../../../devo/gdb/testsuite/gdb.mi/basics.c",
line=
"13"}
422 ^done,
reason=
"watchpoint-scope",
wpnum=
"5",
423 frame={
func=
"callee3",args=[{
name=
"strarg",
424 value=
"0x11940 \"A string argument.\
""}],
425 file=
"../../../devo/gdb/testsuite/gdb.mi/basics.c",
line=
"18"}
429 <p>Listing breakpoints and watchpoints, at different points in the program
430 execution. Note that once the watchpoint goes out of scope, it is
433 <pre class=
"smallexample"> (gdb)
435 ^done,wpt={
number=
"2",
exp=
"C"}
438 ^done,BreakpointTable={
nr_rows=
"2",
nr_cols=
"6",
439 hdr=[{
width=
"3",
alignment=
"-1",
col_name=
"number",
colhdr=
"Num"},
440 {
width=
"14",
alignment=
"-1",
col_name=
"type",
colhdr=
"Type"},
441 {
width=
"4",
alignment=
"-1",
col_name=
"disp",
colhdr=
"Disp"},
442 {
width=
"3",
alignment=
"-1",
col_name=
"enabled",
colhdr=
"Enb"},
443 {
width=
"10",
alignment=
"-1",
col_name=
"addr",
colhdr=
"Address"},
444 {
width=
"40",
alignment=
"2",
col_name=
"what",
colhdr=
"What"}],
445 body=[bkpt={
number=
"1",
type=
"breakpoint",
disp=
"keep",
enabled=
"y",
446 addr=
"0x00010734",
func=
"callee4",
447 file=
"../../../devo/gdb/testsuite/gdb.mi/basics.c",
line=
"8",
times=
"1"},
448 bkpt={
number=
"2",
type=
"watchpoint",
disp=
"keep",
449 enabled=
"y",
addr=
"",
what=
"C",
times=
"0"}]}
453 ^done,
reason=
"watchpoint-trigger",wpt={
number=
"2",
exp=
"C"},
454 value={
old=
"-276895068",
new=
"3"},
455 frame={
func=
"callee4",args=[],
456 file=
"../../../devo/gdb/testsuite/gdb.mi/basics.c",
line=
"13"}
459 ^done,BreakpointTable={
nr_rows=
"2",
nr_cols=
"6",
460 hdr=[{
width=
"3",
alignment=
"-1",
col_name=
"number",
colhdr=
"Num"},
461 {
width=
"14",
alignment=
"-1",
col_name=
"type",
colhdr=
"Type"},
462 {
width=
"4",
alignment=
"-1",
col_name=
"disp",
colhdr=
"Disp"},
463 {
width=
"3",
alignment=
"-1",
col_name=
"enabled",
colhdr=
"Enb"},
464 {
width=
"10",
alignment=
"-1",
col_name=
"addr",
colhdr=
"Address"},
465 {
width=
"40",
alignment=
"2",
col_name=
"what",
colhdr=
"What"}],
466 body=[bkpt={
number=
"1",
type=
"breakpoint",
disp=
"keep",
enabled=
"y",
467 addr=
"0x00010734",
func=
"callee4",
468 file=
"../../../devo/gdb/testsuite/gdb.mi/basics.c",
line=
"8",
times=
"1"},
469 bkpt={
number=
"2",
type=
"watchpoint",
disp=
"keep",
470 enabled=
"y",
addr=
"",
what=
"C",
times=
"-5"}]}
474 ^done,
reason=
"watchpoint-scope",
wpnum=
"2",
475 frame={
func=
"callee3",args=[{
name=
"strarg",
476 value=
"0x11940 \"A string argument.\
""}],
477 file=
"../../../devo/gdb/testsuite/gdb.mi/basics.c",
line=
"18"}
480 ^done,BreakpointTable={
nr_rows=
"1",
nr_cols=
"6",
481 hdr=[{
width=
"3",
alignment=
"-1",
col_name=
"number",
colhdr=
"Num"},
482 {
width=
"14",
alignment=
"-1",
col_name=
"type",
colhdr=
"Type"},
483 {
width=
"4",
alignment=
"-1",
col_name=
"disp",
colhdr=
"Disp"},
484 {
width=
"3",
alignment=
"-1",
col_name=
"enabled",
colhdr=
"Enb"},
485 {
width=
"10",
alignment=
"-1",
col_name=
"addr",
colhdr=
"Address"},
486 {
width=
"40",
alignment=
"2",
col_name=
"what",
colhdr=
"What"}],
487 body=[bkpt={
number=
"1",
type=
"breakpoint",
disp=
"keep",
enabled=
"y",
488 addr=
"0x00010734",
func=
"callee4",
489 file=
"../../../devo/gdb/testsuite/gdb.mi/basics.c",
line=
"8",
times=
"1"}]}