1 \input texinfo @c -*-texinfo-*-
2 @c Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998,
3 @c 1999, 2000, 2001, 2002, 2003, 2004, 2005
4 @c Free Software Foundation, Inc.
7 @c makeinfo ignores cmds prev to setfilename, so its arg cannot make use
8 @c of @set vars. However, you can override filename with makeinfo -o.
13 @settitle Debugging with @value{GDBN}
14 @setchapternewpage odd
25 @c readline appendices use @vindex, @findex and @ftable,
26 @c annotate.texi and gdbmi use @findex.
30 @c !!set GDB manual's edition---not the same as GDB version!
31 @c This is updated by GNU Press.
34 @c !!set GDB edit command default editor
37 @c THIS MANUAL REQUIRES TEXINFO 4.0 OR LATER.
39 @c This is a dir.info fragment to support semi-automated addition of
40 @c manuals to an info tree.
41 @dircategory Software development
43 * Gdb: (gdb). The GNU debugger.
47 This file documents the @sc{gnu} debugger @value{GDBN}.
50 This is the @value{EDITION} Edition, of @cite{Debugging with
51 @value{GDBN}: the @sc{gnu} Source-Level Debugger} for @value{GDBN}
52 Version @value{GDBVN}.
54 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998,@*
55 1999, 2000, 2001, 2002, 2003, 2004, 2005@*
56 Free Software Foundation, Inc.
58 Permission is granted to copy, distribute and/or modify this document
59 under the terms of the GNU Free Documentation License, Version 1.1 or
60 any later version published by the Free Software Foundation; with the
61 Invariant Sections being ``Free Software'' and ``Free Software Needs
62 Free Documentation'', with the Front-Cover Texts being ``A GNU Manual,''
63 and with the Back-Cover Texts as in (a) below.
65 (a) The Free Software Foundation's Back-Cover Text is: ``You have
66 freedom to copy and modify this GNU Manual, like GNU software. Copies
67 published by the Free Software Foundation raise funds for GNU
72 @title Debugging with @value{GDBN}
73 @subtitle The @sc{gnu} Source-Level Debugger
75 @subtitle @value{EDITION} Edition, for @value{GDBN} version @value{GDBVN}
76 @author Richard Stallman, Roland Pesch, Stan Shebs, et al.
80 \hfill (Send bugs and comments on @value{GDBN} to bug-gdb\@gnu.org.)\par
81 \hfill {\it Debugging with @value{GDBN}}\par
82 \hfill \TeX{}info \texinfoversion\par
86 @vskip 0pt plus 1filll
87 Copyright @copyright{} 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
88 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
89 Free Software Foundation, Inc.
91 Published by the Free Software Foundation @*
92 59 Temple Place - Suite 330, @*
93 Boston, MA 02111-1307 USA @*
96 Permission is granted to copy, distribute and/or modify this document
97 under the terms of the GNU Free Documentation License, Version 1.1 or
98 any later version published by the Free Software Foundation; with the
99 Invariant Sections being ``Free Software'' and ``Free Software Needs
100 Free Documentation'', with the Front-Cover Texts being ``A GNU Manual,''
101 and with the Back-Cover Texts as in (a) below.
103 (a) The Free Software Foundation's Back-Cover Text is: ``You have
104 freedom to copy and modify this GNU Manual, like GNU software. Copies
105 published by the Free Software Foundation raise funds for GNU
111 @node Top, Summary, (dir), (dir)
113 @top Debugging with @value{GDBN}
115 This file describes @value{GDBN}, the @sc{gnu} symbolic debugger.
117 This is the @value{EDITION} Edition, for @value{GDBN} Version
120 Copyright (C) 1988-2005 Free Software Foundation, Inc.
123 * Summary:: Summary of @value{GDBN}
124 * Sample Session:: A sample @value{GDBN} session
126 * Invocation:: Getting in and out of @value{GDBN}
127 * Commands:: @value{GDBN} commands
128 * Running:: Running programs under @value{GDBN}
129 * Stopping:: Stopping and continuing
130 * Stack:: Examining the stack
131 * Source:: Examining source files
132 * Data:: Examining data
133 * Macros:: Preprocessor Macros
134 * Tracepoints:: Debugging remote targets non-intrusively
135 * Overlays:: Debugging programs that use overlays
137 * Languages:: Using @value{GDBN} with different languages
139 * Symbols:: Examining the symbol table
140 * Altering:: Altering execution
141 * GDB Files:: @value{GDBN} files
142 * Targets:: Specifying a debugging target
143 * Remote Debugging:: Debugging remote programs
144 * Configurations:: Configuration-specific information
145 * Controlling GDB:: Controlling @value{GDBN}
146 * Sequences:: Canned sequences of commands
147 * TUI:: @value{GDBN} Text User Interface
148 * Interpreters:: Command Interpreters
149 * Emacs:: Using @value{GDBN} under @sc{gnu} Emacs
150 * Annotations:: @value{GDBN}'s annotation interface.
151 * GDB/MI:: @value{GDBN}'s Machine Interface.
153 * GDB Bugs:: Reporting bugs in @value{GDBN}
154 * Formatting Documentation:: How to format and print @value{GDBN} documentation
156 * Command Line Editing:: Command Line Editing
157 * Using History Interactively:: Using History Interactively
158 * Installing GDB:: Installing GDB
159 * Maintenance Commands:: Maintenance Commands
160 * Remote Protocol:: GDB Remote Serial Protocol
161 * Agent Expressions:: The GDB Agent Expression Mechanism
162 * Copying:: GNU General Public License says
163 how you can copy and share GDB
164 * GNU Free Documentation License:: The license for this documentation
173 @unnumbered Summary of @value{GDBN}
175 The purpose of a debugger such as @value{GDBN} is to allow you to see what is
176 going on ``inside'' another program while it executes---or what another
177 program was doing at the moment it crashed.
179 @value{GDBN} can do four main kinds of things (plus other things in support of
180 these) to help you catch bugs in the act:
184 Start your program, specifying anything that might affect its behavior.
187 Make your program stop on specified conditions.
190 Examine what has happened, when your program has stopped.
193 Change things in your program, so you can experiment with correcting the
194 effects of one bug and go on to learn about another.
197 You can use @value{GDBN} to debug programs written in C and C@t{++}.
198 For more information, see @ref{Supported languages,,Supported languages}.
199 For more information, see @ref{C,,C and C++}.
202 Support for Modula-2 is partial. For information on Modula-2, see
203 @ref{Modula-2,,Modula-2}.
206 Debugging Pascal programs which use sets, subranges, file variables, or
207 nested functions does not currently work. @value{GDBN} does not support
208 entering expressions, printing values, or similar features using Pascal
212 @value{GDBN} can be used to debug programs written in Fortran, although
213 it may be necessary to refer to some variables with a trailing
216 @value{GDBN} can be used to debug programs written in Objective-C,
217 using either the Apple/NeXT or the GNU Objective-C runtime.
220 * Free Software:: Freely redistributable software
221 * Contributors:: Contributors to GDB
225 @unnumberedsec Free software
227 @value{GDBN} is @dfn{free software}, protected by the @sc{gnu}
228 General Public License
229 (GPL). The GPL gives you the freedom to copy or adapt a licensed
230 program---but every person getting a copy also gets with it the
231 freedom to modify that copy (which means that they must get access to
232 the source code), and the freedom to distribute further copies.
233 Typical software companies use copyrights to limit your freedoms; the
234 Free Software Foundation uses the GPL to preserve these freedoms.
236 Fundamentally, the General Public License is a license which says that
237 you have these freedoms and that you cannot take these freedoms away
240 @unnumberedsec Free Software Needs Free Documentation
242 The biggest deficiency in the free software community today is not in
243 the software---it is the lack of good free documentation that we can
244 include with the free software. Many of our most important
245 programs do not come with free reference manuals and free introductory
246 texts. Documentation is an essential part of any software package;
247 when an important free software package does not come with a free
248 manual and a free tutorial, that is a major gap. We have many such
251 Consider Perl, for instance. The tutorial manuals that people
252 normally use are non-free. How did this come about? Because the
253 authors of those manuals published them with restrictive terms---no
254 copying, no modification, source files not available---which exclude
255 them from the free software world.
257 That wasn't the first time this sort of thing happened, and it was far
258 from the last. Many times we have heard a GNU user eagerly describe a
259 manual that he is writing, his intended contribution to the community,
260 only to learn that he had ruined everything by signing a publication
261 contract to make it non-free.
263 Free documentation, like free software, is a matter of freedom, not
264 price. The problem with the non-free manual is not that publishers
265 charge a price for printed copies---that in itself is fine. (The Free
266 Software Foundation sells printed copies of manuals, too.) The
267 problem is the restrictions on the use of the manual. Free manuals
268 are available in source code form, and give you permission to copy and
269 modify. Non-free manuals do not allow this.
271 The criteria of freedom for a free manual are roughly the same as for
272 free software. Redistribution (including the normal kinds of
273 commercial redistribution) must be permitted, so that the manual can
274 accompany every copy of the program, both on-line and on paper.
276 Permission for modification of the technical content is crucial too.
277 When people modify the software, adding or changing features, if they
278 are conscientious they will change the manual too---so they can
279 provide accurate and clear documentation for the modified program. A
280 manual that leaves you no choice but to write a new manual to document
281 a changed version of the program is not really available to our
284 Some kinds of limits on the way modification is handled are
285 acceptable. For example, requirements to preserve the original
286 author's copyright notice, the distribution terms, or the list of
287 authors, are ok. It is also no problem to require modified versions
288 to include notice that they were modified. Even entire sections that
289 may not be deleted or changed are acceptable, as long as they deal
290 with nontechnical topics (like this one). These kinds of restrictions
291 are acceptable because they don't obstruct the community's normal use
294 However, it must be possible to modify all the @emph{technical}
295 content of the manual, and then distribute the result in all the usual
296 media, through all the usual channels. Otherwise, the restrictions
297 obstruct the use of the manual, it is not free, and we need another
298 manual to replace it.
300 Please spread the word about this issue. Our community continues to
301 lose manuals to proprietary publishing. If we spread the word that
302 free software needs free reference manuals and free tutorials, perhaps
303 the next person who wants to contribute by writing documentation will
304 realize, before it is too late, that only free manuals contribute to
305 the free software community.
307 If you are writing documentation, please insist on publishing it under
308 the GNU Free Documentation License or another free documentation
309 license. Remember that this decision requires your approval---you
310 don't have to let the publisher decide. Some commercial publishers
311 will use a free license if you insist, but they will not propose the
312 option; it is up to you to raise the issue and say firmly that this is
313 what you want. If the publisher you are dealing with refuses, please
314 try other publishers. If you're not sure whether a proposed license
315 is free, write to @email{licensing@@gnu.org}.
317 You can encourage commercial publishers to sell more free, copylefted
318 manuals and tutorials by buying them, and particularly by buying
319 copies from the publishers that paid for their writing or for major
320 improvements. Meanwhile, try to avoid buying non-free documentation
321 at all. Check the distribution terms of a manual before you buy it,
322 and insist that whoever seeks your business must respect your freedom.
323 Check the history of the book, and try to reward the publishers that
324 have paid or pay the authors to work on it.
326 The Free Software Foundation maintains a list of free documentation
327 published by other publishers, at
328 @url{http://www.fsf.org/doc/other-free-books.html}.
331 @unnumberedsec Contributors to @value{GDBN}
333 Richard Stallman was the original author of @value{GDBN}, and of many
334 other @sc{gnu} programs. Many others have contributed to its
335 development. This section attempts to credit major contributors. One
336 of the virtues of free software is that everyone is free to contribute
337 to it; with regret, we cannot actually acknowledge everyone here. The
338 file @file{ChangeLog} in the @value{GDBN} distribution approximates a
339 blow-by-blow account.
341 Changes much prior to version 2.0 are lost in the mists of time.
344 @emph{Plea:} Additions to this section are particularly welcome. If you
345 or your friends (or enemies, to be evenhanded) have been unfairly
346 omitted from this list, we would like to add your names!
349 So that they may not regard their many labors as thankless, we
350 particularly thank those who shepherded @value{GDBN} through major
352 Andrew Cagney (releases 6.3, 6.2, 6.1, 6.0, 5.3, 5.2, 5.1 and 5.0);
353 Jim Blandy (release 4.18);
354 Jason Molenda (release 4.17);
355 Stan Shebs (release 4.14);
356 Fred Fish (releases 4.16, 4.15, 4.13, 4.12, 4.11, 4.10, and 4.9);
357 Stu Grossman and John Gilmore (releases 4.8, 4.7, 4.6, 4.5, and 4.4);
358 John Gilmore (releases 4.3, 4.2, 4.1, 4.0, and 3.9);
359 Jim Kingdon (releases 3.5, 3.4, and 3.3);
360 and Randy Smith (releases 3.2, 3.1, and 3.0).
362 Richard Stallman, assisted at various times by Peter TerMaat, Chris
363 Hanson, and Richard Mlynarik, handled releases through 2.8.
365 Michael Tiemann is the author of most of the @sc{gnu} C@t{++} support
366 in @value{GDBN}, with significant additional contributions from Per
367 Bothner and Daniel Berlin. James Clark wrote the @sc{gnu} C@t{++}
368 demangler. Early work on C@t{++} was by Peter TerMaat (who also did
369 much general update work leading to release 3.0).
371 @value{GDBN} uses the BFD subroutine library to examine multiple
372 object-file formats; BFD was a joint project of David V.
373 Henkel-Wallace, Rich Pixley, Steve Chamberlain, and John Gilmore.
375 David Johnson wrote the original COFF support; Pace Willison did
376 the original support for encapsulated COFF.
378 Brent Benson of Harris Computer Systems contributed DWARF 2 support.
380 Adam de Boor and Bradley Davis contributed the ISI Optimum V support.
381 Per Bothner, Noboyuki Hikichi, and Alessandro Forin contributed MIPS
383 Jean-Daniel Fekete contributed Sun 386i support.
384 Chris Hanson improved the HP9000 support.
385 Noboyuki Hikichi and Tomoyuki Hasei contributed Sony/News OS 3 support.
386 David Johnson contributed Encore Umax support.
387 Jyrki Kuoppala contributed Altos 3068 support.
388 Jeff Law contributed HP PA and SOM support.
389 Keith Packard contributed NS32K support.
390 Doug Rabson contributed Acorn Risc Machine support.
391 Bob Rusk contributed Harris Nighthawk CX-UX support.
392 Chris Smith contributed Convex support (and Fortran debugging).
393 Jonathan Stone contributed Pyramid support.
394 Michael Tiemann contributed SPARC support.
395 Tim Tucker contributed support for the Gould NP1 and Gould Powernode.
396 Pace Willison contributed Intel 386 support.
397 Jay Vosburgh contributed Symmetry support.
398 Marko Mlinar contributed OpenRISC 1000 support.
400 Andreas Schwab contributed M68K @sc{gnu}/Linux support.
402 Rich Schaefer and Peter Schauer helped with support of SunOS shared
405 Jay Fenlason and Roland McGrath ensured that @value{GDBN} and GAS agree
406 about several machine instruction sets.
408 Patrick Duval, Ted Goldstein, Vikram Koka and Glenn Engel helped develop
409 remote debugging. Intel Corporation, Wind River Systems, AMD, and ARM
410 contributed remote debugging modules for the i960, VxWorks, A29K UDI,
411 and RDI targets, respectively.
413 Brian Fox is the author of the readline libraries providing
414 command-line editing and command history.
416 Andrew Beers of SUNY Buffalo wrote the language-switching code, the
417 Modula-2 support, and contributed the Languages chapter of this manual.
419 Fred Fish wrote most of the support for Unix System Vr4.
420 He also enhanced the command-completion support to cover C@t{++} overloaded
423 Hitachi America (now Renesas America), Ltd. sponsored the support for
424 H8/300, H8/500, and Super-H processors.
426 NEC sponsored the support for the v850, Vr4xxx, and Vr5xxx processors.
428 Mitsubishi (now Renesas) sponsored the support for D10V, D30V, and M32R/D
431 Toshiba sponsored the support for the TX39 Mips processor.
433 Matsushita sponsored the support for the MN10200 and MN10300 processors.
435 Fujitsu sponsored the support for SPARClite and FR30 processors.
437 Kung Hsu, Jeff Law, and Rick Sladkey added support for hardware
440 Michael Snyder added support for tracepoints.
442 Stu Grossman wrote gdbserver.
444 Jim Kingdon, Peter Schauer, Ian Taylor, and Stu Grossman made
445 nearly innumerable bug fixes and cleanups throughout @value{GDBN}.
447 The following people at the Hewlett-Packard Company contributed
448 support for the PA-RISC 2.0 architecture, HP-UX 10.20, 10.30, and 11.0
449 (narrow mode), HP's implementation of kernel threads, HP's aC@t{++}
450 compiler, and the Text User Interface (nee Terminal User Interface):
451 Ben Krepp, Richard Title, John Bishop, Susan Macchia, Kathy Mann,
452 Satish Pai, India Paul, Steve Rehrauer, and Elena Zannoni. Kim Haase
453 provided HP-specific information in this manual.
455 DJ Delorie ported @value{GDBN} to MS-DOS, for the DJGPP project.
456 Robert Hoehne made significant contributions to the DJGPP port.
458 Cygnus Solutions has sponsored @value{GDBN} maintenance and much of its
459 development since 1991. Cygnus engineers who have worked on @value{GDBN}
460 fulltime include Mark Alexander, Jim Blandy, Per Bothner, Kevin
461 Buettner, Edith Epstein, Chris Faylor, Fred Fish, Martin Hunt, Jim
462 Ingham, John Gilmore, Stu Grossman, Kung Hsu, Jim Kingdon, John Metzler,
463 Fernando Nasser, Geoffrey Noer, Dawn Perchik, Rich Pixley, Zdenek
464 Radouch, Keith Seitz, Stan Shebs, David Taylor, and Elena Zannoni. In
465 addition, Dave Brolley, Ian Carmichael, Steve Chamberlain, Nick Clifton,
466 JT Conklin, Stan Cox, DJ Delorie, Ulrich Drepper, Frank Eigler, Doug
467 Evans, Sean Fagan, David Henkel-Wallace, Richard Henderson, Jeff
468 Holcomb, Jeff Law, Jim Lemke, Tom Lord, Bob Manson, Michael Meissner,
469 Jason Merrill, Catherine Moore, Drew Moseley, Ken Raeburn, Gavin
470 Romig-Koch, Rob Savoye, Jamie Smith, Mike Stump, Ian Taylor, Angela
471 Thomas, Michael Tiemann, Tom Tromey, Ron Unrau, Jim Wilson, and David
472 Zuhn have made contributions both large and small.
474 Andrew Cagney, Fernando Nasser, and Elena Zannoni, while working for
475 Cygnus Solutions, implemented the original @sc{gdb/mi} interface.
477 Jim Blandy added support for preprocessor macros, while working for Red
480 Andrew Cagney designed @value{GDBN}'s architecture vector. Many
481 people including Andrew Cagney, Stephane Carrez, Randolph Chung, Nick
482 Duffek, Richard Henderson, Mark Kettenis, Grace Sainsbury, Kei
483 Sakamoto, Yoshinori Sato, Michael Snyder, Andreas Schwab, Jason
484 Thorpe, Corinna Vinschen, Ulrich Weigand, and Elena Zannoni, helped
485 with the migration of old architectures to this new framework.
488 @chapter A Sample @value{GDBN} Session
490 You can use this manual at your leisure to read all about @value{GDBN}.
491 However, a handful of commands are enough to get started using the
492 debugger. This chapter illustrates those commands.
495 In this sample session, we emphasize user input like this: @b{input},
496 to make it easier to pick out from the surrounding output.
499 @c FIXME: this example may not be appropriate for some configs, where
500 @c FIXME...primary interest is in remote use.
502 One of the preliminary versions of @sc{gnu} @code{m4} (a generic macro
503 processor) exhibits the following bug: sometimes, when we change its
504 quote strings from the default, the commands used to capture one macro
505 definition within another stop working. In the following short @code{m4}
506 session, we define a macro @code{foo} which expands to @code{0000}; we
507 then use the @code{m4} built-in @code{defn} to define @code{bar} as the
508 same thing. However, when we change the open quote string to
509 @code{<QUOTE>} and the close quote string to @code{<UNQUOTE>}, the same
510 procedure fails to define a new synonym @code{baz}:
519 @b{define(bar,defn(`foo'))}
523 @b{changequote(<QUOTE>,<UNQUOTE>)}
525 @b{define(baz,defn(<QUOTE>foo<UNQUOTE>))}
528 m4: End of input: 0: fatal error: EOF in string
532 Let us use @value{GDBN} to try to see what is going on.
535 $ @b{@value{GDBP} m4}
536 @c FIXME: this falsifies the exact text played out, to permit smallbook
537 @c FIXME... format to come out better.
538 @value{GDBN} is free software and you are welcome to distribute copies
539 of it under certain conditions; type "show copying" to see
541 There is absolutely no warranty for @value{GDBN}; type "show warranty"
544 @value{GDBN} @value{GDBVN}, Copyright 1999 Free Software Foundation, Inc...
549 @value{GDBN} reads only enough symbol data to know where to find the
550 rest when needed; as a result, the first prompt comes up very quickly.
551 We now tell @value{GDBN} to use a narrower display width than usual, so
552 that examples fit in this manual.
555 (@value{GDBP}) @b{set width 70}
559 We need to see how the @code{m4} built-in @code{changequote} works.
560 Having looked at the source, we know the relevant subroutine is
561 @code{m4_changequote}, so we set a breakpoint there with the @value{GDBN}
562 @code{break} command.
565 (@value{GDBP}) @b{break m4_changequote}
566 Breakpoint 1 at 0x62f4: file builtin.c, line 879.
570 Using the @code{run} command, we start @code{m4} running under @value{GDBN}
571 control; as long as control does not reach the @code{m4_changequote}
572 subroutine, the program runs as usual:
575 (@value{GDBP}) @b{run}
576 Starting program: /work/Editorial/gdb/gnu/m4/m4
584 To trigger the breakpoint, we call @code{changequote}. @value{GDBN}
585 suspends execution of @code{m4}, displaying information about the
586 context where it stops.
589 @b{changequote(<QUOTE>,<UNQUOTE>)}
591 Breakpoint 1, m4_changequote (argc=3, argv=0x33c70)
593 879 if (bad_argc(TOKEN_DATA_TEXT(argv[0]),argc,1,3))
597 Now we use the command @code{n} (@code{next}) to advance execution to
598 the next line of the current function.
602 882 set_quotes((argc >= 2) ? TOKEN_DATA_TEXT(argv[1])\
607 @code{set_quotes} looks like a promising subroutine. We can go into it
608 by using the command @code{s} (@code{step}) instead of @code{next}.
609 @code{step} goes to the next line to be executed in @emph{any}
610 subroutine, so it steps into @code{set_quotes}.
614 set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
616 530 if (lquote != def_lquote)
620 The display that shows the subroutine where @code{m4} is now
621 suspended (and its arguments) is called a stack frame display. It
622 shows a summary of the stack. We can use the @code{backtrace}
623 command (which can also be spelled @code{bt}), to see where we are
624 in the stack as a whole: the @code{backtrace} command displays a
625 stack frame for each active subroutine.
628 (@value{GDBP}) @b{bt}
629 #0 set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
631 #1 0x6344 in m4_changequote (argc=3, argv=0x33c70)
633 #2 0x8174 in expand_macro (sym=0x33320) at macro.c:242
634 #3 0x7a88 in expand_token (obs=0x0, t=209696, td=0xf7fffa30)
636 #4 0x79dc in expand_input () at macro.c:40
637 #5 0x2930 in main (argc=0, argv=0xf7fffb20) at m4.c:195
641 We step through a few more lines to see what happens. The first two
642 times, we can use @samp{s}; the next two times we use @code{n} to avoid
643 falling into the @code{xstrdup} subroutine.
647 0x3b5c 532 if (rquote != def_rquote)
649 0x3b80 535 lquote = (lq == nil || *lq == '\0') ? \
650 def_lquote : xstrdup(lq);
652 536 rquote = (rq == nil || *rq == '\0') ? def_rquote\
655 538 len_lquote = strlen(rquote);
659 The last line displayed looks a little odd; we can examine the variables
660 @code{lquote} and @code{rquote} to see if they are in fact the new left
661 and right quotes we specified. We use the command @code{p}
662 (@code{print}) to see their values.
665 (@value{GDBP}) @b{p lquote}
666 $1 = 0x35d40 "<QUOTE>"
667 (@value{GDBP}) @b{p rquote}
668 $2 = 0x35d50 "<UNQUOTE>"
672 @code{lquote} and @code{rquote} are indeed the new left and right quotes.
673 To look at some context, we can display ten lines of source
674 surrounding the current line with the @code{l} (@code{list}) command.
680 535 lquote = (lq == nil || *lq == '\0') ? def_lquote\
682 536 rquote = (rq == nil || *rq == '\0') ? def_rquote\
685 538 len_lquote = strlen(rquote);
686 539 len_rquote = strlen(lquote);
693 Let us step past the two lines that set @code{len_lquote} and
694 @code{len_rquote}, and then examine the values of those variables.
698 539 len_rquote = strlen(lquote);
701 (@value{GDBP}) @b{p len_lquote}
703 (@value{GDBP}) @b{p len_rquote}
708 That certainly looks wrong, assuming @code{len_lquote} and
709 @code{len_rquote} are meant to be the lengths of @code{lquote} and
710 @code{rquote} respectively. We can set them to better values using
711 the @code{p} command, since it can print the value of
712 any expression---and that expression can include subroutine calls and
716 (@value{GDBP}) @b{p len_lquote=strlen(lquote)}
718 (@value{GDBP}) @b{p len_rquote=strlen(rquote)}
723 Is that enough to fix the problem of using the new quotes with the
724 @code{m4} built-in @code{defn}? We can allow @code{m4} to continue
725 executing with the @code{c} (@code{continue}) command, and then try the
726 example that caused trouble initially:
732 @b{define(baz,defn(<QUOTE>foo<UNQUOTE>))}
739 Success! The new quotes now work just as well as the default ones. The
740 problem seems to have been just the two typos defining the wrong
741 lengths. We allow @code{m4} exit by giving it an EOF as input:
745 Program exited normally.
749 The message @samp{Program exited normally.} is from @value{GDBN}; it
750 indicates @code{m4} has finished executing. We can end our @value{GDBN}
751 session with the @value{GDBN} @code{quit} command.
754 (@value{GDBP}) @b{quit}
758 @chapter Getting In and Out of @value{GDBN}
760 This chapter discusses how to start @value{GDBN}, and how to get out of it.
764 type @samp{@value{GDBP}} to start @value{GDBN}.
766 type @kbd{quit} or @kbd{C-d} to exit.
770 * Invoking GDB:: How to start @value{GDBN}
771 * Quitting GDB:: How to quit @value{GDBN}
772 * Shell Commands:: How to use shell commands inside @value{GDBN}
773 * Logging output:: How to log @value{GDBN}'s output to a file
777 @section Invoking @value{GDBN}
779 Invoke @value{GDBN} by running the program @code{@value{GDBP}}. Once started,
780 @value{GDBN} reads commands from the terminal until you tell it to exit.
782 You can also run @code{@value{GDBP}} with a variety of arguments and options,
783 to specify more of your debugging environment at the outset.
785 The command-line options described here are designed
786 to cover a variety of situations; in some environments, some of these
787 options may effectively be unavailable.
789 The most usual way to start @value{GDBN} is with one argument,
790 specifying an executable program:
793 @value{GDBP} @var{program}
797 You can also start with both an executable program and a core file
801 @value{GDBP} @var{program} @var{core}
804 You can, instead, specify a process ID as a second argument, if you want
805 to debug a running process:
808 @value{GDBP} @var{program} 1234
812 would attach @value{GDBN} to process @code{1234} (unless you also have a file
813 named @file{1234}; @value{GDBN} does check for a core file first).
815 Taking advantage of the second command-line argument requires a fairly
816 complete operating system; when you use @value{GDBN} as a remote
817 debugger attached to a bare board, there may not be any notion of
818 ``process'', and there is often no way to get a core dump. @value{GDBN}
819 will warn you if it is unable to attach or to read core dumps.
821 You can optionally have @code{@value{GDBP}} pass any arguments after the
822 executable file to the inferior using @code{--args}. This option stops
825 gdb --args gcc -O2 -c foo.c
827 This will cause @code{@value{GDBP}} to debug @code{gcc}, and to set
828 @code{gcc}'s command-line arguments (@pxref{Arguments}) to @samp{-O2 -c foo.c}.
830 You can run @code{@value{GDBP}} without printing the front material, which describes
831 @value{GDBN}'s non-warranty, by specifying @code{-silent}:
838 You can further control how @value{GDBN} starts up by using command-line
839 options. @value{GDBN} itself can remind you of the options available.
849 to display all available options and briefly describe their use
850 (@samp{@value{GDBP} -h} is a shorter equivalent).
852 All options and command line arguments you give are processed
853 in sequential order. The order makes a difference when the
854 @samp{-x} option is used.
858 * File Options:: Choosing files
859 * Mode Options:: Choosing modes
860 * Startup:: What @value{GDBN} does during startup
864 @subsection Choosing files
866 When @value{GDBN} starts, it reads any arguments other than options as
867 specifying an executable file and core file (or process ID). This is
868 the same as if the arguments were specified by the @samp{-se} and
869 @samp{-c} (or @samp{-p} options respectively. (@value{GDBN} reads the
870 first argument that does not have an associated option flag as
871 equivalent to the @samp{-se} option followed by that argument; and the
872 second argument that does not have an associated option flag, if any, as
873 equivalent to the @samp{-c}/@samp{-p} option followed by that argument.)
874 If the second argument begins with a decimal digit, @value{GDBN} will
875 first attempt to attach to it as a process, and if that fails, attempt
876 to open it as a corefile. If you have a corefile whose name begins with
877 a digit, you can prevent @value{GDBN} from treating it as a pid by
878 prefixing it with @file{./}, eg. @file{./12345}.
880 If @value{GDBN} has not been configured to included core file support,
881 such as for most embedded targets, then it will complain about a second
882 argument and ignore it.
884 Many options have both long and short forms; both are shown in the
885 following list. @value{GDBN} also recognizes the long forms if you truncate
886 them, so long as enough of the option is present to be unambiguous.
887 (If you prefer, you can flag option arguments with @samp{--} rather
888 than @samp{-}, though we illustrate the more usual convention.)
890 @c NOTE: the @cindex entries here use double dashes ON PURPOSE. This
891 @c way, both those who look for -foo and --foo in the index, will find
895 @item -symbols @var{file}
897 @cindex @code{--symbols}
899 Read symbol table from file @var{file}.
901 @item -exec @var{file}
903 @cindex @code{--exec}
905 Use file @var{file} as the executable file to execute when appropriate,
906 and for examining pure data in conjunction with a core dump.
910 Read symbol table from file @var{file} and use it as the executable
913 @item -core @var{file}
915 @cindex @code{--core}
917 Use file @var{file} as a core dump to examine.
919 @item -c @var{number}
920 @item -pid @var{number}
921 @itemx -p @var{number}
924 Connect to process ID @var{number}, as with the @code{attach} command.
925 If there is no such process, @value{GDBN} will attempt to open a core
926 file named @var{number}.
928 @item -command @var{file}
930 @cindex @code{--command}
932 Execute @value{GDBN} commands from file @var{file}. @xref{Command
933 Files,, Command files}.
935 @item -directory @var{directory}
936 @itemx -d @var{directory}
937 @cindex @code{--directory}
939 Add @var{directory} to the path to search for source files.
943 @cindex @code{--readnow}
945 Read each symbol file's entire symbol table immediately, rather than
946 the default, which is to read it incrementally as it is needed.
947 This makes startup slower, but makes future operations faster.
952 @subsection Choosing modes
954 You can run @value{GDBN} in various alternative modes---for example, in
955 batch mode or quiet mode.
962 Do not execute commands found in any initialization files. Normally,
963 @value{GDBN} executes the commands in these files after all the command
964 options and arguments have been processed. @xref{Command Files,,Command
970 @cindex @code{--quiet}
971 @cindex @code{--silent}
973 ``Quiet''. Do not print the introductory and copyright messages. These
974 messages are also suppressed in batch mode.
977 @cindex @code{--batch}
978 Run in batch mode. Exit with status @code{0} after processing all the
979 command files specified with @samp{-x} (and all commands from
980 initialization files, if not inhibited with @samp{-n}). Exit with
981 nonzero status if an error occurs in executing the @value{GDBN} commands
982 in the command files.
984 Batch mode may be useful for running @value{GDBN} as a filter, for
985 example to download and run a program on another computer; in order to
986 make this more useful, the message
989 Program exited normally.
993 (which is ordinarily issued whenever a program running under
994 @value{GDBN} control terminates) is not issued when running in batch
998 @cindex @code{--batch-silent}
999 Run in batch mode exactly like @samp{-batch}, but totally silently. All
1000 @value{GDBN} output to @code{stdout} is prevented (@code{stderr} is
1001 unaffected). This is much quieter than @samp{-silent} and would be useless
1002 for an interactive session.
1004 This is particularly useful when using targets that give @samp{Loading section}
1005 messages, for example.
1007 Note that targets that give their output via @value{GDBN}, as opposed to
1008 writing directly to @code{stdout}, will also be made silent.
1010 @item -return-child-result
1011 @cindex @code{--return-child-result}
1012 The return code from @value{GDBN} will be the return code from the child
1013 process (the process being debugged), with the following exceptions:
1017 @value{GDBN} exits abnormally. E.g., due to an incorrect argument or an
1018 internal error. In this case the exit code is the same as it would have been
1019 without @samp{-return-child-result}.
1021 The user quits with an explicit value. E.g., @samp{quit 1}.
1023 The child process never runs, or is not allowed to terminate, in which case
1024 the exit code will be -1.
1027 This option is useful in conjunction with @samp{-batch} or @samp{-batch-silent},
1028 when @value{GDBN} is being used as a remote program loader or simulator
1033 @cindex @code{--nowindows}
1035 ``No windows''. If @value{GDBN} comes with a graphical user interface
1036 (GUI) built in, then this option tells @value{GDBN} to only use the command-line
1037 interface. If no GUI is available, this option has no effect.
1041 @cindex @code{--windows}
1043 If @value{GDBN} includes a GUI, then this option requires it to be
1046 @item -cd @var{directory}
1048 Run @value{GDBN} using @var{directory} as its working directory,
1049 instead of the current directory.
1053 @cindex @code{--fullname}
1055 @sc{gnu} Emacs sets this option when it runs @value{GDBN} as a
1056 subprocess. It tells @value{GDBN} to output the full file name and line
1057 number in a standard, recognizable fashion each time a stack frame is
1058 displayed (which includes each time your program stops). This
1059 recognizable format looks like two @samp{\032} characters, followed by
1060 the file name, line number and character position separated by colons,
1061 and a newline. The Emacs-to-@value{GDBN} interface program uses the two
1062 @samp{\032} characters as a signal to display the source code for the
1066 @cindex @code{--epoch}
1067 The Epoch Emacs-@value{GDBN} interface sets this option when it runs
1068 @value{GDBN} as a subprocess. It tells @value{GDBN} to modify its print
1069 routines so as to allow Epoch to display values of expressions in a
1072 @item -annotate @var{level}
1073 @cindex @code{--annotate}
1074 This option sets the @dfn{annotation level} inside @value{GDBN}. Its
1075 effect is identical to using @samp{set annotate @var{level}}
1076 (@pxref{Annotations}). The annotation @var{level} controls how much
1077 information @value{GDBN} prints together with its prompt, values of
1078 expressions, source lines, and other types of output. Level 0 is the
1079 normal, level 1 is for use when @value{GDBN} is run as a subprocess of
1080 @sc{gnu} Emacs, level 3 is the maximum annotation suitable for programs
1081 that control @value{GDBN}, and level 2 has been deprecated.
1083 The annotation mechanism has largely been superseded by @sc{gdb/mi}
1087 @cindex @code{--args}
1088 Change interpretation of command line so that arguments following the
1089 executable file are passed as command line arguments to the inferior.
1090 This option stops option processing.
1092 @item -baud @var{bps}
1094 @cindex @code{--baud}
1096 Set the line speed (baud rate or bits per second) of any serial
1097 interface used by @value{GDBN} for remote debugging.
1099 @item -l @var{timeout}
1101 Set the timeout (in seconds) of any communication used by @value{GDBN}
1102 for remote debugging.
1104 @item -tty @var{device}
1105 @itemx -t @var{device}
1106 @cindex @code{--tty}
1108 Run using @var{device} for your program's standard input and output.
1109 @c FIXME: kingdon thinks there is more to -tty. Investigate.
1111 @c resolve the situation of these eventually
1113 @cindex @code{--tui}
1114 Activate the @dfn{Text User Interface} when starting. The Text User
1115 Interface manages several text windows on the terminal, showing
1116 source, assembly, registers and @value{GDBN} command outputs
1117 (@pxref{TUI, ,@value{GDBN} Text User Interface}). Alternatively, the
1118 Text User Interface can be enabled by invoking the program
1119 @samp{gdbtui}. Do not use this option if you run @value{GDBN} from
1120 Emacs (@pxref{Emacs, ,Using @value{GDBN} under @sc{gnu} Emacs}).
1123 @c @cindex @code{--xdb}
1124 @c Run in XDB compatibility mode, allowing the use of certain XDB commands.
1125 @c For information, see the file @file{xdb_trans.html}, which is usually
1126 @c installed in the directory @code{/opt/langtools/wdb/doc} on HP-UX
1129 @item -interpreter @var{interp}
1130 @cindex @code{--interpreter}
1131 Use the interpreter @var{interp} for interface with the controlling
1132 program or device. This option is meant to be set by programs which
1133 communicate with @value{GDBN} using it as a back end.
1134 @xref{Interpreters, , Command Interpreters}.
1136 @samp{--interpreter=mi} (or @samp{--interpreter=mi2}) causes
1137 @value{GDBN} to use the @dfn{@sc{gdb/mi} interface} (@pxref{GDB/MI, ,
1138 The @sc{gdb/mi} Interface}) included since @value{GDBN} version 6.0. The
1139 previous @sc{gdb/mi} interface, included in @value{GDBN} version 5.3 and
1140 selected with @samp{--interpreter=mi1}, is deprecated. Earlier
1141 @sc{gdb/mi} interfaces are no longer supported.
1144 @cindex @code{--write}
1145 Open the executable and core files for both reading and writing. This
1146 is equivalent to the @samp{set write on} command inside @value{GDBN}
1150 @cindex @code{--statistics}
1151 This option causes @value{GDBN} to print statistics about time and
1152 memory usage after it completes each command and returns to the prompt.
1155 @cindex @code{--version}
1156 This option causes @value{GDBN} to print its version number and
1157 no-warranty blurb, and exit.
1162 @subsection What @value{GDBN} does during startup
1163 @cindex @value{GDBN} startup
1165 Here's the description of what @value{GDBN} does during session startup:
1169 Sets up the command interpreter as specified by the command line
1170 (@pxref{Mode Options, interpreter}).
1174 Reads the @dfn{init file} (if any) in your home directory@footnote{On
1175 DOS/Windows systems, the home directory is the one pointed to by the
1176 @code{HOME} environment variable.} and executes all the commands in
1180 Processes command line options and operands.
1183 Reads and executes the commands from init file (if any) in the current
1184 working directory. This is only done if the current directory is
1185 different from your home directory. Thus, you can have more than one
1186 init file, one generic in your home directory, and another, specific
1187 to the program you are debugging, in the directory where you invoke
1191 Reads command files specified by the @samp{-x} option. @xref{Command
1192 Files}, for more details about @value{GDBN} command files.
1195 Reads the command history recorded in the @dfn{history file}.
1196 @xref{Command History}, for more details about the command history and the
1197 files where @value{GDBN} records it.
1200 Init files use the same syntax as @dfn{command files} (@pxref{Command
1201 Files}) and are processed by @value{GDBN} in the same way. The init
1202 file in your home directory can set options (such as @samp{set
1203 complaints}) that affect subsequent processing of command line options
1204 and operands. Init files are not executed if you use the @samp{-nx}
1205 option (@pxref{Mode Options, ,Choosing modes}).
1207 @cindex init file name
1208 @cindex @file{.gdbinit}
1209 The @value{GDBN} init files are normally called @file{.gdbinit}.
1210 On some configurations of @value{GDBN}, the init file is known by a
1211 different name (these are typically environments where a specialized
1212 form of @value{GDBN} may need to coexist with other forms, hence a
1213 different name for the specialized version's init file). These are the
1214 environments with special init file names:
1217 @cindex @file{gdb.ini}
1219 The DJGPP port of @value{GDBN} uses the name @file{gdb.ini}, due to
1220 the limitations of file names imposed by DOS filesystems. The Windows
1221 ports of @value{GDBN} use the standard name, but if they find a
1222 @file{gdb.ini} file, they warn you about that and suggest to rename
1223 the file to the standard name.
1225 @cindex @file{.vxgdbinit}
1227 VxWorks (Wind River Systems real-time OS): @file{.vxgdbinit}
1229 @cindex @file{.os68gdbinit}
1231 OS68K (Enea Data Systems real-time OS): @file{.os68gdbinit}
1233 @cindex @file{.esgdbinit}
1235 ES-1800 (Ericsson Telecom AB M68000 emulator): @file{.esgdbinit}
1238 CISCO 68k: @file{.cisco-gdbinit}
1243 @section Quitting @value{GDBN}
1244 @cindex exiting @value{GDBN}
1245 @cindex leaving @value{GDBN}
1248 @kindex quit @r{[}@var{expression}@r{]}
1249 @kindex q @r{(@code{quit})}
1250 @item quit @r{[}@var{expression}@r{]}
1252 To exit @value{GDBN}, use the @code{quit} command (abbreviated
1253 @code{q}), or type an end-of-file character (usually @kbd{C-d}). If you
1254 do not supply @var{expression}, @value{GDBN} will terminate normally;
1255 otherwise it will terminate using the result of @var{expression} as the
1260 An interrupt (often @kbd{C-c}) does not exit from @value{GDBN}, but rather
1261 terminates the action of any @value{GDBN} command that is in progress and
1262 returns to @value{GDBN} command level. It is safe to type the interrupt
1263 character at any time because @value{GDBN} does not allow it to take effect
1264 until a time when it is safe.
1266 If you have been using @value{GDBN} to control an attached process or
1267 device, you can release it with the @code{detach} command
1268 (@pxref{Attach, ,Debugging an already-running process}).
1270 @node Shell Commands
1271 @section Shell commands
1273 If you need to execute occasional shell commands during your
1274 debugging session, there is no need to leave or suspend @value{GDBN}; you can
1275 just use the @code{shell} command.
1279 @cindex shell escape
1280 @item shell @var{command string}
1281 Invoke a standard shell to execute @var{command string}.
1282 If it exists, the environment variable @code{SHELL} determines which
1283 shell to run. Otherwise @value{GDBN} uses the default shell
1284 (@file{/bin/sh} on Unix systems, @file{COMMAND.COM} on MS-DOS, etc.).
1287 The utility @code{make} is often needed in development environments.
1288 You do not have to use the @code{shell} command for this purpose in
1293 @cindex calling make
1294 @item make @var{make-args}
1295 Execute the @code{make} program with the specified
1296 arguments. This is equivalent to @samp{shell make @var{make-args}}.
1299 @node Logging output
1300 @section Logging output
1301 @cindex logging @value{GDBN} output
1302 @cindex save @value{GDBN} output to a file
1304 You may want to save the output of @value{GDBN} commands to a file.
1305 There are several commands to control @value{GDBN}'s logging.
1309 @item set logging on
1311 @item set logging off
1313 @cindex logging file name
1314 @item set logging file @var{file}
1315 Change the name of the current logfile. The default logfile is @file{gdb.txt}.
1316 @item set logging overwrite [on|off]
1317 By default, @value{GDBN} will append to the logfile. Set @code{overwrite} if
1318 you want @code{set logging on} to overwrite the logfile instead.
1319 @item set logging redirect [on|off]
1320 By default, @value{GDBN} output will go to both the terminal and the logfile.
1321 Set @code{redirect} if you want output to go only to the log file.
1322 @kindex show logging
1324 Show the current values of the logging settings.
1328 @chapter @value{GDBN} Commands
1330 You can abbreviate a @value{GDBN} command to the first few letters of the command
1331 name, if that abbreviation is unambiguous; and you can repeat certain
1332 @value{GDBN} commands by typing just @key{RET}. You can also use the @key{TAB}
1333 key to get @value{GDBN} to fill out the rest of a word in a command (or to
1334 show you the alternatives available, if there is more than one possibility).
1337 * Command Syntax:: How to give commands to @value{GDBN}
1338 * Completion:: Command completion
1339 * Help:: How to ask @value{GDBN} for help
1342 @node Command Syntax
1343 @section Command syntax
1345 A @value{GDBN} command is a single line of input. There is no limit on
1346 how long it can be. It starts with a command name, which is followed by
1347 arguments whose meaning depends on the command name. For example, the
1348 command @code{step} accepts an argument which is the number of times to
1349 step, as in @samp{step 5}. You can also use the @code{step} command
1350 with no arguments. Some commands do not allow any arguments.
1352 @cindex abbreviation
1353 @value{GDBN} command names may always be truncated if that abbreviation is
1354 unambiguous. Other possible command abbreviations are listed in the
1355 documentation for individual commands. In some cases, even ambiguous
1356 abbreviations are allowed; for example, @code{s} is specially defined as
1357 equivalent to @code{step} even though there are other commands whose
1358 names start with @code{s}. You can test abbreviations by using them as
1359 arguments to the @code{help} command.
1361 @cindex repeating commands
1362 @kindex RET @r{(repeat last command)}
1363 A blank line as input to @value{GDBN} (typing just @key{RET}) means to
1364 repeat the previous command. Certain commands (for example, @code{run})
1365 will not repeat this way; these are commands whose unintentional
1366 repetition might cause trouble and which you are unlikely to want to
1367 repeat. User-defined commands can disable this feature; see
1368 @ref{Define, dont-repeat}.
1370 The @code{list} and @code{x} commands, when you repeat them with
1371 @key{RET}, construct new arguments rather than repeating
1372 exactly as typed. This permits easy scanning of source or memory.
1374 @value{GDBN} can also use @key{RET} in another way: to partition lengthy
1375 output, in a way similar to the common utility @code{more}
1376 (@pxref{Screen Size,,Screen size}). Since it is easy to press one
1377 @key{RET} too many in this situation, @value{GDBN} disables command
1378 repetition after any command that generates this sort of display.
1380 @kindex # @r{(a comment)}
1382 Any text from a @kbd{#} to the end of the line is a comment; it does
1383 nothing. This is useful mainly in command files (@pxref{Command
1384 Files,,Command files}).
1386 @cindex repeating command sequences
1387 @kindex C-o @r{(operate-and-get-next)}
1388 The @kbd{C-o} binding is useful for repeating a complex sequence of
1389 commands. This command accepts the current line, like @kbd{RET}, and
1390 then fetches the next line relative to the current line from the history
1394 @section Command completion
1397 @cindex word completion
1398 @value{GDBN} can fill in the rest of a word in a command for you, if there is
1399 only one possibility; it can also show you what the valid possibilities
1400 are for the next word in a command, at any time. This works for @value{GDBN}
1401 commands, @value{GDBN} subcommands, and the names of symbols in your program.
1403 Press the @key{TAB} key whenever you want @value{GDBN} to fill out the rest
1404 of a word. If there is only one possibility, @value{GDBN} fills in the
1405 word, and waits for you to finish the command (or press @key{RET} to
1406 enter it). For example, if you type
1408 @c FIXME "@key" does not distinguish its argument sufficiently to permit
1409 @c complete accuracy in these examples; space introduced for clarity.
1410 @c If texinfo enhancements make it unnecessary, it would be nice to
1411 @c replace " @key" by "@key" in the following...
1413 (@value{GDBP}) info bre @key{TAB}
1417 @value{GDBN} fills in the rest of the word @samp{breakpoints}, since that is
1418 the only @code{info} subcommand beginning with @samp{bre}:
1421 (@value{GDBP}) info breakpoints
1425 You can either press @key{RET} at this point, to run the @code{info
1426 breakpoints} command, or backspace and enter something else, if
1427 @samp{breakpoints} does not look like the command you expected. (If you
1428 were sure you wanted @code{info breakpoints} in the first place, you
1429 might as well just type @key{RET} immediately after @samp{info bre},
1430 to exploit command abbreviations rather than command completion).
1432 If there is more than one possibility for the next word when you press
1433 @key{TAB}, @value{GDBN} sounds a bell. You can either supply more
1434 characters and try again, or just press @key{TAB} a second time;
1435 @value{GDBN} displays all the possible completions for that word. For
1436 example, you might want to set a breakpoint on a subroutine whose name
1437 begins with @samp{make_}, but when you type @kbd{b make_@key{TAB}} @value{GDBN}
1438 just sounds the bell. Typing @key{TAB} again displays all the
1439 function names in your program that begin with those characters, for
1443 (@value{GDBP}) b make_ @key{TAB}
1444 @exdent @value{GDBN} sounds bell; press @key{TAB} again, to see:
1445 make_a_section_from_file make_environ
1446 make_abs_section make_function_type
1447 make_blockvector make_pointer_type
1448 make_cleanup make_reference_type
1449 make_command make_symbol_completion_list
1450 (@value{GDBP}) b make_
1454 After displaying the available possibilities, @value{GDBN} copies your
1455 partial input (@samp{b make_} in the example) so you can finish the
1458 If you just want to see the list of alternatives in the first place, you
1459 can press @kbd{M-?} rather than pressing @key{TAB} twice. @kbd{M-?}
1460 means @kbd{@key{META} ?}. You can type this either by holding down a
1461 key designated as the @key{META} shift on your keyboard (if there is
1462 one) while typing @kbd{?}, or as @key{ESC} followed by @kbd{?}.
1464 @cindex quotes in commands
1465 @cindex completion of quoted strings
1466 Sometimes the string you need, while logically a ``word'', may contain
1467 parentheses or other characters that @value{GDBN} normally excludes from
1468 its notion of a word. To permit word completion to work in this
1469 situation, you may enclose words in @code{'} (single quote marks) in
1470 @value{GDBN} commands.
1472 The most likely situation where you might need this is in typing the
1473 name of a C@t{++} function. This is because C@t{++} allows function
1474 overloading (multiple definitions of the same function, distinguished
1475 by argument type). For example, when you want to set a breakpoint you
1476 may need to distinguish whether you mean the version of @code{name}
1477 that takes an @code{int} parameter, @code{name(int)}, or the version
1478 that takes a @code{float} parameter, @code{name(float)}. To use the
1479 word-completion facilities in this situation, type a single quote
1480 @code{'} at the beginning of the function name. This alerts
1481 @value{GDBN} that it may need to consider more information than usual
1482 when you press @key{TAB} or @kbd{M-?} to request word completion:
1485 (@value{GDBP}) b 'bubble( @kbd{M-?}
1486 bubble(double,double) bubble(int,int)
1487 (@value{GDBP}) b 'bubble(
1490 In some cases, @value{GDBN} can tell that completing a name requires using
1491 quotes. When this happens, @value{GDBN} inserts the quote for you (while
1492 completing as much as it can) if you do not type the quote in the first
1496 (@value{GDBP}) b bub @key{TAB}
1497 @exdent @value{GDBN} alters your input line to the following, and rings a bell:
1498 (@value{GDBP}) b 'bubble(
1502 In general, @value{GDBN} can tell that a quote is needed (and inserts it) if
1503 you have not yet started typing the argument list when you ask for
1504 completion on an overloaded symbol.
1506 For more information about overloaded functions, see @ref{C plus plus
1507 expressions, ,C@t{++} expressions}. You can use the command @code{set
1508 overload-resolution off} to disable overload resolution;
1509 see @ref{Debugging C plus plus, ,@value{GDBN} features for C@t{++}}.
1513 @section Getting help
1514 @cindex online documentation
1517 You can always ask @value{GDBN} itself for information on its commands,
1518 using the command @code{help}.
1521 @kindex h @r{(@code{help})}
1524 You can use @code{help} (abbreviated @code{h}) with no arguments to
1525 display a short list of named classes of commands:
1529 List of classes of commands:
1531 aliases -- Aliases of other commands
1532 breakpoints -- Making program stop at certain points
1533 data -- Examining data
1534 files -- Specifying and examining files
1535 internals -- Maintenance commands
1536 obscure -- Obscure features
1537 running -- Running the program
1538 stack -- Examining the stack
1539 status -- Status inquiries
1540 support -- Support facilities
1541 tracepoints -- Tracing of program execution without@*
1542 stopping the program
1543 user-defined -- User-defined commands
1545 Type "help" followed by a class name for a list of
1546 commands in that class.
1547 Type "help" followed by command name for full
1549 Command name abbreviations are allowed if unambiguous.
1552 @c the above line break eliminates huge line overfull...
1554 @item help @var{class}
1555 Using one of the general help classes as an argument, you can get a
1556 list of the individual commands in that class. For example, here is the
1557 help display for the class @code{status}:
1560 (@value{GDBP}) help status
1565 @c Line break in "show" line falsifies real output, but needed
1566 @c to fit in smallbook page size.
1567 info -- Generic command for showing things
1568 about the program being debugged
1569 show -- Generic command for showing things
1572 Type "help" followed by command name for full
1574 Command name abbreviations are allowed if unambiguous.
1578 @item help @var{command}
1579 With a command name as @code{help} argument, @value{GDBN} displays a
1580 short paragraph on how to use that command.
1583 @item apropos @var{args}
1584 The @code{apropos} command searches through all of the @value{GDBN}
1585 commands, and their documentation, for the regular expression specified in
1586 @var{args}. It prints out all matches found. For example:
1597 set symbol-reloading -- Set dynamic symbol table reloading
1598 multiple times in one run
1599 show symbol-reloading -- Show dynamic symbol table reloading
1600 multiple times in one run
1605 @item complete @var{args}
1606 The @code{complete @var{args}} command lists all the possible completions
1607 for the beginning of a command. Use @var{args} to specify the beginning of the
1608 command you want completed. For example:
1614 @noindent results in:
1625 @noindent This is intended for use by @sc{gnu} Emacs.
1628 In addition to @code{help}, you can use the @value{GDBN} commands @code{info}
1629 and @code{show} to inquire about the state of your program, or the state
1630 of @value{GDBN} itself. Each command supports many topics of inquiry; this
1631 manual introduces each of them in the appropriate context. The listings
1632 under @code{info} and under @code{show} in the Index point to
1633 all the sub-commands. @xref{Index}.
1638 @kindex i @r{(@code{info})}
1640 This command (abbreviated @code{i}) is for describing the state of your
1641 program. For example, you can list the arguments given to your program
1642 with @code{info args}, list the registers currently in use with @code{info
1643 registers}, or list the breakpoints you have set with @code{info breakpoints}.
1644 You can get a complete list of the @code{info} sub-commands with
1645 @w{@code{help info}}.
1649 You can assign the result of an expression to an environment variable with
1650 @code{set}. For example, you can set the @value{GDBN} prompt to a $-sign with
1651 @code{set prompt $}.
1655 In contrast to @code{info}, @code{show} is for describing the state of
1656 @value{GDBN} itself.
1657 You can change most of the things you can @code{show}, by using the
1658 related command @code{set}; for example, you can control what number
1659 system is used for displays with @code{set radix}, or simply inquire
1660 which is currently in use with @code{show radix}.
1663 To display all the settable parameters and their current
1664 values, you can use @code{show} with no arguments; you may also use
1665 @code{info set}. Both commands produce the same display.
1666 @c FIXME: "info set" violates the rule that "info" is for state of
1667 @c FIXME...program. Ck w/ GNU: "info set" to be called something else,
1668 @c FIXME...or change desc of rule---eg "state of prog and debugging session"?
1672 Here are three miscellaneous @code{show} subcommands, all of which are
1673 exceptional in lacking corresponding @code{set} commands:
1676 @kindex show version
1677 @cindex @value{GDBN} version number
1679 Show what version of @value{GDBN} is running. You should include this
1680 information in @value{GDBN} bug-reports. If multiple versions of
1681 @value{GDBN} are in use at your site, you may need to determine which
1682 version of @value{GDBN} you are running; as @value{GDBN} evolves, new
1683 commands are introduced, and old ones may wither away. Also, many
1684 system vendors ship variant versions of @value{GDBN}, and there are
1685 variant versions of @value{GDBN} in @sc{gnu}/Linux distributions as well.
1686 The version number is the same as the one announced when you start
1689 @kindex show copying
1690 @kindex info copying
1691 @cindex display @value{GDBN} copyright
1694 Display information about permission for copying @value{GDBN}.
1696 @kindex show warranty
1697 @kindex info warranty
1699 @itemx info warranty
1700 Display the @sc{gnu} ``NO WARRANTY'' statement, or a warranty,
1701 if your version of @value{GDBN} comes with one.
1706 @chapter Running Programs Under @value{GDBN}
1708 When you run a program under @value{GDBN}, you must first generate
1709 debugging information when you compile it.
1711 You may start @value{GDBN} with its arguments, if any, in an environment
1712 of your choice. If you are doing native debugging, you may redirect
1713 your program's input and output, debug an already running process, or
1714 kill a child process.
1717 * Compilation:: Compiling for debugging
1718 * Starting:: Starting your program
1719 * Arguments:: Your program's arguments
1720 * Environment:: Your program's environment
1722 * Working Directory:: Your program's working directory
1723 * Input/Output:: Your program's input and output
1724 * Attach:: Debugging an already-running process
1725 * Kill Process:: Killing the child process
1727 * Threads:: Debugging programs with multiple threads
1728 * Processes:: Debugging programs with multiple processes
1732 @section Compiling for debugging
1734 In order to debug a program effectively, you need to generate
1735 debugging information when you compile it. This debugging information
1736 is stored in the object file; it describes the data type of each
1737 variable or function and the correspondence between source line numbers
1738 and addresses in the executable code.
1740 To request debugging information, specify the @samp{-g} option when you run
1743 Programs that are to be shipped to your customers are compiled with
1744 optimizations, using the @samp{-O} compiler option. However, many
1745 compilers are unable to handle the @samp{-g} and @samp{-O} options
1746 together. Using those compilers, you cannot generate optimized
1747 executables containing debugging information.
1749 @value{NGCC}, the @sc{gnu} C/C@t{++} compiler, supports @samp{-g} with or
1750 without @samp{-O}, making it possible to debug optimized code. We
1751 recommend that you @emph{always} use @samp{-g} whenever you compile a
1752 program. You may think your program is correct, but there is no sense
1753 in pushing your luck.
1755 @cindex optimized code, debugging
1756 @cindex debugging optimized code
1757 When you debug a program compiled with @samp{-g -O}, remember that the
1758 optimizer is rearranging your code; the debugger shows you what is
1759 really there. Do not be too surprised when the execution path does not
1760 exactly match your source file! An extreme example: if you define a
1761 variable, but never use it, @value{GDBN} never sees that
1762 variable---because the compiler optimizes it out of existence.
1764 Some things do not work as well with @samp{-g -O} as with just
1765 @samp{-g}, particularly on machines with instruction scheduling. If in
1766 doubt, recompile with @samp{-g} alone, and if this fixes the problem,
1767 please report it to us as a bug (including a test case!).
1768 @xref{Variables}, for more information about debugging optimized code.
1770 Older versions of the @sc{gnu} C compiler permitted a variant option
1771 @w{@samp{-gg}} for debugging information. @value{GDBN} no longer supports this
1772 format; if your @sc{gnu} C compiler has this option, do not use it.
1774 @value{GDBN} knows about preprocessor macros and can show you their
1775 expansion (@pxref{Macros}). Most compilers do not include information
1776 about preprocessor macros in the debugging information if you specify
1777 the @option{-g} flag alone, because this information is rather large.
1778 Version 3.1 and later of @value{NGCC}, the @sc{gnu} C compiler,
1779 provides macro information if you specify the options
1780 @option{-gdwarf-2} and @option{-g3}; the former option requests
1781 debugging information in the Dwarf 2 format, and the latter requests
1782 ``extra information''. In the future, we hope to find more compact
1783 ways to represent macro information, so that it can be included with
1788 @section Starting your program
1794 @kindex r @r{(@code{run})}
1797 Use the @code{run} command to start your program under @value{GDBN}.
1798 You must first specify the program name (except on VxWorks) with an
1799 argument to @value{GDBN} (@pxref{Invocation, ,Getting In and Out of
1800 @value{GDBN}}), or by using the @code{file} or @code{exec-file} command
1801 (@pxref{Files, ,Commands to specify files}).
1805 If you are running your program in an execution environment that
1806 supports processes, @code{run} creates an inferior process and makes
1807 that process run your program. (In environments without processes,
1808 @code{run} jumps to the start of your program.)
1810 The execution of a program is affected by certain information it
1811 receives from its superior. @value{GDBN} provides ways to specify this
1812 information, which you must do @emph{before} starting your program. (You
1813 can change it after starting your program, but such changes only affect
1814 your program the next time you start it.) This information may be
1815 divided into four categories:
1818 @item The @emph{arguments.}
1819 Specify the arguments to give your program as the arguments of the
1820 @code{run} command. If a shell is available on your target, the shell
1821 is used to pass the arguments, so that you may use normal conventions
1822 (such as wildcard expansion or variable substitution) in describing
1824 In Unix systems, you can control which shell is used with the
1825 @code{SHELL} environment variable.
1826 @xref{Arguments, ,Your program's arguments}.
1828 @item The @emph{environment.}
1829 Your program normally inherits its environment from @value{GDBN}, but you can
1830 use the @value{GDBN} commands @code{set environment} and @code{unset
1831 environment} to change parts of the environment that affect
1832 your program. @xref{Environment, ,Your program's environment}.
1834 @item The @emph{working directory.}
1835 Your program inherits its working directory from @value{GDBN}. You can set
1836 the @value{GDBN} working directory with the @code{cd} command in @value{GDBN}.
1837 @xref{Working Directory, ,Your program's working directory}.
1839 @item The @emph{standard input and output.}
1840 Your program normally uses the same device for standard input and
1841 standard output as @value{GDBN} is using. You can redirect input and output
1842 in the @code{run} command line, or you can use the @code{tty} command to
1843 set a different device for your program.
1844 @xref{Input/Output, ,Your program's input and output}.
1847 @emph{Warning:} While input and output redirection work, you cannot use
1848 pipes to pass the output of the program you are debugging to another
1849 program; if you attempt this, @value{GDBN} is likely to wind up debugging the
1853 When you issue the @code{run} command, your program begins to execute
1854 immediately. @xref{Stopping, ,Stopping and continuing}, for discussion
1855 of how to arrange for your program to stop. Once your program has
1856 stopped, you may call functions in your program, using the @code{print}
1857 or @code{call} commands. @xref{Data, ,Examining Data}.
1859 If the modification time of your symbol file has changed since the last
1860 time @value{GDBN} read its symbols, @value{GDBN} discards its symbol
1861 table, and reads it again. When it does this, @value{GDBN} tries to retain
1862 your current breakpoints.
1867 @cindex run to main procedure
1868 The name of the main procedure can vary from language to language.
1869 With C or C@t{++}, the main procedure name is always @code{main}, but
1870 other languages such as Ada do not require a specific name for their
1871 main procedure. The debugger provides a convenient way to start the
1872 execution of the program and to stop at the beginning of the main
1873 procedure, depending on the language used.
1875 The @samp{start} command does the equivalent of setting a temporary
1876 breakpoint at the beginning of the main procedure and then invoking
1877 the @samp{run} command.
1879 @cindex elaboration phase
1880 Some programs contain an @dfn{elaboration} phase where some startup code is
1881 executed before the main procedure is called. This depends on the
1882 languages used to write your program. In C@t{++}, for instance,
1883 constructors for static and global objects are executed before
1884 @code{main} is called. It is therefore possible that the debugger stops
1885 before reaching the main procedure. However, the temporary breakpoint
1886 will remain to halt execution.
1888 Specify the arguments to give to your program as arguments to the
1889 @samp{start} command. These arguments will be given verbatim to the
1890 underlying @samp{run} command. Note that the same arguments will be
1891 reused if no argument is provided during subsequent calls to
1892 @samp{start} or @samp{run}.
1894 It is sometimes necessary to debug the program during elaboration. In
1895 these cases, using the @code{start} command would stop the execution of
1896 your program too late, as the program would have already completed the
1897 elaboration phase. Under these circumstances, insert breakpoints in your
1898 elaboration code before running your program.
1902 @section Your program's arguments
1904 @cindex arguments (to your program)
1905 The arguments to your program can be specified by the arguments of the
1907 They are passed to a shell, which expands wildcard characters and
1908 performs redirection of I/O, and thence to your program. Your
1909 @code{SHELL} environment variable (if it exists) specifies what shell
1910 @value{GDBN} uses. If you do not define @code{SHELL}, @value{GDBN} uses
1911 the default shell (@file{/bin/sh} on Unix).
1913 On non-Unix systems, the program is usually invoked directly by
1914 @value{GDBN}, which emulates I/O redirection via the appropriate system
1915 calls, and the wildcard characters are expanded by the startup code of
1916 the program, not by the shell.
1918 @code{run} with no arguments uses the same arguments used by the previous
1919 @code{run}, or those set by the @code{set args} command.
1924 Specify the arguments to be used the next time your program is run. If
1925 @code{set args} has no arguments, @code{run} executes your program
1926 with no arguments. Once you have run your program with arguments,
1927 using @code{set args} before the next @code{run} is the only way to run
1928 it again without arguments.
1932 Show the arguments to give your program when it is started.
1936 @section Your program's environment
1938 @cindex environment (of your program)
1939 The @dfn{environment} consists of a set of environment variables and
1940 their values. Environment variables conventionally record such things as
1941 your user name, your home directory, your terminal type, and your search
1942 path for programs to run. Usually you set up environment variables with
1943 the shell and they are inherited by all the other programs you run. When
1944 debugging, it can be useful to try running your program with a modified
1945 environment without having to start @value{GDBN} over again.
1949 @item path @var{directory}
1950 Add @var{directory} to the front of the @code{PATH} environment variable
1951 (the search path for executables) that will be passed to your program.
1952 The value of @code{PATH} used by @value{GDBN} does not change.
1953 You may specify several directory names, separated by whitespace or by a
1954 system-dependent separator character (@samp{:} on Unix, @samp{;} on
1955 MS-DOS and MS-Windows). If @var{directory} is already in the path, it
1956 is moved to the front, so it is searched sooner.
1958 You can use the string @samp{$cwd} to refer to whatever is the current
1959 working directory at the time @value{GDBN} searches the path. If you
1960 use @samp{.} instead, it refers to the directory where you executed the
1961 @code{path} command. @value{GDBN} replaces @samp{.} in the
1962 @var{directory} argument (with the current path) before adding
1963 @var{directory} to the search path.
1964 @c 'path' is explicitly nonrepeatable, but RMS points out it is silly to
1965 @c document that, since repeating it would be a no-op.
1969 Display the list of search paths for executables (the @code{PATH}
1970 environment variable).
1972 @kindex show environment
1973 @item show environment @r{[}@var{varname}@r{]}
1974 Print the value of environment variable @var{varname} to be given to
1975 your program when it starts. If you do not supply @var{varname},
1976 print the names and values of all environment variables to be given to
1977 your program. You can abbreviate @code{environment} as @code{env}.
1979 @kindex set environment
1980 @item set environment @var{varname} @r{[}=@var{value}@r{]}
1981 Set environment variable @var{varname} to @var{value}. The value
1982 changes for your program only, not for @value{GDBN} itself. @var{value} may
1983 be any string; the values of environment variables are just strings, and
1984 any interpretation is supplied by your program itself. The @var{value}
1985 parameter is optional; if it is eliminated, the variable is set to a
1987 @c "any string" here does not include leading, trailing
1988 @c blanks. Gnu asks: does anyone care?
1990 For example, this command:
1997 tells the debugged program, when subsequently run, that its user is named
1998 @samp{foo}. (The spaces around @samp{=} are used for clarity here; they
1999 are not actually required.)
2001 @kindex unset environment
2002 @item unset environment @var{varname}
2003 Remove variable @var{varname} from the environment to be passed to your
2004 program. This is different from @samp{set env @var{varname} =};
2005 @code{unset environment} removes the variable from the environment,
2006 rather than assigning it an empty value.
2009 @emph{Warning:} On Unix systems, @value{GDBN} runs your program using
2011 by your @code{SHELL} environment variable if it exists (or
2012 @code{/bin/sh} if not). If your @code{SHELL} variable names a shell
2013 that runs an initialization file---such as @file{.cshrc} for C-shell, or
2014 @file{.bashrc} for BASH---any variables you set in that file affect
2015 your program. You may wish to move setting of environment variables to
2016 files that are only run when you sign on, such as @file{.login} or
2019 @node Working Directory
2020 @section Your program's working directory
2022 @cindex working directory (of your program)
2023 Each time you start your program with @code{run}, it inherits its
2024 working directory from the current working directory of @value{GDBN}.
2025 The @value{GDBN} working directory is initially whatever it inherited
2026 from its parent process (typically the shell), but you can specify a new
2027 working directory in @value{GDBN} with the @code{cd} command.
2029 The @value{GDBN} working directory also serves as a default for the commands
2030 that specify files for @value{GDBN} to operate on. @xref{Files, ,Commands to
2035 @cindex change working directory
2036 @item cd @var{directory}
2037 Set the @value{GDBN} working directory to @var{directory}.
2041 Print the @value{GDBN} working directory.
2044 It is generally impossible to find the current working directory of
2045 the process being debugged (since a program can change its directory
2046 during its run). If you work on a system where @value{GDBN} is
2047 configured with the @file{/proc} support, you can use the @code{info
2048 proc} command (@pxref{SVR4 Process Information}) to find out the
2049 current working directory of the debuggee.
2052 @section Your program's input and output
2057 By default, the program you run under @value{GDBN} does input and output to
2058 the same terminal that @value{GDBN} uses. @value{GDBN} switches the terminal
2059 to its own terminal modes to interact with you, but it records the terminal
2060 modes your program was using and switches back to them when you continue
2061 running your program.
2064 @kindex info terminal
2066 Displays information recorded by @value{GDBN} about the terminal modes your
2070 You can redirect your program's input and/or output using shell
2071 redirection with the @code{run} command. For example,
2078 starts your program, diverting its output to the file @file{outfile}.
2081 @cindex controlling terminal
2082 Another way to specify where your program should do input and output is
2083 with the @code{tty} command. This command accepts a file name as
2084 argument, and causes this file to be the default for future @code{run}
2085 commands. It also resets the controlling terminal for the child
2086 process, for future @code{run} commands. For example,
2093 directs that processes started with subsequent @code{run} commands
2094 default to do input and output on the terminal @file{/dev/ttyb} and have
2095 that as their controlling terminal.
2097 An explicit redirection in @code{run} overrides the @code{tty} command's
2098 effect on the input/output device, but not its effect on the controlling
2101 When you use the @code{tty} command or redirect input in the @code{run}
2102 command, only the input @emph{for your program} is affected. The input
2103 for @value{GDBN} still comes from your terminal. @code{tty} is an alias
2104 for @code{set inferior-tty}.
2106 @cindex inferior tty
2107 @cindex set inferior controlling terminal
2108 You can use the @code{show inferior-tty} command to tell @value{GDBN} to
2109 display the name of the terminal that will be used for future runs of your
2113 @item set inferior-tty /dev/ttyb
2114 @kindex set inferior-tty
2115 Set the tty for the program being debugged to /dev/ttyb.
2117 @item show inferior-tty
2118 @kindex show inferior-tty
2119 Show the current tty for the program being debugged.
2123 @section Debugging an already-running process
2128 @item attach @var{process-id}
2129 This command attaches to a running process---one that was started
2130 outside @value{GDBN}. (@code{info files} shows your active
2131 targets.) The command takes as argument a process ID. The usual way to
2132 find out the @var{process-id} of a Unix process is with the @code{ps} utility,
2133 or with the @samp{jobs -l} shell command.
2135 @code{attach} does not repeat if you press @key{RET} a second time after
2136 executing the command.
2139 To use @code{attach}, your program must be running in an environment
2140 which supports processes; for example, @code{attach} does not work for
2141 programs on bare-board targets that lack an operating system. You must
2142 also have permission to send the process a signal.
2144 When you use @code{attach}, the debugger finds the program running in
2145 the process first by looking in the current working directory, then (if
2146 the program is not found) by using the source file search path
2147 (@pxref{Source Path, ,Specifying source directories}). You can also use
2148 the @code{file} command to load the program. @xref{Files, ,Commands to
2151 The first thing @value{GDBN} does after arranging to debug the specified
2152 process is to stop it. You can examine and modify an attached process
2153 with all the @value{GDBN} commands that are ordinarily available when
2154 you start processes with @code{run}. You can insert breakpoints; you
2155 can step and continue; you can modify storage. If you would rather the
2156 process continue running, you may use the @code{continue} command after
2157 attaching @value{GDBN} to the process.
2162 When you have finished debugging the attached process, you can use the
2163 @code{detach} command to release it from @value{GDBN} control. Detaching
2164 the process continues its execution. After the @code{detach} command,
2165 that process and @value{GDBN} become completely independent once more, and you
2166 are ready to @code{attach} another process or start one with @code{run}.
2167 @code{detach} does not repeat if you press @key{RET} again after
2168 executing the command.
2171 If you exit @value{GDBN} or use the @code{run} command while you have an
2172 attached process, you kill that process. By default, @value{GDBN} asks
2173 for confirmation if you try to do either of these things; you can
2174 control whether or not you need to confirm by using the @code{set
2175 confirm} command (@pxref{Messages/Warnings, ,Optional warnings and
2179 @section Killing the child process
2184 Kill the child process in which your program is running under @value{GDBN}.
2187 This command is useful if you wish to debug a core dump instead of a
2188 running process. @value{GDBN} ignores any core dump file while your program
2191 On some operating systems, a program cannot be executed outside @value{GDBN}
2192 while you have breakpoints set on it inside @value{GDBN}. You can use the
2193 @code{kill} command in this situation to permit running your program
2194 outside the debugger.
2196 The @code{kill} command is also useful if you wish to recompile and
2197 relink your program, since on many systems it is impossible to modify an
2198 executable file while it is running in a process. In this case, when you
2199 next type @code{run}, @value{GDBN} notices that the file has changed, and
2200 reads the symbol table again (while trying to preserve your current
2201 breakpoint settings).
2204 @section Debugging programs with multiple threads
2206 @cindex threads of execution
2207 @cindex multiple threads
2208 @cindex switching threads
2209 In some operating systems, such as HP-UX and Solaris, a single program
2210 may have more than one @dfn{thread} of execution. The precise semantics
2211 of threads differ from one operating system to another, but in general
2212 the threads of a single program are akin to multiple processes---except
2213 that they share one address space (that is, they can all examine and
2214 modify the same variables). On the other hand, each thread has its own
2215 registers and execution stack, and perhaps private memory.
2217 @value{GDBN} provides these facilities for debugging multi-thread
2221 @item automatic notification of new threads
2222 @item @samp{thread @var{threadno}}, a command to switch among threads
2223 @item @samp{info threads}, a command to inquire about existing threads
2224 @item @samp{thread apply [@var{threadno}] [@var{all}] @var{args}},
2225 a command to apply a command to a list of threads
2226 @item thread-specific breakpoints
2230 @emph{Warning:} These facilities are not yet available on every
2231 @value{GDBN} configuration where the operating system supports threads.
2232 If your @value{GDBN} does not support threads, these commands have no
2233 effect. For example, a system without thread support shows no output
2234 from @samp{info threads}, and always rejects the @code{thread} command,
2238 (@value{GDBP}) info threads
2239 (@value{GDBP}) thread 1
2240 Thread ID 1 not known. Use the "info threads" command to
2241 see the IDs of currently known threads.
2243 @c FIXME to implementors: how hard would it be to say "sorry, this GDB
2244 @c doesn't support threads"?
2247 @cindex focus of debugging
2248 @cindex current thread
2249 The @value{GDBN} thread debugging facility allows you to observe all
2250 threads while your program runs---but whenever @value{GDBN} takes
2251 control, one thread in particular is always the focus of debugging.
2252 This thread is called the @dfn{current thread}. Debugging commands show
2253 program information from the perspective of the current thread.
2255 @cindex @code{New} @var{systag} message
2256 @cindex thread identifier (system)
2257 @c FIXME-implementors!! It would be more helpful if the [New...] message
2258 @c included GDB's numeric thread handle, so you could just go to that
2259 @c thread without first checking `info threads'.
2260 Whenever @value{GDBN} detects a new thread in your program, it displays
2261 the target system's identification for the thread with a message in the
2262 form @samp{[New @var{systag}]}. @var{systag} is a thread identifier
2263 whose form varies depending on the particular system. For example, on
2264 LynxOS, you might see
2267 [New process 35 thread 27]
2271 when @value{GDBN} notices a new thread. In contrast, on an SGI system,
2272 the @var{systag} is simply something like @samp{process 368}, with no
2275 @c FIXME!! (1) Does the [New...] message appear even for the very first
2276 @c thread of a program, or does it only appear for the
2277 @c second---i.e.@: when it becomes obvious we have a multithread
2279 @c (2) *Is* there necessarily a first thread always? Or do some
2280 @c multithread systems permit starting a program with multiple
2281 @c threads ab initio?
2283 @cindex thread number
2284 @cindex thread identifier (GDB)
2285 For debugging purposes, @value{GDBN} associates its own thread
2286 number---always a single integer---with each thread in your program.
2289 @kindex info threads
2291 Display a summary of all threads currently in your
2292 program. @value{GDBN} displays for each thread (in this order):
2296 the thread number assigned by @value{GDBN}
2299 the target system's thread identifier (@var{systag})
2302 the current stack frame summary for that thread
2306 An asterisk @samp{*} to the left of the @value{GDBN} thread number
2307 indicates the current thread.
2311 @c end table here to get a little more width for example
2314 (@value{GDBP}) info threads
2315 3 process 35 thread 27 0x34e5 in sigpause ()
2316 2 process 35 thread 23 0x34e5 in sigpause ()
2317 * 1 process 35 thread 13 main (argc=1, argv=0x7ffffff8)
2323 @cindex debugging multithreaded programs (on HP-UX)
2324 @cindex thread identifier (GDB), on HP-UX
2325 For debugging purposes, @value{GDBN} associates its own thread
2326 number---a small integer assigned in thread-creation order---with each
2327 thread in your program.
2329 @cindex @code{New} @var{systag} message, on HP-UX
2330 @cindex thread identifier (system), on HP-UX
2331 @c FIXME-implementors!! It would be more helpful if the [New...] message
2332 @c included GDB's numeric thread handle, so you could just go to that
2333 @c thread without first checking `info threads'.
2334 Whenever @value{GDBN} detects a new thread in your program, it displays
2335 both @value{GDBN}'s thread number and the target system's identification for the thread with a message in the
2336 form @samp{[New @var{systag}]}. @var{systag} is a thread identifier
2337 whose form varies depending on the particular system. For example, on
2341 [New thread 2 (system thread 26594)]
2345 when @value{GDBN} notices a new thread.
2348 @kindex info threads (HP-UX)
2350 Display a summary of all threads currently in your
2351 program. @value{GDBN} displays for each thread (in this order):
2354 @item the thread number assigned by @value{GDBN}
2356 @item the target system's thread identifier (@var{systag})
2358 @item the current stack frame summary for that thread
2362 An asterisk @samp{*} to the left of the @value{GDBN} thread number
2363 indicates the current thread.
2367 @c end table here to get a little more width for example
2370 (@value{GDBP}) info threads
2371 * 3 system thread 26607 worker (wptr=0x7b09c318 "@@") \@*
2373 2 system thread 26606 0x7b0030d8 in __ksleep () \@*
2374 from /usr/lib/libc.2
2375 1 system thread 27905 0x7b003498 in _brk () \@*
2376 from /usr/lib/libc.2
2379 On Solaris, you can display more information about user threads with a
2380 Solaris-specific command:
2383 @item maint info sol-threads
2384 @kindex maint info sol-threads
2385 @cindex thread info (Solaris)
2386 Display info on Solaris user threads.
2390 @kindex thread @var{threadno}
2391 @item thread @var{threadno}
2392 Make thread number @var{threadno} the current thread. The command
2393 argument @var{threadno} is the internal @value{GDBN} thread number, as
2394 shown in the first field of the @samp{info threads} display.
2395 @value{GDBN} responds by displaying the system identifier of the thread
2396 you selected, and its current stack frame summary:
2399 @c FIXME!! This example made up; find a @value{GDBN} w/threads and get real one
2400 (@value{GDBP}) thread 2
2401 [Switching to process 35 thread 23]
2402 0x34e5 in sigpause ()
2406 As with the @samp{[New @dots{}]} message, the form of the text after
2407 @samp{Switching to} depends on your system's conventions for identifying
2410 @kindex thread apply
2411 @cindex apply command to several threads
2412 @item thread apply [@var{threadno}] [@var{all}] @var{args}
2413 The @code{thread apply} command allows you to apply a command to one or
2414 more threads. Specify the numbers of the threads that you want affected
2415 with the command argument @var{threadno}. @var{threadno} is the internal
2416 @value{GDBN} thread number, as shown in the first field of the @samp{info
2417 threads} display. To apply a command to all threads, use
2418 @code{thread apply all} @var{args}.
2421 @cindex automatic thread selection
2422 @cindex switching threads automatically
2423 @cindex threads, automatic switching
2424 Whenever @value{GDBN} stops your program, due to a breakpoint or a
2425 signal, it automatically selects the thread where that breakpoint or
2426 signal happened. @value{GDBN} alerts you to the context switch with a
2427 message of the form @samp{[Switching to @var{systag}]} to identify the
2430 @xref{Thread Stops,,Stopping and starting multi-thread programs}, for
2431 more information about how @value{GDBN} behaves when you stop and start
2432 programs with multiple threads.
2434 @xref{Set Watchpoints,,Setting watchpoints}, for information about
2435 watchpoints in programs with multiple threads.
2438 @section Debugging programs with multiple processes
2440 @cindex fork, debugging programs which call
2441 @cindex multiple processes
2442 @cindex processes, multiple
2443 On most systems, @value{GDBN} has no special support for debugging
2444 programs which create additional processes using the @code{fork}
2445 function. When a program forks, @value{GDBN} will continue to debug the
2446 parent process and the child process will run unimpeded. If you have
2447 set a breakpoint in any code which the child then executes, the child
2448 will get a @code{SIGTRAP} signal which (unless it catches the signal)
2449 will cause it to terminate.
2451 However, if you want to debug the child process there is a workaround
2452 which isn't too painful. Put a call to @code{sleep} in the code which
2453 the child process executes after the fork. It may be useful to sleep
2454 only if a certain environment variable is set, or a certain file exists,
2455 so that the delay need not occur when you don't want to run @value{GDBN}
2456 on the child. While the child is sleeping, use the @code{ps} program to
2457 get its process ID. Then tell @value{GDBN} (a new invocation of
2458 @value{GDBN} if you are also debugging the parent process) to attach to
2459 the child process (@pxref{Attach}). From that point on you can debug
2460 the child process just like any other process which you attached to.
2462 On some systems, @value{GDBN} provides support for debugging programs that
2463 create additional processes using the @code{fork} or @code{vfork} functions.
2464 Currently, the only platforms with this feature are HP-UX (11.x and later
2465 only?) and GNU/Linux (kernel version 2.5.60 and later).
2467 By default, when a program forks, @value{GDBN} will continue to debug
2468 the parent process and the child process will run unimpeded.
2470 If you want to follow the child process instead of the parent process,
2471 use the command @w{@code{set follow-fork-mode}}.
2474 @kindex set follow-fork-mode
2475 @item set follow-fork-mode @var{mode}
2476 Set the debugger response to a program call of @code{fork} or
2477 @code{vfork}. A call to @code{fork} or @code{vfork} creates a new
2478 process. The @var{mode} argument can be:
2482 The original process is debugged after a fork. The child process runs
2483 unimpeded. This is the default.
2486 The new process is debugged after a fork. The parent process runs
2491 @kindex show follow-fork-mode
2492 @item show follow-fork-mode
2493 Display the current debugger response to a @code{fork} or @code{vfork} call.
2496 If you ask to debug a child process and a @code{vfork} is followed by an
2497 @code{exec}, @value{GDBN} executes the new target up to the first
2498 breakpoint in the new target. If you have a breakpoint set on
2499 @code{main} in your original program, the breakpoint will also be set on
2500 the child process's @code{main}.
2502 When a child process is spawned by @code{vfork}, you cannot debug the
2503 child or parent until an @code{exec} call completes.
2505 If you issue a @code{run} command to @value{GDBN} after an @code{exec}
2506 call executes, the new target restarts. To restart the parent process,
2507 use the @code{file} command with the parent executable name as its
2510 You can use the @code{catch} command to make @value{GDBN} stop whenever
2511 a @code{fork}, @code{vfork}, or @code{exec} call is made. @xref{Set
2512 Catchpoints, ,Setting catchpoints}.
2515 @chapter Stopping and Continuing
2517 The principal purposes of using a debugger are so that you can stop your
2518 program before it terminates; or so that, if your program runs into
2519 trouble, you can investigate and find out why.
2521 Inside @value{GDBN}, your program may stop for any of several reasons,
2522 such as a signal, a breakpoint, or reaching a new line after a
2523 @value{GDBN} command such as @code{step}. You may then examine and
2524 change variables, set new breakpoints or remove old ones, and then
2525 continue execution. Usually, the messages shown by @value{GDBN} provide
2526 ample explanation of the status of your program---but you can also
2527 explicitly request this information at any time.
2530 @kindex info program
2532 Display information about the status of your program: whether it is
2533 running or not, what process it is, and why it stopped.
2537 * Breakpoints:: Breakpoints, watchpoints, and catchpoints
2538 * Continuing and Stepping:: Resuming execution
2540 * Thread Stops:: Stopping and starting multi-thread programs
2544 @section Breakpoints, watchpoints, and catchpoints
2547 A @dfn{breakpoint} makes your program stop whenever a certain point in
2548 the program is reached. For each breakpoint, you can add conditions to
2549 control in finer detail whether your program stops. You can set
2550 breakpoints with the @code{break} command and its variants (@pxref{Set
2551 Breaks, ,Setting breakpoints}), to specify the place where your program
2552 should stop by line number, function name or exact address in the
2555 On some systems, you can set breakpoints in shared libraries before
2556 the executable is run. There is a minor limitation on HP-UX systems:
2557 you must wait until the executable is run in order to set breakpoints
2558 in shared library routines that are not called directly by the program
2559 (for example, routines that are arguments in a @code{pthread_create}
2563 @cindex memory tracing
2564 @cindex breakpoint on memory address
2565 @cindex breakpoint on variable modification
2566 A @dfn{watchpoint} is a special breakpoint that stops your program
2567 when the value of an expression changes. You must use a different
2568 command to set watchpoints (@pxref{Set Watchpoints, ,Setting
2569 watchpoints}), but aside from that, you can manage a watchpoint like
2570 any other breakpoint: you enable, disable, and delete both breakpoints
2571 and watchpoints using the same commands.
2573 You can arrange to have values from your program displayed automatically
2574 whenever @value{GDBN} stops at a breakpoint. @xref{Auto Display,,
2578 @cindex breakpoint on events
2579 A @dfn{catchpoint} is another special breakpoint that stops your program
2580 when a certain kind of event occurs, such as the throwing of a C@t{++}
2581 exception or the loading of a library. As with watchpoints, you use a
2582 different command to set a catchpoint (@pxref{Set Catchpoints, ,Setting
2583 catchpoints}), but aside from that, you can manage a catchpoint like any
2584 other breakpoint. (To stop when your program receives a signal, use the
2585 @code{handle} command; see @ref{Signals, ,Signals}.)
2587 @cindex breakpoint numbers
2588 @cindex numbers for breakpoints
2589 @value{GDBN} assigns a number to each breakpoint, watchpoint, or
2590 catchpoint when you create it; these numbers are successive integers
2591 starting with one. In many of the commands for controlling various
2592 features of breakpoints you use the breakpoint number to say which
2593 breakpoint you want to change. Each breakpoint may be @dfn{enabled} or
2594 @dfn{disabled}; if disabled, it has no effect on your program until you
2597 @cindex breakpoint ranges
2598 @cindex ranges of breakpoints
2599 Some @value{GDBN} commands accept a range of breakpoints on which to
2600 operate. A breakpoint range is either a single breakpoint number, like
2601 @samp{5}, or two such numbers, in increasing order, separated by a
2602 hyphen, like @samp{5-7}. When a breakpoint range is given to a command,
2603 all breakpoint in that range are operated on.
2606 * Set Breaks:: Setting breakpoints
2607 * Set Watchpoints:: Setting watchpoints
2608 * Set Catchpoints:: Setting catchpoints
2609 * Delete Breaks:: Deleting breakpoints
2610 * Disabling:: Disabling breakpoints
2611 * Conditions:: Break conditions
2612 * Break Commands:: Breakpoint command lists
2613 * Breakpoint Menus:: Breakpoint menus
2614 * Error in Breakpoints:: ``Cannot insert breakpoints''
2615 * Breakpoint related warnings:: ``Breakpoint address adjusted...''
2619 @subsection Setting breakpoints
2621 @c FIXME LMB what does GDB do if no code on line of breakpt?
2622 @c consider in particular declaration with/without initialization.
2624 @c FIXME 2 is there stuff on this already? break at fun start, already init?
2627 @kindex b @r{(@code{break})}
2628 @vindex $bpnum@r{, convenience variable}
2629 @cindex latest breakpoint
2630 Breakpoints are set with the @code{break} command (abbreviated
2631 @code{b}). The debugger convenience variable @samp{$bpnum} records the
2632 number of the breakpoint you've set most recently; see @ref{Convenience
2633 Vars,, Convenience variables}, for a discussion of what you can do with
2634 convenience variables.
2636 You have several ways to say where the breakpoint should go.
2639 @item break @var{function}
2640 Set a breakpoint at entry to function @var{function}.
2641 When using source languages that permit overloading of symbols, such as
2642 C@t{++}, @var{function} may refer to more than one possible place to break.
2643 @xref{Breakpoint Menus,,Breakpoint menus}, for a discussion of that situation.
2645 @item break +@var{offset}
2646 @itemx break -@var{offset}
2647 Set a breakpoint some number of lines forward or back from the position
2648 at which execution stopped in the currently selected @dfn{stack frame}.
2649 (@xref{Frames, ,Frames}, for a description of stack frames.)
2651 @item break @var{linenum}
2652 Set a breakpoint at line @var{linenum} in the current source file.
2653 The current source file is the last file whose source text was printed.
2654 The breakpoint will stop your program just before it executes any of the
2657 @item break @var{filename}:@var{linenum}
2658 Set a breakpoint at line @var{linenum} in source file @var{filename}.
2660 @item break @var{filename}:@var{function}
2661 Set a breakpoint at entry to function @var{function} found in file
2662 @var{filename}. Specifying a file name as well as a function name is
2663 superfluous except when multiple files contain similarly named
2666 @item break *@var{address}
2667 Set a breakpoint at address @var{address}. You can use this to set
2668 breakpoints in parts of your program which do not have debugging
2669 information or source files.
2672 When called without any arguments, @code{break} sets a breakpoint at
2673 the next instruction to be executed in the selected stack frame
2674 (@pxref{Stack, ,Examining the Stack}). In any selected frame but the
2675 innermost, this makes your program stop as soon as control
2676 returns to that frame. This is similar to the effect of a
2677 @code{finish} command in the frame inside the selected frame---except
2678 that @code{finish} does not leave an active breakpoint. If you use
2679 @code{break} without an argument in the innermost frame, @value{GDBN} stops
2680 the next time it reaches the current location; this may be useful
2683 @value{GDBN} normally ignores breakpoints when it resumes execution, until at
2684 least one instruction has been executed. If it did not do this, you
2685 would be unable to proceed past a breakpoint without first disabling the
2686 breakpoint. This rule applies whether or not the breakpoint already
2687 existed when your program stopped.
2689 @item break @dots{} if @var{cond}
2690 Set a breakpoint with condition @var{cond}; evaluate the expression
2691 @var{cond} each time the breakpoint is reached, and stop only if the
2692 value is nonzero---that is, if @var{cond} evaluates as true.
2693 @samp{@dots{}} stands for one of the possible arguments described
2694 above (or no argument) specifying where to break. @xref{Conditions,
2695 ,Break conditions}, for more information on breakpoint conditions.
2698 @item tbreak @var{args}
2699 Set a breakpoint enabled only for one stop. @var{args} are the
2700 same as for the @code{break} command, and the breakpoint is set in the same
2701 way, but the breakpoint is automatically deleted after the first time your
2702 program stops there. @xref{Disabling, ,Disabling breakpoints}.
2705 @cindex hardware breakpoints
2706 @item hbreak @var{args}
2707 Set a hardware-assisted breakpoint. @var{args} are the same as for the
2708 @code{break} command and the breakpoint is set in the same way, but the
2709 breakpoint requires hardware support and some target hardware may not
2710 have this support. The main purpose of this is EPROM/ROM code
2711 debugging, so you can set a breakpoint at an instruction without
2712 changing the instruction. This can be used with the new trap-generation
2713 provided by SPARClite DSU and most x86-based targets. These targets
2714 will generate traps when a program accesses some data or instruction
2715 address that is assigned to the debug registers. However the hardware
2716 breakpoint registers can take a limited number of breakpoints. For
2717 example, on the DSU, only two data breakpoints can be set at a time, and
2718 @value{GDBN} will reject this command if more than two are used. Delete
2719 or disable unused hardware breakpoints before setting new ones
2720 (@pxref{Disabling, ,Disabling}). @xref{Conditions, ,Break conditions}.
2721 For remote targets, you can restrict the number of hardware
2722 breakpoints @value{GDBN} will use, see @ref{set remote
2723 hardware-breakpoint-limit}.
2727 @item thbreak @var{args}
2728 Set a hardware-assisted breakpoint enabled only for one stop. @var{args}
2729 are the same as for the @code{hbreak} command and the breakpoint is set in
2730 the same way. However, like the @code{tbreak} command,
2731 the breakpoint is automatically deleted after the
2732 first time your program stops there. Also, like the @code{hbreak}
2733 command, the breakpoint requires hardware support and some target hardware
2734 may not have this support. @xref{Disabling, ,Disabling breakpoints}.
2735 See also @ref{Conditions, ,Break conditions}.
2738 @cindex regular expression
2739 @cindex breakpoints in functions matching a regexp
2740 @cindex set breakpoints in many functions
2741 @item rbreak @var{regex}
2742 Set breakpoints on all functions matching the regular expression
2743 @var{regex}. This command sets an unconditional breakpoint on all
2744 matches, printing a list of all breakpoints it set. Once these
2745 breakpoints are set, they are treated just like the breakpoints set with
2746 the @code{break} command. You can delete them, disable them, or make
2747 them conditional the same way as any other breakpoint.
2749 The syntax of the regular expression is the standard one used with tools
2750 like @file{grep}. Note that this is different from the syntax used by
2751 shells, so for instance @code{foo*} matches all functions that include
2752 an @code{fo} followed by zero or more @code{o}s. There is an implicit
2753 @code{.*} leading and trailing the regular expression you supply, so to
2754 match only functions that begin with @code{foo}, use @code{^foo}.
2756 @cindex non-member C@t{++} functions, set breakpoint in
2757 When debugging C@t{++} programs, @code{rbreak} is useful for setting
2758 breakpoints on overloaded functions that are not members of any special
2761 @cindex set breakpoints on all functions
2762 The @code{rbreak} command can be used to set breakpoints in
2763 @strong{all} the functions in a program, like this:
2766 (@value{GDBP}) rbreak .
2769 @kindex info breakpoints
2770 @cindex @code{$_} and @code{info breakpoints}
2771 @item info breakpoints @r{[}@var{n}@r{]}
2772 @itemx info break @r{[}@var{n}@r{]}
2773 @itemx info watchpoints @r{[}@var{n}@r{]}
2774 Print a table of all breakpoints, watchpoints, and catchpoints set and
2775 not deleted, with the following columns for each breakpoint:
2778 @item Breakpoint Numbers
2780 Breakpoint, watchpoint, or catchpoint.
2782 Whether the breakpoint is marked to be disabled or deleted when hit.
2783 @item Enabled or Disabled
2784 Enabled breakpoints are marked with @samp{y}. @samp{n} marks breakpoints
2785 that are not enabled.
2787 Where the breakpoint is in your program, as a memory address. If the
2788 breakpoint is pending (see below for details) on a future load of a shared library, the address
2789 will be listed as @samp{<PENDING>}.
2791 Where the breakpoint is in the source for your program, as a file and
2792 line number. For a pending breakpoint, the original string passed to
2793 the breakpoint command will be listed as it cannot be resolved until
2794 the appropriate shared library is loaded in the future.
2798 If a breakpoint is conditional, @code{info break} shows the condition on
2799 the line following the affected breakpoint; breakpoint commands, if any,
2800 are listed after that. A pending breakpoint is allowed to have a condition
2801 specified for it. The condition is not parsed for validity until a shared
2802 library is loaded that allows the pending breakpoint to resolve to a
2806 @code{info break} with a breakpoint
2807 number @var{n} as argument lists only that breakpoint. The
2808 convenience variable @code{$_} and the default examining-address for
2809 the @code{x} command are set to the address of the last breakpoint
2810 listed (@pxref{Memory, ,Examining memory}).
2813 @code{info break} displays a count of the number of times the breakpoint
2814 has been hit. This is especially useful in conjunction with the
2815 @code{ignore} command. You can ignore a large number of breakpoint
2816 hits, look at the breakpoint info to see how many times the breakpoint
2817 was hit, and then run again, ignoring one less than that number. This
2818 will get you quickly to the last hit of that breakpoint.
2821 @value{GDBN} allows you to set any number of breakpoints at the same place in
2822 your program. There is nothing silly or meaningless about this. When
2823 the breakpoints are conditional, this is even useful
2824 (@pxref{Conditions, ,Break conditions}).
2826 @cindex pending breakpoints
2827 If a specified breakpoint location cannot be found, it may be due to the fact
2828 that the location is in a shared library that is yet to be loaded. In such
2829 a case, you may want @value{GDBN} to create a special breakpoint (known as
2830 a @dfn{pending breakpoint}) that
2831 attempts to resolve itself in the future when an appropriate shared library
2834 Pending breakpoints are useful to set at the start of your
2835 @value{GDBN} session for locations that you know will be dynamically loaded
2836 later by the program being debugged. When shared libraries are loaded,
2837 a check is made to see if the load resolves any pending breakpoint locations.
2838 If a pending breakpoint location gets resolved,
2839 a regular breakpoint is created and the original pending breakpoint is removed.
2841 @value{GDBN} provides some additional commands for controlling pending
2844 @kindex set breakpoint pending
2845 @kindex show breakpoint pending
2847 @item set breakpoint pending auto
2848 This is the default behavior. When @value{GDBN} cannot find the breakpoint
2849 location, it queries you whether a pending breakpoint should be created.
2851 @item set breakpoint pending on
2852 This indicates that an unrecognized breakpoint location should automatically
2853 result in a pending breakpoint being created.
2855 @item set breakpoint pending off
2856 This indicates that pending breakpoints are not to be created. Any
2857 unrecognized breakpoint location results in an error. This setting does
2858 not affect any pending breakpoints previously created.
2860 @item show breakpoint pending
2861 Show the current behavior setting for creating pending breakpoints.
2864 @cindex operations allowed on pending breakpoints
2865 Normal breakpoint operations apply to pending breakpoints as well. You may
2866 specify a condition for a pending breakpoint and/or commands to run when the
2867 breakpoint is reached. You can also enable or disable
2868 the pending breakpoint. When you specify a condition for a pending breakpoint,
2869 the parsing of the condition will be deferred until the point where the
2870 pending breakpoint location is resolved. Disabling a pending breakpoint
2871 tells @value{GDBN} to not attempt to resolve the breakpoint on any subsequent
2872 shared library load. When a pending breakpoint is re-enabled,
2873 @value{GDBN} checks to see if the location is already resolved.
2874 This is done because any number of shared library loads could have
2875 occurred since the time the breakpoint was disabled and one or more
2876 of these loads could resolve the location.
2878 @cindex negative breakpoint numbers
2879 @cindex internal @value{GDBN} breakpoints
2880 @value{GDBN} itself sometimes sets breakpoints in your program for
2881 special purposes, such as proper handling of @code{longjmp} (in C
2882 programs). These internal breakpoints are assigned negative numbers,
2883 starting with @code{-1}; @samp{info breakpoints} does not display them.
2884 You can see these breakpoints with the @value{GDBN} maintenance command
2885 @samp{maint info breakpoints} (@pxref{maint info breakpoints}).
2888 @node Set Watchpoints
2889 @subsection Setting watchpoints
2891 @cindex setting watchpoints
2892 You can use a watchpoint to stop execution whenever the value of an
2893 expression changes, without having to predict a particular place where
2896 @cindex software watchpoints
2897 @cindex hardware watchpoints
2898 Depending on your system, watchpoints may be implemented in software or
2899 hardware. @value{GDBN} does software watchpointing by single-stepping your
2900 program and testing the variable's value each time, which is hundreds of
2901 times slower than normal execution. (But this may still be worth it, to
2902 catch errors where you have no clue what part of your program is the
2905 On some systems, such as HP-UX, @sc{gnu}/Linux and most other
2906 x86-based targets, @value{GDBN} includes support for hardware
2907 watchpoints, which do not slow down the running of your program.
2911 @item watch @var{expr}
2912 Set a watchpoint for an expression. @value{GDBN} will break when @var{expr}
2913 is written into by the program and its value changes.
2916 @item rwatch @var{expr}
2917 Set a watchpoint that will break when the value of @var{expr} is read
2921 @item awatch @var{expr}
2922 Set a watchpoint that will break when @var{expr} is either read from
2923 or written into by the program.
2925 @kindex info watchpoints
2926 @item info watchpoints
2927 This command prints a list of watchpoints, breakpoints, and catchpoints;
2928 it is the same as @code{info break} (@pxref{Set Breaks}).
2931 @value{GDBN} sets a @dfn{hardware watchpoint} if possible. Hardware
2932 watchpoints execute very quickly, and the debugger reports a change in
2933 value at the exact instruction where the change occurs. If @value{GDBN}
2934 cannot set a hardware watchpoint, it sets a software watchpoint, which
2935 executes more slowly and reports the change in value at the next
2936 @emph{statement}, not the instruction, after the change occurs.
2938 @cindex use only software watchpoints
2939 You can force @value{GDBN} to use only software watchpoints with the
2940 @kbd{set can-use-hw-watchpoints 0} command. With this variable set to
2941 zero, @value{GDBN} will never try to use hardware watchpoints, even if
2942 the underlying system supports them. (Note that hardware-assisted
2943 watchpoints that were set @emph{before} setting
2944 @code{can-use-hw-watchpoints} to zero will still use the hardware
2945 mechanism of watching expressiion values.)
2948 @item set can-use-hw-watchpoints
2949 @kindex set can-use-hw-watchpoints
2950 Set whether or not to use hardware watchpoints.
2952 @item show can-use-hw-watchpoints
2953 @kindex show can-use-hw-watchpoints
2954 Show the current mode of using hardware watchpoints.
2957 For remote targets, you can restrict the number of hardware
2958 watchpoints @value{GDBN} will use, see @ref{set remote
2959 hardware-breakpoint-limit}.
2961 When you issue the @code{watch} command, @value{GDBN} reports
2964 Hardware watchpoint @var{num}: @var{expr}
2968 if it was able to set a hardware watchpoint.
2970 Currently, the @code{awatch} and @code{rwatch} commands can only set
2971 hardware watchpoints, because accesses to data that don't change the
2972 value of the watched expression cannot be detected without examining
2973 every instruction as it is being executed, and @value{GDBN} does not do
2974 that currently. If @value{GDBN} finds that it is unable to set a
2975 hardware breakpoint with the @code{awatch} or @code{rwatch} command, it
2976 will print a message like this:
2979 Expression cannot be implemented with read/access watchpoint.
2982 Sometimes, @value{GDBN} cannot set a hardware watchpoint because the
2983 data type of the watched expression is wider than what a hardware
2984 watchpoint on the target machine can handle. For example, some systems
2985 can only watch regions that are up to 4 bytes wide; on such systems you
2986 cannot set hardware watchpoints for an expression that yields a
2987 double-precision floating-point number (which is typically 8 bytes
2988 wide). As a work-around, it might be possible to break the large region
2989 into a series of smaller ones and watch them with separate watchpoints.
2991 If you set too many hardware watchpoints, @value{GDBN} might be unable
2992 to insert all of them when you resume the execution of your program.
2993 Since the precise number of active watchpoints is unknown until such
2994 time as the program is about to be resumed, @value{GDBN} might not be
2995 able to warn you about this when you set the watchpoints, and the
2996 warning will be printed only when the program is resumed:
2999 Hardware watchpoint @var{num}: Could not insert watchpoint
3003 If this happens, delete or disable some of the watchpoints.
3005 The SPARClite DSU will generate traps when a program accesses some data
3006 or instruction address that is assigned to the debug registers. For the
3007 data addresses, DSU facilitates the @code{watch} command. However the
3008 hardware breakpoint registers can only take two data watchpoints, and
3009 both watchpoints must be the same kind. For example, you can set two
3010 watchpoints with @code{watch} commands, two with @code{rwatch} commands,
3011 @strong{or} two with @code{awatch} commands, but you cannot set one
3012 watchpoint with one command and the other with a different command.
3013 @value{GDBN} will reject the command if you try to mix watchpoints.
3014 Delete or disable unused watchpoint commands before setting new ones.
3016 If you call a function interactively using @code{print} or @code{call},
3017 any watchpoints you have set will be inactive until @value{GDBN} reaches another
3018 kind of breakpoint or the call completes.
3020 @value{GDBN} automatically deletes watchpoints that watch local
3021 (automatic) variables, or expressions that involve such variables, when
3022 they go out of scope, that is, when the execution leaves the block in
3023 which these variables were defined. In particular, when the program
3024 being debugged terminates, @emph{all} local variables go out of scope,
3025 and so only watchpoints that watch global variables remain set. If you
3026 rerun the program, you will need to set all such watchpoints again. One
3027 way of doing that would be to set a code breakpoint at the entry to the
3028 @code{main} function and when it breaks, set all the watchpoints.
3031 @cindex watchpoints and threads
3032 @cindex threads and watchpoints
3033 @emph{Warning:} In multi-thread programs, watchpoints have only limited
3034 usefulness. With the current watchpoint implementation, @value{GDBN}
3035 can only watch the value of an expression @emph{in a single thread}. If
3036 you are confident that the expression can only change due to the current
3037 thread's activity (and if you are also confident that no other thread
3038 can become current), then you can use watchpoints as usual. However,
3039 @value{GDBN} may not notice when a non-current thread's activity changes
3042 @c FIXME: this is almost identical to the previous paragraph.
3043 @emph{HP-UX Warning:} In multi-thread programs, software watchpoints
3044 have only limited usefulness. If @value{GDBN} creates a software
3045 watchpoint, it can only watch the value of an expression @emph{in a
3046 single thread}. If you are confident that the expression can only
3047 change due to the current thread's activity (and if you are also
3048 confident that no other thread can become current), then you can use
3049 software watchpoints as usual. However, @value{GDBN} may not notice
3050 when a non-current thread's activity changes the expression. (Hardware
3051 watchpoints, in contrast, watch an expression in all threads.)
3054 @xref{set remote hardware-watchpoint-limit}.
3056 @node Set Catchpoints
3057 @subsection Setting catchpoints
3058 @cindex catchpoints, setting
3059 @cindex exception handlers
3060 @cindex event handling
3062 You can use @dfn{catchpoints} to cause the debugger to stop for certain
3063 kinds of program events, such as C@t{++} exceptions or the loading of a
3064 shared library. Use the @code{catch} command to set a catchpoint.
3068 @item catch @var{event}
3069 Stop when @var{event} occurs. @var{event} can be any of the following:
3072 @cindex stop on C@t{++} exceptions
3073 The throwing of a C@t{++} exception.
3076 The catching of a C@t{++} exception.
3079 @cindex break on fork/exec
3080 A call to @code{exec}. This is currently only available for HP-UX.
3083 A call to @code{fork}. This is currently only available for HP-UX.
3086 A call to @code{vfork}. This is currently only available for HP-UX.
3089 @itemx load @var{libname}
3090 @cindex break on load/unload of shared library
3091 The dynamic loading of any shared library, or the loading of the library
3092 @var{libname}. This is currently only available for HP-UX.
3095 @itemx unload @var{libname}
3096 The unloading of any dynamically loaded shared library, or the unloading
3097 of the library @var{libname}. This is currently only available for HP-UX.
3100 @item tcatch @var{event}
3101 Set a catchpoint that is enabled only for one stop. The catchpoint is
3102 automatically deleted after the first time the event is caught.
3106 Use the @code{info break} command to list the current catchpoints.
3108 There are currently some limitations to C@t{++} exception handling
3109 (@code{catch throw} and @code{catch catch}) in @value{GDBN}:
3113 If you call a function interactively, @value{GDBN} normally returns
3114 control to you when the function has finished executing. If the call
3115 raises an exception, however, the call may bypass the mechanism that
3116 returns control to you and cause your program either to abort or to
3117 simply continue running until it hits a breakpoint, catches a signal
3118 that @value{GDBN} is listening for, or exits. This is the case even if
3119 you set a catchpoint for the exception; catchpoints on exceptions are
3120 disabled within interactive calls.
3123 You cannot raise an exception interactively.
3126 You cannot install an exception handler interactively.
3129 @cindex raise exceptions
3130 Sometimes @code{catch} is not the best way to debug exception handling:
3131 if you need to know exactly where an exception is raised, it is better to
3132 stop @emph{before} the exception handler is called, since that way you
3133 can see the stack before any unwinding takes place. If you set a
3134 breakpoint in an exception handler instead, it may not be easy to find
3135 out where the exception was raised.
3137 To stop just before an exception handler is called, you need some
3138 knowledge of the implementation. In the case of @sc{gnu} C@t{++}, exceptions are
3139 raised by calling a library function named @code{__raise_exception}
3140 which has the following ANSI C interface:
3143 /* @var{addr} is where the exception identifier is stored.
3144 @var{id} is the exception identifier. */
3145 void __raise_exception (void **addr, void *id);
3149 To make the debugger catch all exceptions before any stack
3150 unwinding takes place, set a breakpoint on @code{__raise_exception}
3151 (@pxref{Breakpoints, ,Breakpoints; watchpoints; and exceptions}).
3153 With a conditional breakpoint (@pxref{Conditions, ,Break conditions})
3154 that depends on the value of @var{id}, you can stop your program when
3155 a specific exception is raised. You can use multiple conditional
3156 breakpoints to stop your program when any of a number of exceptions are
3161 @subsection Deleting breakpoints
3163 @cindex clearing breakpoints, watchpoints, catchpoints
3164 @cindex deleting breakpoints, watchpoints, catchpoints
3165 It is often necessary to eliminate a breakpoint, watchpoint, or
3166 catchpoint once it has done its job and you no longer want your program
3167 to stop there. This is called @dfn{deleting} the breakpoint. A
3168 breakpoint that has been deleted no longer exists; it is forgotten.
3170 With the @code{clear} command you can delete breakpoints according to
3171 where they are in your program. With the @code{delete} command you can
3172 delete individual breakpoints, watchpoints, or catchpoints by specifying
3173 their breakpoint numbers.
3175 It is not necessary to delete a breakpoint to proceed past it. @value{GDBN}
3176 automatically ignores breakpoints on the first instruction to be executed
3177 when you continue execution without changing the execution address.
3182 Delete any breakpoints at the next instruction to be executed in the
3183 selected stack frame (@pxref{Selection, ,Selecting a frame}). When
3184 the innermost frame is selected, this is a good way to delete a
3185 breakpoint where your program just stopped.
3187 @item clear @var{function}
3188 @itemx clear @var{filename}:@var{function}
3189 Delete any breakpoints set at entry to the named @var{function}.
3191 @item clear @var{linenum}
3192 @itemx clear @var{filename}:@var{linenum}
3193 Delete any breakpoints set at or within the code of the specified
3194 @var{linenum} of the specified @var{filename}.
3196 @cindex delete breakpoints
3198 @kindex d @r{(@code{delete})}
3199 @item delete @r{[}breakpoints@r{]} @r{[}@var{range}@dots{}@r{]}
3200 Delete the breakpoints, watchpoints, or catchpoints of the breakpoint
3201 ranges specified as arguments. If no argument is specified, delete all
3202 breakpoints (@value{GDBN} asks confirmation, unless you have @code{set
3203 confirm off}). You can abbreviate this command as @code{d}.
3207 @subsection Disabling breakpoints
3209 @cindex enable/disable a breakpoint
3210 Rather than deleting a breakpoint, watchpoint, or catchpoint, you might
3211 prefer to @dfn{disable} it. This makes the breakpoint inoperative as if
3212 it had been deleted, but remembers the information on the breakpoint so
3213 that you can @dfn{enable} it again later.
3215 You disable and enable breakpoints, watchpoints, and catchpoints with
3216 the @code{enable} and @code{disable} commands, optionally specifying one
3217 or more breakpoint numbers as arguments. Use @code{info break} or
3218 @code{info watch} to print a list of breakpoints, watchpoints, and
3219 catchpoints if you do not know which numbers to use.
3221 A breakpoint, watchpoint, or catchpoint can have any of four different
3222 states of enablement:
3226 Enabled. The breakpoint stops your program. A breakpoint set
3227 with the @code{break} command starts out in this state.
3229 Disabled. The breakpoint has no effect on your program.
3231 Enabled once. The breakpoint stops your program, but then becomes
3234 Enabled for deletion. The breakpoint stops your program, but
3235 immediately after it does so it is deleted permanently. A breakpoint
3236 set with the @code{tbreak} command starts out in this state.
3239 You can use the following commands to enable or disable breakpoints,
3240 watchpoints, and catchpoints:
3244 @kindex dis @r{(@code{disable})}
3245 @item disable @r{[}breakpoints@r{]} @r{[}@var{range}@dots{}@r{]}
3246 Disable the specified breakpoints---or all breakpoints, if none are
3247 listed. A disabled breakpoint has no effect but is not forgotten. All
3248 options such as ignore-counts, conditions and commands are remembered in
3249 case the breakpoint is enabled again later. You may abbreviate
3250 @code{disable} as @code{dis}.
3253 @item enable @r{[}breakpoints@r{]} @r{[}@var{range}@dots{}@r{]}
3254 Enable the specified breakpoints (or all defined breakpoints). They
3255 become effective once again in stopping your program.
3257 @item enable @r{[}breakpoints@r{]} once @var{range}@dots{}
3258 Enable the specified breakpoints temporarily. @value{GDBN} disables any
3259 of these breakpoints immediately after stopping your program.
3261 @item enable @r{[}breakpoints@r{]} delete @var{range}@dots{}
3262 Enable the specified breakpoints to work once, then die. @value{GDBN}
3263 deletes any of these breakpoints as soon as your program stops there.
3264 Breakpoints set by the @code{tbreak} command start out in this state.
3267 @c FIXME: I think the following ``Except for [...] @code{tbreak}'' is
3268 @c confusing: tbreak is also initially enabled.
3269 Except for a breakpoint set with @code{tbreak} (@pxref{Set Breaks,
3270 ,Setting breakpoints}), breakpoints that you set are initially enabled;
3271 subsequently, they become disabled or enabled only when you use one of
3272 the commands above. (The command @code{until} can set and delete a
3273 breakpoint of its own, but it does not change the state of your other
3274 breakpoints; see @ref{Continuing and Stepping, ,Continuing and
3278 @subsection Break conditions
3279 @cindex conditional breakpoints
3280 @cindex breakpoint conditions
3282 @c FIXME what is scope of break condition expr? Context where wanted?
3283 @c in particular for a watchpoint?
3284 The simplest sort of breakpoint breaks every time your program reaches a
3285 specified place. You can also specify a @dfn{condition} for a
3286 breakpoint. A condition is just a Boolean expression in your
3287 programming language (@pxref{Expressions, ,Expressions}). A breakpoint with
3288 a condition evaluates the expression each time your program reaches it,
3289 and your program stops only if the condition is @emph{true}.
3291 This is the converse of using assertions for program validation; in that
3292 situation, you want to stop when the assertion is violated---that is,
3293 when the condition is false. In C, if you want to test an assertion expressed
3294 by the condition @var{assert}, you should set the condition
3295 @samp{! @var{assert}} on the appropriate breakpoint.
3297 Conditions are also accepted for watchpoints; you may not need them,
3298 since a watchpoint is inspecting the value of an expression anyhow---but
3299 it might be simpler, say, to just set a watchpoint on a variable name,
3300 and specify a condition that tests whether the new value is an interesting
3303 Break conditions can have side effects, and may even call functions in
3304 your program. This can be useful, for example, to activate functions
3305 that log program progress, or to use your own print functions to
3306 format special data structures. The effects are completely predictable
3307 unless there is another enabled breakpoint at the same address. (In
3308 that case, @value{GDBN} might see the other breakpoint first and stop your
3309 program without checking the condition of this one.) Note that
3310 breakpoint commands are usually more convenient and flexible than break
3312 purpose of performing side effects when a breakpoint is reached
3313 (@pxref{Break Commands, ,Breakpoint command lists}).
3315 Break conditions can be specified when a breakpoint is set, by using
3316 @samp{if} in the arguments to the @code{break} command. @xref{Set
3317 Breaks, ,Setting breakpoints}. They can also be changed at any time
3318 with the @code{condition} command.
3320 You can also use the @code{if} keyword with the @code{watch} command.
3321 The @code{catch} command does not recognize the @code{if} keyword;
3322 @code{condition} is the only way to impose a further condition on a
3327 @item condition @var{bnum} @var{expression}
3328 Specify @var{expression} as the break condition for breakpoint,
3329 watchpoint, or catchpoint number @var{bnum}. After you set a condition,
3330 breakpoint @var{bnum} stops your program only if the value of
3331 @var{expression} is true (nonzero, in C). When you use
3332 @code{condition}, @value{GDBN} checks @var{expression} immediately for
3333 syntactic correctness, and to determine whether symbols in it have
3334 referents in the context of your breakpoint. If @var{expression} uses
3335 symbols not referenced in the context of the breakpoint, @value{GDBN}
3336 prints an error message:
3339 No symbol "foo" in current context.
3344 not actually evaluate @var{expression} at the time the @code{condition}
3345 command (or a command that sets a breakpoint with a condition, like
3346 @code{break if @dots{}}) is given, however. @xref{Expressions, ,Expressions}.
3348 @item condition @var{bnum}
3349 Remove the condition from breakpoint number @var{bnum}. It becomes
3350 an ordinary unconditional breakpoint.
3353 @cindex ignore count (of breakpoint)
3354 A special case of a breakpoint condition is to stop only when the
3355 breakpoint has been reached a certain number of times. This is so
3356 useful that there is a special way to do it, using the @dfn{ignore
3357 count} of the breakpoint. Every breakpoint has an ignore count, which
3358 is an integer. Most of the time, the ignore count is zero, and
3359 therefore has no effect. But if your program reaches a breakpoint whose
3360 ignore count is positive, then instead of stopping, it just decrements
3361 the ignore count by one and continues. As a result, if the ignore count
3362 value is @var{n}, the breakpoint does not stop the next @var{n} times
3363 your program reaches it.
3367 @item ignore @var{bnum} @var{count}
3368 Set the ignore count of breakpoint number @var{bnum} to @var{count}.
3369 The next @var{count} times the breakpoint is reached, your program's
3370 execution does not stop; other than to decrement the ignore count, @value{GDBN}
3373 To make the breakpoint stop the next time it is reached, specify
3376 When you use @code{continue} to resume execution of your program from a
3377 breakpoint, you can specify an ignore count directly as an argument to
3378 @code{continue}, rather than using @code{ignore}. @xref{Continuing and
3379 Stepping,,Continuing and stepping}.
3381 If a breakpoint has a positive ignore count and a condition, the
3382 condition is not checked. Once the ignore count reaches zero,
3383 @value{GDBN} resumes checking the condition.
3385 You could achieve the effect of the ignore count with a condition such
3386 as @w{@samp{$foo-- <= 0}} using a debugger convenience variable that
3387 is decremented each time. @xref{Convenience Vars, ,Convenience
3391 Ignore counts apply to breakpoints, watchpoints, and catchpoints.
3394 @node Break Commands
3395 @subsection Breakpoint command lists
3397 @cindex breakpoint commands
3398 You can give any breakpoint (or watchpoint or catchpoint) a series of
3399 commands to execute when your program stops due to that breakpoint. For
3400 example, you might want to print the values of certain expressions, or
3401 enable other breakpoints.
3406 @item commands @r{[}@var{bnum}@r{]}
3407 @itemx @dots{} @var{command-list} @dots{}
3409 Specify a list of commands for breakpoint number @var{bnum}. The commands
3410 themselves appear on the following lines. Type a line containing just
3411 @code{end} to terminate the commands.
3413 To remove all commands from a breakpoint, type @code{commands} and
3414 follow it immediately with @code{end}; that is, give no commands.
3416 With no @var{bnum} argument, @code{commands} refers to the last
3417 breakpoint, watchpoint, or catchpoint set (not to the breakpoint most
3418 recently encountered).
3421 Pressing @key{RET} as a means of repeating the last @value{GDBN} command is
3422 disabled within a @var{command-list}.
3424 You can use breakpoint commands to start your program up again. Simply
3425 use the @code{continue} command, or @code{step}, or any other command
3426 that resumes execution.
3428 Any other commands in the command list, after a command that resumes
3429 execution, are ignored. This is because any time you resume execution
3430 (even with a simple @code{next} or @code{step}), you may encounter
3431 another breakpoint---which could have its own command list, leading to
3432 ambiguities about which list to execute.
3435 If the first command you specify in a command list is @code{silent}, the
3436 usual message about stopping at a breakpoint is not printed. This may
3437 be desirable for breakpoints that are to print a specific message and
3438 then continue. If none of the remaining commands print anything, you
3439 see no sign that the breakpoint was reached. @code{silent} is
3440 meaningful only at the beginning of a breakpoint command list.
3442 The commands @code{echo}, @code{output}, and @code{printf} allow you to
3443 print precisely controlled output, and are often useful in silent
3444 breakpoints. @xref{Output, ,Commands for controlled output}.
3446 For example, here is how you could use breakpoint commands to print the
3447 value of @code{x} at entry to @code{foo} whenever @code{x} is positive.
3453 printf "x is %d\n",x
3458 One application for breakpoint commands is to compensate for one bug so
3459 you can test for another. Put a breakpoint just after the erroneous line
3460 of code, give it a condition to detect the case in which something
3461 erroneous has been done, and give it commands to assign correct values
3462 to any variables that need them. End with the @code{continue} command
3463 so that your program does not stop, and start with the @code{silent}
3464 command so that no output is produced. Here is an example:
3475 @node Breakpoint Menus
3476 @subsection Breakpoint menus
3478 @cindex symbol overloading
3480 Some programming languages (notably C@t{++} and Objective-C) permit a
3481 single function name
3482 to be defined several times, for application in different contexts.
3483 This is called @dfn{overloading}. When a function name is overloaded,
3484 @samp{break @var{function}} is not enough to tell @value{GDBN} where you want
3485 a breakpoint. If you realize this is a problem, you can use
3486 something like @samp{break @var{function}(@var{types})} to specify which
3487 particular version of the function you want. Otherwise, @value{GDBN} offers
3488 you a menu of numbered choices for different possible breakpoints, and
3489 waits for your selection with the prompt @samp{>}. The first two
3490 options are always @samp{[0] cancel} and @samp{[1] all}. Typing @kbd{1}
3491 sets a breakpoint at each definition of @var{function}, and typing
3492 @kbd{0} aborts the @code{break} command without setting any new
3495 For example, the following session excerpt shows an attempt to set a
3496 breakpoint at the overloaded symbol @code{String::after}.
3497 We choose three particular definitions of that function name:
3499 @c FIXME! This is likely to change to show arg type lists, at least
3502 (@value{GDBP}) b String::after
3505 [2] file:String.cc; line number:867
3506 [3] file:String.cc; line number:860
3507 [4] file:String.cc; line number:875
3508 [5] file:String.cc; line number:853
3509 [6] file:String.cc; line number:846
3510 [7] file:String.cc; line number:735
3512 Breakpoint 1 at 0xb26c: file String.cc, line 867.
3513 Breakpoint 2 at 0xb344: file String.cc, line 875.
3514 Breakpoint 3 at 0xafcc: file String.cc, line 846.
3515 Multiple breakpoints were set.
3516 Use the "delete" command to delete unwanted
3522 @c @ifclear BARETARGET
3523 @node Error in Breakpoints
3524 @subsection ``Cannot insert breakpoints''
3526 @c FIXME!! 14/6/95 Is there a real example of this? Let's use it.
3528 Under some operating systems, breakpoints cannot be used in a program if
3529 any other process is running that program. In this situation,
3530 attempting to run or continue a program with a breakpoint causes
3531 @value{GDBN} to print an error message:
3534 Cannot insert breakpoints.
3535 The same program may be running in another process.
3538 When this happens, you have three ways to proceed:
3542 Remove or disable the breakpoints, then continue.
3545 Suspend @value{GDBN}, and copy the file containing your program to a new
3546 name. Resume @value{GDBN} and use the @code{exec-file} command to specify
3547 that @value{GDBN} should run your program under that name.
3548 Then start your program again.
3551 Relink your program so that the text segment is nonsharable, using the
3552 linker option @samp{-N}. The operating system limitation may not apply
3553 to nonsharable executables.
3557 A similar message can be printed if you request too many active
3558 hardware-assisted breakpoints and watchpoints:
3560 @c FIXME: the precise wording of this message may change; the relevant
3561 @c source change is not committed yet (Sep 3, 1999).
3563 Stopped; cannot insert breakpoints.
3564 You may have requested too many hardware breakpoints and watchpoints.
3568 This message is printed when you attempt to resume the program, since
3569 only then @value{GDBN} knows exactly how many hardware breakpoints and
3570 watchpoints it needs to insert.
3572 When this message is printed, you need to disable or remove some of the
3573 hardware-assisted breakpoints and watchpoints, and then continue.
3575 @node Breakpoint related warnings
3576 @subsection ``Breakpoint address adjusted...''
3577 @cindex breakpoint address adjusted
3579 Some processor architectures place constraints on the addresses at
3580 which breakpoints may be placed. For architectures thus constrained,
3581 @value{GDBN} will attempt to adjust the breakpoint's address to comply
3582 with the constraints dictated by the architecture.
3584 One example of such an architecture is the Fujitsu FR-V. The FR-V is
3585 a VLIW architecture in which a number of RISC-like instructions may be
3586 bundled together for parallel execution. The FR-V architecture
3587 constrains the location of a breakpoint instruction within such a
3588 bundle to the instruction with the lowest address. @value{GDBN}
3589 honors this constraint by adjusting a breakpoint's address to the
3590 first in the bundle.
3592 It is not uncommon for optimized code to have bundles which contain
3593 instructions from different source statements, thus it may happen that
3594 a breakpoint's address will be adjusted from one source statement to
3595 another. Since this adjustment may significantly alter @value{GDBN}'s
3596 breakpoint related behavior from what the user expects, a warning is
3597 printed when the breakpoint is first set and also when the breakpoint
3600 A warning like the one below is printed when setting a breakpoint
3601 that's been subject to address adjustment:
3604 warning: Breakpoint address adjusted from 0x00010414 to 0x00010410.
3607 Such warnings are printed both for user settable and @value{GDBN}'s
3608 internal breakpoints. If you see one of these warnings, you should
3609 verify that a breakpoint set at the adjusted address will have the
3610 desired affect. If not, the breakpoint in question may be removed and
3611 other breakpoints may be set which will have the desired behavior.
3612 E.g., it may be sufficient to place the breakpoint at a later
3613 instruction. A conditional breakpoint may also be useful in some
3614 cases to prevent the breakpoint from triggering too often.
3616 @value{GDBN} will also issue a warning when stopping at one of these
3617 adjusted breakpoints:
3620 warning: Breakpoint 1 address previously adjusted from 0x00010414
3624 When this warning is encountered, it may be too late to take remedial
3625 action except in cases where the breakpoint is hit earlier or more
3626 frequently than expected.
3628 @node Continuing and Stepping
3629 @section Continuing and stepping
3633 @cindex resuming execution
3634 @dfn{Continuing} means resuming program execution until your program
3635 completes normally. In contrast, @dfn{stepping} means executing just
3636 one more ``step'' of your program, where ``step'' may mean either one
3637 line of source code, or one machine instruction (depending on what
3638 particular command you use). Either when continuing or when stepping,
3639 your program may stop even sooner, due to a breakpoint or a signal. (If
3640 it stops due to a signal, you may want to use @code{handle}, or use
3641 @samp{signal 0} to resume execution. @xref{Signals, ,Signals}.)
3645 @kindex c @r{(@code{continue})}
3646 @kindex fg @r{(resume foreground execution)}
3647 @item continue @r{[}@var{ignore-count}@r{]}
3648 @itemx c @r{[}@var{ignore-count}@r{]}
3649 @itemx fg @r{[}@var{ignore-count}@r{]}
3650 Resume program execution, at the address where your program last stopped;
3651 any breakpoints set at that address are bypassed. The optional argument
3652 @var{ignore-count} allows you to specify a further number of times to
3653 ignore a breakpoint at this location; its effect is like that of
3654 @code{ignore} (@pxref{Conditions, ,Break conditions}).
3656 The argument @var{ignore-count} is meaningful only when your program
3657 stopped due to a breakpoint. At other times, the argument to
3658 @code{continue} is ignored.
3660 The synonyms @code{c} and @code{fg} (for @dfn{foreground}, as the
3661 debugged program is deemed to be the foreground program) are provided
3662 purely for convenience, and have exactly the same behavior as
3666 To resume execution at a different place, you can use @code{return}
3667 (@pxref{Returning, ,Returning from a function}) to go back to the
3668 calling function; or @code{jump} (@pxref{Jumping, ,Continuing at a
3669 different address}) to go to an arbitrary location in your program.
3671 A typical technique for using stepping is to set a breakpoint
3672 (@pxref{Breakpoints, ,Breakpoints; watchpoints; and catchpoints}) at the
3673 beginning of the function or the section of your program where a problem
3674 is believed to lie, run your program until it stops at that breakpoint,
3675 and then step through the suspect area, examining the variables that are
3676 interesting, until you see the problem happen.
3680 @kindex s @r{(@code{step})}
3682 Continue running your program until control reaches a different source
3683 line, then stop it and return control to @value{GDBN}. This command is
3684 abbreviated @code{s}.
3687 @c "without debugging information" is imprecise; actually "without line
3688 @c numbers in the debugging information". (gcc -g1 has debugging info but
3689 @c not line numbers). But it seems complex to try to make that
3690 @c distinction here.
3691 @emph{Warning:} If you use the @code{step} command while control is
3692 within a function that was compiled without debugging information,
3693 execution proceeds until control reaches a function that does have
3694 debugging information. Likewise, it will not step into a function which
3695 is compiled without debugging information. To step through functions
3696 without debugging information, use the @code{stepi} command, described
3700 The @code{step} command only stops at the first instruction of a source
3701 line. This prevents the multiple stops that could otherwise occur in
3702 @code{switch} statements, @code{for} loops, etc. @code{step} continues
3703 to stop if a function that has debugging information is called within
3704 the line. In other words, @code{step} @emph{steps inside} any functions
3705 called within the line.
3707 Also, the @code{step} command only enters a function if there is line
3708 number information for the function. Otherwise it acts like the
3709 @code{next} command. This avoids problems when using @code{cc -gl}
3710 on MIPS machines. Previously, @code{step} entered subroutines if there
3711 was any debugging information about the routine.
3713 @item step @var{count}
3714 Continue running as in @code{step}, but do so @var{count} times. If a
3715 breakpoint is reached, or a signal not related to stepping occurs before
3716 @var{count} steps, stepping stops right away.
3719 @kindex n @r{(@code{next})}
3720 @item next @r{[}@var{count}@r{]}
3721 Continue to the next source line in the current (innermost) stack frame.
3722 This is similar to @code{step}, but function calls that appear within
3723 the line of code are executed without stopping. Execution stops when
3724 control reaches a different line of code at the original stack level
3725 that was executing when you gave the @code{next} command. This command
3726 is abbreviated @code{n}.
3728 An argument @var{count} is a repeat count, as for @code{step}.
3731 @c FIX ME!! Do we delete this, or is there a way it fits in with
3732 @c the following paragraph? --- Vctoria
3734 @c @code{next} within a function that lacks debugging information acts like
3735 @c @code{step}, but any function calls appearing within the code of the
3736 @c function are executed without stopping.
3738 The @code{next} command only stops at the first instruction of a
3739 source line. This prevents multiple stops that could otherwise occur in
3740 @code{switch} statements, @code{for} loops, etc.
3742 @kindex set step-mode
3744 @cindex functions without line info, and stepping
3745 @cindex stepping into functions with no line info
3746 @itemx set step-mode on
3747 The @code{set step-mode on} command causes the @code{step} command to
3748 stop at the first instruction of a function which contains no debug line
3749 information rather than stepping over it.
3751 This is useful in cases where you may be interested in inspecting the
3752 machine instructions of a function which has no symbolic info and do not
3753 want @value{GDBN} to automatically skip over this function.
3755 @item set step-mode off
3756 Causes the @code{step} command to step over any functions which contains no
3757 debug information. This is the default.
3759 @item show step-mode
3760 Show whether @value{GDBN} will stop in or step over functions without
3761 source line debug information.
3765 Continue running until just after function in the selected stack frame
3766 returns. Print the returned value (if any).
3768 Contrast this with the @code{return} command (@pxref{Returning,
3769 ,Returning from a function}).
3772 @kindex u @r{(@code{until})}
3773 @cindex run until specified location
3776 Continue running until a source line past the current line, in the
3777 current stack frame, is reached. This command is used to avoid single
3778 stepping through a loop more than once. It is like the @code{next}
3779 command, except that when @code{until} encounters a jump, it
3780 automatically continues execution until the program counter is greater
3781 than the address of the jump.
3783 This means that when you reach the end of a loop after single stepping
3784 though it, @code{until} makes your program continue execution until it
3785 exits the loop. In contrast, a @code{next} command at the end of a loop
3786 simply steps back to the beginning of the loop, which forces you to step
3787 through the next iteration.
3789 @code{until} always stops your program if it attempts to exit the current
3792 @code{until} may produce somewhat counterintuitive results if the order
3793 of machine code does not match the order of the source lines. For
3794 example, in the following excerpt from a debugging session, the @code{f}
3795 (@code{frame}) command shows that execution is stopped at line
3796 @code{206}; yet when we use @code{until}, we get to line @code{195}:
3800 #0 main (argc=4, argv=0xf7fffae8) at m4.c:206
3802 (@value{GDBP}) until
3803 195 for ( ; argc > 0; NEXTARG) @{
3806 This happened because, for execution efficiency, the compiler had
3807 generated code for the loop closure test at the end, rather than the
3808 start, of the loop---even though the test in a C @code{for}-loop is
3809 written before the body of the loop. The @code{until} command appeared
3810 to step back to the beginning of the loop when it advanced to this
3811 expression; however, it has not really gone to an earlier
3812 statement---not in terms of the actual machine code.
3814 @code{until} with no argument works by means of single
3815 instruction stepping, and hence is slower than @code{until} with an
3818 @item until @var{location}
3819 @itemx u @var{location}
3820 Continue running your program until either the specified location is
3821 reached, or the current stack frame returns. @var{location} is any of
3822 the forms of argument acceptable to @code{break} (@pxref{Set Breaks,
3823 ,Setting breakpoints}). This form of the command uses breakpoints, and
3824 hence is quicker than @code{until} without an argument. The specified
3825 location is actually reached only if it is in the current frame. This
3826 implies that @code{until} can be used to skip over recursive function
3827 invocations. For instance in the code below, if the current location is
3828 line @code{96}, issuing @code{until 99} will execute the program up to
3829 line @code{99} in the same invocation of factorial, i.e. after the inner
3830 invocations have returned.
3833 94 int factorial (int value)
3835 96 if (value > 1) @{
3836 97 value *= factorial (value - 1);
3843 @kindex advance @var{location}
3844 @itemx advance @var{location}
3845 Continue running the program up to the given @var{location}. An argument is
3846 required, which should be of the same form as arguments for the @code{break}
3847 command. Execution will also stop upon exit from the current stack
3848 frame. This command is similar to @code{until}, but @code{advance} will
3849 not skip over recursive function calls, and the target location doesn't
3850 have to be in the same frame as the current one.
3854 @kindex si @r{(@code{stepi})}
3856 @itemx stepi @var{arg}
3858 Execute one machine instruction, then stop and return to the debugger.
3860 It is often useful to do @samp{display/i $pc} when stepping by machine
3861 instructions. This makes @value{GDBN} automatically display the next
3862 instruction to be executed, each time your program stops. @xref{Auto
3863 Display,, Automatic display}.
3865 An argument is a repeat count, as in @code{step}.
3869 @kindex ni @r{(@code{nexti})}
3871 @itemx nexti @var{arg}
3873 Execute one machine instruction, but if it is a function call,
3874 proceed until the function returns.
3876 An argument is a repeat count, as in @code{next}.
3883 A signal is an asynchronous event that can happen in a program. The
3884 operating system defines the possible kinds of signals, and gives each
3885 kind a name and a number. For example, in Unix @code{SIGINT} is the
3886 signal a program gets when you type an interrupt character (often @kbd{C-c});
3887 @code{SIGSEGV} is the signal a program gets from referencing a place in
3888 memory far away from all the areas in use; @code{SIGALRM} occurs when
3889 the alarm clock timer goes off (which happens only if your program has
3890 requested an alarm).
3892 @cindex fatal signals
3893 Some signals, including @code{SIGALRM}, are a normal part of the
3894 functioning of your program. Others, such as @code{SIGSEGV}, indicate
3895 errors; these signals are @dfn{fatal} (they kill your program immediately) if the
3896 program has not specified in advance some other way to handle the signal.
3897 @code{SIGINT} does not indicate an error in your program, but it is normally
3898 fatal so it can carry out the purpose of the interrupt: to kill the program.
3900 @value{GDBN} has the ability to detect any occurrence of a signal in your
3901 program. You can tell @value{GDBN} in advance what to do for each kind of
3904 @cindex handling signals
3905 Normally, @value{GDBN} is set up to let the non-erroneous signals like
3906 @code{SIGALRM} be silently passed to your program
3907 (so as not to interfere with their role in the program's functioning)
3908 but to stop your program immediately whenever an error signal happens.
3909 You can change these settings with the @code{handle} command.
3912 @kindex info signals
3916 Print a table of all the kinds of signals and how @value{GDBN} has been told to
3917 handle each one. You can use this to see the signal numbers of all
3918 the defined types of signals.
3920 @code{info handle} is an alias for @code{info signals}.
3923 @item handle @var{signal} @var{keywords}@dots{}
3924 Change the way @value{GDBN} handles signal @var{signal}. @var{signal}
3925 can be the number of a signal or its name (with or without the
3926 @samp{SIG} at the beginning); a list of signal numbers of the form
3927 @samp{@var{low}-@var{high}}; or the word @samp{all}, meaning all the
3928 known signals. The @var{keywords} say what change to make.
3932 The keywords allowed by the @code{handle} command can be abbreviated.
3933 Their full names are:
3937 @value{GDBN} should not stop your program when this signal happens. It may
3938 still print a message telling you that the signal has come in.
3941 @value{GDBN} should stop your program when this signal happens. This implies
3942 the @code{print} keyword as well.
3945 @value{GDBN} should print a message when this signal happens.
3948 @value{GDBN} should not mention the occurrence of the signal at all. This
3949 implies the @code{nostop} keyword as well.
3953 @value{GDBN} should allow your program to see this signal; your program
3954 can handle the signal, or else it may terminate if the signal is fatal
3955 and not handled. @code{pass} and @code{noignore} are synonyms.
3959 @value{GDBN} should not allow your program to see this signal.
3960 @code{nopass} and @code{ignore} are synonyms.
3964 When a signal stops your program, the signal is not visible to the
3966 continue. Your program sees the signal then, if @code{pass} is in
3967 effect for the signal in question @emph{at that time}. In other words,
3968 after @value{GDBN} reports a signal, you can use the @code{handle}
3969 command with @code{pass} or @code{nopass} to control whether your
3970 program sees that signal when you continue.
3972 The default is set to @code{nostop}, @code{noprint}, @code{pass} for
3973 non-erroneous signals such as @code{SIGALRM}, @code{SIGWINCH} and
3974 @code{SIGCHLD}, and to @code{stop}, @code{print}, @code{pass} for the
3977 You can also use the @code{signal} command to prevent your program from
3978 seeing a signal, or cause it to see a signal it normally would not see,
3979 or to give it any signal at any time. For example, if your program stopped
3980 due to some sort of memory reference error, you might store correct
3981 values into the erroneous variables and continue, hoping to see more
3982 execution; but your program would probably terminate immediately as
3983 a result of the fatal signal once it saw the signal. To prevent this,
3984 you can continue with @samp{signal 0}. @xref{Signaling, ,Giving your
3988 @section Stopping and starting multi-thread programs
3990 When your program has multiple threads (@pxref{Threads,, Debugging
3991 programs with multiple threads}), you can choose whether to set
3992 breakpoints on all threads, or on a particular thread.
3995 @cindex breakpoints and threads
3996 @cindex thread breakpoints
3997 @kindex break @dots{} thread @var{threadno}
3998 @item break @var{linespec} thread @var{threadno}
3999 @itemx break @var{linespec} thread @var{threadno} if @dots{}
4000 @var{linespec} specifies source lines; there are several ways of
4001 writing them, but the effect is always to specify some source line.
4003 Use the qualifier @samp{thread @var{threadno}} with a breakpoint command
4004 to specify that you only want @value{GDBN} to stop the program when a
4005 particular thread reaches this breakpoint. @var{threadno} is one of the
4006 numeric thread identifiers assigned by @value{GDBN}, shown in the first
4007 column of the @samp{info threads} display.
4009 If you do not specify @samp{thread @var{threadno}} when you set a
4010 breakpoint, the breakpoint applies to @emph{all} threads of your
4013 You can use the @code{thread} qualifier on conditional breakpoints as
4014 well; in this case, place @samp{thread @var{threadno}} before the
4015 breakpoint condition, like this:
4018 (@value{GDBP}) break frik.c:13 thread 28 if bartab > lim
4023 @cindex stopped threads
4024 @cindex threads, stopped
4025 Whenever your program stops under @value{GDBN} for any reason,
4026 @emph{all} threads of execution stop, not just the current thread. This
4027 allows you to examine the overall state of the program, including
4028 switching between threads, without worrying that things may change
4031 @cindex thread breakpoints and system calls
4032 @cindex system calls and thread breakpoints
4033 @cindex premature return from system calls
4034 There is an unfortunate side effect. If one thread stops for a
4035 breakpoint, or for some other reason, and another thread is blocked in a
4036 system call, then the system call may return prematurely. This is a
4037 consequence of the interaction between multiple threads and the signals
4038 that @value{GDBN} uses to implement breakpoints and other events that
4041 To handle this problem, your program should check the return value of
4042 each system call and react appropriately. This is good programming
4045 For example, do not write code like this:
4051 The call to @code{sleep} will return early if a different thread stops
4052 at a breakpoint or for some other reason.
4054 Instead, write this:
4059 unslept = sleep (unslept);
4062 A system call is allowed to return early, so the system is still
4063 conforming to its specification. But @value{GDBN} does cause your
4064 multi-threaded program to behave differently than it would without
4067 Also, @value{GDBN} uses internal breakpoints in the thread library to
4068 monitor certain events such as thread creation and thread destruction.
4069 When such an event happens, a system call in another thread may return
4070 prematurely, even though your program does not appear to stop.
4072 @cindex continuing threads
4073 @cindex threads, continuing
4074 Conversely, whenever you restart the program, @emph{all} threads start
4075 executing. @emph{This is true even when single-stepping} with commands
4076 like @code{step} or @code{next}.
4078 In particular, @value{GDBN} cannot single-step all threads in lockstep.
4079 Since thread scheduling is up to your debugging target's operating
4080 system (not controlled by @value{GDBN}), other threads may
4081 execute more than one statement while the current thread completes a
4082 single step. Moreover, in general other threads stop in the middle of a
4083 statement, rather than at a clean statement boundary, when the program
4086 You might even find your program stopped in another thread after
4087 continuing or even single-stepping. This happens whenever some other
4088 thread runs into a breakpoint, a signal, or an exception before the
4089 first thread completes whatever you requested.
4091 On some OSes, you can lock the OS scheduler and thus allow only a single
4095 @item set scheduler-locking @var{mode}
4096 @cindex scheduler locking mode
4097 @cindex lock scheduler
4098 Set the scheduler locking mode. If it is @code{off}, then there is no
4099 locking and any thread may run at any time. If @code{on}, then only the
4100 current thread may run when the inferior is resumed. The @code{step}
4101 mode optimizes for single-stepping. It stops other threads from
4102 ``seizing the prompt'' by preempting the current thread while you are
4103 stepping. Other threads will only rarely (or never) get a chance to run
4104 when you step. They are more likely to run when you @samp{next} over a
4105 function call, and they are completely free to run when you use commands
4106 like @samp{continue}, @samp{until}, or @samp{finish}. However, unless another
4107 thread hits a breakpoint during its timeslice, they will never steal the
4108 @value{GDBN} prompt away from the thread that you are debugging.
4110 @item show scheduler-locking
4111 Display the current scheduler locking mode.
4116 @chapter Examining the Stack
4118 When your program has stopped, the first thing you need to know is where it
4119 stopped and how it got there.
4122 Each time your program performs a function call, information about the call
4124 That information includes the location of the call in your program,
4125 the arguments of the call,
4126 and the local variables of the function being called.
4127 The information is saved in a block of data called a @dfn{stack frame}.
4128 The stack frames are allocated in a region of memory called the @dfn{call
4131 When your program stops, the @value{GDBN} commands for examining the
4132 stack allow you to see all of this information.
4134 @cindex selected frame
4135 One of the stack frames is @dfn{selected} by @value{GDBN} and many
4136 @value{GDBN} commands refer implicitly to the selected frame. In
4137 particular, whenever you ask @value{GDBN} for the value of a variable in
4138 your program, the value is found in the selected frame. There are
4139 special @value{GDBN} commands to select whichever frame you are
4140 interested in. @xref{Selection, ,Selecting a frame}.
4142 When your program stops, @value{GDBN} automatically selects the
4143 currently executing frame and describes it briefly, similar to the
4144 @code{frame} command (@pxref{Frame Info, ,Information about a frame}).
4147 * Frames:: Stack frames
4148 * Backtrace:: Backtraces
4149 * Selection:: Selecting a frame
4150 * Frame Info:: Information on a frame
4155 @section Stack frames
4157 @cindex frame, definition
4159 The call stack is divided up into contiguous pieces called @dfn{stack
4160 frames}, or @dfn{frames} for short; each frame is the data associated
4161 with one call to one function. The frame contains the arguments given
4162 to the function, the function's local variables, and the address at
4163 which the function is executing.
4165 @cindex initial frame
4166 @cindex outermost frame
4167 @cindex innermost frame
4168 When your program is started, the stack has only one frame, that of the
4169 function @code{main}. This is called the @dfn{initial} frame or the
4170 @dfn{outermost} frame. Each time a function is called, a new frame is
4171 made. Each time a function returns, the frame for that function invocation
4172 is eliminated. If a function is recursive, there can be many frames for
4173 the same function. The frame for the function in which execution is
4174 actually occurring is called the @dfn{innermost} frame. This is the most
4175 recently created of all the stack frames that still exist.
4177 @cindex frame pointer
4178 Inside your program, stack frames are identified by their addresses. A
4179 stack frame consists of many bytes, each of which has its own address; each
4180 kind of computer has a convention for choosing one byte whose
4181 address serves as the address of the frame. Usually this address is kept
4182 in a register called the @dfn{frame pointer register}
4183 (@pxref{Registers, $fp}) while execution is going on in that frame.
4185 @cindex frame number
4186 @value{GDBN} assigns numbers to all existing stack frames, starting with
4187 zero for the innermost frame, one for the frame that called it,
4188 and so on upward. These numbers do not really exist in your program;
4189 they are assigned by @value{GDBN} to give you a way of designating stack
4190 frames in @value{GDBN} commands.
4192 @c The -fomit-frame-pointer below perennially causes hbox overflow
4193 @c underflow problems.
4194 @cindex frameless execution
4195 Some compilers provide a way to compile functions so that they operate
4196 without stack frames. (For example, the @value{GCC} option
4198 @samp{-fomit-frame-pointer}
4200 generates functions without a frame.)
4201 This is occasionally done with heavily used library functions to save
4202 the frame setup time. @value{GDBN} has limited facilities for dealing
4203 with these function invocations. If the innermost function invocation
4204 has no stack frame, @value{GDBN} nevertheless regards it as though
4205 it had a separate frame, which is numbered zero as usual, allowing
4206 correct tracing of the function call chain. However, @value{GDBN} has
4207 no provision for frameless functions elsewhere in the stack.
4210 @kindex frame@r{, command}
4211 @cindex current stack frame
4212 @item frame @var{args}
4213 The @code{frame} command allows you to move from one stack frame to another,
4214 and to print the stack frame you select. @var{args} may be either the
4215 address of the frame or the stack frame number. Without an argument,
4216 @code{frame} prints the current stack frame.
4218 @kindex select-frame
4219 @cindex selecting frame silently
4221 The @code{select-frame} command allows you to move from one stack frame
4222 to another without printing the frame. This is the silent version of
4230 @cindex call stack traces
4231 A backtrace is a summary of how your program got where it is. It shows one
4232 line per frame, for many frames, starting with the currently executing
4233 frame (frame zero), followed by its caller (frame one), and on up the
4238 @kindex bt @r{(@code{backtrace})}
4241 Print a backtrace of the entire stack: one line per frame for all
4242 frames in the stack.
4244 You can stop the backtrace at any time by typing the system interrupt
4245 character, normally @kbd{C-c}.
4247 @item backtrace @var{n}
4249 Similar, but print only the innermost @var{n} frames.
4251 @item backtrace -@var{n}
4253 Similar, but print only the outermost @var{n} frames.
4255 @item backtrace full
4256 Print the values of the local variables also.
4262 The names @code{where} and @code{info stack} (abbreviated @code{info s})
4263 are additional aliases for @code{backtrace}.
4265 Each line in the backtrace shows the frame number and the function name.
4266 The program counter value is also shown---unless you use @code{set
4267 print address off}. The backtrace also shows the source file name and
4268 line number, as well as the arguments to the function. The program
4269 counter value is omitted if it is at the beginning of the code for that
4272 Here is an example of a backtrace. It was made with the command
4273 @samp{bt 3}, so it shows the innermost three frames.
4277 #0 m4_traceon (obs=0x24eb0, argc=1, argv=0x2b8c8)
4279 #1 0x6e38 in expand_macro (sym=0x2b600) at macro.c:242
4280 #2 0x6840 in expand_token (obs=0x0, t=177664, td=0xf7fffb08)
4282 (More stack frames follow...)
4287 The display for frame zero does not begin with a program counter
4288 value, indicating that your program has stopped at the beginning of the
4289 code for line @code{993} of @code{builtin.c}.
4291 @cindex value optimized out, in backtrace
4292 @cindex function call arguments, optimized out
4293 If your program was compiled with optimizations, some compilers will
4294 optimize away arguments passed to functions if those arguments are
4295 never used after the call. Such optimizations generate code that
4296 passes arguments through registers, but doesn't store those arguments
4297 in the stack frame. @value{GDBN} has no way of displaying such
4298 arguments in stack frames other than the innermost one. Here's what
4299 such a backtrace might look like:
4303 #0 m4_traceon (obs=0x24eb0, argc=1, argv=0x2b8c8)
4305 #1 0x6e38 in expand_macro (sym=<value optimized out>) at macro.c:242
4306 #2 0x6840 in expand_token (obs=0x0, t=<value optimized out>, td=0xf7fffb08)
4308 (More stack frames follow...)
4313 The values of arguments that were not saved in their stack frames are
4314 shown as @samp{<value optimized out>}.
4316 If you need to display the values of such optimized-out arguments,
4317 either deduce that from other variables whose values depend on the one
4318 you are interested in, or recompile without optimizations.
4320 @cindex backtrace beyond @code{main} function
4321 @cindex program entry point
4322 @cindex startup code, and backtrace
4323 Most programs have a standard user entry point---a place where system
4324 libraries and startup code transition into user code. For C this is
4325 @code{main}@footnote{
4326 Note that embedded programs (the so-called ``free-standing''
4327 environment) are not required to have a @code{main} function as the
4328 entry point. They could even have multiple entry points.}.
4329 When @value{GDBN} finds the entry function in a backtrace
4330 it will terminate the backtrace, to avoid tracing into highly
4331 system-specific (and generally uninteresting) code.
4333 If you need to examine the startup code, or limit the number of levels
4334 in a backtrace, you can change this behavior:
4337 @item set backtrace past-main
4338 @itemx set backtrace past-main on
4339 @kindex set backtrace
4340 Backtraces will continue past the user entry point.
4342 @item set backtrace past-main off
4343 Backtraces will stop when they encounter the user entry point. This is the
4346 @item show backtrace past-main
4347 @kindex show backtrace
4348 Display the current user entry point backtrace policy.
4350 @item set backtrace past-entry
4351 @itemx set backtrace past-entry on
4352 Backtraces will continue past the internal entry point of an application.
4353 This entry point is encoded by the linker when the application is built,
4354 and is likely before the user entry point @code{main} (or equivalent) is called.
4356 @item set backtrace past-entry off
4357 Backtraces will stop when they encouter the internal entry point of an
4358 application. This is the default.
4360 @item show backtrace past-entry
4361 Display the current internal entry point backtrace policy.
4363 @item set backtrace limit @var{n}
4364 @itemx set backtrace limit 0
4365 @cindex backtrace limit
4366 Limit the backtrace to @var{n} levels. A value of zero means
4369 @item show backtrace limit
4370 Display the current limit on backtrace levels.
4374 @section Selecting a frame
4376 Most commands for examining the stack and other data in your program work on
4377 whichever stack frame is selected at the moment. Here are the commands for
4378 selecting a stack frame; all of them finish by printing a brief description
4379 of the stack frame just selected.
4382 @kindex frame@r{, selecting}
4383 @kindex f @r{(@code{frame})}
4386 Select frame number @var{n}. Recall that frame zero is the innermost
4387 (currently executing) frame, frame one is the frame that called the
4388 innermost one, and so on. The highest-numbered frame is the one for
4391 @item frame @var{addr}
4393 Select the frame at address @var{addr}. This is useful mainly if the
4394 chaining of stack frames has been damaged by a bug, making it
4395 impossible for @value{GDBN} to assign numbers properly to all frames. In
4396 addition, this can be useful when your program has multiple stacks and
4397 switches between them.
4399 On the SPARC architecture, @code{frame} needs two addresses to
4400 select an arbitrary frame: a frame pointer and a stack pointer.
4402 On the MIPS and Alpha architecture, it needs two addresses: a stack
4403 pointer and a program counter.
4405 On the 29k architecture, it needs three addresses: a register stack
4406 pointer, a program counter, and a memory stack pointer.
4410 Move @var{n} frames up the stack. For positive numbers @var{n}, this
4411 advances toward the outermost frame, to higher frame numbers, to frames
4412 that have existed longer. @var{n} defaults to one.
4415 @kindex do @r{(@code{down})}
4417 Move @var{n} frames down the stack. For positive numbers @var{n}, this
4418 advances toward the innermost frame, to lower frame numbers, to frames
4419 that were created more recently. @var{n} defaults to one. You may
4420 abbreviate @code{down} as @code{do}.
4423 All of these commands end by printing two lines of output describing the
4424 frame. The first line shows the frame number, the function name, the
4425 arguments, and the source file and line number of execution in that
4426 frame. The second line shows the text of that source line.
4434 #1 0x22f0 in main (argc=1, argv=0xf7fffbf4, env=0xf7fffbfc)
4436 10 read_input_file (argv[i]);
4440 After such a printout, the @code{list} command with no arguments
4441 prints ten lines centered on the point of execution in the frame.
4442 You can also edit the program at the point of execution with your favorite
4443 editing program by typing @code{edit}.
4444 @xref{List, ,Printing source lines},
4448 @kindex down-silently
4450 @item up-silently @var{n}
4451 @itemx down-silently @var{n}
4452 These two commands are variants of @code{up} and @code{down},
4453 respectively; they differ in that they do their work silently, without
4454 causing display of the new frame. They are intended primarily for use
4455 in @value{GDBN} command scripts, where the output might be unnecessary and
4460 @section Information about a frame
4462 There are several other commands to print information about the selected
4468 When used without any argument, this command does not change which
4469 frame is selected, but prints a brief description of the currently
4470 selected stack frame. It can be abbreviated @code{f}. With an
4471 argument, this command is used to select a stack frame.
4472 @xref{Selection, ,Selecting a frame}.
4475 @kindex info f @r{(@code{info frame})}
4478 This command prints a verbose description of the selected stack frame,
4483 the address of the frame
4485 the address of the next frame down (called by this frame)
4487 the address of the next frame up (caller of this frame)
4489 the language in which the source code corresponding to this frame is written
4491 the address of the frame's arguments
4493 the address of the frame's local variables
4495 the program counter saved in it (the address of execution in the caller frame)
4497 which registers were saved in the frame
4500 @noindent The verbose description is useful when
4501 something has gone wrong that has made the stack format fail to fit
4502 the usual conventions.
4504 @item info frame @var{addr}
4505 @itemx info f @var{addr}
4506 Print a verbose description of the frame at address @var{addr}, without
4507 selecting that frame. The selected frame remains unchanged by this
4508 command. This requires the same kind of address (more than one for some
4509 architectures) that you specify in the @code{frame} command.
4510 @xref{Selection, ,Selecting a frame}.
4514 Print the arguments of the selected frame, each on a separate line.
4518 Print the local variables of the selected frame, each on a separate
4519 line. These are all variables (declared either static or automatic)
4520 accessible at the point of execution of the selected frame.
4523 @cindex catch exceptions, list active handlers
4524 @cindex exception handlers, how to list
4526 Print a list of all the exception handlers that are active in the
4527 current stack frame at the current point of execution. To see other
4528 exception handlers, visit the associated frame (using the @code{up},
4529 @code{down}, or @code{frame} commands); then type @code{info catch}.
4530 @xref{Set Catchpoints, , Setting catchpoints}.
4536 @chapter Examining Source Files
4538 @value{GDBN} can print parts of your program's source, since the debugging
4539 information recorded in the program tells @value{GDBN} what source files were
4540 used to build it. When your program stops, @value{GDBN} spontaneously prints
4541 the line where it stopped. Likewise, when you select a stack frame
4542 (@pxref{Selection, ,Selecting a frame}), @value{GDBN} prints the line where
4543 execution in that frame has stopped. You can print other portions of
4544 source files by explicit command.
4546 If you use @value{GDBN} through its @sc{gnu} Emacs interface, you may
4547 prefer to use Emacs facilities to view source; see @ref{Emacs, ,Using
4548 @value{GDBN} under @sc{gnu} Emacs}.
4551 * List:: Printing source lines
4552 * Edit:: Editing source files
4553 * Search:: Searching source files
4554 * Source Path:: Specifying source directories
4555 * Machine Code:: Source and machine code
4559 @section Printing source lines
4562 @kindex l @r{(@code{list})}
4563 To print lines from a source file, use the @code{list} command
4564 (abbreviated @code{l}). By default, ten lines are printed.
4565 There are several ways to specify what part of the file you want to print.
4567 Here are the forms of the @code{list} command most commonly used:
4570 @item list @var{linenum}
4571 Print lines centered around line number @var{linenum} in the
4572 current source file.
4574 @item list @var{function}
4575 Print lines centered around the beginning of function
4579 Print more lines. If the last lines printed were printed with a
4580 @code{list} command, this prints lines following the last lines
4581 printed; however, if the last line printed was a solitary line printed
4582 as part of displaying a stack frame (@pxref{Stack, ,Examining the
4583 Stack}), this prints lines centered around that line.
4586 Print lines just before the lines last printed.
4589 @cindex @code{list}, how many lines to display
4590 By default, @value{GDBN} prints ten source lines with any of these forms of
4591 the @code{list} command. You can change this using @code{set listsize}:
4594 @kindex set listsize
4595 @item set listsize @var{count}
4596 Make the @code{list} command display @var{count} source lines (unless
4597 the @code{list} argument explicitly specifies some other number).
4599 @kindex show listsize
4601 Display the number of lines that @code{list} prints.
4604 Repeating a @code{list} command with @key{RET} discards the argument,
4605 so it is equivalent to typing just @code{list}. This is more useful
4606 than listing the same lines again. An exception is made for an
4607 argument of @samp{-}; that argument is preserved in repetition so that
4608 each repetition moves up in the source file.
4611 In general, the @code{list} command expects you to supply zero, one or two
4612 @dfn{linespecs}. Linespecs specify source lines; there are several ways
4613 of writing them, but the effect is always to specify some source line.
4614 Here is a complete description of the possible arguments for @code{list}:
4617 @item list @var{linespec}
4618 Print lines centered around the line specified by @var{linespec}.
4620 @item list @var{first},@var{last}
4621 Print lines from @var{first} to @var{last}. Both arguments are
4624 @item list ,@var{last}
4625 Print lines ending with @var{last}.
4627 @item list @var{first},
4628 Print lines starting with @var{first}.
4631 Print lines just after the lines last printed.
4634 Print lines just before the lines last printed.
4637 As described in the preceding table.
4640 Here are the ways of specifying a single source line---all the
4645 Specifies line @var{number} of the current source file.
4646 When a @code{list} command has two linespecs, this refers to
4647 the same source file as the first linespec.
4650 Specifies the line @var{offset} lines after the last line printed.
4651 When used as the second linespec in a @code{list} command that has
4652 two, this specifies the line @var{offset} lines down from the
4656 Specifies the line @var{offset} lines before the last line printed.
4658 @item @var{filename}:@var{number}
4659 Specifies line @var{number} in the source file @var{filename}.
4661 @item @var{function}
4662 Specifies the line that begins the body of the function @var{function}.
4663 For example: in C, this is the line with the open brace.
4665 @item @var{filename}:@var{function}
4666 Specifies the line of the open-brace that begins the body of the
4667 function @var{function} in the file @var{filename}. You only need the
4668 file name with a function name to avoid ambiguity when there are
4669 identically named functions in different source files.
4671 @item *@var{address}
4672 Specifies the line containing the program address @var{address}.
4673 @var{address} may be any expression.
4677 @section Editing source files
4678 @cindex editing source files
4681 @kindex e @r{(@code{edit})}
4682 To edit the lines in a source file, use the @code{edit} command.
4683 The editing program of your choice
4684 is invoked with the current line set to
4685 the active line in the program.
4686 Alternatively, there are several ways to specify what part of the file you
4687 want to print if you want to see other parts of the program.
4689 Here are the forms of the @code{edit} command most commonly used:
4693 Edit the current source file at the active line number in the program.
4695 @item edit @var{number}
4696 Edit the current source file with @var{number} as the active line number.
4698 @item edit @var{function}
4699 Edit the file containing @var{function} at the beginning of its definition.
4701 @item edit @var{filename}:@var{number}
4702 Specifies line @var{number} in the source file @var{filename}.
4704 @item edit @var{filename}:@var{function}
4705 Specifies the line that begins the body of the
4706 function @var{function} in the file @var{filename}. You only need the
4707 file name with a function name to avoid ambiguity when there are
4708 identically named functions in different source files.
4710 @item edit *@var{address}
4711 Specifies the line containing the program address @var{address}.
4712 @var{address} may be any expression.
4715 @subsection Choosing your editor
4716 You can customize @value{GDBN} to use any editor you want
4718 The only restriction is that your editor (say @code{ex}), recognizes the
4719 following command-line syntax:
4721 ex +@var{number} file
4723 The optional numeric value +@var{number} specifies the number of the line in
4724 the file where to start editing.}.
4725 By default, it is @file{@value{EDITOR}}, but you can change this
4726 by setting the environment variable @code{EDITOR} before using
4727 @value{GDBN}. For example, to configure @value{GDBN} to use the
4728 @code{vi} editor, you could use these commands with the @code{sh} shell:
4734 or in the @code{csh} shell,
4736 setenv EDITOR /usr/bin/vi
4741 @section Searching source files
4742 @cindex searching source files
4744 There are two commands for searching through the current source file for a
4749 @kindex forward-search
4750 @item forward-search @var{regexp}
4751 @itemx search @var{regexp}
4752 The command @samp{forward-search @var{regexp}} checks each line,
4753 starting with the one following the last line listed, for a match for
4754 @var{regexp}. It lists the line that is found. You can use the
4755 synonym @samp{search @var{regexp}} or abbreviate the command name as
4758 @kindex reverse-search
4759 @item reverse-search @var{regexp}
4760 The command @samp{reverse-search @var{regexp}} checks each line, starting
4761 with the one before the last line listed and going backward, for a match
4762 for @var{regexp}. It lists the line that is found. You can abbreviate
4763 this command as @code{rev}.
4767 @section Specifying source directories
4770 @cindex directories for source files
4771 Executable programs sometimes do not record the directories of the source
4772 files from which they were compiled, just the names. Even when they do,
4773 the directories could be moved between the compilation and your debugging
4774 session. @value{GDBN} has a list of directories to search for source files;
4775 this is called the @dfn{source path}. Each time @value{GDBN} wants a source file,
4776 it tries all the directories in the list, in the order they are present
4777 in the list, until it finds a file with the desired name.
4779 For example, suppose an executable references the file
4780 @file{/usr/src/foo-1.0/lib/foo.c}, and our source path is
4781 @file{/mnt/cross}. The file is first looked up literally; if this
4782 fails, @file{/mnt/cross/usr/src/foo-1.0/lib/foo.c} is tried; if this
4783 fails, @file{/mnt/cross/foo.c} is opened; if this fails, an error
4784 message is printed. @value{GDBN} does not look up the parts of the
4785 source file name, such as @file{/mnt/cross/src/foo-1.0/lib/foo.c}.
4786 Likewise, the subdirectories of the source path are not searched: if
4787 the source path is @file{/mnt/cross}, and the binary refers to
4788 @file{foo.c}, @value{GDBN} would not find it under
4789 @file{/mnt/cross/usr/src/foo-1.0/lib}.
4791 Plain file names, relative file names with leading directories, file
4792 names containing dots, etc.@: are all treated as described above; for
4793 instance, if the source path is @file{/mnt/cross}, and the source file
4794 is recorded as @file{../lib/foo.c}, @value{GDBN} would first try
4795 @file{../lib/foo.c}, then @file{/mnt/cross/../lib/foo.c}, and after
4796 that---@file{/mnt/cross/foo.c}.
4798 Note that the executable search path is @emph{not} used to locate the
4799 source files. Neither is the current working directory, unless it
4800 happens to be in the source path.
4802 Whenever you reset or rearrange the source path, @value{GDBN} clears out
4803 any information it has cached about where source files are found and where
4804 each line is in the file.
4808 When you start @value{GDBN}, its source path includes only @samp{cdir}
4809 and @samp{cwd}, in that order.
4810 To add other directories, use the @code{directory} command.
4813 @item directory @var{dirname} @dots{}
4814 @item dir @var{dirname} @dots{}
4815 Add directory @var{dirname} to the front of the source path. Several
4816 directory names may be given to this command, separated by @samp{:}
4817 (@samp{;} on MS-DOS and MS-Windows, where @samp{:} usually appears as
4818 part of absolute file names) or
4819 whitespace. You may specify a directory that is already in the source
4820 path; this moves it forward, so @value{GDBN} searches it sooner.
4824 @vindex $cdir@r{, convenience variable}
4825 @vindex $cwdr@r{, convenience variable}
4826 @cindex compilation directory
4827 @cindex current directory
4828 @cindex working directory
4829 @cindex directory, current
4830 @cindex directory, compilation
4831 You can use the string @samp{$cdir} to refer to the compilation
4832 directory (if one is recorded), and @samp{$cwd} to refer to the current
4833 working directory. @samp{$cwd} is not the same as @samp{.}---the former
4834 tracks the current working directory as it changes during your @value{GDBN}
4835 session, while the latter is immediately expanded to the current
4836 directory at the time you add an entry to the source path.
4839 Reset the source path to empty again. This requires confirmation.
4841 @c RET-repeat for @code{directory} is explicitly disabled, but since
4842 @c repeating it would be a no-op we do not say that. (thanks to RMS)
4844 @item show directories
4845 @kindex show directories
4846 Print the source path: show which directories it contains.
4849 If your source path is cluttered with directories that are no longer of
4850 interest, @value{GDBN} may sometimes cause confusion by finding the wrong
4851 versions of source. You can correct the situation as follows:
4855 Use @code{directory} with no argument to reset the source path to empty.
4858 Use @code{directory} with suitable arguments to reinstall the
4859 directories you want in the source path. You can add all the
4860 directories in one command.
4864 @section Source and machine code
4865 @cindex source line and its code address
4867 You can use the command @code{info line} to map source lines to program
4868 addresses (and vice versa), and the command @code{disassemble} to display
4869 a range of addresses as machine instructions. When run under @sc{gnu} Emacs
4870 mode, the @code{info line} command causes the arrow to point to the
4871 line specified. Also, @code{info line} prints addresses in symbolic form as
4876 @item info line @var{linespec}
4877 Print the starting and ending addresses of the compiled code for
4878 source line @var{linespec}. You can specify source lines in any of
4879 the ways understood by the @code{list} command (@pxref{List, ,Printing
4883 For example, we can use @code{info line} to discover the location of
4884 the object code for the first line of function
4885 @code{m4_changequote}:
4887 @c FIXME: I think this example should also show the addresses in
4888 @c symbolic form, as they usually would be displayed.
4890 (@value{GDBP}) info line m4_changequote
4891 Line 895 of "builtin.c" starts at pc 0x634c and ends at 0x6350.
4895 @cindex code address and its source line
4896 We can also inquire (using @code{*@var{addr}} as the form for
4897 @var{linespec}) what source line covers a particular address:
4899 (@value{GDBP}) info line *0x63ff
4900 Line 926 of "builtin.c" starts at pc 0x63e4 and ends at 0x6404.
4903 @cindex @code{$_} and @code{info line}
4904 @cindex @code{x} command, default address
4905 @kindex x@r{(examine), and} info line
4906 After @code{info line}, the default address for the @code{x} command
4907 is changed to the starting address of the line, so that @samp{x/i} is
4908 sufficient to begin examining the machine code (@pxref{Memory,
4909 ,Examining memory}). Also, this address is saved as the value of the
4910 convenience variable @code{$_} (@pxref{Convenience Vars, ,Convenience
4915 @cindex assembly instructions
4916 @cindex instructions, assembly
4917 @cindex machine instructions
4918 @cindex listing machine instructions
4920 This specialized command dumps a range of memory as machine
4921 instructions. The default memory range is the function surrounding the
4922 program counter of the selected frame. A single argument to this
4923 command is a program counter value; @value{GDBN} dumps the function
4924 surrounding this value. Two arguments specify a range of addresses
4925 (first inclusive, second exclusive) to dump.
4928 The following example shows the disassembly of a range of addresses of
4929 HP PA-RISC 2.0 code:
4932 (@value{GDBP}) disas 0x32c4 0x32e4
4933 Dump of assembler code from 0x32c4 to 0x32e4:
4934 0x32c4 <main+204>: addil 0,dp
4935 0x32c8 <main+208>: ldw 0x22c(sr0,r1),r26
4936 0x32cc <main+212>: ldil 0x3000,r31
4937 0x32d0 <main+216>: ble 0x3f8(sr4,r31)
4938 0x32d4 <main+220>: ldo 0(r31),rp
4939 0x32d8 <main+224>: addil -0x800,dp
4940 0x32dc <main+228>: ldo 0x588(r1),r26
4941 0x32e0 <main+232>: ldil 0x3000,r31
4942 End of assembler dump.
4945 Some architectures have more than one commonly-used set of instruction
4946 mnemonics or other syntax.
4948 For programs that were dynamically linked and use shared libraries,
4949 instructions that call functions or branch to locations in the shared
4950 libraries might show a seemingly bogus location---it's actually a
4951 location of the relocation table. On some architectures, @value{GDBN}
4952 might be able to resolve these to actual function names.
4955 @kindex set disassembly-flavor
4956 @cindex Intel disassembly flavor
4957 @cindex AT&T disassembly flavor
4958 @item set disassembly-flavor @var{instruction-set}
4959 Select the instruction set to use when disassembling the
4960 program via the @code{disassemble} or @code{x/i} commands.
4962 Currently this command is only defined for the Intel x86 family. You
4963 can set @var{instruction-set} to either @code{intel} or @code{att}.
4964 The default is @code{att}, the AT&T flavor used by default by Unix
4965 assemblers for x86-based targets.
4967 @kindex show disassembly-flavor
4968 @item show disassembly-flavor
4969 Show the current setting of the disassembly flavor.
4974 @chapter Examining Data
4976 @cindex printing data
4977 @cindex examining data
4980 @c "inspect" is not quite a synonym if you are using Epoch, which we do not
4981 @c document because it is nonstandard... Under Epoch it displays in a
4982 @c different window or something like that.
4983 The usual way to examine data in your program is with the @code{print}
4984 command (abbreviated @code{p}), or its synonym @code{inspect}. It
4985 evaluates and prints the value of an expression of the language your
4986 program is written in (@pxref{Languages, ,Using @value{GDBN} with
4987 Different Languages}).
4990 @item print @var{expr}
4991 @itemx print /@var{f} @var{expr}
4992 @var{expr} is an expression (in the source language). By default the
4993 value of @var{expr} is printed in a format appropriate to its data type;
4994 you can choose a different format by specifying @samp{/@var{f}}, where
4995 @var{f} is a letter specifying the format; see @ref{Output Formats,,Output
4999 @itemx print /@var{f}
5000 @cindex reprint the last value
5001 If you omit @var{expr}, @value{GDBN} displays the last value again (from the
5002 @dfn{value history}; @pxref{Value History, ,Value history}). This allows you to
5003 conveniently inspect the same value in an alternative format.
5006 A more low-level way of examining data is with the @code{x} command.
5007 It examines data in memory at a specified address and prints it in a
5008 specified format. @xref{Memory, ,Examining memory}.
5010 If you are interested in information about types, or about how the
5011 fields of a struct or a class are declared, use the @code{ptype @var{exp}}
5012 command rather than @code{print}. @xref{Symbols, ,Examining the Symbol
5016 * Expressions:: Expressions
5017 * Variables:: Program variables
5018 * Arrays:: Artificial arrays
5019 * Output Formats:: Output formats
5020 * Memory:: Examining memory
5021 * Auto Display:: Automatic display
5022 * Print Settings:: Print settings
5023 * Value History:: Value history
5024 * Convenience Vars:: Convenience variables
5025 * Registers:: Registers
5026 * Floating Point Hardware:: Floating point hardware
5027 * Vector Unit:: Vector Unit
5028 * OS Information:: Auxiliary data provided by operating system
5029 * Memory Region Attributes:: Memory region attributes
5030 * Dump/Restore Files:: Copy between memory and a file
5031 * Core File Generation:: Cause a program dump its core
5032 * Character Sets:: Debugging programs that use a different
5033 character set than GDB does
5034 * Caching Remote Data:: Data caching for remote targets
5038 @section Expressions
5041 @code{print} and many other @value{GDBN} commands accept an expression and
5042 compute its value. Any kind of constant, variable or operator defined
5043 by the programming language you are using is valid in an expression in
5044 @value{GDBN}. This includes conditional expressions, function calls,
5045 casts, and string constants. It also includes preprocessor macros, if
5046 you compiled your program to include this information; see
5049 @cindex arrays in expressions
5050 @value{GDBN} supports array constants in expressions input by
5051 the user. The syntax is @{@var{element}, @var{element}@dots{}@}. For example,
5052 you can use the command @code{print @{1, 2, 3@}} to build up an array in
5053 memory that is @code{malloc}ed in the target program.
5055 Because C is so widespread, most of the expressions shown in examples in
5056 this manual are in C. @xref{Languages, , Using @value{GDBN} with Different
5057 Languages}, for information on how to use expressions in other
5060 In this section, we discuss operators that you can use in @value{GDBN}
5061 expressions regardless of your programming language.
5063 @cindex casts, in expressions
5064 Casts are supported in all languages, not just in C, because it is so
5065 useful to cast a number into a pointer in order to examine a structure
5066 at that address in memory.
5067 @c FIXME: casts supported---Mod2 true?
5069 @value{GDBN} supports these operators, in addition to those common
5070 to programming languages:
5074 @samp{@@} is a binary operator for treating parts of memory as arrays.
5075 @xref{Arrays, ,Artificial arrays}, for more information.
5078 @samp{::} allows you to specify a variable in terms of the file or
5079 function where it is defined. @xref{Variables, ,Program variables}.
5081 @cindex @{@var{type}@}
5082 @cindex type casting memory
5083 @cindex memory, viewing as typed object
5084 @cindex casts, to view memory
5085 @item @{@var{type}@} @var{addr}
5086 Refers to an object of type @var{type} stored at address @var{addr} in
5087 memory. @var{addr} may be any expression whose value is an integer or
5088 pointer (but parentheses are required around binary operators, just as in
5089 a cast). This construct is allowed regardless of what kind of data is
5090 normally supposed to reside at @var{addr}.
5094 @section Program variables
5096 The most common kind of expression to use is the name of a variable
5099 Variables in expressions are understood in the selected stack frame
5100 (@pxref{Selection, ,Selecting a frame}); they must be either:
5104 global (or file-static)
5111 visible according to the scope rules of the
5112 programming language from the point of execution in that frame
5115 @noindent This means that in the function
5130 you can examine and use the variable @code{a} whenever your program is
5131 executing within the function @code{foo}, but you can only use or
5132 examine the variable @code{b} while your program is executing inside
5133 the block where @code{b} is declared.
5135 @cindex variable name conflict
5136 There is an exception: you can refer to a variable or function whose
5137 scope is a single source file even if the current execution point is not
5138 in this file. But it is possible to have more than one such variable or
5139 function with the same name (in different source files). If that
5140 happens, referring to that name has unpredictable effects. If you wish,
5141 you can specify a static variable in a particular function or file,
5142 using the colon-colon (@code{::}) notation:
5144 @cindex colon-colon, context for variables/functions
5146 @c info cannot cope with a :: index entry, but why deprive hard copy readers?
5147 @cindex @code{::}, context for variables/functions
5150 @var{file}::@var{variable}
5151 @var{function}::@var{variable}
5155 Here @var{file} or @var{function} is the name of the context for the
5156 static @var{variable}. In the case of file names, you can use quotes to
5157 make sure @value{GDBN} parses the file name as a single word---for example,
5158 to print a global value of @code{x} defined in @file{f2.c}:
5161 (@value{GDBP}) p 'f2.c'::x
5164 @cindex C@t{++} scope resolution
5165 This use of @samp{::} is very rarely in conflict with the very similar
5166 use of the same notation in C@t{++}. @value{GDBN} also supports use of the C@t{++}
5167 scope resolution operator in @value{GDBN} expressions.
5168 @c FIXME: Um, so what happens in one of those rare cases where it's in
5171 @cindex wrong values
5172 @cindex variable values, wrong
5173 @cindex function entry/exit, wrong values of variables
5174 @cindex optimized code, wrong values of variables
5176 @emph{Warning:} Occasionally, a local variable may appear to have the
5177 wrong value at certain points in a function---just after entry to a new
5178 scope, and just before exit.
5180 You may see this problem when you are stepping by machine instructions.
5181 This is because, on most machines, it takes more than one instruction to
5182 set up a stack frame (including local variable definitions); if you are
5183 stepping by machine instructions, variables may appear to have the wrong
5184 values until the stack frame is completely built. On exit, it usually
5185 also takes more than one machine instruction to destroy a stack frame;
5186 after you begin stepping through that group of instructions, local
5187 variable definitions may be gone.
5189 This may also happen when the compiler does significant optimizations.
5190 To be sure of always seeing accurate values, turn off all optimization
5193 @cindex ``No symbol "foo" in current context''
5194 Another possible effect of compiler optimizations is to optimize
5195 unused variables out of existence, or assign variables to registers (as
5196 opposed to memory addresses). Depending on the support for such cases
5197 offered by the debug info format used by the compiler, @value{GDBN}
5198 might not be able to display values for such local variables. If that
5199 happens, @value{GDBN} will print a message like this:
5202 No symbol "foo" in current context.
5205 To solve such problems, either recompile without optimizations, or use a
5206 different debug info format, if the compiler supports several such
5207 formats. For example, @value{NGCC}, the @sc{gnu} C/C@t{++} compiler,
5208 usually supports the @option{-gstabs+} option. @option{-gstabs+}
5209 produces debug info in a format that is superior to formats such as
5210 COFF. You may be able to use DWARF 2 (@option{-gdwarf-2}), which is also
5211 an effective form for debug info. @xref{Debugging Options,,Options
5212 for Debugging Your Program or @sc{gnu} CC, gcc.info, Using @sc{gnu} CC}.
5213 @xref{C, , Debugging C++}, for more info about debug info formats
5214 that are best suited to C@t{++} programs.
5216 If you ask to print an object whose contents are unknown to
5217 @value{GDBN}, e.g., because its data type is not completely specified
5218 by the debug information, @value{GDBN} will say @samp{<incomplete
5219 type>}. @xref{Symbols, incomplete type}, for more about this.
5222 @section Artificial arrays
5224 @cindex artificial array
5226 @kindex @@@r{, referencing memory as an array}
5227 It is often useful to print out several successive objects of the
5228 same type in memory; a section of an array, or an array of
5229 dynamically determined size for which only a pointer exists in the
5232 You can do this by referring to a contiguous span of memory as an
5233 @dfn{artificial array}, using the binary operator @samp{@@}. The left
5234 operand of @samp{@@} should be the first element of the desired array
5235 and be an individual object. The right operand should be the desired length
5236 of the array. The result is an array value whose elements are all of
5237 the type of the left argument. The first element is actually the left
5238 argument; the second element comes from bytes of memory immediately
5239 following those that hold the first element, and so on. Here is an
5240 example. If a program says
5243 int *array = (int *) malloc (len * sizeof (int));
5247 you can print the contents of @code{array} with
5253 The left operand of @samp{@@} must reside in memory. Array values made
5254 with @samp{@@} in this way behave just like other arrays in terms of
5255 subscripting, and are coerced to pointers when used in expressions.
5256 Artificial arrays most often appear in expressions via the value history
5257 (@pxref{Value History, ,Value history}), after printing one out.
5259 Another way to create an artificial array is to use a cast.
5260 This re-interprets a value as if it were an array.
5261 The value need not be in memory:
5263 (@value{GDBP}) p/x (short[2])0x12345678
5264 $1 = @{0x1234, 0x5678@}
5267 As a convenience, if you leave the array length out (as in
5268 @samp{(@var{type}[])@var{value}}) @value{GDBN} calculates the size to fill
5269 the value (as @samp{sizeof(@var{value})/sizeof(@var{type})}:
5271 (@value{GDBP}) p/x (short[])0x12345678
5272 $2 = @{0x1234, 0x5678@}
5275 Sometimes the artificial array mechanism is not quite enough; in
5276 moderately complex data structures, the elements of interest may not
5277 actually be adjacent---for example, if you are interested in the values
5278 of pointers in an array. One useful work-around in this situation is
5279 to use a convenience variable (@pxref{Convenience Vars, ,Convenience
5280 variables}) as a counter in an expression that prints the first
5281 interesting value, and then repeat that expression via @key{RET}. For
5282 instance, suppose you have an array @code{dtab} of pointers to
5283 structures, and you are interested in the values of a field @code{fv}
5284 in each structure. Here is an example of what you might type:
5294 @node Output Formats
5295 @section Output formats
5297 @cindex formatted output
5298 @cindex output formats
5299 By default, @value{GDBN} prints a value according to its data type. Sometimes
5300 this is not what you want. For example, you might want to print a number
5301 in hex, or a pointer in decimal. Or you might want to view data in memory
5302 at a certain address as a character string or as an instruction. To do
5303 these things, specify an @dfn{output format} when you print a value.
5305 The simplest use of output formats is to say how to print a value
5306 already computed. This is done by starting the arguments of the
5307 @code{print} command with a slash and a format letter. The format
5308 letters supported are:
5312 Regard the bits of the value as an integer, and print the integer in
5316 Print as integer in signed decimal.
5319 Print as integer in unsigned decimal.
5322 Print as integer in octal.
5325 Print as integer in binary. The letter @samp{t} stands for ``two''.
5326 @footnote{@samp{b} cannot be used because these format letters are also
5327 used with the @code{x} command, where @samp{b} stands for ``byte'';
5328 see @ref{Memory,,Examining memory}.}
5331 @cindex unknown address, locating
5332 @cindex locate address
5333 Print as an address, both absolute in hexadecimal and as an offset from
5334 the nearest preceding symbol. You can use this format used to discover
5335 where (in what function) an unknown address is located:
5338 (@value{GDBP}) p/a 0x54320
5339 $3 = 0x54320 <_initialize_vx+396>
5343 The command @code{info symbol 0x54320} yields similar results.
5344 @xref{Symbols, info symbol}.
5347 Regard as an integer and print it as a character constant. This
5348 prints both the numerical value and its character representation. The
5349 character representation is replaced with the octal escape @samp{\nnn}
5350 for characters outside the 7-bit @sc{ascii} range.
5353 Regard the bits of the value as a floating point number and print
5354 using typical floating point syntax.
5357 For example, to print the program counter in hex (@pxref{Registers}), type
5364 Note that no space is required before the slash; this is because command
5365 names in @value{GDBN} cannot contain a slash.
5367 To reprint the last value in the value history with a different format,
5368 you can use the @code{print} command with just a format and no
5369 expression. For example, @samp{p/x} reprints the last value in hex.
5372 @section Examining memory
5374 You can use the command @code{x} (for ``examine'') to examine memory in
5375 any of several formats, independently of your program's data types.
5377 @cindex examining memory
5379 @kindex x @r{(examine memory)}
5380 @item x/@var{nfu} @var{addr}
5383 Use the @code{x} command to examine memory.
5386 @var{n}, @var{f}, and @var{u} are all optional parameters that specify how
5387 much memory to display and how to format it; @var{addr} is an
5388 expression giving the address where you want to start displaying memory.
5389 If you use defaults for @var{nfu}, you need not type the slash @samp{/}.
5390 Several commands set convenient defaults for @var{addr}.
5393 @item @var{n}, the repeat count
5394 The repeat count is a decimal integer; the default is 1. It specifies
5395 how much memory (counting by units @var{u}) to display.
5396 @c This really is **decimal**; unaffected by 'set radix' as of GDB
5399 @item @var{f}, the display format
5400 The display format is one of the formats used by @code{print}
5401 (@samp{x}, @samp{d}, @samp{u}, @samp{o}, @samp{t}, @samp{a}, @samp{c},
5402 @samp{f}), and in addition @samp{s} (for null-terminated strings) and
5403 @samp{i} (for machine instructions). The default is @samp{x}
5404 (hexadecimal) initially. The default changes each time you use either
5405 @code{x} or @code{print}.
5407 @item @var{u}, the unit size
5408 The unit size is any of
5414 Halfwords (two bytes).
5416 Words (four bytes). This is the initial default.
5418 Giant words (eight bytes).
5421 Each time you specify a unit size with @code{x}, that size becomes the
5422 default unit the next time you use @code{x}. (For the @samp{s} and
5423 @samp{i} formats, the unit size is ignored and is normally not written.)
5425 @item @var{addr}, starting display address
5426 @var{addr} is the address where you want @value{GDBN} to begin displaying
5427 memory. The expression need not have a pointer value (though it may);
5428 it is always interpreted as an integer address of a byte of memory.
5429 @xref{Expressions, ,Expressions}, for more information on expressions. The default for
5430 @var{addr} is usually just after the last address examined---but several
5431 other commands also set the default address: @code{info breakpoints} (to
5432 the address of the last breakpoint listed), @code{info line} (to the
5433 starting address of a line), and @code{print} (if you use it to display
5434 a value from memory).
5437 For example, @samp{x/3uh 0x54320} is a request to display three halfwords
5438 (@code{h}) of memory, formatted as unsigned decimal integers (@samp{u}),
5439 starting at address @code{0x54320}. @samp{x/4xw $sp} prints the four
5440 words (@samp{w}) of memory above the stack pointer (here, @samp{$sp};
5441 @pxref{Registers, ,Registers}) in hexadecimal (@samp{x}).
5443 Since the letters indicating unit sizes are all distinct from the
5444 letters specifying output formats, you do not have to remember whether
5445 unit size or format comes first; either order works. The output
5446 specifications @samp{4xw} and @samp{4wx} mean exactly the same thing.
5447 (However, the count @var{n} must come first; @samp{wx4} does not work.)
5449 Even though the unit size @var{u} is ignored for the formats @samp{s}
5450 and @samp{i}, you might still want to use a count @var{n}; for example,
5451 @samp{3i} specifies that you want to see three machine instructions,
5452 including any operands. The command @code{disassemble} gives an
5453 alternative way of inspecting machine instructions; see @ref{Machine
5454 Code,,Source and machine code}.
5456 All the defaults for the arguments to @code{x} are designed to make it
5457 easy to continue scanning memory with minimal specifications each time
5458 you use @code{x}. For example, after you have inspected three machine
5459 instructions with @samp{x/3i @var{addr}}, you can inspect the next seven
5460 with just @samp{x/7}. If you use @key{RET} to repeat the @code{x} command,
5461 the repeat count @var{n} is used again; the other arguments default as
5462 for successive uses of @code{x}.
5464 @cindex @code{$_}, @code{$__}, and value history
5465 The addresses and contents printed by the @code{x} command are not saved
5466 in the value history because there is often too much of them and they
5467 would get in the way. Instead, @value{GDBN} makes these values available for
5468 subsequent use in expressions as values of the convenience variables
5469 @code{$_} and @code{$__}. After an @code{x} command, the last address
5470 examined is available for use in expressions in the convenience variable
5471 @code{$_}. The contents of that address, as examined, are available in
5472 the convenience variable @code{$__}.
5474 If the @code{x} command has a repeat count, the address and contents saved
5475 are from the last memory unit printed; this is not the same as the last
5476 address printed if several units were printed on the last line of output.
5478 @cindex remote memory comparison
5479 @cindex verify remote memory image
5480 When you are debugging a program running on a remote target machine
5481 (@pxref{Remote}), you may wish to verify the program's image in the
5482 remote machine's memory against the executable file you downloaded to
5483 the target. The @code{compare-sections} command is provided for such
5487 @kindex compare-sections
5488 @item compare-sections @r{[}@var{section-name}@r{]}
5489 Compare the data of a loadable section @var{section-name} in the
5490 executable file of the program being debugged with the same section in
5491 the remote machine's memory, and report any mismatches. With no
5492 arguments, compares all loadable sections. This command's
5493 availability depends on the target's support for the @code{"qCRC"}
5498 @section Automatic display
5499 @cindex automatic display
5500 @cindex display of expressions
5502 If you find that you want to print the value of an expression frequently
5503 (to see how it changes), you might want to add it to the @dfn{automatic
5504 display list} so that @value{GDBN} prints its value each time your program stops.
5505 Each expression added to the list is given a number to identify it;
5506 to remove an expression from the list, you specify that number.
5507 The automatic display looks like this:
5511 3: bar[5] = (struct hack *) 0x3804
5515 This display shows item numbers, expressions and their current values. As with
5516 displays you request manually using @code{x} or @code{print}, you can
5517 specify the output format you prefer; in fact, @code{display} decides
5518 whether to use @code{print} or @code{x} depending on how elaborate your
5519 format specification is---it uses @code{x} if you specify a unit size,
5520 or one of the two formats (@samp{i} and @samp{s}) that are only
5521 supported by @code{x}; otherwise it uses @code{print}.
5525 @item display @var{expr}
5526 Add the expression @var{expr} to the list of expressions to display
5527 each time your program stops. @xref{Expressions, ,Expressions}.
5529 @code{display} does not repeat if you press @key{RET} again after using it.
5531 @item display/@var{fmt} @var{expr}
5532 For @var{fmt} specifying only a display format and not a size or
5533 count, add the expression @var{expr} to the auto-display list but
5534 arrange to display it each time in the specified format @var{fmt}.
5535 @xref{Output Formats,,Output formats}.
5537 @item display/@var{fmt} @var{addr}
5538 For @var{fmt} @samp{i} or @samp{s}, or including a unit-size or a
5539 number of units, add the expression @var{addr} as a memory address to
5540 be examined each time your program stops. Examining means in effect
5541 doing @samp{x/@var{fmt} @var{addr}}. @xref{Memory, ,Examining memory}.
5544 For example, @samp{display/i $pc} can be helpful, to see the machine
5545 instruction about to be executed each time execution stops (@samp{$pc}
5546 is a common name for the program counter; @pxref{Registers, ,Registers}).
5549 @kindex delete display
5551 @item undisplay @var{dnums}@dots{}
5552 @itemx delete display @var{dnums}@dots{}
5553 Remove item numbers @var{dnums} from the list of expressions to display.
5555 @code{undisplay} does not repeat if you press @key{RET} after using it.
5556 (Otherwise you would just get the error @samp{No display number @dots{}}.)
5558 @kindex disable display
5559 @item disable display @var{dnums}@dots{}
5560 Disable the display of item numbers @var{dnums}. A disabled display
5561 item is not printed automatically, but is not forgotten. It may be
5562 enabled again later.
5564 @kindex enable display
5565 @item enable display @var{dnums}@dots{}
5566 Enable display of item numbers @var{dnums}. It becomes effective once
5567 again in auto display of its expression, until you specify otherwise.
5570 Display the current values of the expressions on the list, just as is
5571 done when your program stops.
5573 @kindex info display
5575 Print the list of expressions previously set up to display
5576 automatically, each one with its item number, but without showing the
5577 values. This includes disabled expressions, which are marked as such.
5578 It also includes expressions which would not be displayed right now
5579 because they refer to automatic variables not currently available.
5582 @cindex display disabled out of scope
5583 If a display expression refers to local variables, then it does not make
5584 sense outside the lexical context for which it was set up. Such an
5585 expression is disabled when execution enters a context where one of its
5586 variables is not defined. For example, if you give the command
5587 @code{display last_char} while inside a function with an argument
5588 @code{last_char}, @value{GDBN} displays this argument while your program
5589 continues to stop inside that function. When it stops elsewhere---where
5590 there is no variable @code{last_char}---the display is disabled
5591 automatically. The next time your program stops where @code{last_char}
5592 is meaningful, you can enable the display expression once again.
5594 @node Print Settings
5595 @section Print settings
5597 @cindex format options
5598 @cindex print settings
5599 @value{GDBN} provides the following ways to control how arrays, structures,
5600 and symbols are printed.
5603 These settings are useful for debugging programs in any language:
5607 @item set print address
5608 @itemx set print address on
5609 @cindex print/don't print memory addresses
5610 @value{GDBN} prints memory addresses showing the location of stack
5611 traces, structure values, pointer values, breakpoints, and so forth,
5612 even when it also displays the contents of those addresses. The default
5613 is @code{on}. For example, this is what a stack frame display looks like with
5614 @code{set print address on}:
5619 #0 set_quotes (lq=0x34c78 "<<", rq=0x34c88 ">>")
5621 530 if (lquote != def_lquote)
5625 @item set print address off
5626 Do not print addresses when displaying their contents. For example,
5627 this is the same stack frame displayed with @code{set print address off}:
5631 (@value{GDBP}) set print addr off
5633 #0 set_quotes (lq="<<", rq=">>") at input.c:530
5634 530 if (lquote != def_lquote)
5638 You can use @samp{set print address off} to eliminate all machine
5639 dependent displays from the @value{GDBN} interface. For example, with
5640 @code{print address off}, you should get the same text for backtraces on
5641 all machines---whether or not they involve pointer arguments.
5644 @item show print address
5645 Show whether or not addresses are to be printed.
5648 When @value{GDBN} prints a symbolic address, it normally prints the
5649 closest earlier symbol plus an offset. If that symbol does not uniquely
5650 identify the address (for example, it is a name whose scope is a single
5651 source file), you may need to clarify. One way to do this is with
5652 @code{info line}, for example @samp{info line *0x4537}. Alternately,
5653 you can set @value{GDBN} to print the source file and line number when
5654 it prints a symbolic address:
5657 @item set print symbol-filename on
5658 @cindex source file and line of a symbol
5659 @cindex symbol, source file and line
5660 Tell @value{GDBN} to print the source file name and line number of a
5661 symbol in the symbolic form of an address.
5663 @item set print symbol-filename off
5664 Do not print source file name and line number of a symbol. This is the
5667 @item show print symbol-filename
5668 Show whether or not @value{GDBN} will print the source file name and
5669 line number of a symbol in the symbolic form of an address.
5672 Another situation where it is helpful to show symbol filenames and line
5673 numbers is when disassembling code; @value{GDBN} shows you the line
5674 number and source file that corresponds to each instruction.
5676 Also, you may wish to see the symbolic form only if the address being
5677 printed is reasonably close to the closest earlier symbol:
5680 @item set print max-symbolic-offset @var{max-offset}
5681 @cindex maximum value for offset of closest symbol
5682 Tell @value{GDBN} to only display the symbolic form of an address if the
5683 offset between the closest earlier symbol and the address is less than
5684 @var{max-offset}. The default is 0, which tells @value{GDBN}
5685 to always print the symbolic form of an address if any symbol precedes it.
5687 @item show print max-symbolic-offset
5688 Ask how large the maximum offset is that @value{GDBN} prints in a
5692 @cindex wild pointer, interpreting
5693 @cindex pointer, finding referent
5694 If you have a pointer and you are not sure where it points, try
5695 @samp{set print symbol-filename on}. Then you can determine the name
5696 and source file location of the variable where it points, using
5697 @samp{p/a @var{pointer}}. This interprets the address in symbolic form.
5698 For example, here @value{GDBN} shows that a variable @code{ptt} points
5699 at another variable @code{t}, defined in @file{hi2.c}:
5702 (@value{GDBP}) set print symbol-filename on
5703 (@value{GDBP}) p/a ptt
5704 $4 = 0xe008 <t in hi2.c>
5708 @emph{Warning:} For pointers that point to a local variable, @samp{p/a}
5709 does not show the symbol name and filename of the referent, even with
5710 the appropriate @code{set print} options turned on.
5713 Other settings control how different kinds of objects are printed:
5716 @item set print array
5717 @itemx set print array on
5718 @cindex pretty print arrays
5719 Pretty print arrays. This format is more convenient to read,
5720 but uses more space. The default is off.
5722 @item set print array off
5723 Return to compressed format for arrays.
5725 @item show print array
5726 Show whether compressed or pretty format is selected for displaying
5729 @cindex print array indexes
5730 @item set print array-indexes
5731 @itemx set print array-indexes on
5732 Print the index of each element when displaying arrays. May be more
5733 convenient to locate a given element in the array or quickly find the
5734 index of a given element in that printed array. The default is off.
5736 @item set print array-indexes off
5737 Stop printing element indexes when displaying arrays.
5739 @item show print array-indexes
5740 Show whether the index of each element is printed when displaying
5743 @item set print elements @var{number-of-elements}
5744 @cindex number of array elements to print
5745 @cindex limit on number of printed array elements
5746 Set a limit on how many elements of an array @value{GDBN} will print.
5747 If @value{GDBN} is printing a large array, it stops printing after it has
5748 printed the number of elements set by the @code{set print elements} command.
5749 This limit also applies to the display of strings.
5750 When @value{GDBN} starts, this limit is set to 200.
5751 Setting @var{number-of-elements} to zero means that the printing is unlimited.
5753 @item show print elements
5754 Display the number of elements of a large array that @value{GDBN} will print.
5755 If the number is 0, then the printing is unlimited.
5757 @item set print repeats
5758 @cindex repeated array elements
5759 Set the threshold for suppressing display of repeated array
5760 elelments. When the number of consecutive identical elements of an
5761 array exceeds the threshold, @value{GDBN} prints the string
5762 @code{"<repeats @var{n} times>"}, where @var{n} is the number of
5763 identical repetitions, instead of displaying the identical elements
5764 themselves. Setting the threshold to zero will cause all elements to
5765 be individually printed. The default threshold is 10.
5767 @item show print repeats
5768 Display the current threshold for printing repeated identical
5771 @item set print null-stop
5772 @cindex @sc{null} elements in arrays
5773 Cause @value{GDBN} to stop printing the characters of an array when the first
5774 @sc{null} is encountered. This is useful when large arrays actually
5775 contain only short strings.
5778 @item show print null-stop
5779 Show whether @value{GDBN} stops printing an array on the first
5780 @sc{null} character.
5782 @item set print pretty on
5783 @cindex print structures in indented form
5784 @cindex indentation in structure display
5785 Cause @value{GDBN} to print structures in an indented format with one member
5786 per line, like this:
5801 @item set print pretty off
5802 Cause @value{GDBN} to print structures in a compact format, like this:
5806 $1 = @{next = 0x0, flags = @{sweet = 1, sour = 1@}, \
5807 meat = 0x54 "Pork"@}
5812 This is the default format.
5814 @item show print pretty
5815 Show which format @value{GDBN} is using to print structures.
5817 @item set print sevenbit-strings on
5818 @cindex eight-bit characters in strings
5819 @cindex octal escapes in strings
5820 Print using only seven-bit characters; if this option is set,
5821 @value{GDBN} displays any eight-bit characters (in strings or
5822 character values) using the notation @code{\}@var{nnn}. This setting is
5823 best if you are working in English (@sc{ascii}) and you use the
5824 high-order bit of characters as a marker or ``meta'' bit.
5826 @item set print sevenbit-strings off
5827 Print full eight-bit characters. This allows the use of more
5828 international character sets, and is the default.
5830 @item show print sevenbit-strings
5831 Show whether or not @value{GDBN} is printing only seven-bit characters.
5833 @item set print union on
5834 @cindex unions in structures, printing
5835 Tell @value{GDBN} to print unions which are contained in structures
5836 and other unions. This is the default setting.
5838 @item set print union off
5839 Tell @value{GDBN} not to print unions which are contained in
5840 structures and other unions. @value{GDBN} will print @code{"@{...@}"}
5843 @item show print union
5844 Ask @value{GDBN} whether or not it will print unions which are contained in
5845 structures and other unions.
5847 For example, given the declarations
5850 typedef enum @{Tree, Bug@} Species;
5851 typedef enum @{Big_tree, Acorn, Seedling@} Tree_forms;
5852 typedef enum @{Caterpillar, Cocoon, Butterfly@}
5863 struct thing foo = @{Tree, @{Acorn@}@};
5867 with @code{set print union on} in effect @samp{p foo} would print
5870 $1 = @{it = Tree, form = @{tree = Acorn, bug = Cocoon@}@}
5874 and with @code{set print union off} in effect it would print
5877 $1 = @{it = Tree, form = @{...@}@}
5881 @code{set print union} affects programs written in C-like languages
5887 These settings are of interest when debugging C@t{++} programs:
5890 @cindex demangling C@t{++} names
5891 @item set print demangle
5892 @itemx set print demangle on
5893 Print C@t{++} names in their source form rather than in the encoded
5894 (``mangled'') form passed to the assembler and linker for type-safe
5895 linkage. The default is on.
5897 @item show print demangle
5898 Show whether C@t{++} names are printed in mangled or demangled form.
5900 @item set print asm-demangle
5901 @itemx set print asm-demangle on
5902 Print C@t{++} names in their source form rather than their mangled form, even
5903 in assembler code printouts such as instruction disassemblies.
5906 @item show print asm-demangle
5907 Show whether C@t{++} names in assembly listings are printed in mangled
5910 @cindex C@t{++} symbol decoding style
5911 @cindex symbol decoding style, C@t{++}
5912 @kindex set demangle-style
5913 @item set demangle-style @var{style}
5914 Choose among several encoding schemes used by different compilers to
5915 represent C@t{++} names. The choices for @var{style} are currently:
5919 Allow @value{GDBN} to choose a decoding style by inspecting your program.
5922 Decode based on the @sc{gnu} C@t{++} compiler (@code{g++}) encoding algorithm.
5923 This is the default.
5926 Decode based on the HP ANSI C@t{++} (@code{aCC}) encoding algorithm.
5929 Decode based on the Lucid C@t{++} compiler (@code{lcc}) encoding algorithm.
5932 Decode using the algorithm in the @cite{C@t{++} Annotated Reference Manual}.
5933 @strong{Warning:} this setting alone is not sufficient to allow
5934 debugging @code{cfront}-generated executables. @value{GDBN} would
5935 require further enhancement to permit that.
5938 If you omit @var{style}, you will see a list of possible formats.
5940 @item show demangle-style
5941 Display the encoding style currently in use for decoding C@t{++} symbols.
5943 @item set print object
5944 @itemx set print object on
5945 @cindex derived type of an object, printing
5946 @cindex display derived types
5947 When displaying a pointer to an object, identify the @emph{actual}
5948 (derived) type of the object rather than the @emph{declared} type, using
5949 the virtual function table.
5951 @item set print object off
5952 Display only the declared type of objects, without reference to the
5953 virtual function table. This is the default setting.
5955 @item show print object
5956 Show whether actual, or declared, object types are displayed.
5958 @item set print static-members
5959 @itemx set print static-members on
5960 @cindex static members of C@t{++} objects
5961 Print static members when displaying a C@t{++} object. The default is on.
5963 @item set print static-members off
5964 Do not print static members when displaying a C@t{++} object.
5966 @item show print static-members
5967 Show whether C@t{++} static members are printed or not.
5969 @item set print pascal_static-members
5970 @itemx set print pascal_static-members on
5971 @cindex static members of Pacal objects
5972 @cindex Pacal objects, static members display
5973 Print static members when displaying a Pascal object. The default is on.
5975 @item set print pascal_static-members off
5976 Do not print static members when displaying a Pascal object.
5978 @item show print pascal_static-members
5979 Show whether Pascal static members are printed or not.
5981 @c These don't work with HP ANSI C++ yet.
5982 @item set print vtbl
5983 @itemx set print vtbl on
5984 @cindex pretty print C@t{++} virtual function tables
5985 @cindex virtual functions (C@t{++}) display
5986 @cindex VTBL display
5987 Pretty print C@t{++} virtual function tables. The default is off.
5988 (The @code{vtbl} commands do not work on programs compiled with the HP
5989 ANSI C@t{++} compiler (@code{aCC}).)
5991 @item set print vtbl off
5992 Do not pretty print C@t{++} virtual function tables.
5994 @item show print vtbl
5995 Show whether C@t{++} virtual function tables are pretty printed, or not.
5999 @section Value history
6001 @cindex value history
6002 @cindex history of values printed by @value{GDBN}
6003 Values printed by the @code{print} command are saved in the @value{GDBN}
6004 @dfn{value history}. This allows you to refer to them in other expressions.
6005 Values are kept until the symbol table is re-read or discarded
6006 (for example with the @code{file} or @code{symbol-file} commands).
6007 When the symbol table changes, the value history is discarded,
6008 since the values may contain pointers back to the types defined in the
6013 @cindex history number
6014 The values printed are given @dfn{history numbers} by which you can
6015 refer to them. These are successive integers starting with one.
6016 @code{print} shows you the history number assigned to a value by
6017 printing @samp{$@var{num} = } before the value; here @var{num} is the
6020 To refer to any previous value, use @samp{$} followed by the value's
6021 history number. The way @code{print} labels its output is designed to
6022 remind you of this. Just @code{$} refers to the most recent value in
6023 the history, and @code{$$} refers to the value before that.
6024 @code{$$@var{n}} refers to the @var{n}th value from the end; @code{$$2}
6025 is the value just prior to @code{$$}, @code{$$1} is equivalent to
6026 @code{$$}, and @code{$$0} is equivalent to @code{$}.
6028 For example, suppose you have just printed a pointer to a structure and
6029 want to see the contents of the structure. It suffices to type
6035 If you have a chain of structures where the component @code{next} points
6036 to the next one, you can print the contents of the next one with this:
6043 You can print successive links in the chain by repeating this
6044 command---which you can do by just typing @key{RET}.
6046 Note that the history records values, not expressions. If the value of
6047 @code{x} is 4 and you type these commands:
6055 then the value recorded in the value history by the @code{print} command
6056 remains 4 even though the value of @code{x} has changed.
6061 Print the last ten values in the value history, with their item numbers.
6062 This is like @samp{p@ $$9} repeated ten times, except that @code{show
6063 values} does not change the history.
6065 @item show values @var{n}
6066 Print ten history values centered on history item number @var{n}.
6069 Print ten history values just after the values last printed. If no more
6070 values are available, @code{show values +} produces no display.
6073 Pressing @key{RET} to repeat @code{show values @var{n}} has exactly the
6074 same effect as @samp{show values +}.
6076 @node Convenience Vars
6077 @section Convenience variables
6079 @cindex convenience variables
6080 @cindex user-defined variables
6081 @value{GDBN} provides @dfn{convenience variables} that you can use within
6082 @value{GDBN} to hold on to a value and refer to it later. These variables
6083 exist entirely within @value{GDBN}; they are not part of your program, and
6084 setting a convenience variable has no direct effect on further execution
6085 of your program. That is why you can use them freely.
6087 Convenience variables are prefixed with @samp{$}. Any name preceded by
6088 @samp{$} can be used for a convenience variable, unless it is one of
6089 the predefined machine-specific register names (@pxref{Registers, ,Registers}).
6090 (Value history references, in contrast, are @emph{numbers} preceded
6091 by @samp{$}. @xref{Value History, ,Value history}.)
6093 You can save a value in a convenience variable with an assignment
6094 expression, just as you would set a variable in your program.
6098 set $foo = *object_ptr
6102 would save in @code{$foo} the value contained in the object pointed to by
6105 Using a convenience variable for the first time creates it, but its
6106 value is @code{void} until you assign a new value. You can alter the
6107 value with another assignment at any time.
6109 Convenience variables have no fixed types. You can assign a convenience
6110 variable any type of value, including structures and arrays, even if
6111 that variable already has a value of a different type. The convenience
6112 variable, when used as an expression, has the type of its current value.
6115 @kindex show convenience
6116 @cindex show all user variables
6117 @item show convenience
6118 Print a list of convenience variables used so far, and their values.
6119 Abbreviated @code{show conv}.
6122 One of the ways to use a convenience variable is as a counter to be
6123 incremented or a pointer to be advanced. For example, to print
6124 a field from successive elements of an array of structures:
6128 print bar[$i++]->contents
6132 Repeat that command by typing @key{RET}.
6134 Some convenience variables are created automatically by @value{GDBN} and given
6135 values likely to be useful.
6138 @vindex $_@r{, convenience variable}
6140 The variable @code{$_} is automatically set by the @code{x} command to
6141 the last address examined (@pxref{Memory, ,Examining memory}). Other
6142 commands which provide a default address for @code{x} to examine also
6143 set @code{$_} to that address; these commands include @code{info line}
6144 and @code{info breakpoint}. The type of @code{$_} is @code{void *}
6145 except when set by the @code{x} command, in which case it is a pointer
6146 to the type of @code{$__}.
6148 @vindex $__@r{, convenience variable}
6150 The variable @code{$__} is automatically set by the @code{x} command
6151 to the value found in the last address examined. Its type is chosen
6152 to match the format in which the data was printed.
6155 @vindex $_exitcode@r{, convenience variable}
6156 The variable @code{$_exitcode} is automatically set to the exit code when
6157 the program being debugged terminates.
6160 On HP-UX systems, if you refer to a function or variable name that
6161 begins with a dollar sign, @value{GDBN} searches for a user or system
6162 name first, before it searches for a convenience variable.
6168 You can refer to machine register contents, in expressions, as variables
6169 with names starting with @samp{$}. The names of registers are different
6170 for each machine; use @code{info registers} to see the names used on
6174 @kindex info registers
6175 @item info registers
6176 Print the names and values of all registers except floating-point
6177 and vector registers (in the selected stack frame).
6179 @kindex info all-registers
6180 @cindex floating point registers
6181 @item info all-registers
6182 Print the names and values of all registers, including floating-point
6183 and vector registers (in the selected stack frame).
6185 @item info registers @var{regname} @dots{}
6186 Print the @dfn{relativized} value of each specified register @var{regname}.
6187 As discussed in detail below, register values are normally relative to
6188 the selected stack frame. @var{regname} may be any register name valid on
6189 the machine you are using, with or without the initial @samp{$}.
6192 @cindex stack pointer register
6193 @cindex program counter register
6194 @cindex process status register
6195 @cindex frame pointer register
6196 @cindex standard registers
6197 @value{GDBN} has four ``standard'' register names that are available (in
6198 expressions) on most machines---whenever they do not conflict with an
6199 architecture's canonical mnemonics for registers. The register names
6200 @code{$pc} and @code{$sp} are used for the program counter register and
6201 the stack pointer. @code{$fp} is used for a register that contains a
6202 pointer to the current stack frame, and @code{$ps} is used for a
6203 register that contains the processor status. For example,
6204 you could print the program counter in hex with
6211 or print the instruction to be executed next with
6218 or add four to the stack pointer@footnote{This is a way of removing
6219 one word from the stack, on machines where stacks grow downward in
6220 memory (most machines, nowadays). This assumes that the innermost
6221 stack frame is selected; setting @code{$sp} is not allowed when other
6222 stack frames are selected. To pop entire frames off the stack,
6223 regardless of machine architecture, use @code{return};
6224 see @ref{Returning, ,Returning from a function}.} with
6230 Whenever possible, these four standard register names are available on
6231 your machine even though the machine has different canonical mnemonics,
6232 so long as there is no conflict. The @code{info registers} command
6233 shows the canonical names. For example, on the SPARC, @code{info
6234 registers} displays the processor status register as @code{$psr} but you
6235 can also refer to it as @code{$ps}; and on x86-based machines @code{$ps}
6236 is an alias for the @sc{eflags} register.
6238 @value{GDBN} always considers the contents of an ordinary register as an
6239 integer when the register is examined in this way. Some machines have
6240 special registers which can hold nothing but floating point; these
6241 registers are considered to have floating point values. There is no way
6242 to refer to the contents of an ordinary register as floating point value
6243 (although you can @emph{print} it as a floating point value with
6244 @samp{print/f $@var{regname}}).
6246 Some registers have distinct ``raw'' and ``virtual'' data formats. This
6247 means that the data format in which the register contents are saved by
6248 the operating system is not the same one that your program normally
6249 sees. For example, the registers of the 68881 floating point
6250 coprocessor are always saved in ``extended'' (raw) format, but all C
6251 programs expect to work with ``double'' (virtual) format. In such
6252 cases, @value{GDBN} normally works with the virtual format only (the format
6253 that makes sense for your program), but the @code{info registers} command
6254 prints the data in both formats.
6256 Normally, register values are relative to the selected stack frame
6257 (@pxref{Selection, ,Selecting a frame}). This means that you get the
6258 value that the register would contain if all stack frames farther in
6259 were exited and their saved registers restored. In order to see the
6260 true contents of hardware registers, you must select the innermost
6261 frame (with @samp{frame 0}).
6263 However, @value{GDBN} must deduce where registers are saved, from the machine
6264 code generated by your compiler. If some registers are not saved, or if
6265 @value{GDBN} is unable to locate the saved registers, the selected stack
6266 frame makes no difference.
6268 @node Floating Point Hardware
6269 @section Floating point hardware
6270 @cindex floating point
6272 Depending on the configuration, @value{GDBN} may be able to give
6273 you more information about the status of the floating point hardware.
6278 Display hardware-dependent information about the floating
6279 point unit. The exact contents and layout vary depending on the
6280 floating point chip. Currently, @samp{info float} is supported on
6281 the ARM and x86 machines.
6285 @section Vector Unit
6288 Depending on the configuration, @value{GDBN} may be able to give you
6289 more information about the status of the vector unit.
6294 Display information about the vector unit. The exact contents and
6295 layout vary depending on the hardware.
6298 @node OS Information
6299 @section Operating system auxiliary information
6300 @cindex OS information
6302 @value{GDBN} provides interfaces to useful OS facilities that can help
6303 you debug your program.
6305 @cindex @code{ptrace} system call
6306 @cindex @code{struct user} contents
6307 When @value{GDBN} runs on a @dfn{Posix system} (such as GNU or Unix
6308 machines), it interfaces with the inferior via the @code{ptrace}
6309 system call. The operating system creates a special sata structure,
6310 called @code{struct user}, for this interface. You can use the
6311 command @code{info udot} to display the contents of this data
6317 Display the contents of the @code{struct user} maintained by the OS
6318 kernel for the program being debugged. @value{GDBN} displays the
6319 contents of @code{struct user} as a list of hex numbers, similar to
6320 the @code{examine} command.
6323 @cindex auxiliary vector
6324 @cindex vector, auxiliary
6325 Some operating systems supply an @dfn{auxiliary vector} to programs at
6326 startup. This is akin to the arguments and environment that you
6327 specify for a program, but contains a system-dependent variety of
6328 binary values that tell system libraries important details about the
6329 hardware, operating system, and process. Each value's purpose is
6330 identified by an integer tag; the meanings are well-known but system-specific.
6331 Depending on the configuration and operating system facilities,
6332 @value{GDBN} may be able to show you this information. For remote
6333 targets, this functionality may further depend on the remote stub's
6334 support of the @samp{qPart:auxv:read} packet, see @ref{Remote
6335 configuration, auxiliary vector}.
6340 Display the auxiliary vector of the inferior, which can be either a
6341 live process or a core dump file. @value{GDBN} prints each tag value
6342 numerically, and also shows names and text descriptions for recognized
6343 tags. Some values in the vector are numbers, some bit masks, and some
6344 pointers to strings or other data. @value{GDBN} displays each value in the
6345 most appropriate form for a recognized tag, and in hexadecimal for
6346 an unrecognized tag.
6350 @node Memory Region Attributes
6351 @section Memory region attributes
6352 @cindex memory region attributes
6354 @dfn{Memory region attributes} allow you to describe special handling
6355 required by regions of your target's memory. @value{GDBN} uses attributes
6356 to determine whether to allow certain types of memory accesses; whether to
6357 use specific width accesses; and whether to cache target memory.
6359 Defined memory regions can be individually enabled and disabled. When a
6360 memory region is disabled, @value{GDBN} uses the default attributes when
6361 accessing memory in that region. Similarly, if no memory regions have
6362 been defined, @value{GDBN} uses the default attributes when accessing
6365 When a memory region is defined, it is given a number to identify it;
6366 to enable, disable, or remove a memory region, you specify that number.
6370 @item mem @var{lower} @var{upper} @var{attributes}@dots{}
6371 Define a memory region bounded by @var{lower} and @var{upper} with
6372 attributes @var{attributes}@dots{}, and add it to the list of regions
6373 monitored by @value{GDBN}. Note that @var{upper} == 0 is a special
6374 case: it is treated as the the target's maximum memory address.
6375 (0xffff on 16 bit targets, 0xffffffff on 32 bit targets, etc.)
6378 @item delete mem @var{nums}@dots{}
6379 Remove memory regions @var{nums}@dots{} from the list of regions
6380 monitored by @value{GDBN}.
6383 @item disable mem @var{nums}@dots{}
6384 Disable monitoring of memory regions @var{nums}@dots{}.
6385 A disabled memory region is not forgotten.
6386 It may be enabled again later.
6389 @item enable mem @var{nums}@dots{}
6390 Enable monitoring of memory regions @var{nums}@dots{}.
6394 Print a table of all defined memory regions, with the following columns
6398 @item Memory Region Number
6399 @item Enabled or Disabled.
6400 Enabled memory regions are marked with @samp{y}.
6401 Disabled memory regions are marked with @samp{n}.
6404 The address defining the inclusive lower bound of the memory region.
6407 The address defining the exclusive upper bound of the memory region.
6410 The list of attributes set for this memory region.
6415 @subsection Attributes
6417 @subsubsection Memory Access Mode
6418 The access mode attributes set whether @value{GDBN} may make read or
6419 write accesses to a memory region.
6421 While these attributes prevent @value{GDBN} from performing invalid
6422 memory accesses, they do nothing to prevent the target system, I/O DMA,
6423 etc. from accessing memory.
6427 Memory is read only.
6429 Memory is write only.
6431 Memory is read/write. This is the default.
6434 @subsubsection Memory Access Size
6435 The acccess size attributes tells @value{GDBN} to use specific sized
6436 accesses in the memory region. Often memory mapped device registers
6437 require specific sized accesses. If no access size attribute is
6438 specified, @value{GDBN} may use accesses of any size.
6442 Use 8 bit memory accesses.
6444 Use 16 bit memory accesses.
6446 Use 32 bit memory accesses.
6448 Use 64 bit memory accesses.
6451 @c @subsubsection Hardware/Software Breakpoints
6452 @c The hardware/software breakpoint attributes set whether @value{GDBN}
6453 @c will use hardware or software breakpoints for the internal breakpoints
6454 @c used by the step, next, finish, until, etc. commands.
6458 @c Always use hardware breakpoints
6459 @c @item swbreak (default)
6462 @subsubsection Data Cache
6463 The data cache attributes set whether @value{GDBN} will cache target
6464 memory. While this generally improves performance by reducing debug
6465 protocol overhead, it can lead to incorrect results because @value{GDBN}
6466 does not know about volatile variables or memory mapped device
6471 Enable @value{GDBN} to cache target memory.
6473 Disable @value{GDBN} from caching target memory. This is the default.
6476 @c @subsubsection Memory Write Verification
6477 @c The memory write verification attributes set whether @value{GDBN}
6478 @c will re-reads data after each write to verify the write was successful.
6482 @c @item noverify (default)
6485 @node Dump/Restore Files
6486 @section Copy between memory and a file
6487 @cindex dump/restore files
6488 @cindex append data to a file
6489 @cindex dump data to a file
6490 @cindex restore data from a file
6492 You can use the commands @code{dump}, @code{append}, and
6493 @code{restore} to copy data between target memory and a file. The
6494 @code{dump} and @code{append} commands write data to a file, and the
6495 @code{restore} command reads data from a file back into the inferior's
6496 memory. Files may be in binary, Motorola S-record, Intel hex, or
6497 Tektronix Hex format; however, @value{GDBN} can only append to binary
6503 @item dump @r{[}@var{format}@r{]} memory @var{filename} @var{start_addr} @var{end_addr}
6504 @itemx dump @r{[}@var{format}@r{]} value @var{filename} @var{expr}
6505 Dump the contents of memory from @var{start_addr} to @var{end_addr},
6506 or the value of @var{expr}, to @var{filename} in the given format.
6508 The @var{format} parameter may be any one of:
6515 Motorola S-record format.
6517 Tektronix Hex format.
6520 @value{GDBN} uses the same definitions of these formats as the
6521 @sc{gnu} binary utilities, like @samp{objdump} and @samp{objcopy}. If
6522 @var{format} is omitted, @value{GDBN} dumps the data in raw binary
6526 @item append @r{[}binary@r{]} memory @var{filename} @var{start_addr} @var{end_addr}
6527 @itemx append @r{[}binary@r{]} value @var{filename} @var{expr}
6528 Append the contents of memory from @var{start_addr} to @var{end_addr},
6529 or the value of @var{expr}, to the file @var{filename}, in raw binary form.
6530 (@value{GDBN} can only append data to files in raw binary form.)
6533 @item restore @var{filename} @r{[}binary@r{]} @var{bias} @var{start} @var{end}
6534 Restore the contents of file @var{filename} into memory. The
6535 @code{restore} command can automatically recognize any known @sc{bfd}
6536 file format, except for raw binary. To restore a raw binary file you
6537 must specify the optional keyword @code{binary} after the filename.
6539 If @var{bias} is non-zero, its value will be added to the addresses
6540 contained in the file. Binary files always start at address zero, so
6541 they will be restored at address @var{bias}. Other bfd files have
6542 a built-in location; they will be restored at offset @var{bias}
6545 If @var{start} and/or @var{end} are non-zero, then only data between
6546 file offset @var{start} and file offset @var{end} will be restored.
6547 These offsets are relative to the addresses in the file, before
6548 the @var{bias} argument is applied.
6552 @node Core File Generation
6553 @section How to Produce a Core File from Your Program
6554 @cindex dump core from inferior
6556 A @dfn{core file} or @dfn{core dump} is a file that records the memory
6557 image of a running process and its process status (register values
6558 etc.). Its primary use is post-mortem debugging of a program that
6559 crashed while it ran outside a debugger. A program that crashes
6560 automatically produces a core file, unless this feature is disabled by
6561 the user. @xref{Files}, for information on invoking @value{GDBN} in
6562 the post-mortem debugging mode.
6564 Occasionally, you may wish to produce a core file of the program you
6565 are debugging in order to preserve a snapshot of its state.
6566 @value{GDBN} has a special command for that.
6570 @kindex generate-core-file
6571 @item generate-core-file [@var{file}]
6572 @itemx gcore [@var{file}]
6573 Produce a core dump of the inferior process. The optional argument
6574 @var{file} specifies the file name where to put the core dump. If not
6575 specified, the file name defaults to @file{core.@var{pid}}, where
6576 @var{pid} is the inferior process ID.
6578 Note that this command is implemented only for some systems (as of
6579 this writing, @sc{gnu}/Linux, FreeBSD, Solaris, Unixware, and S390).
6582 @node Character Sets
6583 @section Character Sets
6584 @cindex character sets
6586 @cindex translating between character sets
6587 @cindex host character set
6588 @cindex target character set
6590 If the program you are debugging uses a different character set to
6591 represent characters and strings than the one @value{GDBN} uses itself,
6592 @value{GDBN} can automatically translate between the character sets for
6593 you. The character set @value{GDBN} uses we call the @dfn{host
6594 character set}; the one the inferior program uses we call the
6595 @dfn{target character set}.
6597 For example, if you are running @value{GDBN} on a @sc{gnu}/Linux system, which
6598 uses the ISO Latin 1 character set, but you are using @value{GDBN}'s
6599 remote protocol (@pxref{Remote,Remote Debugging}) to debug a program
6600 running on an IBM mainframe, which uses the @sc{ebcdic} character set,
6601 then the host character set is Latin-1, and the target character set is
6602 @sc{ebcdic}. If you give @value{GDBN} the command @code{set
6603 target-charset EBCDIC-US}, then @value{GDBN} translates between
6604 @sc{ebcdic} and Latin 1 as you print character or string values, or use
6605 character and string literals in expressions.
6607 @value{GDBN} has no way to automatically recognize which character set
6608 the inferior program uses; you must tell it, using the @code{set
6609 target-charset} command, described below.
6611 Here are the commands for controlling @value{GDBN}'s character set
6615 @item set target-charset @var{charset}
6616 @kindex set target-charset
6617 Set the current target character set to @var{charset}. We list the
6618 character set names @value{GDBN} recognizes below, but if you type
6619 @code{set target-charset} followed by @key{TAB}@key{TAB}, @value{GDBN} will
6620 list the target character sets it supports.
6624 @item set host-charset @var{charset}
6625 @kindex set host-charset
6626 Set the current host character set to @var{charset}.
6628 By default, @value{GDBN} uses a host character set appropriate to the
6629 system it is running on; you can override that default using the
6630 @code{set host-charset} command.
6632 @value{GDBN} can only use certain character sets as its host character
6633 set. We list the character set names @value{GDBN} recognizes below, and
6634 indicate which can be host character sets, but if you type
6635 @code{set target-charset} followed by @key{TAB}@key{TAB}, @value{GDBN} will
6636 list the host character sets it supports.
6638 @item set charset @var{charset}
6640 Set the current host and target character sets to @var{charset}. As
6641 above, if you type @code{set charset} followed by @key{TAB}@key{TAB},
6642 @value{GDBN} will list the name of the character sets that can be used
6643 for both host and target.
6647 @kindex show charset
6648 Show the names of the current host and target charsets.
6650 @itemx show host-charset
6651 @kindex show host-charset
6652 Show the name of the current host charset.
6654 @itemx show target-charset
6655 @kindex show target-charset
6656 Show the name of the current target charset.
6660 @value{GDBN} currently includes support for the following character
6666 @cindex ASCII character set
6667 Seven-bit U.S. @sc{ascii}. @value{GDBN} can use this as its host
6671 @cindex ISO 8859-1 character set
6672 @cindex ISO Latin 1 character set
6673 The ISO Latin 1 character set. This extends @sc{ascii} with accented
6674 characters needed for French, German, and Spanish. @value{GDBN} can use
6675 this as its host character set.
6679 @cindex EBCDIC character set
6680 @cindex IBM1047 character set
6681 Variants of the @sc{ebcdic} character set, used on some of IBM's
6682 mainframe operating systems. (@sc{gnu}/Linux on the S/390 uses U.S. @sc{ascii}.)
6683 @value{GDBN} cannot use these as its host character set.
6687 Note that these are all single-byte character sets. More work inside
6688 GDB is needed to support multi-byte or variable-width character
6689 encodings, like the UTF-8 and UCS-2 encodings of Unicode.
6691 Here is an example of @value{GDBN}'s character set support in action.
6692 Assume that the following source code has been placed in the file
6693 @file{charset-test.c}:
6699 = @{72, 101, 108, 108, 111, 44, 32, 119,
6700 111, 114, 108, 100, 33, 10, 0@};
6701 char ibm1047_hello[]
6702 = @{200, 133, 147, 147, 150, 107, 64, 166,
6703 150, 153, 147, 132, 90, 37, 0@};
6707 printf ("Hello, world!\n");
6711 In this program, @code{ascii_hello} and @code{ibm1047_hello} are arrays
6712 containing the string @samp{Hello, world!} followed by a newline,
6713 encoded in the @sc{ascii} and @sc{ibm1047} character sets.
6715 We compile the program, and invoke the debugger on it:
6718 $ gcc -g charset-test.c -o charset-test
6719 $ gdb -nw charset-test
6720 GNU gdb 2001-12-19-cvs
6721 Copyright 2001 Free Software Foundation, Inc.
6726 We can use the @code{show charset} command to see what character sets
6727 @value{GDBN} is currently using to interpret and display characters and
6731 (@value{GDBP}) show charset
6732 The current host and target character set is `ISO-8859-1'.
6736 For the sake of printing this manual, let's use @sc{ascii} as our
6737 initial character set:
6739 (@value{GDBP}) set charset ASCII
6740 (@value{GDBP}) show charset
6741 The current host and target character set is `ASCII'.
6745 Let's assume that @sc{ascii} is indeed the correct character set for our
6746 host system --- in other words, let's assume that if @value{GDBN} prints
6747 characters using the @sc{ascii} character set, our terminal will display
6748 them properly. Since our current target character set is also
6749 @sc{ascii}, the contents of @code{ascii_hello} print legibly:
6752 (@value{GDBP}) print ascii_hello
6753 $1 = 0x401698 "Hello, world!\n"
6754 (@value{GDBP}) print ascii_hello[0]
6759 @value{GDBN} uses the target character set for character and string
6760 literals you use in expressions:
6763 (@value{GDBP}) print '+'
6768 The @sc{ascii} character set uses the number 43 to encode the @samp{+}
6771 @value{GDBN} relies on the user to tell it which character set the
6772 target program uses. If we print @code{ibm1047_hello} while our target
6773 character set is still @sc{ascii}, we get jibberish:
6776 (@value{GDBP}) print ibm1047_hello
6777 $4 = 0x4016a8 "\310\205\223\223\226k@@\246\226\231\223\204Z%"
6778 (@value{GDBP}) print ibm1047_hello[0]
6783 If we invoke the @code{set target-charset} followed by @key{TAB}@key{TAB},
6784 @value{GDBN} tells us the character sets it supports:
6787 (@value{GDBP}) set target-charset
6788 ASCII EBCDIC-US IBM1047 ISO-8859-1
6789 (@value{GDBP}) set target-charset
6792 We can select @sc{ibm1047} as our target character set, and examine the
6793 program's strings again. Now the @sc{ascii} string is wrong, but
6794 @value{GDBN} translates the contents of @code{ibm1047_hello} from the
6795 target character set, @sc{ibm1047}, to the host character set,
6796 @sc{ascii}, and they display correctly:
6799 (@value{GDBP}) set target-charset IBM1047
6800 (@value{GDBP}) show charset
6801 The current host character set is `ASCII'.
6802 The current target character set is `IBM1047'.
6803 (@value{GDBP}) print ascii_hello
6804 $6 = 0x401698 "\110\145%%?\054\040\167?\162%\144\041\012"
6805 (@value{GDBP}) print ascii_hello[0]
6807 (@value{GDBP}) print ibm1047_hello
6808 $8 = 0x4016a8 "Hello, world!\n"
6809 (@value{GDBP}) print ibm1047_hello[0]
6814 As above, @value{GDBN} uses the target character set for character and
6815 string literals you use in expressions:
6818 (@value{GDBP}) print '+'
6823 The @sc{ibm1047} character set uses the number 78 to encode the @samp{+}
6826 @node Caching Remote Data
6827 @section Caching Data of Remote Targets
6828 @cindex caching data of remote targets
6830 @value{GDBN} can cache data exchanged between the debugger and a
6831 remote target (@pxref{Remote}). Such caching generally improves
6832 performance, because it reduces the overhead of the remote protocol by
6833 bundling memory reads and writes into large chunks. Unfortunately,
6834 @value{GDBN} does not currently know anything about volatile
6835 registers, and thus data caching will produce incorrect results when
6836 volatile registers are in use.
6839 @kindex set remotecache
6840 @item set remotecache on
6841 @itemx set remotecache off
6842 Set caching state for remote targets. When @code{ON}, use data
6843 caching. By default, this option is @code{OFF}.
6845 @kindex show remotecache
6846 @item show remotecache
6847 Show the current state of data caching for remote targets.
6851 Print the information about the data cache performance. The
6852 information displayed includes: the dcache width and depth; and for
6853 each cache line, how many times it was referenced, and its data and
6854 state (dirty, bad, ok, etc.). This command is useful for debugging
6855 the data cache operation.
6860 @chapter C Preprocessor Macros
6862 Some languages, such as C and C@t{++}, provide a way to define and invoke
6863 ``preprocessor macros'' which expand into strings of tokens.
6864 @value{GDBN} can evaluate expressions containing macro invocations, show
6865 the result of macro expansion, and show a macro's definition, including
6866 where it was defined.
6868 You may need to compile your program specially to provide @value{GDBN}
6869 with information about preprocessor macros. Most compilers do not
6870 include macros in their debugging information, even when you compile
6871 with the @option{-g} flag. @xref{Compilation}.
6873 A program may define a macro at one point, remove that definition later,
6874 and then provide a different definition after that. Thus, at different
6875 points in the program, a macro may have different definitions, or have
6876 no definition at all. If there is a current stack frame, @value{GDBN}
6877 uses the macros in scope at that frame's source code line. Otherwise,
6878 @value{GDBN} uses the macros in scope at the current listing location;
6881 At the moment, @value{GDBN} does not support the @code{##}
6882 token-splicing operator, the @code{#} stringification operator, or
6883 variable-arity macros.
6885 Whenever @value{GDBN} evaluates an expression, it always expands any
6886 macro invocations present in the expression. @value{GDBN} also provides
6887 the following commands for working with macros explicitly.
6891 @kindex macro expand
6892 @cindex macro expansion, showing the results of preprocessor
6893 @cindex preprocessor macro expansion, showing the results of
6894 @cindex expanding preprocessor macros
6895 @item macro expand @var{expression}
6896 @itemx macro exp @var{expression}
6897 Show the results of expanding all preprocessor macro invocations in
6898 @var{expression}. Since @value{GDBN} simply expands macros, but does
6899 not parse the result, @var{expression} need not be a valid expression;
6900 it can be any string of tokens.
6903 @item macro expand-once @var{expression}
6904 @itemx macro exp1 @var{expression}
6905 @cindex expand macro once
6906 @i{(This command is not yet implemented.)} Show the results of
6907 expanding those preprocessor macro invocations that appear explicitly in
6908 @var{expression}. Macro invocations appearing in that expansion are
6909 left unchanged. This command allows you to see the effect of a
6910 particular macro more clearly, without being confused by further
6911 expansions. Since @value{GDBN} simply expands macros, but does not
6912 parse the result, @var{expression} need not be a valid expression; it
6913 can be any string of tokens.
6916 @cindex macro definition, showing
6917 @cindex definition, showing a macro's
6918 @item info macro @var{macro}
6919 Show the definition of the macro named @var{macro}, and describe the
6920 source location where that definition was established.
6922 @kindex macro define
6923 @cindex user-defined macros
6924 @cindex defining macros interactively
6925 @cindex macros, user-defined
6926 @item macro define @var{macro} @var{replacement-list}
6927 @itemx macro define @var{macro}(@var{arglist}) @var{replacement-list}
6928 @i{(This command is not yet implemented.)} Introduce a definition for a
6929 preprocessor macro named @var{macro}, invocations of which are replaced
6930 by the tokens given in @var{replacement-list}. The first form of this
6931 command defines an ``object-like'' macro, which takes no arguments; the
6932 second form defines a ``function-like'' macro, which takes the arguments
6933 given in @var{arglist}.
6935 A definition introduced by this command is in scope in every expression
6936 evaluated in @value{GDBN}, until it is removed with the @command{macro
6937 undef} command, described below. The definition overrides all
6938 definitions for @var{macro} present in the program being debugged, as
6939 well as any previous user-supplied definition.
6942 @item macro undef @var{macro}
6943 @i{(This command is not yet implemented.)} Remove any user-supplied
6944 definition for the macro named @var{macro}. This command only affects
6945 definitions provided with the @command{macro define} command, described
6946 above; it cannot remove definitions present in the program being
6951 @i{(This command is not yet implemented.)} List all the macros
6952 defined using the @code{macro define} command.
6955 @cindex macros, example of debugging with
6956 Here is a transcript showing the above commands in action. First, we
6957 show our source files:
6965 #define ADD(x) (M + x)
6970 printf ("Hello, world!\n");
6972 printf ("We're so creative.\n");
6974 printf ("Goodbye, world!\n");
6981 Now, we compile the program using the @sc{gnu} C compiler, @value{NGCC}.
6982 We pass the @option{-gdwarf-2} and @option{-g3} flags to ensure the
6983 compiler includes information about preprocessor macros in the debugging
6987 $ gcc -gdwarf-2 -g3 sample.c -o sample
6991 Now, we start @value{GDBN} on our sample program:
6995 GNU gdb 2002-05-06-cvs
6996 Copyright 2002 Free Software Foundation, Inc.
6997 GDB is free software, @dots{}
7001 We can expand macros and examine their definitions, even when the
7002 program is not running. @value{GDBN} uses the current listing position
7003 to decide which macro definitions are in scope:
7006 (@value{GDBP}) list main
7009 5 #define ADD(x) (M + x)
7014 10 printf ("Hello, world!\n");
7016 12 printf ("We're so creative.\n");
7017 (@value{GDBP}) info macro ADD
7018 Defined at /home/jimb/gdb/macros/play/sample.c:5
7019 #define ADD(x) (M + x)
7020 (@value{GDBP}) info macro Q
7021 Defined at /home/jimb/gdb/macros/play/sample.h:1
7022 included at /home/jimb/gdb/macros/play/sample.c:2
7024 (@value{GDBP}) macro expand ADD(1)
7025 expands to: (42 + 1)
7026 (@value{GDBP}) macro expand-once ADD(1)
7027 expands to: once (M + 1)
7031 In the example above, note that @command{macro expand-once} expands only
7032 the macro invocation explicit in the original text --- the invocation of
7033 @code{ADD} --- but does not expand the invocation of the macro @code{M},
7034 which was introduced by @code{ADD}.
7036 Once the program is running, GDB uses the macro definitions in force at
7037 the source line of the current stack frame:
7040 (@value{GDBP}) break main
7041 Breakpoint 1 at 0x8048370: file sample.c, line 10.
7043 Starting program: /home/jimb/gdb/macros/play/sample
7045 Breakpoint 1, main () at sample.c:10
7046 10 printf ("Hello, world!\n");
7050 At line 10, the definition of the macro @code{N} at line 9 is in force:
7053 (@value{GDBP}) info macro N
7054 Defined at /home/jimb/gdb/macros/play/sample.c:9
7056 (@value{GDBP}) macro expand N Q M
7058 (@value{GDBP}) print N Q M
7063 As we step over directives that remove @code{N}'s definition, and then
7064 give it a new definition, @value{GDBN} finds the definition (or lack
7065 thereof) in force at each point:
7070 12 printf ("We're so creative.\n");
7071 (@value{GDBP}) info macro N
7072 The symbol `N' has no definition as a C/C++ preprocessor macro
7073 at /home/jimb/gdb/macros/play/sample.c:12
7076 14 printf ("Goodbye, world!\n");
7077 (@value{GDBP}) info macro N
7078 Defined at /home/jimb/gdb/macros/play/sample.c:13
7080 (@value{GDBP}) macro expand N Q M
7081 expands to: 1729 < 42
7082 (@value{GDBP}) print N Q M
7089 @chapter Tracepoints
7090 @c This chapter is based on the documentation written by Michael
7091 @c Snyder, David Taylor, Jim Blandy, and Elena Zannoni.
7094 In some applications, it is not feasible for the debugger to interrupt
7095 the program's execution long enough for the developer to learn
7096 anything helpful about its behavior. If the program's correctness
7097 depends on its real-time behavior, delays introduced by a debugger
7098 might cause the program to change its behavior drastically, or perhaps
7099 fail, even when the code itself is correct. It is useful to be able
7100 to observe the program's behavior without interrupting it.
7102 Using @value{GDBN}'s @code{trace} and @code{collect} commands, you can
7103 specify locations in the program, called @dfn{tracepoints}, and
7104 arbitrary expressions to evaluate when those tracepoints are reached.
7105 Later, using the @code{tfind} command, you can examine the values
7106 those expressions had when the program hit the tracepoints. The
7107 expressions may also denote objects in memory---structures or arrays,
7108 for example---whose values @value{GDBN} should record; while visiting
7109 a particular tracepoint, you may inspect those objects as if they were
7110 in memory at that moment. However, because @value{GDBN} records these
7111 values without interacting with you, it can do so quickly and
7112 unobtrusively, hopefully not disturbing the program's behavior.
7114 The tracepoint facility is currently available only for remote
7115 targets. @xref{Targets}. In addition, your remote target must know how
7116 to collect trace data. This functionality is implemented in the remote
7117 stub; however, none of the stubs distributed with @value{GDBN} support
7118 tracepoints as of this writing.
7120 This chapter describes the tracepoint commands and features.
7124 * Analyze Collected Data::
7125 * Tracepoint Variables::
7128 @node Set Tracepoints
7129 @section Commands to Set Tracepoints
7131 Before running such a @dfn{trace experiment}, an arbitrary number of
7132 tracepoints can be set. Like a breakpoint (@pxref{Set Breaks}), a
7133 tracepoint has a number assigned to it by @value{GDBN}. Like with
7134 breakpoints, tracepoint numbers are successive integers starting from
7135 one. Many of the commands associated with tracepoints take the
7136 tracepoint number as their argument, to identify which tracepoint to
7139 For each tracepoint, you can specify, in advance, some arbitrary set
7140 of data that you want the target to collect in the trace buffer when
7141 it hits that tracepoint. The collected data can include registers,
7142 local variables, or global data. Later, you can use @value{GDBN}
7143 commands to examine the values these data had at the time the
7146 This section describes commands to set tracepoints and associated
7147 conditions and actions.
7150 * Create and Delete Tracepoints::
7151 * Enable and Disable Tracepoints::
7152 * Tracepoint Passcounts::
7153 * Tracepoint Actions::
7154 * Listing Tracepoints::
7155 * Starting and Stopping Trace Experiment::
7158 @node Create and Delete Tracepoints
7159 @subsection Create and Delete Tracepoints
7162 @cindex set tracepoint
7165 The @code{trace} command is very similar to the @code{break} command.
7166 Its argument can be a source line, a function name, or an address in
7167 the target program. @xref{Set Breaks}. The @code{trace} command
7168 defines a tracepoint, which is a point in the target program where the
7169 debugger will briefly stop, collect some data, and then allow the
7170 program to continue. Setting a tracepoint or changing its commands
7171 doesn't take effect until the next @code{tstart} command; thus, you
7172 cannot change the tracepoint attributes once a trace experiment is
7175 Here are some examples of using the @code{trace} command:
7178 (@value{GDBP}) @b{trace foo.c:121} // a source file and line number
7180 (@value{GDBP}) @b{trace +2} // 2 lines forward
7182 (@value{GDBP}) @b{trace my_function} // first source line of function
7184 (@value{GDBP}) @b{trace *my_function} // EXACT start address of function
7186 (@value{GDBP}) @b{trace *0x2117c4} // an address
7190 You can abbreviate @code{trace} as @code{tr}.
7193 @cindex last tracepoint number
7194 @cindex recent tracepoint number
7195 @cindex tracepoint number
7196 The convenience variable @code{$tpnum} records the tracepoint number
7197 of the most recently set tracepoint.
7199 @kindex delete tracepoint
7200 @cindex tracepoint deletion
7201 @item delete tracepoint @r{[}@var{num}@r{]}
7202 Permanently delete one or more tracepoints. With no argument, the
7203 default is to delete all tracepoints.
7208 (@value{GDBP}) @b{delete trace 1 2 3} // remove three tracepoints
7210 (@value{GDBP}) @b{delete trace} // remove all tracepoints
7214 You can abbreviate this command as @code{del tr}.
7217 @node Enable and Disable Tracepoints
7218 @subsection Enable and Disable Tracepoints
7221 @kindex disable tracepoint
7222 @item disable tracepoint @r{[}@var{num}@r{]}
7223 Disable tracepoint @var{num}, or all tracepoints if no argument
7224 @var{num} is given. A disabled tracepoint will have no effect during
7225 the next trace experiment, but it is not forgotten. You can re-enable
7226 a disabled tracepoint using the @code{enable tracepoint} command.
7228 @kindex enable tracepoint
7229 @item enable tracepoint @r{[}@var{num}@r{]}
7230 Enable tracepoint @var{num}, or all tracepoints. The enabled
7231 tracepoints will become effective the next time a trace experiment is
7235 @node Tracepoint Passcounts
7236 @subsection Tracepoint Passcounts
7240 @cindex tracepoint pass count
7241 @item passcount @r{[}@var{n} @r{[}@var{num}@r{]]}
7242 Set the @dfn{passcount} of a tracepoint. The passcount is a way to
7243 automatically stop a trace experiment. If a tracepoint's passcount is
7244 @var{n}, then the trace experiment will be automatically stopped on
7245 the @var{n}'th time that tracepoint is hit. If the tracepoint number
7246 @var{num} is not specified, the @code{passcount} command sets the
7247 passcount of the most recently defined tracepoint. If no passcount is
7248 given, the trace experiment will run until stopped explicitly by the
7254 (@value{GDBP}) @b{passcount 5 2} // Stop on the 5th execution of
7255 @exdent @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @code{// tracepoint 2}
7257 (@value{GDBP}) @b{passcount 12} // Stop on the 12th execution of the
7258 @exdent @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @code{// most recently defined tracepoint.}
7259 (@value{GDBP}) @b{trace foo}
7260 (@value{GDBP}) @b{pass 3}
7261 (@value{GDBP}) @b{trace bar}
7262 (@value{GDBP}) @b{pass 2}
7263 (@value{GDBP}) @b{trace baz}
7264 (@value{GDBP}) @b{pass 1} // Stop tracing when foo has been
7265 @exdent @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @code{// executed 3 times OR when bar has}
7266 @exdent @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @code{// been executed 2 times}
7267 @exdent @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @code{// OR when baz has been executed 1 time.}
7271 @node Tracepoint Actions
7272 @subsection Tracepoint Action Lists
7276 @cindex tracepoint actions
7277 @item actions @r{[}@var{num}@r{]}
7278 This command will prompt for a list of actions to be taken when the
7279 tracepoint is hit. If the tracepoint number @var{num} is not
7280 specified, this command sets the actions for the one that was most
7281 recently defined (so that you can define a tracepoint and then say
7282 @code{actions} without bothering about its number). You specify the
7283 actions themselves on the following lines, one action at a time, and
7284 terminate the actions list with a line containing just @code{end}. So
7285 far, the only defined actions are @code{collect} and
7286 @code{while-stepping}.
7288 @cindex remove actions from a tracepoint
7289 To remove all actions from a tracepoint, type @samp{actions @var{num}}
7290 and follow it immediately with @samp{end}.
7293 (@value{GDBP}) @b{collect @var{data}} // collect some data
7295 (@value{GDBP}) @b{while-stepping 5} // single-step 5 times, collect data
7297 (@value{GDBP}) @b{end} // signals the end of actions.
7300 In the following example, the action list begins with @code{collect}
7301 commands indicating the things to be collected when the tracepoint is
7302 hit. Then, in order to single-step and collect additional data
7303 following the tracepoint, a @code{while-stepping} command is used,
7304 followed by the list of things to be collected while stepping. The
7305 @code{while-stepping} command is terminated by its own separate
7306 @code{end} command. Lastly, the action list is terminated by an
7310 (@value{GDBP}) @b{trace foo}
7311 (@value{GDBP}) @b{actions}
7312 Enter actions for tracepoint 1, one per line:
7321 @kindex collect @r{(tracepoints)}
7322 @item collect @var{expr1}, @var{expr2}, @dots{}
7323 Collect values of the given expressions when the tracepoint is hit.
7324 This command accepts a comma-separated list of any valid expressions.
7325 In addition to global, static, or local variables, the following
7326 special arguments are supported:
7330 collect all registers
7333 collect all function arguments
7336 collect all local variables.
7339 You can give several consecutive @code{collect} commands, each one
7340 with a single argument, or one @code{collect} command with several
7341 arguments separated by commas: the effect is the same.
7343 The command @code{info scope} (@pxref{Symbols, info scope}) is
7344 particularly useful for figuring out what data to collect.
7346 @kindex while-stepping @r{(tracepoints)}
7347 @item while-stepping @var{n}
7348 Perform @var{n} single-step traces after the tracepoint, collecting
7349 new data at each step. The @code{while-stepping} command is
7350 followed by the list of what to collect while stepping (followed by
7351 its own @code{end} command):
7355 > collect $regs, myglobal
7361 You may abbreviate @code{while-stepping} as @code{ws} or
7365 @node Listing Tracepoints
7366 @subsection Listing Tracepoints
7369 @kindex info tracepoints
7371 @cindex information about tracepoints
7372 @item info tracepoints @r{[}@var{num}@r{]}
7373 Display information about the tracepoint @var{num}. If you don't specify
7374 a tracepoint number, displays information about all the tracepoints
7375 defined so far. For each tracepoint, the following information is
7382 whether it is enabled or disabled
7386 its passcount as given by the @code{passcount @var{n}} command
7388 its step count as given by the @code{while-stepping @var{n}} command
7390 where in the source files is the tracepoint set
7392 its action list as given by the @code{actions} command
7396 (@value{GDBP}) @b{info trace}
7397 Num Enb Address PassC StepC What
7398 1 y 0x002117c4 0 0 <gdb_asm>
7399 2 y 0x0020dc64 0 0 in g_test at g_test.c:1375
7400 3 y 0x0020b1f4 0 0 in get_data at ../foo.c:41
7405 This command can be abbreviated @code{info tp}.
7408 @node Starting and Stopping Trace Experiment
7409 @subsection Starting and Stopping Trace Experiment
7413 @cindex start a new trace experiment
7414 @cindex collected data discarded
7416 This command takes no arguments. It starts the trace experiment, and
7417 begins collecting data. This has the side effect of discarding all
7418 the data collected in the trace buffer during the previous trace
7422 @cindex stop a running trace experiment
7424 This command takes no arguments. It ends the trace experiment, and
7425 stops collecting data.
7427 @strong{Note}: a trace experiment and data collection may stop
7428 automatically if any tracepoint's passcount is reached
7429 (@pxref{Tracepoint Passcounts}), or if the trace buffer becomes full.
7432 @cindex status of trace data collection
7433 @cindex trace experiment, status of
7435 This command displays the status of the current trace data
7439 Here is an example of the commands we described so far:
7442 (@value{GDBP}) @b{trace gdb_c_test}
7443 (@value{GDBP}) @b{actions}
7444 Enter actions for tracepoint #1, one per line.
7445 > collect $regs,$locals,$args
7450 (@value{GDBP}) @b{tstart}
7451 [time passes @dots{}]
7452 (@value{GDBP}) @b{tstop}
7456 @node Analyze Collected Data
7457 @section Using the collected data
7459 After the tracepoint experiment ends, you use @value{GDBN} commands
7460 for examining the trace data. The basic idea is that each tracepoint
7461 collects a trace @dfn{snapshot} every time it is hit and another
7462 snapshot every time it single-steps. All these snapshots are
7463 consecutively numbered from zero and go into a buffer, and you can
7464 examine them later. The way you examine them is to @dfn{focus} on a
7465 specific trace snapshot. When the remote stub is focused on a trace
7466 snapshot, it will respond to all @value{GDBN} requests for memory and
7467 registers by reading from the buffer which belongs to that snapshot,
7468 rather than from @emph{real} memory or registers of the program being
7469 debugged. This means that @strong{all} @value{GDBN} commands
7470 (@code{print}, @code{info registers}, @code{backtrace}, etc.) will
7471 behave as if we were currently debugging the program state as it was
7472 when the tracepoint occurred. Any requests for data that are not in
7473 the buffer will fail.
7476 * tfind:: How to select a trace snapshot
7477 * tdump:: How to display all data for a snapshot
7478 * save-tracepoints:: How to save tracepoints for a future run
7482 @subsection @code{tfind @var{n}}
7485 @cindex select trace snapshot
7486 @cindex find trace snapshot
7487 The basic command for selecting a trace snapshot from the buffer is
7488 @code{tfind @var{n}}, which finds trace snapshot number @var{n},
7489 counting from zero. If no argument @var{n} is given, the next
7490 snapshot is selected.
7492 Here are the various forms of using the @code{tfind} command.
7496 Find the first snapshot in the buffer. This is a synonym for
7497 @code{tfind 0} (since 0 is the number of the first snapshot).
7500 Stop debugging trace snapshots, resume @emph{live} debugging.
7503 Same as @samp{tfind none}.
7506 No argument means find the next trace snapshot.
7509 Find the previous trace snapshot before the current one. This permits
7510 retracing earlier steps.
7512 @item tfind tracepoint @var{num}
7513 Find the next snapshot associated with tracepoint @var{num}. Search
7514 proceeds forward from the last examined trace snapshot. If no
7515 argument @var{num} is given, it means find the next snapshot collected
7516 for the same tracepoint as the current snapshot.
7518 @item tfind pc @var{addr}
7519 Find the next snapshot associated with the value @var{addr} of the
7520 program counter. Search proceeds forward from the last examined trace
7521 snapshot. If no argument @var{addr} is given, it means find the next
7522 snapshot with the same value of PC as the current snapshot.
7524 @item tfind outside @var{addr1}, @var{addr2}
7525 Find the next snapshot whose PC is outside the given range of
7528 @item tfind range @var{addr1}, @var{addr2}
7529 Find the next snapshot whose PC is between @var{addr1} and
7530 @var{addr2}. @c FIXME: Is the range inclusive or exclusive?
7532 @item tfind line @r{[}@var{file}:@r{]}@var{n}
7533 Find the next snapshot associated with the source line @var{n}. If
7534 the optional argument @var{file} is given, refer to line @var{n} in
7535 that source file. Search proceeds forward from the last examined
7536 trace snapshot. If no argument @var{n} is given, it means find the
7537 next line other than the one currently being examined; thus saying
7538 @code{tfind line} repeatedly can appear to have the same effect as
7539 stepping from line to line in a @emph{live} debugging session.
7542 The default arguments for the @code{tfind} commands are specifically
7543 designed to make it easy to scan through the trace buffer. For
7544 instance, @code{tfind} with no argument selects the next trace
7545 snapshot, and @code{tfind -} with no argument selects the previous
7546 trace snapshot. So, by giving one @code{tfind} command, and then
7547 simply hitting @key{RET} repeatedly you can examine all the trace
7548 snapshots in order. Or, by saying @code{tfind -} and then hitting
7549 @key{RET} repeatedly you can examine the snapshots in reverse order.
7550 The @code{tfind line} command with no argument selects the snapshot
7551 for the next source line executed. The @code{tfind pc} command with
7552 no argument selects the next snapshot with the same program counter
7553 (PC) as the current frame. The @code{tfind tracepoint} command with
7554 no argument selects the next trace snapshot collected by the same
7555 tracepoint as the current one.
7557 In addition to letting you scan through the trace buffer manually,
7558 these commands make it easy to construct @value{GDBN} scripts that
7559 scan through the trace buffer and print out whatever collected data
7560 you are interested in. Thus, if we want to examine the PC, FP, and SP
7561 registers from each trace frame in the buffer, we can say this:
7564 (@value{GDBP}) @b{tfind start}
7565 (@value{GDBP}) @b{while ($trace_frame != -1)}
7566 > printf "Frame %d, PC = %08X, SP = %08X, FP = %08X\n", \
7567 $trace_frame, $pc, $sp, $fp
7571 Frame 0, PC = 0020DC64, SP = 0030BF3C, FP = 0030BF44
7572 Frame 1, PC = 0020DC6C, SP = 0030BF38, FP = 0030BF44
7573 Frame 2, PC = 0020DC70, SP = 0030BF34, FP = 0030BF44
7574 Frame 3, PC = 0020DC74, SP = 0030BF30, FP = 0030BF44
7575 Frame 4, PC = 0020DC78, SP = 0030BF2C, FP = 0030BF44
7576 Frame 5, PC = 0020DC7C, SP = 0030BF28, FP = 0030BF44
7577 Frame 6, PC = 0020DC80, SP = 0030BF24, FP = 0030BF44
7578 Frame 7, PC = 0020DC84, SP = 0030BF20, FP = 0030BF44
7579 Frame 8, PC = 0020DC88, SP = 0030BF1C, FP = 0030BF44
7580 Frame 9, PC = 0020DC8E, SP = 0030BF18, FP = 0030BF44
7581 Frame 10, PC = 00203F6C, SP = 0030BE3C, FP = 0030BF14
7584 Or, if we want to examine the variable @code{X} at each source line in
7588 (@value{GDBP}) @b{tfind start}
7589 (@value{GDBP}) @b{while ($trace_frame != -1)}
7590 > printf "Frame %d, X == %d\n", $trace_frame, X
7600 @subsection @code{tdump}
7602 @cindex dump all data collected at tracepoint
7603 @cindex tracepoint data, display
7605 This command takes no arguments. It prints all the data collected at
7606 the current trace snapshot.
7609 (@value{GDBP}) @b{trace 444}
7610 (@value{GDBP}) @b{actions}
7611 Enter actions for tracepoint #2, one per line:
7612 > collect $regs, $locals, $args, gdb_long_test
7615 (@value{GDBP}) @b{tstart}
7617 (@value{GDBP}) @b{tfind line 444}
7618 #0 gdb_test (p1=0x11, p2=0x22, p3=0x33, p4=0x44, p5=0x55, p6=0x66)
7620 444 printp( "%s: arguments = 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X\n", )
7622 (@value{GDBP}) @b{tdump}
7623 Data collected at tracepoint 2, trace frame 1:
7624 d0 0xc4aa0085 -995491707
7628 d4 0x71aea3d 119204413
7633 a1 0x3000668 50333288
7636 a4 0x3000698 50333336
7638 fp 0x30bf3c 0x30bf3c
7639 sp 0x30bf34 0x30bf34
7641 pc 0x20b2c8 0x20b2c8
7645 p = 0x20e5b4 "gdb-test"
7652 gdb_long_test = 17 '\021'
7657 @node save-tracepoints
7658 @subsection @code{save-tracepoints @var{filename}}
7659 @kindex save-tracepoints
7660 @cindex save tracepoints for future sessions
7662 This command saves all current tracepoint definitions together with
7663 their actions and passcounts, into a file @file{@var{filename}}
7664 suitable for use in a later debugging session. To read the saved
7665 tracepoint definitions, use the @code{source} command (@pxref{Command
7668 @node Tracepoint Variables
7669 @section Convenience Variables for Tracepoints
7670 @cindex tracepoint variables
7671 @cindex convenience variables for tracepoints
7674 @vindex $trace_frame
7675 @item (int) $trace_frame
7676 The current trace snapshot (a.k.a.@: @dfn{frame}) number, or -1 if no
7677 snapshot is selected.
7680 @item (int) $tracepoint
7681 The tracepoint for the current trace snapshot.
7684 @item (int) $trace_line
7685 The line number for the current trace snapshot.
7688 @item (char []) $trace_file
7689 The source file for the current trace snapshot.
7692 @item (char []) $trace_func
7693 The name of the function containing @code{$tracepoint}.
7696 Note: @code{$trace_file} is not suitable for use in @code{printf},
7697 use @code{output} instead.
7699 Here's a simple example of using these convenience variables for
7700 stepping through all the trace snapshots and printing some of their
7704 (@value{GDBP}) @b{tfind start}
7706 (@value{GDBP}) @b{while $trace_frame != -1}
7707 > output $trace_file
7708 > printf ", line %d (tracepoint #%d)\n", $trace_line, $tracepoint
7714 @chapter Debugging Programs That Use Overlays
7717 If your program is too large to fit completely in your target system's
7718 memory, you can sometimes use @dfn{overlays} to work around this
7719 problem. @value{GDBN} provides some support for debugging programs that
7723 * How Overlays Work:: A general explanation of overlays.
7724 * Overlay Commands:: Managing overlays in @value{GDBN}.
7725 * Automatic Overlay Debugging:: @value{GDBN} can find out which overlays are
7726 mapped by asking the inferior.
7727 * Overlay Sample Program:: A sample program using overlays.
7730 @node How Overlays Work
7731 @section How Overlays Work
7732 @cindex mapped overlays
7733 @cindex unmapped overlays
7734 @cindex load address, overlay's
7735 @cindex mapped address
7736 @cindex overlay area
7738 Suppose you have a computer whose instruction address space is only 64
7739 kilobytes long, but which has much more memory which can be accessed by
7740 other means: special instructions, segment registers, or memory
7741 management hardware, for example. Suppose further that you want to
7742 adapt a program which is larger than 64 kilobytes to run on this system.
7744 One solution is to identify modules of your program which are relatively
7745 independent, and need not call each other directly; call these modules
7746 @dfn{overlays}. Separate the overlays from the main program, and place
7747 their machine code in the larger memory. Place your main program in
7748 instruction memory, but leave at least enough space there to hold the
7749 largest overlay as well.
7751 Now, to call a function located in an overlay, you must first copy that
7752 overlay's machine code from the large memory into the space set aside
7753 for it in the instruction memory, and then jump to its entry point
7756 @c NB: In the below the mapped area's size is greater or equal to the
7757 @c size of all overlays. This is intentional to remind the developer
7758 @c that overlays don't necessarily need to be the same size.
7762 Data Instruction Larger
7763 Address Space Address Space Address Space
7764 +-----------+ +-----------+ +-----------+
7766 +-----------+ +-----------+ +-----------+<-- overlay 1
7767 | program | | main | .----| overlay 1 | load address
7768 | variables | | program | | +-----------+
7769 | and heap | | | | | |
7770 +-----------+ | | | +-----------+<-- overlay 2
7771 | | +-----------+ | | | load address
7772 +-----------+ | | | .-| overlay 2 |
7774 mapped --->+-----------+ | | +-----------+
7776 | overlay | <-' | | |
7777 | area | <---' +-----------+<-- overlay 3
7778 | | <---. | | load address
7779 +-----------+ `--| overlay 3 |
7786 @anchor{A code overlay}A code overlay
7790 The diagram (@pxref{A code overlay}) shows a system with separate data
7791 and instruction address spaces. To map an overlay, the program copies
7792 its code from the larger address space to the instruction address space.
7793 Since the overlays shown here all use the same mapped address, only one
7794 may be mapped at a time. For a system with a single address space for
7795 data and instructions, the diagram would be similar, except that the
7796 program variables and heap would share an address space with the main
7797 program and the overlay area.
7799 An overlay loaded into instruction memory and ready for use is called a
7800 @dfn{mapped} overlay; its @dfn{mapped address} is its address in the
7801 instruction memory. An overlay not present (or only partially present)
7802 in instruction memory is called @dfn{unmapped}; its @dfn{load address}
7803 is its address in the larger memory. The mapped address is also called
7804 the @dfn{virtual memory address}, or @dfn{VMA}; the load address is also
7805 called the @dfn{load memory address}, or @dfn{LMA}.
7807 Unfortunately, overlays are not a completely transparent way to adapt a
7808 program to limited instruction memory. They introduce a new set of
7809 global constraints you must keep in mind as you design your program:
7814 Before calling or returning to a function in an overlay, your program
7815 must make sure that overlay is actually mapped. Otherwise, the call or
7816 return will transfer control to the right address, but in the wrong
7817 overlay, and your program will probably crash.
7820 If the process of mapping an overlay is expensive on your system, you
7821 will need to choose your overlays carefully to minimize their effect on
7822 your program's performance.
7825 The executable file you load onto your system must contain each
7826 overlay's instructions, appearing at the overlay's load address, not its
7827 mapped address. However, each overlay's instructions must be relocated
7828 and its symbols defined as if the overlay were at its mapped address.
7829 You can use GNU linker scripts to specify different load and relocation
7830 addresses for pieces of your program; see @ref{Overlay Description,,,
7831 ld.info, Using ld: the GNU linker}.
7834 The procedure for loading executable files onto your system must be able
7835 to load their contents into the larger address space as well as the
7836 instruction and data spaces.
7840 The overlay system described above is rather simple, and could be
7841 improved in many ways:
7846 If your system has suitable bank switch registers or memory management
7847 hardware, you could use those facilities to make an overlay's load area
7848 contents simply appear at their mapped address in instruction space.
7849 This would probably be faster than copying the overlay to its mapped
7850 area in the usual way.
7853 If your overlays are small enough, you could set aside more than one
7854 overlay area, and have more than one overlay mapped at a time.
7857 You can use overlays to manage data, as well as instructions. In
7858 general, data overlays are even less transparent to your design than
7859 code overlays: whereas code overlays only require care when you call or
7860 return to functions, data overlays require care every time you access
7861 the data. Also, if you change the contents of a data overlay, you
7862 must copy its contents back out to its load address before you can copy a
7863 different data overlay into the same mapped area.
7868 @node Overlay Commands
7869 @section Overlay Commands
7871 To use @value{GDBN}'s overlay support, each overlay in your program must
7872 correspond to a separate section of the executable file. The section's
7873 virtual memory address and load memory address must be the overlay's
7874 mapped and load addresses. Identifying overlays with sections allows
7875 @value{GDBN} to determine the appropriate address of a function or
7876 variable, depending on whether the overlay is mapped or not.
7878 @value{GDBN}'s overlay commands all start with the word @code{overlay};
7879 you can abbreviate this as @code{ov} or @code{ovly}. The commands are:
7884 Disable @value{GDBN}'s overlay support. When overlay support is
7885 disabled, @value{GDBN} assumes that all functions and variables are
7886 always present at their mapped addresses. By default, @value{GDBN}'s
7887 overlay support is disabled.
7889 @item overlay manual
7890 @cindex manual overlay debugging
7891 Enable @dfn{manual} overlay debugging. In this mode, @value{GDBN}
7892 relies on you to tell it which overlays are mapped, and which are not,
7893 using the @code{overlay map-overlay} and @code{overlay unmap-overlay}
7894 commands described below.
7896 @item overlay map-overlay @var{overlay}
7897 @itemx overlay map @var{overlay}
7898 @cindex map an overlay
7899 Tell @value{GDBN} that @var{overlay} is now mapped; @var{overlay} must
7900 be the name of the object file section containing the overlay. When an
7901 overlay is mapped, @value{GDBN} assumes it can find the overlay's
7902 functions and variables at their mapped addresses. @value{GDBN} assumes
7903 that any other overlays whose mapped ranges overlap that of
7904 @var{overlay} are now unmapped.
7906 @item overlay unmap-overlay @var{overlay}
7907 @itemx overlay unmap @var{overlay}
7908 @cindex unmap an overlay
7909 Tell @value{GDBN} that @var{overlay} is no longer mapped; @var{overlay}
7910 must be the name of the object file section containing the overlay.
7911 When an overlay is unmapped, @value{GDBN} assumes it can find the
7912 overlay's functions and variables at their load addresses.
7915 Enable @dfn{automatic} overlay debugging. In this mode, @value{GDBN}
7916 consults a data structure the overlay manager maintains in the inferior
7917 to see which overlays are mapped. For details, see @ref{Automatic
7920 @item overlay load-target
7922 @cindex reloading the overlay table
7923 Re-read the overlay table from the inferior. Normally, @value{GDBN}
7924 re-reads the table @value{GDBN} automatically each time the inferior
7925 stops, so this command should only be necessary if you have changed the
7926 overlay mapping yourself using @value{GDBN}. This command is only
7927 useful when using automatic overlay debugging.
7929 @item overlay list-overlays
7931 @cindex listing mapped overlays
7932 Display a list of the overlays currently mapped, along with their mapped
7933 addresses, load addresses, and sizes.
7937 Normally, when @value{GDBN} prints a code address, it includes the name
7938 of the function the address falls in:
7941 (@value{GDBP}) print main
7942 $3 = @{int ()@} 0x11a0 <main>
7945 When overlay debugging is enabled, @value{GDBN} recognizes code in
7946 unmapped overlays, and prints the names of unmapped functions with
7947 asterisks around them. For example, if @code{foo} is a function in an
7948 unmapped overlay, @value{GDBN} prints it this way:
7951 (@value{GDBP}) overlay list
7952 No sections are mapped.
7953 (@value{GDBP}) print foo
7954 $5 = @{int (int)@} 0x100000 <*foo*>
7957 When @code{foo}'s overlay is mapped, @value{GDBN} prints the function's
7961 (@value{GDBP}) overlay list
7962 Section .ov.foo.text, loaded at 0x100000 - 0x100034,
7963 mapped at 0x1016 - 0x104a
7964 (@value{GDBP}) print foo
7965 $6 = @{int (int)@} 0x1016 <foo>
7968 When overlay debugging is enabled, @value{GDBN} can find the correct
7969 address for functions and variables in an overlay, whether or not the
7970 overlay is mapped. This allows most @value{GDBN} commands, like
7971 @code{break} and @code{disassemble}, to work normally, even on unmapped
7972 code. However, @value{GDBN}'s breakpoint support has some limitations:
7976 @cindex breakpoints in overlays
7977 @cindex overlays, setting breakpoints in
7978 You can set breakpoints in functions in unmapped overlays, as long as
7979 @value{GDBN} can write to the overlay at its load address.
7981 @value{GDBN} can not set hardware or simulator-based breakpoints in
7982 unmapped overlays. However, if you set a breakpoint at the end of your
7983 overlay manager (and tell @value{GDBN} which overlays are now mapped, if
7984 you are using manual overlay management), @value{GDBN} will re-set its
7985 breakpoints properly.
7989 @node Automatic Overlay Debugging
7990 @section Automatic Overlay Debugging
7991 @cindex automatic overlay debugging
7993 @value{GDBN} can automatically track which overlays are mapped and which
7994 are not, given some simple co-operation from the overlay manager in the
7995 inferior. If you enable automatic overlay debugging with the
7996 @code{overlay auto} command (@pxref{Overlay Commands}), @value{GDBN}
7997 looks in the inferior's memory for certain variables describing the
7998 current state of the overlays.
8000 Here are the variables your overlay manager must define to support
8001 @value{GDBN}'s automatic overlay debugging:
8005 @item @code{_ovly_table}:
8006 This variable must be an array of the following structures:
8011 /* The overlay's mapped address. */
8014 /* The size of the overlay, in bytes. */
8017 /* The overlay's load address. */
8020 /* Non-zero if the overlay is currently mapped;
8022 unsigned long mapped;
8026 @item @code{_novlys}:
8027 This variable must be a four-byte signed integer, holding the total
8028 number of elements in @code{_ovly_table}.
8032 To decide whether a particular overlay is mapped or not, @value{GDBN}
8033 looks for an entry in @w{@code{_ovly_table}} whose @code{vma} and
8034 @code{lma} members equal the VMA and LMA of the overlay's section in the
8035 executable file. When @value{GDBN} finds a matching entry, it consults
8036 the entry's @code{mapped} member to determine whether the overlay is
8039 In addition, your overlay manager may define a function called
8040 @code{_ovly_debug_event}. If this function is defined, @value{GDBN}
8041 will silently set a breakpoint there. If the overlay manager then
8042 calls this function whenever it has changed the overlay table, this
8043 will enable @value{GDBN} to accurately keep track of which overlays
8044 are in program memory, and update any breakpoints that may be set
8045 in overlays. This will allow breakpoints to work even if the
8046 overlays are kept in ROM or other non-writable memory while they
8047 are not being executed.
8049 @node Overlay Sample Program
8050 @section Overlay Sample Program
8051 @cindex overlay example program
8053 When linking a program which uses overlays, you must place the overlays
8054 at their load addresses, while relocating them to run at their mapped
8055 addresses. To do this, you must write a linker script (@pxref{Overlay
8056 Description,,, ld.info, Using ld: the GNU linker}). Unfortunately,
8057 since linker scripts are specific to a particular host system, target
8058 architecture, and target memory layout, this manual cannot provide
8059 portable sample code demonstrating @value{GDBN}'s overlay support.
8061 However, the @value{GDBN} source distribution does contain an overlaid
8062 program, with linker scripts for a few systems, as part of its test
8063 suite. The program consists of the following files from
8064 @file{gdb/testsuite/gdb.base}:
8068 The main program file.
8070 A simple overlay manager, used by @file{overlays.c}.
8075 Overlay modules, loaded and used by @file{overlays.c}.
8078 Linker scripts for linking the test program on the @code{d10v-elf}
8079 and @code{m32r-elf} targets.
8082 You can build the test program using the @code{d10v-elf} GCC
8083 cross-compiler like this:
8086 $ d10v-elf-gcc -g -c overlays.c
8087 $ d10v-elf-gcc -g -c ovlymgr.c
8088 $ d10v-elf-gcc -g -c foo.c
8089 $ d10v-elf-gcc -g -c bar.c
8090 $ d10v-elf-gcc -g -c baz.c
8091 $ d10v-elf-gcc -g -c grbx.c
8092 $ d10v-elf-gcc -g overlays.o ovlymgr.o foo.o bar.o \
8093 baz.o grbx.o -Wl,-Td10v.ld -o overlays
8096 The build process is identical for any other architecture, except that
8097 you must substitute the appropriate compiler and linker script for the
8098 target system for @code{d10v-elf-gcc} and @code{d10v.ld}.
8102 @chapter Using @value{GDBN} with Different Languages
8105 Although programming languages generally have common aspects, they are
8106 rarely expressed in the same manner. For instance, in ANSI C,
8107 dereferencing a pointer @code{p} is accomplished by @code{*p}, but in
8108 Modula-2, it is accomplished by @code{p^}. Values can also be
8109 represented (and displayed) differently. Hex numbers in C appear as
8110 @samp{0x1ae}, while in Modula-2 they appear as @samp{1AEH}.
8112 @cindex working language
8113 Language-specific information is built into @value{GDBN} for some languages,
8114 allowing you to express operations like the above in your program's
8115 native language, and allowing @value{GDBN} to output values in a manner
8116 consistent with the syntax of your program's native language. The
8117 language you use to build expressions is called the @dfn{working
8121 * Setting:: Switching between source languages
8122 * Show:: Displaying the language
8123 * Checks:: Type and range checks
8124 * Supported languages:: Supported languages
8125 * Unsupported languages:: Unsupported languages
8129 @section Switching between source languages
8131 There are two ways to control the working language---either have @value{GDBN}
8132 set it automatically, or select it manually yourself. You can use the
8133 @code{set language} command for either purpose. On startup, @value{GDBN}
8134 defaults to setting the language automatically. The working language is
8135 used to determine how expressions you type are interpreted, how values
8138 In addition to the working language, every source file that
8139 @value{GDBN} knows about has its own working language. For some object
8140 file formats, the compiler might indicate which language a particular
8141 source file is in. However, most of the time @value{GDBN} infers the
8142 language from the name of the file. The language of a source file
8143 controls whether C@t{++} names are demangled---this way @code{backtrace} can
8144 show each frame appropriately for its own language. There is no way to
8145 set the language of a source file from within @value{GDBN}, but you can
8146 set the language associated with a filename extension. @xref{Show, ,
8147 Displaying the language}.
8149 This is most commonly a problem when you use a program, such
8150 as @code{cfront} or @code{f2c}, that generates C but is written in
8151 another language. In that case, make the
8152 program use @code{#line} directives in its C output; that way
8153 @value{GDBN} will know the correct language of the source code of the original
8154 program, and will display that source code, not the generated C code.
8157 * Filenames:: Filename extensions and languages.
8158 * Manually:: Setting the working language manually
8159 * Automatically:: Having @value{GDBN} infer the source language
8163 @subsection List of filename extensions and languages
8165 If a source file name ends in one of the following extensions, then
8166 @value{GDBN} infers that its language is the one indicated.
8187 Objective-C source file
8194 Modula-2 source file
8198 Assembler source file. This actually behaves almost like C, but
8199 @value{GDBN} does not skip over function prologues when stepping.
8202 In addition, you may set the language associated with a filename
8203 extension. @xref{Show, , Displaying the language}.
8206 @subsection Setting the working language
8208 If you allow @value{GDBN} to set the language automatically,
8209 expressions are interpreted the same way in your debugging session and
8212 @kindex set language
8213 If you wish, you may set the language manually. To do this, issue the
8214 command @samp{set language @var{lang}}, where @var{lang} is the name of
8216 @code{c} or @code{modula-2}.
8217 For a list of the supported languages, type @samp{set language}.
8219 Setting the language manually prevents @value{GDBN} from updating the working
8220 language automatically. This can lead to confusion if you try
8221 to debug a program when the working language is not the same as the
8222 source language, when an expression is acceptable to both
8223 languages---but means different things. For instance, if the current
8224 source file were written in C, and @value{GDBN} was parsing Modula-2, a
8232 might not have the effect you intended. In C, this means to add
8233 @code{b} and @code{c} and place the result in @code{a}. The result
8234 printed would be the value of @code{a}. In Modula-2, this means to compare
8235 @code{a} to the result of @code{b+c}, yielding a @code{BOOLEAN} value.
8238 @subsection Having @value{GDBN} infer the source language
8240 To have @value{GDBN} set the working language automatically, use
8241 @samp{set language local} or @samp{set language auto}. @value{GDBN}
8242 then infers the working language. That is, when your program stops in a
8243 frame (usually by encountering a breakpoint), @value{GDBN} sets the
8244 working language to the language recorded for the function in that
8245 frame. If the language for a frame is unknown (that is, if the function
8246 or block corresponding to the frame was defined in a source file that
8247 does not have a recognized extension), the current working language is
8248 not changed, and @value{GDBN} issues a warning.
8250 This may not seem necessary for most programs, which are written
8251 entirely in one source language. However, program modules and libraries
8252 written in one source language can be used by a main program written in
8253 a different source language. Using @samp{set language auto} in this
8254 case frees you from having to set the working language manually.
8257 @section Displaying the language
8259 The following commands help you find out which language is the
8260 working language, and also what language source files were written in.
8264 @kindex show language
8265 Display the current working language. This is the
8266 language you can use with commands such as @code{print} to
8267 build and compute expressions that may involve variables in your program.
8270 @kindex info frame@r{, show the source language}
8271 Display the source language for this frame. This language becomes the
8272 working language if you use an identifier from this frame.
8273 @xref{Frame Info, ,Information about a frame}, to identify the other
8274 information listed here.
8277 @kindex info source@r{, show the source language}
8278 Display the source language of this source file.
8279 @xref{Symbols, ,Examining the Symbol Table}, to identify the other
8280 information listed here.
8283 In unusual circumstances, you may have source files with extensions
8284 not in the standard list. You can then set the extension associated
8285 with a language explicitly:
8288 @item set extension-language @var{ext} @var{language}
8289 @kindex set extension-language
8290 Tell @value{GDBN} that source files with extension @var{ext} are to be
8291 assumed as written in the source language @var{language}.
8293 @item info extensions
8294 @kindex info extensions
8295 List all the filename extensions and the associated languages.
8299 @section Type and range checking
8302 @emph{Warning:} In this release, the @value{GDBN} commands for type and range
8303 checking are included, but they do not yet have any effect. This
8304 section documents the intended facilities.
8306 @c FIXME remove warning when type/range code added
8308 Some languages are designed to guard you against making seemingly common
8309 errors through a series of compile- and run-time checks. These include
8310 checking the type of arguments to functions and operators, and making
8311 sure mathematical overflows are caught at run time. Checks such as
8312 these help to ensure a program's correctness once it has been compiled
8313 by eliminating type mismatches, and providing active checks for range
8314 errors when your program is running.
8316 @value{GDBN} can check for conditions like the above if you wish.
8317 Although @value{GDBN} does not check the statements in your program,
8318 it can check expressions entered directly into @value{GDBN} for
8319 evaluation via the @code{print} command, for example. As with the
8320 working language, @value{GDBN} can also decide whether or not to check
8321 automatically based on your program's source language.
8322 @xref{Supported languages, ,Supported languages}, for the default
8323 settings of supported languages.
8326 * Type Checking:: An overview of type checking
8327 * Range Checking:: An overview of range checking
8330 @cindex type checking
8331 @cindex checks, type
8333 @subsection An overview of type checking
8335 Some languages, such as Modula-2, are strongly typed, meaning that the
8336 arguments to operators and functions have to be of the correct type,
8337 otherwise an error occurs. These checks prevent type mismatch
8338 errors from ever causing any run-time problems. For example,
8346 The second example fails because the @code{CARDINAL} 1 is not
8347 type-compatible with the @code{REAL} 2.3.
8349 For the expressions you use in @value{GDBN} commands, you can tell the
8350 @value{GDBN} type checker to skip checking;
8351 to treat any mismatches as errors and abandon the expression;
8352 or to only issue warnings when type mismatches occur,
8353 but evaluate the expression anyway. When you choose the last of
8354 these, @value{GDBN} evaluates expressions like the second example above, but
8355 also issues a warning.
8357 Even if you turn type checking off, there may be other reasons
8358 related to type that prevent @value{GDBN} from evaluating an expression.
8359 For instance, @value{GDBN} does not know how to add an @code{int} and
8360 a @code{struct foo}. These particular type errors have nothing to do
8361 with the language in use, and usually arise from expressions, such as
8362 the one described above, which make little sense to evaluate anyway.
8364 Each language defines to what degree it is strict about type. For
8365 instance, both Modula-2 and C require the arguments to arithmetical
8366 operators to be numbers. In C, enumerated types and pointers can be
8367 represented as numbers, so that they are valid arguments to mathematical
8368 operators. @xref{Supported languages, ,Supported languages}, for further
8369 details on specific languages.
8371 @value{GDBN} provides some additional commands for controlling the type checker:
8373 @kindex set check type
8374 @kindex show check type
8376 @item set check type auto
8377 Set type checking on or off based on the current working language.
8378 @xref{Supported languages, ,Supported languages}, for the default settings for
8381 @item set check type on
8382 @itemx set check type off
8383 Set type checking on or off, overriding the default setting for the
8384 current working language. Issue a warning if the setting does not
8385 match the language default. If any type mismatches occur in
8386 evaluating an expression while type checking is on, @value{GDBN} prints a
8387 message and aborts evaluation of the expression.
8389 @item set check type warn
8390 Cause the type checker to issue warnings, but to always attempt to
8391 evaluate the expression. Evaluating the expression may still
8392 be impossible for other reasons. For example, @value{GDBN} cannot add
8393 numbers and structures.
8396 Show the current setting of the type checker, and whether or not @value{GDBN}
8397 is setting it automatically.
8400 @cindex range checking
8401 @cindex checks, range
8402 @node Range Checking
8403 @subsection An overview of range checking
8405 In some languages (such as Modula-2), it is an error to exceed the
8406 bounds of a type; this is enforced with run-time checks. Such range
8407 checking is meant to ensure program correctness by making sure
8408 computations do not overflow, or indices on an array element access do
8409 not exceed the bounds of the array.
8411 For expressions you use in @value{GDBN} commands, you can tell
8412 @value{GDBN} to treat range errors in one of three ways: ignore them,
8413 always treat them as errors and abandon the expression, or issue
8414 warnings but evaluate the expression anyway.
8416 A range error can result from numerical overflow, from exceeding an
8417 array index bound, or when you type a constant that is not a member
8418 of any type. Some languages, however, do not treat overflows as an
8419 error. In many implementations of C, mathematical overflow causes the
8420 result to ``wrap around'' to lower values---for example, if @var{m} is
8421 the largest integer value, and @var{s} is the smallest, then
8424 @var{m} + 1 @result{} @var{s}
8427 This, too, is specific to individual languages, and in some cases
8428 specific to individual compilers or machines. @xref{Supported languages, ,
8429 Supported languages}, for further details on specific languages.
8431 @value{GDBN} provides some additional commands for controlling the range checker:
8433 @kindex set check range
8434 @kindex show check range
8436 @item set check range auto
8437 Set range checking on or off based on the current working language.
8438 @xref{Supported languages, ,Supported languages}, for the default settings for
8441 @item set check range on
8442 @itemx set check range off
8443 Set range checking on or off, overriding the default setting for the
8444 current working language. A warning is issued if the setting does not
8445 match the language default. If a range error occurs and range checking is on,
8446 then a message is printed and evaluation of the expression is aborted.
8448 @item set check range warn
8449 Output messages when the @value{GDBN} range checker detects a range error,
8450 but attempt to evaluate the expression anyway. Evaluating the
8451 expression may still be impossible for other reasons, such as accessing
8452 memory that the process does not own (a typical example from many Unix
8456 Show the current setting of the range checker, and whether or not it is
8457 being set automatically by @value{GDBN}.
8460 @node Supported languages
8461 @section Supported languages
8463 @value{GDBN} supports C, C@t{++}, Objective-C, Fortran, Java, Pascal,
8464 assembly, Modula-2, and Ada.
8465 @c This is false ...
8466 Some @value{GDBN} features may be used in expressions regardless of the
8467 language you use: the @value{GDBN} @code{@@} and @code{::} operators,
8468 and the @samp{@{type@}addr} construct (@pxref{Expressions,
8469 ,Expressions}) can be used with the constructs of any supported
8472 The following sections detail to what degree each source language is
8473 supported by @value{GDBN}. These sections are not meant to be language
8474 tutorials or references, but serve only as a reference guide to what the
8475 @value{GDBN} expression parser accepts, and what input and output
8476 formats should look like for different languages. There are many good
8477 books written on each of these languages; please look to these for a
8478 language reference or tutorial.
8482 * Objective-C:: Objective-C
8485 * Modula-2:: Modula-2
8490 @subsection C and C@t{++}
8492 @cindex C and C@t{++}
8493 @cindex expressions in C or C@t{++}
8495 Since C and C@t{++} are so closely related, many features of @value{GDBN} apply
8496 to both languages. Whenever this is the case, we discuss those languages
8500 @cindex @code{g++}, @sc{gnu} C@t{++} compiler
8501 @cindex @sc{gnu} C@t{++}
8502 The C@t{++} debugging facilities are jointly implemented by the C@t{++}
8503 compiler and @value{GDBN}. Therefore, to debug your C@t{++} code
8504 effectively, you must compile your C@t{++} programs with a supported
8505 C@t{++} compiler, such as @sc{gnu} @code{g++}, or the HP ANSI C@t{++}
8506 compiler (@code{aCC}).
8508 For best results when using @sc{gnu} C@t{++}, use the DWARF 2 debugging
8509 format; if it doesn't work on your system, try the stabs+ debugging
8510 format. You can select those formats explicitly with the @code{g++}
8511 command-line options @option{-gdwarf-2} and @option{-gstabs+}.
8512 @xref{Debugging Options,,Options for Debugging Your Program or @sc{gnu}
8513 CC, gcc.info, Using @sc{gnu} CC}.
8516 * C Operators:: C and C@t{++} operators
8517 * C Constants:: C and C@t{++} constants
8518 * C plus plus expressions:: C@t{++} expressions
8519 * C Defaults:: Default settings for C and C@t{++}
8520 * C Checks:: C and C@t{++} type and range checks
8521 * Debugging C:: @value{GDBN} and C
8522 * Debugging C plus plus:: @value{GDBN} features for C@t{++}
8526 @subsubsection C and C@t{++} operators
8528 @cindex C and C@t{++} operators
8530 Operators must be defined on values of specific types. For instance,
8531 @code{+} is defined on numbers, but not on structures. Operators are
8532 often defined on groups of types.
8534 For the purposes of C and C@t{++}, the following definitions hold:
8539 @emph{Integral types} include @code{int} with any of its storage-class
8540 specifiers; @code{char}; @code{enum}; and, for C@t{++}, @code{bool}.
8543 @emph{Floating-point types} include @code{float}, @code{double}, and
8544 @code{long double} (if supported by the target platform).
8547 @emph{Pointer types} include all types defined as @code{(@var{type} *)}.
8550 @emph{Scalar types} include all of the above.
8555 The following operators are supported. They are listed here
8556 in order of increasing precedence:
8560 The comma or sequencing operator. Expressions in a comma-separated list
8561 are evaluated from left to right, with the result of the entire
8562 expression being the last expression evaluated.
8565 Assignment. The value of an assignment expression is the value
8566 assigned. Defined on scalar types.
8569 Used in an expression of the form @w{@code{@var{a} @var{op}= @var{b}}},
8570 and translated to @w{@code{@var{a} = @var{a op b}}}.
8571 @w{@code{@var{op}=}} and @code{=} have the same precedence.
8572 @var{op} is any one of the operators @code{|}, @code{^}, @code{&},
8573 @code{<<}, @code{>>}, @code{+}, @code{-}, @code{*}, @code{/}, @code{%}.
8576 The ternary operator. @code{@var{a} ? @var{b} : @var{c}} can be thought
8577 of as: if @var{a} then @var{b} else @var{c}. @var{a} should be of an
8581 Logical @sc{or}. Defined on integral types.
8584 Logical @sc{and}. Defined on integral types.
8587 Bitwise @sc{or}. Defined on integral types.
8590 Bitwise exclusive-@sc{or}. Defined on integral types.
8593 Bitwise @sc{and}. Defined on integral types.
8596 Equality and inequality. Defined on scalar types. The value of these
8597 expressions is 0 for false and non-zero for true.
8599 @item <@r{, }>@r{, }<=@r{, }>=
8600 Less than, greater than, less than or equal, greater than or equal.
8601 Defined on scalar types. The value of these expressions is 0 for false
8602 and non-zero for true.
8605 left shift, and right shift. Defined on integral types.
8608 The @value{GDBN} ``artificial array'' operator (@pxref{Expressions, ,Expressions}).
8611 Addition and subtraction. Defined on integral types, floating-point types and
8614 @item *@r{, }/@r{, }%
8615 Multiplication, division, and modulus. Multiplication and division are
8616 defined on integral and floating-point types. Modulus is defined on
8620 Increment and decrement. When appearing before a variable, the
8621 operation is performed before the variable is used in an expression;
8622 when appearing after it, the variable's value is used before the
8623 operation takes place.
8626 Pointer dereferencing. Defined on pointer types. Same precedence as
8630 Address operator. Defined on variables. Same precedence as @code{++}.
8632 For debugging C@t{++}, @value{GDBN} implements a use of @samp{&} beyond what is
8633 allowed in the C@t{++} language itself: you can use @samp{&(&@var{ref})}
8634 (or, if you prefer, simply @samp{&&@var{ref}}) to examine the address
8635 where a C@t{++} reference variable (declared with @samp{&@var{ref}}) is
8639 Negative. Defined on integral and floating-point types. Same
8640 precedence as @code{++}.
8643 Logical negation. Defined on integral types. Same precedence as
8647 Bitwise complement operator. Defined on integral types. Same precedence as
8652 Structure member, and pointer-to-structure member. For convenience,
8653 @value{GDBN} regards the two as equivalent, choosing whether to dereference a
8654 pointer based on the stored type information.
8655 Defined on @code{struct} and @code{union} data.
8658 Dereferences of pointers to members.
8661 Array indexing. @code{@var{a}[@var{i}]} is defined as
8662 @code{*(@var{a}+@var{i})}. Same precedence as @code{->}.
8665 Function parameter list. Same precedence as @code{->}.
8668 C@t{++} scope resolution operator. Defined on @code{struct}, @code{union},
8669 and @code{class} types.
8672 Doubled colons also represent the @value{GDBN} scope operator
8673 (@pxref{Expressions, ,Expressions}). Same precedence as @code{::},
8677 If an operator is redefined in the user code, @value{GDBN} usually
8678 attempts to invoke the redefined version instead of using the operator's
8686 @subsubsection C and C@t{++} constants
8688 @cindex C and C@t{++} constants
8690 @value{GDBN} allows you to express the constants of C and C@t{++} in the
8695 Integer constants are a sequence of digits. Octal constants are
8696 specified by a leading @samp{0} (i.e.@: zero), and hexadecimal constants
8697 by a leading @samp{0x} or @samp{0X}. Constants may also end with a letter
8698 @samp{l}, specifying that the constant should be treated as a
8702 Floating point constants are a sequence of digits, followed by a decimal
8703 point, followed by a sequence of digits, and optionally followed by an
8704 exponent. An exponent is of the form:
8705 @samp{@w{e@r{[[}+@r{]|}-@r{]}@var{nnn}}}, where @var{nnn} is another
8706 sequence of digits. The @samp{+} is optional for positive exponents.
8707 A floating-point constant may also end with a letter @samp{f} or
8708 @samp{F}, specifying that the constant should be treated as being of
8709 the @code{float} (as opposed to the default @code{double}) type; or with
8710 a letter @samp{l} or @samp{L}, which specifies a @code{long double}
8714 Enumerated constants consist of enumerated identifiers, or their
8715 integral equivalents.
8718 Character constants are a single character surrounded by single quotes
8719 (@code{'}), or a number---the ordinal value of the corresponding character
8720 (usually its @sc{ascii} value). Within quotes, the single character may
8721 be represented by a letter or by @dfn{escape sequences}, which are of
8722 the form @samp{\@var{nnn}}, where @var{nnn} is the octal representation
8723 of the character's ordinal value; or of the form @samp{\@var{x}}, where
8724 @samp{@var{x}} is a predefined special character---for example,
8725 @samp{\n} for newline.
8728 String constants are a sequence of character constants surrounded by
8729 double quotes (@code{"}). Any valid character constant (as described
8730 above) may appear. Double quotes within the string must be preceded by
8731 a backslash, so for instance @samp{"a\"b'c"} is a string of five
8735 Pointer constants are an integral value. You can also write pointers
8736 to constants using the C operator @samp{&}.
8739 Array constants are comma-separated lists surrounded by braces @samp{@{}
8740 and @samp{@}}; for example, @samp{@{1,2,3@}} is a three-element array of
8741 integers, @samp{@{@{1,2@}, @{3,4@}, @{5,6@}@}} is a three-by-two array,
8742 and @samp{@{&"hi", &"there", &"fred"@}} is a three-element array of pointers.
8746 * C plus plus expressions::
8753 @node C plus plus expressions
8754 @subsubsection C@t{++} expressions
8756 @cindex expressions in C@t{++}
8757 @value{GDBN} expression handling can interpret most C@t{++} expressions.
8759 @cindex debugging C@t{++} programs
8760 @cindex C@t{++} compilers
8761 @cindex debug formats and C@t{++}
8762 @cindex @value{NGCC} and C@t{++}
8764 @emph{Warning:} @value{GDBN} can only debug C@t{++} code if you use the
8765 proper compiler and the proper debug format. Currently, @value{GDBN}
8766 works best when debugging C@t{++} code that is compiled with
8767 @value{NGCC} 2.95.3 or with @value{NGCC} 3.1 or newer, using the options
8768 @option{-gdwarf-2} or @option{-gstabs+}. DWARF 2 is preferred over
8769 stabs+. Most configurations of @value{NGCC} emit either DWARF 2 or
8770 stabs+ as their default debug format, so you usually don't need to
8771 specify a debug format explicitly. Other compilers and/or debug formats
8772 are likely to work badly or not at all when using @value{GDBN} to debug
8778 @cindex member functions
8780 Member function calls are allowed; you can use expressions like
8783 count = aml->GetOriginal(x, y)
8786 @vindex this@r{, inside C@t{++} member functions}
8787 @cindex namespace in C@t{++}
8789 While a member function is active (in the selected stack frame), your
8790 expressions have the same namespace available as the member function;
8791 that is, @value{GDBN} allows implicit references to the class instance
8792 pointer @code{this} following the same rules as C@t{++}.
8794 @cindex call overloaded functions
8795 @cindex overloaded functions, calling
8796 @cindex type conversions in C@t{++}
8798 You can call overloaded functions; @value{GDBN} resolves the function
8799 call to the right definition, with some restrictions. @value{GDBN} does not
8800 perform overload resolution involving user-defined type conversions,
8801 calls to constructors, or instantiations of templates that do not exist
8802 in the program. It also cannot handle ellipsis argument lists or
8805 It does perform integral conversions and promotions, floating-point
8806 promotions, arithmetic conversions, pointer conversions, conversions of
8807 class objects to base classes, and standard conversions such as those of
8808 functions or arrays to pointers; it requires an exact match on the
8809 number of function arguments.
8811 Overload resolution is always performed, unless you have specified
8812 @code{set overload-resolution off}. @xref{Debugging C plus plus,
8813 ,@value{GDBN} features for C@t{++}}.
8815 You must specify @code{set overload-resolution off} in order to use an
8816 explicit function signature to call an overloaded function, as in
8818 p 'foo(char,int)'('x', 13)
8821 The @value{GDBN} command-completion facility can simplify this;
8822 see @ref{Completion, ,Command completion}.
8824 @cindex reference declarations
8826 @value{GDBN} understands variables declared as C@t{++} references; you can use
8827 them in expressions just as you do in C@t{++} source---they are automatically
8830 In the parameter list shown when @value{GDBN} displays a frame, the values of
8831 reference variables are not displayed (unlike other variables); this
8832 avoids clutter, since references are often used for large structures.
8833 The @emph{address} of a reference variable is always shown, unless
8834 you have specified @samp{set print address off}.
8837 @value{GDBN} supports the C@t{++} name resolution operator @code{::}---your
8838 expressions can use it just as expressions in your program do. Since
8839 one scope may be defined in another, you can use @code{::} repeatedly if
8840 necessary, for example in an expression like
8841 @samp{@var{scope1}::@var{scope2}::@var{name}}. @value{GDBN} also allows
8842 resolving name scope by reference to source files, in both C and C@t{++}
8843 debugging (@pxref{Variables, ,Program variables}).
8846 In addition, when used with HP's C@t{++} compiler, @value{GDBN} supports
8847 calling virtual functions correctly, printing out virtual bases of
8848 objects, calling functions in a base subobject, casting objects, and
8849 invoking user-defined operators.
8852 @subsubsection C and C@t{++} defaults
8854 @cindex C and C@t{++} defaults
8856 If you allow @value{GDBN} to set type and range checking automatically, they
8857 both default to @code{off} whenever the working language changes to
8858 C or C@t{++}. This happens regardless of whether you or @value{GDBN}
8859 selects the working language.
8861 If you allow @value{GDBN} to set the language automatically, it
8862 recognizes source files whose names end with @file{.c}, @file{.C}, or
8863 @file{.cc}, etc, and when @value{GDBN} enters code compiled from one of
8864 these files, it sets the working language to C or C@t{++}.
8865 @xref{Automatically, ,Having @value{GDBN} infer the source language},
8866 for further details.
8868 @c Type checking is (a) primarily motivated by Modula-2, and (b)
8869 @c unimplemented. If (b) changes, it might make sense to let this node
8870 @c appear even if Mod-2 does not, but meanwhile ignore it. roland 16jul93.
8873 @subsubsection C and C@t{++} type and range checks
8875 @cindex C and C@t{++} checks
8877 By default, when @value{GDBN} parses C or C@t{++} expressions, type checking
8878 is not used. However, if you turn type checking on, @value{GDBN}
8879 considers two variables type equivalent if:
8883 The two variables are structured and have the same structure, union, or
8887 The two variables have the same type name, or types that have been
8888 declared equivalent through @code{typedef}.
8891 @c leaving this out because neither J Gilmore nor R Pesch understand it.
8894 The two @code{struct}, @code{union}, or @code{enum} variables are
8895 declared in the same declaration. (Note: this may not be true for all C
8900 Range checking, if turned on, is done on mathematical operations. Array
8901 indices are not checked, since they are often used to index a pointer
8902 that is not itself an array.
8905 @subsubsection @value{GDBN} and C
8907 The @code{set print union} and @code{show print union} commands apply to
8908 the @code{union} type. When set to @samp{on}, any @code{union} that is
8909 inside a @code{struct} or @code{class} is also printed. Otherwise, it
8910 appears as @samp{@{...@}}.
8912 The @code{@@} operator aids in the debugging of dynamic arrays, formed
8913 with pointers and a memory allocation function. @xref{Expressions,
8917 * Debugging C plus plus::
8920 @node Debugging C plus plus
8921 @subsubsection @value{GDBN} features for C@t{++}
8923 @cindex commands for C@t{++}
8925 Some @value{GDBN} commands are particularly useful with C@t{++}, and some are
8926 designed specifically for use with C@t{++}. Here is a summary:
8929 @cindex break in overloaded functions
8930 @item @r{breakpoint menus}
8931 When you want a breakpoint in a function whose name is overloaded,
8932 @value{GDBN} breakpoint menus help you specify which function definition
8933 you want. @xref{Breakpoint Menus,,Breakpoint menus}.
8935 @cindex overloading in C@t{++}
8936 @item rbreak @var{regex}
8937 Setting breakpoints using regular expressions is helpful for setting
8938 breakpoints on overloaded functions that are not members of any special
8940 @xref{Set Breaks, ,Setting breakpoints}.
8942 @cindex C@t{++} exception handling
8945 Debug C@t{++} exception handling using these commands. @xref{Set
8946 Catchpoints, , Setting catchpoints}.
8949 @item ptype @var{typename}
8950 Print inheritance relationships as well as other information for type
8952 @xref{Symbols, ,Examining the Symbol Table}.
8954 @cindex C@t{++} symbol display
8955 @item set print demangle
8956 @itemx show print demangle
8957 @itemx set print asm-demangle
8958 @itemx show print asm-demangle
8959 Control whether C@t{++} symbols display in their source form, both when
8960 displaying code as C@t{++} source and when displaying disassemblies.
8961 @xref{Print Settings, ,Print settings}.
8963 @item set print object
8964 @itemx show print object
8965 Choose whether to print derived (actual) or declared types of objects.
8966 @xref{Print Settings, ,Print settings}.
8968 @item set print vtbl
8969 @itemx show print vtbl
8970 Control the format for printing virtual function tables.
8971 @xref{Print Settings, ,Print settings}.
8972 (The @code{vtbl} commands do not work on programs compiled with the HP
8973 ANSI C@t{++} compiler (@code{aCC}).)
8975 @kindex set overload-resolution
8976 @cindex overloaded functions, overload resolution
8977 @item set overload-resolution on
8978 Enable overload resolution for C@t{++} expression evaluation. The default
8979 is on. For overloaded functions, @value{GDBN} evaluates the arguments
8980 and searches for a function whose signature matches the argument types,
8981 using the standard C@t{++} conversion rules (see @ref{C plus plus expressions, ,C@t{++}
8982 expressions}, for details). If it cannot find a match, it emits a
8985 @item set overload-resolution off
8986 Disable overload resolution for C@t{++} expression evaluation. For
8987 overloaded functions that are not class member functions, @value{GDBN}
8988 chooses the first function of the specified name that it finds in the
8989 symbol table, whether or not its arguments are of the correct type. For
8990 overloaded functions that are class member functions, @value{GDBN}
8991 searches for a function whose signature @emph{exactly} matches the
8994 @kindex show overload-resolution
8995 @item show overload-resolution
8996 Show the current setting of overload resolution.
8998 @item @r{Overloaded symbol names}
8999 You can specify a particular definition of an overloaded symbol, using
9000 the same notation that is used to declare such symbols in C@t{++}: type
9001 @code{@var{symbol}(@var{types})} rather than just @var{symbol}. You can
9002 also use the @value{GDBN} command-line word completion facilities to list the
9003 available choices, or to finish the type list for you.
9004 @xref{Completion,, Command completion}, for details on how to do this.
9008 @subsection Objective-C
9011 This section provides information about some commands and command
9012 options that are useful for debugging Objective-C code. See also
9013 @ref{Symbols, info classes}, and @ref{Symbols, info selectors}, for a
9014 few more commands specific to Objective-C support.
9017 * Method Names in Commands::
9018 * The Print Command with Objective-C::
9021 @node Method Names in Commands, The Print Command with Objective-C, Objective-C, Objective-C
9022 @subsubsection Method Names in Commands
9024 The following commands have been extended to accept Objective-C method
9025 names as line specifications:
9027 @kindex clear@r{, and Objective-C}
9028 @kindex break@r{, and Objective-C}
9029 @kindex info line@r{, and Objective-C}
9030 @kindex jump@r{, and Objective-C}
9031 @kindex list@r{, and Objective-C}
9035 @item @code{info line}
9040 A fully qualified Objective-C method name is specified as
9043 -[@var{Class} @var{methodName}]
9046 where the minus sign is used to indicate an instance method and a
9047 plus sign (not shown) is used to indicate a class method. The class
9048 name @var{Class} and method name @var{methodName} are enclosed in
9049 brackets, similar to the way messages are specified in Objective-C
9050 source code. For example, to set a breakpoint at the @code{create}
9051 instance method of class @code{Fruit} in the program currently being
9055 break -[Fruit create]
9058 To list ten program lines around the @code{initialize} class method,
9062 list +[NSText initialize]
9065 In the current version of @value{GDBN}, the plus or minus sign is
9066 required. In future versions of @value{GDBN}, the plus or minus
9067 sign will be optional, but you can use it to narrow the search. It
9068 is also possible to specify just a method name:
9074 You must specify the complete method name, including any colons. If
9075 your program's source files contain more than one @code{create} method,
9076 you'll be presented with a numbered list of classes that implement that
9077 method. Indicate your choice by number, or type @samp{0} to exit if
9080 As another example, to clear a breakpoint established at the
9081 @code{makeKeyAndOrderFront:} method of the @code{NSWindow} class, enter:
9084 clear -[NSWindow makeKeyAndOrderFront:]
9087 @node The Print Command with Objective-C
9088 @subsubsection The Print Command With Objective-C
9089 @cindex Objective-C, print objects
9090 @kindex print-object
9091 @kindex po @r{(@code{print-object})}
9093 The print command has also been extended to accept methods. For example:
9096 print -[@var{object} hash]
9099 @cindex print an Objective-C object description
9100 @cindex @code{_NSPrintForDebugger}, and printing Objective-C objects
9102 will tell @value{GDBN} to send the @code{hash} message to @var{object}
9103 and print the result. Also, an additional command has been added,
9104 @code{print-object} or @code{po} for short, which is meant to print
9105 the description of an object. However, this command may only work
9106 with certain Objective-C libraries that have a particular hook
9107 function, @code{_NSPrintForDebugger}, defined.
9111 @cindex Fortran-specific support in @value{GDBN}
9114 @cindex @code{COMMON} blocks, Fortran
9116 @item info common @r{[}@var{common-name}@r{]}
9117 This command prints the values contained in the Fortran @code{COMMON}
9118 block whose name is @var{common-name}. With no argument, the names of
9119 all @code{COMMON} blocks visible at current program location are
9123 Fortran symbols are usually case-insensitive, so @value{GDBN} by
9124 default uses case-insensitive matches for Fortran symbols. You can
9125 change that with the @samp{set case-insensitive} command, see
9126 @ref{Symbols}, for the details.
9131 @cindex Pascal support in @value{GDBN}, limitations
9132 Debugging Pascal programs which use sets, subranges, file variables, or
9133 nested functions does not currently work. @value{GDBN} does not support
9134 entering expressions, printing values, or similar features using Pascal
9137 The Pascal-specific command @code{set print pascal_static-members}
9138 controls whether static members of Pascal objects are displayed.
9139 @xref{Print Settings, pascal_static-members}.
9142 @subsection Modula-2
9144 @cindex Modula-2, @value{GDBN} support
9146 The extensions made to @value{GDBN} to support Modula-2 only support
9147 output from the @sc{gnu} Modula-2 compiler (which is currently being
9148 developed). Other Modula-2 compilers are not currently supported, and
9149 attempting to debug executables produced by them is most likely
9150 to give an error as @value{GDBN} reads in the executable's symbol
9153 @cindex expressions in Modula-2
9155 * M2 Operators:: Built-in operators
9156 * Built-In Func/Proc:: Built-in functions and procedures
9157 * M2 Constants:: Modula-2 constants
9158 * M2 Defaults:: Default settings for Modula-2
9159 * Deviations:: Deviations from standard Modula-2
9160 * M2 Checks:: Modula-2 type and range checks
9161 * M2 Scope:: The scope operators @code{::} and @code{.}
9162 * GDB/M2:: @value{GDBN} and Modula-2
9166 @subsubsection Operators
9167 @cindex Modula-2 operators
9169 Operators must be defined on values of specific types. For instance,
9170 @code{+} is defined on numbers, but not on structures. Operators are
9171 often defined on groups of types. For the purposes of Modula-2, the
9172 following definitions hold:
9177 @emph{Integral types} consist of @code{INTEGER}, @code{CARDINAL}, and
9181 @emph{Character types} consist of @code{CHAR} and its subranges.
9184 @emph{Floating-point types} consist of @code{REAL}.
9187 @emph{Pointer types} consist of anything declared as @code{POINTER TO
9191 @emph{Scalar types} consist of all of the above.
9194 @emph{Set types} consist of @code{SET} and @code{BITSET} types.
9197 @emph{Boolean types} consist of @code{BOOLEAN}.
9201 The following operators are supported, and appear in order of
9202 increasing precedence:
9206 Function argument or array index separator.
9209 Assignment. The value of @var{var} @code{:=} @var{value} is
9213 Less than, greater than on integral, floating-point, or enumerated
9217 Less than or equal to, greater than or equal to
9218 on integral, floating-point and enumerated types, or set inclusion on
9219 set types. Same precedence as @code{<}.
9221 @item =@r{, }<>@r{, }#
9222 Equality and two ways of expressing inequality, valid on scalar types.
9223 Same precedence as @code{<}. In @value{GDBN} scripts, only @code{<>} is
9224 available for inequality, since @code{#} conflicts with the script
9228 Set membership. Defined on set types and the types of their members.
9229 Same precedence as @code{<}.
9232 Boolean disjunction. Defined on boolean types.
9235 Boolean conjunction. Defined on boolean types.
9238 The @value{GDBN} ``artificial array'' operator (@pxref{Expressions, ,Expressions}).
9241 Addition and subtraction on integral and floating-point types, or union
9242 and difference on set types.
9245 Multiplication on integral and floating-point types, or set intersection
9249 Division on floating-point types, or symmetric set difference on set
9250 types. Same precedence as @code{*}.
9253 Integer division and remainder. Defined on integral types. Same
9254 precedence as @code{*}.
9257 Negative. Defined on @code{INTEGER} and @code{REAL} data.
9260 Pointer dereferencing. Defined on pointer types.
9263 Boolean negation. Defined on boolean types. Same precedence as
9267 @code{RECORD} field selector. Defined on @code{RECORD} data. Same
9268 precedence as @code{^}.
9271 Array indexing. Defined on @code{ARRAY} data. Same precedence as @code{^}.
9274 Procedure argument list. Defined on @code{PROCEDURE} objects. Same precedence
9278 @value{GDBN} and Modula-2 scope operators.
9282 @emph{Warning:} Sets and their operations are not yet supported, so @value{GDBN}
9283 treats the use of the operator @code{IN}, or the use of operators
9284 @code{+}, @code{-}, @code{*}, @code{/}, @code{=}, , @code{<>}, @code{#},
9285 @code{<=}, and @code{>=} on sets as an error.
9289 @node Built-In Func/Proc
9290 @subsubsection Built-in functions and procedures
9291 @cindex Modula-2 built-ins
9293 Modula-2 also makes available several built-in procedures and functions.
9294 In describing these, the following metavariables are used:
9299 represents an @code{ARRAY} variable.
9302 represents a @code{CHAR} constant or variable.
9305 represents a variable or constant of integral type.
9308 represents an identifier that belongs to a set. Generally used in the
9309 same function with the metavariable @var{s}. The type of @var{s} should
9310 be @code{SET OF @var{mtype}} (where @var{mtype} is the type of @var{m}).
9313 represents a variable or constant of integral or floating-point type.
9316 represents a variable or constant of floating-point type.
9322 represents a variable.
9325 represents a variable or constant of one of many types. See the
9326 explanation of the function for details.
9329 All Modula-2 built-in procedures also return a result, described below.
9333 Returns the absolute value of @var{n}.
9336 If @var{c} is a lower case letter, it returns its upper case
9337 equivalent, otherwise it returns its argument.
9340 Returns the character whose ordinal value is @var{i}.
9343 Decrements the value in the variable @var{v} by one. Returns the new value.
9345 @item DEC(@var{v},@var{i})
9346 Decrements the value in the variable @var{v} by @var{i}. Returns the
9349 @item EXCL(@var{m},@var{s})
9350 Removes the element @var{m} from the set @var{s}. Returns the new
9353 @item FLOAT(@var{i})
9354 Returns the floating point equivalent of the integer @var{i}.
9357 Returns the index of the last member of @var{a}.
9360 Increments the value in the variable @var{v} by one. Returns the new value.
9362 @item INC(@var{v},@var{i})
9363 Increments the value in the variable @var{v} by @var{i}. Returns the
9366 @item INCL(@var{m},@var{s})
9367 Adds the element @var{m} to the set @var{s} if it is not already
9368 there. Returns the new set.
9371 Returns the maximum value of the type @var{t}.
9374 Returns the minimum value of the type @var{t}.
9377 Returns boolean TRUE if @var{i} is an odd number.
9380 Returns the ordinal value of its argument. For example, the ordinal
9381 value of a character is its @sc{ascii} value (on machines supporting the
9382 @sc{ascii} character set). @var{x} must be of an ordered type, which include
9383 integral, character and enumerated types.
9386 Returns the size of its argument. @var{x} can be a variable or a type.
9388 @item TRUNC(@var{r})
9389 Returns the integral part of @var{r}.
9391 @item VAL(@var{t},@var{i})
9392 Returns the member of the type @var{t} whose ordinal value is @var{i}.
9396 @emph{Warning:} Sets and their operations are not yet supported, so
9397 @value{GDBN} treats the use of procedures @code{INCL} and @code{EXCL} as
9401 @cindex Modula-2 constants
9403 @subsubsection Constants
9405 @value{GDBN} allows you to express the constants of Modula-2 in the following
9411 Integer constants are simply a sequence of digits. When used in an
9412 expression, a constant is interpreted to be type-compatible with the
9413 rest of the expression. Hexadecimal integers are specified by a
9414 trailing @samp{H}, and octal integers by a trailing @samp{B}.
9417 Floating point constants appear as a sequence of digits, followed by a
9418 decimal point and another sequence of digits. An optional exponent can
9419 then be specified, in the form @samp{E@r{[}+@r{|}-@r{]}@var{nnn}}, where
9420 @samp{@r{[}+@r{|}-@r{]}@var{nnn}} is the desired exponent. All of the
9421 digits of the floating point constant must be valid decimal (base 10)
9425 Character constants consist of a single character enclosed by a pair of
9426 like quotes, either single (@code{'}) or double (@code{"}). They may
9427 also be expressed by their ordinal value (their @sc{ascii} value, usually)
9428 followed by a @samp{C}.
9431 String constants consist of a sequence of characters enclosed by a
9432 pair of like quotes, either single (@code{'}) or double (@code{"}).
9433 Escape sequences in the style of C are also allowed. @xref{C
9434 Constants, ,C and C@t{++} constants}, for a brief explanation of escape
9438 Enumerated constants consist of an enumerated identifier.
9441 Boolean constants consist of the identifiers @code{TRUE} and
9445 Pointer constants consist of integral values only.
9448 Set constants are not yet supported.
9452 @subsubsection Modula-2 defaults
9453 @cindex Modula-2 defaults
9455 If type and range checking are set automatically by @value{GDBN}, they
9456 both default to @code{on} whenever the working language changes to
9457 Modula-2. This happens regardless of whether you or @value{GDBN}
9458 selected the working language.
9460 If you allow @value{GDBN} to set the language automatically, then entering
9461 code compiled from a file whose name ends with @file{.mod} sets the
9462 working language to Modula-2. @xref{Automatically, ,Having @value{GDBN} set
9463 the language automatically}, for further details.
9466 @subsubsection Deviations from standard Modula-2
9467 @cindex Modula-2, deviations from
9469 A few changes have been made to make Modula-2 programs easier to debug.
9470 This is done primarily via loosening its type strictness:
9474 Unlike in standard Modula-2, pointer constants can be formed by
9475 integers. This allows you to modify pointer variables during
9476 debugging. (In standard Modula-2, the actual address contained in a
9477 pointer variable is hidden from you; it can only be modified
9478 through direct assignment to another pointer variable or expression that
9479 returned a pointer.)
9482 C escape sequences can be used in strings and characters to represent
9483 non-printable characters. @value{GDBN} prints out strings with these
9484 escape sequences embedded. Single non-printable characters are
9485 printed using the @samp{CHR(@var{nnn})} format.
9488 The assignment operator (@code{:=}) returns the value of its right-hand
9492 All built-in procedures both modify @emph{and} return their argument.
9496 @subsubsection Modula-2 type and range checks
9497 @cindex Modula-2 checks
9500 @emph{Warning:} in this release, @value{GDBN} does not yet perform type or
9503 @c FIXME remove warning when type/range checks added
9505 @value{GDBN} considers two Modula-2 variables type equivalent if:
9509 They are of types that have been declared equivalent via a @code{TYPE
9510 @var{t1} = @var{t2}} statement
9513 They have been declared on the same line. (Note: This is true of the
9514 @sc{gnu} Modula-2 compiler, but it may not be true of other compilers.)
9517 As long as type checking is enabled, any attempt to combine variables
9518 whose types are not equivalent is an error.
9520 Range checking is done on all mathematical operations, assignment, array
9521 index bounds, and all built-in functions and procedures.
9524 @subsubsection The scope operators @code{::} and @code{.}
9526 @cindex @code{.}, Modula-2 scope operator
9527 @cindex colon, doubled as scope operator
9529 @vindex colon-colon@r{, in Modula-2}
9530 @c Info cannot handle :: but TeX can.
9533 @vindex ::@r{, in Modula-2}
9536 There are a few subtle differences between the Modula-2 scope operator
9537 (@code{.}) and the @value{GDBN} scope operator (@code{::}). The two have
9542 @var{module} . @var{id}
9543 @var{scope} :: @var{id}
9547 where @var{scope} is the name of a module or a procedure,
9548 @var{module} the name of a module, and @var{id} is any declared
9549 identifier within your program, except another module.
9551 Using the @code{::} operator makes @value{GDBN} search the scope
9552 specified by @var{scope} for the identifier @var{id}. If it is not
9553 found in the specified scope, then @value{GDBN} searches all scopes
9554 enclosing the one specified by @var{scope}.
9556 Using the @code{.} operator makes @value{GDBN} search the current scope for
9557 the identifier specified by @var{id} that was imported from the
9558 definition module specified by @var{module}. With this operator, it is
9559 an error if the identifier @var{id} was not imported from definition
9560 module @var{module}, or if @var{id} is not an identifier in
9564 @subsubsection @value{GDBN} and Modula-2
9566 Some @value{GDBN} commands have little use when debugging Modula-2 programs.
9567 Five subcommands of @code{set print} and @code{show print} apply
9568 specifically to C and C@t{++}: @samp{vtbl}, @samp{demangle},
9569 @samp{asm-demangle}, @samp{object}, and @samp{union}. The first four
9570 apply to C@t{++}, and the last to the C @code{union} type, which has no direct
9571 analogue in Modula-2.
9573 The @code{@@} operator (@pxref{Expressions, ,Expressions}), while available
9574 with any language, is not useful with Modula-2. Its
9575 intent is to aid the debugging of @dfn{dynamic arrays}, which cannot be
9576 created in Modula-2 as they can in C or C@t{++}. However, because an
9577 address can be specified by an integral constant, the construct
9578 @samp{@{@var{type}@}@var{adrexp}} is still useful.
9580 @cindex @code{#} in Modula-2
9581 In @value{GDBN} scripts, the Modula-2 inequality operator @code{#} is
9582 interpreted as the beginning of a comment. Use @code{<>} instead.
9588 The extensions made to @value{GDBN} for Ada only support
9589 output from the @sc{gnu} Ada (GNAT) compiler.
9590 Other Ada compilers are not currently supported, and
9591 attempting to debug executables produced by them is most likely
9595 @cindex expressions in Ada
9597 * Ada Mode Intro:: General remarks on the Ada syntax
9598 and semantics supported by Ada mode
9600 * Omissions from Ada:: Restrictions on the Ada expression syntax.
9601 * Additions to Ada:: Extensions of the Ada expression syntax.
9602 * Stopping Before Main Program:: Debugging the program during elaboration.
9603 * Ada Glitches:: Known peculiarities of Ada mode.
9606 @node Ada Mode Intro
9607 @subsubsection Introduction
9608 @cindex Ada mode, general
9610 The Ada mode of @value{GDBN} supports a fairly large subset of Ada expression
9611 syntax, with some extensions.
9612 The philosophy behind the design of this subset is
9616 That @value{GDBN} should provide basic literals and access to operations for
9617 arithmetic, dereferencing, field selection, indexing, and subprogram calls,
9618 leaving more sophisticated computations to subprograms written into the
9619 program (which therefore may be called from @value{GDBN}).
9622 That type safety and strict adherence to Ada language restrictions
9623 are not particularly important to the @value{GDBN} user.
9626 That brevity is important to the @value{GDBN} user.
9629 Thus, for brevity, the debugger acts as if there were
9630 implicit @code{with} and @code{use} clauses in effect for all user-written
9631 packages, making it unnecessary to fully qualify most names with
9632 their packages, regardless of context. Where this causes ambiguity,
9633 @value{GDBN} asks the user's intent.
9635 The debugger will start in Ada mode if it detects an Ada main program.
9636 As for other languages, it will enter Ada mode when stopped in a program that
9637 was translated from an Ada source file.
9639 While in Ada mode, you may use `@t{--}' for comments. This is useful
9640 mostly for documenting command files. The standard @value{GDBN} comment
9641 (@samp{#}) still works at the beginning of a line in Ada mode, but not in the
9642 middle (to allow based literals).
9644 The debugger supports limited overloading. Given a subprogram call in which
9645 the function symbol has multiple definitions, it will use the number of
9646 actual parameters and some information about their types to attempt to narrow
9647 the set of definitions. It also makes very limited use of context, preferring
9648 procedures to functions in the context of the @code{call} command, and
9649 functions to procedures elsewhere.
9651 @node Omissions from Ada
9652 @subsubsection Omissions from Ada
9653 @cindex Ada, omissions from
9655 Here are the notable omissions from the subset:
9659 Only a subset of the attributes are supported:
9663 @t{'First}, @t{'Last}, and @t{'Length}
9664 on array objects (not on types and subtypes).
9667 @t{'Min} and @t{'Max}.
9670 @t{'Pos} and @t{'Val}.
9676 @t{'Range} on array objects (not subtypes), but only as the right
9677 operand of the membership (@code{in}) operator.
9680 @t{'Access}, @t{'Unchecked_Access}, and
9681 @t{'Unrestricted_Access} (a GNAT extension).
9689 @code{Characters.Latin_1} are not available and
9690 concatenation is not implemented. Thus, escape characters in strings are
9691 not currently available.
9694 Equality tests (@samp{=} and @samp{/=}) on arrays test for bitwise
9695 equality of representations. They will generally work correctly
9696 for strings and arrays whose elements have integer or enumeration types.
9697 They may not work correctly for arrays whose element
9698 types have user-defined equality, for arrays of real values
9699 (in particular, IEEE-conformant floating point, because of negative
9700 zeroes and NaNs), and for arrays whose elements contain unused bits with
9701 indeterminate values.
9704 The other component-by-component array operations (@code{and}, @code{or},
9705 @code{xor}, @code{not}, and relational tests other than equality)
9706 are not implemented.
9709 There are no record or array aggregates.
9712 Calls to dispatching subprograms are not implemented.
9715 The overloading algorithm is much more limited (i.e., less selective)
9716 than that of real Ada. It makes only limited use of the context in which a subexpression
9717 appears to resolve its meaning, and it is much looser in its rules for allowing
9718 type matches. As a result, some function calls will be ambiguous, and the user
9719 will be asked to choose the proper resolution.
9722 The @code{new} operator is not implemented.
9725 Entry calls are not implemented.
9728 Aside from printing, arithmetic operations on the native VAX floating-point
9729 formats are not supported.
9732 It is not possible to slice a packed array.
9735 @node Additions to Ada
9736 @subsubsection Additions to Ada
9737 @cindex Ada, deviations from
9739 As it does for other languages, @value{GDBN} makes certain generic
9740 extensions to Ada (@pxref{Expressions}):
9744 If the expression @var{E} is a variable residing in memory
9745 (typically a local variable or array element) and @var{N} is
9746 a positive integer, then @code{@var{E}@@@var{N}} displays the values of
9747 @var{E} and the @var{N}-1 adjacent variables following it in memory as an array.
9748 In Ada, this operator is generally not necessary, since its prime use
9749 is in displaying parts of an array, and slicing will usually do this in Ada.
9750 However, there are occasional uses when debugging programs
9751 in which certain debugging information has been optimized away.
9754 @code{@var{B}::@var{var}} means ``the variable named @var{var} that appears
9755 in function or file @var{B}.'' When @var{B} is a file name, you must typically
9756 surround it in single quotes.
9759 The expression @code{@{@var{type}@} @var{addr}} means ``the variable of type
9760 @var{type} that appears at address @var{addr}.''
9763 A name starting with @samp{$} is a convenience variable
9764 (@pxref{Convenience Vars}) or a machine register (@pxref{Registers}).
9767 In addition, @value{GDBN} provides a few other shortcuts and outright additions specific
9772 The assignment statement is allowed as an expression, returning
9773 its right-hand operand as its value. Thus, you may enter
9777 print A(tmp := y + 1)
9781 The semicolon is allowed as an ``operator,'' returning as its value
9782 the value of its right-hand operand.
9783 This allows, for example,
9784 complex conditional breaks:
9788 condition 1 (report(i); k += 1; A(k) > 100)
9792 Rather than use catenation and symbolic character names to introduce special
9793 characters into strings, one may instead use a special bracket notation,
9794 which is also used to print strings. A sequence of characters of the form
9795 @samp{["@var{XX}"]} within a string or character literal denotes the
9796 (single) character whose numeric encoding is @var{XX} in hexadecimal. The
9797 sequence of characters @samp{["""]} also denotes a single quotation mark
9798 in strings. For example,
9800 "One line.["0a"]Next line.["0a"]"
9803 contains an ASCII newline character (@code{Ada.Characters.Latin_1.LF}) after each
9807 The subtype used as a prefix for the attributes @t{'Pos}, @t{'Min}, and
9808 @t{'Max} is optional (and is ignored in any case). For example, it is valid
9816 When printing arrays, @value{GDBN} uses positional notation when the
9817 array has a lower bound of 1, and uses a modified named notation otherwise.
9818 For example, a one-dimensional array of three integers with a lower bound of 3 might print as
9825 That is, in contrast to valid Ada, only the first component has a @code{=>}
9829 You may abbreviate attributes in expressions with any unique,
9830 multi-character subsequence of
9831 their names (an exact match gets preference).
9832 For example, you may use @t{a'len}, @t{a'gth}, or @t{a'lh}
9833 in place of @t{a'length}.
9836 @cindex quoting Ada internal identifiers
9837 Since Ada is case-insensitive, the debugger normally maps identifiers you type
9838 to lower case. The GNAT compiler uses upper-case characters for
9839 some of its internal identifiers, which are normally of no interest to users.
9840 For the rare occasions when you actually have to look at them,
9841 enclose them in angle brackets to avoid the lower-case mapping.
9844 @value{GDBP} print <JMPBUF_SAVE>[0]
9848 Printing an object of class-wide type or dereferencing an
9849 access-to-class-wide value will display all the components of the object's
9850 specific type (as indicated by its run-time tag). Likewise, component
9851 selection on such a value will operate on the specific type of the
9856 @node Stopping Before Main Program
9857 @subsubsection Stopping at the Very Beginning
9859 @cindex breakpointing Ada elaboration code
9860 It is sometimes necessary to debug the program during elaboration, and
9861 before reaching the main procedure.
9862 As defined in the Ada Reference
9863 Manual, the elaboration code is invoked from a procedure called
9864 @code{adainit}. To run your program up to the beginning of
9865 elaboration, simply use the following two commands:
9866 @code{tbreak adainit} and @code{run}.
9869 @subsubsection Known Peculiarities of Ada Mode
9870 @cindex Ada, problems
9872 Besides the omissions listed previously (@pxref{Omissions from Ada}),
9873 we know of several problems with and limitations of Ada mode in
9875 some of which will be fixed with planned future releases of the debugger
9876 and the GNU Ada compiler.
9880 Currently, the debugger
9881 has insufficient information to determine whether certain pointers represent
9882 pointers to objects or the objects themselves.
9883 Thus, the user may have to tack an extra @code{.all} after an expression
9884 to get it printed properly.
9887 Static constants that the compiler chooses not to materialize as objects in
9888 storage are invisible to the debugger.
9891 Named parameter associations in function argument lists are ignored (the
9892 argument lists are treated as positional).
9895 Many useful library packages are currently invisible to the debugger.
9898 Fixed-point arithmetic, conversions, input, and output is carried out using
9899 floating-point arithmetic, and may give results that only approximate those on
9903 The type of the @t{'Address} attribute may not be @code{System.Address}.
9906 The GNAT compiler never generates the prefix @code{Standard} for any of
9907 the standard symbols defined by the Ada language. @value{GDBN} knows about
9908 this: it will strip the prefix from names when you use it, and will never
9909 look for a name you have so qualified among local symbols, nor match against
9910 symbols in other packages or subprograms. If you have
9911 defined entities anywhere in your program other than parameters and
9912 local variables whose simple names match names in @code{Standard},
9913 GNAT's lack of qualification here can cause confusion. When this happens,
9914 you can usually resolve the confusion
9915 by qualifying the problematic names with package
9916 @code{Standard} explicitly.
9919 @node Unsupported languages
9920 @section Unsupported languages
9922 @cindex unsupported languages
9923 @cindex minimal language
9924 In addition to the other fully-supported programming languages,
9925 @value{GDBN} also provides a pseudo-language, called @code{minimal}.
9926 It does not represent a real programming language, but provides a set
9927 of capabilities close to what the C or assembly languages provide.
9928 This should allow most simple operations to be performed while debugging
9929 an application that uses a language currently not supported by @value{GDBN}.
9931 If the language is set to @code{auto}, @value{GDBN} will automatically
9932 select this language if the current frame corresponds to an unsupported
9936 @chapter Examining the Symbol Table
9938 The commands described in this chapter allow you to inquire about the
9939 symbols (names of variables, functions and types) defined in your
9940 program. This information is inherent in the text of your program and
9941 does not change as your program executes. @value{GDBN} finds it in your
9942 program's symbol table, in the file indicated when you started @value{GDBN}
9943 (@pxref{File Options, ,Choosing files}), or by one of the
9944 file-management commands (@pxref{Files, ,Commands to specify files}).
9946 @cindex symbol names
9947 @cindex names of symbols
9948 @cindex quoting names
9949 Occasionally, you may need to refer to symbols that contain unusual
9950 characters, which @value{GDBN} ordinarily treats as word delimiters. The
9951 most frequent case is in referring to static variables in other
9952 source files (@pxref{Variables,,Program variables}). File names
9953 are recorded in object files as debugging symbols, but @value{GDBN} would
9954 ordinarily parse a typical file name, like @file{foo.c}, as the three words
9955 @samp{foo} @samp{.} @samp{c}. To allow @value{GDBN} to recognize
9956 @samp{foo.c} as a single symbol, enclose it in single quotes; for example,
9963 looks up the value of @code{x} in the scope of the file @file{foo.c}.
9966 @cindex case-insensitive symbol names
9967 @cindex case sensitivity in symbol names
9968 @kindex set case-sensitive
9969 @item set case-sensitive on
9970 @itemx set case-sensitive off
9971 @itemx set case-sensitive auto
9972 Normally, when @value{GDBN} looks up symbols, it matches their names
9973 with case sensitivity determined by the current source language.
9974 Occasionally, you may wish to control that. The command @code{set
9975 case-sensitive} lets you do that by specifying @code{on} for
9976 case-sensitive matches or @code{off} for case-insensitive ones. If
9977 you specify @code{auto}, case sensitivity is reset to the default
9978 suitable for the source language. The default is case-sensitive
9979 matches for all languages except for Fortran, for which the default is
9980 case-insensitive matches.
9982 @kindex show case-sensitive
9983 @item show case-sensitive
9984 This command shows the current setting of case sensitivity for symbols
9987 @kindex info address
9988 @cindex address of a symbol
9989 @item info address @var{symbol}
9990 Describe where the data for @var{symbol} is stored. For a register
9991 variable, this says which register it is kept in. For a non-register
9992 local variable, this prints the stack-frame offset at which the variable
9995 Note the contrast with @samp{print &@var{symbol}}, which does not work
9996 at all for a register variable, and for a stack local variable prints
9997 the exact address of the current instantiation of the variable.
10000 @cindex symbol from address
10001 @cindex closest symbol and offset for an address
10002 @item info symbol @var{addr}
10003 Print the name of a symbol which is stored at the address @var{addr}.
10004 If no symbol is stored exactly at @var{addr}, @value{GDBN} prints the
10005 nearest symbol and an offset from it:
10008 (@value{GDBP}) info symbol 0x54320
10009 _initialize_vx + 396 in section .text
10013 This is the opposite of the @code{info address} command. You can use
10014 it to find out the name of a variable or a function given its address.
10017 @item whatis @var{expr}
10018 Print the data type of expression @var{expr}. @var{expr} is not
10019 actually evaluated, and any side-effecting operations (such as
10020 assignments or function calls) inside it do not take place.
10021 @xref{Expressions, ,Expressions}.
10024 Print the data type of @code{$}, the last value in the value history.
10027 @item ptype @var{typename}
10028 Print a description of data type @var{typename}. @var{typename} may be
10029 the name of a type, or for C code it may have the form @samp{class
10030 @var{class-name}}, @samp{struct @var{struct-tag}}, @samp{union
10031 @var{union-tag}} or @samp{enum @var{enum-tag}}.
10033 @item ptype @var{expr}
10035 Print a description of the type of expression @var{expr}. @code{ptype}
10036 differs from @code{whatis} by printing a detailed description, instead
10037 of just the name of the type.
10039 For example, for this variable declaration:
10042 struct complex @{double real; double imag;@} v;
10046 the two commands give this output:
10050 (@value{GDBP}) whatis v
10051 type = struct complex
10052 (@value{GDBP}) ptype v
10053 type = struct complex @{
10061 As with @code{whatis}, using @code{ptype} without an argument refers to
10062 the type of @code{$}, the last value in the value history.
10064 @cindex incomplete type
10065 Sometimes, programs use opaque data types or incomplete specifications
10066 of complex data structure. If the debug information included in the
10067 program does not allow @value{GDBN} to display a full declaration of
10068 the data type, it will say @samp{<incomplete type>}. For example,
10069 given these declarations:
10073 struct foo *fooptr;
10077 but no definition for @code{struct foo} itself, @value{GDBN} will say:
10081 $1 = <incomplete type>
10085 ``Incomplete type'' is C terminology for data types that are not
10086 completely specified.
10089 @item info types @var{regexp}
10091 Print a brief description of all types whose names match the regular
10092 expression @var{regexp} (or all types in your program, if you supply
10093 no argument). Each complete typename is matched as though it were a
10094 complete line; thus, @samp{i type value} gives information on all
10095 types in your program whose names include the string @code{value}, but
10096 @samp{i type ^value$} gives information only on types whose complete
10097 name is @code{value}.
10099 This command differs from @code{ptype} in two ways: first, like
10100 @code{whatis}, it does not print a detailed description; second, it
10101 lists all source files where a type is defined.
10104 @cindex local variables
10105 @item info scope @var{location}
10106 List all the variables local to a particular scope. This command
10107 accepts a @var{location} argument---a function name, a source line, or
10108 an address preceded by a @samp{*}, and prints all the variables local
10109 to the scope defined by that location. For example:
10112 (@value{GDBP}) @b{info scope command_line_handler}
10113 Scope for command_line_handler:
10114 Symbol rl is an argument at stack/frame offset 8, length 4.
10115 Symbol linebuffer is in static storage at address 0x150a18, length 4.
10116 Symbol linelength is in static storage at address 0x150a1c, length 4.
10117 Symbol p is a local variable in register $esi, length 4.
10118 Symbol p1 is a local variable in register $ebx, length 4.
10119 Symbol nline is a local variable in register $edx, length 4.
10120 Symbol repeat is a local variable at frame offset -8, length 4.
10124 This command is especially useful for determining what data to collect
10125 during a @dfn{trace experiment}, see @ref{Tracepoint Actions,
10128 @kindex info source
10130 Show information about the current source file---that is, the source file for
10131 the function containing the current point of execution:
10134 the name of the source file, and the directory containing it,
10136 the directory it was compiled in,
10138 its length, in lines,
10140 which programming language it is written in,
10142 whether the executable includes debugging information for that file, and
10143 if so, what format the information is in (e.g., STABS, Dwarf 2, etc.), and
10145 whether the debugging information includes information about
10146 preprocessor macros.
10150 @kindex info sources
10152 Print the names of all source files in your program for which there is
10153 debugging information, organized into two lists: files whose symbols
10154 have already been read, and files whose symbols will be read when needed.
10156 @kindex info functions
10157 @item info functions
10158 Print the names and data types of all defined functions.
10160 @item info functions @var{regexp}
10161 Print the names and data types of all defined functions
10162 whose names contain a match for regular expression @var{regexp}.
10163 Thus, @samp{info fun step} finds all functions whose names
10164 include @code{step}; @samp{info fun ^step} finds those whose names
10165 start with @code{step}. If a function name contains characters
10166 that conflict with the regular expression language (eg.
10167 @samp{operator*()}), they may be quoted with a backslash.
10169 @kindex info variables
10170 @item info variables
10171 Print the names and data types of all variables that are declared
10172 outside of functions (i.e.@: excluding local variables).
10174 @item info variables @var{regexp}
10175 Print the names and data types of all variables (except for local
10176 variables) whose names contain a match for regular expression
10179 @kindex info classes
10180 @cindex Objective-C, classes and selectors
10182 @itemx info classes @var{regexp}
10183 Display all Objective-C classes in your program, or
10184 (with the @var{regexp} argument) all those matching a particular regular
10187 @kindex info selectors
10188 @item info selectors
10189 @itemx info selectors @var{regexp}
10190 Display all Objective-C selectors in your program, or
10191 (with the @var{regexp} argument) all those matching a particular regular
10195 This was never implemented.
10196 @kindex info methods
10198 @itemx info methods @var{regexp}
10199 The @code{info methods} command permits the user to examine all defined
10200 methods within C@t{++} program, or (with the @var{regexp} argument) a
10201 specific set of methods found in the various C@t{++} classes. Many
10202 C@t{++} classes provide a large number of methods. Thus, the output
10203 from the @code{ptype} command can be overwhelming and hard to use. The
10204 @code{info-methods} command filters the methods, printing only those
10205 which match the regular-expression @var{regexp}.
10208 @cindex reloading symbols
10209 Some systems allow individual object files that make up your program to
10210 be replaced without stopping and restarting your program. For example,
10211 in VxWorks you can simply recompile a defective object file and keep on
10212 running. If you are running on one of these systems, you can allow
10213 @value{GDBN} to reload the symbols for automatically relinked modules:
10216 @kindex set symbol-reloading
10217 @item set symbol-reloading on
10218 Replace symbol definitions for the corresponding source file when an
10219 object file with a particular name is seen again.
10221 @item set symbol-reloading off
10222 Do not replace symbol definitions when encountering object files of the
10223 same name more than once. This is the default state; if you are not
10224 running on a system that permits automatic relinking of modules, you
10225 should leave @code{symbol-reloading} off, since otherwise @value{GDBN}
10226 may discard symbols when linking large programs, that may contain
10227 several modules (from different directories or libraries) with the same
10230 @kindex show symbol-reloading
10231 @item show symbol-reloading
10232 Show the current @code{on} or @code{off} setting.
10235 @cindex opaque data types
10236 @kindex set opaque-type-resolution
10237 @item set opaque-type-resolution on
10238 Tell @value{GDBN} to resolve opaque types. An opaque type is a type
10239 declared as a pointer to a @code{struct}, @code{class}, or
10240 @code{union}---for example, @code{struct MyType *}---that is used in one
10241 source file although the full declaration of @code{struct MyType} is in
10242 another source file. The default is on.
10244 A change in the setting of this subcommand will not take effect until
10245 the next time symbols for a file are loaded.
10247 @item set opaque-type-resolution off
10248 Tell @value{GDBN} not to resolve opaque types. In this case, the type
10249 is printed as follows:
10251 @{<no data fields>@}
10254 @kindex show opaque-type-resolution
10255 @item show opaque-type-resolution
10256 Show whether opaque types are resolved or not.
10258 @kindex maint print symbols
10259 @cindex symbol dump
10260 @kindex maint print psymbols
10261 @cindex partial symbol dump
10262 @item maint print symbols @var{filename}
10263 @itemx maint print psymbols @var{filename}
10264 @itemx maint print msymbols @var{filename}
10265 Write a dump of debugging symbol data into the file @var{filename}.
10266 These commands are used to debug the @value{GDBN} symbol-reading code. Only
10267 symbols with debugging data are included. If you use @samp{maint print
10268 symbols}, @value{GDBN} includes all the symbols for which it has already
10269 collected full details: that is, @var{filename} reflects symbols for
10270 only those files whose symbols @value{GDBN} has read. You can use the
10271 command @code{info sources} to find out which files these are. If you
10272 use @samp{maint print psymbols} instead, the dump shows information about
10273 symbols that @value{GDBN} only knows partially---that is, symbols defined in
10274 files that @value{GDBN} has skimmed, but not yet read completely. Finally,
10275 @samp{maint print msymbols} dumps just the minimal symbol information
10276 required for each object file from which @value{GDBN} has read some symbols.
10277 @xref{Files, ,Commands to specify files}, for a discussion of how
10278 @value{GDBN} reads symbols (in the description of @code{symbol-file}).
10280 @kindex maint info symtabs
10281 @kindex maint info psymtabs
10282 @cindex listing @value{GDBN}'s internal symbol tables
10283 @cindex symbol tables, listing @value{GDBN}'s internal
10284 @cindex full symbol tables, listing @value{GDBN}'s internal
10285 @cindex partial symbol tables, listing @value{GDBN}'s internal
10286 @item maint info symtabs @r{[} @var{regexp} @r{]}
10287 @itemx maint info psymtabs @r{[} @var{regexp} @r{]}
10289 List the @code{struct symtab} or @code{struct partial_symtab}
10290 structures whose names match @var{regexp}. If @var{regexp} is not
10291 given, list them all. The output includes expressions which you can
10292 copy into a @value{GDBN} debugging this one to examine a particular
10293 structure in more detail. For example:
10296 (@value{GDBP}) maint info psymtabs dwarf2read
10297 @{ objfile /home/gnu/build/gdb/gdb
10298 ((struct objfile *) 0x82e69d0)
10299 @{ psymtab /home/gnu/src/gdb/dwarf2read.c
10300 ((struct partial_symtab *) 0x8474b10)
10303 text addresses 0x814d3c8 -- 0x8158074
10304 globals (* (struct partial_symbol **) 0x8507a08 @@ 9)
10305 statics (* (struct partial_symbol **) 0x40e95b78 @@ 2882)
10306 dependencies (none)
10309 (@value{GDBP}) maint info symtabs
10313 We see that there is one partial symbol table whose filename contains
10314 the string @samp{dwarf2read}, belonging to the @samp{gdb} executable;
10315 and we see that @value{GDBN} has not read in any symtabs yet at all.
10316 If we set a breakpoint on a function, that will cause @value{GDBN} to
10317 read the symtab for the compilation unit containing that function:
10320 (@value{GDBP}) break dwarf2_psymtab_to_symtab
10321 Breakpoint 1 at 0x814e5da: file /home/gnu/src/gdb/dwarf2read.c,
10323 (@value{GDBP}) maint info symtabs
10324 @{ objfile /home/gnu/build/gdb/gdb
10325 ((struct objfile *) 0x82e69d0)
10326 @{ symtab /home/gnu/src/gdb/dwarf2read.c
10327 ((struct symtab *) 0x86c1f38)
10330 blockvector ((struct blockvector *) 0x86c1bd0) (primary)
10331 debugformat DWARF 2
10340 @chapter Altering Execution
10342 Once you think you have found an error in your program, you might want to
10343 find out for certain whether correcting the apparent error would lead to
10344 correct results in the rest of the run. You can find the answer by
10345 experiment, using the @value{GDBN} features for altering execution of the
10348 For example, you can store new values into variables or memory
10349 locations, give your program a signal, restart it at a different
10350 address, or even return prematurely from a function.
10353 * Assignment:: Assignment to variables
10354 * Jumping:: Continuing at a different address
10355 * Signaling:: Giving your program a signal
10356 * Returning:: Returning from a function
10357 * Calling:: Calling your program's functions
10358 * Patching:: Patching your program
10362 @section Assignment to variables
10365 @cindex setting variables
10366 To alter the value of a variable, evaluate an assignment expression.
10367 @xref{Expressions, ,Expressions}. For example,
10374 stores the value 4 into the variable @code{x}, and then prints the
10375 value of the assignment expression (which is 4).
10376 @xref{Languages, ,Using @value{GDBN} with Different Languages}, for more
10377 information on operators in supported languages.
10379 @kindex set variable
10380 @cindex variables, setting
10381 If you are not interested in seeing the value of the assignment, use the
10382 @code{set} command instead of the @code{print} command. @code{set} is
10383 really the same as @code{print} except that the expression's value is
10384 not printed and is not put in the value history (@pxref{Value History,
10385 ,Value history}). The expression is evaluated only for its effects.
10387 If the beginning of the argument string of the @code{set} command
10388 appears identical to a @code{set} subcommand, use the @code{set
10389 variable} command instead of just @code{set}. This command is identical
10390 to @code{set} except for its lack of subcommands. For example, if your
10391 program has a variable @code{width}, you get an error if you try to set
10392 a new value with just @samp{set width=13}, because @value{GDBN} has the
10393 command @code{set width}:
10396 (@value{GDBP}) whatis width
10398 (@value{GDBP}) p width
10400 (@value{GDBP}) set width=47
10401 Invalid syntax in expression.
10405 The invalid expression, of course, is @samp{=47}. In
10406 order to actually set the program's variable @code{width}, use
10409 (@value{GDBP}) set var width=47
10412 Because the @code{set} command has many subcommands that can conflict
10413 with the names of program variables, it is a good idea to use the
10414 @code{set variable} command instead of just @code{set}. For example, if
10415 your program has a variable @code{g}, you run into problems if you try
10416 to set a new value with just @samp{set g=4}, because @value{GDBN} has
10417 the command @code{set gnutarget}, abbreviated @code{set g}:
10421 (@value{GDBP}) whatis g
10425 (@value{GDBP}) set g=4
10429 The program being debugged has been started already.
10430 Start it from the beginning? (y or n) y
10431 Starting program: /home/smith/cc_progs/a.out
10432 "/home/smith/cc_progs/a.out": can't open to read symbols:
10433 Invalid bfd target.
10434 (@value{GDBP}) show g
10435 The current BFD target is "=4".
10440 The program variable @code{g} did not change, and you silently set the
10441 @code{gnutarget} to an invalid value. In order to set the variable
10445 (@value{GDBP}) set var g=4
10448 @value{GDBN} allows more implicit conversions in assignments than C; you can
10449 freely store an integer value into a pointer variable or vice versa,
10450 and you can convert any structure to any other structure that is the
10451 same length or shorter.
10452 @comment FIXME: how do structs align/pad in these conversions?
10455 To store values into arbitrary places in memory, use the @samp{@{@dots{}@}}
10456 construct to generate a value of specified type at a specified address
10457 (@pxref{Expressions, ,Expressions}). For example, @code{@{int@}0x83040} refers
10458 to memory location @code{0x83040} as an integer (which implies a certain size
10459 and representation in memory), and
10462 set @{int@}0x83040 = 4
10466 stores the value 4 into that memory location.
10469 @section Continuing at a different address
10471 Ordinarily, when you continue your program, you do so at the place where
10472 it stopped, with the @code{continue} command. You can instead continue at
10473 an address of your own choosing, with the following commands:
10477 @item jump @var{linespec}
10478 Resume execution at line @var{linespec}. Execution stops again
10479 immediately if there is a breakpoint there. @xref{List, ,Printing
10480 source lines}, for a description of the different forms of
10481 @var{linespec}. It is common practice to use the @code{tbreak} command
10482 in conjunction with @code{jump}. @xref{Set Breaks, ,Setting
10485 The @code{jump} command does not change the current stack frame, or
10486 the stack pointer, or the contents of any memory location or any
10487 register other than the program counter. If line @var{linespec} is in
10488 a different function from the one currently executing, the results may
10489 be bizarre if the two functions expect different patterns of arguments or
10490 of local variables. For this reason, the @code{jump} command requests
10491 confirmation if the specified line is not in the function currently
10492 executing. However, even bizarre results are predictable if you are
10493 well acquainted with the machine-language code of your program.
10495 @item jump *@var{address}
10496 Resume execution at the instruction at address @var{address}.
10499 @c Doesn't work on HP-UX; have to set $pcoqh and $pcoqt.
10500 On many systems, you can get much the same effect as the @code{jump}
10501 command by storing a new value into the register @code{$pc}. The
10502 difference is that this does not start your program running; it only
10503 changes the address of where it @emph{will} run when you continue. For
10511 makes the next @code{continue} command or stepping command execute at
10512 address @code{0x485}, rather than at the address where your program stopped.
10513 @xref{Continuing and Stepping, ,Continuing and stepping}.
10515 The most common occasion to use the @code{jump} command is to back
10516 up---perhaps with more breakpoints set---over a portion of a program
10517 that has already executed, in order to examine its execution in more
10522 @section Giving your program a signal
10523 @cindex deliver a signal to a program
10527 @item signal @var{signal}
10528 Resume execution where your program stopped, but immediately give it the
10529 signal @var{signal}. @var{signal} can be the name or the number of a
10530 signal. For example, on many systems @code{signal 2} and @code{signal
10531 SIGINT} are both ways of sending an interrupt signal.
10533 Alternatively, if @var{signal} is zero, continue execution without
10534 giving a signal. This is useful when your program stopped on account of
10535 a signal and would ordinary see the signal when resumed with the
10536 @code{continue} command; @samp{signal 0} causes it to resume without a
10539 @code{signal} does not repeat when you press @key{RET} a second time
10540 after executing the command.
10544 Invoking the @code{signal} command is not the same as invoking the
10545 @code{kill} utility from the shell. Sending a signal with @code{kill}
10546 causes @value{GDBN} to decide what to do with the signal depending on
10547 the signal handling tables (@pxref{Signals}). The @code{signal} command
10548 passes the signal directly to your program.
10552 @section Returning from a function
10555 @cindex returning from a function
10558 @itemx return @var{expression}
10559 You can cancel execution of a function call with the @code{return}
10560 command. If you give an
10561 @var{expression} argument, its value is used as the function's return
10565 When you use @code{return}, @value{GDBN} discards the selected stack frame
10566 (and all frames within it). You can think of this as making the
10567 discarded frame return prematurely. If you wish to specify a value to
10568 be returned, give that value as the argument to @code{return}.
10570 This pops the selected stack frame (@pxref{Selection, ,Selecting a
10571 frame}), and any other frames inside of it, leaving its caller as the
10572 innermost remaining frame. That frame becomes selected. The
10573 specified value is stored in the registers used for returning values
10576 The @code{return} command does not resume execution; it leaves the
10577 program stopped in the state that would exist if the function had just
10578 returned. In contrast, the @code{finish} command (@pxref{Continuing
10579 and Stepping, ,Continuing and stepping}) resumes execution until the
10580 selected stack frame returns naturally.
10583 @section Calling program functions
10586 @cindex calling functions
10587 @cindex inferior functions, calling
10588 @item print @var{expr}
10589 Evaluate the expression @var{expr} and display the resuling value.
10590 @var{expr} may include calls to functions in the program being
10594 @item call @var{expr}
10595 Evaluate the expression @var{expr} without displaying @code{void}
10598 You can use this variant of the @code{print} command if you want to
10599 execute a function from your program that does not return anything
10600 (a.k.a.@: @dfn{a void function}), but without cluttering the output
10601 with @code{void} returned values that @value{GDBN} will otherwise
10602 print. If the result is not void, it is printed and saved in the
10606 It is possible for the function you call via the @code{print} or
10607 @code{call} command to generate a signal (e.g., if there's a bug in
10608 the function, or if you passed it incorrect arguments). What happens
10609 in that case is controlled by the @code{set unwindonsignal} command.
10612 @item set unwindonsignal
10613 @kindex set unwindonsignal
10614 @cindex unwind stack in called functions
10615 @cindex call dummy stack unwinding
10616 Set unwinding of the stack if a signal is received while in a function
10617 that @value{GDBN} called in the program being debugged. If set to on,
10618 @value{GDBN} unwinds the stack it created for the call and restores
10619 the context to what it was before the call. If set to off (the
10620 default), @value{GDBN} stops in the frame where the signal was
10623 @item show unwindonsignal
10624 @kindex show unwindonsignal
10625 Show the current setting of stack unwinding in the functions called by
10629 @cindex weak alias functions
10630 Sometimes, a function you wish to call is actually a @dfn{weak alias}
10631 for another function. In such case, @value{GDBN} might not pick up
10632 the type information, including the types of the function arguments,
10633 which causes @value{GDBN} to call the inferior function incorrectly.
10634 As a result, the called function will function erroneously and may
10635 even crash. A solution to that is to use the name of the aliased
10639 @section Patching programs
10641 @cindex patching binaries
10642 @cindex writing into executables
10643 @cindex writing into corefiles
10645 By default, @value{GDBN} opens the file containing your program's
10646 executable code (or the corefile) read-only. This prevents accidental
10647 alterations to machine code; but it also prevents you from intentionally
10648 patching your program's binary.
10650 If you'd like to be able to patch the binary, you can specify that
10651 explicitly with the @code{set write} command. For example, you might
10652 want to turn on internal debugging flags, or even to make emergency
10658 @itemx set write off
10659 If you specify @samp{set write on}, @value{GDBN} opens executable and
10660 core files for both reading and writing; if you specify @samp{set write
10661 off} (the default), @value{GDBN} opens them read-only.
10663 If you have already loaded a file, you must load it again (using the
10664 @code{exec-file} or @code{core-file} command) after changing @code{set
10665 write}, for your new setting to take effect.
10669 Display whether executable files and core files are opened for writing
10670 as well as reading.
10674 @chapter @value{GDBN} Files
10676 @value{GDBN} needs to know the file name of the program to be debugged,
10677 both in order to read its symbol table and in order to start your
10678 program. To debug a core dump of a previous run, you must also tell
10679 @value{GDBN} the name of the core dump file.
10682 * Files:: Commands to specify files
10683 * Separate Debug Files:: Debugging information in separate files
10684 * Symbol Errors:: Errors reading symbol files
10688 @section Commands to specify files
10690 @cindex symbol table
10691 @cindex core dump file
10693 You may want to specify executable and core dump file names. The usual
10694 way to do this is at start-up time, using the arguments to
10695 @value{GDBN}'s start-up commands (@pxref{Invocation, , Getting In and
10696 Out of @value{GDBN}}).
10698 Occasionally it is necessary to change to a different file during a
10699 @value{GDBN} session. Or you may run @value{GDBN} and forget to
10700 specify a file you want to use. Or you are debugging a remote target
10701 via @code{gdbserver} (@pxref{Server, file}). In these situations the
10702 @value{GDBN} commands to specify new files are useful.
10705 @cindex executable file
10707 @item file @var{filename}
10708 Use @var{filename} as the program to be debugged. It is read for its
10709 symbols and for the contents of pure memory. It is also the program
10710 executed when you use the @code{run} command. If you do not specify a
10711 directory and the file is not found in the @value{GDBN} working directory,
10712 @value{GDBN} uses the environment variable @code{PATH} as a list of
10713 directories to search, just as the shell does when looking for a program
10714 to run. You can change the value of this variable, for both @value{GDBN}
10715 and your program, using the @code{path} command.
10717 @cindex unlinked object files
10718 @cindex patching object files
10719 You can load unlinked object @file{.o} files into @value{GDBN} using
10720 the @code{file} command. You will not be able to ``run'' an object
10721 file, but you can disassemble functions and inspect variables. Also,
10722 if the underlying BFD functionality supports it, you could use
10723 @kbd{gdb -write} to patch object files using this technique. Note
10724 that @value{GDBN} can neither interpret nor modify relocations in this
10725 case, so branches and some initialized variables will appear to go to
10726 the wrong place. But this feature is still handy from time to time.
10729 @code{file} with no argument makes @value{GDBN} discard any information it
10730 has on both executable file and the symbol table.
10733 @item exec-file @r{[} @var{filename} @r{]}
10734 Specify that the program to be run (but not the symbol table) is found
10735 in @var{filename}. @value{GDBN} searches the environment variable @code{PATH}
10736 if necessary to locate your program. Omitting @var{filename} means to
10737 discard information on the executable file.
10739 @kindex symbol-file
10740 @item symbol-file @r{[} @var{filename} @r{]}
10741 Read symbol table information from file @var{filename}. @code{PATH} is
10742 searched when necessary. Use the @code{file} command to get both symbol
10743 table and program to run from the same file.
10745 @code{symbol-file} with no argument clears out @value{GDBN} information on your
10746 program's symbol table.
10748 The @code{symbol-file} command causes @value{GDBN} to forget the contents
10749 of its convenience variables, the value history, and all breakpoints and
10750 auto-display expressions. This is because they may contain pointers to
10751 the internal data recording symbols and data types, which are part of
10752 the old symbol table data being discarded inside @value{GDBN}.
10754 @code{symbol-file} does not repeat if you press @key{RET} again after
10757 When @value{GDBN} is configured for a particular environment, it
10758 understands debugging information in whatever format is the standard
10759 generated for that environment; you may use either a @sc{gnu} compiler, or
10760 other compilers that adhere to the local conventions.
10761 Best results are usually obtained from @sc{gnu} compilers; for example,
10762 using @code{@value{GCC}} you can generate debugging information for
10765 For most kinds of object files, with the exception of old SVR3 systems
10766 using COFF, the @code{symbol-file} command does not normally read the
10767 symbol table in full right away. Instead, it scans the symbol table
10768 quickly to find which source files and which symbols are present. The
10769 details are read later, one source file at a time, as they are needed.
10771 The purpose of this two-stage reading strategy is to make @value{GDBN}
10772 start up faster. For the most part, it is invisible except for
10773 occasional pauses while the symbol table details for a particular source
10774 file are being read. (The @code{set verbose} command can turn these
10775 pauses into messages if desired. @xref{Messages/Warnings, ,Optional
10776 warnings and messages}.)
10778 We have not implemented the two-stage strategy for COFF yet. When the
10779 symbol table is stored in COFF format, @code{symbol-file} reads the
10780 symbol table data in full right away. Note that ``stabs-in-COFF''
10781 still does the two-stage strategy, since the debug info is actually
10785 @cindex reading symbols immediately
10786 @cindex symbols, reading immediately
10787 @item symbol-file @var{filename} @r{[} -readnow @r{]}
10788 @itemx file @var{filename} @r{[} -readnow @r{]}
10789 You can override the @value{GDBN} two-stage strategy for reading symbol
10790 tables by using the @samp{-readnow} option with any of the commands that
10791 load symbol table information, if you want to be sure @value{GDBN} has the
10792 entire symbol table available.
10794 @c FIXME: for now no mention of directories, since this seems to be in
10795 @c flux. 13mar1992 status is that in theory GDB would look either in
10796 @c current dir or in same dir as myprog; but issues like competing
10797 @c GDB's, or clutter in system dirs, mean that in practice right now
10798 @c only current dir is used. FFish says maybe a special GDB hierarchy
10799 @c (eg rooted in val of env var GDBSYMS) could exist for mappable symbol
10803 @item core-file @r{[}@var{filename}@r{]}
10805 Specify the whereabouts of a core dump file to be used as the ``contents
10806 of memory''. Traditionally, core files contain only some parts of the
10807 address space of the process that generated them; @value{GDBN} can access the
10808 executable file itself for other parts.
10810 @code{core-file} with no argument specifies that no core file is
10813 Note that the core file is ignored when your program is actually running
10814 under @value{GDBN}. So, if you have been running your program and you
10815 wish to debug a core file instead, you must kill the subprocess in which
10816 the program is running. To do this, use the @code{kill} command
10817 (@pxref{Kill Process, ,Killing the child process}).
10819 @kindex add-symbol-file
10820 @cindex dynamic linking
10821 @item add-symbol-file @var{filename} @var{address}
10822 @itemx add-symbol-file @var{filename} @var{address} @r{[} -readnow @r{]}
10823 @itemx add-symbol-file @var{filename} @r{-s}@var{section} @var{address} @dots{}
10824 The @code{add-symbol-file} command reads additional symbol table
10825 information from the file @var{filename}. You would use this command
10826 when @var{filename} has been dynamically loaded (by some other means)
10827 into the program that is running. @var{address} should be the memory
10828 address at which the file has been loaded; @value{GDBN} cannot figure
10829 this out for itself. You can additionally specify an arbitrary number
10830 of @samp{@r{-s}@var{section} @var{address}} pairs, to give an explicit
10831 section name and base address for that section. You can specify any
10832 @var{address} as an expression.
10834 The symbol table of the file @var{filename} is added to the symbol table
10835 originally read with the @code{symbol-file} command. You can use the
10836 @code{add-symbol-file} command any number of times; the new symbol data
10837 thus read keeps adding to the old. To discard all old symbol data
10838 instead, use the @code{symbol-file} command without any arguments.
10840 @cindex relocatable object files, reading symbols from
10841 @cindex object files, relocatable, reading symbols from
10842 @cindex reading symbols from relocatable object files
10843 @cindex symbols, reading from relocatable object files
10844 @cindex @file{.o} files, reading symbols from
10845 Although @var{filename} is typically a shared library file, an
10846 executable file, or some other object file which has been fully
10847 relocated for loading into a process, you can also load symbolic
10848 information from relocatable @file{.o} files, as long as:
10852 the file's symbolic information refers only to linker symbols defined in
10853 that file, not to symbols defined by other object files,
10855 every section the file's symbolic information refers to has actually
10856 been loaded into the inferior, as it appears in the file, and
10858 you can determine the address at which every section was loaded, and
10859 provide these to the @code{add-symbol-file} command.
10863 Some embedded operating systems, like Sun Chorus and VxWorks, can load
10864 relocatable files into an already running program; such systems
10865 typically make the requirements above easy to meet. However, it's
10866 important to recognize that many native systems use complex link
10867 procedures (@code{.linkonce} section factoring and C@t{++} constructor table
10868 assembly, for example) that make the requirements difficult to meet. In
10869 general, one cannot assume that using @code{add-symbol-file} to read a
10870 relocatable object file's symbolic information will have the same effect
10871 as linking the relocatable object file into the program in the normal
10874 @code{add-symbol-file} does not repeat if you press @key{RET} after using it.
10876 @kindex add-symbol-file-from-memory
10877 @cindex @code{syscall DSO}
10878 @cindex load symbols from memory
10879 @item add-symbol-file-from-memory @var{address}
10880 Load symbols from the given @var{address} in a dynamically loaded
10881 object file whose image is mapped directly into the inferior's memory.
10882 For example, the Linux kernel maps a @code{syscall DSO} into each
10883 process's address space; this DSO provides kernel-specific code for
10884 some system calls. The argument can be any expression whose
10885 evaluation yields the address of the file's shared object file header.
10886 For this command to work, you must have used @code{symbol-file} or
10887 @code{exec-file} commands in advance.
10889 @kindex add-shared-symbol-files
10891 @item add-shared-symbol-files @var{library-file}
10892 @itemx assf @var{library-file}
10893 The @code{add-shared-symbol-files} command can currently be used only
10894 in the Cygwin build of @value{GDBN} on MS-Windows OS, where it is an
10895 alias for the @code{dll-symbols} command (@pxref{Cygwin Native}).
10896 @value{GDBN} automatically looks for shared libraries, however if
10897 @value{GDBN} does not find yours, you can invoke
10898 @code{add-shared-symbol-files}. It takes one argument: the shared
10899 library's file name. @code{assf} is a shorthand alias for
10900 @code{add-shared-symbol-files}.
10903 @item section @var{section} @var{addr}
10904 The @code{section} command changes the base address of the named
10905 @var{section} of the exec file to @var{addr}. This can be used if the
10906 exec file does not contain section addresses, (such as in the
10907 @code{a.out} format), or when the addresses specified in the file
10908 itself are wrong. Each section must be changed separately. The
10909 @code{info files} command, described below, lists all the sections and
10913 @kindex info target
10916 @code{info files} and @code{info target} are synonymous; both print the
10917 current target (@pxref{Targets, ,Specifying a Debugging Target}),
10918 including the names of the executable and core dump files currently in
10919 use by @value{GDBN}, and the files from which symbols were loaded. The
10920 command @code{help target} lists all possible targets rather than
10923 @kindex maint info sections
10924 @item maint info sections
10925 Another command that can give you extra information about program sections
10926 is @code{maint info sections}. In addition to the section information
10927 displayed by @code{info files}, this command displays the flags and file
10928 offset of each section in the executable and core dump files. In addition,
10929 @code{maint info sections} provides the following command options (which
10930 may be arbitrarily combined):
10934 Display sections for all loaded object files, including shared libraries.
10935 @item @var{sections}
10936 Display info only for named @var{sections}.
10937 @item @var{section-flags}
10938 Display info only for sections for which @var{section-flags} are true.
10939 The section flags that @value{GDBN} currently knows about are:
10942 Section will have space allocated in the process when loaded.
10943 Set for all sections except those containing debug information.
10945 Section will be loaded from the file into the child process memory.
10946 Set for pre-initialized code and data, clear for @code{.bss} sections.
10948 Section needs to be relocated before loading.
10950 Section cannot be modified by the child process.
10952 Section contains executable code only.
10954 Section contains data only (no executable code).
10956 Section will reside in ROM.
10958 Section contains data for constructor/destructor lists.
10960 Section is not empty.
10962 An instruction to the linker to not output the section.
10963 @item COFF_SHARED_LIBRARY
10964 A notification to the linker that the section contains
10965 COFF shared library information.
10967 Section contains common symbols.
10970 @kindex set trust-readonly-sections
10971 @cindex read-only sections
10972 @item set trust-readonly-sections on
10973 Tell @value{GDBN} that readonly sections in your object file
10974 really are read-only (i.e.@: that their contents will not change).
10975 In that case, @value{GDBN} can fetch values from these sections
10976 out of the object file, rather than from the target program.
10977 For some targets (notably embedded ones), this can be a significant
10978 enhancement to debugging performance.
10980 The default is off.
10982 @item set trust-readonly-sections off
10983 Tell @value{GDBN} not to trust readonly sections. This means that
10984 the contents of the section might change while the program is running,
10985 and must therefore be fetched from the target when needed.
10987 @item show trust-readonly-sections
10988 Show the current setting of trusting readonly sections.
10991 All file-specifying commands allow both absolute and relative file names
10992 as arguments. @value{GDBN} always converts the file name to an absolute file
10993 name and remembers it that way.
10995 @cindex shared libraries
10996 @value{GDBN} supports GNU/Linux, MS-Windows, HP-UX, SunOS, SVr4, Irix,
10997 and IBM RS/6000 AIX shared libraries.
10999 @value{GDBN} automatically loads symbol definitions from shared libraries
11000 when you use the @code{run} command, or when you examine a core file.
11001 (Before you issue the @code{run} command, @value{GDBN} does not understand
11002 references to a function in a shared library, however---unless you are
11003 debugging a core file).
11005 On HP-UX, if the program loads a library explicitly, @value{GDBN}
11006 automatically loads the symbols at the time of the @code{shl_load} call.
11008 @c FIXME: some @value{GDBN} release may permit some refs to undef
11009 @c FIXME...symbols---eg in a break cmd---assuming they are from a shared
11010 @c FIXME...lib; check this from time to time when updating manual
11012 There are times, however, when you may wish to not automatically load
11013 symbol definitions from shared libraries, such as when they are
11014 particularly large or there are many of them.
11016 To control the automatic loading of shared library symbols, use the
11020 @kindex set auto-solib-add
11021 @item set auto-solib-add @var{mode}
11022 If @var{mode} is @code{on}, symbols from all shared object libraries
11023 will be loaded automatically when the inferior begins execution, you
11024 attach to an independently started inferior, or when the dynamic linker
11025 informs @value{GDBN} that a new library has been loaded. If @var{mode}
11026 is @code{off}, symbols must be loaded manually, using the
11027 @code{sharedlibrary} command. The default value is @code{on}.
11029 @cindex memory used for symbol tables
11030 If your program uses lots of shared libraries with debug info that
11031 takes large amounts of memory, you can decrease the @value{GDBN}
11032 memory footprint by preventing it from automatically loading the
11033 symbols from shared libraries. To that end, type @kbd{set
11034 auto-solib-add off} before running the inferior, then load each
11035 library whose debug symbols you do need with @kbd{sharedlibrary
11036 @var{regexp}}, where @var{regexp} is a regular expresion that matches
11037 the libraries whose symbols you want to be loaded.
11039 @kindex show auto-solib-add
11040 @item show auto-solib-add
11041 Display the current autoloading mode.
11044 @cindex load shared library
11045 To explicitly load shared library symbols, use the @code{sharedlibrary}
11049 @kindex info sharedlibrary
11052 @itemx info sharedlibrary
11053 Print the names of the shared libraries which are currently loaded.
11055 @kindex sharedlibrary
11057 @item sharedlibrary @var{regex}
11058 @itemx share @var{regex}
11059 Load shared object library symbols for files matching a
11060 Unix regular expression.
11061 As with files loaded automatically, it only loads shared libraries
11062 required by your program for a core file or after typing @code{run}. If
11063 @var{regex} is omitted all shared libraries required by your program are
11066 @item nosharedlibrary
11067 @kindex nosharedlibrary
11068 @cindex unload symbols from shared libraries
11069 Unload all shared object library symbols. This discards all symbols
11070 that have been loaded from all shared libraries. Symbols from shared
11071 libraries that were loaded by explicit user requests are not
11075 Sometimes you may wish that @value{GDBN} stops and gives you control
11076 when any of shared library events happen. Use the @code{set
11077 stop-on-solib-events} command for this:
11080 @item set stop-on-solib-events
11081 @kindex set stop-on-solib-events
11082 This command controls whether @value{GDBN} should give you control
11083 when the dynamic linker notifies it about some shared library event.
11084 The most common event of interest is loading or unloading of a new
11087 @item show stop-on-solib-events
11088 @kindex show stop-on-solib-events
11089 Show whether @value{GDBN} stops and gives you control when shared
11090 library events happen.
11093 Shared libraries are also supported in many cross or remote debugging
11094 configurations. A copy of the target's libraries need to be present on the
11095 host system; they need to be the same as the target libraries, although the
11096 copies on the target can be stripped as long as the copies on the host are
11099 @cindex where to look for shared libraries
11100 For remote debugging, you need to tell @value{GDBN} where the target
11101 libraries are, so that it can load the correct copies---otherwise, it
11102 may try to load the host's libraries. @value{GDBN} has two variables
11103 to specify the search directories for target libraries.
11106 @cindex prefix for shared library file names
11107 @kindex set solib-absolute-prefix
11108 @item set solib-absolute-prefix @var{path}
11109 If this variable is set, @var{path} will be used as a prefix for any
11110 absolute shared library paths; many runtime loaders store the absolute
11111 paths to the shared library in the target program's memory. If you use
11112 @samp{solib-absolute-prefix} to find shared libraries, they need to be laid
11113 out in the same way that they are on the target, with e.g.@: a
11114 @file{/usr/lib} hierarchy under @var{path}.
11116 @cindex default value of @samp{solib-absolute-prefix}
11117 @cindex @samp{--with-sysroot}
11118 You can set the default value of @samp{solib-absolute-prefix} by using the
11119 configure-time @samp{--with-sysroot} option.
11121 @kindex show solib-absolute-prefix
11122 @item show solib-absolute-prefix
11123 Display the current shared library prefix.
11125 @kindex set solib-search-path
11126 @item set solib-search-path @var{path}
11127 If this variable is set, @var{path} is a colon-separated list of directories
11128 to search for shared libraries. @samp{solib-search-path} is used after
11129 @samp{solib-absolute-prefix} fails to locate the library, or if the path to
11130 the library is relative instead of absolute. If you want to use
11131 @samp{solib-search-path} instead of @samp{solib-absolute-prefix}, be sure to
11132 set @samp{solib-absolute-prefix} to a nonexistant directory to prevent
11133 @value{GDBN} from finding your host's libraries.
11135 @kindex show solib-search-path
11136 @item show solib-search-path
11137 Display the current shared library search path.
11141 @node Separate Debug Files
11142 @section Debugging Information in Separate Files
11143 @cindex separate debugging information files
11144 @cindex debugging information in separate files
11145 @cindex @file{.debug} subdirectories
11146 @cindex debugging information directory, global
11147 @cindex global debugging information directory
11149 @value{GDBN} allows you to put a program's debugging information in a
11150 file separate from the executable itself, in a way that allows
11151 @value{GDBN} to find and load the debugging information automatically.
11152 Since debugging information can be very large --- sometimes larger
11153 than the executable code itself --- some systems distribute debugging
11154 information for their executables in separate files, which users can
11155 install only when they need to debug a problem.
11157 If an executable's debugging information has been extracted to a
11158 separate file, the executable should contain a @dfn{debug link} giving
11159 the name of the debugging information file (with no directory
11160 components), and a checksum of its contents. (The exact form of a
11161 debug link is described below.) If the full name of the directory
11162 containing the executable is @var{execdir}, and the executable has a
11163 debug link that specifies the name @var{debugfile}, then @value{GDBN}
11164 will automatically search for the debugging information file in three
11169 the directory containing the executable file (that is, it will look
11170 for a file named @file{@var{execdir}/@var{debugfile}},
11172 a subdirectory of that directory named @file{.debug} (that is, the
11173 file @file{@var{execdir}/.debug/@var{debugfile}}, and
11175 a subdirectory of the global debug file directory that includes the
11176 executable's full path, and the name from the link (that is, the file
11177 @file{@var{globaldebugdir}/@var{execdir}/@var{debugfile}}, where
11178 @var{globaldebugdir} is the global debug file directory, and
11179 @var{execdir} has been turned into a relative path).
11182 @value{GDBN} checks under each of these names for a debugging
11183 information file whose checksum matches that given in the link, and
11184 reads the debugging information from the first one it finds.
11186 So, for example, if you ask @value{GDBN} to debug @file{/usr/bin/ls},
11187 which has a link containing the name @file{ls.debug}, and the global
11188 debug directory is @file{/usr/lib/debug}, then @value{GDBN} will look
11189 for debug information in @file{/usr/bin/ls.debug},
11190 @file{/usr/bin/.debug/ls.debug}, and
11191 @file{/usr/lib/debug/usr/bin/ls.debug}.
11193 You can set the global debugging info directory's name, and view the
11194 name @value{GDBN} is currently using.
11198 @kindex set debug-file-directory
11199 @item set debug-file-directory @var{directory}
11200 Set the directory which @value{GDBN} searches for separate debugging
11201 information files to @var{directory}.
11203 @kindex show debug-file-directory
11204 @item show debug-file-directory
11205 Show the directory @value{GDBN} searches for separate debugging
11210 @cindex @code{.gnu_debuglink} sections
11211 @cindex debug links
11212 A debug link is a special section of the executable file named
11213 @code{.gnu_debuglink}. The section must contain:
11217 A filename, with any leading directory components removed, followed by
11220 zero to three bytes of padding, as needed to reach the next four-byte
11221 boundary within the section, and
11223 a four-byte CRC checksum, stored in the same endianness used for the
11224 executable file itself. The checksum is computed on the debugging
11225 information file's full contents by the function given below, passing
11226 zero as the @var{crc} argument.
11229 Any executable file format can carry a debug link, as long as it can
11230 contain a section named @code{.gnu_debuglink} with the contents
11233 The debugging information file itself should be an ordinary
11234 executable, containing a full set of linker symbols, sections, and
11235 debugging information. The sections of the debugging information file
11236 should have the same names, addresses and sizes as the original file,
11237 but they need not contain any data --- much like a @code{.bss} section
11238 in an ordinary executable.
11240 As of December 2002, there is no standard GNU utility to produce
11241 separated executable / debugging information file pairs. Ulrich
11242 Drepper's @file{elfutils} package, starting with version 0.53,
11243 contains a version of the @code{strip} command such that the command
11244 @kbd{strip foo -f foo.debug} removes the debugging information from
11245 the executable file @file{foo}, places it in the file
11246 @file{foo.debug}, and leaves behind a debug link in @file{foo}.
11248 Since there are many different ways to compute CRC's (different
11249 polynomials, reversals, byte ordering, etc.), the simplest way to
11250 describe the CRC used in @code{.gnu_debuglink} sections is to give the
11251 complete code for a function that computes it:
11253 @kindex gnu_debuglink_crc32
11256 gnu_debuglink_crc32 (unsigned long crc,
11257 unsigned char *buf, size_t len)
11259 static const unsigned long crc32_table[256] =
11261 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
11262 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4,
11263 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07,
11264 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
11265 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856,
11266 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
11267 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4,
11268 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
11269 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3,
11270 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a,
11271 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599,
11272 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
11273 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190,
11274 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f,
11275 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e,
11276 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
11277 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed,
11278 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
11279 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3,
11280 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
11281 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a,
11282 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5,
11283 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010,
11284 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
11285 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17,
11286 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6,
11287 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615,
11288 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
11289 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344,
11290 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
11291 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a,
11292 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
11293 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1,
11294 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c,
11295 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef,
11296 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
11297 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe,
11298 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31,
11299 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c,
11300 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
11301 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b,
11302 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
11303 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1,
11304 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
11305 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278,
11306 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7,
11307 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66,
11308 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
11309 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605,
11310 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8,
11311 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b,
11314 unsigned char *end;
11316 crc = ~crc & 0xffffffff;
11317 for (end = buf + len; buf < end; ++buf)
11318 crc = crc32_table[(crc ^ *buf) & 0xff] ^ (crc >> 8);
11319 return ~crc & 0xffffffff;
11324 @node Symbol Errors
11325 @section Errors reading symbol files
11327 While reading a symbol file, @value{GDBN} occasionally encounters problems,
11328 such as symbol types it does not recognize, or known bugs in compiler
11329 output. By default, @value{GDBN} does not notify you of such problems, since
11330 they are relatively common and primarily of interest to people
11331 debugging compilers. If you are interested in seeing information
11332 about ill-constructed symbol tables, you can either ask @value{GDBN} to print
11333 only one message about each such type of problem, no matter how many
11334 times the problem occurs; or you can ask @value{GDBN} to print more messages,
11335 to see how many times the problems occur, with the @code{set
11336 complaints} command (@pxref{Messages/Warnings, ,Optional warnings and
11339 The messages currently printed, and their meanings, include:
11342 @item inner block not inside outer block in @var{symbol}
11344 The symbol information shows where symbol scopes begin and end
11345 (such as at the start of a function or a block of statements). This
11346 error indicates that an inner scope block is not fully contained
11347 in its outer scope blocks.
11349 @value{GDBN} circumvents the problem by treating the inner block as if it had
11350 the same scope as the outer block. In the error message, @var{symbol}
11351 may be shown as ``@code{(don't know)}'' if the outer block is not a
11354 @item block at @var{address} out of order
11356 The symbol information for symbol scope blocks should occur in
11357 order of increasing addresses. This error indicates that it does not
11360 @value{GDBN} does not circumvent this problem, and has trouble
11361 locating symbols in the source file whose symbols it is reading. (You
11362 can often determine what source file is affected by specifying
11363 @code{set verbose on}. @xref{Messages/Warnings, ,Optional warnings and
11366 @item bad block start address patched
11368 The symbol information for a symbol scope block has a start address
11369 smaller than the address of the preceding source line. This is known
11370 to occur in the SunOS 4.1.1 (and earlier) C compiler.
11372 @value{GDBN} circumvents the problem by treating the symbol scope block as
11373 starting on the previous source line.
11375 @item bad string table offset in symbol @var{n}
11378 Symbol number @var{n} contains a pointer into the string table which is
11379 larger than the size of the string table.
11381 @value{GDBN} circumvents the problem by considering the symbol to have the
11382 name @code{foo}, which may cause other problems if many symbols end up
11385 @item unknown symbol type @code{0x@var{nn}}
11387 The symbol information contains new data types that @value{GDBN} does
11388 not yet know how to read. @code{0x@var{nn}} is the symbol type of the
11389 uncomprehended information, in hexadecimal.
11391 @value{GDBN} circumvents the error by ignoring this symbol information.
11392 This usually allows you to debug your program, though certain symbols
11393 are not accessible. If you encounter such a problem and feel like
11394 debugging it, you can debug @code{@value{GDBP}} with itself, breakpoint
11395 on @code{complain}, then go up to the function @code{read_dbx_symtab}
11396 and examine @code{*bufp} to see the symbol.
11398 @item stub type has NULL name
11400 @value{GDBN} could not find the full definition for a struct or class.
11402 @item const/volatile indicator missing (ok if using g++ v1.x), got@dots{}
11403 The symbol information for a C@t{++} member function is missing some
11404 information that recent versions of the compiler should have output for
11407 @item info mismatch between compiler and debugger
11409 @value{GDBN} could not parse a type specification output by the compiler.
11414 @chapter Specifying a Debugging Target
11416 @cindex debugging target
11417 A @dfn{target} is the execution environment occupied by your program.
11419 Often, @value{GDBN} runs in the same host environment as your program;
11420 in that case, the debugging target is specified as a side effect when
11421 you use the @code{file} or @code{core} commands. When you need more
11422 flexibility---for example, running @value{GDBN} on a physically separate
11423 host, or controlling a standalone system over a serial port or a
11424 realtime system over a TCP/IP connection---you can use the @code{target}
11425 command to specify one of the target types configured for @value{GDBN}
11426 (@pxref{Target Commands, ,Commands for managing targets}).
11428 @cindex target architecture
11429 It is possible to build @value{GDBN} for several different @dfn{target
11430 architectures}. When @value{GDBN} is built like that, you can choose
11431 one of the available architectures with the @kbd{set architecture}
11435 @kindex set architecture
11436 @kindex show architecture
11437 @item set architecture @var{arch}
11438 This command sets the current target architecture to @var{arch}. The
11439 value of @var{arch} can be @code{"auto"}, in addition to one of the
11440 supported architectures.
11442 @item show architecture
11443 Show the current target architecture.
11445 @item set processor
11447 @kindex set processor
11448 @kindex show processor
11449 These are alias commands for, respectively, @code{set architecture}
11450 and @code{show architecture}.
11454 * Active Targets:: Active targets
11455 * Target Commands:: Commands for managing targets
11456 * Byte Order:: Choosing target byte order
11457 * Remote:: Remote debugging
11458 * KOD:: Kernel Object Display
11462 @node Active Targets
11463 @section Active targets
11465 @cindex stacking targets
11466 @cindex active targets
11467 @cindex multiple targets
11469 There are three classes of targets: processes, core files, and
11470 executable files. @value{GDBN} can work concurrently on up to three
11471 active targets, one in each class. This allows you to (for example)
11472 start a process and inspect its activity without abandoning your work on
11475 For example, if you execute @samp{gdb a.out}, then the executable file
11476 @code{a.out} is the only active target. If you designate a core file as
11477 well---presumably from a prior run that crashed and coredumped---then
11478 @value{GDBN} has two active targets and uses them in tandem, looking
11479 first in the corefile target, then in the executable file, to satisfy
11480 requests for memory addresses. (Typically, these two classes of target
11481 are complementary, since core files contain only a program's
11482 read-write memory---variables and so on---plus machine status, while
11483 executable files contain only the program text and initialized data.)
11485 When you type @code{run}, your executable file becomes an active process
11486 target as well. When a process target is active, all @value{GDBN}
11487 commands requesting memory addresses refer to that target; addresses in
11488 an active core file or executable file target are obscured while the
11489 process target is active.
11491 Use the @code{core-file} and @code{exec-file} commands to select a new
11492 core file or executable target (@pxref{Files, ,Commands to specify
11493 files}). To specify as a target a process that is already running, use
11494 the @code{attach} command (@pxref{Attach, ,Debugging an already-running
11497 @node Target Commands
11498 @section Commands for managing targets
11501 @item target @var{type} @var{parameters}
11502 Connects the @value{GDBN} host environment to a target machine or
11503 process. A target is typically a protocol for talking to debugging
11504 facilities. You use the argument @var{type} to specify the type or
11505 protocol of the target machine.
11507 Further @var{parameters} are interpreted by the target protocol, but
11508 typically include things like device names or host names to connect
11509 with, process numbers, and baud rates.
11511 The @code{target} command does not repeat if you press @key{RET} again
11512 after executing the command.
11514 @kindex help target
11516 Displays the names of all targets available. To display targets
11517 currently selected, use either @code{info target} or @code{info files}
11518 (@pxref{Files, ,Commands to specify files}).
11520 @item help target @var{name}
11521 Describe a particular target, including any parameters necessary to
11524 @kindex set gnutarget
11525 @item set gnutarget @var{args}
11526 @value{GDBN} uses its own library BFD to read your files. @value{GDBN}
11527 knows whether it is reading an @dfn{executable},
11528 a @dfn{core}, or a @dfn{.o} file; however, you can specify the file format
11529 with the @code{set gnutarget} command. Unlike most @code{target} commands,
11530 with @code{gnutarget} the @code{target} refers to a program, not a machine.
11533 @emph{Warning:} To specify a file format with @code{set gnutarget},
11534 you must know the actual BFD name.
11538 @xref{Files, , Commands to specify files}.
11540 @kindex show gnutarget
11541 @item show gnutarget
11542 Use the @code{show gnutarget} command to display what file format
11543 @code{gnutarget} is set to read. If you have not set @code{gnutarget},
11544 @value{GDBN} will determine the file format for each file automatically,
11545 and @code{show gnutarget} displays @samp{The current BDF target is "auto"}.
11548 @cindex common targets
11549 Here are some common targets (available, or not, depending on the GDB
11554 @item target exec @var{program}
11555 @cindex executable file target
11556 An executable file. @samp{target exec @var{program}} is the same as
11557 @samp{exec-file @var{program}}.
11559 @item target core @var{filename}
11560 @cindex core dump file target
11561 A core dump file. @samp{target core @var{filename}} is the same as
11562 @samp{core-file @var{filename}}.
11564 @item target remote @var{dev}
11565 @cindex remote target
11566 Remote serial target in GDB-specific protocol. The argument @var{dev}
11567 specifies what serial device to use for the connection (e.g.
11568 @file{/dev/ttya}). @xref{Remote, ,Remote debugging}. @code{target remote}
11569 supports the @code{load} command. This is only useful if you have
11570 some other way of getting the stub to the target system, and you can put
11571 it somewhere in memory where it won't get clobbered by the download.
11574 @cindex built-in simulator target
11575 Builtin CPU simulator. @value{GDBN} includes simulators for most architectures.
11583 works; however, you cannot assume that a specific memory map, device
11584 drivers, or even basic I/O is available, although some simulators do
11585 provide these. For info about any processor-specific simulator details,
11586 see the appropriate section in @ref{Embedded Processors, ,Embedded
11591 Some configurations may include these targets as well:
11595 @item target nrom @var{dev}
11596 @cindex NetROM ROM emulator target
11597 NetROM ROM emulator. This target only supports downloading.
11601 Different targets are available on different configurations of @value{GDBN};
11602 your configuration may have more or fewer targets.
11604 Many remote targets require you to download the executable's code once
11605 you've successfully established a connection. You may wish to control
11606 various aspects of this process, such as the size of the data chunks
11607 used by @value{GDBN} to download program parts to the remote target.
11610 @kindex set download-write-size
11611 @item set download-write-size @var{size}
11612 Set the write size used when downloading a program. Only used when
11613 downloading a program onto a remote target. Specify zero or a
11614 negative value to disable blocked writes. The actual size of each
11615 transfer is also limited by the size of the target packet and the
11618 @kindex show download-write-size
11619 @item show download-write-size
11620 @kindex show download-write-size
11621 Show the current value of the write size.
11624 @kindex set hash@r{, for remote monitors}
11625 @cindex hash mark while downloading
11626 This command controls whether a hash mark @samp{#} is displayed while
11627 downloading a file to the remote monitor. If on, a hash mark is
11628 displayed after each S-record is successfully downloaded to the
11632 @kindex show hash@r{, for remote monitors}
11633 Show the current status of displaying the hash mark.
11635 @item set debug monitor
11636 @kindex set debug monitor
11637 @cindex display remote monitor communications
11638 Enable or disable display of communications messages between
11639 @value{GDBN} and the remote monitor.
11641 @item show debug monitor
11642 @kindex show debug monitor
11643 Show the current status of displaying communications between
11644 @value{GDBN} and the remote monitor.
11649 @kindex load @var{filename}
11650 @item load @var{filename}
11651 Depending on what remote debugging facilities are configured into
11652 @value{GDBN}, the @code{load} command may be available. Where it exists, it
11653 is meant to make @var{filename} (an executable) available for debugging
11654 on the remote system---by downloading, or dynamic linking, for example.
11655 @code{load} also records the @var{filename} symbol table in @value{GDBN}, like
11656 the @code{add-symbol-file} command.
11658 If your @value{GDBN} does not have a @code{load} command, attempting to
11659 execute it gets the error message ``@code{You can't do that when your
11660 target is @dots{}}''
11662 The file is loaded at whatever address is specified in the executable.
11663 For some object file formats, you can specify the load address when you
11664 link the program; for other formats, like a.out, the object file format
11665 specifies a fixed address.
11666 @c FIXME! This would be a good place for an xref to the GNU linker doc.
11668 @code{load} does not repeat if you press @key{RET} again after using it.
11672 @section Choosing target byte order
11674 @cindex choosing target byte order
11675 @cindex target byte order
11677 Some types of processors, such as the MIPS, PowerPC, and Renesas SH,
11678 offer the ability to run either big-endian or little-endian byte
11679 orders. Usually the executable or symbol will include a bit to
11680 designate the endian-ness, and you will not need to worry about
11681 which to use. However, you may still find it useful to adjust
11682 @value{GDBN}'s idea of processor endian-ness manually.
11686 @item set endian big
11687 Instruct @value{GDBN} to assume the target is big-endian.
11689 @item set endian little
11690 Instruct @value{GDBN} to assume the target is little-endian.
11692 @item set endian auto
11693 Instruct @value{GDBN} to use the byte order associated with the
11697 Display @value{GDBN}'s current idea of the target byte order.
11701 Note that these commands merely adjust interpretation of symbolic
11702 data on the host, and that they have absolutely no effect on the
11706 @section Remote debugging
11707 @cindex remote debugging
11709 If you are trying to debug a program running on a machine that cannot run
11710 @value{GDBN} in the usual way, it is often useful to use remote debugging.
11711 For example, you might use remote debugging on an operating system kernel,
11712 or on a small system which does not have a general purpose operating system
11713 powerful enough to run a full-featured debugger.
11715 Some configurations of @value{GDBN} have special serial or TCP/IP interfaces
11716 to make this work with particular debugging targets. In addition,
11717 @value{GDBN} comes with a generic serial protocol (specific to @value{GDBN},
11718 but not specific to any particular target system) which you can use if you
11719 write the remote stubs---the code that runs on the remote system to
11720 communicate with @value{GDBN}.
11722 Other remote targets may be available in your
11723 configuration of @value{GDBN}; use @code{help target} to list them.
11725 Once you've connected to the remote target, @value{GDBN} allows you to
11726 send arbitrary commands to the remote monitor:
11729 @item remote @var{command}
11730 @kindex remote@r{, a command}
11731 @cindex send command to remote monitor
11732 Send an arbitrary @var{command} string to the remote monitor.
11737 @section Kernel Object Display
11738 @cindex kernel object display
11741 Some targets support kernel object display. Using this facility,
11742 @value{GDBN} communicates specially with the underlying operating system
11743 and can display information about operating system-level objects such as
11744 mutexes and other synchronization objects. Exactly which objects can be
11745 displayed is determined on a per-OS basis.
11748 Use the @code{set os} command to set the operating system. This tells
11749 @value{GDBN} which kernel object display module to initialize:
11752 (@value{GDBP}) set os cisco
11756 The associated command @code{show os} displays the operating system
11757 set with the @code{set os} command; if no operating system has been
11758 set, @code{show os} will display an empty string @samp{""}.
11760 If @code{set os} succeeds, @value{GDBN} will display some information
11761 about the operating system, and will create a new @code{info} command
11762 which can be used to query the target. The @code{info} command is named
11763 after the operating system:
11767 (@value{GDBP}) info cisco
11768 List of Cisco Kernel Objects
11770 any Any and all objects
11773 Further subcommands can be used to query about particular objects known
11776 There is currently no way to determine whether a given operating
11777 system is supported other than to try setting it with @kbd{set os
11778 @var{name}}, where @var{name} is the name of the operating system you
11782 @node Remote Debugging
11783 @chapter Debugging remote programs
11786 * Connecting:: Connecting to a remote target
11787 * Server:: Using the gdbserver program
11788 * NetWare:: Using the gdbserve.nlm program
11789 * Remote configuration:: Remote configuration
11790 * remote stub:: Implementing a remote stub
11794 @section Connecting to a remote target
11796 On the @value{GDBN} host machine, you will need an unstripped copy of
11797 your program, since @value{GDBN} needs symobl and debugging information.
11798 Start up @value{GDBN} as usual, using the name of the local copy of your
11799 program as the first argument.
11801 @cindex serial line, @code{target remote}
11802 If you're using a serial line, you may want to give @value{GDBN} the
11803 @w{@samp{--baud}} option, or use the @code{set remotebaud} command
11804 (@pxref{Remote configuration, set remotebaud}) before the
11805 @code{target} command.
11807 After that, use @code{target remote} to establish communications with
11808 the target machine. Its argument specifies how to communicate---either
11809 via a devicename attached to a direct serial line, or a TCP or UDP port
11810 (possibly to a terminal server which in turn has a serial line to the
11811 target). For example, to use a serial line connected to the device
11812 named @file{/dev/ttyb}:
11815 target remote /dev/ttyb
11818 @cindex TCP port, @code{target remote}
11819 To use a TCP connection, use an argument of the form
11820 @code{@var{host}:@var{port}} or @code{tcp:@var{host}:@var{port}}.
11821 For example, to connect to port 2828 on a
11822 terminal server named @code{manyfarms}:
11825 target remote manyfarms:2828
11828 If your remote target is actually running on the same machine as
11829 your debugger session (e.g.@: a simulator of your target running on
11830 the same host), you can omit the hostname. For example, to connect
11831 to port 1234 on your local machine:
11834 target remote :1234
11838 Note that the colon is still required here.
11840 @cindex UDP port, @code{target remote}
11841 To use a UDP connection, use an argument of the form
11842 @code{udp:@var{host}:@var{port}}. For example, to connect to UDP port 2828
11843 on a terminal server named @code{manyfarms}:
11846 target remote udp:manyfarms:2828
11849 When using a UDP connection for remote debugging, you should keep in mind
11850 that the `U' stands for ``Unreliable''. UDP can silently drop packets on
11851 busy or unreliable networks, which will cause havoc with your debugging
11854 Now you can use all the usual commands to examine and change data and to
11855 step and continue the remote program.
11857 @cindex interrupting remote programs
11858 @cindex remote programs, interrupting
11859 Whenever @value{GDBN} is waiting for the remote program, if you type the
11860 interrupt character (often @key{C-C}), @value{GDBN} attempts to stop the
11861 program. This may or may not succeed, depending in part on the hardware
11862 and the serial drivers the remote system uses. If you type the
11863 interrupt character once again, @value{GDBN} displays this prompt:
11866 Interrupted while waiting for the program.
11867 Give up (and stop debugging it)? (y or n)
11870 If you type @kbd{y}, @value{GDBN} abandons the remote debugging session.
11871 (If you decide you want to try again later, you can use @samp{target
11872 remote} again to connect once more.) If you type @kbd{n}, @value{GDBN}
11873 goes back to waiting.
11876 @kindex detach (remote)
11878 When you have finished debugging the remote program, you can use the
11879 @code{detach} command to release it from @value{GDBN} control.
11880 Detaching from the target normally resumes its execution, but the results
11881 will depend on your particular remote stub. After the @code{detach}
11882 command, @value{GDBN} is free to connect to another target.
11886 The @code{disconnect} command behaves like @code{detach}, except that
11887 the target is generally not resumed. It will wait for @value{GDBN}
11888 (this instance or another one) to connect and continue debugging. After
11889 the @code{disconnect} command, @value{GDBN} is again free to connect to
11892 @cindex send command to remote monitor
11894 @item monitor @var{cmd}
11895 This command allows you to send commands directly to the remote
11900 @section Using the @code{gdbserver} program
11903 @cindex remote connection without stubs
11904 @code{gdbserver} is a control program for Unix-like systems, which
11905 allows you to connect your program with a remote @value{GDBN} via
11906 @code{target remote}---but without linking in the usual debugging stub.
11908 @code{gdbserver} is not a complete replacement for the debugging stubs,
11909 because it requires essentially the same operating-system facilities
11910 that @value{GDBN} itself does. In fact, a system that can run
11911 @code{gdbserver} to connect to a remote @value{GDBN} could also run
11912 @value{GDBN} locally! @code{gdbserver} is sometimes useful nevertheless,
11913 because it is a much smaller program than @value{GDBN} itself. It is
11914 also easier to port than all of @value{GDBN}, so you may be able to get
11915 started more quickly on a new system by using @code{gdbserver}.
11916 Finally, if you develop code for real-time systems, you may find that
11917 the tradeoffs involved in real-time operation make it more convenient to
11918 do as much development work as possible on another system, for example
11919 by cross-compiling. You can use @code{gdbserver} to make a similar
11920 choice for debugging.
11922 @value{GDBN} and @code{gdbserver} communicate via either a serial line
11923 or a TCP connection, using the standard @value{GDBN} remote serial
11927 @item On the target machine,
11928 you need to have a copy of the program you want to debug.
11929 @code{gdbserver} does not need your program's symbol table, so you can
11930 strip the program if necessary to save space. @value{GDBN} on the host
11931 system does all the symbol handling.
11933 To use the server, you must tell it how to communicate with @value{GDBN};
11934 the name of your program; and the arguments for your program. The usual
11938 target> gdbserver @var{comm} @var{program} [ @var{args} @dots{} ]
11941 @var{comm} is either a device name (to use a serial line) or a TCP
11942 hostname and portnumber. For example, to debug Emacs with the argument
11943 @samp{foo.txt} and communicate with @value{GDBN} over the serial port
11947 target> gdbserver /dev/com1 emacs foo.txt
11950 @code{gdbserver} waits passively for the host @value{GDBN} to communicate
11953 To use a TCP connection instead of a serial line:
11956 target> gdbserver host:2345 emacs foo.txt
11959 The only difference from the previous example is the first argument,
11960 specifying that you are communicating with the host @value{GDBN} via
11961 TCP. The @samp{host:2345} argument means that @code{gdbserver} is to
11962 expect a TCP connection from machine @samp{host} to local TCP port 2345.
11963 (Currently, the @samp{host} part is ignored.) You can choose any number
11964 you want for the port number as long as it does not conflict with any
11965 TCP ports already in use on the target system (for example, @code{23} is
11966 reserved for @code{telnet}).@footnote{If you choose a port number that
11967 conflicts with another service, @code{gdbserver} prints an error message
11968 and exits.} You must use the same port number with the host @value{GDBN}
11969 @code{target remote} command.
11971 On some targets, @code{gdbserver} can also attach to running programs.
11972 This is accomplished via the @code{--attach} argument. The syntax is:
11975 target> gdbserver @var{comm} --attach @var{pid}
11978 @var{pid} is the process ID of a currently running process. It isn't necessary
11979 to point @code{gdbserver} at a binary for the running process.
11982 @cindex attach to a program by name
11983 You can debug processes by name instead of process ID if your target has the
11984 @code{pidof} utility:
11987 target> gdbserver @var{comm} --attach `pidof @var{PROGRAM}`
11990 In case more than one copy of @var{PROGRAM} is running, or @var{PROGRAM}
11991 has multiple threads, most versions of @code{pidof} support the
11992 @code{-s} option to only return the first process ID.
11994 @item On the host machine,
11995 connect to your target (@pxref{Connecting,,Connecting to a remote target}).
11996 For TCP connections, you must start up @code{gdbserver} prior to using
11997 the @code{target remote} command. Otherwise you may get an error whose
11998 text depends on the host system, but which usually looks something like
11999 @samp{Connection refused}. You don't need to use the @code{load}
12000 command in @value{GDBN} when using @code{gdbserver}, since the program is
12001 already on the target. However, if you want to load the symbols (as
12002 you normally would), do that with the @code{file} command, and issue
12003 it @emph{before} connecting to the server; otherwise, you will get an
12004 error message saying @code{"Program is already running"}, since the
12005 program is considered running after the connection.
12010 @section Using the @code{gdbserve.nlm} program
12012 @kindex gdbserve.nlm
12013 @code{gdbserve.nlm} is a control program for NetWare systems, which
12014 allows you to connect your program with a remote @value{GDBN} via
12015 @code{target remote}.
12017 @value{GDBN} and @code{gdbserve.nlm} communicate via a serial line,
12018 using the standard @value{GDBN} remote serial protocol.
12021 @item On the target machine,
12022 you need to have a copy of the program you want to debug.
12023 @code{gdbserve.nlm} does not need your program's symbol table, so you
12024 can strip the program if necessary to save space. @value{GDBN} on the
12025 host system does all the symbol handling.
12027 To use the server, you must tell it how to communicate with
12028 @value{GDBN}; the name of your program; and the arguments for your
12029 program. The syntax is:
12032 load gdbserve [ BOARD=@var{board} ] [ PORT=@var{port} ]
12033 [ BAUD=@var{baud} ] @var{program} [ @var{args} @dots{} ]
12036 @var{board} and @var{port} specify the serial line; @var{baud} specifies
12037 the baud rate used by the connection. @var{port} and @var{node} default
12038 to 0, @var{baud} defaults to 9600@dmn{bps}.
12040 For example, to debug Emacs with the argument @samp{foo.txt}and
12041 communicate with @value{GDBN} over serial port number 2 or board 1
12042 using a 19200@dmn{bps} connection:
12045 load gdbserve BOARD=1 PORT=2 BAUD=19200 emacs foo.txt
12049 On the @value{GDBN} host machine, connect to your target (@pxref{Connecting,,
12050 Connecting to a remote target}).
12054 @node Remote configuration
12055 @section Remote configuration
12058 @kindex show remote
12059 This section documents the configuration options available when
12060 debugging remote programs. For the options related to the File I/O
12061 extensions of the remote protocol, see @ref{The system call,
12062 system-call-allowed}.
12065 @item set remoteaddresssize @var{bits}
12066 @cindex adress size for remote targets
12067 @cindex bits in remote address
12068 Set the maximum size of address in a memory packet to the specified
12069 number of bits. @value{GDBN} will mask off the address bits above
12070 that number, when it passes addresses to the remote target. The
12071 default value is the number of bits in the target's address.
12073 @item show remoteaddresssize
12074 Show the current value of remote address size in bits.
12076 @item set remotebaud @var{n}
12077 @cindex baud rate for remote targets
12078 Set the baud rate for the remote serial I/O to @var{n} baud. The
12079 value is used to set the speed of the serial port used for debugging
12082 @item show remotebaud
12083 Show the current speed of the remote connection.
12085 @item set remotebreak
12086 @cindex interrupt remote programs
12087 @cindex BREAK signal instead of Ctrl-C
12088 If set to on, @value{GDBN} sends a @code{BREAK} signal to the remote
12089 when you press the @key{Ctrl-C} key to interrupt the program running
12090 on the remote. If set to off, @value{GDBN} sends the @samp{Strl-C}
12091 character instead. The default is off, since most remote systems
12092 expect to see @samp{Ctrl-C} as the interrupt signal.
12094 @item show remotebreak
12095 Show whether @value{GDBN} sends @code{BREAK} or @samp{Ctrl-C} to
12096 interrupt the remote program.
12098 @item set remotedebug
12099 @cindex debug remote protocol
12100 @cindex remote protocol debugging
12101 @cindex display remote packets
12102 Control the debugging of the remote protocol. When enabled, each
12103 packet sent to or received from the remote target is displayed. The
12106 @item show remotedebug
12107 Show the current setting of the remote protocol debugging.
12109 @item set remotedevice @var{device}
12110 @cindex serial port name
12111 Set the name of the serial port through which to communicate to the
12112 remote target to @var{device}. This is the device used by
12113 @value{GDBN} to open the serial communications line to the remote
12114 target. There's no default, so you must set a valid port name for the
12115 remote serial communications to work. (Some varieties of the
12116 @code{target} command accept the port name as part of their
12119 @item show remotedevice
12120 Show the current name of the serial port.
12122 @item set remotelogbase @var{base}
12123 Set the base (a.k.a.@: radix) of logging serial protocol
12124 communications to @var{base}. Supported values of @var{base} are:
12125 @code{ascii}, @code{octal}, and @code{hex}. The default is
12128 @item show remotelogbase
12129 Show the current setting of the radix for logging remote serial
12132 @item set remotelogfile @var{file}
12133 @cindex record serial communications on file
12134 Record remote serial communications on the named @var{file}. The
12135 default is not to record at all.
12137 @item show remotelogfile.
12138 Show the current setting of the file name on which to record the
12139 serial communications.
12141 @item set remotetimeout @var{num}
12142 @cindex timeout for serial communications
12143 @cindex remote timeout
12144 Set the timeout limit to wait for the remote target to respond to
12145 @var{num} seconds. The default is 2 seconds.
12147 @item show remotetimeout
12148 Show the current number of seconds to wait for the remote target
12151 @cindex limit hardware breakpoints and watchpoints
12152 @cindex remote target, limit break- and watchpoints
12153 @anchor{set remote hardware-watchpoint-limit}
12154 @anchor{set remote hardware-breakpoint-limit}
12155 @item set remote hardware-watchpoint-limit @var{limit}
12156 @itemx set remote hardware-breakpoint-limit @var{limit}
12157 Restrict @value{GDBN} to using @var{limit} remote hardware breakpoint or
12158 watchpoints. A limit of -1, the default, is treated as unlimited.
12160 @item set remote fetch-register-packet
12161 @itemx set remote set-register-packet
12162 @itemx set remote P-packet
12163 @itemx set remote p-packet
12165 @cindex fetch registers from remote targets
12166 @cindex set registers in remote targets
12167 Determine whether @value{GDBN} can set and fetch registers from the
12168 remote target using the @samp{P} packets. The default depends on the
12169 remote stub's support of the @samp{P} packets (@value{GDBN} queries
12170 the stub when this packet is first required).
12172 @item show remote fetch-register-packet
12173 @itemx show remote set-register-packet
12174 @itemx show remote P-packet
12175 @itemx show remote p-packet
12176 Show the current setting of using the @samp{P} packets for setting and
12177 fetching registers from the remote target.
12179 @cindex binary downloads
12181 @item set remote binary-download-packet
12182 @itemx set remote X-packet
12183 Determine whether @value{GDBN} sends downloads in binary mode using
12184 the @samp{X} packets. The default is on.
12186 @item show remote binary-download-packet
12187 @itemx show remote X-packet
12188 Show the current setting of using the @samp{X} packets for binary
12191 @item set remote read-aux-vector-packet
12192 @cindex auxiliary vector of remote target
12193 @cindex @code{auxv}, and remote targets
12194 Set the use of the remote protocol's @samp{qPart:auxv:read} (target
12195 auxiliary vector read) request. This request is used to fetch the
12196 remote target's @dfn{auxiliary vector}, see @ref{OS Information,
12197 Auxiliary Vector}. The default setting depends on the remote stub's
12198 support of this request (@value{GDBN} queries the stub when this
12199 request is first required). @xref{General Query Packets, qPart}, for
12200 more information about this request.
12202 @item show remote read-aux-vector-packet
12203 Show the current setting of use of the @samp{qPart:auxv:read} request.
12205 @item set remote symbol-lookup-packet
12206 @cindex remote symbol lookup request
12207 Set the use of the remote protocol's @samp{qSymbol} (target symbol
12208 lookup) request. This request is used to communicate symbol
12209 information to the remote target, e.g., whenever a new shared library
12210 is loaded by the remote (@pxref{Files, shared libraries}). The
12211 default setting depends on the remote stub's support of this request
12212 (@value{GDBN} queries the stub when this request is first required).
12213 @xref{General Query Packets, qSymbol}, for more information about this
12216 @item show remote symbol-lookup-packet
12217 Show the current setting of use of the @samp{qSymbol} request.
12219 @item set remote verbose-resume-packet
12220 @cindex resume remote target
12221 @cindex signal thread, and remote targets
12222 @cindex single-step thread, and remote targets
12223 @cindex thread-specific operations on remote targets
12224 Set the use of the remote protocol's @samp{vCont} (descriptive resume)
12225 request. This request is used to resume specific threads in the
12226 remote target, and to single-step or signal them. The default setting
12227 depends on the remote stub's support of this request (@value{GDBN}
12228 queries the stub when this request is first required). This setting
12229 affects debugging of multithreaded programs: if @samp{vCont} cannot be
12230 used, @value{GDBN} might be unable to single-step a specific thread,
12231 especially under @code{set scheduler-locking off}; it is also
12232 impossible to pause a specific thread. @xref{Packets, vCont}, for
12235 @item show remote verbose-resume-packet
12236 Show the current setting of use of the @samp{vCont} request
12238 @item set remote software-breakpoint-packet
12239 @itemx set remote hardware-breakpoint-packet
12240 @itemx set remote write-watchpoint-packet
12241 @itemx set remote read-watchpoint-packet
12242 @itemx set remote access-watchpoint-packet
12243 @itemx set remote Z-packet
12245 @cindex remote hardware breakpoints and watchpoints
12246 These commands enable or disable the use of @samp{Z} packets for
12247 setting breakpoints and watchpoints in the remote target. The default
12248 depends on the remote stub's support of the @samp{Z} packets
12249 (@value{GDBN} queries the stub when each packet is first required).
12250 The command @code{set remote Z-packet}, kept for back-compatibility,
12251 turns on or off all the features that require the use of @samp{Z}
12254 @item show remote software-breakpoint-packet
12255 @itemx show remote hardware-breakpoint-packet
12256 @itemx show remote write-watchpoint-packet
12257 @itemx show remote read-watchpoint-packet
12258 @itemx show remote access-watchpoint-packet
12259 @itemx show remote Z-packet
12260 Show the current setting of @samp{Z} packets usage.
12262 @item set remote get-thread-local-storage-address
12263 @kindex set remote get-thread-local-storage-address
12264 @cindex thread local storage of remote targets
12265 This command enables or disables the use of the @samp{qGetTLSAddr}
12266 (Get Thread Local Storage Address) request packet. The default
12267 depends on whether the remote stub supports this request.
12268 @xref{General Query Packets, qGetTLSAddr}, for more details about this
12271 @item show remote get-thread-local-storage-address
12272 @kindex show remote get-thread-local-storage-address
12273 Show the current setting of @samp{qGetTLSAddr} packet usage.
12277 @section Implementing a remote stub
12279 @cindex debugging stub, example
12280 @cindex remote stub, example
12281 @cindex stub example, remote debugging
12282 The stub files provided with @value{GDBN} implement the target side of the
12283 communication protocol, and the @value{GDBN} side is implemented in the
12284 @value{GDBN} source file @file{remote.c}. Normally, you can simply allow
12285 these subroutines to communicate, and ignore the details. (If you're
12286 implementing your own stub file, you can still ignore the details: start
12287 with one of the existing stub files. @file{sparc-stub.c} is the best
12288 organized, and therefore the easiest to read.)
12290 @cindex remote serial debugging, overview
12291 To debug a program running on another machine (the debugging
12292 @dfn{target} machine), you must first arrange for all the usual
12293 prerequisites for the program to run by itself. For example, for a C
12298 A startup routine to set up the C runtime environment; these usually
12299 have a name like @file{crt0}. The startup routine may be supplied by
12300 your hardware supplier, or you may have to write your own.
12303 A C subroutine library to support your program's
12304 subroutine calls, notably managing input and output.
12307 A way of getting your program to the other machine---for example, a
12308 download program. These are often supplied by the hardware
12309 manufacturer, but you may have to write your own from hardware
12313 The next step is to arrange for your program to use a serial port to
12314 communicate with the machine where @value{GDBN} is running (the @dfn{host}
12315 machine). In general terms, the scheme looks like this:
12319 @value{GDBN} already understands how to use this protocol; when everything
12320 else is set up, you can simply use the @samp{target remote} command
12321 (@pxref{Targets,,Specifying a Debugging Target}).
12323 @item On the target,
12324 you must link with your program a few special-purpose subroutines that
12325 implement the @value{GDBN} remote serial protocol. The file containing these
12326 subroutines is called a @dfn{debugging stub}.
12328 On certain remote targets, you can use an auxiliary program
12329 @code{gdbserver} instead of linking a stub into your program.
12330 @xref{Server,,Using the @code{gdbserver} program}, for details.
12333 The debugging stub is specific to the architecture of the remote
12334 machine; for example, use @file{sparc-stub.c} to debug programs on
12337 @cindex remote serial stub list
12338 These working remote stubs are distributed with @value{GDBN}:
12343 @cindex @file{i386-stub.c}
12346 For Intel 386 and compatible architectures.
12349 @cindex @file{m68k-stub.c}
12350 @cindex Motorola 680x0
12352 For Motorola 680x0 architectures.
12355 @cindex @file{sh-stub.c}
12358 For Renesas SH architectures.
12361 @cindex @file{sparc-stub.c}
12363 For @sc{sparc} architectures.
12365 @item sparcl-stub.c
12366 @cindex @file{sparcl-stub.c}
12369 For Fujitsu @sc{sparclite} architectures.
12373 The @file{README} file in the @value{GDBN} distribution may list other
12374 recently added stubs.
12377 * Stub Contents:: What the stub can do for you
12378 * Bootstrapping:: What you must do for the stub
12379 * Debug Session:: Putting it all together
12382 @node Stub Contents
12383 @subsection What the stub can do for you
12385 @cindex remote serial stub
12386 The debugging stub for your architecture supplies these three
12390 @item set_debug_traps
12391 @findex set_debug_traps
12392 @cindex remote serial stub, initialization
12393 This routine arranges for @code{handle_exception} to run when your
12394 program stops. You must call this subroutine explicitly near the
12395 beginning of your program.
12397 @item handle_exception
12398 @findex handle_exception
12399 @cindex remote serial stub, main routine
12400 This is the central workhorse, but your program never calls it
12401 explicitly---the setup code arranges for @code{handle_exception} to
12402 run when a trap is triggered.
12404 @code{handle_exception} takes control when your program stops during
12405 execution (for example, on a breakpoint), and mediates communications
12406 with @value{GDBN} on the host machine. This is where the communications
12407 protocol is implemented; @code{handle_exception} acts as the @value{GDBN}
12408 representative on the target machine. It begins by sending summary
12409 information on the state of your program, then continues to execute,
12410 retrieving and transmitting any information @value{GDBN} needs, until you
12411 execute a @value{GDBN} command that makes your program resume; at that point,
12412 @code{handle_exception} returns control to your own code on the target
12416 @cindex @code{breakpoint} subroutine, remote
12417 Use this auxiliary subroutine to make your program contain a
12418 breakpoint. Depending on the particular situation, this may be the only
12419 way for @value{GDBN} to get control. For instance, if your target
12420 machine has some sort of interrupt button, you won't need to call this;
12421 pressing the interrupt button transfers control to
12422 @code{handle_exception}---in effect, to @value{GDBN}. On some machines,
12423 simply receiving characters on the serial port may also trigger a trap;
12424 again, in that situation, you don't need to call @code{breakpoint} from
12425 your own program---simply running @samp{target remote} from the host
12426 @value{GDBN} session gets control.
12428 Call @code{breakpoint} if none of these is true, or if you simply want
12429 to make certain your program stops at a predetermined point for the
12430 start of your debugging session.
12433 @node Bootstrapping
12434 @subsection What you must do for the stub
12436 @cindex remote stub, support routines
12437 The debugging stubs that come with @value{GDBN} are set up for a particular
12438 chip architecture, but they have no information about the rest of your
12439 debugging target machine.
12441 First of all you need to tell the stub how to communicate with the
12445 @item int getDebugChar()
12446 @findex getDebugChar
12447 Write this subroutine to read a single character from the serial port.
12448 It may be identical to @code{getchar} for your target system; a
12449 different name is used to allow you to distinguish the two if you wish.
12451 @item void putDebugChar(int)
12452 @findex putDebugChar
12453 Write this subroutine to write a single character to the serial port.
12454 It may be identical to @code{putchar} for your target system; a
12455 different name is used to allow you to distinguish the two if you wish.
12458 @cindex control C, and remote debugging
12459 @cindex interrupting remote targets
12460 If you want @value{GDBN} to be able to stop your program while it is
12461 running, you need to use an interrupt-driven serial driver, and arrange
12462 for it to stop when it receives a @code{^C} (@samp{\003}, the control-C
12463 character). That is the character which @value{GDBN} uses to tell the
12464 remote system to stop.
12466 Getting the debugging target to return the proper status to @value{GDBN}
12467 probably requires changes to the standard stub; one quick and dirty way
12468 is to just execute a breakpoint instruction (the ``dirty'' part is that
12469 @value{GDBN} reports a @code{SIGTRAP} instead of a @code{SIGINT}).
12471 Other routines you need to supply are:
12474 @item void exceptionHandler (int @var{exception_number}, void *@var{exception_address})
12475 @findex exceptionHandler
12476 Write this function to install @var{exception_address} in the exception
12477 handling tables. You need to do this because the stub does not have any
12478 way of knowing what the exception handling tables on your target system
12479 are like (for example, the processor's table might be in @sc{rom},
12480 containing entries which point to a table in @sc{ram}).
12481 @var{exception_number} is the exception number which should be changed;
12482 its meaning is architecture-dependent (for example, different numbers
12483 might represent divide by zero, misaligned access, etc). When this
12484 exception occurs, control should be transferred directly to
12485 @var{exception_address}, and the processor state (stack, registers,
12486 and so on) should be just as it is when a processor exception occurs. So if
12487 you want to use a jump instruction to reach @var{exception_address}, it
12488 should be a simple jump, not a jump to subroutine.
12490 For the 386, @var{exception_address} should be installed as an interrupt
12491 gate so that interrupts are masked while the handler runs. The gate
12492 should be at privilege level 0 (the most privileged level). The
12493 @sc{sparc} and 68k stubs are able to mask interrupts themselves without
12494 help from @code{exceptionHandler}.
12496 @item void flush_i_cache()
12497 @findex flush_i_cache
12498 On @sc{sparc} and @sc{sparclite} only, write this subroutine to flush the
12499 instruction cache, if any, on your target machine. If there is no
12500 instruction cache, this subroutine may be a no-op.
12502 On target machines that have instruction caches, @value{GDBN} requires this
12503 function to make certain that the state of your program is stable.
12507 You must also make sure this library routine is available:
12510 @item void *memset(void *, int, int)
12512 This is the standard library function @code{memset} that sets an area of
12513 memory to a known value. If you have one of the free versions of
12514 @code{libc.a}, @code{memset} can be found there; otherwise, you must
12515 either obtain it from your hardware manufacturer, or write your own.
12518 If you do not use the GNU C compiler, you may need other standard
12519 library subroutines as well; this varies from one stub to another,
12520 but in general the stubs are likely to use any of the common library
12521 subroutines which @code{@value{GCC}} generates as inline code.
12524 @node Debug Session
12525 @subsection Putting it all together
12527 @cindex remote serial debugging summary
12528 In summary, when your program is ready to debug, you must follow these
12533 Make sure you have defined the supporting low-level routines
12534 (@pxref{Bootstrapping,,What you must do for the stub}):
12536 @code{getDebugChar}, @code{putDebugChar},
12537 @code{flush_i_cache}, @code{memset}, @code{exceptionHandler}.
12541 Insert these lines near the top of your program:
12549 For the 680x0 stub only, you need to provide a variable called
12550 @code{exceptionHook}. Normally you just use:
12553 void (*exceptionHook)() = 0;
12557 but if before calling @code{set_debug_traps}, you set it to point to a
12558 function in your program, that function is called when
12559 @code{@value{GDBN}} continues after stopping on a trap (for example, bus
12560 error). The function indicated by @code{exceptionHook} is called with
12561 one parameter: an @code{int} which is the exception number.
12564 Compile and link together: your program, the @value{GDBN} debugging stub for
12565 your target architecture, and the supporting subroutines.
12568 Make sure you have a serial connection between your target machine and
12569 the @value{GDBN} host, and identify the serial port on the host.
12572 @c The "remote" target now provides a `load' command, so we should
12573 @c document that. FIXME.
12574 Download your program to your target machine (or get it there by
12575 whatever means the manufacturer provides), and start it.
12578 Start @value{GDBN} on the host, and connect to the target
12579 (@pxref{Connecting,,Connecting to a remote target}).
12583 @node Configurations
12584 @chapter Configuration-Specific Information
12586 While nearly all @value{GDBN} commands are available for all native and
12587 cross versions of the debugger, there are some exceptions. This chapter
12588 describes things that are only available in certain configurations.
12590 There are three major categories of configurations: native
12591 configurations, where the host and target are the same, embedded
12592 operating system configurations, which are usually the same for several
12593 different processor architectures, and bare embedded processors, which
12594 are quite different from each other.
12599 * Embedded Processors::
12606 This section describes details specific to particular native
12611 * BSD libkvm Interface:: Debugging BSD kernel memory images
12612 * SVR4 Process Information:: SVR4 process information
12613 * DJGPP Native:: Features specific to the DJGPP port
12614 * Cygwin Native:: Features specific to the Cygwin port
12615 * Hurd Native:: Features specific to @sc{gnu} Hurd
12616 * Neutrino:: Features specific to QNX Neutrino
12622 On HP-UX systems, if you refer to a function or variable name that
12623 begins with a dollar sign, @value{GDBN} searches for a user or system
12624 name first, before it searches for a convenience variable.
12627 @node BSD libkvm Interface
12628 @subsection BSD libkvm Interface
12631 @cindex kernel memory image
12632 @cindex kernel crash dump
12634 BSD-derived systems (FreeBSD/NetBSD/OpenBSD) have a kernel memory
12635 interface that provides a uniform interface for accessing kernel virtual
12636 memory images, including live systems and crash dumps. @value{GDBN}
12637 uses this interface to allow you to debug live kernels and kernel crash
12638 dumps on many native BSD configurations. This is implemented as a
12639 special @code{kvm} debugging target. For debugging a live system, load
12640 the currently running kernel into @value{GDBN} and connect to the
12644 (@value{GDBP}) @b{target kvm}
12647 For debugging crash dumps, provide the file name of the crash dump as an
12651 (@value{GDBP}) @b{target kvm /var/crash/bsd.0}
12654 Once connected to the @code{kvm} target, the following commands are
12660 Set current context from the @dfn{Process Control Block} (PCB) address.
12663 Set current context from proc address. This command isn't available on
12664 modern FreeBSD systems.
12667 @node SVR4 Process Information
12668 @subsection SVR4 process information
12670 @cindex examine process image
12671 @cindex process info via @file{/proc}
12673 Many versions of SVR4 and compatible systems provide a facility called
12674 @samp{/proc} that can be used to examine the image of a running
12675 process using file-system subroutines. If @value{GDBN} is configured
12676 for an operating system with this facility, the command @code{info
12677 proc} is available to report information about the process running
12678 your program, or about any process running on your system. @code{info
12679 proc} works only on SVR4 systems that include the @code{procfs} code.
12680 This includes, as of this writing, @sc{gnu}/Linux, OSF/1 (Digital
12681 Unix), Solaris, Irix, and Unixware, but not HP-UX, for example.
12687 @itemx info proc @var{process-id}
12688 Summarize available information about any running process. If a
12689 process ID is specified by @var{process-id}, display information about
12690 that process; otherwise display information about the program being
12691 debugged. The summary includes the debugged process ID, the command
12692 line used to invoke it, its current working directory, and its
12693 executable file's absolute file name.
12695 On some systems, @var{process-id} can be of the form
12696 @samp{[@var{pid}]/@var{tid}} which specifies a certain thread ID
12697 within a process. If the optional @var{pid} part is missing, it means
12698 a thread from the process being debugged (the leading @samp{/} still
12699 needs to be present, or else @value{GDBN} will interpret the number as
12700 a process ID rather than a thread ID).
12702 @item info proc mappings
12703 @cindex memory address space mappings
12704 Report the memory address space ranges accessible in the program, with
12705 information on whether the process has read, write, or execute access
12706 rights to each range. On @sc{gnu}/Linux systems, each memory range
12707 includes the object file which is mapped to that range, instead of the
12708 memory access rights to that range.
12710 @item info proc stat
12711 @itemx info proc status
12712 @cindex process detailed status information
12713 These subcommands are specific to @sc{gnu}/Linux systems. They show
12714 the process-related information, including the user ID and group ID;
12715 how many threads are there in the process; its virtual memory usage;
12716 the signals that are pending, blocked, and ignored; its TTY; its
12717 consumption of system and user time; its stack size; its @samp{nice}
12718 value; etc. For more information, see the @samp{proc} man page
12719 (type @kbd{man 5 proc} from your shell prompt).
12721 @item info proc all
12722 Show all the information about the process described under all of the
12723 above @code{info proc} subcommands.
12726 @comment These sub-options of 'info proc' were not included when
12727 @comment procfs.c was re-written. Keep their descriptions around
12728 @comment against the day when someone finds the time to put them back in.
12729 @kindex info proc times
12730 @item info proc times
12731 Starting time, user CPU time, and system CPU time for your program and
12734 @kindex info proc id
12736 Report on the process IDs related to your program: its own process ID,
12737 the ID of its parent, the process group ID, and the session ID.
12740 @item set procfs-trace
12741 @kindex set procfs-trace
12742 @cindex @code{procfs} API calls
12743 This command enables and disables tracing of @code{procfs} API calls.
12745 @item show procfs-trace
12746 @kindex show procfs-trace
12747 Show the current state of @code{procfs} API call tracing.
12749 @item set procfs-file @var{file}
12750 @kindex set procfs-file
12751 Tell @value{GDBN} to write @code{procfs} API trace to the named
12752 @var{file}. @value{GDBN} appends the trace info to the previous
12753 contents of the file. The default is to display the trace on the
12756 @item show procfs-file
12757 @kindex show procfs-file
12758 Show the file to which @code{procfs} API trace is written.
12760 @item proc-trace-entry
12761 @itemx proc-trace-exit
12762 @itemx proc-untrace-entry
12763 @itemx proc-untrace-exit
12764 @kindex proc-trace-entry
12765 @kindex proc-trace-exit
12766 @kindex proc-untrace-entry
12767 @kindex proc-untrace-exit
12768 These commands enable and disable tracing of entries into and exits
12769 from the @code{syscall} interface.
12772 @kindex info pidlist
12773 @cindex process list, QNX Neutrino
12774 For QNX Neutrino only, this command displays the list of all the
12775 processes and all the threads within each process.
12778 @kindex info meminfo
12779 @cindex mapinfo list, QNX Neutrino
12780 For QNX Neutrino only, this command displays the list of all mapinfos.
12784 @subsection Features for Debugging @sc{djgpp} Programs
12785 @cindex @sc{djgpp} debugging
12786 @cindex native @sc{djgpp} debugging
12787 @cindex MS-DOS-specific commands
12790 @sc{djgpp} is a port of the @sc{gnu} development tools to MS-DOS and
12791 MS-Windows. @sc{djgpp} programs are 32-bit protected-mode programs
12792 that use the @dfn{DPMI} (DOS Protected-Mode Interface) API to run on
12793 top of real-mode DOS systems and their emulations.
12795 @value{GDBN} supports native debugging of @sc{djgpp} programs, and
12796 defines a few commands specific to the @sc{djgpp} port. This
12797 subsection describes those commands.
12802 This is a prefix of @sc{djgpp}-specific commands which print
12803 information about the target system and important OS structures.
12806 @cindex MS-DOS system info
12807 @cindex free memory information (MS-DOS)
12808 @item info dos sysinfo
12809 This command displays assorted information about the underlying
12810 platform: the CPU type and features, the OS version and flavor, the
12811 DPMI version, and the available conventional and DPMI memory.
12816 @cindex segment descriptor tables
12817 @cindex descriptor tables display
12819 @itemx info dos ldt
12820 @itemx info dos idt
12821 These 3 commands display entries from, respectively, Global, Local,
12822 and Interrupt Descriptor Tables (GDT, LDT, and IDT). The descriptor
12823 tables are data structures which store a descriptor for each segment
12824 that is currently in use. The segment's selector is an index into a
12825 descriptor table; the table entry for that index holds the
12826 descriptor's base address and limit, and its attributes and access
12829 A typical @sc{djgpp} program uses 3 segments: a code segment, a data
12830 segment (used for both data and the stack), and a DOS segment (which
12831 allows access to DOS/BIOS data structures and absolute addresses in
12832 conventional memory). However, the DPMI host will usually define
12833 additional segments in order to support the DPMI environment.
12835 @cindex garbled pointers
12836 These commands allow to display entries from the descriptor tables.
12837 Without an argument, all entries from the specified table are
12838 displayed. An argument, which should be an integer expression, means
12839 display a single entry whose index is given by the argument. For
12840 example, here's a convenient way to display information about the
12841 debugged program's data segment:
12844 @exdent @code{(@value{GDBP}) info dos ldt $ds}
12845 @exdent @code{0x13f: base=0x11970000 limit=0x0009ffff 32-Bit Data (Read/Write, Exp-up)}
12849 This comes in handy when you want to see whether a pointer is outside
12850 the data segment's limit (i.e.@: @dfn{garbled}).
12852 @cindex page tables display (MS-DOS)
12854 @itemx info dos pte
12855 These two commands display entries from, respectively, the Page
12856 Directory and the Page Tables. Page Directories and Page Tables are
12857 data structures which control how virtual memory addresses are mapped
12858 into physical addresses. A Page Table includes an entry for every
12859 page of memory that is mapped into the program's address space; there
12860 may be several Page Tables, each one holding up to 4096 entries. A
12861 Page Directory has up to 4096 entries, one each for every Page Table
12862 that is currently in use.
12864 Without an argument, @kbd{info dos pde} displays the entire Page
12865 Directory, and @kbd{info dos pte} displays all the entries in all of
12866 the Page Tables. An argument, an integer expression, given to the
12867 @kbd{info dos pde} command means display only that entry from the Page
12868 Directory table. An argument given to the @kbd{info dos pte} command
12869 means display entries from a single Page Table, the one pointed to by
12870 the specified entry in the Page Directory.
12872 @cindex direct memory access (DMA) on MS-DOS
12873 These commands are useful when your program uses @dfn{DMA} (Direct
12874 Memory Access), which needs physical addresses to program the DMA
12877 These commands are supported only with some DPMI servers.
12879 @cindex physical address from linear address
12880 @item info dos address-pte @var{addr}
12881 This command displays the Page Table entry for a specified linear
12882 address. The argument @var{addr} is a linear address which should
12883 already have the appropriate segment's base address added to it,
12884 because this command accepts addresses which may belong to @emph{any}
12885 segment. For example, here's how to display the Page Table entry for
12886 the page where a variable @code{i} is stored:
12889 @exdent @code{(@value{GDBP}) info dos address-pte __djgpp_base_address + (char *)&i}
12890 @exdent @code{Page Table entry for address 0x11a00d30:}
12891 @exdent @code{Base=0x02698000 Dirty Acc. Not-Cached Write-Back Usr Read-Write +0xd30}
12895 This says that @code{i} is stored at offset @code{0xd30} from the page
12896 whose physical base address is @code{0x02698000}, and shows all the
12897 attributes of that page.
12899 Note that you must cast the addresses of variables to a @code{char *},
12900 since otherwise the value of @code{__djgpp_base_address}, the base
12901 address of all variables and functions in a @sc{djgpp} program, will
12902 be added using the rules of C pointer arithmetics: if @code{i} is
12903 declared an @code{int}, @value{GDBN} will add 4 times the value of
12904 @code{__djgpp_base_address} to the address of @code{i}.
12906 Here's another example, it displays the Page Table entry for the
12910 @exdent @code{(@value{GDBP}) info dos address-pte *((unsigned *)&_go32_info_block + 3)}
12911 @exdent @code{Page Table entry for address 0x29110:}
12912 @exdent @code{Base=0x00029000 Dirty Acc. Not-Cached Write-Back Usr Read-Write +0x110}
12916 (The @code{+ 3} offset is because the transfer buffer's address is the
12917 3rd member of the @code{_go32_info_block} structure.) The output
12918 clearly shows that this DPMI server maps the addresses in conventional
12919 memory 1:1, i.e.@: the physical (@code{0x00029000} + @code{0x110}) and
12920 linear (@code{0x29110}) addresses are identical.
12922 This command is supported only with some DPMI servers.
12925 @cindex DOS serial data link, remote debugging
12926 In addition to native debugging, the DJGPP port supports remote
12927 debugging via a serial data link. The following commands are specific
12928 to remote serial debugging in the DJGPP port of @value{GDBN}.
12931 @kindex set com1base
12932 @kindex set com1irq
12933 @kindex set com2base
12934 @kindex set com2irq
12935 @kindex set com3base
12936 @kindex set com3irq
12937 @kindex set com4base
12938 @kindex set com4irq
12939 @item set com1base @var{addr}
12940 This command sets the base I/O port address of the @file{COM1} serial
12943 @item set com1irq @var{irq}
12944 This command sets the @dfn{Interrupt Request} (@code{IRQ}) line to use
12945 for the @file{COM1} serial port.
12947 There are similar commands @samp{set com2base}, @samp{set com3irq},
12948 etc.@: for setting the port address and the @code{IRQ} lines for the
12951 @kindex show com1base
12952 @kindex show com1irq
12953 @kindex show com2base
12954 @kindex show com2irq
12955 @kindex show com3base
12956 @kindex show com3irq
12957 @kindex show com4base
12958 @kindex show com4irq
12959 The related commands @samp{show com1base}, @samp{show com1irq} etc.@:
12960 display the current settings of the base address and the @code{IRQ}
12961 lines used by the COM ports.
12964 @kindex info serial
12965 @cindex DOS serial port status
12966 This command prints the status of the 4 DOS serial ports. For each
12967 port, it prints whether it's active or not, its I/O base address and
12968 IRQ number, whether it uses a 16550-style FIFO, its baudrate, and the
12969 counts of various errors encountered so far.
12973 @node Cygwin Native
12974 @subsection Features for Debugging MS Windows PE executables
12975 @cindex MS Windows debugging
12976 @cindex native Cygwin debugging
12977 @cindex Cygwin-specific commands
12979 @value{GDBN} supports native debugging of MS Windows programs, including
12980 DLLs with and without symbolic debugging information. There are various
12981 additional Cygwin-specific commands, described in this subsection. The
12982 subsubsection @pxref{Non-debug DLL symbols} describes working with DLLs
12983 that have no debugging symbols.
12989 This is a prefix of MS Windows specific commands which print
12990 information about the target system and important OS structures.
12992 @item info w32 selector
12993 This command displays information returned by
12994 the Win32 API @code{GetThreadSelectorEntry} function.
12995 It takes an optional argument that is evaluated to
12996 a long value to give the information about this given selector.
12997 Without argument, this command displays information
12998 about the the six segment registers.
13002 This is a Cygwin specific alias of info shared.
13004 @kindex dll-symbols
13006 This command loads symbols from a dll similarly to
13007 add-sym command but without the need to specify a base address.
13009 @kindex set new-console
13010 @item set new-console @var{mode}
13011 If @var{mode} is @code{on} the debuggee will
13012 be started in a new console on next start.
13013 If @var{mode} is @code{off}i, the debuggee will
13014 be started in the same console as the debugger.
13016 @kindex show new-console
13017 @item show new-console
13018 Displays whether a new console is used
13019 when the debuggee is started.
13021 @kindex set new-group
13022 @item set new-group @var{mode}
13023 This boolean value controls whether the debuggee should
13024 start a new group or stay in the same group as the debugger.
13025 This affects the way the Windows OS handles
13028 @kindex show new-group
13029 @item show new-group
13030 Displays current value of new-group boolean.
13032 @kindex set debugevents
13033 @item set debugevents
13034 This boolean value adds debug output concerning events seen by the debugger.
13036 @kindex set debugexec
13037 @item set debugexec
13038 This boolean value adds debug output concerning execute events
13039 seen by the debugger.
13041 @kindex set debugexceptions
13042 @item set debugexceptions
13043 This boolean value adds debug ouptut concerning exception events
13044 seen by the debugger.
13046 @kindex set debugmemory
13047 @item set debugmemory
13048 This boolean value adds debug ouptut concerning memory events
13049 seen by the debugger.
13053 This boolean values specifies whether the debuggee is called
13054 via a shell or directly (default value is on).
13058 Displays if the debuggee will be started with a shell.
13063 * Non-debug DLL symbols:: Support for DLLs without debugging symbols
13066 @node Non-debug DLL symbols
13067 @subsubsection Support for DLLs without debugging symbols
13068 @cindex DLLs with no debugging symbols
13069 @cindex Minimal symbols and DLLs
13071 Very often on windows, some of the DLLs that your program relies on do
13072 not include symbolic debugging information (for example,
13073 @file{kernel32.dll}). When @value{GDBN} doesn't recognize any debugging
13074 symbols in a DLL, it relies on the minimal amount of symbolic
13075 information contained in the DLL's export table. This subsubsection
13076 describes working with such symbols, known internally to @value{GDBN} as
13077 ``minimal symbols''.
13079 Note that before the debugged program has started execution, no DLLs
13080 will have been loaded. The easiest way around this problem is simply to
13081 start the program --- either by setting a breakpoint or letting the
13082 program run once to completion. It is also possible to force
13083 @value{GDBN} to load a particular DLL before starting the executable ---
13084 see the shared library information in @pxref{Files} or the
13085 @code{dll-symbols} command in @pxref{Cygwin Native}. Currently,
13086 explicitly loading symbols from a DLL with no debugging information will
13087 cause the symbol names to be duplicated in @value{GDBN}'s lookup table,
13088 which may adversely affect symbol lookup performance.
13090 @subsubsection DLL name prefixes
13092 In keeping with the naming conventions used by the Microsoft debugging
13093 tools, DLL export symbols are made available with a prefix based on the
13094 DLL name, for instance @code{KERNEL32!CreateFileA}. The plain name is
13095 also entered into the symbol table, so @code{CreateFileA} is often
13096 sufficient. In some cases there will be name clashes within a program
13097 (particularly if the executable itself includes full debugging symbols)
13098 necessitating the use of the fully qualified name when referring to the
13099 contents of the DLL. Use single-quotes around the name to avoid the
13100 exclamation mark (``!'') being interpreted as a language operator.
13102 Note that the internal name of the DLL may be all upper-case, even
13103 though the file name of the DLL is lower-case, or vice-versa. Since
13104 symbols within @value{GDBN} are @emph{case-sensitive} this may cause
13105 some confusion. If in doubt, try the @code{info functions} and
13106 @code{info variables} commands or even @code{maint print msymbols} (see
13107 @pxref{Symbols}). Here's an example:
13110 (@value{GDBP}) info function CreateFileA
13111 All functions matching regular expression "CreateFileA":
13113 Non-debugging symbols:
13114 0x77e885f4 CreateFileA
13115 0x77e885f4 KERNEL32!CreateFileA
13119 (@value{GDBP}) info function !
13120 All functions matching regular expression "!":
13122 Non-debugging symbols:
13123 0x6100114c cygwin1!__assert
13124 0x61004034 cygwin1!_dll_crt0@@0
13125 0x61004240 cygwin1!dll_crt0(per_process *)
13129 @subsubsection Working with minimal symbols
13131 Symbols extracted from a DLL's export table do not contain very much
13132 type information. All that @value{GDBN} can do is guess whether a symbol
13133 refers to a function or variable depending on the linker section that
13134 contains the symbol. Also note that the actual contents of the memory
13135 contained in a DLL are not available unless the program is running. This
13136 means that you cannot examine the contents of a variable or disassemble
13137 a function within a DLL without a running program.
13139 Variables are generally treated as pointers and dereferenced
13140 automatically. For this reason, it is often necessary to prefix a
13141 variable name with the address-of operator (``&'') and provide explicit
13142 type information in the command. Here's an example of the type of
13146 (@value{GDBP}) print 'cygwin1!__argv'
13151 (@value{GDBP}) x 'cygwin1!__argv'
13152 0x10021610: "\230y\""
13155 And two possible solutions:
13158 (@value{GDBP}) print ((char **)'cygwin1!__argv')[0]
13159 $2 = 0x22fd98 "/cygdrive/c/mydirectory/myprogram"
13163 (@value{GDBP}) x/2x &'cygwin1!__argv'
13164 0x610c0aa8 <cygwin1!__argv>: 0x10021608 0x00000000
13165 (@value{GDBP}) x/x 0x10021608
13166 0x10021608: 0x0022fd98
13167 (@value{GDBP}) x/s 0x0022fd98
13168 0x22fd98: "/cygdrive/c/mydirectory/myprogram"
13171 Setting a break point within a DLL is possible even before the program
13172 starts execution. However, under these circumstances, @value{GDBN} can't
13173 examine the initial instructions of the function in order to skip the
13174 function's frame set-up code. You can work around this by using ``*&''
13175 to set the breakpoint at a raw memory address:
13178 (@value{GDBP}) break *&'python22!PyOS_Readline'
13179 Breakpoint 1 at 0x1e04eff0
13182 The author of these extensions is not entirely convinced that setting a
13183 break point within a shared DLL like @file{kernel32.dll} is completely
13187 @subsection Commands specific to @sc{gnu} Hurd systems
13188 @cindex @sc{gnu} Hurd debugging
13190 This subsection describes @value{GDBN} commands specific to the
13191 @sc{gnu} Hurd native debugging.
13196 @kindex set signals@r{, Hurd command}
13197 @kindex set sigs@r{, Hurd command}
13198 This command toggles the state of inferior signal interception by
13199 @value{GDBN}. Mach exceptions, such as breakpoint traps, are not
13200 affected by this command. @code{sigs} is a shorthand alias for
13205 @kindex show signals@r{, Hurd command}
13206 @kindex show sigs@r{, Hurd command}
13207 Show the current state of intercepting inferior's signals.
13209 @item set signal-thread
13210 @itemx set sigthread
13211 @kindex set signal-thread
13212 @kindex set sigthread
13213 This command tells @value{GDBN} which thread is the @code{libc} signal
13214 thread. That thread is run when a signal is delivered to a running
13215 process. @code{set sigthread} is the shorthand alias of @code{set
13218 @item show signal-thread
13219 @itemx show sigthread
13220 @kindex show signal-thread
13221 @kindex show sigthread
13222 These two commands show which thread will run when the inferior is
13223 delivered a signal.
13226 @kindex set stopped@r{, Hurd command}
13227 This commands tells @value{GDBN} that the inferior process is stopped,
13228 as with the @code{SIGSTOP} signal. The stopped process can be
13229 continued by delivering a signal to it.
13232 @kindex show stopped@r{, Hurd command}
13233 This command shows whether @value{GDBN} thinks the debuggee is
13236 @item set exceptions
13237 @kindex set exceptions@r{, Hurd command}
13238 Use this command to turn off trapping of exceptions in the inferior.
13239 When exception trapping is off, neither breakpoints nor
13240 single-stepping will work. To restore the default, set exception
13243 @item show exceptions
13244 @kindex show exceptions@r{, Hurd command}
13245 Show the current state of trapping exceptions in the inferior.
13247 @item set task pause
13248 @kindex set task@r{, Hurd commands}
13249 @cindex task attributes (@sc{gnu} Hurd)
13250 @cindex pause current task (@sc{gnu} Hurd)
13251 This command toggles task suspension when @value{GDBN} has control.
13252 Setting it to on takes effect immediately, and the task is suspended
13253 whenever @value{GDBN} gets control. Setting it to off will take
13254 effect the next time the inferior is continued. If this option is set
13255 to off, you can use @code{set thread default pause on} or @code{set
13256 thread pause on} (see below) to pause individual threads.
13258 @item show task pause
13259 @kindex show task@r{, Hurd commands}
13260 Show the current state of task suspension.
13262 @item set task detach-suspend-count
13263 @cindex task suspend count
13264 @cindex detach from task, @sc{gnu} Hurd
13265 This command sets the suspend count the task will be left with when
13266 @value{GDBN} detaches from it.
13268 @item show task detach-suspend-count
13269 Show the suspend count the task will be left with when detaching.
13271 @item set task exception-port
13272 @itemx set task excp
13273 @cindex task exception port, @sc{gnu} Hurd
13274 This command sets the task exception port to which @value{GDBN} will
13275 forward exceptions. The argument should be the value of the @dfn{send
13276 rights} of the task. @code{set task excp} is a shorthand alias.
13278 @item set noninvasive
13279 @cindex noninvasive task options
13280 This command switches @value{GDBN} to a mode that is the least
13281 invasive as far as interfering with the inferior is concerned. This
13282 is the same as using @code{set task pause}, @code{set exceptions}, and
13283 @code{set signals} to values opposite to the defaults.
13285 @item info send-rights
13286 @itemx info receive-rights
13287 @itemx info port-rights
13288 @itemx info port-sets
13289 @itemx info dead-names
13292 @cindex send rights, @sc{gnu} Hurd
13293 @cindex receive rights, @sc{gnu} Hurd
13294 @cindex port rights, @sc{gnu} Hurd
13295 @cindex port sets, @sc{gnu} Hurd
13296 @cindex dead names, @sc{gnu} Hurd
13297 These commands display information about, respectively, send rights,
13298 receive rights, port rights, port sets, and dead names of a task.
13299 There are also shorthand aliases: @code{info ports} for @code{info
13300 port-rights} and @code{info psets} for @code{info port-sets}.
13302 @item set thread pause
13303 @kindex set thread@r{, Hurd command}
13304 @cindex thread properties, @sc{gnu} Hurd
13305 @cindex pause current thread (@sc{gnu} Hurd)
13306 This command toggles current thread suspension when @value{GDBN} has
13307 control. Setting it to on takes effect immediately, and the current
13308 thread is suspended whenever @value{GDBN} gets control. Setting it to
13309 off will take effect the next time the inferior is continued.
13310 Normally, this command has no effect, since when @value{GDBN} has
13311 control, the whole task is suspended. However, if you used @code{set
13312 task pause off} (see above), this command comes in handy to suspend
13313 only the current thread.
13315 @item show thread pause
13316 @kindex show thread@r{, Hurd command}
13317 This command shows the state of current thread suspension.
13319 @item set thread run
13320 This comamnd sets whether the current thread is allowed to run.
13322 @item show thread run
13323 Show whether the current thread is allowed to run.
13325 @item set thread detach-suspend-count
13326 @cindex thread suspend count, @sc{gnu} Hurd
13327 @cindex detach from thread, @sc{gnu} Hurd
13328 This command sets the suspend count @value{GDBN} will leave on a
13329 thread when detaching. This number is relative to the suspend count
13330 found by @value{GDBN} when it notices the thread; use @code{set thread
13331 takeover-suspend-count} to force it to an absolute value.
13333 @item show thread detach-suspend-count
13334 Show the suspend count @value{GDBN} will leave on the thread when
13337 @item set thread exception-port
13338 @itemx set thread excp
13339 Set the thread exception port to which to forward exceptions. This
13340 overrides the port set by @code{set task exception-port} (see above).
13341 @code{set thread excp} is the shorthand alias.
13343 @item set thread takeover-suspend-count
13344 Normally, @value{GDBN}'s thread suspend counts are relative to the
13345 value @value{GDBN} finds when it notices each thread. This command
13346 changes the suspend counts to be absolute instead.
13348 @item set thread default
13349 @itemx show thread default
13350 @cindex thread default settings, @sc{gnu} Hurd
13351 Each of the above @code{set thread} commands has a @code{set thread
13352 default} counterpart (e.g., @code{set thread default pause}, @code{set
13353 thread default exception-port}, etc.). The @code{thread default}
13354 variety of commands sets the default thread properties for all
13355 threads; you can then change the properties of individual threads with
13356 the non-default commands.
13361 @subsection QNX Neutrino
13362 @cindex QNX Neutrino
13364 @value{GDBN} provides the following commands specific to the QNX
13368 @item set debug nto-debug
13369 @kindex set debug nto-debug
13370 When set to on, enables debugging messages specific to the QNX
13373 @item show debug nto-debug
13374 @kindex show debug nto-debug
13375 Show the current state of QNX Neutrino messages.
13380 @section Embedded Operating Systems
13382 This section describes configurations involving the debugging of
13383 embedded operating systems that are available for several different
13387 * VxWorks:: Using @value{GDBN} with VxWorks
13390 @value{GDBN} includes the ability to debug programs running on
13391 various real-time operating systems.
13394 @subsection Using @value{GDBN} with VxWorks
13400 @kindex target vxworks
13401 @item target vxworks @var{machinename}
13402 A VxWorks system, attached via TCP/IP. The argument @var{machinename}
13403 is the target system's machine name or IP address.
13407 On VxWorks, @code{load} links @var{filename} dynamically on the
13408 current target system as well as adding its symbols in @value{GDBN}.
13410 @value{GDBN} enables developers to spawn and debug tasks running on networked
13411 VxWorks targets from a Unix host. Already-running tasks spawned from
13412 the VxWorks shell can also be debugged. @value{GDBN} uses code that runs on
13413 both the Unix host and on the VxWorks target. The program
13414 @code{@value{GDBP}} is installed and executed on the Unix host. (It may be
13415 installed with the name @code{vxgdb}, to distinguish it from a
13416 @value{GDBN} for debugging programs on the host itself.)
13419 @item VxWorks-timeout @var{args}
13420 @kindex vxworks-timeout
13421 All VxWorks-based targets now support the option @code{vxworks-timeout}.
13422 This option is set by the user, and @var{args} represents the number of
13423 seconds @value{GDBN} waits for responses to rpc's. You might use this if
13424 your VxWorks target is a slow software simulator or is on the far side
13425 of a thin network line.
13428 The following information on connecting to VxWorks was current when
13429 this manual was produced; newer releases of VxWorks may use revised
13432 @findex INCLUDE_RDB
13433 To use @value{GDBN} with VxWorks, you must rebuild your VxWorks kernel
13434 to include the remote debugging interface routines in the VxWorks
13435 library @file{rdb.a}. To do this, define @code{INCLUDE_RDB} in the
13436 VxWorks configuration file @file{configAll.h} and rebuild your VxWorks
13437 kernel. The resulting kernel contains @file{rdb.a}, and spawns the
13438 source debugging task @code{tRdbTask} when VxWorks is booted. For more
13439 information on configuring and remaking VxWorks, see the manufacturer's
13441 @c VxWorks, see the @cite{VxWorks Programmer's Guide}.
13443 Once you have included @file{rdb.a} in your VxWorks system image and set
13444 your Unix execution search path to find @value{GDBN}, you are ready to
13445 run @value{GDBN}. From your Unix host, run @code{@value{GDBP}} (or
13446 @code{vxgdb}, depending on your installation).
13448 @value{GDBN} comes up showing the prompt:
13455 * VxWorks Connection:: Connecting to VxWorks
13456 * VxWorks Download:: VxWorks download
13457 * VxWorks Attach:: Running tasks
13460 @node VxWorks Connection
13461 @subsubsection Connecting to VxWorks
13463 The @value{GDBN} command @code{target} lets you connect to a VxWorks target on the
13464 network. To connect to a target whose host name is ``@code{tt}'', type:
13467 (vxgdb) target vxworks tt
13471 @value{GDBN} displays messages like these:
13474 Attaching remote machine across net...
13479 @value{GDBN} then attempts to read the symbol tables of any object modules
13480 loaded into the VxWorks target since it was last booted. @value{GDBN} locates
13481 these files by searching the directories listed in the command search
13482 path (@pxref{Environment, ,Your program's environment}); if it fails
13483 to find an object file, it displays a message such as:
13486 prog.o: No such file or directory.
13489 When this happens, add the appropriate directory to the search path with
13490 the @value{GDBN} command @code{path}, and execute the @code{target}
13493 @node VxWorks Download
13494 @subsubsection VxWorks download
13496 @cindex download to VxWorks
13497 If you have connected to the VxWorks target and you want to debug an
13498 object that has not yet been loaded, you can use the @value{GDBN}
13499 @code{load} command to download a file from Unix to VxWorks
13500 incrementally. The object file given as an argument to the @code{load}
13501 command is actually opened twice: first by the VxWorks target in order
13502 to download the code, then by @value{GDBN} in order to read the symbol
13503 table. This can lead to problems if the current working directories on
13504 the two systems differ. If both systems have NFS mounted the same
13505 filesystems, you can avoid these problems by using absolute paths.
13506 Otherwise, it is simplest to set the working directory on both systems
13507 to the directory in which the object file resides, and then to reference
13508 the file by its name, without any path. For instance, a program
13509 @file{prog.o} may reside in @file{@var{vxpath}/vw/demo/rdb} in VxWorks
13510 and in @file{@var{hostpath}/vw/demo/rdb} on the host. To load this
13511 program, type this on VxWorks:
13514 -> cd "@var{vxpath}/vw/demo/rdb"
13518 Then, in @value{GDBN}, type:
13521 (vxgdb) cd @var{hostpath}/vw/demo/rdb
13522 (vxgdb) load prog.o
13525 @value{GDBN} displays a response similar to this:
13528 Reading symbol data from wherever/vw/demo/rdb/prog.o... done.
13531 You can also use the @code{load} command to reload an object module
13532 after editing and recompiling the corresponding source file. Note that
13533 this makes @value{GDBN} delete all currently-defined breakpoints,
13534 auto-displays, and convenience variables, and to clear the value
13535 history. (This is necessary in order to preserve the integrity of
13536 debugger's data structures that reference the target system's symbol
13539 @node VxWorks Attach
13540 @subsubsection Running tasks
13542 @cindex running VxWorks tasks
13543 You can also attach to an existing task using the @code{attach} command as
13547 (vxgdb) attach @var{task}
13551 where @var{task} is the VxWorks hexadecimal task ID. The task can be running
13552 or suspended when you attach to it. Running tasks are suspended at
13553 the time of attachment.
13555 @node Embedded Processors
13556 @section Embedded Processors
13558 This section goes into details specific to particular embedded
13561 @cindex send command to simulator
13562 Whenever a specific embedded processor has a simulator, @value{GDBN}
13563 allows to send an arbitrary command to the simulator.
13566 @item sim @var{command}
13567 @kindex sim@r{, a command}
13568 Send an arbitrary @var{command} string to the simulator. Consult the
13569 documentation for the specific simulator in use for information about
13570 acceptable commands.
13576 * H8/300:: Renesas H8/300
13577 * H8/500:: Renesas H8/500
13578 * M32R/D:: Renesas M32R/D
13579 * M68K:: Motorola M68K
13580 * MIPS Embedded:: MIPS Embedded
13581 * OpenRISC 1000:: OpenRisc 1000
13582 * PA:: HP PA Embedded
13585 * Sparclet:: Tsqware Sparclet
13586 * Sparclite:: Fujitsu Sparclite
13587 * ST2000:: Tandem ST2000
13588 * Z8000:: Zilog Z8000
13591 * Super-H:: Renesas Super-H
13592 * WinCE:: Windows CE child processes
13601 @item target rdi @var{dev}
13602 ARM Angel monitor, via RDI library interface to ADP protocol. You may
13603 use this target to communicate with both boards running the Angel
13604 monitor, or with the EmbeddedICE JTAG debug device.
13607 @item target rdp @var{dev}
13612 @value{GDBN} provides the following ARM-specific commands:
13615 @item set arm disassembler
13617 This commands selects from a list of disassembly styles. The
13618 @code{"std"} style is the standard style.
13620 @item show arm disassembler
13622 Show the current disassembly style.
13624 @item set arm apcs32
13625 @cindex ARM 32-bit mode
13626 This command toggles ARM operation mode between 32-bit and 26-bit.
13628 @item show arm apcs32
13629 Display the current usage of the ARM 32-bit mode.
13631 @item set arm fpu @var{fputype}
13632 This command sets the ARM floating-point unit (FPU) type. The
13633 argument @var{fputype} can be one of these:
13637 Determine the FPU type by querying the OS ABI.
13639 Software FPU, with mixed-endian doubles on little-endian ARM
13642 GCC-compiled FPA co-processor.
13644 Software FPU with pure-endian doubles.
13650 Show the current type of the FPU.
13653 This command forces @value{GDBN} to use the specified ABI.
13656 Show the currently used ABI.
13658 @item set debug arm
13659 Toggle whether to display ARM-specific debugging messages from the ARM
13660 target support subsystem.
13662 @item show debug arm
13663 Show whether ARM-specific debugging messages are enabled.
13666 The following commands are available when an ARM target is debugged
13667 using the RDI interface:
13670 @item rdilogfile @r{[}@var{file}@r{]}
13672 @cindex ADP (Angel Debugger Protocol) logging
13673 Set the filename for the ADP (Angel Debugger Protocol) packet log.
13674 With an argument, sets the log file to the specified @var{file}. With
13675 no argument, show the current log file name. The default log file is
13678 @item rdilogenable @r{[}@var{arg}@r{]}
13679 @kindex rdilogenable
13680 Control logging of ADP packets. With an argument of 1 or @code{"yes"}
13681 enables logging, with an argument 0 or @code{"no"} disables it. With
13682 no arguments displays the current setting. When logging is enabled,
13683 ADP packets exchanged between @value{GDBN} and the RDI target device
13684 are logged to a file.
13686 @item set rdiromatzero
13687 @kindex set rdiromatzero
13688 @cindex ROM at zero address, RDI
13689 Tell @value{GDBN} whether the target has ROM at address 0. If on,
13690 vector catching is disabled, so that zero address can be used. If off
13691 (the default), vector catching is enabled. For this command to take
13692 effect, it needs to be invoked prior to the @code{target rdi} command.
13694 @item show rdiromatzero
13695 @kindex show rdiromatzero
13696 Show the current setting of ROM at zero address.
13698 @item set rdiheartbeat
13699 @kindex set rdiheartbeat
13700 @cindex RDI heartbeat
13701 Enable or disable RDI heartbeat packets. It is not recommended to
13702 turn on this option, since it confuses ARM and EPI JTAG interface, as
13703 well as the Angel monitor.
13705 @item show rdiheartbeat
13706 @kindex show rdiheartbeat
13707 Show the setting of RDI heartbeat packets.
13712 @subsection Renesas H8/300
13716 @kindex target hms@r{, with H8/300}
13717 @item target hms @var{dev}
13718 A Renesas SH, H8/300, or H8/500 board, attached via serial line to your host.
13719 Use special commands @code{device} and @code{speed} to control the serial
13720 line and the communications speed used.
13722 @kindex target e7000@r{, with H8/300}
13723 @item target e7000 @var{dev}
13724 E7000 emulator for Renesas H8 and SH.
13726 @kindex target sh3@r{, with H8/300}
13727 @kindex target sh3e@r{, with H8/300}
13728 @item target sh3 @var{dev}
13729 @itemx target sh3e @var{dev}
13730 Renesas SH-3 and SH-3E target systems.
13734 @cindex download to H8/300 or H8/500
13735 @cindex H8/300 or H8/500 download
13736 @cindex download to Renesas SH
13737 @cindex Renesas SH download
13738 When you select remote debugging to a Renesas SH, H8/300, or H8/500
13739 board, the @code{load} command downloads your program to the Renesas
13740 board and also opens it as the current executable target for
13741 @value{GDBN} on your host (like the @code{file} command).
13743 @value{GDBN} needs to know these things to talk to your
13744 Renesas SH, H8/300, or H8/500:
13748 that you want to use @samp{target hms}, the remote debugging interface
13749 for Renesas microprocessors, or @samp{target e7000}, the in-circuit
13750 emulator for the Renesas SH and the Renesas 300H. (@samp{target hms} is
13751 the default when @value{GDBN} is configured specifically for the Renesas SH,
13752 H8/300, or H8/500.)
13755 what serial device connects your host to your Renesas board (the first
13756 serial device available on your host is the default).
13759 what speed to use over the serial device.
13763 * Renesas Boards:: Connecting to Renesas boards.
13764 * Renesas ICE:: Using the E7000 In-Circuit Emulator.
13765 * Renesas Special:: Special @value{GDBN} commands for Renesas micros.
13768 @node Renesas Boards
13769 @subsubsection Connecting to Renesas boards
13771 @c only for Unix hosts
13773 @cindex serial device, Renesas micros
13774 Use the special @code{@value{GDBN}} command @samp{device @var{port}} if you
13775 need to explicitly set the serial device. The default @var{port} is the
13776 first available port on your host. This is only necessary on Unix
13777 hosts, where it is typically something like @file{/dev/ttya}.
13780 @cindex serial line speed, Renesas micros
13781 @code{@value{GDBN}} has another special command to set the communications
13782 speed: @samp{speed @var{bps}}. This command also is only used from Unix
13783 hosts; on DOS hosts, set the line speed as usual from outside @value{GDBN} with
13784 the DOS @code{mode} command (for instance,
13785 @w{@kbd{mode com2:9600,n,8,1,p}} for a 9600@dmn{bps} connection).
13787 The @samp{device} and @samp{speed} commands are available only when you
13788 use a Unix host to debug your Renesas microprocessor programs. If you
13790 @value{GDBN} depends on an auxiliary terminate-and-stay-resident program
13791 called @code{asynctsr} to communicate with the development board
13792 through a PC serial port. You must also use the DOS @code{mode} command
13793 to set up the serial port on the DOS side.
13795 The following sample session illustrates the steps needed to start a
13796 program under @value{GDBN} control on an H8/300. The example uses a
13797 sample H8/300 program called @file{t.x}. The procedure is the same for
13798 the Renesas SH and the H8/500.
13800 First hook up your development board. In this example, we use a
13801 board attached to serial port @code{COM2}; if you use a different serial
13802 port, substitute its name in the argument of the @code{mode} command.
13803 When you call @code{asynctsr}, the auxiliary comms program used by the
13804 debugger, you give it just the numeric part of the serial port's name;
13805 for example, @samp{asyncstr 2} below runs @code{asyncstr} on
13809 C:\H8300\TEST> asynctsr 2
13810 C:\H8300\TEST> mode com2:9600,n,8,1,p
13812 Resident portion of MODE loaded
13814 COM2: 9600, n, 8, 1, p
13819 @emph{Warning:} We have noticed a bug in PC-NFS that conflicts with
13820 @code{asynctsr}. If you also run PC-NFS on your DOS host, you may need to
13821 disable it, or even boot without it, to use @code{asynctsr} to control
13822 your development board.
13825 @kindex target hms@r{, and serial protocol}
13826 Now that serial communications are set up, and the development board is
13827 connected, you can start up @value{GDBN}. Call @code{@value{GDBN}} with
13828 the name of your program as the argument. @code{@value{GDBN}} prompts
13829 you, as usual, with the prompt @samp{(@value{GDBP})}. Use two special
13830 commands to begin your debugging session: @samp{target hms} to specify
13831 cross-debugging to the Renesas board, and the @code{load} command to
13832 download your program to the board. @code{load} displays the names of
13833 the program's sections, and a @samp{*} for each 2K of data downloaded.
13834 (If you want to refresh @value{GDBN} data on symbols or on the
13835 executable file without downloading, use the @value{GDBN} commands
13836 @code{file} or @code{symbol-file}. These commands, and @code{load}
13837 itself, are described in @ref{Files,,Commands to specify files}.)
13840 (eg-C:\H8300\TEST) @value{GDBP} t.x
13841 @value{GDBN} is free software and you are welcome to distribute copies
13842 of it under certain conditions; type "show copying" to see
13844 There is absolutely no warranty for @value{GDBN}; type "show warranty"
13846 @value{GDBN} @value{GDBVN}, Copyright 1992 Free Software Foundation, Inc...
13847 (@value{GDBP}) target hms
13848 Connected to remote H8/300 HMS system.
13849 (@value{GDBP}) load t.x
13850 .text : 0x8000 .. 0xabde ***********
13851 .data : 0xabde .. 0xad30 *
13852 .stack : 0xf000 .. 0xf014 *
13855 At this point, you're ready to run or debug your program. From here on,
13856 you can use all the usual @value{GDBN} commands. The @code{break} command
13857 sets breakpoints; the @code{run} command starts your program;
13858 @code{print} or @code{x} display data; the @code{continue} command
13859 resumes execution after stopping at a breakpoint. You can use the
13860 @code{help} command at any time to find out more about @value{GDBN} commands.
13862 Remember, however, that @emph{operating system} facilities aren't
13863 available on your development board; for example, if your program hangs,
13864 you can't send an interrupt---but you can press the @sc{reset} switch!
13866 Use the @sc{reset} button on the development board
13869 to interrupt your program (don't use @kbd{ctl-C} on the DOS host---it has
13870 no way to pass an interrupt signal to the development board); and
13873 to return to the @value{GDBN} command prompt after your program finishes
13874 normally. The communications protocol provides no other way for @value{GDBN}
13875 to detect program completion.
13878 In either case, @value{GDBN} sees the effect of a @sc{reset} on the
13879 development board as a ``normal exit'' of your program.
13882 @subsubsection Using the E7000 in-circuit emulator
13884 @kindex target e7000@r{, with Renesas ICE}
13885 You can use the E7000 in-circuit emulator to develop code for either the
13886 Renesas SH or the H8/300H. Use one of these forms of the @samp{target
13887 e7000} command to connect @value{GDBN} to your E7000:
13890 @item target e7000 @var{port} @var{speed}
13891 Use this form if your E7000 is connected to a serial port. The
13892 @var{port} argument identifies what serial port to use (for example,
13893 @samp{com2}). The third argument is the line speed in bits per second
13894 (for example, @samp{9600}).
13896 @item target e7000 @var{hostname}
13897 If your E7000 is installed as a host on a TCP/IP network, you can just
13898 specify its hostname; @value{GDBN} uses @code{telnet} to connect.
13901 The following special commands are available when debugging with the
13905 @item e7000 @var{command}
13907 @cindex send command to E7000 monitor
13908 This sends the specified @var{command} to the E7000 monitor.
13910 @item ftplogin @var{machine} @var{username} @var{password} @var{dir}
13911 @kindex ftplogin@r{, E7000}
13912 This command records information for subsequent interface with the
13913 E7000 monitor via the FTP protocol: @value{GDBN} will log into the
13914 named @var{machine} using specified @var{username} and @var{password},
13915 and then chdir to the named directory @var{dir}.
13917 @item ftpload @var{file}
13918 @kindex ftpload@r{, E7000}
13919 This command uses credentials recorded by @code{ftplogin} to fetch and
13920 load the named @var{file} from the E7000 monitor.
13923 @kindex drain@r{, E7000}
13924 This command drains any pending text buffers stored on the E7000.
13926 @item set usehardbreakpoints
13927 @itemx show usehardbreakpoints
13928 @kindex set usehardbreakpoints@r{, E7000}
13929 @kindex show usehardbreakpoints@r{, E7000}
13930 @cindex hardware breakpoints, and E7000
13931 These commands set and show the use of hardware breakpoints for all
13932 breakpoints. @xref{Set Breaks, hardware-assisted breakpoint}, for
13933 more information about using hardware breakpoints selectively.
13936 @node Renesas Special
13937 @subsubsection Special @value{GDBN} commands for Renesas micros
13939 Some @value{GDBN} commands are available only for the H8/300:
13943 @kindex set machine
13944 @kindex show machine
13945 @item set machine h8300
13946 @itemx set machine h8300h
13947 Condition @value{GDBN} for one of the two variants of the H8/300
13948 architecture with @samp{set machine}. You can use @samp{show machine}
13949 to check which variant is currently in effect.
13958 @kindex set memory @var{mod}
13959 @cindex memory models, H8/500
13960 @item set memory @var{mod}
13962 Specify which H8/500 memory model (@var{mod}) you are using with
13963 @samp{set memory}; check which memory model is in effect with @samp{show
13964 memory}. The accepted values for @var{mod} are @code{small},
13965 @code{big}, @code{medium}, and @code{compact}.
13970 @subsection Renesas M32R/D and M32R/SDI
13973 @kindex target m32r
13974 @item target m32r @var{dev}
13975 Renesas M32R/D ROM monitor.
13977 @kindex target m32rsdi
13978 @item target m32rsdi @var{dev}
13979 Renesas M32R SDI server, connected via parallel port to the board.
13982 The following @value{GDBN} commands are specific to the M32R monitor:
13985 @item set download-path @var{path}
13986 @kindex set download-path
13987 @cindex find downloadable @sc{srec} files (M32R)
13988 Set the default path for finding donwloadable @sc{srec} files.
13990 @item show download-path
13991 @kindex show download-path
13992 Show the default path for downloadable @sc{srec} files.
13994 @item set board-address @var{addr}
13995 @kindex set board-address
13996 @cindex M32-EVA target board address
13997 Set the IP address for the M32R-EVA target board.
13999 @item show board-address
14000 @kindex show board-address
14001 Show the current IP address of the target board.
14003 @item set server-address @var{addr}
14004 @kindex set server-address
14005 @cindex download server address (M32R)
14006 Set the IP address for the download server, which is the @value{GDBN}'s
14009 @item show server-address
14010 @kindex show server-address
14011 Display the IP address of the download server.
14013 @item upload @r{[}@var{file}@r{]}
14014 @kindex upload@r{, M32R}
14015 Upload the specified @sc{srec} @var{file} via the monitor's Ethernet
14016 upload capability. If no @var{file} argument is given, the current
14017 executable file is uploaded.
14019 @item tload @r{[}@var{file}@r{]}
14020 @kindex tload@r{, M32R}
14021 Test the @code{upload} command.
14024 The following commands are available for M32R/SDI:
14029 @cindex reset SDI connection, M32R
14030 This command resets the SDI connection.
14034 This command shows the SDI connection status.
14037 @kindex debug_chaos
14038 @cindex M32R/Chaos debugging
14039 Instructs the remote that M32R/Chaos debugging is to be used.
14041 @item use_debug_dma
14042 @kindex use_debug_dma
14043 Instructs the remote to use the DEBUG_DMA method of accessing memory.
14046 @kindex use_mon_code
14047 Instructs the remote to use the MON_CODE method of accessing memory.
14050 @kindex use_ib_break
14051 Instructs the remote to set breakpoints by IB break.
14053 @item use_dbt_break
14054 @kindex use_dbt_break
14055 Instructs the remote to set breakpoints by DBT.
14061 The Motorola m68k configuration includes ColdFire support, and
14062 target command for the following ROM monitors.
14066 @kindex target abug
14067 @item target abug @var{dev}
14068 ABug ROM monitor for M68K.
14070 @kindex target cpu32bug
14071 @item target cpu32bug @var{dev}
14072 CPU32BUG monitor, running on a CPU32 (M68K) board.
14074 @kindex target dbug
14075 @item target dbug @var{dev}
14076 dBUG ROM monitor for Motorola ColdFire.
14079 @item target est @var{dev}
14080 EST-300 ICE monitor, running on a CPU32 (M68K) board.
14082 @kindex target rom68k
14083 @item target rom68k @var{dev}
14084 ROM 68K monitor, running on an M68K IDP board.
14090 @kindex target rombug
14091 @item target rombug @var{dev}
14092 ROMBUG ROM monitor for OS/9000.
14096 @node MIPS Embedded
14097 @subsection MIPS Embedded
14099 @cindex MIPS boards
14100 @value{GDBN} can use the MIPS remote debugging protocol to talk to a
14101 MIPS board attached to a serial line. This is available when
14102 you configure @value{GDBN} with @samp{--target=mips-idt-ecoff}.
14105 Use these @value{GDBN} commands to specify the connection to your target board:
14108 @item target mips @var{port}
14109 @kindex target mips @var{port}
14110 To run a program on the board, start up @code{@value{GDBP}} with the
14111 name of your program as the argument. To connect to the board, use the
14112 command @samp{target mips @var{port}}, where @var{port} is the name of
14113 the serial port connected to the board. If the program has not already
14114 been downloaded to the board, you may use the @code{load} command to
14115 download it. You can then use all the usual @value{GDBN} commands.
14117 For example, this sequence connects to the target board through a serial
14118 port, and loads and runs a program called @var{prog} through the
14122 host$ @value{GDBP} @var{prog}
14123 @value{GDBN} is free software and @dots{}
14124 (@value{GDBP}) target mips /dev/ttyb
14125 (@value{GDBP}) load @var{prog}
14129 @item target mips @var{hostname}:@var{portnumber}
14130 On some @value{GDBN} host configurations, you can specify a TCP
14131 connection (for instance, to a serial line managed by a terminal
14132 concentrator) instead of a serial port, using the syntax
14133 @samp{@var{hostname}:@var{portnumber}}.
14135 @item target pmon @var{port}
14136 @kindex target pmon @var{port}
14139 @item target ddb @var{port}
14140 @kindex target ddb @var{port}
14141 NEC's DDB variant of PMON for Vr4300.
14143 @item target lsi @var{port}
14144 @kindex target lsi @var{port}
14145 LSI variant of PMON.
14147 @kindex target r3900
14148 @item target r3900 @var{dev}
14149 Densan DVE-R3900 ROM monitor for Toshiba R3900 Mips.
14151 @kindex target array
14152 @item target array @var{dev}
14153 Array Tech LSI33K RAID controller board.
14159 @value{GDBN} also supports these special commands for MIPS targets:
14162 @item set mipsfpu double
14163 @itemx set mipsfpu single
14164 @itemx set mipsfpu none
14165 @itemx set mipsfpu auto
14166 @itemx show mipsfpu
14167 @kindex set mipsfpu
14168 @kindex show mipsfpu
14169 @cindex MIPS remote floating point
14170 @cindex floating point, MIPS remote
14171 If your target board does not support the MIPS floating point
14172 coprocessor, you should use the command @samp{set mipsfpu none} (if you
14173 need this, you may wish to put the command in your @value{GDBN} init
14174 file). This tells @value{GDBN} how to find the return value of
14175 functions which return floating point values. It also allows
14176 @value{GDBN} to avoid saving the floating point registers when calling
14177 functions on the board. If you are using a floating point coprocessor
14178 with only single precision floating point support, as on the @sc{r4650}
14179 processor, use the command @samp{set mipsfpu single}. The default
14180 double precision floating point coprocessor may be selected using
14181 @samp{set mipsfpu double}.
14183 In previous versions the only choices were double precision or no
14184 floating point, so @samp{set mipsfpu on} will select double precision
14185 and @samp{set mipsfpu off} will select no floating point.
14187 As usual, you can inquire about the @code{mipsfpu} variable with
14188 @samp{show mipsfpu}.
14190 @item set timeout @var{seconds}
14191 @itemx set retransmit-timeout @var{seconds}
14192 @itemx show timeout
14193 @itemx show retransmit-timeout
14194 @cindex @code{timeout}, MIPS protocol
14195 @cindex @code{retransmit-timeout}, MIPS protocol
14196 @kindex set timeout
14197 @kindex show timeout
14198 @kindex set retransmit-timeout
14199 @kindex show retransmit-timeout
14200 You can control the timeout used while waiting for a packet, in the MIPS
14201 remote protocol, with the @code{set timeout @var{seconds}} command. The
14202 default is 5 seconds. Similarly, you can control the timeout used while
14203 waiting for an acknowledgement of a packet with the @code{set
14204 retransmit-timeout @var{seconds}} command. The default is 3 seconds.
14205 You can inspect both values with @code{show timeout} and @code{show
14206 retransmit-timeout}. (These commands are @emph{only} available when
14207 @value{GDBN} is configured for @samp{--target=mips-idt-ecoff}.)
14209 The timeout set by @code{set timeout} does not apply when @value{GDBN}
14210 is waiting for your program to stop. In that case, @value{GDBN} waits
14211 forever because it has no way of knowing how long the program is going
14212 to run before stopping.
14214 @item set syn-garbage-limit @var{num}
14215 @kindex set syn-garbage-limit@r{, MIPS remote}
14216 @cindex synchronize with remote MIPS target
14217 Limit the maximum number of characters @value{GDBN} should ignore when
14218 it tries to synchronize with the remote target. The default is 10
14219 characters. Setting the limit to -1 means there's no limit.
14221 @item show syn-garbage-limit
14222 @kindex show syn-garbage-limit@r{, MIPS remote}
14223 Show the current limit on the number of characters to ignore when
14224 trying to synchronize with the remote system.
14226 @item set monitor-prompt @var{prompt}
14227 @kindex set monitor-prompt@r{, MIPS remote}
14228 @cindex remote monitor prompt
14229 Tell @value{GDBN} to expect the specified @var{prompt} string from the
14230 remote monitor. The default depends on the target:
14240 @item show monitor-prompt
14241 @kindex show monitor-prompt@r{, MIPS remote}
14242 Show the current strings @value{GDBN} expects as the prompt from the
14245 @item set monitor-warnings
14246 @kindex set monitor-warnings@r{, MIPS remote}
14247 Enable or disable monitor warnings about hardware breakpoints. This
14248 has effect only for the @code{lsi} target. When on, @value{GDBN} will
14249 display warning messages whose codes are returned by the @code{lsi}
14250 PMON monitor for breakpoint commands.
14252 @item show monitor-warnings
14253 @kindex show monitor-warnings@r{, MIPS remote}
14254 Show the current setting of printing monitor warnings.
14256 @item pmon @var{command}
14257 @kindex pmon@r{, MIPS remote}
14258 @cindex send PMON command
14259 This command allows sending an arbitrary @var{command} string to the
14260 monitor. The monitor must be in debug mode for this to work.
14263 @node OpenRISC 1000
14264 @subsection OpenRISC 1000
14265 @cindex OpenRISC 1000
14267 @cindex or1k boards
14268 See OR1k Architecture document (@uref{www.opencores.org}) for more information
14269 about platform and commands.
14273 @kindex target jtag
14274 @item target jtag jtag://@var{host}:@var{port}
14276 Connects to remote JTAG server.
14277 JTAG remote server can be either an or1ksim or JTAG server,
14278 connected via parallel port to the board.
14280 Example: @code{target jtag jtag://localhost:9999}
14283 @item or1ksim @var{command}
14284 If connected to @code{or1ksim} OpenRISC 1000 Architectural
14285 Simulator, proprietary commands can be executed.
14287 @kindex info or1k spr
14288 @item info or1k spr
14289 Displays spr groups.
14291 @item info or1k spr @var{group}
14292 @itemx info or1k spr @var{groupno}
14293 Displays register names in selected group.
14295 @item info or1k spr @var{group} @var{register}
14296 @itemx info or1k spr @var{register}
14297 @itemx info or1k spr @var{groupno} @var{registerno}
14298 @itemx info or1k spr @var{registerno}
14299 Shows information about specified spr register.
14302 @item spr @var{group} @var{register} @var{value}
14303 @itemx spr @var{register @var{value}}
14304 @itemx spr @var{groupno} @var{registerno @var{value}}
14305 @itemx spr @var{registerno @var{value}}
14306 Writes @var{value} to specified spr register.
14309 Some implementations of OpenRISC 1000 Architecture also have hardware trace.
14310 It is very similar to @value{GDBN} trace, except it does not interfere with normal
14311 program execution and is thus much faster. Hardware breakpoints/watchpoint
14312 triggers can be set using:
14315 Load effective address/data
14317 Store effective address/data
14319 Access effective address ($SEA or $LEA) or data ($SDATA/$LDATA)
14324 When triggered, it can capture low level data, like: @code{PC}, @code{LSEA},
14325 @code{LDATA}, @code{SDATA}, @code{READSPR}, @code{WRITESPR}, @code{INSTR}.
14327 @code{htrace} commands:
14328 @cindex OpenRISC 1000 htrace
14331 @item hwatch @var{conditional}
14332 Set hardware watchpoint on combination of Load/Store Effecive Address(es)
14333 or Data. For example:
14335 @code{hwatch ($LEA == my_var) && ($LDATA < 50) || ($SEA == my_var) && ($SDATA >= 50)}
14337 @code{hwatch ($LEA == my_var) && ($LDATA < 50) || ($SEA == my_var) && ($SDATA >= 50)}
14341 Display information about current HW trace configuration.
14343 @item htrace trigger @var{conditional}
14344 Set starting criteria for HW trace.
14346 @item htrace qualifier @var{conditional}
14347 Set acquisition qualifier for HW trace.
14349 @item htrace stop @var{conditional}
14350 Set HW trace stopping criteria.
14352 @item htrace record [@var{data}]*
14353 Selects the data to be recorded, when qualifier is met and HW trace was
14356 @item htrace enable
14357 @itemx htrace disable
14358 Enables/disables the HW trace.
14360 @item htrace rewind [@var{filename}]
14361 Clears currently recorded trace data.
14363 If filename is specified, new trace file is made and any newly collected data
14364 will be written there.
14366 @item htrace print [@var{start} [@var{len}]]
14367 Prints trace buffer, using current record configuration.
14369 @item htrace mode continuous
14370 Set continuous trace mode.
14372 @item htrace mode suspend
14373 Set suspend trace mode.
14378 @subsection PowerPC
14381 @kindex target dink32
14382 @item target dink32 @var{dev}
14383 DINK32 ROM monitor.
14385 @kindex target ppcbug
14386 @item target ppcbug @var{dev}
14387 @kindex target ppcbug1
14388 @item target ppcbug1 @var{dev}
14389 PPCBUG ROM monitor for PowerPC.
14392 @item target sds @var{dev}
14393 SDS monitor, running on a PowerPC board (such as Motorola's ADS).
14396 @cindex SDS protocol
14397 The following commands specifi to the SDS protocol are supported
14401 @item set sdstimeout @var{nsec}
14402 @kindex set sdstimeout
14403 Set the timeout for SDS protocol reads to be @var{nsec} seconds. The
14404 default is 2 seconds.
14406 @item show sdstimeout
14407 @kindex show sdstimeout
14408 Show the current value of the SDS timeout.
14410 @item sds @var{command}
14411 @kindex sds@r{, a command}
14412 Send the specified @var{command} string to the SDS monitor.
14417 @subsection HP PA Embedded
14421 @kindex target op50n
14422 @item target op50n @var{dev}
14423 OP50N monitor, running on an OKI HPPA board.
14425 @kindex target w89k
14426 @item target w89k @var{dev}
14427 W89K monitor, running on a Winbond HPPA board.
14432 @subsection Renesas SH
14436 @kindex target hms@r{, with Renesas SH}
14437 @item target hms @var{dev}
14438 A Renesas SH board attached via serial line to your host. Use special
14439 commands @code{device} and @code{speed} to control the serial line and
14440 the communications speed used.
14442 @kindex target e7000@r{, with Renesas SH}
14443 @item target e7000 @var{dev}
14444 E7000 emulator for Renesas SH.
14446 @kindex target sh3@r{, with SH}
14447 @kindex target sh3e@r{, with SH}
14448 @item target sh3 @var{dev}
14449 @item target sh3e @var{dev}
14450 Renesas SH-3 and SH-3E target systems.
14455 @subsection Tsqware Sparclet
14459 @value{GDBN} enables developers to debug tasks running on
14460 Sparclet targets from a Unix host.
14461 @value{GDBN} uses code that runs on
14462 both the Unix host and on the Sparclet target. The program
14463 @code{@value{GDBP}} is installed and executed on the Unix host.
14466 @item remotetimeout @var{args}
14467 @kindex remotetimeout
14468 @value{GDBN} supports the option @code{remotetimeout}.
14469 This option is set by the user, and @var{args} represents the number of
14470 seconds @value{GDBN} waits for responses.
14473 @cindex compiling, on Sparclet
14474 When compiling for debugging, include the options @samp{-g} to get debug
14475 information and @samp{-Ttext} to relocate the program to where you wish to
14476 load it on the target. You may also want to add the options @samp{-n} or
14477 @samp{-N} in order to reduce the size of the sections. Example:
14480 sparclet-aout-gcc prog.c -Ttext 0x12010000 -g -o prog -N
14483 You can use @code{objdump} to verify that the addresses are what you intended:
14486 sparclet-aout-objdump --headers --syms prog
14489 @cindex running, on Sparclet
14491 your Unix execution search path to find @value{GDBN}, you are ready to
14492 run @value{GDBN}. From your Unix host, run @code{@value{GDBP}}
14493 (or @code{sparclet-aout-gdb}, depending on your installation).
14495 @value{GDBN} comes up showing the prompt:
14502 * Sparclet File:: Setting the file to debug
14503 * Sparclet Connection:: Connecting to Sparclet
14504 * Sparclet Download:: Sparclet download
14505 * Sparclet Execution:: Running and debugging
14508 @node Sparclet File
14509 @subsubsection Setting file to debug
14511 The @value{GDBN} command @code{file} lets you choose with program to debug.
14514 (gdbslet) file prog
14518 @value{GDBN} then attempts to read the symbol table of @file{prog}.
14519 @value{GDBN} locates
14520 the file by searching the directories listed in the command search
14522 If the file was compiled with debug information (option "-g"), source
14523 files will be searched as well.
14524 @value{GDBN} locates
14525 the source files by searching the directories listed in the directory search
14526 path (@pxref{Environment, ,Your program's environment}).
14528 to find a file, it displays a message such as:
14531 prog: No such file or directory.
14534 When this happens, add the appropriate directories to the search paths with
14535 the @value{GDBN} commands @code{path} and @code{dir}, and execute the
14536 @code{target} command again.
14538 @node Sparclet Connection
14539 @subsubsection Connecting to Sparclet
14541 The @value{GDBN} command @code{target} lets you connect to a Sparclet target.
14542 To connect to a target on serial port ``@code{ttya}'', type:
14545 (gdbslet) target sparclet /dev/ttya
14546 Remote target sparclet connected to /dev/ttya
14547 main () at ../prog.c:3
14551 @value{GDBN} displays messages like these:
14557 @node Sparclet Download
14558 @subsubsection Sparclet download
14560 @cindex download to Sparclet
14561 Once connected to the Sparclet target,
14562 you can use the @value{GDBN}
14563 @code{load} command to download the file from the host to the target.
14564 The file name and load offset should be given as arguments to the @code{load}
14566 Since the file format is aout, the program must be loaded to the starting
14567 address. You can use @code{objdump} to find out what this value is. The load
14568 offset is an offset which is added to the VMA (virtual memory address)
14569 of each of the file's sections.
14570 For instance, if the program
14571 @file{prog} was linked to text address 0x1201000, with data at 0x12010160
14572 and bss at 0x12010170, in @value{GDBN}, type:
14575 (gdbslet) load prog 0x12010000
14576 Loading section .text, size 0xdb0 vma 0x12010000
14579 If the code is loaded at a different address then what the program was linked
14580 to, you may need to use the @code{section} and @code{add-symbol-file} commands
14581 to tell @value{GDBN} where to map the symbol table.
14583 @node Sparclet Execution
14584 @subsubsection Running and debugging
14586 @cindex running and debugging Sparclet programs
14587 You can now begin debugging the task using @value{GDBN}'s execution control
14588 commands, @code{b}, @code{step}, @code{run}, etc. See the @value{GDBN}
14589 manual for the list of commands.
14593 Breakpoint 1 at 0x12010000: file prog.c, line 3.
14595 Starting program: prog
14596 Breakpoint 1, main (argc=1, argv=0xeffff21c) at prog.c:3
14597 3 char *symarg = 0;
14599 4 char *execarg = "hello!";
14604 @subsection Fujitsu Sparclite
14608 @kindex target sparclite
14609 @item target sparclite @var{dev}
14610 Fujitsu sparclite boards, used only for the purpose of loading.
14611 You must use an additional command to debug the program.
14612 For example: target remote @var{dev} using @value{GDBN} standard
14618 @subsection Tandem ST2000
14620 @value{GDBN} may be used with a Tandem ST2000 phone switch, running Tandem's
14623 To connect your ST2000 to the host system, see the manufacturer's
14624 manual. Once the ST2000 is physically attached, you can run:
14627 target st2000 @var{dev} @var{speed}
14631 to establish it as your debugging environment. @var{dev} is normally
14632 the name of a serial device, such as @file{/dev/ttya}, connected to the
14633 ST2000 via a serial line. You can instead specify @var{dev} as a TCP
14634 connection (for example, to a serial line attached via a terminal
14635 concentrator) using the syntax @code{@var{hostname}:@var{portnumber}}.
14637 The @code{load} and @code{attach} commands are @emph{not} defined for
14638 this target; you must load your program into the ST2000 as you normally
14639 would for standalone operation. @value{GDBN} reads debugging information
14640 (such as symbols) from a separate, debugging version of the program
14641 available on your host computer.
14642 @c FIXME!! This is terribly vague; what little content is here is
14643 @c basically hearsay.
14645 @cindex ST2000 auxiliary commands
14646 These auxiliary @value{GDBN} commands are available to help you with the ST2000
14650 @item st2000 @var{command}
14651 @kindex st2000 @var{cmd}
14652 @cindex STDBUG commands (ST2000)
14653 @cindex commands to STDBUG (ST2000)
14654 Send a @var{command} to the STDBUG monitor. See the manufacturer's
14655 manual for available commands.
14658 @cindex connect (to STDBUG)
14659 Connect the controlling terminal to the STDBUG command monitor. When
14660 you are done interacting with STDBUG, typing either of two character
14661 sequences gets you back to the @value{GDBN} command prompt:
14662 @kbd{@key{RET}~.} (Return, followed by tilde and period) or
14663 @kbd{@key{RET}~@key{C-d}} (Return, followed by tilde and control-D).
14667 @subsection Zilog Z8000
14670 @cindex simulator, Z8000
14671 @cindex Zilog Z8000 simulator
14673 When configured for debugging Zilog Z8000 targets, @value{GDBN} includes
14676 For the Z8000 family, @samp{target sim} simulates either the Z8002 (the
14677 unsegmented variant of the Z8000 architecture) or the Z8001 (the
14678 segmented variant). The simulator recognizes which architecture is
14679 appropriate by inspecting the object code.
14682 @item target sim @var{args}
14684 @kindex target sim@r{, with Z8000}
14685 Debug programs on a simulated CPU. If the simulator supports setup
14686 options, specify them via @var{args}.
14690 After specifying this target, you can debug programs for the simulated
14691 CPU in the same style as programs for your host computer; use the
14692 @code{file} command to load a new program image, the @code{run} command
14693 to run your program, and so on.
14695 As well as making available all the usual machine registers
14696 (@pxref{Registers, ,Registers}), the Z8000 simulator provides three
14697 additional items of information as specially named registers:
14702 Counts clock-ticks in the simulator.
14705 Counts instructions run in the simulator.
14708 Execution time in 60ths of a second.
14712 You can refer to these values in @value{GDBN} expressions with the usual
14713 conventions; for example, @w{@samp{b fputc if $cycles>5000}} sets a
14714 conditional breakpoint that suspends only after at least 5000
14715 simulated clock ticks.
14718 @subsection Atmel AVR
14721 When configured for debugging the Atmel AVR, @value{GDBN} supports the
14722 following AVR-specific commands:
14725 @item info io_registers
14726 @kindex info io_registers@r{, AVR}
14727 @cindex I/O registers (Atmel AVR)
14728 This command displays information about the AVR I/O registers. For
14729 each register, @value{GDBN} prints its number and value.
14736 When configured for debugging CRIS, @value{GDBN} provides the
14737 following CRIS-specific commands:
14740 @item set cris-version @var{ver}
14741 @cindex CRIS version
14742 Set the current CRIS version to @var{ver}, either @samp{10} or @samp{32}.
14743 The CRIS version affects register names and sizes. This command is useful in
14744 case autodetection of the CRIS version fails.
14746 @item show cris-version
14747 Show the current CRIS version.
14749 @item set cris-dwarf2-cfi
14750 @cindex DWARF-2 CFI and CRIS
14751 Set the usage of DWARF-2 CFI for CRIS debugging. The default is @samp{on}.
14752 Change to @samp{off} when using @code{gcc-cris} whose version is below
14755 @item show cris-dwarf2-cfi
14756 Show the current state of using DWARF-2 CFI.
14758 @item set cris-mode @var{mode}
14760 Set the current CRIS mode to @var{mode}. It should only be changed when
14761 debugging in guru mode, in which case it should be set to
14762 @samp{guru} (the default is @samp{normal}).
14764 @item show cris-mode
14765 Show the current CRIS mode.
14769 @subsection Renesas Super-H
14772 For the Renesas Super-H processor, @value{GDBN} provides these
14777 @kindex regs@r{, Super-H}
14778 Show the values of all Super-H registers.
14782 @subsection Windows CE
14785 The following commands are available for Windows CE:
14788 @item set remotedirectory @var{dir}
14789 @kindex set remotedirectory
14790 Tell @value{GDBN} to upload files from the named directory @var{dir}.
14791 The default is @file{/gdb}, i.e.@: the root directory on the current
14794 @item show remotedirectory
14795 @kindex show remotedirectory
14796 Show the current value of the upload directory.
14798 @item set remoteupload @var{method}
14799 @kindex set remoteupload
14800 Set the method used to upload files to remote device. Valid values
14801 for @var{method} are @samp{always}, @samp{newer}, and @samp{never}.
14802 The default is @samp{newer}.
14804 @item show remoteupload
14805 @kindex show remoteupload
14806 Show the current setting of the upload method.
14808 @item set remoteaddhost
14809 @kindex set remoteaddhost
14810 Tell @value{GDBN} whether to add this host to the remote stub's
14811 arguments when you debug over a network.
14813 @item show remoteaddhost
14814 @kindex show remoteaddhost
14815 Show whether to add this host to remote stub's arguments when
14816 debugging over a network.
14820 @node Architectures
14821 @section Architectures
14823 This section describes characteristics of architectures that affect
14824 all uses of @value{GDBN} with the architecture, both native and cross.
14831 * HPPA:: HP PA architecture
14835 @subsection x86 Architecture-specific issues.
14838 @item set struct-convention @var{mode}
14839 @kindex set struct-convention
14840 @cindex struct return convention
14841 @cindex struct/union returned in registers
14842 Set the convention used by the inferior to return @code{struct}s and
14843 @code{union}s from functions to @var{mode}. Possible values of
14844 @var{mode} are @code{"pcc"}, @code{"reg"}, and @code{"default"} (the
14845 default). @code{"default"} or @code{"pcc"} means that @code{struct}s
14846 are returned on the stack, while @code{"reg"} means that a
14847 @code{struct} or a @code{union} whose size is 1, 2, 4, or 8 bytes will
14848 be returned in a register.
14850 @item show struct-convention
14851 @kindex show struct-convention
14852 Show the current setting of the convention to return @code{struct}s
14861 @kindex set rstack_high_address
14862 @cindex AMD 29K register stack
14863 @cindex register stack, AMD29K
14864 @item set rstack_high_address @var{address}
14865 On AMD 29000 family processors, registers are saved in a separate
14866 @dfn{register stack}. There is no way for @value{GDBN} to determine the
14867 extent of this stack. Normally, @value{GDBN} just assumes that the
14868 stack is ``large enough''. This may result in @value{GDBN} referencing
14869 memory locations that do not exist. If necessary, you can get around
14870 this problem by specifying the ending address of the register stack with
14871 the @code{set rstack_high_address} command. The argument should be an
14872 address, which you probably want to precede with @samp{0x} to specify in
14875 @kindex show rstack_high_address
14876 @item show rstack_high_address
14877 Display the current limit of the register stack, on AMD 29000 family
14885 See the following section.
14890 @cindex stack on Alpha
14891 @cindex stack on MIPS
14892 @cindex Alpha stack
14894 Alpha- and MIPS-based computers use an unusual stack frame, which
14895 sometimes requires @value{GDBN} to search backward in the object code to
14896 find the beginning of a function.
14898 @cindex response time, MIPS debugging
14899 To improve response time (especially for embedded applications, where
14900 @value{GDBN} may be restricted to a slow serial line for this search)
14901 you may want to limit the size of this search, using one of these
14905 @cindex @code{heuristic-fence-post} (Alpha, MIPS)
14906 @item set heuristic-fence-post @var{limit}
14907 Restrict @value{GDBN} to examining at most @var{limit} bytes in its
14908 search for the beginning of a function. A value of @var{0} (the
14909 default) means there is no limit. However, except for @var{0}, the
14910 larger the limit the more bytes @code{heuristic-fence-post} must search
14911 and therefore the longer it takes to run. You should only need to use
14912 this command when debugging a stripped executable.
14914 @item show heuristic-fence-post
14915 Display the current limit.
14919 These commands are available @emph{only} when @value{GDBN} is configured
14920 for debugging programs on Alpha or MIPS processors.
14922 Several MIPS-specific commands are available when debugging MIPS
14926 @item set mips saved-gpreg-size @var{size}
14927 @kindex set mips saved-gpreg-size
14928 @cindex MIPS GP register size on stack
14929 Set the size of MIPS general-purpose registers saved on the stack.
14930 The argument @var{size} can be one of the following:
14934 32-bit GP registers
14936 64-bit GP registers
14938 Use the target's default setting or autodetect the saved size from the
14939 information contained in the executable. This is the default
14942 @item show mips saved-gpreg-size
14943 @kindex show mips saved-gpreg-size
14944 Show the current size of MIPS GP registers on the stack.
14946 @item set mips stack-arg-size @var{size}
14947 @kindex set mips stack-arg-size
14948 @cindex MIPS stack space for arguments
14949 Set the amount of stack space reserved for arguments to functions.
14950 The argument can be one of @code{"32"}, @code{"64"} or @code{"auto"}
14953 @item set mips abi @var{arg}
14954 @kindex set mips abi
14955 @cindex set ABI for MIPS
14956 Tell @value{GDBN} which MIPS ABI is used by the inferior. Possible
14957 values of @var{arg} are:
14961 The default ABI associated with the current binary (this is the
14972 @item show mips abi
14973 @kindex show mips abi
14974 Show the MIPS ABI used by @value{GDBN} to debug the inferior.
14977 @itemx show mipsfpu
14978 @xref{MIPS Embedded, set mipsfpu}.
14980 @item set mips mask-address @var{arg}
14981 @kindex set mips mask-address
14982 @cindex MIPS addresses, masking
14983 This command determines whether the most-significant 32 bits of 64-bit
14984 MIPS addresses are masked off. The argument @var{arg} can be
14985 @samp{on}, @samp{off}, or @samp{auto}. The latter is the default
14986 setting, which lets @value{GDBN} determine the correct value.
14988 @item show mips mask-address
14989 @kindex show mips mask-address
14990 Show whether the upper 32 bits of MIPS addresses are masked off or
14993 @item set remote-mips64-transfers-32bit-regs
14994 @kindex set remote-mips64-transfers-32bit-regs
14995 This command controls compatibility with 64-bit MIPS targets that
14996 transfer data in 32-bit quantities. If you have an old MIPS 64 target
14997 that transfers 32 bits for some registers, like @sc{sr} and @sc{fsr},
14998 and 64 bits for other registers, set this option to @samp{on}.
15000 @item show remote-mips64-transfers-32bit-regs
15001 @kindex show remote-mips64-transfers-32bit-regs
15002 Show the current setting of compatibility with older MIPS 64 targets.
15004 @item set debug mips
15005 @kindex set debug mips
15006 This command turns on and off debugging messages for the MIPS-specific
15007 target code in @value{GDBN}.
15009 @item show debug mips
15010 @kindex show debug mips
15011 Show the current setting of MIPS debugging messages.
15017 @cindex HPPA support
15019 When @value{GDBN} is debugging te HP PA architecture, it provides the
15020 following special commands:
15023 @item set debug hppa
15024 @kindex set debug hppa
15025 THis command determines whether HPPA architecture specific debugging
15026 messages are to be displayed.
15028 @item show debug hppa
15029 Show whether HPPA debugging messages are displayed.
15031 @item maint print unwind @var{address}
15032 @kindex maint print unwind@r{, HPPA}
15033 This command displays the contents of the unwind table entry at the
15034 given @var{address}.
15039 @node Controlling GDB
15040 @chapter Controlling @value{GDBN}
15042 You can alter the way @value{GDBN} interacts with you by using the
15043 @code{set} command. For commands controlling how @value{GDBN} displays
15044 data, see @ref{Print Settings, ,Print settings}. Other settings are
15049 * Editing:: Command editing
15050 * Command History:: Command history
15051 * Screen Size:: Screen size
15052 * Numbers:: Numbers
15053 * ABI:: Configuring the current ABI
15054 * Messages/Warnings:: Optional warnings and messages
15055 * Debugging Output:: Optional messages about internal happenings
15063 @value{GDBN} indicates its readiness to read a command by printing a string
15064 called the @dfn{prompt}. This string is normally @samp{(@value{GDBP})}. You
15065 can change the prompt string with the @code{set prompt} command. For
15066 instance, when debugging @value{GDBN} with @value{GDBN}, it is useful to change
15067 the prompt in one of the @value{GDBN} sessions so that you can always tell
15068 which one you are talking to.
15070 @emph{Note:} @code{set prompt} does not add a space for you after the
15071 prompt you set. This allows you to set a prompt which ends in a space
15072 or a prompt that does not.
15076 @item set prompt @var{newprompt}
15077 Directs @value{GDBN} to use @var{newprompt} as its prompt string henceforth.
15079 @kindex show prompt
15081 Prints a line of the form: @samp{Gdb's prompt is: @var{your-prompt}}
15085 @section Command editing
15087 @cindex command line editing
15089 @value{GDBN} reads its input commands via the @dfn{Readline} interface. This
15090 @sc{gnu} library provides consistent behavior for programs which provide a
15091 command line interface to the user. Advantages are @sc{gnu} Emacs-style
15092 or @dfn{vi}-style inline editing of commands, @code{csh}-like history
15093 substitution, and a storage and recall of command history across
15094 debugging sessions.
15096 You may control the behavior of command line editing in @value{GDBN} with the
15097 command @code{set}.
15100 @kindex set editing
15103 @itemx set editing on
15104 Enable command line editing (enabled by default).
15106 @item set editing off
15107 Disable command line editing.
15109 @kindex show editing
15111 Show whether command line editing is enabled.
15114 @xref{Command Line Editing}, for more details about the Readline
15115 interface. Users unfamiliar with @sc{gnu} Emacs or @code{vi} are
15116 encouraged to read that chapter.
15118 @node Command History
15119 @section Command history
15120 @cindex command history
15122 @value{GDBN} can keep track of the commands you type during your
15123 debugging sessions, so that you can be certain of precisely what
15124 happened. Use these commands to manage the @value{GDBN} command
15127 @value{GDBN} uses the @sc{gnu} History library, a part of the Readline
15128 package, to provide the history facility. @xref{Using History
15129 Interactively}, for the detailed description of the History library.
15131 To issue a command to @value{GDBN} without affecting certain aspects of
15132 the state which is seen by users, prefix it with @samp{server }. This
15133 means that this command will not affect the command history, nor will it
15134 affect @value{GDBN}'s notion of which command to repeat if @key{RET} is
15135 pressed on a line by itself.
15137 @cindex @code{server}, command prefix
15138 The server prefix does not affect the recording of values into the value
15139 history; to print a value without recording it into the value history,
15140 use the @code{output} command instead of the @code{print} command.
15142 Here is the description of @value{GDBN} commands related to command
15146 @cindex history substitution
15147 @cindex history file
15148 @kindex set history filename
15149 @cindex @env{GDBHISTFILE}, environment variable
15150 @item set history filename @var{fname}
15151 Set the name of the @value{GDBN} command history file to @var{fname}.
15152 This is the file where @value{GDBN} reads an initial command history
15153 list, and where it writes the command history from this session when it
15154 exits. You can access this list through history expansion or through
15155 the history command editing characters listed below. This file defaults
15156 to the value of the environment variable @code{GDBHISTFILE}, or to
15157 @file{./.gdb_history} (@file{./_gdb_history} on MS-DOS) if this variable
15160 @cindex save command history
15161 @kindex set history save
15162 @item set history save
15163 @itemx set history save on
15164 Record command history in a file, whose name may be specified with the
15165 @code{set history filename} command. By default, this option is disabled.
15167 @item set history save off
15168 Stop recording command history in a file.
15170 @cindex history size
15171 @kindex set history size
15172 @cindex @env{HISTSIZE}, environment variable
15173 @item set history size @var{size}
15174 Set the number of commands which @value{GDBN} keeps in its history list.
15175 This defaults to the value of the environment variable
15176 @code{HISTSIZE}, or to 256 if this variable is not set.
15179 History expansion assigns special meaning to the character @kbd{!}.
15180 @xref{Event Designators}, for more details.
15182 @cindex history expansion, turn on/off
15183 Since @kbd{!} is also the logical not operator in C, history expansion
15184 is off by default. If you decide to enable history expansion with the
15185 @code{set history expansion on} command, you may sometimes need to
15186 follow @kbd{!} (when it is used as logical not, in an expression) with
15187 a space or a tab to prevent it from being expanded. The readline
15188 history facilities do not attempt substitution on the strings
15189 @kbd{!=} and @kbd{!(}, even when history expansion is enabled.
15191 The commands to control history expansion are:
15194 @item set history expansion on
15195 @itemx set history expansion
15196 @kindex set history expansion
15197 Enable history expansion. History expansion is off by default.
15199 @item set history expansion off
15200 Disable history expansion.
15203 @kindex show history
15205 @itemx show history filename
15206 @itemx show history save
15207 @itemx show history size
15208 @itemx show history expansion
15209 These commands display the state of the @value{GDBN} history parameters.
15210 @code{show history} by itself displays all four states.
15215 @kindex show commands
15216 @cindex show last commands
15217 @cindex display command history
15218 @item show commands
15219 Display the last ten commands in the command history.
15221 @item show commands @var{n}
15222 Print ten commands centered on command number @var{n}.
15224 @item show commands +
15225 Print ten commands just after the commands last printed.
15229 @section Screen size
15230 @cindex size of screen
15231 @cindex pauses in output
15233 Certain commands to @value{GDBN} may produce large amounts of
15234 information output to the screen. To help you read all of it,
15235 @value{GDBN} pauses and asks you for input at the end of each page of
15236 output. Type @key{RET} when you want to continue the output, or @kbd{q}
15237 to discard the remaining output. Also, the screen width setting
15238 determines when to wrap lines of output. Depending on what is being
15239 printed, @value{GDBN} tries to break the line at a readable place,
15240 rather than simply letting it overflow onto the following line.
15242 Normally @value{GDBN} knows the size of the screen from the terminal
15243 driver software. For example, on Unix @value{GDBN} uses the termcap data base
15244 together with the value of the @code{TERM} environment variable and the
15245 @code{stty rows} and @code{stty cols} settings. If this is not correct,
15246 you can override it with the @code{set height} and @code{set
15253 @kindex show height
15254 @item set height @var{lpp}
15256 @itemx set width @var{cpl}
15258 These @code{set} commands specify a screen height of @var{lpp} lines and
15259 a screen width of @var{cpl} characters. The associated @code{show}
15260 commands display the current settings.
15262 If you specify a height of zero lines, @value{GDBN} does not pause during
15263 output no matter how long the output is. This is useful if output is to a
15264 file or to an editor buffer.
15266 Likewise, you can specify @samp{set width 0} to prevent @value{GDBN}
15267 from wrapping its output.
15269 @item set pagination on
15270 @itemx set pagination off
15271 @kindex set pagination
15272 Turn the output pagination on or off; the default is on. Turning
15273 pagination off is the alternative to @code{set height 0}.
15275 @item show pagination
15276 @kindex show pagination
15277 Show the current pagination mode.
15282 @cindex number representation
15283 @cindex entering numbers
15285 You can always enter numbers in octal, decimal, or hexadecimal in
15286 @value{GDBN} by the usual conventions: octal numbers begin with
15287 @samp{0}, decimal numbers end with @samp{.}, and hexadecimal numbers
15288 begin with @samp{0x}. Numbers that neither begin with @samp{0} or
15289 @samp{0x}, nor end with a @samp{.} are, by default, entered in base
15290 10; likewise, the default display for numbers---when no particular
15291 format is specified---is base 10. You can change the default base for
15292 both input and output with the commands described below.
15295 @kindex set input-radix
15296 @item set input-radix @var{base}
15297 Set the default base for numeric input. Supported choices
15298 for @var{base} are decimal 8, 10, or 16. @var{base} must itself be
15299 specified either unambiguously or using the current input radix; for
15303 set input-radix 012
15304 set input-radix 10.
15305 set input-radix 0xa
15309 sets the input base to decimal. On the other hand, @samp{set input-radix 10}
15310 leaves the input radix unchanged, no matter what it was, since
15311 @samp{10}, being without any leading or trailing signs of its base, is
15312 interpreted in the current radix. Thus, if the current radix is 16,
15313 @samp{10} is interpreted in hex, i.e.@: as 16 decimal, which doesn't
15316 @kindex set output-radix
15317 @item set output-radix @var{base}
15318 Set the default base for numeric display. Supported choices
15319 for @var{base} are decimal 8, 10, or 16. @var{base} must itself be
15320 specified either unambiguously or using the current input radix.
15322 @kindex show input-radix
15323 @item show input-radix
15324 Display the current default base for numeric input.
15326 @kindex show output-radix
15327 @item show output-radix
15328 Display the current default base for numeric display.
15330 @item set radix @r{[}@var{base}@r{]}
15334 These commands set and show the default base for both input and output
15335 of numbers. @code{set radix} sets the radix of input and output to
15336 the same base; without an argument, it resets the radix back to its
15337 default value of 10.
15342 @section Configuring the current ABI
15344 @value{GDBN} can determine the @dfn{ABI} (Application Binary Interface) of your
15345 application automatically. However, sometimes you need to override its
15346 conclusions. Use these commands to manage @value{GDBN}'s view of the
15353 One @value{GDBN} configuration can debug binaries for multiple operating
15354 system targets, either via remote debugging or native emulation.
15355 @value{GDBN} will autodetect the @dfn{OS ABI} (Operating System ABI) in use,
15356 but you can override its conclusion using the @code{set osabi} command.
15357 One example where this is useful is in debugging of binaries which use
15358 an alternate C library (e.g.@: @sc{uClibc} for @sc{gnu}/Linux) which does
15359 not have the same identifying marks that the standard C library for your
15364 Show the OS ABI currently in use.
15367 With no argument, show the list of registered available OS ABI's.
15369 @item set osabi @var{abi}
15370 Set the current OS ABI to @var{abi}.
15373 @cindex float promotion
15375 Generally, the way that an argument of type @code{float} is passed to a
15376 function depends on whether the function is prototyped. For a prototyped
15377 (i.e.@: ANSI/ISO style) function, @code{float} arguments are passed unchanged,
15378 according to the architecture's convention for @code{float}. For unprototyped
15379 (i.e.@: K&R style) functions, @code{float} arguments are first promoted to type
15380 @code{double} and then passed.
15382 Unfortunately, some forms of debug information do not reliably indicate whether
15383 a function is prototyped. If @value{GDBN} calls a function that is not marked
15384 as prototyped, it consults @kbd{set coerce-float-to-double}.
15387 @kindex set coerce-float-to-double
15388 @item set coerce-float-to-double
15389 @itemx set coerce-float-to-double on
15390 Arguments of type @code{float} will be promoted to @code{double} when passed
15391 to an unprototyped function. This is the default setting.
15393 @item set coerce-float-to-double off
15394 Arguments of type @code{float} will be passed directly to unprototyped
15397 @kindex show coerce-float-to-double
15398 @item show coerce-float-to-double
15399 Show the current setting of promoting @code{float} to @code{double}.
15403 @kindex show cp-abi
15404 @value{GDBN} needs to know the ABI used for your program's C@t{++}
15405 objects. The correct C@t{++} ABI depends on which C@t{++} compiler was
15406 used to build your application. @value{GDBN} only fully supports
15407 programs with a single C@t{++} ABI; if your program contains code using
15408 multiple C@t{++} ABI's or if @value{GDBN} can not identify your
15409 program's ABI correctly, you can tell @value{GDBN} which ABI to use.
15410 Currently supported ABI's include ``gnu-v2'', for @code{g++} versions
15411 before 3.0, ``gnu-v3'', for @code{g++} versions 3.0 and later, and
15412 ``hpaCC'' for the HP ANSI C@t{++} compiler. Other C@t{++} compilers may
15413 use the ``gnu-v2'' or ``gnu-v3'' ABI's as well. The default setting is
15418 Show the C@t{++} ABI currently in use.
15421 With no argument, show the list of supported C@t{++} ABI's.
15423 @item set cp-abi @var{abi}
15424 @itemx set cp-abi auto
15425 Set the current C@t{++} ABI to @var{abi}, or return to automatic detection.
15428 @node Messages/Warnings
15429 @section Optional warnings and messages
15431 @cindex verbose operation
15432 @cindex optional warnings
15433 By default, @value{GDBN} is silent about its inner workings. If you are
15434 running on a slow machine, you may want to use the @code{set verbose}
15435 command. This makes @value{GDBN} tell you when it does a lengthy
15436 internal operation, so you will not think it has crashed.
15438 Currently, the messages controlled by @code{set verbose} are those
15439 which announce that the symbol table for a source file is being read;
15440 see @code{symbol-file} in @ref{Files, ,Commands to specify files}.
15443 @kindex set verbose
15444 @item set verbose on
15445 Enables @value{GDBN} output of certain informational messages.
15447 @item set verbose off
15448 Disables @value{GDBN} output of certain informational messages.
15450 @kindex show verbose
15452 Displays whether @code{set verbose} is on or off.
15455 By default, if @value{GDBN} encounters bugs in the symbol table of an
15456 object file, it is silent; but if you are debugging a compiler, you may
15457 find this information useful (@pxref{Symbol Errors, ,Errors reading
15462 @kindex set complaints
15463 @item set complaints @var{limit}
15464 Permits @value{GDBN} to output @var{limit} complaints about each type of
15465 unusual symbols before becoming silent about the problem. Set
15466 @var{limit} to zero to suppress all complaints; set it to a large number
15467 to prevent complaints from being suppressed.
15469 @kindex show complaints
15470 @item show complaints
15471 Displays how many symbol complaints @value{GDBN} is permitted to produce.
15475 By default, @value{GDBN} is cautious, and asks what sometimes seems to be a
15476 lot of stupid questions to confirm certain commands. For example, if
15477 you try to run a program which is already running:
15481 The program being debugged has been started already.
15482 Start it from the beginning? (y or n)
15485 If you are willing to unflinchingly face the consequences of your own
15486 commands, you can disable this ``feature'':
15490 @kindex set confirm
15492 @cindex confirmation
15493 @cindex stupid questions
15494 @item set confirm off
15495 Disables confirmation requests.
15497 @item set confirm on
15498 Enables confirmation requests (the default).
15500 @kindex show confirm
15502 Displays state of confirmation requests.
15506 @node Debugging Output
15507 @section Optional messages about internal happenings
15508 @cindex optional debugging messages
15510 @value{GDBN} has commands that enable optional debugging messages from
15511 various @value{GDBN} subsystems; normally these commands are of
15512 interest to @value{GDBN} maintainers, or when reporting a bug. This
15513 section documents those commands.
15516 @kindex set exec-done-display
15517 @item set exec-done-display
15518 Turns on or off the notification of asynchronous commands'
15519 completion. When on, @value{GDBN} will print a message when an
15520 asynchronous command finishes its execution. The default is off.
15521 @kindex show exec-done-display
15522 @item show exec-done-display
15523 Displays the current setting of asynchronous command completion
15526 @cindex gdbarch debugging info
15527 @cindex architecture debugging info
15528 @item set debug arch
15529 Turns on or off display of gdbarch debugging info. The default is off
15531 @item show debug arch
15532 Displays the current state of displaying gdbarch debugging info.
15533 @item set debug aix-thread
15534 @cindex AIX threads
15535 Display debugging messages about inner workings of the AIX thread
15537 @item show debug aix-thread
15538 Show the current state of AIX thread debugging info display.
15539 @item set debug event
15540 @cindex event debugging info
15541 Turns on or off display of @value{GDBN} event debugging info. The
15543 @item show debug event
15544 Displays the current state of displaying @value{GDBN} event debugging
15546 @item set debug expression
15547 @cindex expression debugging info
15548 Turns on or off display of debugging info about @value{GDBN}
15549 expression parsing. The default is off.
15550 @item show debug expression
15551 Displays the current state of displaying debugging info about
15552 @value{GDBN} expression parsing.
15553 @item set debug frame
15554 @cindex frame debugging info
15555 Turns on or off display of @value{GDBN} frame debugging info. The
15557 @item show debug frame
15558 Displays the current state of displaying @value{GDBN} frame debugging
15560 @item set debug infrun
15561 @cindex inferior debugging info
15562 Turns on or off display of @value{GDBN} debugging info for running the inferior.
15563 The default is off. @file{infrun.c} contains GDB's runtime state machine used
15564 for implementing operations such as single-stepping the inferior.
15565 @item show debug infrun
15566 Displays the current state of @value{GDBN} inferior debugging.
15567 @item set debug lin-lwp
15568 @cindex @sc{gnu}/Linux LWP debug messages
15569 @cindex Linux lightweight processes
15570 Turns on or off debugging messages from the Linux LWP debug support.
15571 @item show debug lin-lwp
15572 Show the current state of Linux LWP debugging messages.
15573 @item set debug observer
15574 @cindex observer debugging info
15575 Turns on or off display of @value{GDBN} observer debugging. This
15576 includes info such as the notification of observable events.
15577 @item show debug observer
15578 Displays the current state of observer debugging.
15579 @item set debug overload
15580 @cindex C@t{++} overload debugging info
15581 Turns on or off display of @value{GDBN} C@t{++} overload debugging
15582 info. This includes info such as ranking of functions, etc. The default
15584 @item show debug overload
15585 Displays the current state of displaying @value{GDBN} C@t{++} overload
15587 @cindex packets, reporting on stdout
15588 @cindex serial connections, debugging
15589 @item set debug remote
15590 Turns on or off display of reports on all packets sent back and forth across
15591 the serial line to the remote machine. The info is printed on the
15592 @value{GDBN} standard output stream. The default is off.
15593 @item show debug remote
15594 Displays the state of display of remote packets.
15595 @item set debug serial
15596 Turns on or off display of @value{GDBN} serial debugging info. The
15598 @item show debug serial
15599 Displays the current state of displaying @value{GDBN} serial debugging
15601 @item set debug solib-frv
15602 @cindex FR-V shared-library debugging
15603 Turns on or off debugging messages for FR-V shared-library code.
15604 @item show debug solib-frv
15605 Display the current state of FR-V shared-library code debugging
15607 @item set debug target
15608 @cindex target debugging info
15609 Turns on or off display of @value{GDBN} target debugging info. This info
15610 includes what is going on at the target level of GDB, as it happens. The
15611 default is 0. Set it to 1 to track events, and to 2 to also track the
15612 value of large memory transfers. Changes to this flag do not take effect
15613 until the next time you connect to a target or use the @code{run} command.
15614 @item show debug target
15615 Displays the current state of displaying @value{GDBN} target debugging
15617 @item set debugvarobj
15618 @cindex variable object debugging info
15619 Turns on or off display of @value{GDBN} variable object debugging
15620 info. The default is off.
15621 @item show debugvarobj
15622 Displays the current state of displaying @value{GDBN} variable object
15627 @chapter Canned Sequences of Commands
15629 Aside from breakpoint commands (@pxref{Break Commands, ,Breakpoint
15630 command lists}), @value{GDBN} provides two ways to store sequences of
15631 commands for execution as a unit: user-defined commands and command
15635 * Define:: User-defined commands
15636 * Hooks:: User-defined command hooks
15637 * Command Files:: Command files
15638 * Output:: Commands for controlled output
15642 @section User-defined commands
15644 @cindex user-defined command
15645 A @dfn{user-defined command} is a sequence of @value{GDBN} commands to
15646 which you assign a new name as a command. This is done with the
15647 @code{define} command. User commands may accept up to 10 arguments
15648 separated by whitespace. Arguments are accessed within the user command
15649 via @var{$arg0@dots{}$arg9}. A trivial example:
15653 print $arg0 + $arg1 + $arg2
15657 To execute the command use:
15664 This defines the command @code{adder}, which prints the sum of
15665 its three arguments. Note the arguments are text substitutions, so they may
15666 reference variables, use complex expressions, or even perform inferior
15672 @item define @var{commandname}
15673 Define a command named @var{commandname}. If there is already a command
15674 by that name, you are asked to confirm that you want to redefine it.
15676 The definition of the command is made up of other @value{GDBN} command lines,
15677 which are given following the @code{define} command. The end of these
15678 commands is marked by a line containing @code{end}.
15684 Takes a single argument, which is an expression to evaluate.
15685 It is followed by a series of commands that are executed
15686 only if the expression is true (nonzero).
15687 There can then optionally be a line @code{else}, followed
15688 by a series of commands that are only executed if the expression
15689 was false. The end of the list is marked by a line containing @code{end}.
15693 The syntax is similar to @code{if}: the command takes a single argument,
15694 which is an expression to evaluate, and must be followed by the commands to
15695 execute, one per line, terminated by an @code{end}.
15696 The commands are executed repeatedly as long as the expression
15700 @item document @var{commandname}
15701 Document the user-defined command @var{commandname}, so that it can be
15702 accessed by @code{help}. The command @var{commandname} must already be
15703 defined. This command reads lines of documentation just as @code{define}
15704 reads the lines of the command definition, ending with @code{end}.
15705 After the @code{document} command is finished, @code{help} on command
15706 @var{commandname} displays the documentation you have written.
15708 You may use the @code{document} command again to change the
15709 documentation of a command. Redefining the command with @code{define}
15710 does not change the documentation.
15712 @kindex dont-repeat
15713 @cindex don't repeat command
15715 Used inside a user-defined command, this tells @value{GDBN} that this
15716 command should not be repeated when the user hits @key{RET}
15717 (@pxref{Command Syntax, repeat last command}).
15719 @kindex help user-defined
15720 @item help user-defined
15721 List all user-defined commands, with the first line of the documentation
15726 @itemx show user @var{commandname}
15727 Display the @value{GDBN} commands used to define @var{commandname} (but
15728 not its documentation). If no @var{commandname} is given, display the
15729 definitions for all user-defined commands.
15731 @cindex infinite recusrion in user-defined commands
15732 @kindex show max-user-call-depth
15733 @kindex set max-user-call-depth
15734 @item show max-user-call-depth
15735 @itemx set max-user-call-depth
15736 The value of @code{max-user-call-depth} controls how many recursion
15737 levels are allowed in user-defined commands before GDB suspects an
15738 infinite recursion and aborts the command.
15742 When user-defined commands are executed, the
15743 commands of the definition are not printed. An error in any command
15744 stops execution of the user-defined command.
15746 If used interactively, commands that would ask for confirmation proceed
15747 without asking when used inside a user-defined command. Many @value{GDBN}
15748 commands that normally print messages to say what they are doing omit the
15749 messages when used in a user-defined command.
15752 @section User-defined command hooks
15753 @cindex command hooks
15754 @cindex hooks, for commands
15755 @cindex hooks, pre-command
15758 You may define @dfn{hooks}, which are a special kind of user-defined
15759 command. Whenever you run the command @samp{foo}, if the user-defined
15760 command @samp{hook-foo} exists, it is executed (with no arguments)
15761 before that command.
15763 @cindex hooks, post-command
15765 A hook may also be defined which is run after the command you executed.
15766 Whenever you run the command @samp{foo}, if the user-defined command
15767 @samp{hookpost-foo} exists, it is executed (with no arguments) after
15768 that command. Post-execution hooks may exist simultaneously with
15769 pre-execution hooks, for the same command.
15771 It is valid for a hook to call the command which it hooks. If this
15772 occurs, the hook is not re-executed, thereby avoiding infinite recursion.
15774 @c It would be nice if hookpost could be passed a parameter indicating
15775 @c if the command it hooks executed properly or not. FIXME!
15777 @kindex stop@r{, a pseudo-command}
15778 In addition, a pseudo-command, @samp{stop} exists. Defining
15779 (@samp{hook-stop}) makes the associated commands execute every time
15780 execution stops in your program: before breakpoint commands are run,
15781 displays are printed, or the stack frame is printed.
15783 For example, to ignore @code{SIGALRM} signals while
15784 single-stepping, but treat them normally during normal execution,
15789 handle SIGALRM nopass
15793 handle SIGALRM pass
15796 define hook-continue
15797 handle SIGLARM pass
15801 As a further example, to hook at the begining and end of the @code{echo}
15802 command, and to add extra text to the beginning and end of the message,
15810 define hookpost-echo
15814 (@value{GDBP}) echo Hello World
15815 <<<---Hello World--->>>
15820 You can define a hook for any single-word command in @value{GDBN}, but
15821 not for command aliases; you should define a hook for the basic command
15822 name, e.g. @code{backtrace} rather than @code{bt}.
15823 @c FIXME! So how does Joe User discover whether a command is an alias
15825 If an error occurs during the execution of your hook, execution of
15826 @value{GDBN} commands stops and @value{GDBN} issues a prompt
15827 (before the command that you actually typed had a chance to run).
15829 If you try to define a hook which does not match any known command, you
15830 get a warning from the @code{define} command.
15832 @node Command Files
15833 @section Command files
15835 @cindex command files
15836 A command file for @value{GDBN} is a text file made of lines that are
15837 @value{GDBN} commands. Comments (lines starting with @kbd{#}) may
15838 also be included. An empty line in a command file does nothing; it
15839 does not mean to repeat the last command, as it would from the
15842 You can request the execution of a command file with the @code{source}
15847 @item source @var{filename}
15848 Execute the command file @var{filename}.
15851 The lines in a command file are executed sequentially. They are not
15852 printed as they are executed. An error in any command terminates
15853 execution of the command file and control is returned to the console.
15855 Commands that would ask for confirmation if used interactively proceed
15856 without asking when used in a command file. Many @value{GDBN} commands that
15857 normally print messages to say what they are doing omit the messages
15858 when called from command files.
15860 @value{GDBN} also accepts command input from standard input. In this
15861 mode, normal output goes to standard output and error output goes to
15862 standard error. Errors in a command file supplied on standard input do
15863 not terminate execution of the command file---execution continues with
15867 gdb < cmds > log 2>&1
15870 (The syntax above will vary depending on the shell used.) This example
15871 will execute commands from the file @file{cmds}. All output and errors
15872 would be directed to @file{log}.
15875 @section Commands for controlled output
15877 During the execution of a command file or a user-defined command, normal
15878 @value{GDBN} output is suppressed; the only output that appears is what is
15879 explicitly printed by the commands in the definition. This section
15880 describes three commands useful for generating exactly the output you
15885 @item echo @var{text}
15886 @c I do not consider backslash-space a standard C escape sequence
15887 @c because it is not in ANSI.
15888 Print @var{text}. Nonprinting characters can be included in
15889 @var{text} using C escape sequences, such as @samp{\n} to print a
15890 newline. @strong{No newline is printed unless you specify one.}
15891 In addition to the standard C escape sequences, a backslash followed
15892 by a space stands for a space. This is useful for displaying a
15893 string with spaces at the beginning or the end, since leading and
15894 trailing spaces are otherwise trimmed from all arguments.
15895 To print @samp{@w{ }and foo =@w{ }}, use the command
15896 @samp{echo \@w{ }and foo = \@w{ }}.
15898 A backslash at the end of @var{text} can be used, as in C, to continue
15899 the command onto subsequent lines. For example,
15902 echo This is some text\n\
15903 which is continued\n\
15904 onto several lines.\n
15907 produces the same output as
15910 echo This is some text\n
15911 echo which is continued\n
15912 echo onto several lines.\n
15916 @item output @var{expression}
15917 Print the value of @var{expression} and nothing but that value: no
15918 newlines, no @samp{$@var{nn} = }. The value is not entered in the
15919 value history either. @xref{Expressions, ,Expressions}, for more information
15922 @item output/@var{fmt} @var{expression}
15923 Print the value of @var{expression} in format @var{fmt}. You can use
15924 the same formats as for @code{print}. @xref{Output Formats,,Output
15925 formats}, for more information.
15928 @item printf @var{string}, @var{expressions}@dots{}
15929 Print the values of the @var{expressions} under the control of
15930 @var{string}. The @var{expressions} are separated by commas and may be
15931 either numbers or pointers. Their values are printed as specified by
15932 @var{string}, exactly as if your program were to execute the C
15934 @c FIXME: the above implies that at least all ANSI C formats are
15935 @c supported, but it isn't true: %E and %G don't work (or so it seems).
15936 @c Either this is a bug, or the manual should document what formats are
15940 printf (@var{string}, @var{expressions}@dots{});
15943 For example, you can print two values in hex like this:
15946 printf "foo, bar-foo = 0x%x, 0x%x\n", foo, bar-foo
15949 The only backslash-escape sequences that you can use in the format
15950 string are the simple ones that consist of backslash followed by a
15955 @chapter Command Interpreters
15956 @cindex command interpreters
15958 @value{GDBN} supports multiple command interpreters, and some command
15959 infrastructure to allow users or user interface writers to switch
15960 between interpreters or run commands in other interpreters.
15962 @value{GDBN} currently supports two command interpreters, the console
15963 interpreter (sometimes called the command-line interpreter or @sc{cli})
15964 and the machine interface interpreter (or @sc{gdb/mi}). This manual
15965 describes both of these interfaces in great detail.
15967 By default, @value{GDBN} will start with the console interpreter.
15968 However, the user may choose to start @value{GDBN} with another
15969 interpreter by specifying the @option{-i} or @option{--interpreter}
15970 startup options. Defined interpreters include:
15974 @cindex console interpreter
15975 The traditional console or command-line interpreter. This is the most often
15976 used interpreter with @value{GDBN}. With no interpreter specified at runtime,
15977 @value{GDBN} will use this interpreter.
15980 @cindex mi interpreter
15981 The newest @sc{gdb/mi} interface (currently @code{mi2}). Used primarily
15982 by programs wishing to use @value{GDBN} as a backend for a debugger GUI
15983 or an IDE. For more information, see @ref{GDB/MI, ,The @sc{gdb/mi}
15987 @cindex mi2 interpreter
15988 The current @sc{gdb/mi} interface.
15991 @cindex mi1 interpreter
15992 The @sc{gdb/mi} interface included in @value{GDBN} 5.1, 5.2, and 5.3.
15996 @cindex invoke another interpreter
15997 The interpreter being used by @value{GDBN} may not be dynamically
15998 switched at runtime. Although possible, this could lead to a very
15999 precarious situation. Consider an IDE using @sc{gdb/mi}. If a user
16000 enters the command "interpreter-set console" in a console view,
16001 @value{GDBN} would switch to using the console interpreter, rendering
16002 the IDE inoperable!
16004 @kindex interpreter-exec
16005 Although you may only choose a single interpreter at startup, you may execute
16006 commands in any interpreter from the current interpreter using the appropriate
16007 command. If you are running the console interpreter, simply use the
16008 @code{interpreter-exec} command:
16011 interpreter-exec mi "-data-list-register-names"
16014 @sc{gdb/mi} has a similar command, although it is only available in versions of
16015 @value{GDBN} which support @sc{gdb/mi} version 2 (or greater).
16018 @chapter @value{GDBN} Text User Interface
16020 @cindex Text User Interface
16023 * TUI Overview:: TUI overview
16024 * TUI Keys:: TUI key bindings
16025 * TUI Single Key Mode:: TUI single key mode
16026 * TUI Commands:: TUI specific commands
16027 * TUI Configuration:: TUI configuration variables
16030 The @value{GDBN} Text User Interface, TUI in short, is a terminal
16031 interface which uses the @code{curses} library to show the source
16032 file, the assembly output, the program registers and @value{GDBN}
16033 commands in separate text windows.
16035 The TUI is enabled by invoking @value{GDBN} using either
16037 @samp{gdbtui} or @samp{gdb -tui}.
16040 @section TUI overview
16042 The TUI has two display modes that can be switched while
16047 A curses (or TUI) mode in which it displays several text
16048 windows on the terminal.
16051 A standard mode which corresponds to the @value{GDBN} configured without
16055 In the TUI mode, @value{GDBN} can display several text window
16060 This window is the @value{GDBN} command window with the @value{GDBN}
16061 prompt and the @value{GDBN} outputs. The @value{GDBN} input is still
16062 managed using readline but through the TUI. The @emph{command}
16063 window is always visible.
16066 The source window shows the source file of the program. The current
16067 line as well as active breakpoints are displayed in this window.
16070 The assembly window shows the disassembly output of the program.
16073 This window shows the processor registers. It detects when
16074 a register is changed and when this is the case, registers that have
16075 changed are highlighted.
16079 The source and assembly windows show the current program position
16080 by highlighting the current line and marking them with the @samp{>} marker.
16081 Breakpoints are also indicated with two markers. A first one
16082 indicates the breakpoint type:
16086 Breakpoint which was hit at least once.
16089 Breakpoint which was never hit.
16092 Hardware breakpoint which was hit at least once.
16095 Hardware breakpoint which was never hit.
16099 The second marker indicates whether the breakpoint is enabled or not:
16103 Breakpoint is enabled.
16106 Breakpoint is disabled.
16110 The source, assembly and register windows are attached to the thread
16111 and the frame position. They are updated when the current thread
16112 changes, when the frame changes or when the program counter changes.
16113 These three windows are arranged by the TUI according to several
16114 layouts. The layout defines which of these three windows are visible.
16115 The following layouts are available:
16125 source and assembly
16128 source and registers
16131 assembly and registers
16135 On top of the command window a status line gives various information
16136 concerning the current process begin debugged. The status line is
16137 updated when the information it shows changes. The following fields
16142 Indicates the current gdb target
16143 (@pxref{Targets, ,Specifying a Debugging Target}).
16146 Gives information about the current process or thread number.
16147 When no process is being debugged, this field is set to @code{No process}.
16150 Gives the current function name for the selected frame.
16151 The name is demangled if demangling is turned on (@pxref{Print Settings}).
16152 When there is no symbol corresponding to the current program counter
16153 the string @code{??} is displayed.
16156 Indicates the current line number for the selected frame.
16157 When the current line number is not known the string @code{??} is displayed.
16160 Indicates the current program counter address.
16165 @section TUI Key Bindings
16166 @cindex TUI key bindings
16168 The TUI installs several key bindings in the readline keymaps
16169 (@pxref{Command Line Editing}).
16170 They allow to leave or enter in the TUI mode or they operate
16171 directly on the TUI layout and windows. The TUI also provides
16172 a @emph{SingleKey} keymap which binds several keys directly to
16173 @value{GDBN} commands. The following key bindings
16174 are installed for both TUI mode and the @value{GDBN} standard mode.
16183 Enter or leave the TUI mode. When the TUI mode is left,
16184 the curses window management is left and @value{GDBN} operates using
16185 its standard mode writing on the terminal directly. When the TUI
16186 mode is entered, the control is given back to the curses windows.
16187 The screen is then refreshed.
16191 Use a TUI layout with only one window. The layout will
16192 either be @samp{source} or @samp{assembly}. When the TUI mode
16193 is not active, it will switch to the TUI mode.
16195 Think of this key binding as the Emacs @kbd{C-x 1} binding.
16199 Use a TUI layout with at least two windows. When the current
16200 layout shows already two windows, a next layout with two windows is used.
16201 When a new layout is chosen, one window will always be common to the
16202 previous layout and the new one.
16204 Think of it as the Emacs @kbd{C-x 2} binding.
16208 Change the active window. The TUI associates several key bindings
16209 (like scrolling and arrow keys) to the active window. This command
16210 gives the focus to the next TUI window.
16212 Think of it as the Emacs @kbd{C-x o} binding.
16216 Use the TUI @emph{SingleKey} keymap that binds single key to gdb commands
16217 (@pxref{TUI Single Key Mode}).
16221 The following key bindings are handled only by the TUI mode:
16226 Scroll the active window one page up.
16230 Scroll the active window one page down.
16234 Scroll the active window one line up.
16238 Scroll the active window one line down.
16242 Scroll the active window one column left.
16246 Scroll the active window one column right.
16250 Refresh the screen.
16254 In the TUI mode, the arrow keys are used by the active window
16255 for scrolling. This means they are available for readline when the
16256 active window is the command window. When the command window
16257 does not have the focus, it is necessary to use other readline
16258 key bindings such as @key{C-p}, @key{C-n}, @key{C-b} and @key{C-f}.
16260 @node TUI Single Key Mode
16261 @section TUI Single Key Mode
16262 @cindex TUI single key mode
16264 The TUI provides a @emph{SingleKey} mode in which it installs a particular
16265 key binding in the readline keymaps to connect single keys to
16269 @kindex c @r{(SingleKey TUI key)}
16273 @kindex d @r{(SingleKey TUI key)}
16277 @kindex f @r{(SingleKey TUI key)}
16281 @kindex n @r{(SingleKey TUI key)}
16285 @kindex q @r{(SingleKey TUI key)}
16287 exit the @emph{SingleKey} mode.
16289 @kindex r @r{(SingleKey TUI key)}
16293 @kindex s @r{(SingleKey TUI key)}
16297 @kindex u @r{(SingleKey TUI key)}
16301 @kindex v @r{(SingleKey TUI key)}
16305 @kindex w @r{(SingleKey TUI key)}
16311 Other keys temporarily switch to the @value{GDBN} command prompt.
16312 The key that was pressed is inserted in the editing buffer so that
16313 it is possible to type most @value{GDBN} commands without interaction
16314 with the TUI @emph{SingleKey} mode. Once the command is entered the TUI
16315 @emph{SingleKey} mode is restored. The only way to permanently leave
16316 this mode is by hitting @key{q} or @samp{@key{C-x} @key{s}}.
16320 @section TUI specific commands
16321 @cindex TUI commands
16323 The TUI has specific commands to control the text windows.
16324 These commands are always available, that is they do not depend on
16325 the current terminal mode in which @value{GDBN} runs. When @value{GDBN}
16326 is in the standard mode, using these commands will automatically switch
16332 List and give the size of all displayed windows.
16336 Display the next layout.
16339 Display the previous layout.
16342 Display the source window only.
16345 Display the assembly window only.
16348 Display the source and assembly window.
16351 Display the register window together with the source or assembly window.
16353 @item focus next | prev | src | asm | regs | split
16355 Set the focus to the named window.
16356 This command allows to change the active window so that scrolling keys
16357 can be affected to another window.
16361 Refresh the screen. This is similar to using @key{C-L} key.
16363 @item tui reg float
16365 Show the floating point registers in the register window.
16367 @item tui reg general
16368 Show the general registers in the register window.
16371 Show the next register group. The list of register groups as well as
16372 their order is target specific. The predefined register groups are the
16373 following: @code{general}, @code{float}, @code{system}, @code{vector},
16374 @code{all}, @code{save}, @code{restore}.
16376 @item tui reg system
16377 Show the system registers in the register window.
16381 Update the source window and the current execution point.
16383 @item winheight @var{name} +@var{count}
16384 @itemx winheight @var{name} -@var{count}
16386 Change the height of the window @var{name} by @var{count}
16387 lines. Positive counts increase the height, while negative counts
16391 @kindex tabset @var{nchars}
16392 Set the width of tab stops to be @var{nchars} characters.
16396 @node TUI Configuration
16397 @section TUI configuration variables
16398 @cindex TUI configuration variables
16400 The TUI has several configuration variables that control the
16401 appearance of windows on the terminal.
16404 @item set tui border-kind @var{kind}
16405 @kindex set tui border-kind
16406 Select the border appearance for the source, assembly and register windows.
16407 The possible values are the following:
16410 Use a space character to draw the border.
16413 Use ascii characters + - and | to draw the border.
16416 Use the Alternate Character Set to draw the border. The border is
16417 drawn using character line graphics if the terminal supports them.
16421 @item set tui active-border-mode @var{mode}
16422 @kindex set tui active-border-mode
16423 Select the attributes to display the border of the active window.
16424 The possible values are @code{normal}, @code{standout}, @code{reverse},
16425 @code{half}, @code{half-standout}, @code{bold} and @code{bold-standout}.
16427 @item set tui border-mode @var{mode}
16428 @kindex set tui border-mode
16429 Select the attributes to display the border of other windows.
16430 The @var{mode} can be one of the following:
16433 Use normal attributes to display the border.
16439 Use reverse video mode.
16442 Use half bright mode.
16444 @item half-standout
16445 Use half bright and standout mode.
16448 Use extra bright or bold mode.
16450 @item bold-standout
16451 Use extra bright or bold and standout mode.
16458 @chapter Using @value{GDBN} under @sc{gnu} Emacs
16461 @cindex @sc{gnu} Emacs
16462 A special interface allows you to use @sc{gnu} Emacs to view (and
16463 edit) the source files for the program you are debugging with
16466 To use this interface, use the command @kbd{M-x gdb} in Emacs. Give the
16467 executable file you want to debug as an argument. This command starts
16468 @value{GDBN} as a subprocess of Emacs, with input and output through a newly
16469 created Emacs buffer.
16470 @c (Do not use the @code{-tui} option to run @value{GDBN} from Emacs.)
16472 Using @value{GDBN} under Emacs is just like using @value{GDBN} normally except for two
16477 All ``terminal'' input and output goes through the Emacs buffer.
16480 This applies both to @value{GDBN} commands and their output, and to the input
16481 and output done by the program you are debugging.
16483 This is useful because it means that you can copy the text of previous
16484 commands and input them again; you can even use parts of the output
16487 All the facilities of Emacs' Shell mode are available for interacting
16488 with your program. In particular, you can send signals the usual
16489 way---for example, @kbd{C-c C-c} for an interrupt, @kbd{C-c C-z} for a
16494 @value{GDBN} displays source code through Emacs.
16497 Each time @value{GDBN} displays a stack frame, Emacs automatically finds the
16498 source file for that frame and puts an arrow (@samp{=>}) at the
16499 left margin of the current line. Emacs uses a separate buffer for
16500 source display, and splits the screen to show both your @value{GDBN} session
16503 Explicit @value{GDBN} @code{list} or search commands still produce output as
16504 usual, but you probably have no reason to use them from Emacs.
16506 If you specify an absolute file name when prompted for the @kbd{M-x
16507 gdb} argument, then Emacs sets your current working directory to where
16508 your program resides. If you only specify the file name, then Emacs
16509 sets your current working directory to to the directory associated
16510 with the previous buffer. In this case, @value{GDBN} may find your
16511 program by searching your environment's @code{PATH} variable, but on
16512 some operating systems it might not find the source. So, although the
16513 @value{GDBN} input and output session proceeds normally, the auxiliary
16514 buffer does not display the current source and line of execution.
16516 The initial working directory of @value{GDBN} is printed on the top
16517 line of the @value{GDBN} I/O buffer and this serves as a default for
16518 the commands that specify files for @value{GDBN} to operate
16519 on. @xref{Files, ,Commands to specify files}.
16521 By default, @kbd{M-x gdb} calls the program called @file{gdb}. If you
16522 need to call @value{GDBN} by a different name (for example, if you
16523 keep several configurations around, with different names) you can
16524 customize the Emacs variable @code{gud-gdb-command-name} to run the
16527 In the @value{GDBN} I/O buffer, you can use these special Emacs commands in
16528 addition to the standard Shell mode commands:
16532 Describe the features of Emacs' @value{GDBN} Mode.
16535 Execute to another source line, like the @value{GDBN} @code{step} command; also
16536 update the display window to show the current file and location.
16539 Execute to next source line in this function, skipping all function
16540 calls, like the @value{GDBN} @code{next} command. Then update the display window
16541 to show the current file and location.
16544 Execute one instruction, like the @value{GDBN} @code{stepi} command; update
16545 display window accordingly.
16548 Execute until exit from the selected stack frame, like the @value{GDBN}
16549 @code{finish} command.
16552 Continue execution of your program, like the @value{GDBN} @code{continue}
16556 Go up the number of frames indicated by the numeric argument
16557 (@pxref{Arguments, , Numeric Arguments, Emacs, The @sc{gnu} Emacs Manual}),
16558 like the @value{GDBN} @code{up} command.
16561 Go down the number of frames indicated by the numeric argument, like the
16562 @value{GDBN} @code{down} command.
16565 In any source file, the Emacs command @kbd{C-x SPC} (@code{gud-break})
16566 tells @value{GDBN} to set a breakpoint on the source line point is on.
16568 If you type @kbd{M-x speedbar}, then Emacs displays a separate frame which
16569 shows a backtrace when the @value{GDBN} I/O buffer is current. Move
16570 point to any frame in the stack and type @key{RET} to make it become the
16571 current frame and display the associated source in the source buffer.
16572 Alternatively, click @kbd{Mouse-2} to make the selected frame become the
16575 If you accidentally delete the source-display buffer, an easy way to get
16576 it back is to type the command @code{f} in the @value{GDBN} buffer, to
16577 request a frame display; when you run under Emacs, this recreates
16578 the source buffer if necessary to show you the context of the current
16581 The source files displayed in Emacs are in ordinary Emacs buffers
16582 which are visiting the source files in the usual way. You can edit
16583 the files with these buffers if you wish; but keep in mind that @value{GDBN}
16584 communicates with Emacs in terms of line numbers. If you add or
16585 delete lines from the text, the line numbers that @value{GDBN} knows cease
16586 to correspond properly with the code.
16588 The description given here is for GNU Emacs version 21.3 and a more
16589 detailed description of its interaction with @value{GDBN} is given in
16590 the Emacs manual (@pxref{Debuggers,,, Emacs, The @sc{gnu} Emacs Manual}).
16592 @c The following dropped because Epoch is nonstandard. Reactivate
16595 @kindex Emacs Epoch environment
16599 Version 18 of @sc{gnu} Emacs has a built-in window system
16600 called the @code{epoch}
16601 environment. Users of this environment can use a new command,
16602 @code{inspect} which performs identically to @code{print} except that
16603 each value is printed in its own window.
16608 @chapter The @sc{gdb/mi} Interface
16610 @unnumberedsec Function and Purpose
16612 @cindex @sc{gdb/mi}, its purpose
16613 @sc{gdb/mi} is a line based machine oriented text interface to
16614 @value{GDBN} and is activated by specifying using the
16615 @option{--interpreter} command line option (@pxref{Mode Options}). It
16616 is specifically intended to support the development of systems which
16617 use the debugger as just one small component of a larger system.
16619 This chapter is a specification of the @sc{gdb/mi} interface. It is written
16620 in the form of a reference manual.
16622 Note that @sc{gdb/mi} is still under construction, so some of the
16623 features described below are incomplete and subject to change.
16625 @unnumberedsec Notation and Terminology
16627 @cindex notational conventions, for @sc{gdb/mi}
16628 This chapter uses the following notation:
16632 @code{|} separates two alternatives.
16635 @code{[ @var{something} ]} indicates that @var{something} is optional:
16636 it may or may not be given.
16639 @code{( @var{group} )*} means that @var{group} inside the parentheses
16640 may repeat zero or more times.
16643 @code{( @var{group} )+} means that @var{group} inside the parentheses
16644 may repeat one or more times.
16647 @code{"@var{string}"} means a literal @var{string}.
16651 @heading Dependencies
16654 @heading Acknowledgments
16656 In alphabetic order: Andrew Cagney, Fernando Nasser, Stan Shebs and
16660 * GDB/MI Command Syntax::
16661 * GDB/MI Compatibility with CLI::
16662 * GDB/MI Output Records::
16663 * GDB/MI Command Description Format::
16664 * GDB/MI Breakpoint Table Commands::
16665 * GDB/MI Data Manipulation::
16666 * GDB/MI Program Control::
16667 * GDB/MI Miscellaneous Commands::
16669 * GDB/MI Kod Commands::
16670 * GDB/MI Memory Overlay Commands::
16671 * GDB/MI Signal Handling Commands::
16673 * GDB/MI Stack Manipulation::
16674 * GDB/MI Symbol Query::
16675 * GDB/MI Target Manipulation::
16676 * GDB/MI Thread Commands::
16677 * GDB/MI Tracepoint Commands::
16678 * GDB/MI Variable Objects::
16681 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16682 @node GDB/MI Command Syntax
16683 @section @sc{gdb/mi} Command Syntax
16686 * GDB/MI Input Syntax::
16687 * GDB/MI Output Syntax::
16688 * GDB/MI Simple Examples::
16691 @node GDB/MI Input Syntax
16692 @subsection @sc{gdb/mi} Input Syntax
16694 @cindex input syntax for @sc{gdb/mi}
16695 @cindex @sc{gdb/mi}, input syntax
16697 @item @var{command} @expansion{}
16698 @code{@var{cli-command} | @var{mi-command}}
16700 @item @var{cli-command} @expansion{}
16701 @code{[ @var{token} ] @var{cli-command} @var{nl}}, where
16702 @var{cli-command} is any existing @value{GDBN} CLI command.
16704 @item @var{mi-command} @expansion{}
16705 @code{[ @var{token} ] "-" @var{operation} ( " " @var{option} )*
16706 @code{[} " --" @code{]} ( " " @var{parameter} )* @var{nl}}
16708 @item @var{token} @expansion{}
16709 "any sequence of digits"
16711 @item @var{option} @expansion{}
16712 @code{"-" @var{parameter} [ " " @var{parameter} ]}
16714 @item @var{parameter} @expansion{}
16715 @code{@var{non-blank-sequence} | @var{c-string}}
16717 @item @var{operation} @expansion{}
16718 @emph{any of the operations described in this chapter}
16720 @item @var{non-blank-sequence} @expansion{}
16721 @emph{anything, provided it doesn't contain special characters such as
16722 "-", @var{nl}, """ and of course " "}
16724 @item @var{c-string} @expansion{}
16725 @code{""" @var{seven-bit-iso-c-string-content} """}
16727 @item @var{nl} @expansion{}
16736 The CLI commands are still handled by the @sc{mi} interpreter; their
16737 output is described below.
16740 The @code{@var{token}}, when present, is passed back when the command
16744 Some @sc{mi} commands accept optional arguments as part of the parameter
16745 list. Each option is identified by a leading @samp{-} (dash) and may be
16746 followed by an optional argument parameter. Options occur first in the
16747 parameter list and can be delimited from normal parameters using
16748 @samp{--} (this is useful when some parameters begin with a dash).
16755 We want easy access to the existing CLI syntax (for debugging).
16758 We want it to be easy to spot a @sc{mi} operation.
16761 @node GDB/MI Output Syntax
16762 @subsection @sc{gdb/mi} Output Syntax
16764 @cindex output syntax of @sc{gdb/mi}
16765 @cindex @sc{gdb/mi}, output syntax
16766 The output from @sc{gdb/mi} consists of zero or more out-of-band records
16767 followed, optionally, by a single result record. This result record
16768 is for the most recent command. The sequence of output records is
16769 terminated by @samp{(@value{GDBP})}.
16771 If an input command was prefixed with a @code{@var{token}} then the
16772 corresponding output for that command will also be prefixed by that same
16776 @item @var{output} @expansion{}
16777 @code{( @var{out-of-band-record} )* [ @var{result-record} ] "(@value{GDBP})" @var{nl}}
16779 @item @var{result-record} @expansion{}
16780 @code{ [ @var{token} ] "^" @var{result-class} ( "," @var{result} )* @var{nl}}
16782 @item @var{out-of-band-record} @expansion{}
16783 @code{@var{async-record} | @var{stream-record}}
16785 @item @var{async-record} @expansion{}
16786 @code{@var{exec-async-output} | @var{status-async-output} | @var{notify-async-output}}
16788 @item @var{exec-async-output} @expansion{}
16789 @code{[ @var{token} ] "*" @var{async-output}}
16791 @item @var{status-async-output} @expansion{}
16792 @code{[ @var{token} ] "+" @var{async-output}}
16794 @item @var{notify-async-output} @expansion{}
16795 @code{[ @var{token} ] "=" @var{async-output}}
16797 @item @var{async-output} @expansion{}
16798 @code{@var{async-class} ( "," @var{result} )* @var{nl}}
16800 @item @var{result-class} @expansion{}
16801 @code{"done" | "running" | "connected" | "error" | "exit"}
16803 @item @var{async-class} @expansion{}
16804 @code{"stopped" | @var{others}} (where @var{others} will be added
16805 depending on the needs---this is still in development).
16807 @item @var{result} @expansion{}
16808 @code{ @var{variable} "=" @var{value}}
16810 @item @var{variable} @expansion{}
16811 @code{ @var{string} }
16813 @item @var{value} @expansion{}
16814 @code{ @var{const} | @var{tuple} | @var{list} }
16816 @item @var{const} @expansion{}
16817 @code{@var{c-string}}
16819 @item @var{tuple} @expansion{}
16820 @code{ "@{@}" | "@{" @var{result} ( "," @var{result} )* "@}" }
16822 @item @var{list} @expansion{}
16823 @code{ "[]" | "[" @var{value} ( "," @var{value} )* "]" | "["
16824 @var{result} ( "," @var{result} )* "]" }
16826 @item @var{stream-record} @expansion{}
16827 @code{@var{console-stream-output} | @var{target-stream-output} | @var{log-stream-output}}
16829 @item @var{console-stream-output} @expansion{}
16830 @code{"~" @var{c-string}}
16832 @item @var{target-stream-output} @expansion{}
16833 @code{"@@" @var{c-string}}
16835 @item @var{log-stream-output} @expansion{}
16836 @code{"&" @var{c-string}}
16838 @item @var{nl} @expansion{}
16841 @item @var{token} @expansion{}
16842 @emph{any sequence of digits}.
16850 All output sequences end in a single line containing a period.
16853 The @code{@var{token}} is from the corresponding request. If an execution
16854 command is interrupted by the @samp{-exec-interrupt} command, the
16855 @var{token} associated with the @samp{*stopped} message is the one of the
16856 original execution command, not the one of the interrupt command.
16859 @cindex status output in @sc{gdb/mi}
16860 @var{status-async-output} contains on-going status information about the
16861 progress of a slow operation. It can be discarded. All status output is
16862 prefixed by @samp{+}.
16865 @cindex async output in @sc{gdb/mi}
16866 @var{exec-async-output} contains asynchronous state change on the target
16867 (stopped, started, disappeared). All async output is prefixed by
16871 @cindex notify output in @sc{gdb/mi}
16872 @var{notify-async-output} contains supplementary information that the
16873 client should handle (e.g., a new breakpoint information). All notify
16874 output is prefixed by @samp{=}.
16877 @cindex console output in @sc{gdb/mi}
16878 @var{console-stream-output} is output that should be displayed as is in the
16879 console. It is the textual response to a CLI command. All the console
16880 output is prefixed by @samp{~}.
16883 @cindex target output in @sc{gdb/mi}
16884 @var{target-stream-output} is the output produced by the target program.
16885 All the target output is prefixed by @samp{@@}.
16888 @cindex log output in @sc{gdb/mi}
16889 @var{log-stream-output} is output text coming from @value{GDBN}'s internals, for
16890 instance messages that should be displayed as part of an error log. All
16891 the log output is prefixed by @samp{&}.
16894 @cindex list output in @sc{gdb/mi}
16895 New @sc{gdb/mi} commands should only output @var{lists} containing
16901 @xref{GDB/MI Stream Records, , @sc{gdb/mi} Stream Records}, for more
16902 details about the various output records.
16904 @node GDB/MI Simple Examples
16905 @subsection Simple Examples of @sc{gdb/mi} Interaction
16906 @cindex @sc{gdb/mi}, simple examples
16908 This subsection presents several simple examples of interaction using
16909 the @sc{gdb/mi} interface. In these examples, @samp{->} means that the
16910 following line is passed to @sc{gdb/mi} as input, while @samp{<-} means
16911 the output received from @sc{gdb/mi}.
16913 @subsubheading Target Stop
16914 @c Ummm... There is no "-stop" command. This assumes async, no?
16915 Here's an example of stopping the inferior process:
16926 <- *stop,reason="stop",address="0x123",source="a.c:123"
16930 @subsubheading Simple CLI Command
16932 Here's an example of a simple CLI command being passed through
16933 @sc{gdb/mi} and on to the CLI.
16943 @subsubheading Command With Side Effects
16946 -> -symbol-file xyz.exe
16947 <- *breakpoint,nr="3",address="0x123",source="a.c:123"
16951 @subsubheading A Bad Command
16953 Here's what happens if you pass a non-existent command:
16957 <- ^error,msg="Undefined MI command: rubbish"
16961 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16962 @node GDB/MI Compatibility with CLI
16963 @section @sc{gdb/mi} Compatibility with CLI
16965 @cindex compatibility, @sc{gdb/mi} and CLI
16966 @cindex @sc{gdb/mi}, compatibility with CLI
16967 To help users familiar with @value{GDBN}'s existing CLI interface, @sc{gdb/mi}
16968 accepts existing CLI commands. As specified by the syntax, such
16969 commands can be directly entered into the @sc{gdb/mi} interface and @value{GDBN} will
16972 This mechanism is provided as an aid to developers of @sc{gdb/mi}
16973 clients and not as a reliable interface into the CLI. Since the command
16974 is being interpreteted in an environment that assumes @sc{gdb/mi}
16975 behaviour, the exact output of such commands is likely to end up being
16976 an un-supported hybrid of @sc{gdb/mi} and CLI output.
16978 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16979 @node GDB/MI Output Records
16980 @section @sc{gdb/mi} Output Records
16983 * GDB/MI Result Records::
16984 * GDB/MI Stream Records::
16985 * GDB/MI Out-of-band Records::
16988 @node GDB/MI Result Records
16989 @subsection @sc{gdb/mi} Result Records
16991 @cindex result records in @sc{gdb/mi}
16992 @cindex @sc{gdb/mi}, result records
16993 In addition to a number of out-of-band notifications, the response to a
16994 @sc{gdb/mi} command includes one of the following result indications:
16998 @item "^done" [ "," @var{results} ]
16999 The synchronous operation was successful, @code{@var{results}} are the return
17004 @c Is this one correct? Should it be an out-of-band notification?
17005 The asynchronous operation was successfully started. The target is
17008 @item "^error" "," @var{c-string}
17010 The operation failed. The @code{@var{c-string}} contains the corresponding
17014 @node GDB/MI Stream Records
17015 @subsection @sc{gdb/mi} Stream Records
17017 @cindex @sc{gdb/mi}, stream records
17018 @cindex stream records in @sc{gdb/mi}
17019 @value{GDBN} internally maintains a number of output streams: the console, the
17020 target, and the log. The output intended for each of these streams is
17021 funneled through the @sc{gdb/mi} interface using @dfn{stream records}.
17023 Each stream record begins with a unique @dfn{prefix character} which
17024 identifies its stream (@pxref{GDB/MI Output Syntax, , @sc{gdb/mi} Output
17025 Syntax}). In addition to the prefix, each stream record contains a
17026 @code{@var{string-output}}. This is either raw text (with an implicit new
17027 line) or a quoted C string (which does not contain an implicit newline).
17030 @item "~" @var{string-output}
17031 The console output stream contains text that should be displayed in the
17032 CLI console window. It contains the textual responses to CLI commands.
17034 @item "@@" @var{string-output}
17035 The target output stream contains any textual output from the running
17038 @item "&" @var{string-output}
17039 The log stream contains debugging messages being produced by @value{GDBN}'s
17043 @node GDB/MI Out-of-band Records
17044 @subsection @sc{gdb/mi} Out-of-band Records
17046 @cindex out-of-band records in @sc{gdb/mi}
17047 @cindex @sc{gdb/mi}, out-of-band records
17048 @dfn{Out-of-band} records are used to notify the @sc{gdb/mi} client of
17049 additional changes that have occurred. Those changes can either be a
17050 consequence of @sc{gdb/mi} (e.g., a breakpoint modified) or a result of
17051 target activity (e.g., target stopped).
17053 The following is a preliminary list of possible out-of-band records.
17054 In particular, the @var{exec-async-output} records.
17057 @item *stopped,reason="@var{reason}"
17060 @var{reason} can be one of the following:
17063 @item breakpoint-hit
17064 A breakpoint was reached.
17065 @item watchpoint-trigger
17066 A watchpoint was triggered.
17067 @item read-watchpoint-trigger
17068 A read watchpoint was triggered.
17069 @item access-watchpoint-trigger
17070 An access watchpoint was triggered.
17071 @item function-finished
17072 An -exec-finish or similar CLI command was accomplished.
17073 @item location-reached
17074 An -exec-until or similar CLI command was accomplished.
17075 @item watchpoint-scope
17076 A watchpoint has gone out of scope.
17077 @item end-stepping-range
17078 An -exec-next, -exec-next-instruction, -exec-step, -exec-step-instruction or
17079 similar CLI command was accomplished.
17080 @item exited-signalled
17081 The inferior exited because of a signal.
17083 The inferior exited.
17084 @item exited-normally
17085 The inferior exited normally.
17086 @item signal-received
17087 A signal was received by the inferior.
17091 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
17092 @node GDB/MI Command Description Format
17093 @section @sc{gdb/mi} Command Description Format
17095 The remaining sections describe blocks of commands. Each block of
17096 commands is laid out in a fashion similar to this section.
17098 Note the the line breaks shown in the examples are here only for
17099 readability. They don't appear in the real output.
17100 Also note that the commands with a non-available example (N.A.@:) are
17101 not yet implemented.
17103 @subheading Motivation
17105 The motivation for this collection of commands.
17107 @subheading Introduction
17109 A brief introduction to this collection of commands as a whole.
17111 @subheading Commands
17113 For each command in the block, the following is described:
17115 @subsubheading Synopsis
17118 -command @var{args}@dots{}
17121 @subsubheading Result
17123 @subsubheading @value{GDBN} Command
17125 The corresponding @value{GDBN} CLI command(s), if any.
17127 @subsubheading Example
17129 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
17130 @node GDB/MI Breakpoint Table Commands
17131 @section @sc{gdb/mi} Breakpoint table commands
17133 @cindex breakpoint commands for @sc{gdb/mi}
17134 @cindex @sc{gdb/mi}, breakpoint commands
17135 This section documents @sc{gdb/mi} commands for manipulating
17138 @subheading The @code{-break-after} Command
17139 @findex -break-after
17141 @subsubheading Synopsis
17144 -break-after @var{number} @var{count}
17147 The breakpoint number @var{number} is not in effect until it has been
17148 hit @var{count} times. To see how this is reflected in the output of
17149 the @samp{-break-list} command, see the description of the
17150 @samp{-break-list} command below.
17152 @subsubheading @value{GDBN} Command
17154 The corresponding @value{GDBN} command is @samp{ignore}.
17156 @subsubheading Example
17161 ^done,bkpt=@{number="1",addr="0x000100d0",file="hello.c",line="5"@}
17168 ^done,BreakpointTable=@{nr_rows="1",nr_cols="6",
17169 hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
17170 @{width="14",alignment="-1",col_name="type",colhdr="Type"@},
17171 @{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
17172 @{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
17173 @{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
17174 @{width="40",alignment="2",col_name="what",colhdr="What"@}],
17175 body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y",
17176 addr="0x000100d0",func="main",file="hello.c",line="5",times="0",
17182 @subheading The @code{-break-catch} Command
17183 @findex -break-catch
17185 @subheading The @code{-break-commands} Command
17186 @findex -break-commands
17190 @subheading The @code{-break-condition} Command
17191 @findex -break-condition
17193 @subsubheading Synopsis
17196 -break-condition @var{number} @var{expr}
17199 Breakpoint @var{number} will stop the program only if the condition in
17200 @var{expr} is true. The condition becomes part of the
17201 @samp{-break-list} output (see the description of the @samp{-break-list}
17204 @subsubheading @value{GDBN} Command
17206 The corresponding @value{GDBN} command is @samp{condition}.
17208 @subsubheading Example
17212 -break-condition 1 1
17216 ^done,BreakpointTable=@{nr_rows="1",nr_cols="6",
17217 hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
17218 @{width="14",alignment="-1",col_name="type",colhdr="Type"@},
17219 @{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
17220 @{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
17221 @{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
17222 @{width="40",alignment="2",col_name="what",colhdr="What"@}],
17223 body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y",
17224 addr="0x000100d0",func="main",file="hello.c",line="5",cond="1",
17225 times="0",ignore="3"@}]@}
17229 @subheading The @code{-break-delete} Command
17230 @findex -break-delete
17232 @subsubheading Synopsis
17235 -break-delete ( @var{breakpoint} )+
17238 Delete the breakpoint(s) whose number(s) are specified in the argument
17239 list. This is obviously reflected in the breakpoint list.
17241 @subsubheading @value{GDBN} command
17243 The corresponding @value{GDBN} command is @samp{delete}.
17245 @subsubheading Example
17253 ^done,BreakpointTable=@{nr_rows="0",nr_cols="6",
17254 hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
17255 @{width="14",alignment="-1",col_name="type",colhdr="Type"@},
17256 @{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
17257 @{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
17258 @{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
17259 @{width="40",alignment="2",col_name="what",colhdr="What"@}],
17264 @subheading The @code{-break-disable} Command
17265 @findex -break-disable
17267 @subsubheading Synopsis
17270 -break-disable ( @var{breakpoint} )+
17273 Disable the named @var{breakpoint}(s). The field @samp{enabled} in the
17274 break list is now set to @samp{n} for the named @var{breakpoint}(s).
17276 @subsubheading @value{GDBN} Command
17278 The corresponding @value{GDBN} command is @samp{disable}.
17280 @subsubheading Example
17288 ^done,BreakpointTable=@{nr_rows="1",nr_cols="6",
17289 hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
17290 @{width="14",alignment="-1",col_name="type",colhdr="Type"@},
17291 @{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
17292 @{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
17293 @{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
17294 @{width="40",alignment="2",col_name="what",colhdr="What"@}],
17295 body=[bkpt=@{number="2",type="breakpoint",disp="keep",enabled="n",
17296 addr="0x000100d0",func="main",file="hello.c",line="5",times="0"@}]@}
17300 @subheading The @code{-break-enable} Command
17301 @findex -break-enable
17303 @subsubheading Synopsis
17306 -break-enable ( @var{breakpoint} )+
17309 Enable (previously disabled) @var{breakpoint}(s).
17311 @subsubheading @value{GDBN} Command
17313 The corresponding @value{GDBN} command is @samp{enable}.
17315 @subsubheading Example
17323 ^done,BreakpointTable=@{nr_rows="1",nr_cols="6",
17324 hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
17325 @{width="14",alignment="-1",col_name="type",colhdr="Type"@},
17326 @{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
17327 @{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
17328 @{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
17329 @{width="40",alignment="2",col_name="what",colhdr="What"@}],
17330 body=[bkpt=@{number="2",type="breakpoint",disp="keep",enabled="y",
17331 addr="0x000100d0",func="main",file="hello.c",line="5",times="0"@}]@}
17335 @subheading The @code{-break-info} Command
17336 @findex -break-info
17338 @subsubheading Synopsis
17341 -break-info @var{breakpoint}
17345 Get information about a single breakpoint.
17347 @subsubheading @value{GDBN} command
17349 The corresponding @value{GDBN} command is @samp{info break @var{breakpoint}}.
17351 @subsubheading Example
17354 @subheading The @code{-break-insert} Command
17355 @findex -break-insert
17357 @subsubheading Synopsis
17360 -break-insert [ -t ] [ -h ] [ -r ]
17361 [ -c @var{condition} ] [ -i @var{ignore-count} ]
17362 [ -p @var{thread} ] [ @var{line} | @var{addr} ]
17366 If specified, @var{line}, can be one of:
17373 @item filename:linenum
17374 @item filename:function
17378 The possible optional parameters of this command are:
17382 Insert a tempoary breakpoint.
17384 Insert a hardware breakpoint.
17385 @item -c @var{condition}
17386 Make the breakpoint conditional on @var{condition}.
17387 @item -i @var{ignore-count}
17388 Initialize the @var{ignore-count}.
17390 Insert a regular breakpoint in all the functions whose names match the
17391 given regular expression. Other flags are not applicable to regular
17395 @subsubheading Result
17397 The result is in the form:
17400 ^done,bkptno="@var{number}",func="@var{funcname}",
17401 file="@var{filename}",line="@var{lineno}"
17405 where @var{number} is the @value{GDBN} number for this breakpoint, @var{funcname}
17406 is the name of the function where the breakpoint was inserted,
17407 @var{filename} is the name of the source file which contains this
17408 function, and @var{lineno} is the source line number within that file.
17410 Note: this format is open to change.
17411 @c An out-of-band breakpoint instead of part of the result?
17413 @subsubheading @value{GDBN} Command
17415 The corresponding @value{GDBN} commands are @samp{break}, @samp{tbreak},
17416 @samp{hbreak}, @samp{thbreak}, and @samp{rbreak}.
17418 @subsubheading Example
17423 ^done,bkpt=@{number="1",addr="0x0001072c",file="recursive2.c",line="4"@}
17425 -break-insert -t foo
17426 ^done,bkpt=@{number="2",addr="0x00010774",file="recursive2.c",line="11"@}
17429 ^done,BreakpointTable=@{nr_rows="2",nr_cols="6",
17430 hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
17431 @{width="14",alignment="-1",col_name="type",colhdr="Type"@},
17432 @{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
17433 @{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
17434 @{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
17435 @{width="40",alignment="2",col_name="what",colhdr="What"@}],
17436 body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y",
17437 addr="0x0001072c", func="main",file="recursive2.c",line="4",times="0"@},
17438 bkpt=@{number="2",type="breakpoint",disp="del",enabled="y",
17439 addr="0x00010774",func="foo",file="recursive2.c",line="11",times="0"@}]@}
17441 -break-insert -r foo.*
17442 ~int foo(int, int);
17443 ^done,bkpt=@{number="3",addr="0x00010774",file="recursive2.c",line="11"@}
17447 @subheading The @code{-break-list} Command
17448 @findex -break-list
17450 @subsubheading Synopsis
17456 Displays the list of inserted breakpoints, showing the following fields:
17460 number of the breakpoint
17462 type of the breakpoint: @samp{breakpoint} or @samp{watchpoint}
17464 should the breakpoint be deleted or disabled when it is hit: @samp{keep}
17467 is the breakpoint enabled or no: @samp{y} or @samp{n}
17469 memory location at which the breakpoint is set
17471 logical location of the breakpoint, expressed by function name, file
17474 number of times the breakpoint has been hit
17477 If there are no breakpoints or watchpoints, the @code{BreakpointTable}
17478 @code{body} field is an empty list.
17480 @subsubheading @value{GDBN} Command
17482 The corresponding @value{GDBN} command is @samp{info break}.
17484 @subsubheading Example
17489 ^done,BreakpointTable=@{nr_rows="2",nr_cols="6",
17490 hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
17491 @{width="14",alignment="-1",col_name="type",colhdr="Type"@},
17492 @{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
17493 @{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
17494 @{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
17495 @{width="40",alignment="2",col_name="what",colhdr="What"@}],
17496 body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y",
17497 addr="0x000100d0",func="main",file="hello.c",line="5",times="0"@},
17498 bkpt=@{number="2",type="breakpoint",disp="keep",enabled="y",
17499 addr="0x00010114",func="foo",file="hello.c",line="13",times="0"@}]@}
17503 Here's an example of the result when there are no breakpoints:
17508 ^done,BreakpointTable=@{nr_rows="0",nr_cols="6",
17509 hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
17510 @{width="14",alignment="-1",col_name="type",colhdr="Type"@},
17511 @{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
17512 @{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
17513 @{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
17514 @{width="40",alignment="2",col_name="what",colhdr="What"@}],
17519 @subheading The @code{-break-watch} Command
17520 @findex -break-watch
17522 @subsubheading Synopsis
17525 -break-watch [ -a | -r ]
17528 Create a watchpoint. With the @samp{-a} option it will create an
17529 @dfn{access} watchpoint, i.e. a watchpoint that triggers either on a
17530 read from or on a write to the memory location. With the @samp{-r}
17531 option, the watchpoint created is a @dfn{read} watchpoint, i.e. it will
17532 trigger only when the memory location is accessed for reading. Without
17533 either of the options, the watchpoint created is a regular watchpoint,
17534 i.e. it will trigger when the memory location is accessed for writing.
17535 @xref{Set Watchpoints, , Setting watchpoints}.
17537 Note that @samp{-break-list} will report a single list of watchpoints and
17538 breakpoints inserted.
17540 @subsubheading @value{GDBN} Command
17542 The corresponding @value{GDBN} commands are @samp{watch}, @samp{awatch}, and
17545 @subsubheading Example
17547 Setting a watchpoint on a variable in the @code{main} function:
17552 ^done,wpt=@{number="2",exp="x"@}
17556 ^done,reason="watchpoint-trigger",wpt=@{number="2",exp="x"@},
17557 value=@{old="-268439212",new="55"@},
17558 frame=@{func="main",args=[],file="recursive2.c",
17559 fullname="/home/foo/bar/devo/myproject/recursive2.c",line="5"@}
17563 Setting a watchpoint on a variable local to a function. @value{GDBN} will stop
17564 the program execution twice: first for the variable changing value, then
17565 for the watchpoint going out of scope.
17570 ^done,wpt=@{number="5",exp="C"@}
17574 ^done,reason="watchpoint-trigger",
17575 wpt=@{number="5",exp="C"@},value=@{old="-276895068",new="3"@},
17576 frame=@{func="callee4",args=[],
17577 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
17578 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="13"@}
17582 ^done,reason="watchpoint-scope",wpnum="5",
17583 frame=@{func="callee3",args=[@{name="strarg",
17584 value="0x11940 \"A string argument.\""@}],
17585 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
17586 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="18"@}
17590 Listing breakpoints and watchpoints, at different points in the program
17591 execution. Note that once the watchpoint goes out of scope, it is
17597 ^done,wpt=@{number="2",exp="C"@}
17600 ^done,BreakpointTable=@{nr_rows="2",nr_cols="6",
17601 hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
17602 @{width="14",alignment="-1",col_name="type",colhdr="Type"@},
17603 @{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
17604 @{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
17605 @{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
17606 @{width="40",alignment="2",col_name="what",colhdr="What"@}],
17607 body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y",
17608 addr="0x00010734",func="callee4",
17609 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="8",times="1"@},
17610 bkpt=@{number="2",type="watchpoint",disp="keep",
17611 enabled="y",addr="",what="C",times="0"@}]@}
17615 ^done,reason="watchpoint-trigger",wpt=@{number="2",exp="C"@},
17616 value=@{old="-276895068",new="3"@},
17617 frame=@{func="callee4",args=[],
17618 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
17619 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="13"@}
17622 ^done,BreakpointTable=@{nr_rows="2",nr_cols="6",
17623 hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
17624 @{width="14",alignment="-1",col_name="type",colhdr="Type"@},
17625 @{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
17626 @{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
17627 @{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
17628 @{width="40",alignment="2",col_name="what",colhdr="What"@}],
17629 body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y",
17630 addr="0x00010734",func="callee4",
17631 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="8",times="1"@},
17632 bkpt=@{number="2",type="watchpoint",disp="keep",
17633 enabled="y",addr="",what="C",times="-5"@}]@}
17637 ^done,reason="watchpoint-scope",wpnum="2",
17638 frame=@{func="callee3",args=[@{name="strarg",
17639 value="0x11940 \"A string argument.\""@}],
17640 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
17641 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="18"@}
17644 ^done,BreakpointTable=@{nr_rows="1",nr_cols="6",
17645 hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
17646 @{width="14",alignment="-1",col_name="type",colhdr="Type"@},
17647 @{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
17648 @{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
17649 @{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
17650 @{width="40",alignment="2",col_name="what",colhdr="What"@}],
17651 body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y",
17652 addr="0x00010734",func="callee4",
17653 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="8",times="1"@}]@}
17657 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
17658 @node GDB/MI Data Manipulation
17659 @section @sc{gdb/mi} Data Manipulation
17661 @cindex data manipulation, in @sc{gdb/mi}
17662 @cindex @sc{gdb/mi}, data manipulation
17663 This section describes the @sc{gdb/mi} commands that manipulate data:
17664 examine memory and registers, evaluate expressions, etc.
17666 @c REMOVED FROM THE INTERFACE.
17667 @c @subheading -data-assign
17668 @c Change the value of a program variable. Plenty of side effects.
17669 @c @subsubheading GDB command
17671 @c @subsubheading Example
17674 @subheading The @code{-data-disassemble} Command
17675 @findex -data-disassemble
17677 @subsubheading Synopsis
17681 [ -s @var{start-addr} -e @var{end-addr} ]
17682 | [ -f @var{filename} -l @var{linenum} [ -n @var{lines} ] ]
17690 @item @var{start-addr}
17691 is the beginning address (or @code{$pc})
17692 @item @var{end-addr}
17694 @item @var{filename}
17695 is the name of the file to disassemble
17696 @item @var{linenum}
17697 is the line number to disassemble around
17699 is the the number of disassembly lines to be produced. If it is -1,
17700 the whole function will be disassembled, in case no @var{end-addr} is
17701 specified. If @var{end-addr} is specified as a non-zero value, and
17702 @var{lines} is lower than the number of disassembly lines between
17703 @var{start-addr} and @var{end-addr}, only @var{lines} lines are
17704 displayed; if @var{lines} is higher than the number of lines between
17705 @var{start-addr} and @var{end-addr}, only the lines up to @var{end-addr}
17708 is either 0 (meaning only disassembly) or 1 (meaning mixed source and
17712 @subsubheading Result
17714 The output for each instruction is composed of four fields:
17723 Note that whatever included in the instruction field, is not manipulated
17724 directely by @sc{gdb/mi}, i.e. it is not possible to adjust its format.
17726 @subsubheading @value{GDBN} Command
17728 There's no direct mapping from this command to the CLI.
17730 @subsubheading Example
17732 Disassemble from the current value of @code{$pc} to @code{$pc + 20}:
17736 -data-disassemble -s $pc -e "$pc + 20" -- 0
17739 @{address="0x000107c0",func-name="main",offset="4",
17740 inst="mov 2, %o0"@},
17741 @{address="0x000107c4",func-name="main",offset="8",
17742 inst="sethi %hi(0x11800), %o2"@},
17743 @{address="0x000107c8",func-name="main",offset="12",
17744 inst="or %o2, 0x140, %o1\t! 0x11940 <_lib_version+8>"@},
17745 @{address="0x000107cc",func-name="main",offset="16",
17746 inst="sethi %hi(0x11800), %o2"@},
17747 @{address="0x000107d0",func-name="main",offset="20",
17748 inst="or %o2, 0x168, %o4\t! 0x11968 <_lib_version+48>"@}]
17752 Disassemble the whole @code{main} function. Line 32 is part of
17756 -data-disassemble -f basics.c -l 32 -- 0
17758 @{address="0x000107bc",func-name="main",offset="0",
17759 inst="save %sp, -112, %sp"@},
17760 @{address="0x000107c0",func-name="main",offset="4",
17761 inst="mov 2, %o0"@},
17762 @{address="0x000107c4",func-name="main",offset="8",
17763 inst="sethi %hi(0x11800), %o2"@},
17765 @{address="0x0001081c",func-name="main",offset="96",inst="ret "@},
17766 @{address="0x00010820",func-name="main",offset="100",inst="restore "@}]
17770 Disassemble 3 instructions from the start of @code{main}:
17774 -data-disassemble -f basics.c -l 32 -n 3 -- 0
17776 @{address="0x000107bc",func-name="main",offset="0",
17777 inst="save %sp, -112, %sp"@},
17778 @{address="0x000107c0",func-name="main",offset="4",
17779 inst="mov 2, %o0"@},
17780 @{address="0x000107c4",func-name="main",offset="8",
17781 inst="sethi %hi(0x11800), %o2"@}]
17785 Disassemble 3 instructions from the start of @code{main} in mixed mode:
17789 -data-disassemble -f basics.c -l 32 -n 3 -- 1
17791 src_and_asm_line=@{line="31",
17792 file="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb/ \
17793 testsuite/gdb.mi/basics.c",line_asm_insn=[
17794 @{address="0x000107bc",func-name="main",offset="0",
17795 inst="save %sp, -112, %sp"@}]@},
17796 src_and_asm_line=@{line="32",
17797 file="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb/ \
17798 testsuite/gdb.mi/basics.c",line_asm_insn=[
17799 @{address="0x000107c0",func-name="main",offset="4",
17800 inst="mov 2, %o0"@},
17801 @{address="0x000107c4",func-name="main",offset="8",
17802 inst="sethi %hi(0x11800), %o2"@}]@}]
17807 @subheading The @code{-data-evaluate-expression} Command
17808 @findex -data-evaluate-expression
17810 @subsubheading Synopsis
17813 -data-evaluate-expression @var{expr}
17816 Evaluate @var{expr} as an expression. The expression could contain an
17817 inferior function call. The function call will execute synchronously.
17818 If the expression contains spaces, it must be enclosed in double quotes.
17820 @subsubheading @value{GDBN} Command
17822 The corresponding @value{GDBN} commands are @samp{print}, @samp{output}, and
17823 @samp{call}. In @code{gdbtk} only, there's a corresponding
17824 @samp{gdb_eval} command.
17826 @subsubheading Example
17828 In the following example, the numbers that precede the commands are the
17829 @dfn{tokens} described in @ref{GDB/MI Command Syntax, ,@sc{gdb/mi}
17830 Command Syntax}. Notice how @sc{gdb/mi} returns the same tokens in its
17834 211-data-evaluate-expression A
17837 311-data-evaluate-expression &A
17838 311^done,value="0xefffeb7c"
17840 411-data-evaluate-expression A+3
17843 511-data-evaluate-expression "A + 3"
17849 @subheading The @code{-data-list-changed-registers} Command
17850 @findex -data-list-changed-registers
17852 @subsubheading Synopsis
17855 -data-list-changed-registers
17858 Display a list of the registers that have changed.
17860 @subsubheading @value{GDBN} Command
17862 @value{GDBN} doesn't have a direct analog for this command; @code{gdbtk}
17863 has the corresponding command @samp{gdb_changed_register_list}.
17865 @subsubheading Example
17867 On a PPC MBX board:
17875 *stopped,reason="breakpoint-hit",bkptno="1",frame=@{func="main",
17876 args=[],file="try.c",fullname="/home/foo/bar/devo/myproject/try.c",line="5"@}
17878 -data-list-changed-registers
17879 ^done,changed-registers=["0","1","2","4","5","6","7","8","9",
17880 "10","11","13","14","15","16","17","18","19","20","21","22","23",
17881 "24","25","26","27","28","30","31","64","65","66","67","69"]
17886 @subheading The @code{-data-list-register-names} Command
17887 @findex -data-list-register-names
17889 @subsubheading Synopsis
17892 -data-list-register-names [ ( @var{regno} )+ ]
17895 Show a list of register names for the current target. If no arguments
17896 are given, it shows a list of the names of all the registers. If
17897 integer numbers are given as arguments, it will print a list of the
17898 names of the registers corresponding to the arguments. To ensure
17899 consistency between a register name and its number, the output list may
17900 include empty register names.
17902 @subsubheading @value{GDBN} Command
17904 @value{GDBN} does not have a command which corresponds to
17905 @samp{-data-list-register-names}. In @code{gdbtk} there is a
17906 corresponding command @samp{gdb_regnames}.
17908 @subsubheading Example
17910 For the PPC MBX board:
17913 -data-list-register-names
17914 ^done,register-names=["r0","r1","r2","r3","r4","r5","r6","r7",
17915 "r8","r9","r10","r11","r12","r13","r14","r15","r16","r17","r18",
17916 "r19","r20","r21","r22","r23","r24","r25","r26","r27","r28","r29",
17917 "r30","r31","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9",
17918 "f10","f11","f12","f13","f14","f15","f16","f17","f18","f19","f20",
17919 "f21","f22","f23","f24","f25","f26","f27","f28","f29","f30","f31",
17920 "", "pc","ps","cr","lr","ctr","xer"]
17922 -data-list-register-names 1 2 3
17923 ^done,register-names=["r1","r2","r3"]
17927 @subheading The @code{-data-list-register-values} Command
17928 @findex -data-list-register-values
17930 @subsubheading Synopsis
17933 -data-list-register-values @var{fmt} [ ( @var{regno} )*]
17936 Display the registers' contents. @var{fmt} is the format according to
17937 which the registers' contents are to be returned, followed by an optional
17938 list of numbers specifying the registers to display. A missing list of
17939 numbers indicates that the contents of all the registers must be returned.
17941 Allowed formats for @var{fmt} are:
17958 @subsubheading @value{GDBN} Command
17960 The corresponding @value{GDBN} commands are @samp{info reg}, @samp{info
17961 all-reg}, and (in @code{gdbtk}) @samp{gdb_fetch_registers}.
17963 @subsubheading Example
17965 For a PPC MBX board (note: line breaks are for readability only, they
17966 don't appear in the actual output):
17970 -data-list-register-values r 64 65
17971 ^done,register-values=[@{number="64",value="0xfe00a300"@},
17972 @{number="65",value="0x00029002"@}]
17974 -data-list-register-values x
17975 ^done,register-values=[@{number="0",value="0xfe0043c8"@},
17976 @{number="1",value="0x3fff88"@},@{number="2",value="0xfffffffe"@},
17977 @{number="3",value="0x0"@},@{number="4",value="0xa"@},
17978 @{number="5",value="0x3fff68"@},@{number="6",value="0x3fff58"@},
17979 @{number="7",value="0xfe011e98"@},@{number="8",value="0x2"@},
17980 @{number="9",value="0xfa202820"@},@{number="10",value="0xfa202808"@},
17981 @{number="11",value="0x1"@},@{number="12",value="0x0"@},
17982 @{number="13",value="0x4544"@},@{number="14",value="0xffdfffff"@},
17983 @{number="15",value="0xffffffff"@},@{number="16",value="0xfffffeff"@},
17984 @{number="17",value="0xefffffed"@},@{number="18",value="0xfffffffe"@},
17985 @{number="19",value="0xffffffff"@},@{number="20",value="0xffffffff"@},
17986 @{number="21",value="0xffffffff"@},@{number="22",value="0xfffffff7"@},
17987 @{number="23",value="0xffffffff"@},@{number="24",value="0xffffffff"@},
17988 @{number="25",value="0xffffffff"@},@{number="26",value="0xfffffffb"@},
17989 @{number="27",value="0xffffffff"@},@{number="28",value="0xf7bfffff"@},
17990 @{number="29",value="0x0"@},@{number="30",value="0xfe010000"@},
17991 @{number="31",value="0x0"@},@{number="32",value="0x0"@},
17992 @{number="33",value="0x0"@},@{number="34",value="0x0"@},
17993 @{number="35",value="0x0"@},@{number="36",value="0x0"@},
17994 @{number="37",value="0x0"@},@{number="38",value="0x0"@},
17995 @{number="39",value="0x0"@},@{number="40",value="0x0"@},
17996 @{number="41",value="0x0"@},@{number="42",value="0x0"@},
17997 @{number="43",value="0x0"@},@{number="44",value="0x0"@},
17998 @{number="45",value="0x0"@},@{number="46",value="0x0"@},
17999 @{number="47",value="0x0"@},@{number="48",value="0x0"@},
18000 @{number="49",value="0x0"@},@{number="50",value="0x0"@},
18001 @{number="51",value="0x0"@},@{number="52",value="0x0"@},
18002 @{number="53",value="0x0"@},@{number="54",value="0x0"@},
18003 @{number="55",value="0x0"@},@{number="56",value="0x0"@},
18004 @{number="57",value="0x0"@},@{number="58",value="0x0"@},
18005 @{number="59",value="0x0"@},@{number="60",value="0x0"@},
18006 @{number="61",value="0x0"@},@{number="62",value="0x0"@},
18007 @{number="63",value="0x0"@},@{number="64",value="0xfe00a300"@},
18008 @{number="65",value="0x29002"@},@{number="66",value="0x202f04b5"@},
18009 @{number="67",value="0xfe0043b0"@},@{number="68",value="0xfe00b3e4"@},
18010 @{number="69",value="0x20002b03"@}]
18015 @subheading The @code{-data-read-memory} Command
18016 @findex -data-read-memory
18018 @subsubheading Synopsis
18021 -data-read-memory [ -o @var{byte-offset} ]
18022 @var{address} @var{word-format} @var{word-size}
18023 @var{nr-rows} @var{nr-cols} [ @var{aschar} ]
18030 @item @var{address}
18031 An expression specifying the address of the first memory word to be
18032 read. Complex expressions containing embedded white space should be
18033 quoted using the C convention.
18035 @item @var{word-format}
18036 The format to be used to print the memory words. The notation is the
18037 same as for @value{GDBN}'s @code{print} command (@pxref{Output Formats,
18040 @item @var{word-size}
18041 The size of each memory word in bytes.
18043 @item @var{nr-rows}
18044 The number of rows in the output table.
18046 @item @var{nr-cols}
18047 The number of columns in the output table.
18050 If present, indicates that each row should include an @sc{ascii} dump. The
18051 value of @var{aschar} is used as a padding character when a byte is not a
18052 member of the printable @sc{ascii} character set (printable @sc{ascii}
18053 characters are those whose code is between 32 and 126, inclusively).
18055 @item @var{byte-offset}
18056 An offset to add to the @var{address} before fetching memory.
18059 This command displays memory contents as a table of @var{nr-rows} by
18060 @var{nr-cols} words, each word being @var{word-size} bytes. In total,
18061 @code{@var{nr-rows} * @var{nr-cols} * @var{word-size}} bytes are read
18062 (returned as @samp{total-bytes}). Should less than the requested number
18063 of bytes be returned by the target, the missing words are identified
18064 using @samp{N/A}. The number of bytes read from the target is returned
18065 in @samp{nr-bytes} and the starting address used to read memory in
18068 The address of the next/previous row or page is available in
18069 @samp{next-row} and @samp{prev-row}, @samp{next-page} and
18072 @subsubheading @value{GDBN} Command
18074 The corresponding @value{GDBN} command is @samp{x}. @code{gdbtk} has
18075 @samp{gdb_get_mem} memory read command.
18077 @subsubheading Example
18079 Read six bytes of memory starting at @code{bytes+6} but then offset by
18080 @code{-6} bytes. Format as three rows of two columns. One byte per
18081 word. Display each word in hex.
18085 9-data-read-memory -o -6 -- bytes+6 x 1 3 2
18086 9^done,addr="0x00001390",nr-bytes="6",total-bytes="6",
18087 next-row="0x00001396",prev-row="0x0000138e",next-page="0x00001396",
18088 prev-page="0x0000138a",memory=[
18089 @{addr="0x00001390",data=["0x00","0x01"]@},
18090 @{addr="0x00001392",data=["0x02","0x03"]@},
18091 @{addr="0x00001394",data=["0x04","0x05"]@}]
18095 Read two bytes of memory starting at address @code{shorts + 64} and
18096 display as a single word formatted in decimal.
18100 5-data-read-memory shorts+64 d 2 1 1
18101 5^done,addr="0x00001510",nr-bytes="2",total-bytes="2",
18102 next-row="0x00001512",prev-row="0x0000150e",
18103 next-page="0x00001512",prev-page="0x0000150e",memory=[
18104 @{addr="0x00001510",data=["128"]@}]
18108 Read thirty two bytes of memory starting at @code{bytes+16} and format
18109 as eight rows of four columns. Include a string encoding with @samp{x}
18110 used as the non-printable character.
18114 4-data-read-memory bytes+16 x 1 8 4 x
18115 4^done,addr="0x000013a0",nr-bytes="32",total-bytes="32",
18116 next-row="0x000013c0",prev-row="0x0000139c",
18117 next-page="0x000013c0",prev-page="0x00001380",memory=[
18118 @{addr="0x000013a0",data=["0x10","0x11","0x12","0x13"],ascii="xxxx"@},
18119 @{addr="0x000013a4",data=["0x14","0x15","0x16","0x17"],ascii="xxxx"@},
18120 @{addr="0x000013a8",data=["0x18","0x19","0x1a","0x1b"],ascii="xxxx"@},
18121 @{addr="0x000013ac",data=["0x1c","0x1d","0x1e","0x1f"],ascii="xxxx"@},
18122 @{addr="0x000013b0",data=["0x20","0x21","0x22","0x23"],ascii=" !\"#"@},
18123 @{addr="0x000013b4",data=["0x24","0x25","0x26","0x27"],ascii="$%&'"@},
18124 @{addr="0x000013b8",data=["0x28","0x29","0x2a","0x2b"],ascii="()*+"@},
18125 @{addr="0x000013bc",data=["0x2c","0x2d","0x2e","0x2f"],ascii=",-./"@}]
18129 @subheading The @code{-display-delete} Command
18130 @findex -display-delete
18132 @subsubheading Synopsis
18135 -display-delete @var{number}
18138 Delete the display @var{number}.
18140 @subsubheading @value{GDBN} Command
18142 The corresponding @value{GDBN} command is @samp{delete display}.
18144 @subsubheading Example
18148 @subheading The @code{-display-disable} Command
18149 @findex -display-disable
18151 @subsubheading Synopsis
18154 -display-disable @var{number}
18157 Disable display @var{number}.
18159 @subsubheading @value{GDBN} Command
18161 The corresponding @value{GDBN} command is @samp{disable display}.
18163 @subsubheading Example
18167 @subheading The @code{-display-enable} Command
18168 @findex -display-enable
18170 @subsubheading Synopsis
18173 -display-enable @var{number}
18176 Enable display @var{number}.
18178 @subsubheading @value{GDBN} Command
18180 The corresponding @value{GDBN} command is @samp{enable display}.
18182 @subsubheading Example
18186 @subheading The @code{-display-insert} Command
18187 @findex -display-insert
18189 @subsubheading Synopsis
18192 -display-insert @var{expression}
18195 Display @var{expression} every time the program stops.
18197 @subsubheading @value{GDBN} Command
18199 The corresponding @value{GDBN} command is @samp{display}.
18201 @subsubheading Example
18205 @subheading The @code{-display-list} Command
18206 @findex -display-list
18208 @subsubheading Synopsis
18214 List the displays. Do not show the current values.
18216 @subsubheading @value{GDBN} Command
18218 The corresponding @value{GDBN} command is @samp{info display}.
18220 @subsubheading Example
18224 @subheading The @code{-environment-cd} Command
18225 @findex -environment-cd
18227 @subsubheading Synopsis
18230 -environment-cd @var{pathdir}
18233 Set @value{GDBN}'s working directory.
18235 @subsubheading @value{GDBN} Command
18237 The corresponding @value{GDBN} command is @samp{cd}.
18239 @subsubheading Example
18243 -environment-cd /kwikemart/marge/ezannoni/flathead-dev/devo/gdb
18249 @subheading The @code{-environment-directory} Command
18250 @findex -environment-directory
18252 @subsubheading Synopsis
18255 -environment-directory [ -r ] [ @var{pathdir} ]+
18258 Add directories @var{pathdir} to beginning of search path for source files.
18259 If the @samp{-r} option is used, the search path is reset to the default
18260 search path. If directories @var{pathdir} are supplied in addition to the
18261 @samp{-r} option, the search path is first reset and then addition
18263 Multiple directories may be specified, separated by blanks. Specifying
18264 multiple directories in a single command
18265 results in the directories added to the beginning of the
18266 search path in the same order they were presented in the command.
18267 If blanks are needed as
18268 part of a directory name, double-quotes should be used around
18269 the name. In the command output, the path will show up separated
18270 by the system directory-separator character. The directory-seperator
18271 character must not be used
18272 in any directory name.
18273 If no directories are specified, the current search path is displayed.
18275 @subsubheading @value{GDBN} Command
18277 The corresponding @value{GDBN} command is @samp{dir}.
18279 @subsubheading Example
18283 -environment-directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb
18284 ^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
18286 -environment-directory ""
18287 ^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
18289 -environment-directory -r /home/jjohnstn/src/gdb /usr/src
18290 ^done,source-path="/home/jjohnstn/src/gdb:/usr/src:$cdir:$cwd"
18292 -environment-directory -r
18293 ^done,source-path="$cdir:$cwd"
18298 @subheading The @code{-environment-path} Command
18299 @findex -environment-path
18301 @subsubheading Synopsis
18304 -environment-path [ -r ] [ @var{pathdir} ]+
18307 Add directories @var{pathdir} to beginning of search path for object files.
18308 If the @samp{-r} option is used, the search path is reset to the original
18309 search path that existed at gdb start-up. If directories @var{pathdir} are
18310 supplied in addition to the
18311 @samp{-r} option, the search path is first reset and then addition
18313 Multiple directories may be specified, separated by blanks. Specifying
18314 multiple directories in a single command
18315 results in the directories added to the beginning of the
18316 search path in the same order they were presented in the command.
18317 If blanks are needed as
18318 part of a directory name, double-quotes should be used around
18319 the name. In the command output, the path will show up separated
18320 by the system directory-separator character. The directory-seperator
18321 character must not be used
18322 in any directory name.
18323 If no directories are specified, the current path is displayed.
18326 @subsubheading @value{GDBN} Command
18328 The corresponding @value{GDBN} command is @samp{path}.
18330 @subsubheading Example
18335 ^done,path="/usr/bin"
18337 -environment-path /kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb /bin
18338 ^done,path="/kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb:/bin:/usr/bin"
18340 -environment-path -r /usr/local/bin
18341 ^done,path="/usr/local/bin:/usr/bin"
18346 @subheading The @code{-environment-pwd} Command
18347 @findex -environment-pwd
18349 @subsubheading Synopsis
18355 Show the current working directory.
18357 @subsubheading @value{GDBN} command
18359 The corresponding @value{GDBN} command is @samp{pwd}.
18361 @subsubheading Example
18366 ^done,cwd="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb"
18370 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18371 @node GDB/MI Program Control
18372 @section @sc{gdb/mi} Program control
18374 @subsubheading Program termination
18376 As a result of execution, the inferior program can run to completion, if
18377 it doesn't encounter any breakpoints. In this case the output will
18378 include an exit code, if the program has exited exceptionally.
18380 @subsubheading Examples
18383 Program exited normally:
18391 *stopped,reason="exited-normally"
18396 Program exited exceptionally:
18404 *stopped,reason="exited",exit-code="01"
18408 Another way the program can terminate is if it receives a signal such as
18409 @code{SIGINT}. In this case, @sc{gdb/mi} displays this:
18413 *stopped,reason="exited-signalled",signal-name="SIGINT",
18414 signal-meaning="Interrupt"
18418 @subheading The @code{-exec-abort} Command
18419 @findex -exec-abort
18421 @subsubheading Synopsis
18427 Kill the inferior running program.
18429 @subsubheading @value{GDBN} Command
18431 The corresponding @value{GDBN} command is @samp{kill}.
18433 @subsubheading Example
18437 @subheading The @code{-exec-arguments} Command
18438 @findex -exec-arguments
18440 @subsubheading Synopsis
18443 -exec-arguments @var{args}
18446 Set the inferior program arguments, to be used in the next
18449 @subsubheading @value{GDBN} Command
18451 The corresponding @value{GDBN} command is @samp{set args}.
18453 @subsubheading Example
18456 Don't have one around.
18459 @subheading The @code{-exec-continue} Command
18460 @findex -exec-continue
18462 @subsubheading Synopsis
18468 Asynchronous command. Resumes the execution of the inferior program
18469 until a breakpoint is encountered, or until the inferior exits.
18471 @subsubheading @value{GDBN} Command
18473 The corresponding @value{GDBN} corresponding is @samp{continue}.
18475 @subsubheading Example
18482 *stopped,reason="breakpoint-hit",bkptno="2",frame=@{func="foo",args=[],
18483 file="hello.c",fullname="/home/foo/bar/devo/myproject/hello.c",line="13"@}
18488 @subheading The @code{-exec-finish} Command
18489 @findex -exec-finish
18491 @subsubheading Synopsis
18497 Asynchronous command. Resumes the execution of the inferior program
18498 until the current function is exited. Displays the results returned by
18501 @subsubheading @value{GDBN} Command
18503 The corresponding @value{GDBN} command is @samp{finish}.
18505 @subsubheading Example
18507 Function returning @code{void}.
18514 *stopped,reason="function-finished",frame=@{func="main",args=[],
18515 file="hello.c",fullname="/home/foo/bar/devo/myproject/hello.c",line="7"@}
18519 Function returning other than @code{void}. The name of the internal
18520 @value{GDBN} variable storing the result is printed, together with the
18527 *stopped,reason="function-finished",frame=@{addr="0x000107b0",func="foo",
18528 args=[@{name="a",value="1"],@{name="b",value="9"@}@},
18529 file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="14"@},
18530 gdb-result-var="$1",return-value="0"
18535 @subheading The @code{-exec-interrupt} Command
18536 @findex -exec-interrupt
18538 @subsubheading Synopsis
18544 Asynchronous command. Interrupts the background execution of the target.
18545 Note how the token associated with the stop message is the one for the
18546 execution command that has been interrupted. The token for the interrupt
18547 itself only appears in the @samp{^done} output. If the user is trying to
18548 interrupt a non-running program, an error message will be printed.
18550 @subsubheading @value{GDBN} Command
18552 The corresponding @value{GDBN} command is @samp{interrupt}.
18554 @subsubheading Example
18565 111*stopped,signal-name="SIGINT",signal-meaning="Interrupt",
18566 frame=@{addr="0x00010140",func="foo",args=[],file="try.c",
18567 fullname="/home/foo/bar/devo/myproject/try.c",line="13"@}
18572 ^error,msg="mi_cmd_exec_interrupt: Inferior not executing."
18577 @subheading The @code{-exec-next} Command
18580 @subsubheading Synopsis
18586 Asynchronous command. Resumes execution of the inferior program, stopping
18587 when the beginning of the next source line is reached.
18589 @subsubheading @value{GDBN} Command
18591 The corresponding @value{GDBN} command is @samp{next}.
18593 @subsubheading Example
18599 *stopped,reason="end-stepping-range",line="8",file="hello.c"
18604 @subheading The @code{-exec-next-instruction} Command
18605 @findex -exec-next-instruction
18607 @subsubheading Synopsis
18610 -exec-next-instruction
18613 Asynchronous command. Executes one machine instruction. If the
18614 instruction is a function call continues until the function returns. If
18615 the program stops at an instruction in the middle of a source line, the
18616 address will be printed as well.
18618 @subsubheading @value{GDBN} Command
18620 The corresponding @value{GDBN} command is @samp{nexti}.
18622 @subsubheading Example
18626 -exec-next-instruction
18630 *stopped,reason="end-stepping-range",
18631 addr="0x000100d4",line="5",file="hello.c"
18636 @subheading The @code{-exec-return} Command
18637 @findex -exec-return
18639 @subsubheading Synopsis
18645 Makes current function return immediately. Doesn't execute the inferior.
18646 Displays the new current frame.
18648 @subsubheading @value{GDBN} Command
18650 The corresponding @value{GDBN} command is @samp{return}.
18652 @subsubheading Example
18656 200-break-insert callee4
18657 200^done,bkpt=@{number="1",addr="0x00010734",
18658 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="8"@}
18663 000*stopped,reason="breakpoint-hit",bkptno="1",
18664 frame=@{func="callee4",args=[],
18665 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
18666 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="8"@}
18672 111^done,frame=@{level="0",func="callee3",
18673 args=[@{name="strarg",
18674 value="0x11940 \"A string argument.\""@}],
18675 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
18676 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="18"@}
18681 @subheading The @code{-exec-run} Command
18684 @subsubheading Synopsis
18690 Asynchronous command. Starts execution of the inferior from the
18691 beginning. The inferior executes until either a breakpoint is
18692 encountered or the program exits.
18694 @subsubheading @value{GDBN} Command
18696 The corresponding @value{GDBN} command is @samp{run}.
18698 @subsubheading Example
18703 ^done,bkpt=@{number="1",addr="0x0001072c",file="recursive2.c",line="4"@}
18708 *stopped,reason="breakpoint-hit",bkptno="1",
18709 frame=@{func="main",args=[],file="recursive2.c",
18710 fullname="/home/foo/bar/devo/myproject/recursive2.c",line="4"@}
18715 @subheading The @code{-exec-show-arguments} Command
18716 @findex -exec-show-arguments
18718 @subsubheading Synopsis
18721 -exec-show-arguments
18724 Print the arguments of the program.
18726 @subsubheading @value{GDBN} Command
18728 The corresponding @value{GDBN} command is @samp{show args}.
18730 @subsubheading Example
18733 @c @subheading -exec-signal
18735 @subheading The @code{-exec-step} Command
18738 @subsubheading Synopsis
18744 Asynchronous command. Resumes execution of the inferior program, stopping
18745 when the beginning of the next source line is reached, if the next
18746 source line is not a function call. If it is, stop at the first
18747 instruction of the called function.
18749 @subsubheading @value{GDBN} Command
18751 The corresponding @value{GDBN} command is @samp{step}.
18753 @subsubheading Example
18755 Stepping into a function:
18761 *stopped,reason="end-stepping-range",
18762 frame=@{func="foo",args=[@{name="a",value="10"@},
18763 @{name="b",value="0"@}],file="recursive2.c",
18764 fullname="/home/foo/bar/devo/myproject/recursive2.c",line="11"@}
18774 *stopped,reason="end-stepping-range",line="14",file="recursive2.c"
18779 @subheading The @code{-exec-step-instruction} Command
18780 @findex -exec-step-instruction
18782 @subsubheading Synopsis
18785 -exec-step-instruction
18788 Asynchronous command. Resumes the inferior which executes one machine
18789 instruction. The output, once @value{GDBN} has stopped, will vary depending on
18790 whether we have stopped in the middle of a source line or not. In the
18791 former case, the address at which the program stopped will be printed as
18794 @subsubheading @value{GDBN} Command
18796 The corresponding @value{GDBN} command is @samp{stepi}.
18798 @subsubheading Example
18802 -exec-step-instruction
18806 *stopped,reason="end-stepping-range",
18807 frame=@{func="foo",args=[],file="try.c",
18808 fullname="/home/foo/bar/devo/myproject/try.c",line="10"@}
18810 -exec-step-instruction
18814 *stopped,reason="end-stepping-range",
18815 frame=@{addr="0x000100f4",func="foo",args=[],file="try.c",
18816 fullname="/home/foo/bar/devo/myproject/try.c",line="10"@}
18821 @subheading The @code{-exec-until} Command
18822 @findex -exec-until
18824 @subsubheading Synopsis
18827 -exec-until [ @var{location} ]
18830 Asynchronous command. Executes the inferior until the @var{location}
18831 specified in the argument is reached. If there is no argument, the inferior
18832 executes until a source line greater than the current one is reached.
18833 The reason for stopping in this case will be @samp{location-reached}.
18835 @subsubheading @value{GDBN} Command
18837 The corresponding @value{GDBN} command is @samp{until}.
18839 @subsubheading Example
18843 -exec-until recursive2.c:6
18847 *stopped,reason="location-reached",frame=@{func="main",args=[],
18848 file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="6"@}
18853 @subheading -file-clear
18854 Is this going away????
18858 @subheading The @code{-file-exec-and-symbols} Command
18859 @findex -file-exec-and-symbols
18861 @subsubheading Synopsis
18864 -file-exec-and-symbols @var{file}
18867 Specify the executable file to be debugged. This file is the one from
18868 which the symbol table is also read. If no file is specified, the
18869 command clears the executable and symbol information. If breakpoints
18870 are set when using this command with no arguments, @value{GDBN} will produce
18871 error messages. Otherwise, no output is produced, except a completion
18874 @subsubheading @value{GDBN} Command
18876 The corresponding @value{GDBN} command is @samp{file}.
18878 @subsubheading Example
18882 -file-exec-and-symbols /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx
18888 @subheading The @code{-file-exec-file} Command
18889 @findex -file-exec-file
18891 @subsubheading Synopsis
18894 -file-exec-file @var{file}
18897 Specify the executable file to be debugged. Unlike
18898 @samp{-file-exec-and-symbols}, the symbol table is @emph{not} read
18899 from this file. If used without argument, @value{GDBN} clears the information
18900 about the executable file. No output is produced, except a completion
18903 @subsubheading @value{GDBN} Command
18905 The corresponding @value{GDBN} command is @samp{exec-file}.
18907 @subsubheading Example
18911 -file-exec-file /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx
18917 @subheading The @code{-file-list-exec-sections} Command
18918 @findex -file-list-exec-sections
18920 @subsubheading Synopsis
18923 -file-list-exec-sections
18926 List the sections of the current executable file.
18928 @subsubheading @value{GDBN} Command
18930 The @value{GDBN} command @samp{info file} shows, among the rest, the same
18931 information as this command. @code{gdbtk} has a corresponding command
18932 @samp{gdb_load_info}.
18934 @subsubheading Example
18938 @subheading The @code{-file-list-exec-source-file} Command
18939 @findex -file-list-exec-source-file
18941 @subsubheading Synopsis
18944 -file-list-exec-source-file
18947 List the line number, the current source file, and the absolute path
18948 to the current source file for the current executable.
18950 @subsubheading @value{GDBN} Command
18952 There's no @value{GDBN} command which directly corresponds to this one.
18954 @subsubheading Example
18958 123-file-list-exec-source-file
18959 123^done,line="1",file="foo.c",fullname="/home/bar/foo.c"
18964 @subheading The @code{-file-list-exec-source-files} Command
18965 @findex -file-list-exec-source-files
18967 @subsubheading Synopsis
18970 -file-list-exec-source-files
18973 List the source files for the current executable.
18975 It will always output the filename, but only when GDB can find the absolute
18976 file name of a source file, will it output the fullname.
18978 @subsubheading @value{GDBN} Command
18980 There's no @value{GDBN} command which directly corresponds to this one.
18981 @code{gdbtk} has an analogous command @samp{gdb_listfiles}.
18983 @subsubheading Example
18986 -file-list-exec-source-files
18988 @{file=foo.c,fullname=/home/foo.c@},
18989 @{file=/home/bar.c,fullname=/home/bar.c@},
18990 @{file=gdb_could_not_find_fullpath.c@}]
18994 @subheading The @code{-file-list-shared-libraries} Command
18995 @findex -file-list-shared-libraries
18997 @subsubheading Synopsis
19000 -file-list-shared-libraries
19003 List the shared libraries in the program.
19005 @subsubheading @value{GDBN} Command
19007 The corresponding @value{GDBN} command is @samp{info shared}.
19009 @subsubheading Example
19013 @subheading The @code{-file-list-symbol-files} Command
19014 @findex -file-list-symbol-files
19016 @subsubheading Synopsis
19019 -file-list-symbol-files
19024 @subsubheading @value{GDBN} Command
19026 The corresponding @value{GDBN} command is @samp{info file} (part of it).
19028 @subsubheading Example
19032 @subheading The @code{-file-symbol-file} Command
19033 @findex -file-symbol-file
19035 @subsubheading Synopsis
19038 -file-symbol-file @var{file}
19041 Read symbol table info from the specified @var{file} argument. When
19042 used without arguments, clears @value{GDBN}'s symbol table info. No output is
19043 produced, except for a completion notification.
19045 @subsubheading @value{GDBN} Command
19047 The corresponding @value{GDBN} command is @samp{symbol-file}.
19049 @subsubheading Example
19053 -file-symbol-file /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx
19058 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19059 @node GDB/MI Miscellaneous Commands
19060 @section Miscellaneous @value{GDBN} commands in @sc{gdb/mi}
19062 @c @subheading -gdb-complete
19064 @subheading The @code{-gdb-exit} Command
19067 @subsubheading Synopsis
19073 Exit @value{GDBN} immediately.
19075 @subsubheading @value{GDBN} Command
19077 Approximately corresponds to @samp{quit}.
19079 @subsubheading Example
19086 @subheading The @code{-gdb-set} Command
19089 @subsubheading Synopsis
19095 Set an internal @value{GDBN} variable.
19096 @c IS THIS A DOLLAR VARIABLE? OR SOMETHING LIKE ANNOTATE ?????
19098 @subsubheading @value{GDBN} Command
19100 The corresponding @value{GDBN} command is @samp{set}.
19102 @subsubheading Example
19112 @subheading The @code{-gdb-show} Command
19115 @subsubheading Synopsis
19121 Show the current value of a @value{GDBN} variable.
19123 @subsubheading @value{GDBN} command
19125 The corresponding @value{GDBN} command is @samp{show}.
19127 @subsubheading Example
19136 @c @subheading -gdb-source
19139 @subheading The @code{-gdb-version} Command
19140 @findex -gdb-version
19142 @subsubheading Synopsis
19148 Show version information for @value{GDBN}. Used mostly in testing.
19150 @subsubheading @value{GDBN} Command
19152 There's no equivalent @value{GDBN} command. @value{GDBN} by default shows this
19153 information when you start an interactive session.
19155 @subsubheading Example
19157 @c This example modifies the actual output from GDB to avoid overfull
19163 ~Copyright 2000 Free Software Foundation, Inc.
19164 ~GDB is free software, covered by the GNU General Public License, and
19165 ~you are welcome to change it and/or distribute copies of it under
19166 ~ certain conditions.
19167 ~Type "show copying" to see the conditions.
19168 ~There is absolutely no warranty for GDB. Type "show warranty" for
19170 ~This GDB was configured as
19171 "--host=sparc-sun-solaris2.5.1 --target=ppc-eabi".
19176 @subheading The @code{-interpreter-exec} Command
19177 @findex -interpreter-exec
19179 @subheading Synopsis
19182 -interpreter-exec @var{interpreter} @var{command}
19185 Execute the specified @var{command} in the given @var{interpreter}.
19187 @subheading @value{GDBN} Command
19189 The corresponding @value{GDBN} command is @samp{interpreter-exec}.
19191 @subheading Example
19195 -interpreter-exec console "break main"
19196 &"During symbol reading, couldn't parse type; debugger out of date?.\n"
19197 &"During symbol reading, bad structure-type format.\n"
19198 ~"Breakpoint 1 at 0x8074fc6: file ../../src/gdb/main.c, line 743.\n"
19203 @subheading The @code{-inferior-tty-set} Command
19204 @findex -inferior-tty-set
19206 @subheading Synopsis
19209 -inferior-tty-set /dev/pts/1
19212 Set terminal for future runs of the program being debugged.
19214 @subheading @value{GDBN} Command
19216 The corresponding @value{GDBN} command is @samp{set inferior-tty /dev/pts/1}.
19218 @subheading Example
19222 -inferior-tty-set /dev/pts/1
19227 @subheading The @code{-inferior-tty-show} Command
19228 @findex -inferior-tty-show
19230 @subheading Synopsis
19236 Show terminal for future runs of program being debugged.
19238 @subheading @value{GDBN} Command
19240 The corresponding @value{GDBN} command is @samp{show inferior-tty}.
19242 @subheading Example
19246 -inferior-tty-set /dev/pts/1
19250 ^done,inferior_tty_terminal="/dev/pts/1"
19255 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19256 @node GDB/MI Kod Commands
19257 @section @sc{gdb/mi} Kod Commands
19259 The Kod commands are not implemented.
19261 @c @subheading -kod-info
19263 @c @subheading -kod-list
19265 @c @subheading -kod-list-object-types
19267 @c @subheading -kod-show
19269 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19270 @node GDB/MI Memory Overlay Commands
19271 @section @sc{gdb/mi} Memory Overlay Commands
19273 The memory overlay commands are not implemented.
19275 @c @subheading -overlay-auto
19277 @c @subheading -overlay-list-mapping-state
19279 @c @subheading -overlay-list-overlays
19281 @c @subheading -overlay-map
19283 @c @subheading -overlay-off
19285 @c @subheading -overlay-on
19287 @c @subheading -overlay-unmap
19289 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19290 @node GDB/MI Signal Handling Commands
19291 @section @sc{gdb/mi} Signal Handling Commands
19293 Signal handling commands are not implemented.
19295 @c @subheading -signal-handle
19297 @c @subheading -signal-list-handle-actions
19299 @c @subheading -signal-list-signal-types
19303 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19304 @node GDB/MI Stack Manipulation
19305 @section @sc{gdb/mi} Stack Manipulation Commands
19308 @subheading The @code{-stack-info-frame} Command
19309 @findex -stack-info-frame
19311 @subsubheading Synopsis
19317 Get info on the selected frame.
19319 @subsubheading @value{GDBN} Command
19321 The corresponding @value{GDBN} command is @samp{info frame} or @samp{frame}
19322 (without arguments).
19324 @subsubheading Example
19329 ^done,frame=@{level="1",addr="0x0001076c",func="callee3",
19330 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
19331 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="17"@}
19335 @subheading The @code{-stack-info-depth} Command
19336 @findex -stack-info-depth
19338 @subsubheading Synopsis
19341 -stack-info-depth [ @var{max-depth} ]
19344 Return the depth of the stack. If the integer argument @var{max-depth}
19345 is specified, do not count beyond @var{max-depth} frames.
19347 @subsubheading @value{GDBN} Command
19349 There's no equivalent @value{GDBN} command.
19351 @subsubheading Example
19353 For a stack with frame levels 0 through 11:
19360 -stack-info-depth 4
19363 -stack-info-depth 12
19366 -stack-info-depth 11
19369 -stack-info-depth 13
19374 @subheading The @code{-stack-list-arguments} Command
19375 @findex -stack-list-arguments
19377 @subsubheading Synopsis
19380 -stack-list-arguments @var{show-values}
19381 [ @var{low-frame} @var{high-frame} ]
19384 Display a list of the arguments for the frames between @var{low-frame}
19385 and @var{high-frame} (inclusive). If @var{low-frame} and
19386 @var{high-frame} are not provided, list the arguments for the whole call
19389 The @var{show-values} argument must have a value of 0 or 1. A value of
19390 0 means that only the names of the arguments are listed, a value of 1
19391 means that both names and values of the arguments are printed.
19393 @subsubheading @value{GDBN} Command
19395 @value{GDBN} does not have an equivalent command. @code{gdbtk} has a
19396 @samp{gdb_get_args} command which partially overlaps with the
19397 functionality of @samp{-stack-list-arguments}.
19399 @subsubheading Example
19406 frame=@{level="0",addr="0x00010734",func="callee4",
19407 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
19408 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="8"@},
19409 frame=@{level="1",addr="0x0001076c",func="callee3",
19410 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
19411 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="17"@},
19412 frame=@{level="2",addr="0x0001078c",func="callee2",
19413 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
19414 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="22"@},
19415 frame=@{level="3",addr="0x000107b4",func="callee1",
19416 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
19417 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="27"@},
19418 frame=@{level="4",addr="0x000107e0",func="main",
19419 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
19420 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="32"@}]
19422 -stack-list-arguments 0
19425 frame=@{level="0",args=[]@},
19426 frame=@{level="1",args=[name="strarg"]@},
19427 frame=@{level="2",args=[name="intarg",name="strarg"]@},
19428 frame=@{level="3",args=[name="intarg",name="strarg",name="fltarg"]@},
19429 frame=@{level="4",args=[]@}]
19431 -stack-list-arguments 1
19434 frame=@{level="0",args=[]@},
19436 args=[@{name="strarg",value="0x11940 \"A string argument.\""@}]@},
19437 frame=@{level="2",args=[
19438 @{name="intarg",value="2"@},
19439 @{name="strarg",value="0x11940 \"A string argument.\""@}]@},
19440 @{frame=@{level="3",args=[
19441 @{name="intarg",value="2"@},
19442 @{name="strarg",value="0x11940 \"A string argument.\""@},
19443 @{name="fltarg",value="3.5"@}]@},
19444 frame=@{level="4",args=[]@}]
19446 -stack-list-arguments 0 2 2
19447 ^done,stack-args=[frame=@{level="2",args=[name="intarg",name="strarg"]@}]
19449 -stack-list-arguments 1 2 2
19450 ^done,stack-args=[frame=@{level="2",
19451 args=[@{name="intarg",value="2"@},
19452 @{name="strarg",value="0x11940 \"A string argument.\""@}]@}]
19456 @c @subheading -stack-list-exception-handlers
19459 @subheading The @code{-stack-list-frames} Command
19460 @findex -stack-list-frames
19462 @subsubheading Synopsis
19465 -stack-list-frames [ @var{low-frame} @var{high-frame} ]
19468 List the frames currently on the stack. For each frame it displays the
19473 The frame number, 0 being the topmost frame, i.e. the innermost function.
19475 The @code{$pc} value for that frame.
19479 File name of the source file where the function lives.
19481 Line number corresponding to the @code{$pc}.
19484 If invoked without arguments, this command prints a backtrace for the
19485 whole stack. If given two integer arguments, it shows the frames whose
19486 levels are between the two arguments (inclusive). If the two arguments
19487 are equal, it shows the single frame at the corresponding level.
19489 @subsubheading @value{GDBN} Command
19491 The corresponding @value{GDBN} commands are @samp{backtrace} and @samp{where}.
19493 @subsubheading Example
19495 Full stack backtrace:
19501 [frame=@{level="0",addr="0x0001076c",func="foo",
19502 file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="11"@},
19503 frame=@{level="1",addr="0x000107a4",func="foo",
19504 file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="14"@},
19505 frame=@{level="2",addr="0x000107a4",func="foo",
19506 file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="14"@},
19507 frame=@{level="3",addr="0x000107a4",func="foo",
19508 file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="14"@},
19509 frame=@{level="4",addr="0x000107a4",func="foo",
19510 file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="14"@},
19511 frame=@{level="5",addr="0x000107a4",func="foo",
19512 file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="14"@},
19513 frame=@{level="6",addr="0x000107a4",func="foo",
19514 file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="14"@},
19515 frame=@{level="7",addr="0x000107a4",func="foo",
19516 file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="14"@},
19517 frame=@{level="8",addr="0x000107a4",func="foo",
19518 file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="14"@},
19519 frame=@{level="9",addr="0x000107a4",func="foo",
19520 file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="14"@},
19521 frame=@{level="10",addr="0x000107a4",func="foo",
19522 file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="14"@},
19523 frame=@{level="11",addr="0x00010738",func="main",
19524 file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="4"@}]
19528 Show frames between @var{low_frame} and @var{high_frame}:
19532 -stack-list-frames 3 5
19534 [frame=@{level="3",addr="0x000107a4",func="foo",
19535 file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="14"@},
19536 frame=@{level="4",addr="0x000107a4",func="foo",
19537 file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="14"@},
19538 frame=@{level="5",addr="0x000107a4",func="foo",
19539 file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="14"@}]
19543 Show a single frame:
19547 -stack-list-frames 3 3
19549 [frame=@{level="3",addr="0x000107a4",func="foo",
19550 file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="14"@}]
19555 @subheading The @code{-stack-list-locals} Command
19556 @findex -stack-list-locals
19558 @subsubheading Synopsis
19561 -stack-list-locals @var{print-values}
19564 Display the local variable names for the selected frame. If
19565 @var{print-values} is 0 or @code{--no-values}, print only the names of
19566 the variables; if it is 1 or @code{--all-values}, print also their
19567 values; and if it is 2 or @code{--simple-values}, print the name,
19568 type and value for simple data types and the name and type for arrays,
19569 structures and unions. In this last case, a frontend can immediately
19570 display the value of simple data types and create variable objects for
19571 other data types when the the user wishes to explore their values in
19574 @subsubheading @value{GDBN} Command
19576 @samp{info locals} in @value{GDBN}, @samp{gdb_get_locals} in @code{gdbtk}.
19578 @subsubheading Example
19582 -stack-list-locals 0
19583 ^done,locals=[name="A",name="B",name="C"]
19585 -stack-list-locals --all-values
19586 ^done,locals=[@{name="A",value="1"@},@{name="B",value="2"@},
19587 @{name="C",value="@{1, 2, 3@}"@}]
19588 -stack-list-locals --simple-values
19589 ^done,locals=[@{name="A",type="int",value="1"@},
19590 @{name="B",type="int",value="2"@},@{name="C",type="int [3]"@}]
19595 @subheading The @code{-stack-select-frame} Command
19596 @findex -stack-select-frame
19598 @subsubheading Synopsis
19601 -stack-select-frame @var{framenum}
19604 Change the selected frame. Select a different frame @var{framenum} on
19607 @subsubheading @value{GDBN} Command
19609 The corresponding @value{GDBN} commands are @samp{frame}, @samp{up},
19610 @samp{down}, @samp{select-frame}, @samp{up-silent}, and @samp{down-silent}.
19612 @subsubheading Example
19616 -stack-select-frame 2
19621 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19622 @node GDB/MI Symbol Query
19623 @section @sc{gdb/mi} Symbol Query Commands
19626 @subheading The @code{-symbol-info-address} Command
19627 @findex -symbol-info-address
19629 @subsubheading Synopsis
19632 -symbol-info-address @var{symbol}
19635 Describe where @var{symbol} is stored.
19637 @subsubheading @value{GDBN} Command
19639 The corresponding @value{GDBN} command is @samp{info address}.
19641 @subsubheading Example
19645 @subheading The @code{-symbol-info-file} Command
19646 @findex -symbol-info-file
19648 @subsubheading Synopsis
19654 Show the file for the symbol.
19656 @subsubheading @value{GDBN} Command
19658 There's no equivalent @value{GDBN} command. @code{gdbtk} has
19659 @samp{gdb_find_file}.
19661 @subsubheading Example
19665 @subheading The @code{-symbol-info-function} Command
19666 @findex -symbol-info-function
19668 @subsubheading Synopsis
19671 -symbol-info-function
19674 Show which function the symbol lives in.
19676 @subsubheading @value{GDBN} Command
19678 @samp{gdb_get_function} in @code{gdbtk}.
19680 @subsubheading Example
19684 @subheading The @code{-symbol-info-line} Command
19685 @findex -symbol-info-line
19687 @subsubheading Synopsis
19693 Show the core addresses of the code for a source line.
19695 @subsubheading @value{GDBN} Command
19697 The corresponding @value{GDBN} command is @samp{info line}.
19698 @code{gdbtk} has the @samp{gdb_get_line} and @samp{gdb_get_file} commands.
19700 @subsubheading Example
19704 @subheading The @code{-symbol-info-symbol} Command
19705 @findex -symbol-info-symbol
19707 @subsubheading Synopsis
19710 -symbol-info-symbol @var{addr}
19713 Describe what symbol is at location @var{addr}.
19715 @subsubheading @value{GDBN} Command
19717 The corresponding @value{GDBN} command is @samp{info symbol}.
19719 @subsubheading Example
19723 @subheading The @code{-symbol-list-functions} Command
19724 @findex -symbol-list-functions
19726 @subsubheading Synopsis
19729 -symbol-list-functions
19732 List the functions in the executable.
19734 @subsubheading @value{GDBN} Command
19736 @samp{info functions} in @value{GDBN}, @samp{gdb_listfunc} and
19737 @samp{gdb_search} in @code{gdbtk}.
19739 @subsubheading Example
19743 @subheading The @code{-symbol-list-lines} Command
19744 @findex -symbol-list-lines
19746 @subsubheading Synopsis
19749 -symbol-list-lines @var{filename}
19752 Print the list of lines that contain code and their associated program
19753 addresses for the given source filename. The entries are sorted in
19754 ascending PC order.
19756 @subsubheading @value{GDBN} Command
19758 There is no corresponding @value{GDBN} command.
19760 @subsubheading Example
19763 -symbol-list-lines basics.c
19764 ^done,lines=[@{pc="0x08048554",line="7"@},@{pc="0x0804855a",line="8"@}]
19769 @subheading The @code{-symbol-list-types} Command
19770 @findex -symbol-list-types
19772 @subsubheading Synopsis
19778 List all the type names.
19780 @subsubheading @value{GDBN} Command
19782 The corresponding commands are @samp{info types} in @value{GDBN},
19783 @samp{gdb_search} in @code{gdbtk}.
19785 @subsubheading Example
19789 @subheading The @code{-symbol-list-variables} Command
19790 @findex -symbol-list-variables
19792 @subsubheading Synopsis
19795 -symbol-list-variables
19798 List all the global and static variable names.
19800 @subsubheading @value{GDBN} Command
19802 @samp{info variables} in @value{GDBN}, @samp{gdb_search} in @code{gdbtk}.
19804 @subsubheading Example
19808 @subheading The @code{-symbol-locate} Command
19809 @findex -symbol-locate
19811 @subsubheading Synopsis
19817 @subsubheading @value{GDBN} Command
19819 @samp{gdb_loc} in @code{gdbtk}.
19821 @subsubheading Example
19825 @subheading The @code{-symbol-type} Command
19826 @findex -symbol-type
19828 @subsubheading Synopsis
19831 -symbol-type @var{variable}
19834 Show type of @var{variable}.
19836 @subsubheading @value{GDBN} Command
19838 The corresponding @value{GDBN} command is @samp{ptype}, @code{gdbtk} has
19839 @samp{gdb_obj_variable}.
19841 @subsubheading Example
19845 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19846 @node GDB/MI Target Manipulation
19847 @section @sc{gdb/mi} Target Manipulation Commands
19850 @subheading The @code{-target-attach} Command
19851 @findex -target-attach
19853 @subsubheading Synopsis
19856 -target-attach @var{pid} | @var{file}
19859 Attach to a process @var{pid} or a file @var{file} outside of @value{GDBN}.
19861 @subsubheading @value{GDBN} command
19863 The corresponding @value{GDBN} command is @samp{attach}.
19865 @subsubheading Example
19869 @subheading The @code{-target-compare-sections} Command
19870 @findex -target-compare-sections
19872 @subsubheading Synopsis
19875 -target-compare-sections [ @var{section} ]
19878 Compare data of section @var{section} on target to the exec file.
19879 Without the argument, all sections are compared.
19881 @subsubheading @value{GDBN} Command
19883 The @value{GDBN} equivalent is @samp{compare-sections}.
19885 @subsubheading Example
19889 @subheading The @code{-target-detach} Command
19890 @findex -target-detach
19892 @subsubheading Synopsis
19898 Disconnect from the remote target. There's no output.
19900 @subsubheading @value{GDBN} command
19902 The corresponding @value{GDBN} command is @samp{detach}.
19904 @subsubheading Example
19914 @subheading The @code{-target-disconnect} Command
19915 @findex -target-disconnect
19917 @subsubheading Synopsis
19923 Disconnect from the remote target. There's no output.
19925 @subsubheading @value{GDBN} command
19927 The corresponding @value{GDBN} command is @samp{disconnect}.
19929 @subsubheading Example
19939 @subheading The @code{-target-download} Command
19940 @findex -target-download
19942 @subsubheading Synopsis
19948 Loads the executable onto the remote target.
19949 It prints out an update message every half second, which includes the fields:
19953 The name of the section.
19955 The size of what has been sent so far for that section.
19957 The size of the section.
19959 The total size of what was sent so far (the current and the previous sections).
19961 The size of the overall executable to download.
19965 Each message is sent as status record (@pxref{GDB/MI Output Syntax, ,
19966 @sc{gdb/mi} Output Syntax}).
19968 In addition, it prints the name and size of the sections, as they are
19969 downloaded. These messages include the following fields:
19973 The name of the section.
19975 The size of the section.
19977 The size of the overall executable to download.
19981 At the end, a summary is printed.
19983 @subsubheading @value{GDBN} Command
19985 The corresponding @value{GDBN} command is @samp{load}.
19987 @subsubheading Example
19989 Note: each status message appears on a single line. Here the messages
19990 have been broken down so that they can fit onto a page.
19995 +download,@{section=".text",section-size="6668",total-size="9880"@}
19996 +download,@{section=".text",section-sent="512",section-size="6668",
19997 total-sent="512",total-size="9880"@}
19998 +download,@{section=".text",section-sent="1024",section-size="6668",
19999 total-sent="1024",total-size="9880"@}
20000 +download,@{section=".text",section-sent="1536",section-size="6668",
20001 total-sent="1536",total-size="9880"@}
20002 +download,@{section=".text",section-sent="2048",section-size="6668",
20003 total-sent="2048",total-size="9880"@}
20004 +download,@{section=".text",section-sent="2560",section-size="6668",
20005 total-sent="2560",total-size="9880"@}
20006 +download,@{section=".text",section-sent="3072",section-size="6668",
20007 total-sent="3072",total-size="9880"@}
20008 +download,@{section=".text",section-sent="3584",section-size="6668",
20009 total-sent="3584",total-size="9880"@}
20010 +download,@{section=".text",section-sent="4096",section-size="6668",
20011 total-sent="4096",total-size="9880"@}
20012 +download,@{section=".text",section-sent="4608",section-size="6668",
20013 total-sent="4608",total-size="9880"@}
20014 +download,@{section=".text",section-sent="5120",section-size="6668",
20015 total-sent="5120",total-size="9880"@}
20016 +download,@{section=".text",section-sent="5632",section-size="6668",
20017 total-sent="5632",total-size="9880"@}
20018 +download,@{section=".text",section-sent="6144",section-size="6668",
20019 total-sent="6144",total-size="9880"@}
20020 +download,@{section=".text",section-sent="6656",section-size="6668",
20021 total-sent="6656",total-size="9880"@}
20022 +download,@{section=".init",section-size="28",total-size="9880"@}
20023 +download,@{section=".fini",section-size="28",total-size="9880"@}
20024 +download,@{section=".data",section-size="3156",total-size="9880"@}
20025 +download,@{section=".data",section-sent="512",section-size="3156",
20026 total-sent="7236",total-size="9880"@}
20027 +download,@{section=".data",section-sent="1024",section-size="3156",
20028 total-sent="7748",total-size="9880"@}
20029 +download,@{section=".data",section-sent="1536",section-size="3156",
20030 total-sent="8260",total-size="9880"@}
20031 +download,@{section=".data",section-sent="2048",section-size="3156",
20032 total-sent="8772",total-size="9880"@}
20033 +download,@{section=".data",section-sent="2560",section-size="3156",
20034 total-sent="9284",total-size="9880"@}
20035 +download,@{section=".data",section-sent="3072",section-size="3156",
20036 total-sent="9796",total-size="9880"@}
20037 ^done,address="0x10004",load-size="9880",transfer-rate="6586",
20043 @subheading The @code{-target-exec-status} Command
20044 @findex -target-exec-status
20046 @subsubheading Synopsis
20049 -target-exec-status
20052 Provide information on the state of the target (whether it is running or
20053 not, for instance).
20055 @subsubheading @value{GDBN} Command
20057 There's no equivalent @value{GDBN} command.
20059 @subsubheading Example
20063 @subheading The @code{-target-list-available-targets} Command
20064 @findex -target-list-available-targets
20066 @subsubheading Synopsis
20069 -target-list-available-targets
20072 List the possible targets to connect to.
20074 @subsubheading @value{GDBN} Command
20076 The corresponding @value{GDBN} command is @samp{help target}.
20078 @subsubheading Example
20082 @subheading The @code{-target-list-current-targets} Command
20083 @findex -target-list-current-targets
20085 @subsubheading Synopsis
20088 -target-list-current-targets
20091 Describe the current target.
20093 @subsubheading @value{GDBN} Command
20095 The corresponding information is printed by @samp{info file} (among
20098 @subsubheading Example
20102 @subheading The @code{-target-list-parameters} Command
20103 @findex -target-list-parameters
20105 @subsubheading Synopsis
20108 -target-list-parameters
20113 @subsubheading @value{GDBN} Command
20117 @subsubheading Example
20121 @subheading The @code{-target-select} Command
20122 @findex -target-select
20124 @subsubheading Synopsis
20127 -target-select @var{type} @var{parameters @dots{}}
20130 Connect @value{GDBN} to the remote target. This command takes two args:
20134 The type of target, for instance @samp{async}, @samp{remote}, etc.
20135 @item @var{parameters}
20136 Device names, host names and the like. @xref{Target Commands, ,
20137 Commands for managing targets}, for more details.
20140 The output is a connection notification, followed by the address at
20141 which the target program is, in the following form:
20144 ^connected,addr="@var{address}",func="@var{function name}",
20145 args=[@var{arg list}]
20148 @subsubheading @value{GDBN} Command
20150 The corresponding @value{GDBN} command is @samp{target}.
20152 @subsubheading Example
20156 -target-select async /dev/ttya
20157 ^connected,addr="0xfe00a300",func="??",args=[]
20161 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
20162 @node GDB/MI Thread Commands
20163 @section @sc{gdb/mi} Thread Commands
20166 @subheading The @code{-thread-info} Command
20167 @findex -thread-info
20169 @subsubheading Synopsis
20175 @subsubheading @value{GDBN} command
20179 @subsubheading Example
20183 @subheading The @code{-thread-list-all-threads} Command
20184 @findex -thread-list-all-threads
20186 @subsubheading Synopsis
20189 -thread-list-all-threads
20192 @subsubheading @value{GDBN} Command
20194 The equivalent @value{GDBN} command is @samp{info threads}.
20196 @subsubheading Example
20200 @subheading The @code{-thread-list-ids} Command
20201 @findex -thread-list-ids
20203 @subsubheading Synopsis
20209 Produces a list of the currently known @value{GDBN} thread ids. At the
20210 end of the list it also prints the total number of such threads.
20212 @subsubheading @value{GDBN} Command
20214 Part of @samp{info threads} supplies the same information.
20216 @subsubheading Example
20218 No threads present, besides the main process:
20223 ^done,thread-ids=@{@},number-of-threads="0"
20233 ^done,thread-ids=@{thread-id="3",thread-id="2",thread-id="1"@},
20234 number-of-threads="3"
20239 @subheading The @code{-thread-select} Command
20240 @findex -thread-select
20242 @subsubheading Synopsis
20245 -thread-select @var{threadnum}
20248 Make @var{threadnum} the current thread. It prints the number of the new
20249 current thread, and the topmost frame for that thread.
20251 @subsubheading @value{GDBN} Command
20253 The corresponding @value{GDBN} command is @samp{thread}.
20255 @subsubheading Example
20262 *stopped,reason="end-stepping-range",thread-id="2",line="187",
20263 file="../../../devo/gdb/testsuite/gdb.threads/linux-dp.c"
20267 thread-ids=@{thread-id="3",thread-id="2",thread-id="1"@},
20268 number-of-threads="3"
20271 ^done,new-thread-id="3",
20272 frame=@{level="0",func="vprintf",
20273 args=[@{name="format",value="0x8048e9c \"%*s%c %d %c\\n\""@},
20274 @{name="arg",value="0x2"@}],file="vprintf.c",line="31"@}
20278 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
20279 @node GDB/MI Tracepoint Commands
20280 @section @sc{gdb/mi} Tracepoint Commands
20282 The tracepoint commands are not yet implemented.
20284 @c @subheading -trace-actions
20286 @c @subheading -trace-delete
20288 @c @subheading -trace-disable
20290 @c @subheading -trace-dump
20292 @c @subheading -trace-enable
20294 @c @subheading -trace-exists
20296 @c @subheading -trace-find
20298 @c @subheading -trace-frame-number
20300 @c @subheading -trace-info
20302 @c @subheading -trace-insert
20304 @c @subheading -trace-list
20306 @c @subheading -trace-pass-count
20308 @c @subheading -trace-save
20310 @c @subheading -trace-start
20312 @c @subheading -trace-stop
20315 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
20316 @node GDB/MI Variable Objects
20317 @section @sc{gdb/mi} Variable Objects
20320 @subheading Motivation for Variable Objects in @sc{gdb/mi}
20322 For the implementation of a variable debugger window (locals, watched
20323 expressions, etc.), we are proposing the adaptation of the existing code
20324 used by @code{Insight}.
20326 The two main reasons for that are:
20330 It has been proven in practice (it is already on its second generation).
20333 It will shorten development time (needless to say how important it is
20337 The original interface was designed to be used by Tcl code, so it was
20338 slightly changed so it could be used through @sc{gdb/mi}. This section
20339 describes the @sc{gdb/mi} operations that will be available and gives some
20340 hints about their use.
20342 @emph{Note}: In addition to the set of operations described here, we
20343 expect the @sc{gui} implementation of a variable window to require, at
20344 least, the following operations:
20347 @item @code{-gdb-show} @code{output-radix}
20348 @item @code{-stack-list-arguments}
20349 @item @code{-stack-list-locals}
20350 @item @code{-stack-select-frame}
20353 @subheading Introduction to Variable Objects in @sc{gdb/mi}
20355 @cindex variable objects in @sc{gdb/mi}
20356 The basic idea behind variable objects is the creation of a named object
20357 to represent a variable, an expression, a memory location or even a CPU
20358 register. For each object created, a set of operations is available for
20359 examining or changing its properties.
20361 Furthermore, complex data types, such as C structures, are represented
20362 in a tree format. For instance, the @code{struct} type variable is the
20363 root and the children will represent the struct members. If a child
20364 is itself of a complex type, it will also have children of its own.
20365 Appropriate language differences are handled for C, C@t{++} and Java.
20367 When returning the actual values of the objects, this facility allows
20368 for the individual selection of the display format used in the result
20369 creation. It can be chosen among: binary, decimal, hexadecimal, octal
20370 and natural. Natural refers to a default format automatically
20371 chosen based on the variable type (like decimal for an @code{int}, hex
20372 for pointers, etc.).
20374 The following is the complete set of @sc{gdb/mi} operations defined to
20375 access this functionality:
20377 @multitable @columnfractions .4 .6
20378 @item @strong{Operation}
20379 @tab @strong{Description}
20381 @item @code{-var-create}
20382 @tab create a variable object
20383 @item @code{-var-delete}
20384 @tab delete the variable object and its children
20385 @item @code{-var-set-format}
20386 @tab set the display format of this variable
20387 @item @code{-var-show-format}
20388 @tab show the display format of this variable
20389 @item @code{-var-info-num-children}
20390 @tab tells how many children this object has
20391 @item @code{-var-list-children}
20392 @tab return a list of the object's children
20393 @item @code{-var-info-type}
20394 @tab show the type of this variable object
20395 @item @code{-var-info-expression}
20396 @tab print what this variable object represents
20397 @item @code{-var-show-attributes}
20398 @tab is this variable editable? does it exist here?
20399 @item @code{-var-evaluate-expression}
20400 @tab get the value of this variable
20401 @item @code{-var-assign}
20402 @tab set the value of this variable
20403 @item @code{-var-update}
20404 @tab update the variable and its children
20407 In the next subsection we describe each operation in detail and suggest
20408 how it can be used.
20410 @subheading Description And Use of Operations on Variable Objects
20412 @subheading The @code{-var-create} Command
20413 @findex -var-create
20415 @subsubheading Synopsis
20418 -var-create @{@var{name} | "-"@}
20419 @{@var{frame-addr} | "*"@} @var{expression}
20422 This operation creates a variable object, which allows the monitoring of
20423 a variable, the result of an expression, a memory cell or a CPU
20426 The @var{name} parameter is the string by which the object can be
20427 referenced. It must be unique. If @samp{-} is specified, the varobj
20428 system will generate a string ``varNNNNNN'' automatically. It will be
20429 unique provided that one does not specify @var{name} on that format.
20430 The command fails if a duplicate name is found.
20432 The frame under which the expression should be evaluated can be
20433 specified by @var{frame-addr}. A @samp{*} indicates that the current
20434 frame should be used.
20436 @var{expression} is any expression valid on the current language set (must not
20437 begin with a @samp{*}), or one of the following:
20441 @samp{*@var{addr}}, where @var{addr} is the address of a memory cell
20444 @samp{*@var{addr}-@var{addr}} --- a memory address range (TBD)
20447 @samp{$@var{regname}} --- a CPU register name
20450 @subsubheading Result
20452 This operation returns the name, number of children and the type of the
20453 object created. Type is returned as a string as the ones generated by
20454 the @value{GDBN} CLI:
20457 name="@var{name}",numchild="N",type="@var{type}"
20461 @subheading The @code{-var-delete} Command
20462 @findex -var-delete
20464 @subsubheading Synopsis
20467 -var-delete @var{name}
20470 Deletes a previously created variable object and all of its children.
20472 Returns an error if the object @var{name} is not found.
20475 @subheading The @code{-var-set-format} Command
20476 @findex -var-set-format
20478 @subsubheading Synopsis
20481 -var-set-format @var{name} @var{format-spec}
20484 Sets the output format for the value of the object @var{name} to be
20487 The syntax for the @var{format-spec} is as follows:
20490 @var{format-spec} @expansion{}
20491 @{binary | decimal | hexadecimal | octal | natural@}
20495 @subheading The @code{-var-show-format} Command
20496 @findex -var-show-format
20498 @subsubheading Synopsis
20501 -var-show-format @var{name}
20504 Returns the format used to display the value of the object @var{name}.
20507 @var{format} @expansion{}
20512 @subheading The @code{-var-info-num-children} Command
20513 @findex -var-info-num-children
20515 @subsubheading Synopsis
20518 -var-info-num-children @var{name}
20521 Returns the number of children of a variable object @var{name}:
20528 @subheading The @code{-var-list-children} Command
20529 @findex -var-list-children
20531 @subsubheading Synopsis
20534 -var-list-children [@var{print-values}] @var{name}
20536 @anchor{-var-list-children}
20538 Return a list of the children of the specified variable object and
20539 create variable objects for them, if they do not already exist. With
20540 a single argument or if @var{print-values} has a value for of 0 or
20541 @code{--no-values}, print only the names of the variables; if
20542 @var{print-values} is 1 or @code{--all-values}, also print their
20543 values; and if it is 2 or @code{--simple-values} print the name and
20544 value for simple data types and just the name for arrays, structures
20547 @subsubheading Example
20551 -var-list-children n
20552 ^done,numchild=@var{n},children=[@{name=@var{name},
20553 numchild=@var{n},type=@var{type}@},@r{(repeats N times)}]
20555 -var-list-children --all-values n
20556 ^done,numchild=@var{n},children=[@{name=@var{name},
20557 numchild=@var{n},value=@var{value},type=@var{type}@},@r{(repeats N times)}]
20561 @subheading The @code{-var-info-type} Command
20562 @findex -var-info-type
20564 @subsubheading Synopsis
20567 -var-info-type @var{name}
20570 Returns the type of the specified variable @var{name}. The type is
20571 returned as a string in the same format as it is output by the
20575 type=@var{typename}
20579 @subheading The @code{-var-info-expression} Command
20580 @findex -var-info-expression
20582 @subsubheading Synopsis
20585 -var-info-expression @var{name}
20588 Returns what is represented by the variable object @var{name}:
20591 lang=@var{lang-spec},exp=@var{expression}
20595 where @var{lang-spec} is @code{@{"C" | "C++" | "Java"@}}.
20597 @subheading The @code{-var-show-attributes} Command
20598 @findex -var-show-attributes
20600 @subsubheading Synopsis
20603 -var-show-attributes @var{name}
20606 List attributes of the specified variable object @var{name}:
20609 status=@var{attr} [ ( ,@var{attr} )* ]
20613 where @var{attr} is @code{@{ @{ editable | noneditable @} | TBD @}}.
20615 @subheading The @code{-var-evaluate-expression} Command
20616 @findex -var-evaluate-expression
20618 @subsubheading Synopsis
20621 -var-evaluate-expression @var{name}
20624 Evaluates the expression that is represented by the specified variable
20625 object and returns its value as a string in the current format specified
20632 Note that one must invoke @code{-var-list-children} for a variable
20633 before the value of a child variable can be evaluated.
20635 @subheading The @code{-var-assign} Command
20636 @findex -var-assign
20638 @subsubheading Synopsis
20641 -var-assign @var{name} @var{expression}
20644 Assigns the value of @var{expression} to the variable object specified
20645 by @var{name}. The object must be @samp{editable}. If the variable's
20646 value is altered by the assign, the variable will show up in any
20647 subsequent @code{-var-update} list.
20649 @subsubheading Example
20657 ^done,changelist=[@{name="var1",in_scope="true",type_changed="false"@}]
20661 @subheading The @code{-var-update} Command
20662 @findex -var-update
20664 @subsubheading Synopsis
20667 -var-update [@var{print-values}] @{@var{name} | "*"@}
20670 Update the value of the variable object @var{name} by evaluating its
20671 expression after fetching all the new values from memory or registers.
20672 A @samp{*} causes all existing variable objects to be updated. The
20673 option @var{print-values} determines whether names both and values, or
20674 just names are printed in the manner described for
20675 @code{-var-list-children} (@pxref{-var-list-children}).
20677 @subsubheading Example
20684 -var-update --all-values var1
20685 ^done,changelist=[@{name="var1",value="3",in_scope="true",
20686 type_changed="false"@}]
20691 @chapter @value{GDBN} Annotations
20693 This chapter describes annotations in @value{GDBN}. Annotations were
20694 designed to interface @value{GDBN} to graphical user interfaces or other
20695 similar programs which want to interact with @value{GDBN} at a
20696 relatively high level.
20698 The annotation mechanism has largely been superseeded by @sc{gdb/mi}
20702 This is Edition @value{EDITION}, @value{DATE}.
20706 * Annotations Overview:: What annotations are; the general syntax.
20707 * Prompting:: Annotations marking @value{GDBN}'s need for input.
20708 * Errors:: Annotations for error messages.
20709 * Invalidation:: Some annotations describe things now invalid.
20710 * Annotations for Running::
20711 Whether the program is running, how it stopped, etc.
20712 * Source Annotations:: Annotations describing source code.
20715 @node Annotations Overview
20716 @section What is an Annotation?
20717 @cindex annotations
20719 Annotations start with a newline character, two @samp{control-z}
20720 characters, and the name of the annotation. If there is no additional
20721 information associated with this annotation, the name of the annotation
20722 is followed immediately by a newline. If there is additional
20723 information, the name of the annotation is followed by a space, the
20724 additional information, and a newline. The additional information
20725 cannot contain newline characters.
20727 Any output not beginning with a newline and two @samp{control-z}
20728 characters denotes literal output from @value{GDBN}. Currently there is
20729 no need for @value{GDBN} to output a newline followed by two
20730 @samp{control-z} characters, but if there was such a need, the
20731 annotations could be extended with an @samp{escape} annotation which
20732 means those three characters as output.
20734 The annotation @var{level}, which is specified using the
20735 @option{--annotate} command line option (@pxref{Mode Options}), controls
20736 how much information @value{GDBN} prints together with its prompt,
20737 values of expressions, source lines, and other types of output. Level 0
20738 is for no anntations, level 1 is for use when @value{GDBN} is run as a
20739 subprocess of @sc{gnu} Emacs, level 3 is the maximum annotation suitable
20740 for programs that control @value{GDBN}, and level 2 annotations have
20741 been made obsolete (@pxref{Limitations, , Limitations of the Annotation
20742 Interface, annotate, GDB's Obsolete Annotations}).
20745 @kindex set annotate
20746 @item set annotate @var{level}
20747 The @value{GDBN} command @code{set annotate} sets the level of
20748 annotations to the specified @var{level}.
20750 @item show annotate
20751 @kindex show annotate
20752 Show the current annotation level.
20755 This chapter describes level 3 annotations.
20757 A simple example of starting up @value{GDBN} with annotations is:
20760 $ @kbd{gdb --annotate=3}
20762 Copyright 2003 Free Software Foundation, Inc.
20763 GDB is free software, covered by the GNU General Public License,
20764 and you are welcome to change it and/or distribute copies of it
20765 under certain conditions.
20766 Type "show copying" to see the conditions.
20767 There is absolutely no warranty for GDB. Type "show warranty"
20769 This GDB was configured as "i386-pc-linux-gnu"
20780 Here @samp{quit} is input to @value{GDBN}; the rest is output from
20781 @value{GDBN}. The three lines beginning @samp{^Z^Z} (where @samp{^Z}
20782 denotes a @samp{control-z} character) are annotations; the rest is
20783 output from @value{GDBN}.
20786 @section Annotation for @value{GDBN} Input
20788 @cindex annotations for prompts
20789 When @value{GDBN} prompts for input, it annotates this fact so it is possible
20790 to know when to send output, when the output from a given command is
20793 Different kinds of input each have a different @dfn{input type}. Each
20794 input type has three annotations: a @code{pre-} annotation, which
20795 denotes the beginning of any prompt which is being output, a plain
20796 annotation, which denotes the end of the prompt, and then a @code{post-}
20797 annotation which denotes the end of any echo which may (or may not) be
20798 associated with the input. For example, the @code{prompt} input type
20799 features the following annotations:
20807 The input types are
20812 @findex post-prompt
20814 When @value{GDBN} is prompting for a command (the main @value{GDBN} prompt).
20816 @findex pre-commands
20818 @findex post-commands
20820 When @value{GDBN} prompts for a set of commands, like in the @code{commands}
20821 command. The annotations are repeated for each command which is input.
20823 @findex pre-overload-choice
20824 @findex overload-choice
20825 @findex post-overload-choice
20826 @item overload-choice
20827 When @value{GDBN} wants the user to select between various overloaded functions.
20833 When @value{GDBN} wants the user to confirm a potentially dangerous operation.
20835 @findex pre-prompt-for-continue
20836 @findex prompt-for-continue
20837 @findex post-prompt-for-continue
20838 @item prompt-for-continue
20839 When @value{GDBN} is asking the user to press return to continue. Note: Don't
20840 expect this to work well; instead use @code{set height 0} to disable
20841 prompting. This is because the counting of lines is buggy in the
20842 presence of annotations.
20847 @cindex annotations for errors, warnings and interrupts
20854 This annotation occurs right before @value{GDBN} responds to an interrupt.
20861 This annotation occurs right before @value{GDBN} responds to an error.
20863 Quit and error annotations indicate that any annotations which @value{GDBN} was
20864 in the middle of may end abruptly. For example, if a
20865 @code{value-history-begin} annotation is followed by a @code{error}, one
20866 cannot expect to receive the matching @code{value-history-end}. One
20867 cannot expect not to receive it either, however; an error annotation
20868 does not necessarily mean that @value{GDBN} is immediately returning all the way
20871 @findex error-begin
20872 A quit or error annotation may be preceded by
20878 Any output between that and the quit or error annotation is the error
20881 Warning messages are not yet annotated.
20882 @c If we want to change that, need to fix warning(), type_error(),
20883 @c range_error(), and possibly other places.
20886 @section Invalidation Notices
20888 @cindex annotations for invalidation messages
20889 The following annotations say that certain pieces of state may have
20893 @findex frames-invalid
20894 @item ^Z^Zframes-invalid
20896 The frames (for example, output from the @code{backtrace} command) may
20899 @findex breakpoints-invalid
20900 @item ^Z^Zbreakpoints-invalid
20902 The breakpoints may have changed. For example, the user just added or
20903 deleted a breakpoint.
20906 @node Annotations for Running
20907 @section Running the Program
20908 @cindex annotations for running programs
20912 When the program starts executing due to a @value{GDBN} command such as
20913 @code{step} or @code{continue},
20919 is output. When the program stops,
20925 is output. Before the @code{stopped} annotation, a variety of
20926 annotations describe how the program stopped.
20930 @item ^Z^Zexited @var{exit-status}
20931 The program exited, and @var{exit-status} is the exit status (zero for
20932 successful exit, otherwise nonzero).
20935 @findex signal-name
20936 @findex signal-name-end
20937 @findex signal-string
20938 @findex signal-string-end
20939 @item ^Z^Zsignalled
20940 The program exited with a signal. After the @code{^Z^Zsignalled}, the
20941 annotation continues:
20947 ^Z^Zsignal-name-end
20951 ^Z^Zsignal-string-end
20956 where @var{name} is the name of the signal, such as @code{SIGILL} or
20957 @code{SIGSEGV}, and @var{string} is the explanation of the signal, such
20958 as @code{Illegal Instruction} or @code{Segmentation fault}.
20959 @var{intro-text}, @var{middle-text}, and @var{end-text} are for the
20960 user's benefit and have no particular format.
20964 The syntax of this annotation is just like @code{signalled}, but @value{GDBN} is
20965 just saying that the program received the signal, not that it was
20966 terminated with it.
20969 @item ^Z^Zbreakpoint @var{number}
20970 The program hit breakpoint number @var{number}.
20973 @item ^Z^Zwatchpoint @var{number}
20974 The program hit watchpoint number @var{number}.
20977 @node Source Annotations
20978 @section Displaying Source
20979 @cindex annotations for source display
20982 The following annotation is used instead of displaying source code:
20985 ^Z^Zsource @var{filename}:@var{line}:@var{character}:@var{middle}:@var{addr}
20988 where @var{filename} is an absolute file name indicating which source
20989 file, @var{line} is the line number within that file (where 1 is the
20990 first line in the file), @var{character} is the character position
20991 within the file (where 0 is the first character in the file) (for most
20992 debug formats this will necessarily point to the beginning of a line),
20993 @var{middle} is @samp{middle} if @var{addr} is in the middle of the
20994 line, or @samp{beg} if @var{addr} is at the beginning of the line, and
20995 @var{addr} is the address in the target program associated with the
20996 source which is being displayed. @var{addr} is in the form @samp{0x}
20997 followed by one or more lowercase hex digits (note that this does not
20998 depend on the language).
21001 @chapter Reporting Bugs in @value{GDBN}
21002 @cindex bugs in @value{GDBN}
21003 @cindex reporting bugs in @value{GDBN}
21005 Your bug reports play an essential role in making @value{GDBN} reliable.
21007 Reporting a bug may help you by bringing a solution to your problem, or it
21008 may not. But in any case the principal function of a bug report is to help
21009 the entire community by making the next version of @value{GDBN} work better. Bug
21010 reports are your contribution to the maintenance of @value{GDBN}.
21012 In order for a bug report to serve its purpose, you must include the
21013 information that enables us to fix the bug.
21016 * Bug Criteria:: Have you found a bug?
21017 * Bug Reporting:: How to report bugs
21021 @section Have you found a bug?
21022 @cindex bug criteria
21024 If you are not sure whether you have found a bug, here are some guidelines:
21027 @cindex fatal signal
21028 @cindex debugger crash
21029 @cindex crash of debugger
21031 If the debugger gets a fatal signal, for any input whatever, that is a
21032 @value{GDBN} bug. Reliable debuggers never crash.
21034 @cindex error on valid input
21036 If @value{GDBN} produces an error message for valid input, that is a
21037 bug. (Note that if you're cross debugging, the problem may also be
21038 somewhere in the connection to the target.)
21040 @cindex invalid input
21042 If @value{GDBN} does not produce an error message for invalid input,
21043 that is a bug. However, you should note that your idea of
21044 ``invalid input'' might be our idea of ``an extension'' or ``support
21045 for traditional practice''.
21048 If you are an experienced user of debugging tools, your suggestions
21049 for improvement of @value{GDBN} are welcome in any case.
21052 @node Bug Reporting
21053 @section How to report bugs
21054 @cindex bug reports
21055 @cindex @value{GDBN} bugs, reporting
21057 A number of companies and individuals offer support for @sc{gnu} products.
21058 If you obtained @value{GDBN} from a support organization, we recommend you
21059 contact that organization first.
21061 You can find contact information for many support companies and
21062 individuals in the file @file{etc/SERVICE} in the @sc{gnu} Emacs
21064 @c should add a web page ref...
21066 In any event, we also recommend that you submit bug reports for
21067 @value{GDBN}. The prefered method is to submit them directly using
21068 @uref{http://www.gnu.org/software/gdb/bugs/, @value{GDBN}'s Bugs web
21069 page}. Alternatively, the @email{bug-gdb@@gnu.org, e-mail gateway} can
21072 @strong{Do not send bug reports to @samp{info-gdb}, or to
21073 @samp{help-gdb}, or to any newsgroups.} Most users of @value{GDBN} do
21074 not want to receive bug reports. Those that do have arranged to receive
21077 The mailing list @samp{bug-gdb} has a newsgroup @samp{gnu.gdb.bug} which
21078 serves as a repeater. The mailing list and the newsgroup carry exactly
21079 the same messages. Often people think of posting bug reports to the
21080 newsgroup instead of mailing them. This appears to work, but it has one
21081 problem which can be crucial: a newsgroup posting often lacks a mail
21082 path back to the sender. Thus, if we need to ask for more information,
21083 we may be unable to reach you. For this reason, it is better to send
21084 bug reports to the mailing list.
21086 The fundamental principle of reporting bugs usefully is this:
21087 @strong{report all the facts}. If you are not sure whether to state a
21088 fact or leave it out, state it!
21090 Often people omit facts because they think they know what causes the
21091 problem and assume that some details do not matter. Thus, you might
21092 assume that the name of the variable you use in an example does not matter.
21093 Well, probably it does not, but one cannot be sure. Perhaps the bug is a
21094 stray memory reference which happens to fetch from the location where that
21095 name is stored in memory; perhaps, if the name were different, the contents
21096 of that location would fool the debugger into doing the right thing despite
21097 the bug. Play it safe and give a specific, complete example. That is the
21098 easiest thing for you to do, and the most helpful.
21100 Keep in mind that the purpose of a bug report is to enable us to fix the
21101 bug. It may be that the bug has been reported previously, but neither
21102 you nor we can know that unless your bug report is complete and
21105 Sometimes people give a few sketchy facts and ask, ``Does this ring a
21106 bell?'' Those bug reports are useless, and we urge everyone to
21107 @emph{refuse to respond to them} except to chide the sender to report
21110 To enable us to fix the bug, you should include all these things:
21114 The version of @value{GDBN}. @value{GDBN} announces it if you start
21115 with no arguments; you can also print it at any time using @code{show
21118 Without this, we will not know whether there is any point in looking for
21119 the bug in the current version of @value{GDBN}.
21122 The type of machine you are using, and the operating system name and
21126 What compiler (and its version) was used to compile @value{GDBN}---e.g.
21127 ``@value{GCC}--2.8.1''.
21130 What compiler (and its version) was used to compile the program you are
21131 debugging---e.g. ``@value{GCC}--2.8.1'', or ``HP92453-01 A.10.32.03 HP
21132 C Compiler''. For GCC, you can say @code{gcc --version} to get this
21133 information; for other compilers, see the documentation for those
21137 The command arguments you gave the compiler to compile your example and
21138 observe the bug. For example, did you use @samp{-O}? To guarantee
21139 you will not omit something important, list them all. A copy of the
21140 Makefile (or the output from make) is sufficient.
21142 If we were to try to guess the arguments, we would probably guess wrong
21143 and then we might not encounter the bug.
21146 A complete input script, and all necessary source files, that will
21150 A description of what behavior you observe that you believe is
21151 incorrect. For example, ``It gets a fatal signal.''
21153 Of course, if the bug is that @value{GDBN} gets a fatal signal, then we
21154 will certainly notice it. But if the bug is incorrect output, we might
21155 not notice unless it is glaringly wrong. You might as well not give us
21156 a chance to make a mistake.
21158 Even if the problem you experience is a fatal signal, you should still
21159 say so explicitly. Suppose something strange is going on, such as, your
21160 copy of @value{GDBN} is out of synch, or you have encountered a bug in
21161 the C library on your system. (This has happened!) Your copy might
21162 crash and ours would not. If you told us to expect a crash, then when
21163 ours fails to crash, we would know that the bug was not happening for
21164 us. If you had not told us to expect a crash, then we would not be able
21165 to draw any conclusion from our observations.
21168 @cindex recording a session script
21169 To collect all this information, you can use a session recording program
21170 such as @command{script}, which is available on many Unix systems.
21171 Just run your @value{GDBN} session inside @command{script} and then
21172 include the @file{typescript} file with your bug report.
21174 Another way to record a @value{GDBN} session is to run @value{GDBN}
21175 inside Emacs and then save the entire buffer to a file.
21178 If you wish to suggest changes to the @value{GDBN} source, send us context
21179 diffs. If you even discuss something in the @value{GDBN} source, refer to
21180 it by context, not by line number.
21182 The line numbers in our development sources will not match those in your
21183 sources. Your line numbers would convey no useful information to us.
21187 Here are some things that are not necessary:
21191 A description of the envelope of the bug.
21193 Often people who encounter a bug spend a lot of time investigating
21194 which changes to the input file will make the bug go away and which
21195 changes will not affect it.
21197 This is often time consuming and not very useful, because the way we
21198 will find the bug is by running a single example under the debugger
21199 with breakpoints, not by pure deduction from a series of examples.
21200 We recommend that you save your time for something else.
21202 Of course, if you can find a simpler example to report @emph{instead}
21203 of the original one, that is a convenience for us. Errors in the
21204 output will be easier to spot, running under the debugger will take
21205 less time, and so on.
21207 However, simplification is not vital; if you do not want to do this,
21208 report the bug anyway and send us the entire test case you used.
21211 A patch for the bug.
21213 A patch for the bug does help us if it is a good one. But do not omit
21214 the necessary information, such as the test case, on the assumption that
21215 a patch is all we need. We might see problems with your patch and decide
21216 to fix the problem another way, or we might not understand it at all.
21218 Sometimes with a program as complicated as @value{GDBN} it is very hard to
21219 construct an example that will make the program follow a certain path
21220 through the code. If you do not send us the example, we will not be able
21221 to construct one, so we will not be able to verify that the bug is fixed.
21223 And if we cannot understand what bug you are trying to fix, or why your
21224 patch should be an improvement, we will not install it. A test case will
21225 help us to understand.
21228 A guess about what the bug is or what it depends on.
21230 Such guesses are usually wrong. Even we cannot guess right about such
21231 things without first using the debugger to find the facts.
21234 @c The readline documentation is distributed with the readline code
21235 @c and consists of the two following files:
21237 @c inc-hist.texinfo
21238 @c Use -I with makeinfo to point to the appropriate directory,
21239 @c environment var TEXINPUTS with TeX.
21240 @include rluser.texinfo
21241 @include inc-hist.texinfo
21244 @node Formatting Documentation
21245 @appendix Formatting Documentation
21247 @cindex @value{GDBN} reference card
21248 @cindex reference card
21249 The @value{GDBN} 4 release includes an already-formatted reference card, ready
21250 for printing with PostScript or Ghostscript, in the @file{gdb}
21251 subdirectory of the main source directory@footnote{In
21252 @file{gdb-@value{GDBVN}/gdb/refcard.ps} of the version @value{GDBVN}
21253 release.}. If you can use PostScript or Ghostscript with your printer,
21254 you can print the reference card immediately with @file{refcard.ps}.
21256 The release also includes the source for the reference card. You
21257 can format it, using @TeX{}, by typing:
21263 The @value{GDBN} reference card is designed to print in @dfn{landscape}
21264 mode on US ``letter'' size paper;
21265 that is, on a sheet 11 inches wide by 8.5 inches
21266 high. You will need to specify this form of printing as an option to
21267 your @sc{dvi} output program.
21269 @cindex documentation
21271 All the documentation for @value{GDBN} comes as part of the machine-readable
21272 distribution. The documentation is written in Texinfo format, which is
21273 a documentation system that uses a single source file to produce both
21274 on-line information and a printed manual. You can use one of the Info
21275 formatting commands to create the on-line version of the documentation
21276 and @TeX{} (or @code{texi2roff}) to typeset the printed version.
21278 @value{GDBN} includes an already formatted copy of the on-line Info
21279 version of this manual in the @file{gdb} subdirectory. The main Info
21280 file is @file{gdb-@value{GDBVN}/gdb/gdb.info}, and it refers to
21281 subordinate files matching @samp{gdb.info*} in the same directory. If
21282 necessary, you can print out these files, or read them with any editor;
21283 but they are easier to read using the @code{info} subsystem in @sc{gnu}
21284 Emacs or the standalone @code{info} program, available as part of the
21285 @sc{gnu} Texinfo distribution.
21287 If you want to format these Info files yourself, you need one of the
21288 Info formatting programs, such as @code{texinfo-format-buffer} or
21291 If you have @code{makeinfo} installed, and are in the top level
21292 @value{GDBN} source directory (@file{gdb-@value{GDBVN}}, in the case of
21293 version @value{GDBVN}), you can make the Info file by typing:
21300 If you want to typeset and print copies of this manual, you need @TeX{},
21301 a program to print its @sc{dvi} output files, and @file{texinfo.tex}, the
21302 Texinfo definitions file.
21304 @TeX{} is a typesetting program; it does not print files directly, but
21305 produces output files called @sc{dvi} files. To print a typeset
21306 document, you need a program to print @sc{dvi} files. If your system
21307 has @TeX{} installed, chances are it has such a program. The precise
21308 command to use depends on your system; @kbd{lpr -d} is common; another
21309 (for PostScript devices) is @kbd{dvips}. The @sc{dvi} print command may
21310 require a file name without any extension or a @samp{.dvi} extension.
21312 @TeX{} also requires a macro definitions file called
21313 @file{texinfo.tex}. This file tells @TeX{} how to typeset a document
21314 written in Texinfo format. On its own, @TeX{} cannot either read or
21315 typeset a Texinfo file. @file{texinfo.tex} is distributed with GDB
21316 and is located in the @file{gdb-@var{version-number}/texinfo}
21319 If you have @TeX{} and a @sc{dvi} printer program installed, you can
21320 typeset and print this manual. First switch to the the @file{gdb}
21321 subdirectory of the main source directory (for example, to
21322 @file{gdb-@value{GDBVN}/gdb}) and type:
21328 Then give @file{gdb.dvi} to your @sc{dvi} printing program.
21330 @node Installing GDB
21331 @appendix Installing @value{GDBN}
21332 @cindex configuring @value{GDBN}
21333 @cindex installation
21334 @cindex configuring @value{GDBN}, and source tree subdirectories
21336 @value{GDBN} comes with a @code{configure} script that automates the process
21337 of preparing @value{GDBN} for installation; you can then use @code{make} to
21338 build the @code{gdb} program.
21340 @c irrelevant in info file; it's as current as the code it lives with.
21341 @footnote{If you have a more recent version of @value{GDBN} than @value{GDBVN},
21342 look at the @file{README} file in the sources; we may have improved the
21343 installation procedures since publishing this manual.}
21346 The @value{GDBN} distribution includes all the source code you need for
21347 @value{GDBN} in a single directory, whose name is usually composed by
21348 appending the version number to @samp{gdb}.
21350 For example, the @value{GDBN} version @value{GDBVN} distribution is in the
21351 @file{gdb-@value{GDBVN}} directory. That directory contains:
21354 @item gdb-@value{GDBVN}/configure @r{(and supporting files)}
21355 script for configuring @value{GDBN} and all its supporting libraries
21357 @item gdb-@value{GDBVN}/gdb
21358 the source specific to @value{GDBN} itself
21360 @item gdb-@value{GDBVN}/bfd
21361 source for the Binary File Descriptor library
21363 @item gdb-@value{GDBVN}/include
21364 @sc{gnu} include files
21366 @item gdb-@value{GDBVN}/libiberty
21367 source for the @samp{-liberty} free software library
21369 @item gdb-@value{GDBVN}/opcodes
21370 source for the library of opcode tables and disassemblers
21372 @item gdb-@value{GDBVN}/readline
21373 source for the @sc{gnu} command-line interface
21375 @item gdb-@value{GDBVN}/glob
21376 source for the @sc{gnu} filename pattern-matching subroutine
21378 @item gdb-@value{GDBVN}/mmalloc
21379 source for the @sc{gnu} memory-mapped malloc package
21382 The simplest way to configure and build @value{GDBN} is to run @code{configure}
21383 from the @file{gdb-@var{version-number}} source directory, which in
21384 this example is the @file{gdb-@value{GDBVN}} directory.
21386 First switch to the @file{gdb-@var{version-number}} source directory
21387 if you are not already in it; then run @code{configure}. Pass the
21388 identifier for the platform on which @value{GDBN} will run as an
21394 cd gdb-@value{GDBVN}
21395 ./configure @var{host}
21400 where @var{host} is an identifier such as @samp{sun4} or
21401 @samp{decstation}, that identifies the platform where @value{GDBN} will run.
21402 (You can often leave off @var{host}; @code{configure} tries to guess the
21403 correct value by examining your system.)
21405 Running @samp{configure @var{host}} and then running @code{make} builds the
21406 @file{bfd}, @file{readline}, @file{mmalloc}, and @file{libiberty}
21407 libraries, then @code{gdb} itself. The configured source files, and the
21408 binaries, are left in the corresponding source directories.
21411 @code{configure} is a Bourne-shell (@code{/bin/sh}) script; if your
21412 system does not recognize this automatically when you run a different
21413 shell, you may need to run @code{sh} on it explicitly:
21416 sh configure @var{host}
21419 If you run @code{configure} from a directory that contains source
21420 directories for multiple libraries or programs, such as the
21421 @file{gdb-@value{GDBVN}} source directory for version @value{GDBVN}, @code{configure}
21422 creates configuration files for every directory level underneath (unless
21423 you tell it not to, with the @samp{--norecursion} option).
21425 You should run the @code{configure} script from the top directory in the
21426 source tree, the @file{gdb-@var{version-number}} directory. If you run
21427 @code{configure} from one of the subdirectories, you will configure only
21428 that subdirectory. That is usually not what you want. In particular,
21429 if you run the first @code{configure} from the @file{gdb} subdirectory
21430 of the @file{gdb-@var{version-number}} directory, you will omit the
21431 configuration of @file{bfd}, @file{readline}, and other sibling
21432 directories of the @file{gdb} subdirectory. This leads to build errors
21433 about missing include files such as @file{bfd/bfd.h}.
21435 You can install @code{@value{GDBP}} anywhere; it has no hardwired paths.
21436 However, you should make sure that the shell on your path (named by
21437 the @samp{SHELL} environment variable) is publicly readable. Remember
21438 that @value{GDBN} uses the shell to start your program---some systems refuse to
21439 let @value{GDBN} debug child processes whose programs are not readable.
21442 * Separate Objdir:: Compiling @value{GDBN} in another directory
21443 * Config Names:: Specifying names for hosts and targets
21444 * Configure Options:: Summary of options for configure
21447 @node Separate Objdir
21448 @section Compiling @value{GDBN} in another directory
21450 If you want to run @value{GDBN} versions for several host or target machines,
21451 you need a different @code{gdb} compiled for each combination of
21452 host and target. @code{configure} is designed to make this easy by
21453 allowing you to generate each configuration in a separate subdirectory,
21454 rather than in the source directory. If your @code{make} program
21455 handles the @samp{VPATH} feature (@sc{gnu} @code{make} does), running
21456 @code{make} in each of these directories builds the @code{gdb}
21457 program specified there.
21459 To build @code{gdb} in a separate directory, run @code{configure}
21460 with the @samp{--srcdir} option to specify where to find the source.
21461 (You also need to specify a path to find @code{configure}
21462 itself from your working directory. If the path to @code{configure}
21463 would be the same as the argument to @samp{--srcdir}, you can leave out
21464 the @samp{--srcdir} option; it is assumed.)
21466 For example, with version @value{GDBVN}, you can build @value{GDBN} in a
21467 separate directory for a Sun 4 like this:
21471 cd gdb-@value{GDBVN}
21474 ../gdb-@value{GDBVN}/configure sun4
21479 When @code{configure} builds a configuration using a remote source
21480 directory, it creates a tree for the binaries with the same structure
21481 (and using the same names) as the tree under the source directory. In
21482 the example, you'd find the Sun 4 library @file{libiberty.a} in the
21483 directory @file{gdb-sun4/libiberty}, and @value{GDBN} itself in
21484 @file{gdb-sun4/gdb}.
21486 Make sure that your path to the @file{configure} script has just one
21487 instance of @file{gdb} in it. If your path to @file{configure} looks
21488 like @file{../gdb-@value{GDBVN}/gdb/configure}, you are configuring only
21489 one subdirectory of @value{GDBN}, not the whole package. This leads to
21490 build errors about missing include files such as @file{bfd/bfd.h}.
21492 One popular reason to build several @value{GDBN} configurations in separate
21493 directories is to configure @value{GDBN} for cross-compiling (where
21494 @value{GDBN} runs on one machine---the @dfn{host}---while debugging
21495 programs that run on another machine---the @dfn{target}).
21496 You specify a cross-debugging target by
21497 giving the @samp{--target=@var{target}} option to @code{configure}.
21499 When you run @code{make} to build a program or library, you must run
21500 it in a configured directory---whatever directory you were in when you
21501 called @code{configure} (or one of its subdirectories).
21503 The @code{Makefile} that @code{configure} generates in each source
21504 directory also runs recursively. If you type @code{make} in a source
21505 directory such as @file{gdb-@value{GDBVN}} (or in a separate configured
21506 directory configured with @samp{--srcdir=@var{dirname}/gdb-@value{GDBVN}}), you
21507 will build all the required libraries, and then build GDB.
21509 When you have multiple hosts or targets configured in separate
21510 directories, you can run @code{make} on them in parallel (for example,
21511 if they are NFS-mounted on each of the hosts); they will not interfere
21515 @section Specifying names for hosts and targets
21517 The specifications used for hosts and targets in the @code{configure}
21518 script are based on a three-part naming scheme, but some short predefined
21519 aliases are also supported. The full naming scheme encodes three pieces
21520 of information in the following pattern:
21523 @var{architecture}-@var{vendor}-@var{os}
21526 For example, you can use the alias @code{sun4} as a @var{host} argument,
21527 or as the value for @var{target} in a @code{--target=@var{target}}
21528 option. The equivalent full name is @samp{sparc-sun-sunos4}.
21530 The @code{configure} script accompanying @value{GDBN} does not provide
21531 any query facility to list all supported host and target names or
21532 aliases. @code{configure} calls the Bourne shell script
21533 @code{config.sub} to map abbreviations to full names; you can read the
21534 script, if you wish, or you can use it to test your guesses on
21535 abbreviations---for example:
21538 % sh config.sub i386-linux
21540 % sh config.sub alpha-linux
21541 alpha-unknown-linux-gnu
21542 % sh config.sub hp9k700
21544 % sh config.sub sun4
21545 sparc-sun-sunos4.1.1
21546 % sh config.sub sun3
21547 m68k-sun-sunos4.1.1
21548 % sh config.sub i986v
21549 Invalid configuration `i986v': machine `i986v' not recognized
21553 @code{config.sub} is also distributed in the @value{GDBN} source
21554 directory (@file{gdb-@value{GDBVN}}, for version @value{GDBVN}).
21556 @node Configure Options
21557 @section @code{configure} options
21559 Here is a summary of the @code{configure} options and arguments that
21560 are most often useful for building @value{GDBN}. @code{configure} also has
21561 several other options not listed here. @inforef{What Configure
21562 Does,,configure.info}, for a full explanation of @code{configure}.
21565 configure @r{[}--help@r{]}
21566 @r{[}--prefix=@var{dir}@r{]}
21567 @r{[}--exec-prefix=@var{dir}@r{]}
21568 @r{[}--srcdir=@var{dirname}@r{]}
21569 @r{[}--norecursion@r{]} @r{[}--rm@r{]}
21570 @r{[}--target=@var{target}@r{]}
21575 You may introduce options with a single @samp{-} rather than
21576 @samp{--} if you prefer; but you may abbreviate option names if you use
21581 Display a quick summary of how to invoke @code{configure}.
21583 @item --prefix=@var{dir}
21584 Configure the source to install programs and files under directory
21587 @item --exec-prefix=@var{dir}
21588 Configure the source to install programs under directory
21591 @c avoid splitting the warning from the explanation:
21593 @item --srcdir=@var{dirname}
21594 @strong{Warning: using this option requires @sc{gnu} @code{make}, or another
21595 @code{make} that implements the @code{VPATH} feature.}@*
21596 Use this option to make configurations in directories separate from the
21597 @value{GDBN} source directories. Among other things, you can use this to
21598 build (or maintain) several configurations simultaneously, in separate
21599 directories. @code{configure} writes configuration specific files in
21600 the current directory, but arranges for them to use the source in the
21601 directory @var{dirname}. @code{configure} creates directories under
21602 the working directory in parallel to the source directories below
21605 @item --norecursion
21606 Configure only the directory level where @code{configure} is executed; do not
21607 propagate configuration to subdirectories.
21609 @item --target=@var{target}
21610 Configure @value{GDBN} for cross-debugging programs running on the specified
21611 @var{target}. Without this option, @value{GDBN} is configured to debug
21612 programs that run on the same machine (@var{host}) as @value{GDBN} itself.
21614 There is no convenient way to generate a list of all available targets.
21616 @item @var{host} @dots{}
21617 Configure @value{GDBN} to run on the specified @var{host}.
21619 There is no convenient way to generate a list of all available hosts.
21622 There are many other options available as well, but they are generally
21623 needed for special purposes only.
21625 @node Maintenance Commands
21626 @appendix Maintenance Commands
21627 @cindex maintenance commands
21628 @cindex internal commands
21630 In addition to commands intended for @value{GDBN} users, @value{GDBN}
21631 includes a number of commands intended for @value{GDBN} developers,
21632 that are not documented elsewhere in this manual. These commands are
21633 provided here for reference. (For commands that turn on debugging
21634 messages, see @ref{Debugging Output}.)
21637 @kindex maint agent
21638 @item maint agent @var{expression}
21639 Translate the given @var{expression} into remote agent bytecodes.
21640 This command is useful for debugging the Agent Expression mechanism
21641 (@pxref{Agent Expressions}).
21643 @kindex maint info breakpoints
21644 @item @anchor{maint info breakpoints}maint info breakpoints
21645 Using the same format as @samp{info breakpoints}, display both the
21646 breakpoints you've set explicitly, and those @value{GDBN} is using for
21647 internal purposes. Internal breakpoints are shown with negative
21648 breakpoint numbers. The type column identifies what kind of breakpoint
21653 Normal, explicitly set breakpoint.
21656 Normal, explicitly set watchpoint.
21659 Internal breakpoint, used to handle correctly stepping through
21660 @code{longjmp} calls.
21662 @item longjmp resume
21663 Internal breakpoint at the target of a @code{longjmp}.
21666 Temporary internal breakpoint used by the @value{GDBN} @code{until} command.
21669 Temporary internal breakpoint used by the @value{GDBN} @code{finish} command.
21672 Shared library events.
21676 @kindex maint check-symtabs
21677 @item maint check-symtabs
21678 Check the consistency of psymtabs and symtabs.
21680 @kindex maint cplus first_component
21681 @item maint cplus first_component @var{name}
21682 Print the first C@t{++} class/namespace component of @var{name}.
21684 @kindex maint cplus namespace
21685 @item maint cplus namespace
21686 Print the list of possible C@t{++} namespaces.
21688 @kindex maint demangle
21689 @item maint demangle @var{name}
21690 Demangle a C@t{++} or Objective-C manled @var{name}.
21692 @kindex maint deprecate
21693 @kindex maint undeprecate
21694 @cindex deprecated commands
21695 @item maint deprecate @var{command} @r{[}@var{replacement}@r{]}
21696 @itemx maint undeprecate @var{command}
21697 Deprecate or undeprecate the named @var{command}. Deprecated commands
21698 cause @value{GDBN} to issue a warning when you use them. The optional
21699 argument @var{replacement} says which newer command should be used in
21700 favor of the deprecated one; if it is given, @value{GDBN} will mention
21701 the replacement as part of the warning.
21703 @kindex maint dump-me
21704 @item maint dump-me
21705 @cindex @code{SIGQUIT} signal, dump core of @value{GDBN}
21706 Cause a fatal signal in the debugger and force it to dump its core.
21707 This is supported only on systems which support aborting a program
21708 with the @code{SIGQUIT} signal.
21710 @kindex maint internal-error
21711 @kindex maint internal-warning
21712 @item maint internal-error @r{[}@var{message-text}@r{]}
21713 @itemx maint internal-warning @r{[}@var{message-text}@r{]}
21714 Cause @value{GDBN} to call the internal function @code{internal_error}
21715 or @code{internal_warning} and hence behave as though an internal error
21716 or internal warning has been detected. In addition to reporting the
21717 internal problem, these functions give the user the opportunity to
21718 either quit @value{GDBN} or create a core file of the current
21719 @value{GDBN} session.
21721 These commands take an optional parameter @var{message-text} that is
21722 used as the text of the error or warning message.
21724 Here's an example of using @code{indernal-error}:
21727 (@value{GDBP}) @kbd{maint internal-error testing, 1, 2}
21728 @dots{}/maint.c:121: internal-error: testing, 1, 2
21729 A problem internal to GDB has been detected. Further
21730 debugging may prove unreliable.
21731 Quit this debugging session? (y or n) @kbd{n}
21732 Create a core file? (y or n) @kbd{n}
21736 @kindex maint packet
21737 @item maint packet @var{text}
21738 If @value{GDBN} is talking to an inferior via the serial protocol,
21739 then this command sends the string @var{text} to the inferior, and
21740 displays the response packet. @value{GDBN} supplies the initial
21741 @samp{$} character, the terminating @samp{#} character, and the
21744 @kindex maint print architecture
21745 @item maint print architecture @r{[}@var{file}@r{]}
21746 Print the entire architecture configuration. The optional argument
21747 @var{file} names the file where the output goes.
21749 @kindex maint print dummy-frames
21750 @item maint print dummy-frames
21751 Prints the contents of @value{GDBN}'s internal dummy-frame stack.
21754 (@value{GDBP}) @kbd{b add}
21756 (@value{GDBP}) @kbd{print add(2,3)}
21757 Breakpoint 2, add (a=2, b=3) at @dots{}
21759 The program being debugged stopped while in a function called from GDB.
21761 (@value{GDBP}) @kbd{maint print dummy-frames}
21762 0x1a57c80: pc=0x01014068 fp=0x0200bddc sp=0x0200bdd6
21763 top=0x0200bdd4 id=@{stack=0x200bddc,code=0x101405c@}
21764 call_lo=0x01014000 call_hi=0x01014001
21768 Takes an optional file parameter.
21770 @kindex maint print registers
21771 @kindex maint print raw-registers
21772 @kindex maint print cooked-registers
21773 @kindex maint print register-groups
21774 @item maint print registers @r{[}@var{file}@r{]}
21775 @itemx maint print raw-registers @r{[}@var{file}@r{]}
21776 @itemx maint print cooked-registers @r{[}@var{file}@r{]}
21777 @itemx maint print register-groups @r{[}@var{file}@r{]}
21778 Print @value{GDBN}'s internal register data structures.
21780 The command @code{maint print raw-registers} includes the contents of
21781 the raw register cache; the command @code{maint print cooked-registers}
21782 includes the (cooked) value of all registers; and the command
21783 @code{maint print register-groups} includes the groups that each
21784 register is a member of. @xref{Registers,, Registers, gdbint,
21785 @value{GDBN} Internals}.
21787 These commands take an optional parameter, a file name to which to
21788 write the information.
21790 @kindex maint print reggroups
21791 @item maint print reggroups @r{[}@var{file}@r{]}
21792 Print @value{GDBN}'s internal register group data structures. The
21793 optional argument @var{file} tells to what file to write the
21796 The register groups info looks like this:
21799 (@value{GDBP}) @kbd{maint print reggroups}
21812 This command forces @value{GDBN} to flush its internal register cache.
21814 @kindex maint print objfiles
21815 @cindex info for known object files
21816 @item maint print objfiles
21817 Print a dump of all known object files. For each object file, this
21818 command prints its name, address in memory, and all of its psymtabs
21821 @kindex maint print statistics
21822 @cindex bcache statistics
21823 @item maint print statistics
21824 This command prints, for each object file in the program, various data
21825 about that object file followed by the byte cache (@dfn{bcache})
21826 statistics for the object file. The objfile data includes the number
21827 of minimal, partical, full, and stabs symbols, the number of types
21828 defined by the objfile, the number of as yet unexpanded psym tables,
21829 the number of line tables and string tables, and the amount of memory
21830 used by the various tables. The bcache statistics include the counts,
21831 sizes, and counts of duplicates of all and unique objects, max,
21832 average, and median entry size, total memory used and its overhead and
21833 savings, and various measures of the hash table size and chain
21836 @kindex maint print type
21837 @cindex type chain of a data type
21838 @item maint print type @var{expr}
21839 Print the type chain for a type specified by @var{expr}. The argument
21840 can be either a type name or a symbol. If it is a symbol, the type of
21841 that symbol is described. The type chain produced by this command is
21842 a recursive definition of the data type as stored in @value{GDBN}'s
21843 data structures, including its flags and contained types.
21845 @kindex maint set dwarf2 max-cache-age
21846 @kindex maint show dwarf2 max-cache-age
21847 @item maint set dwarf2 max-cache-age
21848 @itemx maint show dwarf2 max-cache-age
21849 Control the DWARF 2 compilation unit cache.
21851 @cindex DWARF 2 compilation units cache
21852 In object files with inter-compilation-unit references, such as those
21853 produced by the GCC option @samp{-feliminate-dwarf2-dups}, the DWARF 2
21854 reader needs to frequently refer to previously read compilation units.
21855 This setting controls how long a compilation unit will remain in the
21856 cache if it is not referenced. A higher limit means that cached
21857 compilation units will be stored in memory longer, and more total
21858 memory will be used. Setting it to zero disables caching, which will
21859 slow down @value{GDBN} startup, but reduce memory consumption.
21861 @kindex maint set profile
21862 @kindex maint show profile
21863 @cindex profiling GDB
21864 @item maint set profile
21865 @itemx maint show profile
21866 Control profiling of @value{GDBN}.
21868 Profiling will be disabled until you use the @samp{maint set profile}
21869 command to enable it. When you enable profiling, the system will begin
21870 collecting timing and execution count data; when you disable profiling or
21871 exit @value{GDBN}, the results will be written to a log file. Remember that
21872 if you use profiling, @value{GDBN} will overwrite the profiling log file
21873 (often called @file{gmon.out}). If you have a record of important profiling
21874 data in a @file{gmon.out} file, be sure to move it to a safe location.
21876 Configuring with @samp{--enable-profiling} arranges for @value{GDBN} to be
21877 compiled with the @samp{-pg} compiler option.
21879 @kindex maint show-debug-regs
21880 @cindex x86 hardware debug registers
21881 @item maint show-debug-regs
21882 Control whether to show variables that mirror the x86 hardware debug
21883 registers. Use @code{ON} to enable, @code{OFF} to disable. If
21884 enabled, the debug registers values are shown when GDB inserts or
21885 removes a hardware breakpoint or watchpoint, and when the inferior
21886 triggers a hardware-assisted breakpoint or watchpoint.
21888 @kindex maint space
21889 @cindex memory used by commands
21891 Control whether to display memory usage for each command. If set to a
21892 nonzero value, @value{GDBN} will display how much memory each command
21893 took, following the command's own output. This can also be requested
21894 by invoking @value{GDBN} with the @option{--statistics} command-line
21895 switch (@pxref{Mode Options}).
21898 @cindex time of command execution
21900 Control whether to display the execution time for each command. If
21901 set to a nonzero value, @value{GDBN} will display how much time it
21902 took to execute each command, following the command's own output.
21903 This can also be requested by invoking @value{GDBN} with the
21904 @option{--statistics} command-line switch (@pxref{Mode Options}).
21906 @kindex maint translate-address
21907 @item maint translate-address @r{[}@var{section}@r{]} @var{addr}
21908 Find the symbol stored at the location specified by the address
21909 @var{addr} and an optional section name @var{section}. If found,
21910 @value{GDBN} prints the name of the closest symbol and an offset from
21911 the symbol's location to the specified address. This is similar to
21912 the @code{info address} command (@pxref{Symbols}), except that this
21913 command also allows to find symbols in other sections.
21917 The following command is useful for non-interactive invocations of
21918 @value{GDBN}, such as in the test suite.
21921 @item set watchdog @var{nsec}
21922 @kindex set watchdog
21923 @cindex watchdog timer
21924 @cindex timeout for commands
21925 Set the maximum number of seconds @value{GDBN} will wait for the
21926 target operation to finish. If this time expires, @value{GDBN}
21927 reports and error and the command is aborted.
21929 @item show watchdog
21930 Show the current setting of the target wait timeout.
21933 @node Remote Protocol
21934 @appendix @value{GDBN} Remote Serial Protocol
21939 * Stop Reply Packets::
21940 * General Query Packets::
21941 * Register Packet Format::
21943 * File-I/O remote protocol extension::
21949 There may be occasions when you need to know something about the
21950 protocol---for example, if there is only one serial port to your target
21951 machine, you might want your program to do something special if it
21952 recognizes a packet meant for @value{GDBN}.
21954 In the examples below, @samp{->} and @samp{<-} are used to indicate
21955 transmitted and received data respectfully.
21957 @cindex protocol, @value{GDBN} remote serial
21958 @cindex serial protocol, @value{GDBN} remote
21959 @cindex remote serial protocol
21960 All @value{GDBN} commands and responses (other than acknowledgments) are
21961 sent as a @var{packet}. A @var{packet} is introduced with the character
21962 @samp{$}, the actual @var{packet-data}, and the terminating character
21963 @samp{#} followed by a two-digit @var{checksum}:
21966 @code{$}@var{packet-data}@code{#}@var{checksum}
21970 @cindex checksum, for @value{GDBN} remote
21972 The two-digit @var{checksum} is computed as the modulo 256 sum of all
21973 characters between the leading @samp{$} and the trailing @samp{#} (an
21974 eight bit unsigned checksum).
21976 Implementors should note that prior to @value{GDBN} 5.0 the protocol
21977 specification also included an optional two-digit @var{sequence-id}:
21980 @code{$}@var{sequence-id}@code{:}@var{packet-data}@code{#}@var{checksum}
21983 @cindex sequence-id, for @value{GDBN} remote
21985 That @var{sequence-id} was appended to the acknowledgment. @value{GDBN}
21986 has never output @var{sequence-id}s. Stubs that handle packets added
21987 since @value{GDBN} 5.0 must not accept @var{sequence-id}.
21989 @cindex acknowledgment, for @value{GDBN} remote
21990 When either the host or the target machine receives a packet, the first
21991 response expected is an acknowledgment: either @samp{+} (to indicate
21992 the package was received correctly) or @samp{-} (to request
21996 -> @code{$}@var{packet-data}@code{#}@var{checksum}
22001 The host (@value{GDBN}) sends @var{command}s, and the target (the
22002 debugging stub incorporated in your program) sends a @var{response}. In
22003 the case of step and continue @var{command}s, the response is only sent
22004 when the operation has completed (the target has again stopped).
22006 @var{packet-data} consists of a sequence of characters with the
22007 exception of @samp{#} and @samp{$} (see @samp{X} packet for additional
22010 Fields within the packet should be separated using @samp{,} @samp{;} or
22011 @cindex remote protocol, field separator
22012 @samp{:}. Except where otherwise noted all numbers are represented in
22013 @sc{hex} with leading zeros suppressed.
22015 Implementors should note that prior to @value{GDBN} 5.0, the character
22016 @samp{:} could not appear as the third character in a packet (as it
22017 would potentially conflict with the @var{sequence-id}).
22019 Response @var{data} can be run-length encoded to save space. A @samp{*}
22020 means that the next character is an @sc{ascii} encoding giving a repeat count
22021 which stands for that many repetitions of the character preceding the
22022 @samp{*}. The encoding is @code{n+29}, yielding a printable character
22023 where @code{n >=3} (which is where rle starts to win). The printable
22024 characters @samp{$}, @samp{#}, @samp{+} and @samp{-} or with a numeric
22025 value greater than 126 should not be used.
22032 means the same as "0000".
22034 The error response returned for some packets includes a two character
22035 error number. That number is not well defined.
22037 For any @var{command} not supported by the stub, an empty response
22038 (@samp{$#00}) should be returned. That way it is possible to extend the
22039 protocol. A newer @value{GDBN} can tell if a packet is supported based
22042 A stub is required to support the @samp{g}, @samp{G}, @samp{m}, @samp{M},
22043 @samp{c}, and @samp{s} @var{command}s. All other @var{command}s are
22049 The following table provides a complete list of all currently defined
22050 @var{command}s and their corresponding response @var{data}.
22051 @xref{File-I/O remote protocol extension}, for details about the File
22052 I/O extension of the remote protocol.
22056 @item @code{!} --- extended mode
22057 @cindex @code{!} packet
22059 Enable extended mode. In extended mode, the remote server is made
22060 persistent. The @samp{R} packet is used to restart the program being
22066 The remote target both supports and has enabled extended mode.
22069 @item @code{?} --- last signal
22070 @cindex @code{?} packet
22072 Indicate the reason the target halted. The reply is the same as for
22076 @xref{Stop Reply Packets}, for the reply specifications.
22078 @item @code{a} --- reserved
22080 Reserved for future use.
22082 @item @code{A}@var{arglen}@code{,}@var{argnum}@code{,}@var{arg}@code{,@dots{}} --- set program arguments @strong{(reserved)}
22083 @cindex @code{A} packet
22085 Initialized @samp{argv[]} array passed into program. @var{arglen}
22086 specifies the number of bytes in the hex encoded byte stream @var{arg}.
22087 See @code{gdbserver} for more details.
22095 @item @code{b}@var{baud} --- set baud @strong{(deprecated)}
22096 @cindex @code{b} packet
22098 Change the serial line speed to @var{baud}.
22100 JTC: @emph{When does the transport layer state change? When it's
22101 received, or after the ACK is transmitted. In either case, there are
22102 problems if the command or the acknowledgment packet is dropped.}
22104 Stan: @emph{If people really wanted to add something like this, and get
22105 it working for the first time, they ought to modify ser-unix.c to send
22106 some kind of out-of-band message to a specially-setup stub and have the
22107 switch happen "in between" packets, so that from remote protocol's point
22108 of view, nothing actually happened.}
22110 @item @code{B}@var{addr},@var{mode} --- set breakpoint @strong{(deprecated)}
22111 @cindex @code{B} packet
22113 Set (@var{mode} is @samp{S}) or clear (@var{mode} is @samp{C}) a
22114 breakpoint at @var{addr}.
22116 This packet has been replaced by the @samp{Z} and @samp{z} packets
22117 (@pxref{insert breakpoint or watchpoint packet}).
22119 @item @code{c}@var{addr} --- continue
22120 @cindex @code{c} packet
22122 @var{addr} is address to resume. If @var{addr} is omitted, resume at
22126 @xref{Stop Reply Packets}, for the reply specifications.
22128 @item @code{C}@var{sig}@code{;}@var{addr} --- continue with signal
22129 @cindex @code{C} packet
22131 Continue with signal @var{sig} (hex signal number). If
22132 @code{;}@var{addr} is omitted, resume at same address.
22135 @xref{Stop Reply Packets}, for the reply specifications.
22137 @item @code{d} --- toggle debug @strong{(deprecated)}
22138 @cindex @code{d} packet
22142 @item @code{D} --- detach
22143 @cindex @code{D} packet
22145 Detach @value{GDBN} from the remote system. Sent to the remote target
22146 before @value{GDBN} disconnects via the @code{detach} command.
22156 @item @code{e} --- reserved
22158 Reserved for future use.
22160 @item @code{E} --- reserved
22162 Reserved for future use.
22164 @item @code{f} --- reserved
22166 Reserved for future use.
22168 @item @code{F}@var{RC}@code{,}@var{EE}@code{,}@var{CF}@code{;}@var{XX} --- Reply to target's F packet.
22169 @cindex @code{F} packet
22171 This packet is send by @value{GDBN} as reply to a @code{F} request packet
22172 sent by the target. This is part of the File-I/O protocol extension.
22173 @xref{File-I/O remote protocol extension}, for the specification.
22175 @item @code{g} --- read registers
22176 @anchor{read registers packet}
22177 @cindex @code{g} packet
22179 Read general registers.
22183 @item @var{XX@dots{}}
22184 Each byte of register data is described by two hex digits. The bytes
22185 with the register are transmitted in target byte order. The size of
22186 each register and their position within the @samp{g} @var{packet} are
22187 determined by the @value{GDBN} internal macros
22188 @var{DEPRECATED_REGISTER_RAW_SIZE} and @var{REGISTER_NAME} macros. The
22189 specification of several standard @code{g} packets is specified below.
22194 @item @code{G}@var{XX@dots{}} --- write regs
22195 @cindex @code{G} packet
22197 @xref{read registers packet}, for a description of the @var{XX@dots{}}
22208 @item @code{h} --- reserved
22210 Reserved for future use.
22212 @item @code{H}@var{c}@var{t@dots{}} --- set thread
22213 @cindex @code{H} packet
22215 Set thread for subsequent operations (@samp{m}, @samp{M}, @samp{g},
22216 @samp{G}, et.al.). @var{c} depends on the operation to be performed: it
22217 should be @samp{c} for step and continue operations, @samp{g} for other
22218 operations. The thread designator @var{t@dots{}} may be -1, meaning all
22219 the threads, a thread number, or zero which means pick any thread.
22230 @c 'H': How restrictive (or permissive) is the thread model. If a
22231 @c thread is selected and stopped, are other threads allowed
22232 @c to continue to execute? As I mentioned above, I think the
22233 @c semantics of each command when a thread is selected must be
22234 @c described. For example:
22236 @c 'g': If the stub supports threads and a specific thread is
22237 @c selected, returns the register block from that thread;
22238 @c otherwise returns current registers.
22240 @c 'G' If the stub supports threads and a specific thread is
22241 @c selected, sets the registers of the register block of
22242 @c that thread; otherwise sets current registers.
22244 @item @code{i}@var{addr}@code{,}@var{nnn} --- cycle step @strong{(draft)}
22245 @anchor{cycle step packet}
22246 @cindex @code{i} packet
22248 Step the remote target by a single clock cycle. If @code{,}@var{nnn} is
22249 present, cycle step @var{nnn} cycles. If @var{addr} is present, cycle
22250 step starting at that address.
22252 @item @code{I} --- signal then cycle step @strong{(reserved)}
22253 @cindex @code{I} packet
22255 @xref{step with signal packet}. @xref{cycle step packet}.
22257 @item @code{j} --- reserved
22259 Reserved for future use.
22261 @item @code{J} --- reserved
22263 Reserved for future use.
22265 @item @code{k} --- kill request
22266 @cindex @code{k} packet
22268 FIXME: @emph{There is no description of how to operate when a specific
22269 thread context has been selected (i.e.@: does 'k' kill only that
22272 @item @code{K} --- reserved
22274 Reserved for future use.
22276 @item @code{l} --- reserved
22278 Reserved for future use.
22280 @item @code{L} --- reserved
22282 Reserved for future use.
22284 @item @code{m}@var{addr}@code{,}@var{length} --- read memory
22285 @cindex @code{m} packet
22287 Read @var{length} bytes of memory starting at address @var{addr}.
22288 Neither @value{GDBN} nor the stub assume that sized memory transfers are
22289 assumed using word aligned accesses. FIXME: @emph{A word aligned memory
22290 transfer mechanism is needed.}
22294 @item @var{XX@dots{}}
22295 @var{XX@dots{}} is mem contents. Can be fewer bytes than requested if able
22296 to read only part of the data. Neither @value{GDBN} nor the stub assume
22297 that sized memory transfers are assumed using word aligned
22298 accesses. FIXME: @emph{A word aligned memory transfer mechanism is
22304 @item @code{M}@var{addr},@var{length}@code{:}@var{XX@dots{}} --- write mem
22305 @cindex @code{M} packet
22307 Write @var{length} bytes of memory starting at address @var{addr}.
22308 @var{XX@dots{}} is the data.
22315 for an error (this includes the case where only part of the data was
22319 @item @code{n} --- reserved
22321 Reserved for future use.
22323 @item @code{N} --- reserved
22325 Reserved for future use.
22327 @item @code{o} --- reserved
22329 Reserved for future use.
22331 @item @code{O} --- reserved
22333 @item @code{p}@var{hex number of register} --- read register packet
22334 @cindex @code{p} packet
22336 @xref{read registers packet}, for a description of how the returned
22337 register value is encoded.
22341 @item @var{XX@dots{}}
22342 the register's value
22346 Indicating an unrecognized @var{query}.
22349 @item @code{P}@var{n@dots{}}@code{=}@var{r@dots{}} --- write register
22350 @anchor{write register packet}
22351 @cindex @code{P} packet
22353 Write register @var{n@dots{}} with value @var{r@dots{}}, which contains two hex
22354 digits for each byte in the register (target byte order).
22364 @item @code{q}@var{query} --- general query
22365 @anchor{general query packet}
22366 @cindex @code{q} packet
22368 Request info about @var{query}. In general @value{GDBN} queries have a
22369 leading upper case letter. Custom vendor queries should use a company
22370 prefix (in lower case) ex: @samp{qfsf.var}. @var{query} may optionally
22371 be followed by a @samp{,} or @samp{;} separated list. Stubs must ensure
22372 that they match the full @var{query} name.
22376 @item @var{XX@dots{}}
22377 Hex encoded data from query. The reply can not be empty.
22381 Indicating an unrecognized @var{query}.
22384 @item @code{Q}@var{var}@code{=}@var{val} --- general set
22385 @cindex @code{Q} packet
22387 Set value of @var{var} to @var{val}.
22389 @xref{general query packet}, for a discussion of naming conventions.
22391 @item @code{r} --- reset @strong{(deprecated)}
22392 @cindex @code{r} packet
22394 Reset the entire system.
22396 @item @code{R}@var{XX} --- remote restart
22397 @cindex @code{R} packet
22399 Restart the program being debugged. @var{XX}, while needed, is ignored.
22400 This packet is only available in extended mode.
22404 @item @emph{no reply}
22405 The @samp{R} packet has no reply.
22408 @item @code{s}@var{addr} --- step
22409 @cindex @code{s} packet
22411 @var{addr} is address to resume. If @var{addr} is omitted, resume at
22415 @xref{Stop Reply Packets}, for the reply specifications.
22417 @item @code{S}@var{sig}@code{;}@var{addr} --- step with signal
22418 @anchor{step with signal packet}
22419 @cindex @code{S} packet
22421 Like @samp{C} but step not continue.
22424 @xref{Stop Reply Packets}, for the reply specifications.
22426 @item @code{t}@var{addr}@code{:}@var{PP}@code{,}@var{MM} --- search
22427 @cindex @code{t} packet
22429 Search backwards starting at address @var{addr} for a match with pattern
22430 @var{PP} and mask @var{MM}. @var{PP} and @var{MM} are 4 bytes.
22431 @var{addr} must be at least 3 digits.
22433 @item @code{T}@var{XX} --- thread alive
22434 @cindex @code{T} packet
22436 Find out if the thread XX is alive.
22441 thread is still alive
22446 @item @code{u} --- reserved
22448 Reserved for future use.
22450 @item @code{U} --- reserved
22452 Reserved for future use.
22454 @item @code{v} --- verbose packet prefix
22456 Packets starting with @code{v} are identified by a multi-letter name,
22457 up to the first @code{;} or @code{?} (or the end of the packet).
22459 @item @code{vCont}[;@var{action}[@code{:}@var{tid}]]... --- extended resume
22460 @cindex @code{vCont} packet
22462 Resume the inferior. Different actions may be specified for each thread.
22463 If an action is specified with no @var{tid}, then it is applied to any
22464 threads that don't have a specific action specified; if no default action is
22465 specified then other threads should remain stopped. Specifying multiple
22466 default actions is an error; specifying no actions is also an error.
22467 Thread IDs are specified in hexadecimal. Currently supported actions are:
22473 Continue with signal @var{sig}. @var{sig} should be two hex digits.
22477 Step with signal @var{sig}. @var{sig} should be two hex digits.
22480 The optional @var{addr} argument normally associated with these packets is
22481 not supported in @code{vCont}.
22484 @xref{Stop Reply Packets}, for the reply specifications.
22486 @item @code{vCont?} --- extended resume query
22487 @cindex @code{vCont?} packet
22489 Query support for the @code{vCont} packet.
22493 @item @code{vCont}[;@var{action}]...
22494 The @code{vCont} packet is supported. Each @var{action} is a supported
22495 command in the @code{vCont} packet.
22497 The @code{vCont} packet is not supported.
22500 @item @code{V} --- reserved
22502 Reserved for future use.
22504 @item @code{w} --- reserved
22506 Reserved for future use.
22508 @item @code{W} --- reserved
22510 Reserved for future use.
22512 @item @code{x} --- reserved
22514 Reserved for future use.
22516 @item @code{X}@var{addr}@code{,}@var{length}@var{:}@var{XX@dots{}} --- write mem (binary)
22517 @cindex @code{X} packet
22519 @var{addr} is address, @var{length} is number of bytes, @var{XX@dots{}}
22520 is binary data. The characters @code{$}, @code{#}, and @code{0x7d} are
22521 escaped using @code{0x7d}, and then XORed with @code{0x20}.
22522 For example, @code{0x7d} would be transmitted as @code{0x7d 0x5d}.
22532 @item @code{y} --- reserved
22534 Reserved for future use.
22536 @item @code{Y} reserved
22538 Reserved for future use.
22540 @item @code{z}@var{type}@code{,}@var{addr}@code{,}@var{length} --- remove breakpoint or watchpoint @strong{(draft)}
22541 @itemx @code{Z}@var{type}@code{,}@var{addr}@code{,}@var{length} --- insert breakpoint or watchpoint @strong{(draft)}
22542 @anchor{insert breakpoint or watchpoint packet}
22543 @cindex @code{z} packet
22544 @cindex @code{Z} packets
22546 Insert (@code{Z}) or remove (@code{z}) a @var{type} breakpoint or
22547 watchpoint starting at address @var{address} and covering the next
22548 @var{length} bytes.
22550 Each breakpoint and watchpoint packet @var{type} is documented
22553 @emph{Implementation notes: A remote target shall return an empty string
22554 for an unrecognized breakpoint or watchpoint packet @var{type}. A
22555 remote target shall support either both or neither of a given
22556 @code{Z}@var{type}@dots{} and @code{z}@var{type}@dots{} packet pair. To
22557 avoid potential problems with duplicate packets, the operations should
22558 be implemented in an idempotent way.}
22560 @item @code{z}@code{0}@code{,}@var{addr}@code{,}@var{length} --- remove memory breakpoint @strong{(draft)}
22561 @item @code{Z}@code{0}@code{,}@var{addr}@code{,}@var{length} --- insert memory breakpoint @strong{(draft)}
22562 @cindex @code{z0} packet
22563 @cindex @code{Z0} packet
22565 Insert (@code{Z0}) or remove (@code{z0}) a memory breakpoint at address
22566 @code{addr} of size @code{length}.
22568 A memory breakpoint is implemented by replacing the instruction at
22569 @var{addr} with a software breakpoint or trap instruction. The
22570 @code{length} is used by targets that indicates the size of the
22571 breakpoint (in bytes) that should be inserted (e.g., the @sc{arm} and
22572 @sc{mips} can insert either a 2 or 4 byte breakpoint).
22574 @emph{Implementation note: It is possible for a target to copy or move
22575 code that contains memory breakpoints (e.g., when implementing
22576 overlays). The behavior of this packet, in the presence of such a
22577 target, is not defined.}
22589 @item @code{z}@code{1}@code{,}@var{addr}@code{,}@var{length} --- remove hardware breakpoint @strong{(draft)}
22590 @item @code{Z}@code{1}@code{,}@var{addr}@code{,}@var{length} --- insert hardware breakpoint @strong{(draft)}
22591 @cindex @code{z1} packet
22592 @cindex @code{Z1} packet
22594 Insert (@code{Z1}) or remove (@code{z1}) a hardware breakpoint at
22595 address @code{addr} of size @code{length}.
22597 A hardware breakpoint is implemented using a mechanism that is not
22598 dependant on being able to modify the target's memory.
22600 @emph{Implementation note: A hardware breakpoint is not affected by code
22613 @item @code{z}@code{2}@code{,}@var{addr}@code{,}@var{length} --- remove write watchpoint @strong{(draft)}
22614 @item @code{Z}@code{2}@code{,}@var{addr}@code{,}@var{length} --- insert write watchpoint @strong{(draft)}
22615 @cindex @code{z2} packet
22616 @cindex @code{Z2} packet
22618 Insert (@code{Z2}) or remove (@code{z2}) a write watchpoint.
22630 @item @code{z}@code{3}@code{,}@var{addr}@code{,}@var{length} --- remove read watchpoint @strong{(draft)}
22631 @item @code{Z}@code{3}@code{,}@var{addr}@code{,}@var{length} --- insert read watchpoint @strong{(draft)}
22632 @cindex @code{z3} packet
22633 @cindex @code{Z3} packet
22635 Insert (@code{Z3}) or remove (@code{z3}) a read watchpoint.
22647 @item @code{z}@code{4}@code{,}@var{addr}@code{,}@var{length} --- remove access watchpoint @strong{(draft)}
22648 @item @code{Z}@code{4}@code{,}@var{addr}@code{,}@var{length} --- insert access watchpoint @strong{(draft)}
22649 @cindex @code{z4} packet
22650 @cindex @code{Z4} packet
22652 Insert (@code{Z4}) or remove (@code{z4}) an access watchpoint.
22666 @node Stop Reply Packets
22667 @section Stop Reply Packets
22668 @cindex stop reply packets
22670 The @samp{C}, @samp{c}, @samp{S}, @samp{s} and @samp{?} packets can
22671 receive any of the below as a reply. In the case of the @samp{C},
22672 @samp{c}, @samp{S} and @samp{s} packets, that reply is only returned
22673 when the target halts. In the below the exact meaning of @samp{signal
22674 number} is poorly defined. In general one of the UNIX signal numbering
22675 conventions is used.
22680 @var{AA} is the signal number
22682 @item @code{T}@var{AA}@var{n...}@code{:}@var{r...}@code{;}@var{n...}@code{:}@var{r...}@code{;}@var{n...}@code{:}@var{r...}@code{;}
22683 @cindex @code{T} packet reply
22685 @var{AA} = two hex digit signal number; @var{n...} = register number
22686 (hex), @var{r...} = target byte ordered register contents, size defined
22687 by @code{DEPRECATED_REGISTER_RAW_SIZE}; @var{n...} = @samp{thread},
22688 @var{r...} = thread process ID, this is a hex integer; @var{n...} =
22689 (@samp{watch} | @samp{rwatch} | @samp{awatch}, @var{r...} = data
22690 address, this is a hex integer; @var{n...} = other string not starting
22691 with valid hex digit. @value{GDBN} should ignore this @var{n...},
22692 @var{r...} pair and go on to the next. This way we can extend the
22697 The process exited, and @var{AA} is the exit status. This is only
22698 applicable to certain targets.
22702 The process terminated with signal @var{AA}.
22704 @item O@var{XX@dots{}}
22706 @var{XX@dots{}} is hex encoding of @sc{ascii} data. This can happen at
22707 any time while the program is running and the debugger should continue
22708 to wait for @samp{W}, @samp{T}, etc.
22710 @item F@var{call-id}@code{,}@var{parameter@dots{}}
22712 @var{call-id} is the identifier which says which host system call should
22713 be called. This is just the name of the function. Translation into the
22714 correct system call is only applicable as it's defined in @value{GDBN}.
22715 @xref{File-I/O remote protocol extension}, for a list of implemented
22718 @var{parameter@dots{}} is a list of parameters as defined for this very
22721 The target replies with this packet when it expects @value{GDBN} to call
22722 a host system call on behalf of the target. @value{GDBN} replies with
22723 an appropriate @code{F} packet and keeps up waiting for the next reply
22724 packet from the target. The latest @samp{C}, @samp{c}, @samp{S} or
22725 @samp{s} action is expected to be continued.
22726 @xref{File-I/O remote protocol extension}, for more details.
22730 @node General Query Packets
22731 @section General Query Packets
22732 @cindex remote query requests
22734 The following set and query packets have already been defined.
22738 @item @code{q}@code{C} --- current thread
22739 @cindex current thread, remote request
22740 @cindex @code{qC} packet
22741 Return the current thread id.
22745 @item @code{QC}@var{pid}
22746 Where @var{pid} is an unsigned hexidecimal process id.
22748 Any other reply implies the old pid.
22751 @item @code{q}@code{fThreadInfo} -- all thread ids
22752 @cindex list active threads, remote request
22753 @cindex @code{qfThreadInfo} packet
22754 @code{q}@code{sThreadInfo}
22756 Obtain a list of active thread ids from the target (OS). Since there
22757 may be too many active threads to fit into one reply packet, this query
22758 works iteratively: it may require more than one query/reply sequence to
22759 obtain the entire list of threads. The first query of the sequence will
22760 be the @code{qf}@code{ThreadInfo} query; subsequent queries in the
22761 sequence will be the @code{qs}@code{ThreadInfo} query.
22763 NOTE: replaces the @code{qL} query (see below).
22767 @item @code{m}@var{id}
22769 @item @code{m}@var{id},@var{id}@dots{}
22770 a comma-separated list of thread ids
22772 (lower case 'el') denotes end of list.
22775 In response to each query, the target will reply with a list of one or
22776 more thread ids, in big-endian unsigned hex, separated by commas.
22777 @value{GDBN} will respond to each reply with a request for more thread
22778 ids (using the @code{qs} form of the query), until the target responds
22779 with @code{l} (lower-case el, for @code{'last'}).
22781 @item @code{q}@code{ThreadExtraInfo}@code{,}@var{id} --- extra thread info
22782 @cindex thread attributes info, remote request
22783 @cindex @code{qThreadExtraInfo} packet
22784 Where @var{id} is a thread-id in big-endian hex. Obtain a printable
22785 string description of a thread's attributes from the target OS. This
22786 string may contain anything that the target OS thinks is interesting for
22787 @value{GDBN} to tell the user about the thread. The string is displayed
22788 in @value{GDBN}'s @samp{info threads} display. Some examples of
22789 possible thread extra info strings are ``Runnable'', or ``Blocked on
22794 @item @var{XX@dots{}}
22795 Where @var{XX@dots{}} is a hex encoding of @sc{ascii} data, comprising
22796 the printable string containing the extra information about the thread's
22800 @item @code{q}@code{L}@var{startflag}@var{threadcount}@var{nextthread} --- query @var{LIST} or @var{threadLIST} @strong{(deprecated)}
22802 Obtain thread information from RTOS. Where: @var{startflag} (one hex
22803 digit) is one to indicate the first query and zero to indicate a
22804 subsequent query; @var{threadcount} (two hex digits) is the maximum
22805 number of threads the response packet can contain; and @var{nextthread}
22806 (eight hex digits), for subsequent queries (@var{startflag} is zero), is
22807 returned in the response as @var{argthread}.
22809 NOTE: this query is replaced by the @code{q}@code{fThreadInfo} query
22814 @item @code{q}@code{M}@var{count}@var{done}@var{argthread}@var{thread@dots{}}
22815 Where: @var{count} (two hex digits) is the number of threads being
22816 returned; @var{done} (one hex digit) is zero to indicate more threads
22817 and one indicates no further threads; @var{argthreadid} (eight hex
22818 digits) is @var{nextthread} from the request packet; @var{thread@dots{}}
22819 is a sequence of thread IDs from the target. @var{threadid} (eight hex
22820 digits). See @code{remote.c:parse_threadlist_response()}.
22823 @item @code{q}@code{CRC:}@var{addr}@code{,}@var{length} --- compute CRC of memory block
22824 @cindex CRC of memory block, remote request
22825 @cindex @code{qCRC} packet
22828 @item @code{E}@var{NN}
22829 An error (such as memory fault)
22830 @item @code{C}@var{CRC32}
22831 A 32 bit cyclic redundancy check of the specified memory region.
22834 @item @code{q}@code{Offsets} --- query sect offs
22835 @cindex section offsets, remote request
22836 @cindex @code{qOffsets} packet
22837 Get section offsets that the target used when re-locating the downloaded
22838 image. @emph{Note: while a @code{Bss} offset is included in the
22839 response, @value{GDBN} ignores this and instead applies the @code{Data}
22840 offset to the @code{Bss} section.}
22844 @item @code{Text=}@var{xxx}@code{;Data=}@var{yyy}@code{;Bss=}@var{zzz}
22847 @item @code{q}@code{P}@var{mode}@var{threadid} --- thread info request
22848 @cindex thread information, remote request
22849 @cindex @code{qP} packet
22850 Returns information on @var{threadid}. Where: @var{mode} is a hex
22851 encoded 32 bit mode; @var{threadid} is a hex encoded 64 bit thread ID.
22858 See @code{remote.c:remote_unpack_thread_info_response()}.
22860 @item @code{q}@code{Rcmd,}@var{command} --- remote command
22861 @cindex execute remote command, remote request
22862 @cindex @code{qRcmd} packet
22863 @var{command} (hex encoded) is passed to the local interpreter for
22864 execution. Invalid commands should be reported using the output string.
22865 Before the final result packet, the target may also respond with a
22866 number of intermediate @code{O}@var{output} console output packets.
22867 @emph{Implementors should note that providing access to a stubs's
22868 interpreter may have security implications}.
22873 A command response with no output.
22875 A command response with the hex encoded output string @var{OUTPUT}.
22876 @item @code{E}@var{NN}
22877 Indicate a badly formed request.
22879 When @samp{q}@samp{Rcmd} is not recognized.
22882 @item @code{qSymbol::} --- symbol lookup
22883 @cindex symbol lookup, remote request
22884 @cindex @code{qSymbol} packet
22885 Notify the target that @value{GDBN} is prepared to serve symbol lookup
22886 requests. Accept requests from the target for the values of symbols.
22891 The target does not need to look up any (more) symbols.
22892 @item @code{qSymbol:}@var{sym_name}
22893 The target requests the value of symbol @var{sym_name} (hex encoded).
22894 @value{GDBN} may provide the value by using the
22895 @code{qSymbol:}@var{sym_value}:@var{sym_name} message, described below.
22898 @item @code{qSymbol:}@var{sym_value}:@var{sym_name} --- symbol value
22900 Set the value of @var{sym_name} to @var{sym_value}.
22902 @var{sym_name} (hex encoded) is the name of a symbol whose value the
22903 target has previously requested.
22905 @var{sym_value} (hex) is the value for symbol @var{sym_name}. If
22906 @value{GDBN} cannot supply a value for @var{sym_name}, then this field
22912 The target does not need to look up any (more) symbols.
22913 @item @code{qSymbol:}@var{sym_name}
22914 The target requests the value of a new symbol @var{sym_name} (hex
22915 encoded). @value{GDBN} will continue to supply the values of symbols
22916 (if available), until the target ceases to request them.
22919 @item @code{qPart}:@var{object}:@code{read}:@var{annex}:@var{offset},@var{length} --- read special data
22920 @cindex read special object, remote request
22921 @cindex @code{qPart} packet
22922 Read uninterpreted bytes from the target's special data area
22923 identified by the keyword @code{object}.
22924 Request @var{length} bytes starting at @var{offset} bytes into the data.
22925 The content and encoding of @var{annex} is specific to the object;
22926 it can supply additional details about what data to access.
22928 Here are the specific requests of this form defined so far.
22929 All @samp{@code{qPart}:@var{object}:@code{read}:@dots{}}
22930 requests use the same reply formats, listed below.
22933 @item @code{qPart}:@code{auxv}:@code{read}::@var{offset},@var{length}
22934 Access the target's @dfn{auxiliary vector}. @xref{OS Information,
22935 auxiliary vector}, and see @ref{Remote configuration,
22936 read-aux-vector-packet}. Note @var{annex} must be empty.
22942 The @var{offset} in the request is at the end of the data.
22943 There is no more data to be read.
22945 @item @var{XX@dots{}}
22946 Hex encoded data bytes read.
22947 This may be fewer bytes than the @var{length} in the request.
22950 The request was malformed, or @var{annex} was invalid.
22952 @item @code{E}@var{nn}
22953 The offset was invalid, or there was an error encountered reading the data.
22954 @var{nn} is a hex-encoded @code{errno} value.
22956 @item @code{""} (empty)
22957 An empty reply indicates the @var{object} or @var{annex} string was not
22958 recognized by the stub.
22961 @item @code{qPart}:@var{object}:@code{write}:@var{annex}:@var{offset}:@var{data@dots{}}
22962 @cindex write data into object, remote request
22963 Write uninterpreted bytes into the target's special data area
22964 identified by the keyword @code{object},
22965 starting at @var{offset} bytes into the data.
22966 @var{data@dots{}} is the hex-encoded data to be written.
22967 The content and encoding of @var{annex} is specific to the object;
22968 it can supply additional details about what data to access.
22970 No requests of this form are presently in use. This specification
22971 serves as a placeholder to document the common format that new
22972 specific request specifications ought to use.
22977 @var{nn} (hex encoded) is the number of bytes written.
22978 This may be fewer bytes than supplied in the request.
22981 The request was malformed, or @var{annex} was invalid.
22983 @item @code{E}@var{nn}
22984 The offset was invalid, or there was an error encountered writing the data.
22985 @var{nn} is a hex-encoded @code{errno} value.
22987 @item @code{""} (empty)
22988 An empty reply indicates the @var{object} or @var{annex} string was not
22989 recognized by the stub, or that the object does not support writing.
22992 @item @code{qPart}:@var{object}:@var{operation}:@dots{}
22993 Requests of this form may be added in the future. When a stub does
22994 not recognize the @var{object} keyword, or its support for
22995 @var{object} does not recognize the @var{operation} keyword,
22996 the stub must respond with an empty packet.
22998 @item @code{qGetTLSAddr}:@var{thread-id},@var{offset},@var{lm} --- get thread local storage address
22999 @cindex get thread-local storage address, remote request
23000 @cindex @code{qGetTLSAddr} packet
23001 Fetch the address associated with thread local storage specified
23002 by @var{thread-id}, @var{offset}, and @var{lm}.
23004 @var{thread-id} is the (big endian, hex encoded) thread id associated with the
23005 thread for which to fetch the TLS address.
23007 @var{offset} is the (big endian, hex encoded) offset associated with the
23008 thread local variable. (This offset is obtained from the debug
23009 information associated with the variable.)
23011 @var{lm} is the (big endian, hex encoded) OS/ABI specific encoding of the
23012 the load module associated with the thread local storage. For example,
23013 a @sc{gnu}/Linux system will pass the link map address of the shared
23014 object associated with the thread local storage under consideration.
23015 Other operating environments may choose to represent the load module
23016 differently, so the precise meaning of this parameter will vary.
23020 @item @var{XX@dots{}}
23021 Hex encoded (big endian) bytes representing the address of the thread
23022 local storage requested.
23024 @item @code{E}@var{nn} (where @var{nn} are hex digits)
23027 @item @code{""} (empty)
23028 An empty reply indicates that @code{qGetTLSAddr} is not supported by the stub.
23031 Use of this request packet is controlled by the @code{set remote
23032 get-thread-local-storage-address} command (@pxref{Remote
23033 configuration, set remote get-thread-local-storage-address}).
23037 @node Register Packet Format
23038 @section Register Packet Format
23040 The following @samp{g}/@samp{G} packets have previously been defined.
23041 In the below, some thirty-two bit registers are transferred as
23042 sixty-four bits. Those registers should be zero/sign extended (which?)
23043 to fill the space allocated. Register bytes are transfered in target
23044 byte order. The two nibbles within a register byte are transfered
23045 most-significant - least-significant.
23051 All registers are transfered as thirty-two bit quantities in the order:
23052 32 general-purpose; sr; lo; hi; bad; cause; pc; 32 floating-point
23053 registers; fsr; fir; fp.
23057 All registers are transfered as sixty-four bit quantities (including
23058 thirty-two bit registers such as @code{sr}). The ordering is the same
23066 Example sequence of a target being re-started. Notice how the restart
23067 does not get any direct output:
23072 @emph{target restarts}
23075 <- @code{T001:1234123412341234}
23079 Example sequence of a target being stepped by a single instruction:
23082 -> @code{G1445@dots{}}
23087 <- @code{T001:1234123412341234}
23091 <- @code{1455@dots{}}
23095 @node File-I/O remote protocol extension
23096 @section File-I/O remote protocol extension
23097 @cindex File-I/O remote protocol extension
23100 * File-I/O Overview::
23101 * Protocol basics::
23102 * The F request packet::
23103 * The F reply packet::
23104 * Memory transfer::
23105 * The Ctrl-C message::
23107 * The isatty call::
23108 * The system call::
23109 * List of supported calls::
23110 * Protocol specific representation of datatypes::
23112 * File-I/O Examples::
23115 @node File-I/O Overview
23116 @subsection File-I/O Overview
23117 @cindex file-i/o overview
23119 The @dfn{File I/O remote protocol extension} (short: File-I/O) allows the
23120 target to use the host's file system and console I/O when calling various
23121 system calls. System calls on the target system are translated into a
23122 remote protocol packet to the host system which then performs the needed
23123 actions and returns with an adequate response packet to the target system.
23124 This simulates file system operations even on targets that lack file systems.
23126 The protocol is defined host- and target-system independent. It uses
23127 its own independent representation of datatypes and values. Both,
23128 @value{GDBN} and the target's @value{GDBN} stub are responsible for
23129 translating the system dependent values into the unified protocol values
23130 when data is transmitted.
23132 The communication is synchronous. A system call is possible only
23133 when GDB is waiting for the @samp{C}, @samp{c}, @samp{S} or @samp{s}
23134 packets. While @value{GDBN} handles the request for a system call,
23135 the target is stopped to allow deterministic access to the target's
23136 memory. Therefore File-I/O is not interuptible by target signals. It
23137 is possible to interrupt File-I/O by a user interrupt (Ctrl-C), though.
23139 The target's request to perform a host system call does not finish
23140 the latest @samp{C}, @samp{c}, @samp{S} or @samp{s} action. That means,
23141 after finishing the system call, the target returns to continuing the
23142 previous activity (continue, step). No additional continue or step
23143 request from @value{GDBN} is required.
23146 (@value{GDBP}) continue
23147 <- target requests 'system call X'
23148 target is stopped, @value{GDBN} executes system call
23149 -> GDB returns result
23150 ... target continues, GDB returns to wait for the target
23151 <- target hits breakpoint and sends a Txx packet
23154 The protocol is only used for files on the host file system and
23155 for I/O on the console. Character or block special devices, pipes,
23156 named pipes or sockets or any other communication method on the host
23157 system are not supported by this protocol.
23159 @node Protocol basics
23160 @subsection Protocol basics
23161 @cindex protocol basics, file-i/o
23163 The File-I/O protocol uses the @code{F} packet, as request as well
23164 as as reply packet. Since a File-I/O system call can only occur when
23165 @value{GDBN} is waiting for the continuing or stepping target, the
23166 File-I/O request is a reply that @value{GDBN} has to expect as a result
23167 of a former @samp{C}, @samp{c}, @samp{S} or @samp{s} packet.
23168 This @code{F} packet contains all information needed to allow @value{GDBN}
23169 to call the appropriate host system call:
23173 A unique identifier for the requested system call.
23176 All parameters to the system call. Pointers are given as addresses
23177 in the target memory address space. Pointers to strings are given as
23178 pointer/length pair. Numerical values are given as they are.
23179 Numerical control values are given in a protocol specific representation.
23183 At that point @value{GDBN} has to perform the following actions.
23187 If parameter pointer values are given, which point to data needed as input
23188 to a system call, @value{GDBN} requests this data from the target with a
23189 standard @code{m} packet request. This additional communication has to be
23190 expected by the target implementation and is handled as any other @code{m}
23194 @value{GDBN} translates all value from protocol representation to host
23195 representation as needed. Datatypes are coerced into the host types.
23198 @value{GDBN} calls the system call
23201 It then coerces datatypes back to protocol representation.
23204 If pointer parameters in the request packet point to buffer space in which
23205 a system call is expected to copy data to, the data is transmitted to the
23206 target using a @code{M} or @code{X} packet. This packet has to be expected
23207 by the target implementation and is handled as any other @code{M} or @code{X}
23212 Eventually @value{GDBN} replies with another @code{F} packet which contains all
23213 necessary information for the target to continue. This at least contains
23220 @code{errno}, if has been changed by the system call.
23227 After having done the needed type and value coercion, the target continues
23228 the latest continue or step action.
23230 @node The F request packet
23231 @subsection The @code{F} request packet
23232 @cindex file-i/o request packet
23233 @cindex @code{F} request packet
23235 The @code{F} request packet has the following format:
23240 @code{F}@var{call-id}@code{,}@var{parameter@dots{}}
23243 @var{call-id} is the identifier to indicate the host system call to be called.
23244 This is just the name of the function.
23246 @var{parameter@dots{}} are the parameters to the system call.
23250 Parameters are hexadecimal integer values, either the real values in case
23251 of scalar datatypes, as pointers to target buffer space in case of compound
23252 datatypes and unspecified memory areas or as pointer/length pairs in case
23253 of string parameters. These are appended to the call-id, each separated
23254 from its predecessor by a comma. All values are transmitted in ASCII
23255 string representation, pointer/length pairs separated by a slash.
23257 @node The F reply packet
23258 @subsection The @code{F} reply packet
23259 @cindex file-i/o reply packet
23260 @cindex @code{F} reply packet
23262 The @code{F} reply packet has the following format:
23267 @code{F}@var{retcode}@code{,}@var{errno}@code{,}@var{Ctrl-C flag}@code{;}@var{call specific attachment}
23270 @var{retcode} is the return code of the system call as hexadecimal value.
23272 @var{errno} is the errno set by the call, in protocol specific representation.
23273 This parameter can be omitted if the call was successful.
23275 @var{Ctrl-C flag} is only send if the user requested a break. In this
23276 case, @var{errno} must be send as well, even if the call was successful.
23277 The @var{Ctrl-C flag} itself consists of the character 'C':
23284 or, if the call was interupted before the host call has been performed:
23291 assuming 4 is the protocol specific representation of @code{EINTR}.
23295 @node Memory transfer
23296 @subsection Memory transfer
23297 @cindex memory transfer, in file-i/o protocol
23299 Structured data which is transferred using a memory read or write as e.g.@:
23300 a @code{struct stat} is expected to be in a protocol specific format with
23301 all scalar multibyte datatypes being big endian. This should be done by
23302 the target before the @code{F} packet is sent resp.@: by @value{GDBN} before
23303 it transfers memory to the target. Transferred pointers to structured
23304 data should point to the already coerced data at any time.
23306 @node The Ctrl-C message
23307 @subsection The Ctrl-C message
23308 @cindex ctrl-c message, in file-i/o protocol
23310 A special case is, if the @var{Ctrl-C flag} is set in the @value{GDBN}
23311 reply packet. In this case the target should behave, as if it had
23312 gotten a break message. The meaning for the target is ``system call
23313 interupted by @code{SIGINT}''. Consequentially, the target should actually stop
23314 (as with a break message) and return to @value{GDBN} with a @code{T02}
23315 packet. In this case, it's important for the target to know, in which
23316 state the system call was interrupted. Since this action is by design
23317 not an atomic operation, we have to differ between two cases:
23321 The system call hasn't been performed on the host yet.
23324 The system call on the host has been finished.
23328 These two states can be distinguished by the target by the value of the
23329 returned @code{errno}. If it's the protocol representation of @code{EINTR}, the system
23330 call hasn't been performed. This is equivalent to the @code{EINTR} handling
23331 on POSIX systems. In any other case, the target may presume that the
23332 system call has been finished --- successful or not --- and should behave
23333 as if the break message arrived right after the system call.
23335 @value{GDBN} must behave reliable. If the system call has not been called
23336 yet, @value{GDBN} may send the @code{F} reply immediately, setting @code{EINTR} as
23337 @code{errno} in the packet. If the system call on the host has been finished
23338 before the user requests a break, the full action must be finshed by
23339 @value{GDBN}. This requires sending @code{M} or @code{X} packets as they fit.
23340 The @code{F} packet may only be send when either nothing has happened
23341 or the full action has been completed.
23344 @subsection Console I/O
23345 @cindex console i/o as part of file-i/o
23347 By default and if not explicitely closed by the target system, the file
23348 descriptors 0, 1 and 2 are connected to the @value{GDBN} console. Output
23349 on the @value{GDBN} console is handled as any other file output operation
23350 (@code{write(1, @dots{})} or @code{write(2, @dots{})}). Console input is handled
23351 by @value{GDBN} so that after the target read request from file descriptor
23352 0 all following typing is buffered until either one of the following
23357 The user presses @kbd{Ctrl-C}. The behaviour is as explained above, the
23359 system call is treated as finished.
23362 The user presses @kbd{Enter}. This is treated as end of input with a trailing
23366 The user presses @kbd{Ctrl-D}. This is treated as end of input. No trailing
23367 character, especially no Ctrl-D is appended to the input.
23371 If the user has typed more characters as fit in the buffer given to
23372 the read call, the trailing characters are buffered in @value{GDBN} until
23373 either another @code{read(0, @dots{})} is requested by the target or debugging
23374 is stopped on users request.
23376 @node The isatty call
23377 @subsection The @samp{isatty} function call
23378 @cindex isatty call, file-i/o protocol
23380 A special case in this protocol is the library call @code{isatty} which
23381 is implemented as its own call inside of this protocol. It returns
23382 1 to the target if the file descriptor given as parameter is attached
23383 to the @value{GDBN} console, 0 otherwise. Implementing through system calls
23384 would require implementing @code{ioctl} and would be more complex than
23387 @node The system call
23388 @subsection The @samp{system} function call
23389 @cindex system call, file-i/o protocol
23391 The other special case in this protocol is the @code{system} call which
23392 is implemented as its own call, too. @value{GDBN} is taking over the full
23393 task of calling the necessary host calls to perform the @code{system}
23394 call. The return value of @code{system} is simplified before it's returned
23395 to the target. Basically, the only signal transmitted back is @code{EINTR}
23396 in case the user pressed @kbd{Ctrl-C}. Otherwise the return value consists
23397 entirely of the exit status of the called command.
23399 Due to security concerns, the @code{system} call is by default refused
23400 by @value{GDBN}. The user has to allow this call explicitly with the
23401 @kbd{set remote system-call-allowed 1} command.
23404 @item set remote system-call-allowed
23405 @kindex set remote system-call-allowed
23406 Control whether to allow the @code{system} calls in the File I/O
23407 protocol for the remote target. The default is zero (disabled).
23409 @item show remote system-call-allowed
23410 @kindex show remote system-call-allowed
23411 Show the current setting of system calls for the remote File I/O
23415 @node List of supported calls
23416 @subsection List of supported calls
23417 @cindex list of supported file-i/o calls
23434 @unnumberedsubsubsec open
23435 @cindex open, file-i/o system call
23439 int open(const char *pathname, int flags);
23440 int open(const char *pathname, int flags, mode_t mode);
23443 Fopen,pathptr/len,flags,mode
23447 @code{flags} is the bitwise or of the following values:
23451 If the file does not exist it will be created. The host
23452 rules apply as far as file ownership and time stamps
23456 When used with O_CREAT, if the file already exists it is
23457 an error and open() fails.
23460 If the file already exists and the open mode allows
23461 writing (O_RDWR or O_WRONLY is given) it will be
23462 truncated to length 0.
23465 The file is opened in append mode.
23468 The file is opened for reading only.
23471 The file is opened for writing only.
23474 The file is opened for reading and writing.
23477 Each other bit is silently ignored.
23482 @code{mode} is the bitwise or of the following values:
23486 User has read permission.
23489 User has write permission.
23492 Group has read permission.
23495 Group has write permission.
23498 Others have read permission.
23501 Others have write permission.
23504 Each other bit is silently ignored.
23509 @exdent Return value:
23510 open returns the new file descriptor or -1 if an error
23518 pathname already exists and O_CREAT and O_EXCL were used.
23521 pathname refers to a directory.
23524 The requested access is not allowed.
23527 pathname was too long.
23530 A directory component in pathname does not exist.
23533 pathname refers to a device, pipe, named pipe or socket.
23536 pathname refers to a file on a read-only filesystem and
23537 write access was requested.
23540 pathname is an invalid pointer value.
23543 No space on device to create the file.
23546 The process already has the maximum number of files open.
23549 The limit on the total number of files open on the system
23553 The call was interrupted by the user.
23557 @unnumberedsubsubsec close
23558 @cindex close, file-i/o system call
23567 @exdent Return value:
23568 close returns zero on success, or -1 if an error occurred.
23575 fd isn't a valid open file descriptor.
23578 The call was interrupted by the user.
23582 @unnumberedsubsubsec read
23583 @cindex read, file-i/o system call
23587 int read(int fd, void *buf, unsigned int count);
23590 Fread,fd,bufptr,count
23592 @exdent Return value:
23593 On success, the number of bytes read is returned.
23594 Zero indicates end of file. If count is zero, read
23595 returns zero as well. On error, -1 is returned.
23602 fd is not a valid file descriptor or is not open for
23606 buf is an invalid pointer value.
23609 The call was interrupted by the user.
23613 @unnumberedsubsubsec write
23614 @cindex write, file-i/o system call
23618 int write(int fd, const void *buf, unsigned int count);
23621 Fwrite,fd,bufptr,count
23623 @exdent Return value:
23624 On success, the number of bytes written are returned.
23625 Zero indicates nothing was written. On error, -1
23633 fd is not a valid file descriptor or is not open for
23637 buf is an invalid pointer value.
23640 An attempt was made to write a file that exceeds the
23641 host specific maximum file size allowed.
23644 No space on device to write the data.
23647 The call was interrupted by the user.
23651 @unnumberedsubsubsec lseek
23652 @cindex lseek, file-i/o system call
23656 long lseek (int fd, long offset, int flag);
23659 Flseek,fd,offset,flag
23662 @code{flag} is one of:
23666 The offset is set to offset bytes.
23669 The offset is set to its current location plus offset
23673 The offset is set to the size of the file plus offset
23678 @exdent Return value:
23679 On success, the resulting unsigned offset in bytes from
23680 the beginning of the file is returned. Otherwise, a
23681 value of -1 is returned.
23688 fd is not a valid open file descriptor.
23691 fd is associated with the @value{GDBN} console.
23694 flag is not a proper value.
23697 The call was interrupted by the user.
23701 @unnumberedsubsubsec rename
23702 @cindex rename, file-i/o system call
23706 int rename(const char *oldpath, const char *newpath);
23709 Frename,oldpathptr/len,newpathptr/len
23711 @exdent Return value:
23712 On success, zero is returned. On error, -1 is returned.
23719 newpath is an existing directory, but oldpath is not a
23723 newpath is a non-empty directory.
23726 oldpath or newpath is a directory that is in use by some
23730 An attempt was made to make a directory a subdirectory
23734 A component used as a directory in oldpath or new
23735 path is not a directory. Or oldpath is a directory
23736 and newpath exists but is not a directory.
23739 oldpathptr or newpathptr are invalid pointer values.
23742 No access to the file or the path of the file.
23746 oldpath or newpath was too long.
23749 A directory component in oldpath or newpath does not exist.
23752 The file is on a read-only filesystem.
23755 The device containing the file has no room for the new
23759 The call was interrupted by the user.
23763 @unnumberedsubsubsec unlink
23764 @cindex unlink, file-i/o system call
23768 int unlink(const char *pathname);
23771 Funlink,pathnameptr/len
23773 @exdent Return value:
23774 On success, zero is returned. On error, -1 is returned.
23781 No access to the file or the path of the file.
23784 The system does not allow unlinking of directories.
23787 The file pathname cannot be unlinked because it's
23788 being used by another process.
23791 pathnameptr is an invalid pointer value.
23794 pathname was too long.
23797 A directory component in pathname does not exist.
23800 A component of the path is not a directory.
23803 The file is on a read-only filesystem.
23806 The call was interrupted by the user.
23810 @unnumberedsubsubsec stat/fstat
23811 @cindex fstat, file-i/o system call
23812 @cindex stat, file-i/o system call
23816 int stat(const char *pathname, struct stat *buf);
23817 int fstat(int fd, struct stat *buf);
23820 Fstat,pathnameptr/len,bufptr
23823 @exdent Return value:
23824 On success, zero is returned. On error, -1 is returned.
23831 fd is not a valid open file.
23834 A directory component in pathname does not exist or the
23835 path is an empty string.
23838 A component of the path is not a directory.
23841 pathnameptr is an invalid pointer value.
23844 No access to the file or the path of the file.
23847 pathname was too long.
23850 The call was interrupted by the user.
23854 @unnumberedsubsubsec gettimeofday
23855 @cindex gettimeofday, file-i/o system call
23859 int gettimeofday(struct timeval *tv, void *tz);
23862 Fgettimeofday,tvptr,tzptr
23864 @exdent Return value:
23865 On success, 0 is returned, -1 otherwise.
23872 tz is a non-NULL pointer.
23875 tvptr and/or tzptr is an invalid pointer value.
23879 @unnumberedsubsubsec isatty
23880 @cindex isatty, file-i/o system call
23884 int isatty(int fd);
23889 @exdent Return value:
23890 Returns 1 if fd refers to the @value{GDBN} console, 0 otherwise.
23897 The call was interrupted by the user.
23901 @unnumberedsubsubsec system
23902 @cindex system, file-i/o system call
23906 int system(const char *command);
23909 Fsystem,commandptr/len
23911 @exdent Return value:
23912 The value returned is -1 on error and the return status
23913 of the command otherwise. Only the exit status of the
23914 command is returned, which is extracted from the hosts
23915 system return value by calling WEXITSTATUS(retval).
23916 In case /bin/sh could not be executed, 127 is returned.
23923 The call was interrupted by the user.
23926 @node Protocol specific representation of datatypes
23927 @subsection Protocol specific representation of datatypes
23928 @cindex protocol specific representation of datatypes, in file-i/o protocol
23931 * Integral datatypes::
23937 @node Integral datatypes
23938 @unnumberedsubsubsec Integral datatypes
23939 @cindex integral datatypes, in file-i/o protocol
23941 The integral datatypes used in the system calls are
23944 int@r{,} unsigned int@r{,} long@r{,} unsigned long@r{,} mode_t @r{and} time_t
23947 @code{Int}, @code{unsigned int}, @code{mode_t} and @code{time_t} are
23948 implemented as 32 bit values in this protocol.
23950 @code{Long} and @code{unsigned long} are implemented as 64 bit types.
23952 @xref{Limits}, for corresponding MIN and MAX values (similar to those
23953 in @file{limits.h}) to allow range checking on host and target.
23955 @code{time_t} datatypes are defined as seconds since the Epoch.
23957 All integral datatypes transferred as part of a memory read or write of a
23958 structured datatype e.g.@: a @code{struct stat} have to be given in big endian
23961 @node Pointer values
23962 @unnumberedsubsubsec Pointer values
23963 @cindex pointer values, in file-i/o protocol
23965 Pointers to target data are transmitted as they are. An exception
23966 is made for pointers to buffers for which the length isn't
23967 transmitted as part of the function call, namely strings. Strings
23968 are transmitted as a pointer/length pair, both as hex values, e.g.@:
23975 which is a pointer to data of length 18 bytes at position 0x1aaf.
23976 The length is defined as the full string length in bytes, including
23977 the trailing null byte. Example:
23980 ``hello, world'' at address 0x123456
23991 @unnumberedsubsubsec struct stat
23992 @cindex struct stat, in file-i/o protocol
23994 The buffer of type struct stat used by the target and @value{GDBN} is defined
23999 unsigned int st_dev; /* device */
24000 unsigned int st_ino; /* inode */
24001 mode_t st_mode; /* protection */
24002 unsigned int st_nlink; /* number of hard links */
24003 unsigned int st_uid; /* user ID of owner */
24004 unsigned int st_gid; /* group ID of owner */
24005 unsigned int st_rdev; /* device type (if inode device) */
24006 unsigned long st_size; /* total size, in bytes */
24007 unsigned long st_blksize; /* blocksize for filesystem I/O */
24008 unsigned long st_blocks; /* number of blocks allocated */
24009 time_t st_atime; /* time of last access */
24010 time_t st_mtime; /* time of last modification */
24011 time_t st_ctime; /* time of last change */
24015 The integral datatypes are conforming to the definitions given in the
24016 approriate section (see @ref{Integral datatypes}, for details) so this
24017 structure is of size 64 bytes.
24019 The values of several fields have a restricted meaning and/or
24026 st_ino: No valid meaning for the target. Transmitted unchanged.
24028 st_mode: Valid mode bits are described in Appendix C. Any other
24029 bits have currently no meaning for the target.
24031 st_uid: No valid meaning for the target. Transmitted unchanged.
24033 st_gid: No valid meaning for the target. Transmitted unchanged.
24035 st_rdev: No valid meaning for the target. Transmitted unchanged.
24037 st_atime, st_mtime, st_ctime:
24038 These values have a host and file system dependent
24039 accuracy. Especially on Windows hosts the file systems
24040 don't support exact timing values.
24043 The target gets a struct stat of the above representation and is
24044 responsible to coerce it to the target representation before
24047 Note that due to size differences between the host and target
24048 representation of stat members, these members could eventually
24049 get truncated on the target.
24051 @node struct timeval
24052 @unnumberedsubsubsec struct timeval
24053 @cindex struct timeval, in file-i/o protocol
24055 The buffer of type struct timeval used by the target and @value{GDBN}
24056 is defined as follows:
24060 time_t tv_sec; /* second */
24061 long tv_usec; /* microsecond */
24065 The integral datatypes are conforming to the definitions given in the
24066 approriate section (see @ref{Integral datatypes}, for details) so this
24067 structure is of size 8 bytes.
24070 @subsection Constants
24071 @cindex constants, in file-i/o protocol
24073 The following values are used for the constants inside of the
24074 protocol. @value{GDBN} and target are resposible to translate these
24075 values before and after the call as needed.
24086 @unnumberedsubsubsec Open flags
24087 @cindex open flags, in file-i/o protocol
24089 All values are given in hexadecimal representation.
24101 @node mode_t values
24102 @unnumberedsubsubsec mode_t values
24103 @cindex mode_t values, in file-i/o protocol
24105 All values are given in octal representation.
24122 @unnumberedsubsubsec Errno values
24123 @cindex errno values, in file-i/o protocol
24125 All values are given in decimal representation.
24150 EUNKNOWN is used as a fallback error value if a host system returns
24151 any error value not in the list of supported error numbers.
24154 @unnumberedsubsubsec Lseek flags
24155 @cindex lseek flags, in file-i/o protocol
24164 @unnumberedsubsubsec Limits
24165 @cindex limits, in file-i/o protocol
24167 All values are given in decimal representation.
24170 INT_MIN -2147483648
24172 UINT_MAX 4294967295
24173 LONG_MIN -9223372036854775808
24174 LONG_MAX 9223372036854775807
24175 ULONG_MAX 18446744073709551615
24178 @node File-I/O Examples
24179 @subsection File-I/O Examples
24180 @cindex file-i/o examples
24182 Example sequence of a write call, file descriptor 3, buffer is at target
24183 address 0x1234, 6 bytes should be written:
24186 <- @code{Fwrite,3,1234,6}
24187 @emph{request memory read from target}
24190 @emph{return "6 bytes written"}
24194 Example sequence of a read call, file descriptor 3, buffer is at target
24195 address 0x1234, 6 bytes should be read:
24198 <- @code{Fread,3,1234,6}
24199 @emph{request memory write to target}
24200 -> @code{X1234,6:XXXXXX}
24201 @emph{return "6 bytes read"}
24205 Example sequence of a read call, call fails on the host due to invalid
24206 file descriptor (EBADF):
24209 <- @code{Fread,3,1234,6}
24213 Example sequence of a read call, user presses Ctrl-C before syscall on
24217 <- @code{Fread,3,1234,6}
24222 Example sequence of a read call, user presses Ctrl-C after syscall on
24226 <- @code{Fread,3,1234,6}
24227 -> @code{X1234,6:XXXXXX}
24231 @include agentexpr.texi
24245 % I think something like @colophon should be in texinfo. In the
24247 \long\def\colophon{\hbox to0pt{}\vfill
24248 \centerline{The body of this manual is set in}
24249 \centerline{\fontname\tenrm,}
24250 \centerline{with headings in {\bf\fontname\tenbf}}
24251 \centerline{and examples in {\tt\fontname\tentt}.}
24252 \centerline{{\it\fontname\tenit\/},}
24253 \centerline{{\bf\fontname\tenbf}, and}
24254 \centerline{{\sl\fontname\tensl\/}}
24255 \centerline{are used for emphasis.}\vfill}