Home | History | Annotate | Line # | Download | only in doc
      1 \input texinfo      @c -*-texinfo-*-
      2 @c Copyright (C) 1988--2024 Free Software Foundation, Inc.
      3 @c
      4 @c %**start of header
      5 @c makeinfo ignores cmds prev to setfilename, so its arg cannot make use
      6 @c of @set vars.  However, you can override filename with makeinfo -o.
      7 @setfilename gdb.info
      8 @c
      9 @c man begin INCLUDE
     10 @include gdb-cfg.texi
     11 @c man end
     12 @c
     13 @settitle Debugging with @value{GDBN}
     14 @setchapternewpage odd
     15 @c %**end of header
     16 
     17 @iftex
     18 @c @smallbook
     19 @c @cropmarks
     20 @end iftex
     21 
     22 @finalout
     23 @c To avoid file-name clashes between index.html and Index.html, when
     24 @c the manual is produced on a Posix host and then moved to a
     25 @c case-insensitive filesystem (e.g., MS-Windows), we separate the
     26 @c indices into two: Concept Index and all the rest.
     27 @syncodeindex ky fn
     28 @syncodeindex tp fn
     29 
     30 @c readline appendices use @vindex, @findex and @ftable,
     31 @c annotate.texi and gdbmi use @findex.
     32 @syncodeindex vr fn
     33 
     34 @c !!set GDB manual's edition---not the same as GDB version!
     35 @c This is updated by GNU Press.
     36 @set EDITION Tenth
     37 
     38 @c !!set GDB edit command default editor
     39 @set EDITOR /bin/ex
     40 
     41 @c THIS MANUAL REQUIRES TEXINFO 4.0 OR LATER.
     42 
     43 @c This is a dir.info fragment to support semi-automated addition of
     44 @c manuals to an info tree.
     45 @dircategory Software development
     46 @direntry
     47 * Gdb: (gdb).                     The GNU debugger.
     48 * gdbserver: (gdb) Server.        The GNU debugging server.
     49 @end direntry
     50 
     51 @copying
     52 @c man begin COPYRIGHT
     53 Copyright @copyright{} 1988-2024 Free Software Foundation, Inc.
     54 
     55 Permission is granted to copy, distribute and/or modify this document
     56 under the terms of the GNU Free Documentation License, Version 1.3 or
     57 any later version published by the Free Software Foundation; with the
     58 Invariant Sections being ``Free Software'' and ``Free Software Needs
     59 Free Documentation'', with the Front-Cover Texts being ``A GNU Manual,''
     60 and with the Back-Cover Texts as in (a) below.
     61 
     62 (a) The FSF's Back-Cover Text is: ``You are free to copy and modify
     63 this GNU Manual.  Buying copies from GNU Press supports the FSF in
     64 developing GNU and promoting software freedom.''
     65 @c man end
     66 @end copying
     67 
     68 @ifnottex
     69 This file documents the @sc{gnu} debugger @value{GDBN}.
     70 
     71 This is the @value{EDITION} Edition, of @cite{Debugging with
     72 @value{GDBN}: the @sc{gnu} Source-Level Debugger} for @value{GDBN}
     73 @ifset VERSION_PACKAGE
     74 @value{VERSION_PACKAGE}
     75 @end ifset
     76 Version @value{GDBVN}.
     77 
     78 @insertcopying
     79 @end ifnottex
     80 
     81 @titlepage
     82 @title Debugging with @value{GDBN}
     83 @subtitle The @sc{gnu} Source-Level Debugger
     84 @sp 1
     85 @subtitle @value{EDITION} Edition, for @value{GDBN} version @value{GDBVN}
     86 @ifset VERSION_PACKAGE
     87 @sp 1
     88 @subtitle @value{VERSION_PACKAGE}
     89 @end ifset
     90 @author Richard Stallman, Roland Pesch, Stan Shebs, et al.
     91 @page
     92 @tex
     93 {\parskip=0pt
     94 \hfill (Send bugs and comments on @value{GDBN} to @value{BUGURL}.)\par
     95 \hfill {\it Debugging with @value{GDBN}}\par
     96 \hfill \TeX{}info \texinfoversion\par
     97 }
     98 @end tex
     99 
    100 @vskip 0pt plus 1filll
    101 Published by the Free Software Foundation @*
    102 51 Franklin Street, Fifth Floor,
    103 Boston, MA 02110-1301, USA@*
    104 ISBN 978-0-9831592-3-0 @*
    105 
    106 @insertcopying
    107 @end titlepage
    108 @page
    109 
    110 @ifnottex
    111 @node Top, Summary
    112 
    113 @top Debugging with @value{GDBN}
    114 
    115 This file describes @value{GDBN}, the @sc{gnu} symbolic debugger.
    116 
    117 This is the @value{EDITION} Edition, for @value{GDBN}
    118 @ifset VERSION_PACKAGE
    119 @value{VERSION_PACKAGE}
    120 @end ifset
    121 Version @value{GDBVN}.
    122 
    123 Copyright (C) 1988-2024 Free Software Foundation, Inc.
    124 
    125 This edition of the GDB manual is dedicated to the memory of Fred
    126 Fish.  Fred was a long-standing contributor to GDB and to Free
    127 software in general.  We will miss him.
    128 
    129 @menu
    130 * Summary::                     Summary of @value{GDBN}
    131 * Sample Session::              A sample @value{GDBN} session
    132 
    133 * Invocation::                  Getting in and out of @value{GDBN}
    134 * Commands::                    @value{GDBN} commands
    135 * Running::                     Running programs under @value{GDBN}
    136 * Stopping::                    Stopping and continuing
    137 * Reverse Execution::           Running programs backward
    138 * Process Record and Replay::   Recording inferior's execution and replaying it
    139 * Stack::                       Examining the stack
    140 * Source::                      Examining source files
    141 * Data::                        Examining data
    142 * Optimized Code::              Debugging optimized code
    143 * Macros::                      Preprocessor Macros
    144 * Tracepoints::                 Debugging remote targets non-intrusively
    145 * Overlays::                    Debugging programs that use overlays
    146 
    147 * Languages::                   Using @value{GDBN} with different languages
    148 
    149 * Symbols::                     Examining the symbol table
    150 * Altering::                    Altering execution
    151 * GDB Files::                   @value{GDBN} files
    152 * Targets::                     Specifying a debugging target
    153 * Remote Debugging::            Debugging remote programs
    154 * Configurations::              Configuration-specific information
    155 * Controlling GDB::             Controlling @value{GDBN}
    156 * Extending GDB::               Extending @value{GDBN}
    157 * Interpreters::                Command Interpreters
    158 * TUI::                         @value{GDBN} Text User Interface
    159 * Emacs::                       Using @value{GDBN} under @sc{gnu} Emacs
    160 * GDB/MI::                      @value{GDBN}'s Machine Interface.
    161 * Annotations::                 @value{GDBN}'s annotation interface.
    162 * Debugger Adapter Protocol::	The Debugger Adapter Protocol.
    163 * JIT Interface::               Using the JIT debugging interface.
    164 * In-Process Agent::            In-Process Agent
    165 
    166 * GDB Bugs::                    Reporting bugs in @value{GDBN}
    167 
    168 @ifset SYSTEM_READLINE
    169 * Command Line Editing: (rluserman).         Command Line Editing
    170 * Using History Interactively: (history).    Using History Interactively
    171 @end ifset
    172 @ifclear SYSTEM_READLINE
    173 * Command Line Editing::        Command Line Editing
    174 * Using History Interactively:: Using History Interactively
    175 @end ifclear
    176 * In Memoriam::                 In Memoriam
    177 * Formatting Documentation::    How to format and print @value{GDBN} documentation
    178 * Installing GDB::              Installing @value{GDBN}
    179 * Maintenance Commands::        Maintenance Commands
    180 * Remote Protocol::             GDB Remote Serial Protocol
    181 * Agent Expressions::           The @value{GDBN} Agent Expression Mechanism
    182 * Target Descriptions::         How targets can describe themselves to
    183                                 @value{GDBN}
    184 * Operating System Information:: Getting additional information from
    185                                  the operating system
    186 * Trace File Format::		@value{GDBN} trace file format
    187 * Index Section Format::        .gdb_index section format
    188 * Debuginfod::                  Download debugging resources with @code{debuginfod}
    189 * Man Pages::                   Manual pages
    190 * Copying::                     GNU General Public License says
    191                                 how you can copy and share @value{GDBN}
    192 * GNU Free Documentation License::  The license for this documentation
    193 * Concept Index::               Index of @value{GDBN} concepts
    194 * Command and Variable Index::  Index of @value{GDBN} commands, variables,
    195                                 functions, and Python data types
    196 @end menu
    197 
    198 @end ifnottex
    199 
    200 @contents
    201 
    202 @node Summary
    203 @unnumbered Summary of @value{GDBN}
    204 
    205 The purpose of a debugger such as @value{GDBN} is to allow you to see what is
    206 going on ``inside'' another program while it executes---or what another
    207 program was doing at the moment it crashed.
    208 
    209 @value{GDBN} can do four main kinds of things (plus other things in support of
    210 these) to help you catch bugs in the act:
    211 
    212 @itemize @bullet
    213 @item
    214 Start your program, specifying anything that might affect its behavior.
    215 
    216 @item
    217 Make your program stop on specified conditions.
    218 
    219 @item
    220 Examine what has happened, when your program has stopped.
    221 
    222 @item
    223 Change things in your program, so you can experiment with correcting the
    224 effects of one bug and go on to learn about another.
    225 @end itemize
    226 
    227 You can use @value{GDBN} to debug programs written in C and C@t{++}.
    228 For more information, see @ref{Supported Languages,,Supported Languages}.
    229 For more information, see @ref{C,,C and C++}.
    230 
    231 Support for D is partial.  For information on D, see
    232 @ref{D,,D}.
    233 
    234 @cindex Modula-2
    235 Support for Modula-2 is partial.  For information on Modula-2, see
    236 @ref{Modula-2,,Modula-2}.
    237 
    238 Support for OpenCL C is partial.  For information on OpenCL C, see
    239 @ref{OpenCL C,,OpenCL C}.
    240 
    241 @cindex Pascal
    242 Debugging Pascal programs which use sets, subranges, file variables, or
    243 nested functions does not currently work.  @value{GDBN} does not support
    244 entering expressions, printing values, or similar features using Pascal
    245 syntax.
    246 
    247 @cindex Fortran
    248 @value{GDBN} can be used to debug programs written in Fortran, although
    249 it may be necessary to refer to some variables with a trailing
    250 underscore.
    251 
    252 @value{GDBN} can be used to debug programs written in Objective-C,
    253 using either the Apple/NeXT or the GNU Objective-C runtime.
    254 
    255 @menu
    256 * Free Software::               Freely redistributable software
    257 * Free Documentation::          Free Software Needs Free Documentation
    258 * Contributors::                Contributors to GDB
    259 @end menu
    260 
    261 @node Free Software
    262 @unnumberedsec Free Software
    263 
    264 @value{GDBN} is @dfn{free software}, protected by the @sc{gnu}
    265 General Public License
    266 (GPL).  The GPL gives you the freedom to copy or adapt a licensed
    267 program---but every person getting a copy also gets with it the
    268 freedom to modify that copy (which means that they must get access to
    269 the source code), and the freedom to distribute further copies.
    270 Typical software companies use copyrights to limit your freedoms; the
    271 Free Software Foundation uses the GPL to preserve these freedoms.
    272 
    273 Fundamentally, the General Public License is a license which says that
    274 you have these freedoms and that you cannot take these freedoms away
    275 from anyone else.
    276 
    277 @node Free Documentation
    278 @unnumberedsec Free Software Needs Free Documentation
    279 
    280 The biggest deficiency in the free software community today is not in
    281 the software---it is the lack of good free documentation that we can
    282 include with the free software.  Many of our most important
    283 programs do not come with free reference manuals and free introductory
    284 texts.  Documentation is an essential part of any software package;
    285 when an important free software package does not come with a free
    286 manual and a free tutorial, that is a major gap.  We have many such
    287 gaps today.
    288 
    289 Consider Perl, for instance.  The tutorial manuals that people
    290 normally use are non-free.  How did this come about?  Because the
    291 authors of those manuals published them with restrictive terms---no
    292 copying, no modification, source files not available---which exclude
    293 them from the free software world.
    294 
    295 That wasn't the first time this sort of thing happened, and it was far
    296 from the last.  Many times we have heard a GNU user eagerly describe a
    297 manual that he is writing, his intended contribution to the community,
    298 only to learn that he had ruined everything by signing a publication
    299 contract to make it non-free.
    300 
    301 Free documentation, like free software, is a matter of freedom, not
    302 price.  The problem with the non-free manual is not that publishers
    303 charge a price for printed copies---that in itself is fine.  (The Free
    304 Software Foundation sells printed copies of manuals, too.)  The
    305 problem is the restrictions on the use of the manual.  Free manuals
    306 are available in source code form, and give you permission to copy and
    307 modify.  Non-free manuals do not allow this.
    308 
    309 The criteria of freedom for a free manual are roughly the same as for
    310 free software.  Redistribution (including the normal kinds of
    311 commercial redistribution) must be permitted, so that the manual can
    312 accompany every copy of the program, both on-line and on paper.
    313 
    314 Permission for modification of the technical content is crucial too.
    315 When people modify the software, adding or changing features, if they
    316 are conscientious they will change the manual too---so they can
    317 provide accurate and clear documentation for the modified program.  A
    318 manual that leaves you no choice but to write a new manual to document
    319 a changed version of the program is not really available to our
    320 community.
    321 
    322 Some kinds of limits on the way modification is handled are
    323 acceptable.  For example, requirements to preserve the original
    324 author's copyright notice, the distribution terms, or the list of
    325 authors, are ok.  It is also no problem to require modified versions
    326 to include notice that they were modified.  Even entire sections that
    327 may not be deleted or changed are acceptable, as long as they deal
    328 with nontechnical topics (like this one).  These kinds of restrictions
    329 are acceptable because they don't obstruct the community's normal use
    330 of the manual.
    331 
    332 However, it must be possible to modify all the @emph{technical}
    333 content of the manual, and then distribute the result in all the usual
    334 media, through all the usual channels.  Otherwise, the restrictions
    335 obstruct the use of the manual, it is not free, and we need another
    336 manual to replace it.
    337 
    338 Please spread the word about this issue.  Our community continues to
    339 lose manuals to proprietary publishing.  If we spread the word that
    340 free software needs free reference manuals and free tutorials, perhaps
    341 the next person who wants to contribute by writing documentation will
    342 realize, before it is too late, that only free manuals contribute to
    343 the free software community.
    344 
    345 If you are writing documentation, please insist on publishing it under
    346 the GNU Free Documentation License or another free documentation
    347 license.  Remember that this decision requires your approval---you
    348 don't have to let the publisher decide.  Some commercial publishers
    349 will use a free license if you insist, but they will not propose the
    350 option; it is up to you to raise the issue and say firmly that this is
    351 what you want.  If the publisher you are dealing with refuses, please
    352 try other publishers.  If you're not sure whether a proposed license
    353 is free, write to @email{licensing@@gnu.org}.
    354 
    355 You can encourage commercial publishers to sell more free, copylefted
    356 manuals and tutorials by buying them, and particularly by buying
    357 copies from the publishers that paid for their writing or for major
    358 improvements.  Meanwhile, try to avoid buying non-free documentation
    359 at all.  Check the distribution terms of a manual before you buy it,
    360 and insist that whoever seeks your business must respect your freedom.
    361 Check the history of the book, and try to reward the publishers that
    362 have paid or pay the authors to work on it.
    363 
    364 The Free Software Foundation maintains a list of free documentation
    365 published by other publishers, at
    366 @url{http://www.fsf.org/doc/other-free-books.html}.
    367 
    368 @node Contributors
    369 @unnumberedsec Contributors to @value{GDBN}
    370 
    371 Richard Stallman was the original author of @value{GDBN}, and of many
    372 other @sc{gnu} programs.  Many others have contributed to its
    373 development.  This section attempts to credit major contributors.  One
    374 of the virtues of free software is that everyone is free to contribute
    375 to it; with regret, we cannot actually acknowledge everyone here.  The
    376 file @file{ChangeLog} in the @value{GDBN} distribution approximates a
    377 blow-by-blow account.
    378 
    379 Changes much prior to version 2.0 are lost in the mists of time.
    380 
    381 @quotation
    382 @emph{Plea:} Additions to this section are particularly welcome.  If you
    383 or your friends (or enemies, to be evenhanded) have been unfairly
    384 omitted from this list, we would like to add your names!
    385 @end quotation
    386 
    387 So that they may not regard their many labors as thankless, we
    388 particularly thank those who shepherded @value{GDBN} through major
    389 releases:
    390 Andrew Cagney (releases 6.3, 6.2, 6.1, 6.0, 5.3, 5.2, 5.1 and 5.0);
    391 Jim Blandy (release 4.18);
    392 Jason Molenda (release 4.17);
    393 Stan Shebs (release 4.14);
    394 Fred Fish (releases 4.16, 4.15, 4.13, 4.12, 4.11, 4.10, and 4.9);
    395 Stu Grossman and John Gilmore (releases 4.8, 4.7, 4.6, 4.5, and 4.4);
    396 John Gilmore (releases 4.3, 4.2, 4.1, 4.0, and 3.9);
    397 Jim Kingdon (releases 3.5, 3.4, and 3.3);
    398 and Randy Smith (releases 3.2, 3.1, and 3.0).
    399 
    400 Richard Stallman, assisted at various times by Peter TerMaat, Chris
    401 Hanson, and Richard Mlynarik, handled releases through 2.8.
    402 
    403 Michael Tiemann is the author of most of the @sc{gnu} C@t{++} support
    404 in @value{GDBN}, with significant additional contributions from Per
    405 Bothner and Daniel Berlin.  James Clark wrote the @sc{gnu} C@t{++}
    406 demangler.  Early work on C@t{++} was by Peter TerMaat (who also did
    407 much general update work leading to release 3.0).
    408 
    409 @value{GDBN} uses the BFD subroutine library to examine multiple
    410 object-file formats; BFD was a joint project of David V.
    411 Henkel-Wallace, Rich Pixley, Steve Chamberlain, and John Gilmore.
    412 
    413 David Johnson wrote the original COFF support; Pace Willison did
    414 the original support for encapsulated COFF.
    415 
    416 Brent Benson of Harris Computer Systems contributed DWARF 2 support.
    417 
    418 Adam de Boor and Bradley Davis contributed the ISI Optimum V support.
    419 Per Bothner, Noboyuki Hikichi, and Alessandro Forin contributed MIPS
    420 support.
    421 Jean-Daniel Fekete contributed Sun 386i support.
    422 Chris Hanson improved the HP9000 support.
    423 Noboyuki Hikichi and Tomoyuki Hasei contributed Sony/News OS 3 support.
    424 David Johnson contributed Encore Umax support.
    425 Jyrki Kuoppala contributed Altos 3068 support.
    426 Jeff Law contributed HP PA and SOM support.
    427 Keith Packard contributed NS32K support.
    428 Doug Rabson contributed Acorn Risc Machine support.
    429 Bob Rusk contributed Harris Nighthawk CX-UX support.
    430 Chris Smith contributed Convex support (and Fortran debugging).
    431 Jonathan Stone contributed Pyramid support.
    432 Michael Tiemann contributed SPARC support.
    433 Tim Tucker contributed support for the Gould NP1 and Gould Powernode.
    434 Pace Willison contributed Intel 386 support.
    435 Jay Vosburgh contributed Symmetry support.
    436 Marko Mlinar contributed OpenRISC 1000 support.
    437 
    438 Andreas Schwab contributed M68K @sc{gnu}/Linux support.
    439 
    440 Rich Schaefer and Peter Schauer helped with support of SunOS shared
    441 libraries.
    442 
    443 Jay Fenlason and Roland McGrath ensured that @value{GDBN} and GAS agree
    444 about several machine instruction sets.
    445 
    446 Patrick Duval, Ted Goldstein, Vikram Koka and Glenn Engel helped develop
    447 remote debugging.  Intel Corporation, Wind River Systems, AMD, and ARM
    448 contributed remote debugging modules for the i960, VxWorks, A29K UDI,
    449 and RDI targets, respectively.
    450 
    451 Brian Fox is the author of the readline libraries providing
    452 command-line editing and command history.
    453 
    454 Andrew Beers of SUNY Buffalo wrote the language-switching code, the
    455 Modula-2 support, and contributed the Languages chapter of this manual.
    456 
    457 Fred Fish wrote most of the support for Unix System Vr4.
    458 He also enhanced the command-completion support to cover C@t{++} overloaded
    459 symbols.
    460 
    461 Hitachi America (now Renesas America), Ltd. sponsored the support for
    462 H8/300, H8/500, and Super-H processors.
    463 
    464 NEC sponsored the support for the v850, Vr4xxx, and Vr5xxx processors.
    465 
    466 Mitsubishi (now Renesas) sponsored the support for D10V, D30V, and M32R/D
    467 processors.
    468 
    469 Toshiba sponsored the support for the TX39 Mips processor.
    470 
    471 Matsushita sponsored the support for the MN10200 and MN10300 processors.
    472 
    473 Fujitsu sponsored the support for SPARClite and FR30 processors.
    474 
    475 Kung Hsu, Jeff Law, and Rick Sladkey added support for hardware
    476 watchpoints.
    477 
    478 Michael Snyder added support for tracepoints.
    479 
    480 Stu Grossman wrote gdbserver.
    481 
    482 Jim Kingdon, Peter Schauer, Ian Taylor, and Stu Grossman made
    483 nearly innumerable bug fixes and cleanups throughout @value{GDBN}.
    484 
    485 The following people at the Hewlett-Packard Company contributed
    486 support for the PA-RISC 2.0 architecture, HP-UX 10.20, 10.30, and 11.0
    487 (narrow mode), HP's implementation of kernel threads, HP's aC@t{++}
    488 compiler, and the Text User Interface (nee Terminal User Interface):
    489 Ben Krepp, Richard Title, John Bishop, Susan Macchia, Kathy Mann,
    490 Satish Pai, India Paul, Steve Rehrauer, and Elena Zannoni.  Kim Haase
    491 provided HP-specific information in this manual.
    492 
    493 DJ Delorie ported @value{GDBN} to MS-DOS, for the DJGPP project.
    494 Robert Hoehne made significant contributions to the DJGPP port.
    495 
    496 Cygnus Solutions has sponsored @value{GDBN} maintenance and much of its
    497 development since 1991.  Cygnus engineers who have worked on @value{GDBN}
    498 fulltime include Mark Alexander, Jim Blandy, Per Bothner, Kevin
    499 Buettner, Edith Epstein, Chris Faylor, Fred Fish, Martin Hunt, Jim
    500 Ingham, John Gilmore, Stu Grossman, Kung Hsu, Jim Kingdon, John Metzler,
    501 Fernando Nasser, Geoffrey Noer, Dawn Perchik, Rich Pixley, Zdenek
    502 Radouch, Keith Seitz, Stan Shebs, David Taylor, and Elena Zannoni.  In
    503 addition, Dave Brolley, Ian Carmichael, Steve Chamberlain, Nick Clifton,
    504 JT Conklin, Stan Cox, DJ Delorie, Ulrich Drepper, Frank Eigler, Doug
    505 Evans, Sean Fagan, David Henkel-Wallace, Richard Henderson, Jeff
    506 Holcomb, Jeff Law, Jim Lemke, Tom Lord, Bob Manson, Michael Meissner,
    507 Jason Merrill, Catherine Moore, Drew Moseley, Ken Raeburn, Gavin
    508 Romig-Koch, Rob Savoye, Jamie Smith, Mike Stump, Ian Taylor, Angela
    509 Thomas, Michael Tiemann, Tom Tromey, Ron Unrau, Jim Wilson, and David
    510 Zuhn have made contributions both large and small.
    511 
    512 Andrew Cagney, Fernando Nasser, and Elena Zannoni, while working for
    513 Cygnus Solutions, implemented the original @sc{gdb/mi} interface.
    514 
    515 Jim Blandy added support for preprocessor macros, while working for Red
    516 Hat.
    517 
    518 Andrew Cagney designed @value{GDBN}'s architecture vector.  Many
    519 people including Andrew Cagney, Stephane Carrez, Randolph Chung, Nick
    520 Duffek, Richard Henderson, Mark Kettenis, Grace Sainsbury, Kei
    521 Sakamoto, Yoshinori Sato, Michael Snyder, Andreas Schwab, Jason
    522 Thorpe, Corinna Vinschen, Ulrich Weigand, and Elena Zannoni, helped
    523 with the migration of old architectures to this new framework.
    524 
    525 Andrew Cagney completely re-designed and re-implemented @value{GDBN}'s
    526 unwinder framework, this consisting of a fresh new design featuring
    527 frame IDs, independent frame sniffers, and the sentinel frame.  Mark
    528 Kettenis implemented the @sc{dwarf 2} unwinder, Jeff Johnston the
    529 libunwind unwinder, and Andrew Cagney the dummy, sentinel, tramp, and
    530 trad unwinders.  The architecture-specific changes, each involving a
    531 complete rewrite of the architecture's frame code, were carried out by
    532 Jim Blandy, Joel Brobecker, Kevin Buettner, Andrew Cagney, Stephane
    533 Carrez, Randolph Chung, Orjan Friberg, Richard Henderson, Daniel
    534 Jacobowitz, Jeff Johnston, Mark Kettenis, Theodore A. Roth, Kei
    535 Sakamoto, Yoshinori Sato, Michael Snyder, Corinna Vinschen, and Ulrich
    536 Weigand.
    537 
    538 Christian Zankel, Ross Morley, Bob Wilson, and Maxim Grigoriev from
    539 Tensilica, Inc.@: contributed support for Xtensa processors.  Others
    540 who have worked on the Xtensa port of @value{GDBN} in the past include
    541 Steve Tjiang, John Newlin, and Scott Foehner.
    542 
    543 Michael Eager and staff of Xilinx, Inc., contributed support for the
    544 Xilinx MicroBlaze architecture.
    545 
    546 Initial support for the FreeBSD/mips target and native configuration
    547 was developed by SRI International and the University of Cambridge
    548 Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237
    549 ("CTSRD"), as part of the DARPA CRASH research programme.
    550 
    551 Initial support for the FreeBSD/riscv target and native configuration
    552 was developed by SRI International and the University of Cambridge
    553 Computer Laboratory (Department of Computer Science and Technology)
    554 under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the DARPA
    555 SSITH research programme.
    556 
    557 The original port to the OpenRISC 1000 is believed to be due to
    558 Alessandro Forin and Per Bothner.  More recent ports have been the work
    559 of Jeremy Bennett, Franck Jullien, Stefan Wallentowitz and
    560 Stafford Horne.
    561 
    562 Weimin Pan, David Faust and Jose E. Marchesi contributed support for
    563 the Linux kernel BPF virtual architecture.  This work was sponsored by
    564 Oracle.
    565 
    566 @node Sample Session
    567 @chapter A Sample @value{GDBN} Session
    568 
    569 You can use this manual at your leisure to read all about @value{GDBN}.
    570 However, a handful of commands are enough to get started using the
    571 debugger.  This chapter illustrates those commands.
    572 
    573 @iftex
    574 In this sample session, we emphasize user input like this: @b{input},
    575 to make it easier to pick out from the surrounding output.
    576 @end iftex
    577 
    578 @c FIXME: this example may not be appropriate for some configs, where
    579 @c FIXME...primary interest is in remote use.
    580 
    581 One of the preliminary versions of @sc{gnu} @code{m4} (a generic macro
    582 processor) exhibits the following bug: sometimes, when we change its
    583 quote strings from the default, the commands used to capture one macro
    584 definition within another stop working.  In the following short @code{m4}
    585 session, we define a macro @code{foo} which expands to @code{0000}; we
    586 then use the @code{m4} built-in @code{defn} to define @code{bar} as the
    587 same thing.  However, when we change the open quote string to
    588 @code{<QUOTE>} and the close quote string to @code{<UNQUOTE>}, the same
    589 procedure fails to define a new synonym @code{baz}:
    590 
    591 @smallexample
    592 $ @b{cd gnu/m4}
    593 $ @b{./m4}
    594 @b{define(foo,0000)}
    595 
    596 @b{foo}
    597 0000
    598 @b{define(bar,defn(`foo'))}
    599 
    600 @b{bar}
    601 0000
    602 @b{changequote(<QUOTE>,<UNQUOTE>)}
    603 
    604 @b{define(baz,defn(<QUOTE>foo<UNQUOTE>))}
    605 @b{baz}
    606 @b{Ctrl-d}
    607 m4: End of input: 0: fatal error: EOF in string
    608 @end smallexample
    609 
    610 @noindent
    611 Let us use @value{GDBN} to try to see what is going on.
    612 
    613 @smallexample
    614 $ @b{@value{GDBP} m4}
    615 @c FIXME: this falsifies the exact text played out, to permit smallbook
    616 @c FIXME... format to come out better.
    617 @value{GDBN} is free software and you are welcome to distribute copies
    618  of it under certain conditions; type "show copying" to see
    619  the conditions.
    620 There is absolutely no warranty for @value{GDBN}; type "show warranty"
    621  for details.
    622 
    623 @value{GDBN} @value{GDBVN}, Copyright 1999 Free Software Foundation, Inc...
    624 (@value{GDBP})
    625 @end smallexample
    626 
    627 @noindent
    628 @value{GDBN} reads only enough symbol data to know where to find the
    629 rest when needed; as a result, the first prompt comes up very quickly.
    630 We now tell @value{GDBN} to use a narrower display width than usual, so
    631 that examples fit in this manual.
    632 
    633 @smallexample
    634 (@value{GDBP}) @b{set width 70}
    635 @end smallexample
    636 
    637 @noindent
    638 We need to see how the @code{m4} built-in @code{changequote} works.
    639 Having looked at the source, we know the relevant subroutine is
    640 @code{m4_changequote}, so we set a breakpoint there with the @value{GDBN}
    641 @code{break} command.
    642 
    643 @smallexample
    644 (@value{GDBP}) @b{break m4_changequote}
    645 Breakpoint 1 at 0x62f4: file builtin.c, line 879.
    646 @end smallexample
    647 
    648 @noindent
    649 Using the @code{run} command, we start @code{m4} running under @value{GDBN}
    650 control; as long as control does not reach the @code{m4_changequote}
    651 subroutine, the program runs as usual:
    652 
    653 @smallexample
    654 (@value{GDBP}) @b{run}
    655 Starting program: /work/Editorial/gdb/gnu/m4/m4
    656 @b{define(foo,0000)}
    657 
    658 @b{foo}
    659 0000
    660 @end smallexample
    661 
    662 @noindent
    663 To trigger the breakpoint, we call @code{changequote}.  @value{GDBN}
    664 suspends execution of @code{m4}, displaying information about the
    665 context where it stops.
    666 
    667 @smallexample
    668 @b{changequote(<QUOTE>,<UNQUOTE>)}
    669 
    670 Breakpoint 1, m4_changequote (argc=3, argv=0x33c70)
    671     at builtin.c:879
    672 879         if (bad_argc(TOKEN_DATA_TEXT(argv[0]),argc,1,3))
    673 @end smallexample
    674 
    675 @noindent
    676 Now we use the command @code{n} (@code{next}) to advance execution to
    677 the next line of the current function.
    678 
    679 @smallexample
    680 (@value{GDBP}) @b{n}
    681 882         set_quotes((argc >= 2) ? TOKEN_DATA_TEXT(argv[1])\
    682  : nil,
    683 @end smallexample
    684 
    685 @noindent
    686 @code{set_quotes} looks like a promising subroutine.  We can go into it
    687 by using the command @code{s} (@code{step}) instead of @code{next}.
    688 @code{step} goes to the next line to be executed in @emph{any}
    689 subroutine, so it steps into @code{set_quotes}.
    690 
    691 @smallexample
    692 (@value{GDBP}) @b{s}
    693 set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
    694     at input.c:530
    695 530         if (lquote != def_lquote)
    696 @end smallexample
    697 
    698 @noindent
    699 The display that shows the subroutine where @code{m4} is now
    700 suspended (and its arguments) is called a stack frame display.  It
    701 shows a summary of the stack.  We can use the @code{backtrace}
    702 command (which can also be spelled @code{bt}), to see where we are
    703 in the stack as a whole: the @code{backtrace} command displays a
    704 stack frame for each active subroutine.
    705 
    706 @smallexample
    707 (@value{GDBP}) @b{bt}
    708 #0  set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
    709     at input.c:530
    710 #1  0x6344 in m4_changequote (argc=3, argv=0x33c70)
    711     at builtin.c:882
    712 #2  0x8174 in expand_macro (sym=0x33320) at macro.c:242
    713 #3  0x7a88 in expand_token (obs=0x0, t=209696, td=0xf7fffa30)
    714     at macro.c:71
    715 #4  0x79dc in expand_input () at macro.c:40
    716 #5  0x2930 in main (argc=0, argv=0xf7fffb20) at m4.c:195
    717 @end smallexample
    718 
    719 @noindent
    720 We step through a few more lines to see what happens.  The first two
    721 times, we can use @samp{s}; the next two times we use @code{n} to avoid
    722 falling into the @code{xstrdup} subroutine.
    723 
    724 @smallexample
    725 (@value{GDBP}) @b{s}
    726 0x3b5c  532         if (rquote != def_rquote)
    727 (@value{GDBP}) @b{s}
    728 0x3b80  535         lquote = (lq == nil || *lq == '\0') ?  \
    729 def_lquote : xstrdup(lq);
    730 (@value{GDBP}) @b{n}
    731 536         rquote = (rq == nil || *rq == '\0') ? def_rquote\
    732  : xstrdup(rq);
    733 (@value{GDBP}) @b{n}
    734 538         len_lquote = strlen(rquote);
    735 @end smallexample
    736 
    737 @noindent
    738 The last line displayed looks a little odd; we can examine the variables
    739 @code{lquote} and @code{rquote} to see if they are in fact the new left
    740 and right quotes we specified.  We use the command @code{p}
    741 (@code{print}) to see their values.
    742 
    743 @smallexample
    744 (@value{GDBP}) @b{p lquote}
    745 $1 = 0x35d40 "<QUOTE>"
    746 (@value{GDBP}) @b{p rquote}
    747 $2 = 0x35d50 "<UNQUOTE>"
    748 @end smallexample
    749 
    750 @noindent
    751 @code{lquote} and @code{rquote} are indeed the new left and right quotes.
    752 To look at some context, we can display ten lines of source
    753 surrounding the current line with the @code{l} (@code{list}) command.
    754 
    755 @smallexample
    756 (@value{GDBP}) @b{l}
    757 533             xfree(rquote);
    758 534
    759 535         lquote = (lq == nil || *lq == '\0') ? def_lquote\
    760  : xstrdup (lq);
    761 536         rquote = (rq == nil || *rq == '\0') ? def_rquote\
    762  : xstrdup (rq);
    763 537
    764 538         len_lquote = strlen(rquote);
    765 539         len_rquote = strlen(lquote);
    766 540     @}
    767 541
    768 542     void
    769 @end smallexample
    770 
    771 @noindent
    772 Let us step past the two lines that set @code{len_lquote} and
    773 @code{len_rquote}, and then examine the values of those variables.
    774 
    775 @smallexample
    776 (@value{GDBP}) @b{n}
    777 539         len_rquote = strlen(lquote);
    778 (@value{GDBP}) @b{n}
    779 540     @}
    780 (@value{GDBP}) @b{p len_lquote}
    781 $3 = 9
    782 (@value{GDBP}) @b{p len_rquote}
    783 $4 = 7
    784 @end smallexample
    785 
    786 @noindent
    787 That certainly looks wrong, assuming @code{len_lquote} and
    788 @code{len_rquote} are meant to be the lengths of @code{lquote} and
    789 @code{rquote} respectively.  We can set them to better values using
    790 the @code{p} command, since it can print the value of
    791 any expression---and that expression can include subroutine calls and
    792 assignments.
    793 
    794 @smallexample
    795 (@value{GDBP}) @b{p len_lquote=strlen(lquote)}
    796 $5 = 7
    797 (@value{GDBP}) @b{p len_rquote=strlen(rquote)}
    798 $6 = 9
    799 @end smallexample
    800 
    801 @noindent
    802 Is that enough to fix the problem of using the new quotes with the
    803 @code{m4} built-in @code{defn}?  We can allow @code{m4} to continue
    804 executing with the @code{c} (@code{continue}) command, and then try the
    805 example that caused trouble initially:
    806 
    807 @smallexample
    808 (@value{GDBP}) @b{c}
    809 Continuing.
    810 
    811 @b{define(baz,defn(<QUOTE>foo<UNQUOTE>))}
    812 
    813 baz
    814 0000
    815 @end smallexample
    816 
    817 @noindent
    818 Success!  The new quotes now work just as well as the default ones.  The
    819 problem seems to have been just the two typos defining the wrong
    820 lengths.  We allow @code{m4} exit by giving it an EOF as input:
    821 
    822 @smallexample
    823 @b{Ctrl-d}
    824 Program exited normally.
    825 @end smallexample
    826 
    827 @noindent
    828 The message @samp{Program exited normally.} is from @value{GDBN}; it
    829 indicates @code{m4} has finished executing.  We can end our @value{GDBN}
    830 session with the @value{GDBN} @code{quit} command.
    831 
    832 @smallexample
    833 (@value{GDBP}) @b{quit}
    834 @end smallexample
    835 
    836 @node Invocation
    837 @chapter Getting In and Out of @value{GDBN}
    838 
    839 This chapter discusses how to start @value{GDBN}, and how to get out of it.
    840 The essentials are:
    841 @itemize @bullet
    842 @item
    843 type @samp{@value{GDBP}} to start @value{GDBN}.
    844 @item
    845 type @kbd{quit}, @kbd{exit} or @kbd{Ctrl-d} to exit.
    846 @end itemize
    847 
    848 @menu
    849 * Invoking GDB::                How to start @value{GDBN}
    850 * Quitting GDB::                How to quit @value{GDBN}
    851 * Shell Commands::              How to use shell commands inside @value{GDBN}
    852 * Logging Output::              How to log @value{GDBN}'s output to a file
    853 @end menu
    854 
    855 @node Invoking GDB
    856 @section Invoking @value{GDBN}
    857 
    858 Invoke @value{GDBN} by running the program @code{@value{GDBP}}.  Once started,
    859 @value{GDBN} reads commands from the terminal until you tell it to exit.
    860 
    861 You can also run @code{@value{GDBP}} with a variety of arguments and options,
    862 to specify more of your debugging environment at the outset.
    863 
    864 The command-line options described here are designed
    865 to cover a variety of situations; in some environments, some of these
    866 options may effectively be unavailable.
    867 
    868 The most usual way to start @value{GDBN} is with one argument,
    869 specifying an executable program:
    870 
    871 @smallexample
    872 @value{GDBP} @var{program}
    873 @end smallexample
    874 
    875 @noindent
    876 You can also start with both an executable program and a core file
    877 specified:
    878 
    879 @smallexample
    880 @value{GDBP} @var{program} @var{core}
    881 @end smallexample
    882 
    883 You can, instead, specify a process ID as a second argument or use option
    884 @code{-p}, if you want to debug a running process:
    885 
    886 @smallexample
    887 @value{GDBP} @var{program} 1234
    888 @value{GDBP} -p 1234
    889 @end smallexample
    890 
    891 @noindent
    892 would attach @value{GDBN} to process @code{1234}.  With option @option{-p} you
    893 can omit the @var{program} filename.
    894 
    895 Taking advantage of the second command-line argument requires a fairly
    896 complete operating system; when you use @value{GDBN} as a remote
    897 debugger attached to a bare board, there may not be any notion of
    898 ``process'', and there is often no way to get a core dump.  @value{GDBN}
    899 will warn you if it is unable to attach or to read core dumps.
    900 
    901 You can optionally have @code{@value{GDBP}} pass any arguments after the
    902 executable file to the inferior using @code{--args}.  This option stops
    903 option processing.
    904 @smallexample
    905 @value{GDBP} --args gcc -O2 -c foo.c
    906 @end smallexample
    907 This will cause @code{@value{GDBP}} to debug @code{gcc}, and to set
    908 @code{gcc}'s command-line arguments (@pxref{Arguments}) to @samp{-O2 -c foo.c}.
    909 
    910 You can run @code{@value{GDBP}} without printing the front material, which describes
    911 @value{GDBN}'s non-warranty, by specifying @code{--silent}
    912 (or @code{-q}/@code{--quiet}):
    913 
    914 @smallexample
    915 @value{GDBP} --silent
    916 @end smallexample
    917 
    918 @noindent
    919 You can further control how @value{GDBN} starts up by using command-line
    920 options.  @value{GDBN} itself can remind you of the options available.
    921 
    922 @noindent
    923 Type
    924 
    925 @smallexample
    926 @value{GDBP} -help
    927 @end smallexample
    928 
    929 @noindent
    930 to display all available options and briefly describe their use
    931 (@samp{@value{GDBP} -h} is a shorter equivalent).
    932 
    933 All options and command line arguments you give are processed
    934 in sequential order.  The order makes a difference when the
    935 @samp{-x} option is used.
    936 
    937 
    938 @menu
    939 * File Options::                Choosing files
    940 * Mode Options::                Choosing modes
    941 * Startup::                     What @value{GDBN} does during startup
    942 * Initialization Files::        Initialization Files
    943 @end menu
    944 
    945 @node File Options
    946 @subsection Choosing Files
    947 
    948 When @value{GDBN} starts, it reads any arguments other than options as
    949 specifying an executable file and core file (or process ID).  This is
    950 the same as if the arguments were specified by the @samp{-se} and
    951 @samp{-c} (or @samp{-p}) options respectively.  (@value{GDBN} reads the
    952 first argument that does not have an associated option flag as
    953 equivalent to the @samp{-se} option followed by that argument; and the
    954 second argument that does not have an associated option flag, if any, as
    955 equivalent to the @samp{-c}/@samp{-p} option followed by that argument.)
    956 If the second argument begins with a decimal digit, @value{GDBN} will
    957 first attempt to attach to it as a process, and if that fails, attempt
    958 to open it as a corefile.  If you have a corefile whose name begins with
    959 a digit, you can prevent @value{GDBN} from treating it as a pid by
    960 prefixing it with @file{./}, e.g.@: @file{./12345}.
    961 
    962 If @value{GDBN} has not been configured to included core file support,
    963 such as for most embedded targets, then it will complain about a second
    964 argument and ignore it.
    965 
    966 For the @samp{-s}, @samp{-e}, and @samp{-se} options, and their long
    967 form equivalents, the method used to search the file system for the
    968 symbol and/or executable file is the same as that used by the
    969 @code{file} command.  @xref{Files, ,file}.
    970 
    971 Many options have both long and short forms; both are shown in the
    972 following list.  @value{GDBN} also recognizes the long forms if you truncate
    973 them, so long as enough of the option is present to be unambiguous.
    974 (If you prefer, you can flag option arguments with @samp{--} rather
    975 than @samp{-}, though we illustrate the more usual convention.)
    976 
    977 @c NOTE: the @cindex entries here use double dashes ON PURPOSE.  This
    978 @c way, both those who look for -foo and --foo in the index, will find
    979 @c it.
    980 
    981 @table @code
    982 @item -symbols @var{file}
    983 @itemx -s @var{file}
    984 @cindex @code{--symbols}
    985 @cindex @code{-s}
    986 Read symbol table from file @var{file}.
    987 
    988 @item -exec @var{file}
    989 @itemx -e @var{file}
    990 @cindex @code{--exec}
    991 @cindex @code{-e}
    992 Use file @var{file} as the executable file to execute when appropriate,
    993 and for examining pure data in conjunction with a core dump.
    994 
    995 @item -se @var{file}
    996 @cindex @code{--se}
    997 Read symbol table from file @var{file} and use it as the executable
    998 file.
    999 
   1000 @item -core @var{file}
   1001 @itemx -c @var{file}
   1002 @cindex @code{--core}
   1003 @cindex @code{-c}
   1004 Use file @var{file} as a core dump to examine.
   1005 
   1006 @item -pid @var{number}
   1007 @itemx -p @var{number}
   1008 @cindex @code{--pid}
   1009 @cindex @code{-p}
   1010 Connect to process ID @var{number}, as with the @code{attach} command.
   1011 
   1012 @item -command @var{file}
   1013 @itemx -x @var{file}
   1014 @cindex @code{--command}
   1015 @cindex @code{-x}
   1016 Execute commands from file @var{file}.  The contents of this file is
   1017 evaluated exactly as the @code{source} command would.
   1018 @xref{Command Files,, Command files}.
   1019 
   1020 @item -eval-command @var{command}
   1021 @itemx -ex @var{command}
   1022 @cindex @code{--eval-command}
   1023 @cindex @code{-ex}
   1024 Execute a single @value{GDBN} command.
   1025 
   1026 This option may be used multiple times to call multiple commands.  It may
   1027 also be interleaved with @samp{-command} as required.
   1028 
   1029 @smallexample
   1030 @value{GDBP} -ex 'target sim' -ex 'load' \
   1031    -x setbreakpoints -ex 'run' a.out
   1032 @end smallexample
   1033 
   1034 @item -init-command @var{file}
   1035 @itemx -ix @var{file}
   1036 @cindex @code{--init-command}
   1037 @cindex @code{-ix}
   1038 Execute commands from file @var{file} before loading the inferior (but
   1039 after loading gdbinit files).
   1040 @xref{Startup}.
   1041 
   1042 @item -init-eval-command @var{command}
   1043 @itemx -iex @var{command}
   1044 @cindex @code{--init-eval-command}
   1045 @cindex @code{-iex}
   1046 Execute a single @value{GDBN} command before loading the inferior (but
   1047 after loading gdbinit files).
   1048 @xref{Startup}.
   1049 
   1050 @item -early-init-command @var{file}
   1051 @itemx -eix @var{file}
   1052 @cindex @code{--early-init-command}
   1053 @cindex @code{-eix}
   1054 Execute commands from @var{file} very early in the initialization
   1055 process, before any output is produced.  @xref{Startup}.
   1056 
   1057 @item -early-init-eval-command @var{command}
   1058 @itemx -eiex @var{command}
   1059 @cindex @code{--early-init-eval-command}
   1060 @cindex @code{-eiex}
   1061 Execute a single @value{GDBN} command very early in the initialization
   1062 process, before any output is produced.
   1063 
   1064 @item -directory @var{directory}
   1065 @itemx -d @var{directory}
   1066 @cindex @code{--directory}
   1067 @cindex @code{-d}
   1068 Add @var{directory} to the path to search for source and script files.
   1069 
   1070 @item -r
   1071 @itemx -readnow
   1072 @cindex @code{--readnow}
   1073 @cindex @code{-r}
   1074 Read each symbol file's entire symbol table immediately, rather than
   1075 the default, which is to read it incrementally as it is needed.
   1076 This makes startup slower, but makes future operations faster.
   1077 
   1078 @item --readnever
   1079 @anchor{--readnever}
   1080 @cindex @code{--readnever}, command-line option
   1081 Do not read each symbol file's symbolic debug information.  This makes
   1082 startup faster but at the expense of not being able to perform
   1083 symbolic debugging.  DWARF unwind information is also not read,
   1084 meaning backtraces may become incomplete or inaccurate.  One use of
   1085 this is when a user simply wants to do the following sequence: attach,
   1086 dump core, detach.  Loading the debugging information in this case is
   1087 an unnecessary cause of delay.
   1088 @end table
   1089 
   1090 @node Mode Options
   1091 @subsection Choosing Modes
   1092 
   1093 You can run @value{GDBN} in various alternative modes---for example, in
   1094 batch mode or quiet mode.
   1095 
   1096 @table @code
   1097 @anchor{-nx}
   1098 @item -nx
   1099 @itemx -n
   1100 @cindex @code{--nx}
   1101 @cindex @code{-n}
   1102 Do not execute commands found in any initialization files
   1103 (@pxref{Initialization Files}).
   1104 
   1105 @anchor{-nh}
   1106 @item -nh
   1107 @cindex @code{--nh}
   1108 Do not execute commands found in any home directory initialization
   1109 file (@pxref{Initialization Files,,Home directory initialization
   1110 file}).  The system wide and current directory initialization files
   1111 are still loaded.
   1112 
   1113 @item -quiet
   1114 @itemx -silent
   1115 @itemx -q
   1116 @cindex @code{--quiet}
   1117 @cindex @code{--silent}
   1118 @cindex @code{-q}
   1119 ``Quiet''.  Do not print the introductory and copyright messages.  These
   1120 messages are also suppressed in batch mode.
   1121 
   1122 @kindex set startup-quietly
   1123 @kindex show startup-quietly
   1124 This can also be enabled using @code{set startup-quietly on}.  The
   1125 default is @code{off}.  Use @code{show startup-quietly} to see the
   1126 current setting.  Place @code{set startup-quietly on} into your early
   1127 initialization file (@pxref{Initialization Files,,Initialization
   1128 Files}) to have future @value{GDBN} sessions startup quietly.
   1129 
   1130 @item -batch
   1131 @cindex @code{--batch}
   1132 Run in batch mode.  Exit with status @code{0} after processing all the
   1133 command files specified with @samp{-x} (and all commands from
   1134 initialization files, if not inhibited with @samp{-n}).  Exit with
   1135 nonzero status if an error occurs in executing the @value{GDBN} commands
   1136 in the command files.  Batch mode also disables pagination, sets unlimited
   1137 terminal width and height @pxref{Screen Size}, and acts as if @kbd{set confirm
   1138 off} were in effect (@pxref{Messages/Warnings}).
   1139 
   1140 Batch mode may be useful for running @value{GDBN} as a filter, for
   1141 example to download and run a program on another computer; in order to
   1142 make this more useful, the message
   1143 
   1144 @smallexample
   1145 Program exited normally.
   1146 @end smallexample
   1147 
   1148 @noindent
   1149 (which is ordinarily issued whenever a program running under
   1150 @value{GDBN} control terminates) is not issued when running in batch
   1151 mode.
   1152 
   1153 @item -batch-silent
   1154 @cindex @code{--batch-silent}
   1155 Run in batch mode exactly like @samp{-batch}, but totally silently.  All
   1156 @value{GDBN} output to @code{stdout} is prevented (@code{stderr} is
   1157 unaffected).  This is much quieter than @samp{-silent} and would be useless
   1158 for an interactive session.
   1159 
   1160 This is particularly useful when using targets that give @samp{Loading section}
   1161 messages, for example.
   1162 
   1163 Note that targets that give their output via @value{GDBN}, as opposed to
   1164 writing directly to @code{stdout}, will also be made silent.
   1165 
   1166 @item -return-child-result
   1167 @cindex @code{--return-child-result}
   1168 The return code from @value{GDBN} will be the return code from the child
   1169 process (the process being debugged), with the following exceptions:
   1170 
   1171 @itemize @bullet
   1172 @item
   1173 @value{GDBN} exits abnormally.  E.g., due to an incorrect argument or an
   1174 internal error.  In this case the exit code is the same as it would have been
   1175 without @samp{-return-child-result}.
   1176 @item
   1177 The user quits with an explicit value.  E.g., @samp{quit 1}.
   1178 @item
   1179 The child process never runs, or is not allowed to terminate, in which case
   1180 the exit code will be -1.
   1181 @end itemize
   1182 
   1183 This option is useful in conjunction with @samp{-batch} or @samp{-batch-silent},
   1184 when @value{GDBN} is being used as a remote program loader or simulator
   1185 interface.
   1186 
   1187 @item -nowindows
   1188 @itemx -nw
   1189 @cindex @code{--nowindows}
   1190 @cindex @code{-nw}
   1191 ``No windows''.  If @value{GDBN} comes with a graphical user interface
   1192 (GUI) built in, then this option tells @value{GDBN} to only use the command-line
   1193 interface.  If no GUI is available, this option has no effect.
   1194 
   1195 @item -windows
   1196 @itemx -w
   1197 @cindex @code{--windows}
   1198 @cindex @code{-w}
   1199 If @value{GDBN} includes a GUI, then this option requires it to be
   1200 used if possible.
   1201 
   1202 @item -cd @var{directory}
   1203 @cindex @code{--cd}
   1204 Run @value{GDBN} using @var{directory} as its working directory,
   1205 instead of the current directory.
   1206 
   1207 @item -data-directory @var{directory}
   1208 @itemx -D @var{directory}
   1209 @cindex @code{--data-directory}
   1210 @cindex @code{-D}
   1211 Run @value{GDBN} using @var{directory} as its data directory.
   1212 The data directory is where @value{GDBN} searches for its
   1213 auxiliary files.  @xref{Data Files}.
   1214 
   1215 @item -fullname
   1216 @itemx -f
   1217 @cindex @code{--fullname}
   1218 @cindex @code{-f}
   1219 @sc{gnu} Emacs sets this option when it runs @value{GDBN} as a
   1220 subprocess.  It tells @value{GDBN} to output the full file name and line
   1221 number in a standard, recognizable fashion each time a stack frame is
   1222 displayed (which includes each time your program stops).  This
   1223 recognizable format looks like two @samp{\032} characters, followed by
   1224 the file name, line number and character position separated by colons,
   1225 and a newline.  The Emacs-to-@value{GDBN} interface program uses the two
   1226 @samp{\032} characters as a signal to display the source code for the
   1227 frame.
   1228 
   1229 @item -annotate @var{level}
   1230 @cindex @code{--annotate}
   1231 This option sets the @dfn{annotation level} inside @value{GDBN}.  Its
   1232 effect is identical to using @samp{set annotate @var{level}}
   1233 (@pxref{Annotations}).  The annotation @var{level} controls how much
   1234 information @value{GDBN} prints together with its prompt, values of
   1235 expressions, source lines, and other types of output.  Level 0 is the
   1236 normal, level 1 is for use when @value{GDBN} is run as a subprocess of
   1237 @sc{gnu} Emacs, level 3 is the maximum annotation suitable for programs
   1238 that control @value{GDBN}, and level 2 has been deprecated.
   1239 
   1240 The annotation mechanism has largely been superseded by @sc{gdb/mi}
   1241 (@pxref{GDB/MI}).
   1242 
   1243 @item --args
   1244 @cindex @code{--args}
   1245 Change interpretation of command line so that arguments following the
   1246 executable file are passed as command line arguments to the inferior.
   1247 This option stops option processing.
   1248 
   1249 @item -baud @var{bps}
   1250 @itemx -b @var{bps}
   1251 @cindex @code{--baud}
   1252 @cindex @code{-b}
   1253 Set the line speed (baud rate or bits per second) of any serial
   1254 interface used by @value{GDBN} for remote debugging.
   1255 
   1256 @item -l @var{timeout}
   1257 @cindex @code{-l}
   1258 Set the timeout (in seconds) of any communication used by @value{GDBN}
   1259 for remote debugging.
   1260 
   1261 @item -tty @var{device}
   1262 @itemx -t @var{device}
   1263 @cindex @code{--tty}
   1264 @cindex @code{-t}
   1265 Run using @var{device} for your program's standard input and output.
   1266 @c FIXME: kingdon thinks there is more to -tty.  Investigate.
   1267 
   1268 @c resolve the situation of these eventually
   1269 @item -tui
   1270 @cindex @code{--tui}
   1271 Activate the @dfn{Text User Interface} when starting.  The Text User
   1272 Interface manages several text windows on the terminal, showing
   1273 source, assembly, registers and @value{GDBN} command outputs
   1274 (@pxref{TUI, ,@value{GDBN} Text User Interface}).  Do not use this
   1275 option if you run @value{GDBN} from Emacs (@pxref{Emacs, ,
   1276 Using @value{GDBN} under @sc{gnu} Emacs}).
   1277 
   1278 @item -interpreter @var{interp}
   1279 @cindex @code{--interpreter}
   1280 Use the interpreter @var{interp} for interface with the controlling
   1281 program or device.  This option is meant to be set by programs which
   1282 communicate with @value{GDBN} using it as a back end.
   1283 @xref{Interpreters, , Command Interpreters}.
   1284 
   1285 @samp{--interpreter=mi} (or @samp{--interpreter=mi3}) causes
   1286 @value{GDBN} to use the @dfn{@sc{gdb/mi} interface} version 3 (@pxref{GDB/MI, ,
   1287 The @sc{gdb/mi} Interface}) included since @value{GDBN} version 9.1.  @sc{gdb/mi}
   1288 version 2 (@code{mi2}), included in @value{GDBN} 6.0 and version 1 (@code{mi1}),
   1289 included in @value{GDBN} 5.3, are also available.  Earlier @sc{gdb/mi}
   1290 interfaces are no longer supported.
   1291 
   1292 @item -write
   1293 @cindex @code{--write}
   1294 Open the executable and core files for both reading and writing.  This
   1295 is equivalent to the @samp{set write on} command inside @value{GDBN}
   1296 (@pxref{Patching}).
   1297 
   1298 @item -statistics
   1299 @cindex @code{--statistics}
   1300 This option causes @value{GDBN} to print statistics about time and
   1301 memory usage after it completes each command and returns to the prompt.
   1302 
   1303 @item -version
   1304 @cindex @code{--version}
   1305 This option causes @value{GDBN} to print its version number and
   1306 no-warranty blurb, and exit.
   1307 
   1308 @item -configuration
   1309 @cindex @code{--configuration}
   1310 This option causes @value{GDBN} to print details about its build-time
   1311 configuration parameters, and then exit.  These details can be
   1312 important when reporting @value{GDBN} bugs (@pxref{GDB Bugs}).
   1313 
   1314 @end table
   1315 
   1316 @node Startup
   1317 @subsection What @value{GDBN} Does During Startup
   1318 @cindex @value{GDBN} startup
   1319 
   1320 Here's the description of what @value{GDBN} does during session startup:
   1321 
   1322 @enumerate
   1323 
   1324 @item
   1325 Performs minimal setup required to initialize basic internal state.
   1326 
   1327 @item
   1328 @cindex early initialization file
   1329 Reads commands from the early initialization file (if any) in your
   1330 home directory.  Only a restricted set of commands can be placed into
   1331 an early initialization file, see @ref{Initialization Files}, for
   1332 details.
   1333 
   1334 @item
   1335 Executes commands and command files specified by the @samp{-eiex} and
   1336 @samp{-eix} command line options in their specified order.  Only a
   1337 restricted set of commands can be used with @samp{-eiex} and
   1338 @samp{eix}, see @ref{Initialization Files}, for details.
   1339 
   1340 @item
   1341 Sets up the command interpreter as specified by the command line
   1342 (@pxref{Mode Options, interpreter}).
   1343 
   1344 @item
   1345 @cindex init file
   1346 Reads the system wide initialization file and the files from the
   1347 system wide initialization directory, @pxref{System Wide Init Files}.
   1348 
   1349 @item
   1350 Reads the initialization file (if any) in your home directory and
   1351 executes all the commands in that file, @pxref{Home Directory Init
   1352 File}.
   1353 
   1354 @anchor{Option -init-eval-command}
   1355 @item
   1356 Executes commands and command files specified by the @samp{-iex} and
   1357 @samp{-ix} options in their specified order.  Usually you should use the
   1358 @samp{-ex} and @samp{-x} options instead, but this way you can apply
   1359 settings before @value{GDBN} init files get executed and before inferior
   1360 gets loaded.
   1361 
   1362 @item
   1363 Processes command line options and operands.
   1364 
   1365 @item
   1366 Reads and executes the commands from the initialization file (if any)
   1367 in the current working directory as long as @samp{set auto-load
   1368 local-gdbinit} is set to @samp{on} (@pxref{Init File in the Current
   1369 Directory}).  This is only done if the current directory is different
   1370 from your home directory.  Thus, you can have more than one init file,
   1371 one generic in your home directory, and another, specific to the
   1372 program you are debugging, in the directory where you invoke
   1373 @value{GDBN}. @xref{Init File in the Current Directory during
   1374 Startup}.
   1375 
   1376 @item
   1377 If the command line specified a program to debug, or a process to
   1378 attach to, or a core file, @value{GDBN} loads any auto-loaded
   1379 scripts provided for the program or for its loaded shared libraries.
   1380 @xref{Auto-loading}.
   1381 
   1382 If you wish to disable the auto-loading during startup,
   1383 you must do something like the following:
   1384 
   1385 @smallexample
   1386 $ gdb -iex "set auto-load python-scripts off" myprogram
   1387 @end smallexample
   1388 
   1389 Option @samp{-ex} does not work because the auto-loading is then turned
   1390 off too late.
   1391 
   1392 @item
   1393 Executes commands and command files specified by the @samp{-ex} and
   1394 @samp{-x} options in their specified order.  @xref{Command Files}, for
   1395 more details about @value{GDBN} command files.
   1396 
   1397 @item
   1398 Reads the command history recorded in the @dfn{history file}.
   1399 @xref{Command History}, for more details about the command history and the
   1400 files where @value{GDBN} records it.
   1401 @end enumerate
   1402 
   1403 @node Initialization Files
   1404 @subsection Initialization Files
   1405 @cindex init file name
   1406 
   1407 During startup (@pxref{Startup}) @value{GDBN} will execute commands
   1408 from several initialization files.  These initialization files use the
   1409 same syntax as @dfn{command files} (@pxref{Command Files}) and are
   1410 processed by @value{GDBN} in the same way.
   1411 
   1412 To display the list of initialization files loaded by @value{GDBN} at
   1413 startup, in the order they will be loaded, you can use @kbd{gdb
   1414 --help}.
   1415 
   1416 @cindex early initialization
   1417 The @dfn{early initialization} file is loaded very early in
   1418 @value{GDBN}'s initialization process, before the interpreter
   1419 (@pxref{Interpreters}) has been initialized, and before the default
   1420 target (@pxref{Targets}) is initialized.  Only @code{set} or
   1421 @code{source} commands should be placed into an early initialization
   1422 file, and the only @code{set} commands that can be used are those that
   1423 control how @value{GDBN} starts up.
   1424 
   1425 Commands that can be placed into an early initialization file will be
   1426 documented as such throughout this manual.  Any command that is not
   1427 documented as being suitable for an early initialization file should
   1428 instead be placed into a general initialization file.  Command files
   1429 passed to @code{--early-init-command} or @code{-eix} are also early
   1430 initialization files, with the same command restrictions.  Only
   1431 commands that can appear in an early initialization file should be
   1432 passed to @code{--early-init-eval-command} or @code{-eiex}.
   1433 
   1434 @cindex general initialization
   1435 In contrast, the @dfn{general initialization} files are processed
   1436 later, after @value{GDBN} has finished its own internal initialization
   1437 process, any valid command can be used in these files.
   1438 
   1439 @cindex initialization file
   1440 Throughout the rest of this document the term @dfn{initialization
   1441 file} refers to one of the general initialization files, not the early
   1442 initialization file.  Any discussion of the early initialization file
   1443 will specifically mention that it is the early initialization file
   1444 being discussed.
   1445 
   1446 As the system wide and home directory initialization files are
   1447 processed before most command line options, changes to settings
   1448 (e.g.@: @samp{set complaints}) can affect subsequent processing of
   1449 command line options and operands.
   1450 
   1451 The following sections describe where @value{GDBN} looks for the early
   1452 initialization and initialization files, and the order that the files
   1453 are searched for.
   1454 
   1455 @subsubsection Home directory early initialization files
   1456 
   1457 @value{GDBN} initially looks for an early initialization file in the
   1458 users home directory@footnote{On DOS/Windows systems, the home
   1459 directory is the one pointed to by the @env{HOME} environment
   1460 variable.}.  There are a number of locations that @value{GDBN} will
   1461 search in the home directory, these locations are searched in order
   1462 and @value{GDBN} will load the first file that it finds, and
   1463 subsequent locations will not be checked.
   1464 
   1465 On non-macOS hosts the locations searched are:
   1466 @itemize
   1467 @item
   1468 The file @file{gdb/gdbearlyinit} within the directory pointed to by the
   1469 environment variable @env{XDG_CONFIG_HOME}, if it is defined.
   1470 @item
   1471 The file @file{.config/gdb/gdbearlyinit} within the directory pointed to
   1472 by the environment variable @env{HOME}, if it is defined.
   1473 @item
   1474 The file @file{.gdbearlyinit} within the directory pointed to by the
   1475 environment variable @env{HOME}, if it is defined.
   1476 @end itemize
   1477 
   1478 By contrast, on macOS hosts the locations searched are:
   1479 @itemize
   1480 @item
   1481 The file @file{Library/Preferences/gdb/gdbearlyinit} within the
   1482 directory pointed to by the environment variable @env{HOME}, if it is
   1483 defined.
   1484 @item
   1485 The file @file{.gdbearlyinit} within the directory pointed to by the
   1486 environment variable @env{HOME}, if it is defined.
   1487 @end itemize
   1488 
   1489 It is possible to prevent the home directory early initialization file
   1490 from being loaded using the @samp{-nx} or @samp{-nh} command line
   1491 options, @pxref{Mode Options,,Choosing Modes}.
   1492 
   1493 @anchor{System Wide Init Files}
   1494 @subsubsection System wide initialization files
   1495 
   1496 There are two locations that are searched for system wide
   1497 initialization files.  Both of these locations are always checked:
   1498 
   1499 @table @code
   1500 
   1501 @item @file{system.gdbinit}
   1502 This is a single system-wide initialization file.  Its location is
   1503 specified with the @code{--with-system-gdbinit} configure option
   1504 (@pxref{System-wide configuration}).  It is loaded first when
   1505 @value{GDBN} starts, before command line options have been processed.
   1506 
   1507 @item @file{system.gdbinit.d}
   1508 This is the system-wide initialization directory.  Its location is
   1509 specified with the @code{--with-system-gdbinit-dir} configure option
   1510 (@pxref{System-wide configuration}).  Files in this directory are
   1511 loaded in alphabetical order immediately after @file{system.gdbinit}
   1512 (if enabled) when @value{GDBN} starts, before command line options
   1513 have been processed.  Files need to have a recognized scripting
   1514 language extension (@file{.py}/@file{.scm}) or be named with a
   1515 @file{.gdb} extension to be interpreted as regular @value{GDBN}
   1516 commands.  @value{GDBN} will not recurse into any subdirectories of
   1517 this directory.
   1518 
   1519 @end table
   1520 
   1521 It is possible to prevent the system wide initialization files from
   1522 being loaded using the @samp{-nx} command line option, @pxref{Mode
   1523 Options,,Choosing Modes}.
   1524 
   1525 @anchor{Home Directory Init File}
   1526 @subsubsection Home directory initialization file
   1527 @cindex @file{gdbinit}
   1528 @cindex @file{.gdbinit}
   1529 @cindex @file{gdb.ini}
   1530 
   1531 After loading the system wide initialization files @value{GDBN} will
   1532 look for an initialization file in the users home
   1533 directory@footnote{On DOS/Windows systems, the home directory is the
   1534 one pointed to by the @env{HOME} environment variable.}.  There are a
   1535 number of locations that @value{GDBN} will search in the home
   1536 directory, these locations are searched in order and @value{GDBN} will
   1537 load the first file that it finds, and subsequent locations will not
   1538 be checked.
   1539 
   1540 On non-Apple hosts the locations searched are:
   1541 @table @file
   1542 @item $XDG_CONFIG_HOME/gdb/gdbinit
   1543 @item $HOME/.config/gdb/gdbinit
   1544 @item $HOME/.gdbinit
   1545 @end table
   1546 
   1547 While on Apple hosts the locations searched are:
   1548 @table @file
   1549 @item $HOME/Library/Preferences/gdb/gdbinit
   1550 @item $HOME/.gdbinit
   1551 @end table
   1552 
   1553 It is possible to prevent the home directory initialization file from
   1554 being loaded using the @samp{-nx} or @samp{-nh} command line options,
   1555 @pxref{Mode Options,,Choosing Modes}.
   1556 
   1557 The DJGPP port of @value{GDBN} uses the name @file{gdb.ini} instead of
   1558 @file{.gdbinit} or @file{gdbinit}, due to the limitations of file
   1559 names imposed by DOS filesystems.  The Windows port of @value{GDBN}
   1560 uses the standard name, but if it finds a @file{gdb.ini} file in your
   1561 home directory, it warns you about that and suggests to rename the
   1562 file to the standard name.
   1563 
   1564 @anchor{Init File in the Current Directory during Startup}
   1565 @subsubsection Local directory initialization file
   1566 
   1567 @value{GDBN} will check the current directory for a file called
   1568 @file{.gdbinit}.  It is loaded last, after command line options
   1569 other than @samp{-x} and @samp{-ex} have been processed.  The command
   1570 line options @samp{-x} and @samp{-ex} are processed last, after
   1571 @file{.gdbinit} has been loaded, @pxref{File Options,,Choosing
   1572 Files}.
   1573 
   1574 If the file in the current directory was already loaded as the home
   1575 directory initialization file then it will not be loaded a second
   1576 time.
   1577 
   1578 It is possible to prevent the local directory initialization file from
   1579 being loaded using the @samp{-nx} command line option, @pxref{Mode
   1580 Options,,Choosing Modes}.
   1581 
   1582 @node Quitting GDB
   1583 @section Quitting @value{GDBN}
   1584 @cindex exiting @value{GDBN}
   1585 @cindex leaving @value{GDBN}
   1586 
   1587 @table @code
   1588 @kindex quit @r{[}@var{expression}@r{]}
   1589 @kindex exit @r{[}@var{expression}@r{]}
   1590 @kindex q @r{(@code{quit})}
   1591 @item quit @r{[}@var{expression}@r{]}
   1592 @itemx exit @r{[}@var{expression}@r{]}
   1593 @itemx q
   1594 To exit @value{GDBN}, use the @code{quit} command (abbreviated
   1595 @code{q}), the @code{exit} command, or type an end-of-file
   1596 character (usually @kbd{Ctrl-d}).  If you do not supply @var{expression},
   1597 @value{GDBN} will terminate normally; otherwise it will terminate using
   1598 the result of @var{expression} as the error code.
   1599 @end table
   1600 
   1601 @cindex interrupt
   1602 An interrupt (often @kbd{Ctrl-c}) does not exit from @value{GDBN}, but rather
   1603 terminates the action of any @value{GDBN} command that is in progress and
   1604 returns to @value{GDBN} command level.  It is safe to type the interrupt
   1605 character at any time because @value{GDBN} does not allow it to take effect
   1606 until a time when it is safe.
   1607 
   1608 If you have been using @value{GDBN} to control an attached process or
   1609 device, you can release it with the @code{detach} command
   1610 (@pxref{Attach, ,Debugging an Already-running Process}).
   1611 
   1612 @node Shell Commands
   1613 @section Shell Commands
   1614 
   1615 If you need to execute occasional shell commands during your
   1616 debugging session, there is no need to leave or suspend @value{GDBN}; you can
   1617 just use the @code{shell} command.
   1618 
   1619 @table @code
   1620 @kindex shell
   1621 @kindex !
   1622 @cindex shell escape
   1623 @item shell @var{command-string}
   1624 @itemx !@var{command-string}
   1625 Invoke a shell to execute @var{command-string}.
   1626 Note that no space is needed between @code{!} and @var{command-string}.
   1627 On GNU and Unix systems, the environment variable @env{SHELL}, if it
   1628 exists, determines which shell to run.  Otherwise @value{GDBN} uses
   1629 the default shell (@file{/bin/sh} on GNU and Unix systems,
   1630 @file{cmd.exe} on MS-Windows, @file{COMMAND.COM} on MS-DOS, etc.).
   1631 @end table
   1632 
   1633 You may also invoke shell commands from expressions, using the
   1634 @code{$_shell} convenience function.  @xref{$_shell convenience
   1635 function}.
   1636 
   1637 The utility @code{make} is often needed in development environments.
   1638 You do not have to use the @code{shell} command for this purpose in
   1639 @value{GDBN}:
   1640 
   1641 @table @code
   1642 @kindex make
   1643 @cindex calling make
   1644 @item make @var{make-args}
   1645 Execute the @code{make} program with the specified
   1646 arguments.  This is equivalent to @samp{shell make @var{make-args}}.
   1647 @end table
   1648 
   1649 @table @code
   1650 @kindex pipe
   1651 @kindex |
   1652 @cindex send the output of a gdb command to a shell command
   1653 @anchor{pipe}
   1654 @item pipe [@var{command}] | @var{shell_command}
   1655 @itemx | [@var{command}] | @var{shell_command}
   1656 @itemx pipe -d @var{delim} @var{command} @var{delim} @var{shell_command}
   1657 @itemx | -d @var{delim} @var{command} @var{delim} @var{shell_command}
   1658 Executes @var{command} and sends its output to @var{shell_command}.
   1659 Note that no space is needed around @code{|}.
   1660 If no @var{command} is provided, the last command executed is repeated.
   1661 
   1662 In case the @var{command} contains a @code{|}, the option @code{-d @var{delim}}
   1663 can be used to specify an alternate delimiter string @var{delim} that separates
   1664 the @var{command} from the @var{shell_command}.
   1665 
   1666 Example:
   1667 @smallexample
   1668 @group
   1669 (@value{GDBP}) p var
   1670 $1 = @{
   1671   black = 144,
   1672   red = 233,
   1673   green = 377,
   1674   blue = 610,
   1675   white = 987
   1676 @}
   1677 @end group
   1678 @group
   1679 (@value{GDBP}) pipe p var|wc
   1680       7      19      80
   1681 (@value{GDBP}) |p var|wc -l
   1682 7
   1683 @end group
   1684 @group
   1685 (@value{GDBP}) p /x var
   1686 $4 = @{
   1687   black = 0x90,
   1688   red = 0xe9,
   1689   green = 0x179,
   1690   blue = 0x262,
   1691   white = 0x3db
   1692 @}
   1693 (@value{GDBP}) ||grep red
   1694   red => 0xe9,
   1695 @end group
   1696 @group
   1697 (@value{GDBP}) | -d ! echo this contains a | char\n ! sed -e 's/|/PIPE/'
   1698 this contains a PIPE char
   1699 (@value{GDBP}) | -d xxx echo this contains a | char!\n xxx sed -e 's/|/PIPE/'
   1700 this contains a PIPE char!
   1701 (@value{GDBP})
   1702 @end group
   1703 @end smallexample
   1704 @end table
   1705 
   1706 The convenience variables @code{$_shell_exitcode} and @code{$_shell_exitsignal}
   1707 can be used to examine the exit status of the last shell command launched
   1708 by @code{shell}, @code{make}, @code{pipe} and @code{|}.
   1709 @xref{Convenience Vars,, Convenience Variables}.
   1710 
   1711 @node Logging Output
   1712 @section Logging Output
   1713 @cindex logging @value{GDBN} output
   1714 @cindex save @value{GDBN} output to a file
   1715 
   1716 You may want to save the output of @value{GDBN} commands to a file.
   1717 There are several commands to control @value{GDBN}'s logging.
   1718 
   1719 @table @code
   1720 @kindex set logging enabled
   1721 @item set logging enabled [on|off]
   1722 Enable or disable logging.
   1723 @cindex logging file name
   1724 @item set logging file @var{file}
   1725 Change the name of the current logfile.  The default logfile is @file{gdb.txt}.
   1726 @item set logging overwrite [on|off]
   1727 By default, @value{GDBN} will append to the logfile.  Set @code{overwrite} if
   1728 you want @code{set logging enabled on} to overwrite the logfile instead.
   1729 @item set logging redirect [on|off]
   1730 By default, @value{GDBN} output will go to both the terminal and the logfile.
   1731 Set @code{redirect} if you want output to go only to the log file.
   1732 @item set logging debugredirect [on|off]
   1733 By default, @value{GDBN} debug output will go to both the terminal and the logfile.
   1734 Set @code{debugredirect} if you want debug output to go only to the log file.
   1735 @kindex show logging
   1736 @item show logging
   1737 Show the current values of the logging settings.
   1738 @end table
   1739 
   1740 You can also redirect the output of a @value{GDBN} command to a
   1741 shell command.  @xref{pipe}.
   1742 @node Commands
   1743 @chapter @value{GDBN} Commands
   1744 
   1745 You can abbreviate a @value{GDBN} command to the first few letters of the command
   1746 name, if that abbreviation is unambiguous; and you can repeat certain
   1747 @value{GDBN} commands by typing just @key{RET}.  You can also use the @key{TAB}
   1748 key to get @value{GDBN} to fill out the rest of a word in a command (or to
   1749 show you the alternatives available, if there is more than one possibility).
   1750 
   1751 @menu
   1752 * Command Syntax::              How to give commands to @value{GDBN}
   1753 * Command Settings::            How to change default behavior of commands
   1754 * Completion::                  Command completion
   1755 * Filename Arguments::		Filenames As Command Arguments
   1756 * Command Options::             Command options
   1757 * Help::                        How to ask @value{GDBN} for help
   1758 @end menu
   1759 
   1760 @node Command Syntax
   1761 @section Command Syntax
   1762 
   1763 A @value{GDBN} command is a single line of input.  There is no limit on
   1764 how long it can be.  It starts with a command name, which is followed by
   1765 arguments whose meaning depends on the command name.  For example, the
   1766 command @code{step} accepts an argument which is the number of times to
   1767 step, as in @samp{step 5}.  You can also use the @code{step} command
   1768 with no arguments.  Some commands do not allow any arguments.
   1769 
   1770 @cindex abbreviation
   1771 @value{GDBN} command names may always be truncated if that abbreviation is
   1772 unambiguous.  Other possible command abbreviations are listed in the
   1773 documentation for individual commands.  In some cases, even ambiguous
   1774 abbreviations are allowed; for example, @code{s} is specially defined as
   1775 equivalent to @code{step} even though there are other commands whose
   1776 names start with @code{s}.  You can test abbreviations by using them as
   1777 arguments to the @code{help} command.
   1778 
   1779 @cindex repeating commands
   1780 @kindex RET @r{(repeat last command)}
   1781 A blank line as input to @value{GDBN} (typing just @key{RET}) means to
   1782 repeat the previous command.  Certain commands (for example, @code{run})
   1783 will not repeat this way; these are commands whose unintentional
   1784 repetition might cause trouble and which you are unlikely to want to
   1785 repeat.  User-defined commands can disable this feature; see
   1786 @ref{Define, dont-repeat}.
   1787 
   1788 The @code{list} and @code{x} commands, when you repeat them with
   1789 @key{RET}, construct new arguments rather than repeating
   1790 exactly as typed.  This permits easy scanning of source or memory.
   1791 
   1792 @value{GDBN} can also use @key{RET} in another way: to partition lengthy
   1793 output, in a way similar to the common utility @code{more}
   1794 (@pxref{Screen Size,,Screen Size}).  Since it is easy to press one
   1795 @key{RET} too many in this situation, @value{GDBN} disables command
   1796 repetition after any command that generates this sort of display.
   1797 
   1798 @kindex # @r{(a comment)}
   1799 @cindex comment
   1800 Any text from a @kbd{#} to the end of the line is a comment; it does
   1801 nothing.  This is useful mainly in command files (@pxref{Command
   1802 Files,,Command Files}).
   1803 
   1804 @cindex repeating command sequences
   1805 @kindex Ctrl-o @r{(operate-and-get-next)}
   1806 The @kbd{Ctrl-o} binding is useful for repeating a complex sequence of
   1807 commands.  This command accepts the current line, like @key{RET}, and
   1808 then fetches the next line relative to the current line from the history
   1809 for editing.
   1810 
   1811 
   1812 @node Command Settings
   1813 @section Command Settings
   1814 @cindex default behavior of commands, changing
   1815 @cindex default settings, changing
   1816 
   1817 Many commands change their behavior according to command-specific
   1818 variables or settings.  These settings can be changed with the
   1819 @code{set} subcommands.  For example, the @code{print} command
   1820 (@pxref{Data, ,Examining Data}) prints arrays differently depending on
   1821 settings changeable with the commands @code{set print elements
   1822 NUMBER-OF-ELEMENTS} and @code{set print array-indexes}, among others.
   1823 
   1824 You can change these settings to your preference in the gdbinit files
   1825 loaded at @value{GDBN} startup.  @xref{Startup}.
   1826 
   1827 The settings can also be changed interactively during the debugging
   1828 session.  For example, to change the limit of array elements to print,
   1829 you can do the following:
   1830 @smallexample
   1831 (@value{GDBP}) set print elements 10
   1832 (@value{GDBP}) print some_array
   1833 $1 = @{0, 10, 20, 30, 40, 50, 60, 70, 80, 90...@}
   1834 @end smallexample
   1835 
   1836 The above @code{set print elements 10} command changes the number of
   1837 elements to print from the default of 200 to 10.  If you only intend
   1838 this limit of 10 to be used for printing @code{some_array}, then you
   1839 must restore the limit back to 200, with @code{set print elements
   1840 200}.
   1841 
   1842 Some commands allow overriding settings with command options.  For
   1843 example, the @code{print} command supports a number of options that
   1844 allow overriding relevant global print settings as set by @code{set
   1845 print} subcommands.  @xref{print options}.  The example above could be
   1846 rewritten as:
   1847 @smallexample
   1848 (@value{GDBP}) print -elements 10 -- some_array
   1849 $1 = @{0, 10, 20, 30, 40, 50, 60, 70, 80, 90...@}
   1850 @end smallexample
   1851 
   1852 Alternatively, you can use the @code{with} command to change a setting
   1853 temporarily, for the duration of a command invocation.
   1854 
   1855 @table @code
   1856 @kindex with command
   1857 @kindex w @r{(@code{with})}
   1858 @cindex settings
   1859 @cindex temporarily change settings
   1860 @item with @var{setting} [@var{value}] [-- @var{command}]
   1861 @itemx w @var{setting} [@var{value}] [-- @var{command}]
   1862 Temporarily set @var{setting} to @var{value} for the duration of
   1863 @var{command}.
   1864 
   1865 @var{setting} is any setting you can change with the @code{set}
   1866 subcommands.  @var{value} is the value to assign to @code{setting}
   1867 while running @code{command}.
   1868 
   1869 If no @var{command} is provided, the last command executed is
   1870 repeated.
   1871 
   1872 If a @var{command} is provided, it must be preceded by a double dash
   1873 (@code{--}) separator.  This is required because some settings accept
   1874 free-form arguments, such as expressions or filenames.
   1875 
   1876 For example, the command
   1877 @smallexample
   1878 (@value{GDBP}) with print array on -- print some_array
   1879 @end smallexample
   1880 @noindent
   1881 is equivalent to the following 3 commands:
   1882 @smallexample
   1883 (@value{GDBP}) set print array on
   1884 (@value{GDBP}) print some_array
   1885 (@value{GDBP}) set print array off
   1886 @end smallexample
   1887 
   1888 The @code{with} command is particularly useful when you want to
   1889 override a setting while running user-defined commands, or commands
   1890 defined in Python or Guile.  @xref{Extending GDB,, Extending GDB}.
   1891 
   1892 @smallexample
   1893 (@value{GDBP}) with print pretty on -- my_complex_command
   1894 @end smallexample
   1895 
   1896 To change several settings for the same command, you can nest
   1897 @code{with} commands.  For example, @code{with language ada -- with
   1898 print elements 10} temporarily changes the language to Ada and sets a
   1899 limit of 10 elements to print for arrays and strings.
   1900 
   1901 @end table
   1902 
   1903 @node Completion
   1904 @section Command Completion
   1905 
   1906 @cindex completion
   1907 @cindex word completion
   1908 @value{GDBN} can fill in the rest of a word in a command for you, if there is
   1909 only one possibility; it can also show you what the valid possibilities
   1910 are for the next word in a command, at any time.  This works for @value{GDBN}
   1911 commands, @value{GDBN} subcommands, command options, and the names of symbols
   1912 in your program.
   1913 
   1914 Press the @key{TAB} key whenever you want @value{GDBN} to fill out the rest
   1915 of a word.  If there is only one possibility, @value{GDBN} fills in the
   1916 word, and waits for you to finish the command (or press @key{RET} to
   1917 enter it).  For example, if you type
   1918 
   1919 @c FIXME "@key" does not distinguish its argument sufficiently to permit
   1920 @c complete accuracy in these examples; space introduced for clarity.
   1921 @c If texinfo enhancements make it unnecessary, it would be nice to
   1922 @c replace " @key" by "@key" in the following...
   1923 @smallexample
   1924 (@value{GDBP}) info bre@key{TAB}
   1925 @end smallexample
   1926 
   1927 @noindent
   1928 @value{GDBN} fills in the rest of the word @samp{breakpoints}, since that is
   1929 the only @code{info} subcommand beginning with @samp{bre}:
   1930 
   1931 @smallexample
   1932 (@value{GDBP}) info breakpoints
   1933 @end smallexample
   1934 
   1935 @noindent
   1936 You can either press @key{RET} at this point, to run the @code{info
   1937 breakpoints} command, or backspace and enter something else, if
   1938 @samp{breakpoints} does not look like the command you expected.  (If you
   1939 were sure you wanted @code{info breakpoints} in the first place, you
   1940 might as well just type @key{RET} immediately after @samp{info bre},
   1941 to exploit command abbreviations rather than command completion).
   1942 
   1943 If there is more than one possibility for the next word when you press
   1944 @key{TAB}, @value{GDBN} sounds a bell.  You can either supply more
   1945 characters and try again, or just press @key{TAB} a second time;
   1946 @value{GDBN} displays all the possible completions for that word.  For
   1947 example, you might want to set a breakpoint on a subroutine whose name
   1948 begins with @samp{make_}, but when you type @kbd{b make_@key{TAB}} @value{GDBN}
   1949 just sounds the bell.  Typing @key{TAB} again displays all the
   1950 function names in your program that begin with those characters, for
   1951 example:
   1952 
   1953 @smallexample
   1954 (@value{GDBP}) b make_@key{TAB}
   1955 @exdent @value{GDBN} sounds bell; press @key{TAB} again, to see:
   1956 make_a_section_from_file     make_environ
   1957 make_abs_section             make_function_type
   1958 make_blockvector             make_pointer_type
   1959 make_cleanup                 make_reference_type
   1960 make_command                 make_symbol_completion_list
   1961 (@value{GDBP}) b make_
   1962 @end smallexample
   1963 
   1964 @noindent
   1965 After displaying the available possibilities, @value{GDBN} copies your
   1966 partial input (@samp{b make_} in the example) so you can finish the
   1967 command.
   1968 
   1969 If the command you are trying to complete expects either a keyword or a
   1970 number to follow, then @samp{NUMBER} will be shown among the available
   1971 completions, for example:
   1972 
   1973 @smallexample
   1974 (@value{GDBP}) print -elements @key{TAB}@key{TAB}
   1975 NUMBER     unlimited
   1976 (@value{GDBP}) print -elements@tie{}
   1977 @end smallexample
   1978 
   1979 @noindent
   1980 Here, the option expects a number (e.g., @code{100}), not literal
   1981 @code{NUMBER}.  Such metasyntactical arguments are always presented in
   1982 uppercase.
   1983 
   1984 If you just want to see the list of alternatives in the first place, you
   1985 can press @kbd{M-?} rather than pressing @key{TAB} twice.  @kbd{M-?}
   1986 means @kbd{@key{META} ?}.  You can type this either by holding down a
   1987 key designated as the @key{META} shift on your keyboard (if there is
   1988 one) while typing @kbd{?}, or as @key{ESC} followed by @kbd{?}.
   1989 
   1990 If the number of possible completions is large, @value{GDBN} will
   1991 print as much of the list as it has collected, as well as a message
   1992 indicating that the list may be truncated.
   1993 
   1994 @smallexample
   1995 (@value{GDBP}) b m@key{TAB}@key{TAB}
   1996 main
   1997 <... the rest of the possible completions ...>
   1998 *** List may be truncated, max-completions reached. ***
   1999 (@value{GDBP}) b m
   2000 @end smallexample
   2001 
   2002 @noindent
   2003 This behavior can be controlled with the following commands:
   2004 
   2005 @table @code
   2006 @kindex set max-completions
   2007 @item set max-completions @var{limit}
   2008 @itemx set max-completions unlimited
   2009 Set the maximum number of completion candidates.  @value{GDBN} will
   2010 stop looking for more completions once it collects this many candidates.
   2011 This is useful when completing on things like function names as collecting
   2012 all the possible candidates can be time consuming.
   2013 The default value is 200.  A value of zero disables tab-completion.
   2014 Note that setting either no limit or a very large limit can make
   2015 completion slow.
   2016 @kindex show max-completions
   2017 @item show max-completions
   2018 Show the maximum number of candidates that @value{GDBN} will collect and show
   2019 during completion.
   2020 @end table
   2021 
   2022 @cindex quotes in commands
   2023 @cindex completion of quoted strings
   2024 Sometimes the string you need, while logically a ``word'', may contain
   2025 parentheses or other characters that @value{GDBN} normally excludes from
   2026 its notion of a word.  To permit word completion to work in this
   2027 situation, you may enclose words in @code{'} (single quote marks) in
   2028 @value{GDBN} commands.
   2029 
   2030 A likely situation where you might need this is in typing an
   2031 expression that involves a C@t{++} symbol name with template
   2032 parameters.  This is because when completing expressions, GDB treats
   2033 the @samp{<} character as word delimiter, assuming that it's the
   2034 less-than comparison operator (@pxref{C Operators, , C and C@t{++}
   2035 Operators}).
   2036 
   2037 For example, when you want to call a C@t{++} template function
   2038 interactively using the @code{print} or @code{call} commands, you may
   2039 need to distinguish whether you mean the version of @code{name} that
   2040 was specialized for @code{int}, @code{name<int>()}, or the version
   2041 that was specialized for @code{float}, @code{name<float>()}.  To use
   2042 the word-completion facilities in this situation, type a single quote
   2043 @code{'} at the beginning of the function name.  This alerts
   2044 @value{GDBN} that it may need to consider more information than usual
   2045 when you press @key{TAB} or @kbd{M-?} to request word completion:
   2046 
   2047 @smallexample
   2048 (@value{GDBP}) p 'func<@kbd{M-?}
   2049 func<int>()    func<float>()
   2050 (@value{GDBP}) p 'func<
   2051 @end smallexample
   2052 
   2053 When setting breakpoints however (@pxref{Location Specifications}), you don't
   2054 usually need to type a quote before the function name, because
   2055 @value{GDBN} understands that you want to set a breakpoint on a
   2056 function:
   2057 
   2058 @smallexample
   2059 (@value{GDBP}) b func<@kbd{M-?}
   2060 func<int>()    func<float>()
   2061 (@value{GDBP}) b func<
   2062 @end smallexample
   2063 
   2064 This is true even in the case of typing the name of C@t{++} overloaded
   2065 functions (multiple definitions of the same function, distinguished by
   2066 argument type).  For example, when you want to set a breakpoint you
   2067 don't need to distinguish whether you mean the version of @code{name}
   2068 that takes an @code{int} parameter, @code{name(int)}, or the version
   2069 that takes a @code{float} parameter, @code{name(float)}.
   2070 
   2071 @smallexample
   2072 (@value{GDBP}) b bubble(@kbd{M-?}
   2073 bubble(int)    bubble(double)
   2074 (@value{GDBP}) b bubble(dou@kbd{M-?}
   2075 bubble(double)
   2076 @end smallexample
   2077 
   2078 See @ref{quoting names} for a description of other scenarios that
   2079 require quoting.
   2080 
   2081 For more information about overloaded functions, see @ref{C Plus Plus
   2082 Expressions, ,C@t{++} Expressions}.  You can use the command @code{set
   2083 overload-resolution off} to disable overload resolution;
   2084 see @ref{Debugging C Plus Plus, ,@value{GDBN} Features for C@t{++}}.
   2085 
   2086 @cindex completion of structure field names
   2087 @cindex structure field name completion
   2088 @cindex completion of union field names
   2089 @cindex union field name completion
   2090 When completing in an expression which looks up a field in a
   2091 structure, @value{GDBN} also tries@footnote{The completer can be
   2092 confused by certain kinds of invalid expressions.  Also, it only
   2093 examines the static type of the expression, not the dynamic type.} to
   2094 limit completions to the field names available in the type of the
   2095 left-hand-side:
   2096 
   2097 @smallexample
   2098 (@value{GDBP}) p gdb_stdout.@kbd{M-?}
   2099 magic                to_fputs             to_rewind
   2100 to_data              to_isatty            to_write
   2101 to_delete            to_put               to_write_async_safe
   2102 to_flush             to_read
   2103 @end smallexample
   2104 
   2105 @noindent
   2106 This is because the @code{gdb_stdout} is a variable of the type
   2107 @code{struct ui_file} that is defined in @value{GDBN} sources as
   2108 follows:
   2109 
   2110 @smallexample
   2111 struct ui_file
   2112 @{
   2113    int *magic;
   2114    ui_file_flush_ftype *to_flush;
   2115    ui_file_write_ftype *to_write;
   2116    ui_file_write_async_safe_ftype *to_write_async_safe;
   2117    ui_file_fputs_ftype *to_fputs;
   2118    ui_file_read_ftype *to_read;
   2119    ui_file_delete_ftype *to_delete;
   2120    ui_file_isatty_ftype *to_isatty;
   2121    ui_file_rewind_ftype *to_rewind;
   2122    ui_file_put_ftype *to_put;
   2123    void *to_data;
   2124 @}
   2125 @end smallexample
   2126 
   2127 @node Filename Arguments
   2128 @section Filenames As Command Arguments
   2129 @cindex file names, quoting and escaping
   2130 
   2131 When passing filenames (or directory names) as arguments to a command,
   2132 if the filename argument does not include any whitespace, double
   2133 quotes, or single quotes, then for all commands the filename can be
   2134 written as a simple string, for example:
   2135 
   2136 @smallexample
   2137 (@value{GDBP}) file /path/to/some/file
   2138 @end smallexample
   2139 
   2140 If the filename does include whitespace, double quotes, or single
   2141 quotes, then @value{GDBN} has two approaches for how these filenames
   2142 should be formatted; which format to use depends on which command is
   2143 being used.
   2144 
   2145 Most @value{GDBN} commands don't require, or support, quoting and
   2146 escaping.  These commands treat any text after the command name, that
   2147 is not a command option (@pxref{Command Options}), as the filename,
   2148 even if the filename contains whitespace or quote characters.  In the
   2149 following example the user is adding @w{@file{/path/that contains/two
   2150 spaces/}} to the auto-load safe-path (@pxref{add-auto-load-safe-path}):
   2151 
   2152 @smallexample
   2153 (@value{GDBP}) add-auto-load-safe-path /path/that contains/two spaces/
   2154 @end smallexample
   2155 
   2156 A small number of commands require that filenames containing
   2157 whitespace or quote characters are either quoted, or have the special
   2158 characters escaped with a backslash.  Commands that support this style
   2159 are marked as such in the manual, any command not marked as accepting
   2160 quoting and escaping of its filename argument, does not accept this
   2161 filename argument style.
   2162 
   2163 For example, to load the file @w{@file{/path/with spaces/to/a file}}
   2164 with the @code{file} command (@pxref{Files, ,Commands to Specify
   2165 Files}), you can escape the whitespace characters with a backslash:
   2166 
   2167 @smallexample
   2168 (@value{GDBP}) file /path/with\ spaces/to/a\ file
   2169 @end smallexample
   2170 
   2171 Alternatively the entire filename can be wrapped in either single or
   2172 double quotes, in which case no backlsashes are needed, for example:
   2173 
   2174 @smallexample
   2175 (@value{GDBP}) symbol-file "/path/with spaces/to/a file"
   2176 (@value{GDBP}) exec-file '/path/with spaces/to/a file'
   2177 @end smallexample
   2178 
   2179 It is possible to include a quote character within a quoted filename
   2180 by escaping it with a backslash, for example, within a filename
   2181 surrounded by double quotes, a double quote character should be
   2182 escaped with a backslash, but a single quote character should not be
   2183 escaped.  Within a single quoted string a single quote character needs
   2184 to be escaped, but a double quote character does not.
   2185 
   2186 A literal backslash character can also be included by escaping it with
   2187 a backslash.
   2188 
   2189 @node Command Options
   2190 @section Command options
   2191 
   2192 @cindex command options
   2193 Some commands accept options starting with a leading dash.  For
   2194 example, @code{print -pretty}.  Similarly to command names, you can
   2195 abbreviate a @value{GDBN} option to the first few letters of the
   2196 option name, if that abbreviation is unambiguous, and you can also use
   2197 the @key{TAB} key to get @value{GDBN} to fill out the rest of a word
   2198 in an option (or to show you the alternatives available, if there is
   2199 more than one possibility).
   2200 
   2201 @cindex command options, raw input
   2202 Some commands take raw input as argument.  For example, the print
   2203 command processes arbitrary expressions in any of the languages
   2204 supported by @value{GDBN}.  With such commands, because raw input may
   2205 start with a leading dash that would be confused with an option or any
   2206 of its abbreviations, e.g.@: @code{print -p} (short for @code{print
   2207 -pretty} or printing negative @code{p}?), if you specify any command
   2208 option, then you must use a double-dash (@code{--}) delimiter to
   2209 indicate the end of options.
   2210 
   2211 @cindex command options, boolean
   2212 
   2213 Some options are described as accepting an argument which can be
   2214 either @code{on} or @code{off}.  These are known as @dfn{boolean
   2215 options}.  Similarly to boolean settings commands---@code{on} and
   2216 @code{off} are the typical values, but any of @code{1}, @code{yes} and
   2217 @code{enable} can also be used as ``true'' value, and any of @code{0},
   2218 @code{no} and @code{disable} can also be used as ``false'' value.  You
   2219 can also omit a ``true'' value, as it is implied by default.
   2220 
   2221 For example, these are equivalent:
   2222 
   2223 @smallexample
   2224 (@value{GDBP}) print -object on -pretty off -element unlimited -- *myptr
   2225 (@value{GDBP}) p -o -p 0 -e u -- *myptr
   2226 @end smallexample
   2227 
   2228 You can discover the set of options some command accepts by completing
   2229 on @code{-} after the command name.  For example:
   2230 
   2231 @smallexample
   2232 (@value{GDBP}) print -@key{TAB}@key{TAB}
   2233 -address         -max-depth               -object          -static-members
   2234 -array           -memory-tag-violations   -pretty          -symbol
   2235 -array-indexes   -nibbles                 -raw-values      -union
   2236 -elements        -null-stop               -repeats         -vtbl
   2237 @end smallexample
   2238 
   2239 Completion will in some cases guide you with a suggestion of what kind
   2240 of argument an option expects.  For example:
   2241 
   2242 @smallexample
   2243 (@value{GDBP}) print -elements @key{TAB}@key{TAB}
   2244 NUMBER     unlimited
   2245 @end smallexample
   2246 
   2247 @noindent
   2248 Here, the option expects a number (e.g., @code{100}), not literal
   2249 @code{NUMBER}.  Such metasyntactical arguments are always presented in
   2250 uppercase.
   2251 
   2252 (For more on using the @code{print} command, see @ref{Data, ,Examining
   2253 Data}.)
   2254 
   2255 @node Help
   2256 @section Getting Help
   2257 @cindex online documentation
   2258 @kindex help
   2259 
   2260 You can always ask @value{GDBN} itself for information on its commands,
   2261 using the command @code{help}.
   2262 
   2263 @table @code
   2264 @kindex h @r{(@code{help})}
   2265 @item help
   2266 @itemx h
   2267 You can use @code{help} (abbreviated @code{h}) with no arguments to
   2268 display a short list of named classes of commands:
   2269 
   2270 @smallexample
   2271 (@value{GDBP}) help
   2272 List of classes of commands:
   2273 
   2274 aliases -- User-defined aliases of other commands
   2275 breakpoints -- Making program stop at certain points
   2276 data -- Examining data
   2277 files -- Specifying and examining files
   2278 internals -- Maintenance commands
   2279 obscure -- Obscure features
   2280 running -- Running the program
   2281 stack -- Examining the stack
   2282 status -- Status inquiries
   2283 support -- Support facilities
   2284 tracepoints -- Tracing of program execution without
   2285                stopping the program
   2286 user-defined -- User-defined commands
   2287 
   2288 Type "help" followed by a class name for a list of
   2289 commands in that class.
   2290 Type "help" followed by command name for full
   2291 documentation.
   2292 Command name abbreviations are allowed if unambiguous.
   2293 (@value{GDBP})
   2294 @end smallexample
   2295 @c the above line break eliminates huge line overfull...
   2296 
   2297 @item help @var{class}
   2298 Using one of the general help classes as an argument, you can get a
   2299 list of the individual commands in that class.  If a command has
   2300 aliases, the aliases are given after the command name, separated by
   2301 commas.  If an alias has default arguments, the full definition of
   2302 the alias is given after the first line.
   2303 For example, here is the help display for the class @code{status}:
   2304 
   2305 @smallexample
   2306 (@value{GDBP}) help status
   2307 Status inquiries.
   2308 
   2309 List of commands:
   2310 
   2311 @c Line break in "show" line falsifies real output, but needed
   2312 @c to fit in smallbook page size.
   2313 info, inf, i -- Generic command for showing things
   2314         about the program being debugged
   2315 info address, iamain  -- Describe where symbol SYM is stored.
   2316   alias iamain = info address main
   2317 info all-registers -- List of all registers and their contents,
   2318         for selected stack frame.
   2319 ...
   2320 show, info set -- Generic command for showing things
   2321         about the debugger
   2322 
   2323 Type "help" followed by command name for full
   2324 documentation.
   2325 Command name abbreviations are allowed if unambiguous.
   2326 (@value{GDBP})
   2327 @end smallexample
   2328 
   2329 @item help @var{command}
   2330 With a command name as @code{help} argument, @value{GDBN} displays a
   2331 short paragraph on how to use that command.  If that command has
   2332 one or more aliases, @value{GDBN} will display a first line with
   2333 the command name and all its aliases separated by commas.
   2334 This first line will be followed by the full definition of all aliases
   2335 having default arguments.
   2336 When asking the help for an alias, the documentation for the aliased
   2337 command is shown.
   2338 
   2339 A user-defined alias can optionally be documented using the
   2340 @code{document} command (@pxref{Define, document}).  @value{GDBN} then
   2341 considers this alias as different from the aliased command: this alias
   2342 is not listed in the aliased command help output, and asking help for
   2343 this alias will show the documentation provided for the alias instead of
   2344 the documentation of the aliased command.
   2345 
   2346 @kindex apropos
   2347 @item apropos [-v] @var{regexp}
   2348 The @code{apropos} command searches through all of the @value{GDBN}
   2349 commands and aliases, and their documentation, for the regular expression specified in
   2350 @var{args}.  It prints out all matches found.  The optional flag  @samp{-v},
   2351 which stands for @samp{verbose}, indicates to output the full documentation
   2352 of the matching commands and highlight the parts of the documentation
   2353 matching @var{regexp}.  For example:
   2354 
   2355 @smallexample
   2356 apropos alias
   2357 @end smallexample
   2358 
   2359 @noindent
   2360 results in:
   2361 
   2362 @smallexample
   2363 @group
   2364 alias -- Define a new command that is an alias of an existing command
   2365 aliases -- User-defined aliases of other commands
   2366 @end group
   2367 @end smallexample
   2368 
   2369 @noindent
   2370 while
   2371 
   2372 @smallexample
   2373 apropos -v cut.*thread apply
   2374 @end smallexample
   2375 
   2376 @noindent
   2377 results in the below output, where @samp{cut for 'thread apply}
   2378 is highlighted if styling is enabled.
   2379 
   2380 @smallexample
   2381 @group
   2382 taas -- Apply a command to all threads (ignoring errors
   2383 and empty output).
   2384 Usage: taas COMMAND
   2385 shortcut for 'thread apply all -s COMMAND'
   2386 
   2387 tfaas -- Apply a command to all frames of all threads
   2388 (ignoring errors and empty output).
   2389 Usage: tfaas COMMAND
   2390 shortcut for 'thread apply all -s frame apply all -s COMMAND'
   2391 @end group
   2392 @end smallexample
   2393 
   2394 @kindex complete
   2395 @item complete @var{args}
   2396 The @code{complete @var{args}} command lists all the possible completions
   2397 for the beginning of a command.  Use @var{args} to specify the beginning of the
   2398 command you want completed.  For example:
   2399 
   2400 @smallexample
   2401 complete i
   2402 @end smallexample
   2403 
   2404 @noindent results in:
   2405 
   2406 @smallexample
   2407 @group
   2408 if
   2409 ignore
   2410 info
   2411 inspect
   2412 @end group
   2413 @end smallexample
   2414 
   2415 @noindent This is intended for use by @sc{gnu} Emacs.
   2416 @end table
   2417 
   2418 In addition to @code{help}, you can use the @value{GDBN} commands @code{info}
   2419 and @code{show} to inquire about the state of your program, or the state
   2420 of @value{GDBN} itself.  Each command supports many topics of inquiry; this
   2421 manual introduces each of them in the appropriate context.  The listings
   2422 under @code{info} and under @code{show} in the Command, Variable, and
   2423 Function Index point to all the sub-commands.  @xref{Command and Variable
   2424 Index}.
   2425 
   2426 @c @group
   2427 @table @code
   2428 @kindex info
   2429 @kindex i @r{(@code{info})}
   2430 @item info
   2431 This command (abbreviated @code{i}) is for describing the state of your
   2432 program.  For example, you can show the arguments passed to a function
   2433 with @code{info args}, list the registers currently in use with @code{info
   2434 registers}, or list the breakpoints you have set with @code{info breakpoints}.
   2435 You can get a complete list of the @code{info} sub-commands with
   2436 @w{@code{help info}}.
   2437 
   2438 @kindex set
   2439 @item set
   2440 You can assign the result of an expression to an environment variable with
   2441 @code{set}.  For example, you can set the @value{GDBN} prompt to a $-sign with
   2442 @code{set prompt $}.
   2443 
   2444 @kindex show
   2445 @item show
   2446 In contrast to @code{info}, @code{show} is for describing the state of
   2447 @value{GDBN} itself.
   2448 You can change most of the things you can @code{show}, by using the
   2449 related command @code{set}; for example, you can control what number
   2450 system is used for displays with @code{set radix}, or simply inquire
   2451 which is currently in use with @code{show radix}.
   2452 
   2453 @kindex info set
   2454 To display all the settable parameters and their current
   2455 values, you can use @code{show} with no arguments; you may also use
   2456 @code{info set}.  Both commands produce the same display.
   2457 @c FIXME: "info set" violates the rule that "info" is for state of
   2458 @c FIXME...program.  Ck w/ GNU: "info set" to be called something else,
   2459 @c FIXME...or change desc of rule---eg "state of prog and debugging session"?
   2460 @end table
   2461 @c @end group
   2462 
   2463 Here are several miscellaneous @code{show} subcommands, all of which are
   2464 exceptional in lacking corresponding @code{set} commands:
   2465 
   2466 @table @code
   2467 @kindex show version
   2468 @cindex @value{GDBN} version number
   2469 @item show version
   2470 Show what version of @value{GDBN} is running.  You should include this
   2471 information in @value{GDBN} bug-reports.  If multiple versions of
   2472 @value{GDBN} are in use at your site, you may need to determine which
   2473 version of @value{GDBN} you are running; as @value{GDBN} evolves, new
   2474 commands are introduced, and old ones may wither away.  Also, many
   2475 system vendors ship variant versions of @value{GDBN}, and there are
   2476 variant versions of @value{GDBN} in @sc{gnu}/Linux distributions as well.
   2477 The version number is the same as the one announced when you start
   2478 @value{GDBN}.
   2479 
   2480 @kindex show copying
   2481 @kindex info copying
   2482 @cindex display @value{GDBN} copyright
   2483 @item show copying
   2484 @itemx info copying
   2485 Display information about permission for copying @value{GDBN}.
   2486 
   2487 @kindex show warranty
   2488 @kindex info warranty
   2489 @item show warranty
   2490 @itemx info warranty
   2491 Display the @sc{gnu} ``NO WARRANTY'' statement, or a warranty,
   2492 if your version of @value{GDBN} comes with one.
   2493 
   2494 @anchor{show configuration}
   2495 @kindex show configuration
   2496 @item show configuration
   2497 Display detailed information about the way @value{GDBN} was configured
   2498 when it was built.  This displays the optional arguments passed to the
   2499 @file{configure} script and also configuration parameters detected
   2500 automatically by @command{configure}.  When reporting a @value{GDBN}
   2501 bug (@pxref{GDB Bugs}), it is important to include this information in
   2502 your report.
   2503 
   2504 This commands also displays the version number of the Readline library
   2505 that @value{GDBN} is using.  After the version number will appear
   2506 either @samp{(system)} indicating @value{GDBN} is using the shared
   2507 system Readline library, or @samp{(internal)} indicating @value{GDBN}
   2508 is using a statically linked in version of the Readline library.
   2509 @end table
   2510 
   2511 @node Running
   2512 @chapter Running Programs Under @value{GDBN}
   2513 
   2514 When you run a program under @value{GDBN}, you must first generate
   2515 debugging information when you compile it.
   2516 
   2517 You may start @value{GDBN} with its arguments, if any, in an environment
   2518 of your choice.  If you are doing native debugging, you may redirect
   2519 your program's input and output, debug an already running process, or
   2520 kill a child process.
   2521 
   2522 @menu
   2523 * Compilation::                 Compiling for debugging
   2524 * Starting::                    Starting your program
   2525 * Arguments::                   Your program's arguments
   2526 * Environment::                 Your program's environment
   2527 
   2528 * Working Directory::           Your program's working directory
   2529 * Input/Output::                Your program's input and output
   2530 * Attach::                      Debugging an already-running process
   2531 * Kill Process::                Killing the child process
   2532 * Inferiors Connections and Programs:: Debugging multiple inferiors
   2533 					 connections and programs
   2534 * Threads::                     Debugging programs with multiple threads
   2535 * Forks::                       Debugging forks
   2536 * Checkpoint/Restart::          Setting a @emph{bookmark} to return to later
   2537 @end menu
   2538 
   2539 @node Compilation
   2540 @section Compiling for Debugging
   2541 
   2542 In order to debug a program effectively, you need to generate
   2543 debugging information when you compile it.  This debugging information
   2544 is stored in the object file; it describes the data type of each
   2545 variable or function and the correspondence between source line numbers
   2546 and addresses in the executable code.
   2547 
   2548 To request debugging information, specify the @samp{-g} option when you run
   2549 the compiler.
   2550 
   2551 Programs that are to be shipped to your customers are compiled with
   2552 optimizations, using the @samp{-O} compiler option.  However, some
   2553 compilers are unable to handle the @samp{-g} and @samp{-O} options
   2554 together.  Using those compilers, you cannot generate optimized
   2555 executables containing debugging information.
   2556 
   2557 @value{NGCC}, the @sc{gnu} C/C@t{++} compiler, supports @samp{-g} with or
   2558 without @samp{-O}, making it possible to debug optimized code.  We
   2559 recommend that you @emph{always} use @samp{-g} whenever you compile a
   2560 program.  You may think your program is correct, but there is no sense
   2561 in pushing your luck.  For more information, see @ref{Optimized Code}.
   2562 
   2563 Older versions of the @sc{gnu} C compiler permitted a variant option
   2564 @w{@samp{-gg}} for debugging information.  @value{GDBN} no longer supports this
   2565 format; if your @sc{gnu} C compiler has this option, do not use it.
   2566 
   2567 @value{GDBN} knows about preprocessor macros and can show you their
   2568 expansion (@pxref{Macros}).  Most compilers do not include information
   2569 about preprocessor macros in the debugging information if you specify
   2570 the @option{-g} flag alone.  Version 3.1 and later of @value{NGCC},
   2571 the @sc{gnu} C compiler, provides macro information if you are using
   2572 the DWARF debugging format, and specify the option @option{-g3}.
   2573 
   2574 @xref{Debugging Options,,Options for Debugging Your Program or GCC,
   2575 gcc, Using the @sc{gnu} Compiler Collection (GCC)}, for more
   2576 information on @value{NGCC} options affecting debug information.
   2577 
   2578 You will have the best debugging experience if you use the latest
   2579 version of the DWARF debugging format that your compiler supports.
   2580 DWARF is currently the most expressive and best supported debugging
   2581 format in @value{GDBN}.
   2582 
   2583 @need 2000
   2584 @node Starting
   2585 @section Starting your Program
   2586 @cindex starting
   2587 @cindex running
   2588 
   2589 @table @code
   2590 @kindex run
   2591 @kindex r @r{(@code{run})}
   2592 @item run
   2593 @itemx r
   2594 Use the @code{run} command to start your program under @value{GDBN}.
   2595 You must first specify the program name with an argument to
   2596 @value{GDBN} (@pxref{Invocation, ,Getting In and Out of
   2597 @value{GDBN}}), or by using the @code{file} or @code{exec-file}
   2598 command (@pxref{Files, ,Commands to Specify Files}).
   2599 
   2600 @end table
   2601 
   2602 If you are running your program in an execution environment that
   2603 supports processes, @code{run} creates an inferior process and makes
   2604 that process run your program.  In some environments without processes,
   2605 @code{run} jumps to the start of your program.  Other targets,
   2606 like @samp{remote}, are always running.  If you get an error
   2607 message like this one:
   2608 
   2609 @smallexample
   2610 The "remote" target does not support "run".
   2611 Try "help target" or "continue".
   2612 @end smallexample
   2613 
   2614 @noindent
   2615 then use @code{continue} to run your program.  You may need @code{load}
   2616 first (@pxref{load}).
   2617 
   2618 The execution of a program is affected by certain information it
   2619 receives from its superior.  @value{GDBN} provides ways to specify this
   2620 information, which you must do @emph{before} starting your program.  (You
   2621 can change it after starting your program, but such changes only affect
   2622 your program the next time you start it.)  This information may be
   2623 divided into four categories:
   2624 
   2625 @table @asis
   2626 @item The @emph{arguments.}
   2627 Specify the arguments to give your program as the arguments of the
   2628 @code{run} command.  If a shell is available on your target, the shell
   2629 is used to pass the arguments, so that you may use normal conventions
   2630 (such as wildcard expansion or variable substitution) in describing
   2631 the arguments.
   2632 In Unix systems, you can control which shell is used with the
   2633 @env{SHELL} environment variable.  If you do not define @env{SHELL},
   2634 @value{GDBN} uses the default shell (@file{/bin/sh}).  You can disable
   2635 use of any shell with the @code{set startup-with-shell} command (see
   2636 below for details).
   2637 
   2638 @item The @emph{environment.}
   2639 Your program normally inherits its environment from @value{GDBN}, but you can
   2640 use the @value{GDBN} commands @code{set environment} and @code{unset
   2641 environment} to change parts of the environment that affect
   2642 your program.  @xref{Environment, ,Your Program's Environment}.
   2643 
   2644 @item The @emph{working directory.}
   2645 You can set your program's working directory with the command
   2646 @kbd{set cwd}.  If you do not set any working directory with this
   2647 command, your program will inherit @value{GDBN}'s working directory if
   2648 native debugging, or the remote server's working directory if remote
   2649 debugging.  @xref{Working Directory, ,Your Program's Working
   2650 Directory}.
   2651 
   2652 @item The @emph{standard input and output.}
   2653 Your program normally uses the same device for standard input and
   2654 standard output as @value{GDBN} is using.  You can redirect input and output
   2655 in the @code{run} command line, or you can use the @code{tty} command to
   2656 set a different device for your program.
   2657 @xref{Input/Output, ,Your Program's Input and Output}.
   2658 
   2659 @cindex pipes
   2660 @emph{Warning:} While input and output redirection work, you cannot use
   2661 pipes to pass the output of the program you are debugging to another
   2662 program; if you attempt this, @value{GDBN} is likely to wind up debugging the
   2663 wrong program.
   2664 @end table
   2665 
   2666 When you issue the @code{run} command, your program begins to execute
   2667 immediately.  @xref{Stopping, ,Stopping and Continuing}, for discussion
   2668 of how to arrange for your program to stop.  Once your program has
   2669 stopped, you may call functions in your program, using the @code{print}
   2670 or @code{call} commands.  @xref{Data, ,Examining Data}.
   2671 
   2672 If the modification time of your symbol file has changed since the last
   2673 time @value{GDBN} read its symbols, @value{GDBN} discards its symbol
   2674 table, and reads it again.  When it does this, @value{GDBN} tries to retain
   2675 your current breakpoints.
   2676 
   2677 @table @code
   2678 @kindex start
   2679 @item start
   2680 @cindex run to main procedure
   2681 The name of the main procedure can vary from language to language.
   2682 With C or C@t{++}, the main procedure name is always @code{main}, but
   2683 other languages such as Ada do not require a specific name for their
   2684 main procedure.  The debugger provides a convenient way to start the
   2685 execution of the program and to stop at the beginning of the main
   2686 procedure, depending on the language used.
   2687 
   2688 The @samp{start} command does the equivalent of setting a temporary
   2689 breakpoint at the beginning of the main procedure and then invoking
   2690 the @samp{run} command.
   2691 
   2692 @cindex elaboration phase
   2693 Some programs contain an @dfn{elaboration} phase where some startup code is
   2694 executed before the main procedure is called.  This depends on the
   2695 languages used to write your program.  In C@t{++}, for instance,
   2696 constructors for static and global objects are executed before
   2697 @code{main} is called.  It is therefore possible that the debugger stops
   2698 before reaching the main procedure.  However, the temporary breakpoint
   2699 will remain to halt execution.
   2700 
   2701 Specify the arguments to give to your program as arguments to the
   2702 @samp{start} command.  These arguments will be given verbatim to the
   2703 underlying @samp{run} command.  Note that the same arguments will be
   2704 reused if no argument is provided during subsequent calls to
   2705 @samp{start} or @samp{run}.
   2706 
   2707 It is sometimes necessary to debug the program during elaboration.  In
   2708 these cases, using the @code{start} command would stop the execution
   2709 of your program too late, as the program would have already completed
   2710 the elaboration phase.  Under these circumstances, either insert
   2711 breakpoints in your elaboration code before running your program or
   2712 use the @code{starti} command.
   2713 
   2714 @kindex starti
   2715 @item starti
   2716 @cindex run to first instruction
   2717 The @samp{starti} command does the equivalent of setting a temporary
   2718 breakpoint at the first instruction of a program's execution and then
   2719 invoking the @samp{run} command.  For programs containing an
   2720 elaboration phase, the @code{starti} command will stop execution at
   2721 the start of the elaboration phase.
   2722 
   2723 @anchor{set exec-wrapper}
   2724 @kindex set exec-wrapper
   2725 @item set exec-wrapper @var{wrapper}
   2726 @itemx show exec-wrapper
   2727 @itemx unset exec-wrapper
   2728 When @samp{exec-wrapper} is set, the specified wrapper is used to
   2729 launch programs for debugging.  @value{GDBN} starts your program
   2730 with a shell command of the form @kbd{exec @var{wrapper}
   2731 @var{program}}.  Quoting is added to @var{program} and its
   2732 arguments, but not to @var{wrapper}, so you should add quotes if
   2733 appropriate for your shell.  The wrapper runs until it executes
   2734 your program, and then @value{GDBN} takes control.
   2735 
   2736 You can use any program that eventually calls @code{execve} with
   2737 its arguments as a wrapper.  Several standard Unix utilities do
   2738 this, e.g.@: @code{env} and @code{nohup}.  Any Unix shell script ending
   2739 with @code{exec "$@@"} will also work.
   2740 
   2741 For example, you can use @code{env} to pass an environment variable to
   2742 the debugged program, without setting the variable in your shell's
   2743 environment:
   2744 
   2745 @smallexample
   2746 (@value{GDBP}) set exec-wrapper env 'LD_PRELOAD=libtest.so'
   2747 (@value{GDBP}) run
   2748 @end smallexample
   2749 
   2750 This command is available when debugging locally on most targets, excluding
   2751 @sc{djgpp}, Cygwin, and MS Windows.
   2752 
   2753 @kindex set startup-with-shell
   2754 @anchor{set startup-with-shell}
   2755 @item set startup-with-shell
   2756 @itemx set startup-with-shell on
   2757 @itemx set startup-with-shell off
   2758 @itemx show startup-with-shell
   2759 On Unix systems, by default, if a shell is available on your target,
   2760 @value{GDBN}) uses it to start your program.  Arguments of the
   2761 @code{run} command are passed to the shell, which does variable
   2762 substitution, expands wildcard characters and performs redirection of
   2763 I/O.  In some circumstances, it may be useful to disable such use of a
   2764 shell, for example, when debugging the shell itself or diagnosing
   2765 startup failures such as:
   2766 
   2767 @smallexample
   2768 (@value{GDBP}) run
   2769 Starting program: ./a.out
   2770 During startup program terminated with signal SIGSEGV, Segmentation fault.
   2771 @end smallexample
   2772 
   2773 @noindent
   2774 which indicates the shell or the wrapper specified with
   2775 @samp{exec-wrapper} crashed, not your program.  Most often, this is
   2776 caused by something odd in your shell's non-interactive mode
   2777 initialization file---such as @file{.cshrc} for C-shell,
   2778 $@file{.zshenv} for the Z shell, or the file specified in the
   2779 @env{BASH_ENV} environment variable for BASH.
   2780 
   2781 @anchor{set auto-connect-native-target}
   2782 @kindex set auto-connect-native-target
   2783 @item set auto-connect-native-target
   2784 @itemx set auto-connect-native-target on
   2785 @itemx set auto-connect-native-target off
   2786 @itemx show auto-connect-native-target
   2787 
   2788 By default, if the current inferior is not connected to any target yet
   2789 (e.g., with @code{target remote}), the @code{run} command starts your
   2790 program as a native process under @value{GDBN}, on your local machine.
   2791 If you're sure you don't want to debug programs on your local machine,
   2792 you can tell @value{GDBN} to not connect to the native target
   2793 automatically with the @code{set auto-connect-native-target off}
   2794 command.
   2795 
   2796 If @code{on}, which is the default, and if the current inferior is not
   2797 connected to a target already, the @code{run} command automatically
   2798 connects to the native target, if one is available.
   2799 
   2800 If @code{off}, and if the current inferior is not connected to a
   2801 target already, the @code{run} command fails with an error:
   2802 
   2803 @smallexample
   2804 (@value{GDBP}) run
   2805 Don't know how to run.  Try "help target".
   2806 @end smallexample
   2807 
   2808 If the current inferior is already connected to a target, @value{GDBN}
   2809 always uses it with the @code{run} command.
   2810 
   2811 In any case, you can explicitly connect to the native target with the
   2812 @code{target native} command.  For example,
   2813 
   2814 @smallexample
   2815 (@value{GDBP}) set auto-connect-native-target off
   2816 (@value{GDBP}) run
   2817 Don't know how to run.  Try "help target".
   2818 (@value{GDBP}) target native
   2819 (@value{GDBP}) run
   2820 Starting program: ./a.out
   2821 [Inferior 1 (process 10421) exited normally]
   2822 @end smallexample
   2823 
   2824 In case you connected explicitly to the @code{native} target,
   2825 @value{GDBN} remains connected even if all inferiors exit, ready for
   2826 the next @code{run} command.  Use the @code{disconnect} command to
   2827 disconnect.
   2828 
   2829 Examples of other commands that likewise respect the
   2830 @code{auto-connect-native-target} setting: @code{attach}, @code{info
   2831 proc}, @code{info os}.
   2832 
   2833 @kindex set disable-randomization
   2834 @item set disable-randomization
   2835 @itemx set disable-randomization on
   2836 This option (enabled by default in @value{GDBN}) will turn off the native
   2837 randomization of the virtual address space of the started program.  This option
   2838 is useful for multiple debugging sessions to make the execution better
   2839 reproducible and memory addresses reusable across debugging sessions.
   2840 
   2841 This feature is implemented only on certain targets, including @sc{gnu}/Linux.
   2842 On @sc{gnu}/Linux you can get the same behavior using
   2843 
   2844 @smallexample
   2845 (@value{GDBP}) set exec-wrapper setarch `uname -m` -R
   2846 @end smallexample
   2847 
   2848 @item set disable-randomization off
   2849 Leave the behavior of the started executable unchanged.  Some bugs rear their
   2850 ugly heads only when the program is loaded at certain addresses.  If your bug
   2851 disappears when you run the program under @value{GDBN}, that might be because
   2852 @value{GDBN} by default disables the address randomization on platforms, such
   2853 as @sc{gnu}/Linux, which do that for stand-alone programs.  Use @kbd{set
   2854 disable-randomization off} to try to reproduce such elusive bugs.
   2855 
   2856 On targets where it is available, virtual address space randomization
   2857 protects the programs against certain kinds of security attacks.  In these
   2858 cases the attacker needs to know the exact location of a concrete executable
   2859 code.  Randomizing its location makes it impossible to inject jumps misusing
   2860 a code at its expected addresses.
   2861 
   2862 Prelinking shared libraries provides a startup performance advantage but it
   2863 makes addresses in these libraries predictable for privileged processes by
   2864 having just unprivileged access at the target system.  Reading the shared
   2865 library binary gives enough information for assembling the malicious code
   2866 misusing it.  Still even a prelinked shared library can get loaded at a new
   2867 random address just requiring the regular relocation process during the
   2868 startup.  Shared libraries not already prelinked are always loaded at
   2869 a randomly chosen address.
   2870 
   2871 Position independent executables (PIE) contain position independent code
   2872 similar to the shared libraries and therefore such executables get loaded at
   2873 a randomly chosen address upon startup.  PIE executables always load even
   2874 already prelinked shared libraries at a random address.  You can build such
   2875 executable using @command{gcc -fPIE -pie}.
   2876 
   2877 Heap (malloc storage), stack and custom mmap areas are always placed randomly
   2878 (as long as the randomization is enabled).
   2879 
   2880 @item show disable-randomization
   2881 Show the current setting of the explicit disable of the native randomization of
   2882 the virtual address space of the started program.
   2883 
   2884 @end table
   2885 
   2886 @node Arguments
   2887 @section Your Program's Arguments
   2888 
   2889 @cindex arguments (to your program)
   2890 The arguments to your program can be specified by the arguments of the
   2891 @code{run} command.
   2892 They are passed to a shell, which expands wildcard characters and
   2893 performs redirection of I/O, and thence to your program.  Your
   2894 @env{SHELL} environment variable (if it exists) specifies what shell
   2895 @value{GDBN} uses.  If you do not define @env{SHELL}, @value{GDBN} uses
   2896 the default shell (@file{/bin/sh} on Unix).
   2897 
   2898 On non-Unix systems, the program is usually invoked directly by
   2899 @value{GDBN}, which emulates I/O redirection via the appropriate system
   2900 calls, and the wildcard characters are expanded by the startup code of
   2901 the program, not by the shell.
   2902 
   2903 @code{run} with no arguments uses the same arguments used by the previous
   2904 @code{run}, or those set by the @code{set args} command.
   2905 
   2906 @table @code
   2907 @kindex set args
   2908 @item set args
   2909 Specify the arguments to be used the next time your program is run.  If
   2910 @code{set args} has no arguments, @code{run} executes your program
   2911 with no arguments.  Once you have run your program with arguments,
   2912 using @code{set args} before the next @code{run} is the only way to run
   2913 it again without arguments.
   2914 
   2915 @kindex show args
   2916 @item show args
   2917 Show the arguments to give your program when it is started.
   2918 @end table
   2919 
   2920 @node Environment
   2921 @section Your Program's Environment
   2922 
   2923 @cindex environment (of your program)
   2924 The @dfn{environment} consists of a set of environment variables and
   2925 their values.  Environment variables conventionally record such things as
   2926 your user name, your home directory, your terminal type, and your search
   2927 path for programs to run.  Usually you set up environment variables with
   2928 the shell and they are inherited by all the other programs you run.  When
   2929 debugging, it can be useful to try running your program with a modified
   2930 environment without having to start @value{GDBN} over again.
   2931 
   2932 @table @code
   2933 @kindex path
   2934 @item path @var{directory}
   2935 Add @var{directory} to the front of the @env{PATH} environment variable
   2936 (the search path for executables) that will be passed to your program.
   2937 The value of @env{PATH} used by @value{GDBN} does not change.
   2938 You may specify several directory names, separated by whitespace or by a
   2939 system-dependent separator character (@samp{:} on Unix, @samp{;} on
   2940 MS-DOS and MS-Windows).  If @var{directory} is already in the path, it
   2941 is moved to the front, so it is searched sooner.
   2942 
   2943 You can use the string @samp{$cwd} to refer to whatever is the current
   2944 working directory at the time @value{GDBN} searches the path.  If you
   2945 use @samp{.} instead, it refers to the directory where you executed the
   2946 @code{path} command.  @value{GDBN} replaces @samp{.} in the
   2947 @var{directory} argument (with the current path) before adding
   2948 @var{directory} to the search path.
   2949 @c 'path' is explicitly nonrepeatable, but RMS points out it is silly to
   2950 @c document that, since repeating it would be a no-op.
   2951 
   2952 @kindex show paths
   2953 @item show paths
   2954 Display the list of search paths for executables (the @env{PATH}
   2955 environment variable).
   2956 
   2957 @kindex show environment
   2958 @item show environment @r{[}@var{varname}@r{]}
   2959 Print the value of environment variable @var{varname} to be given to
   2960 your program when it starts.  If you do not supply @var{varname},
   2961 print the names and values of all environment variables to be given to
   2962 your program.  You can abbreviate @code{environment} as @code{env}.
   2963 
   2964 @kindex set environment
   2965 @anchor{set environment}
   2966 @item set environment @var{varname} @r{[}=@var{value}@r{]}
   2967 Set environment variable @var{varname} to @var{value}.  The value
   2968 changes for your program (and the shell @value{GDBN} uses to launch
   2969 it), not for @value{GDBN} itself.  The @var{value} may be any string; the
   2970 values of environment variables are just strings, and any
   2971 interpretation is supplied by your program itself.  The @var{value}
   2972 parameter is optional; if it is eliminated, the variable is set to a
   2973 null value.
   2974 @c "any string" here does not include leading, trailing
   2975 @c blanks. Gnu asks: does anyone care?
   2976 
   2977 For example, this command:
   2978 
   2979 @smallexample
   2980 set env USER = foo
   2981 @end smallexample
   2982 
   2983 @noindent
   2984 tells the debugged program, when subsequently run, that its user is named
   2985 @samp{foo}.  (The spaces around @samp{=} are used for clarity here; they
   2986 are not actually required.)
   2987 
   2988 Note that on Unix systems, @value{GDBN} runs your program via a shell,
   2989 which also inherits the environment set with @code{set environment}.
   2990 If necessary, you can avoid that by using the @samp{env} program as a
   2991 wrapper instead of using @code{set environment}.  @xref{set
   2992 exec-wrapper}, for an example doing just that.
   2993 
   2994 Environment variables that are set by the user are also transmitted to
   2995 @command{gdbserver} to be used when starting the remote inferior.
   2996 @pxref{QEnvironmentHexEncoded}.
   2997 
   2998 @kindex unset environment
   2999 @anchor{unset environment}
   3000 @item unset environment @var{varname}
   3001 Remove variable @var{varname} from the environment to be passed to your
   3002 program.  This is different from @samp{set env @var{varname} =};
   3003 @code{unset environment} removes the variable from the environment,
   3004 rather than assigning it an empty value.
   3005 
   3006 Environment variables that are unset by the user are also unset on
   3007 @command{gdbserver} when starting the remote inferior.
   3008 @pxref{QEnvironmentUnset}.
   3009 @end table
   3010 
   3011 @emph{Warning:} On Unix systems, @value{GDBN} runs your program using
   3012 the shell indicated by your @env{SHELL} environment variable if it
   3013 exists (or @code{/bin/sh} if not).  If your @env{SHELL} variable
   3014 names a shell that runs an initialization file when started
   3015 non-interactively---such as @file{.cshrc} for C-shell, $@file{.zshenv}
   3016 for the Z shell, or the file specified in the @env{BASH_ENV}
   3017 environment variable for BASH---any variables you set in that file
   3018 affect your program.  You may wish to move setting of environment
   3019 variables to files that are only run when you sign on, such as
   3020 @file{.login} or @file{.profile}.
   3021 
   3022 @node Working Directory
   3023 @section Your Program's Working Directory
   3024 
   3025 @cindex working directory (of your program)
   3026 Each time you start your program with @code{run}, the inferior will be
   3027 initialized with the current working directory specified by the
   3028 @kbd{set cwd} command.  If no directory has been specified by this
   3029 command, then the inferior will inherit @value{GDBN}'s current working
   3030 directory as its working directory if native debugging, or it will
   3031 inherit the remote server's current working directory if remote
   3032 debugging.
   3033 
   3034 @table @code
   3035 @kindex set cwd
   3036 @cindex change inferior's working directory
   3037 @anchor{set cwd command}
   3038 @item set cwd @r{[}@var{directory}@r{]}
   3039 Set the inferior's working directory to @var{directory}, which will be
   3040 @code{glob}-expanded in order to resolve tildes (@file{~}).  If no
   3041 argument has been specified, the command clears the setting and resets
   3042 it to an empty state.  This setting has no effect on @value{GDBN}'s
   3043 working directory, and it only takes effect the next time you start
   3044 the inferior.  The @file{~} in @var{directory} is a short for the
   3045 @dfn{home directory}, usually pointed to by the @env{HOME} environment
   3046 variable.  On MS-Windows, if @env{HOME} is not defined, @value{GDBN}
   3047 uses the concatenation of @env{HOMEDRIVE} and @env{HOMEPATH} as
   3048 fallback.
   3049 
   3050 You can also change @value{GDBN}'s current working directory by using
   3051 the @code{cd} command.
   3052 @xref{cd command}.
   3053 
   3054 @kindex show cwd
   3055 @cindex show inferior's working directory
   3056 @item show cwd
   3057 Show the inferior's working directory.  If no directory has been
   3058 specified by @kbd{set cwd}, then the default inferior's working
   3059 directory is the same as @value{GDBN}'s working directory.
   3060 
   3061 @kindex cd
   3062 @cindex change @value{GDBN}'s working directory
   3063 @anchor{cd command}
   3064 @item cd @r{[}@var{directory}@r{]}
   3065 Set the @value{GDBN} working directory to @var{directory}.  If not
   3066 given, @var{directory} uses @file{'~'}.
   3067 
   3068 The @value{GDBN} working directory serves as a default for the
   3069 commands that specify files for @value{GDBN} to operate on.
   3070 @xref{Files, ,Commands to Specify Files}.
   3071 @xref{set cwd command}.
   3072 
   3073 @kindex pwd
   3074 @item pwd
   3075 Print the @value{GDBN} working directory.
   3076 @end table
   3077 
   3078 It is generally impossible to find the current working directory of
   3079 the process being debugged (since a program can change its directory
   3080 during its run).  If you work on a system where @value{GDBN} supports
   3081 the @code{info proc} command (@pxref{Process Information}), you can
   3082 use the @code{info proc} command to find out the
   3083 current working directory of the debuggee.
   3084 
   3085 @node Input/Output
   3086 @section Your Program's Input and Output
   3087 
   3088 @cindex redirection
   3089 @cindex i/o
   3090 @cindex terminal
   3091 By default, the program you run under @value{GDBN} does input and output to
   3092 the same terminal that @value{GDBN} uses.  @value{GDBN} switches the terminal
   3093 to its own terminal modes to interact with you, but it records the terminal
   3094 modes your program was using and switches back to them when you continue
   3095 running your program.
   3096 
   3097 @table @code
   3098 @kindex info terminal
   3099 @item info terminal
   3100 Displays information recorded by @value{GDBN} about the terminal modes your
   3101 program is using.
   3102 @end table
   3103 
   3104 You can redirect your program's input and/or output using shell
   3105 redirection with the @code{run} command.  For example,
   3106 
   3107 @smallexample
   3108 run > outfile
   3109 @end smallexample
   3110 
   3111 @noindent
   3112 starts your program, diverting its output to the file @file{outfile}.
   3113 
   3114 @kindex tty
   3115 @cindex controlling terminal
   3116 Another way to specify where your program should do input and output is
   3117 with the @code{tty} command.  This command accepts a file name as
   3118 argument, and causes this file to be the default for future @code{run}
   3119 commands.  It also resets the controlling terminal for the child
   3120 process, for future @code{run} commands.  For example,
   3121 
   3122 @smallexample
   3123 tty /dev/ttyb
   3124 @end smallexample
   3125 
   3126 @noindent
   3127 directs that processes started with subsequent @code{run} commands
   3128 default to do input and output on the terminal @file{/dev/ttyb} and have
   3129 that as their controlling terminal.
   3130 
   3131 An explicit redirection in @code{run} overrides the @code{tty} command's
   3132 effect on the input/output device, but not its effect on the controlling
   3133 terminal.
   3134 
   3135 When you use the @code{tty} command or redirect input in the @code{run}
   3136 command, only the input @emph{for your program} is affected.  The input
   3137 for @value{GDBN} still comes from your terminal.  @code{tty} is an alias
   3138 for @code{set inferior-tty}.
   3139 
   3140 @cindex inferior tty
   3141 @cindex set inferior controlling terminal
   3142 You can use the @code{show inferior-tty} command to tell @value{GDBN} to
   3143 display the name of the terminal that will be used for future runs of your
   3144 program.
   3145 
   3146 @table @code
   3147 @item set inferior-tty [ @var{tty} ]
   3148 @kindex set inferior-tty
   3149 Set the tty for the program being debugged to @var{tty}.  Omitting @var{tty}
   3150 restores the default behavior, which is to use the same terminal as
   3151 @value{GDBN}.
   3152 
   3153 @item show inferior-tty
   3154 @kindex show inferior-tty
   3155 Show the current tty for the program being debugged.
   3156 @end table
   3157 
   3158 @node Attach
   3159 @section Debugging an Already-running Process
   3160 @kindex attach
   3161 @cindex attach
   3162 
   3163 @table @code
   3164 @item attach @var{process-id}
   3165 This command attaches to a running process---one that was started
   3166 outside @value{GDBN}.  (@code{info files} shows your active
   3167 targets.)  The command takes as argument a process ID.  The usual way to
   3168 find out the @var{process-id} of a Unix process is with the @code{ps} utility,
   3169 or with the @samp{jobs -l} shell command.
   3170 
   3171 @code{attach} does not repeat if you press @key{RET} a second time after
   3172 executing the command.
   3173 @end table
   3174 
   3175 To use @code{attach}, your program must be running in an environment
   3176 which supports processes; for example, @code{attach} does not work for
   3177 programs on bare-board targets that lack an operating system.  You must
   3178 also have permission to send the process a signal.
   3179 
   3180 When you use @code{attach}, the debugger finds the program running in
   3181 the process first by looking in the current working directory, then (if
   3182 the program is not found) by using the source file search path
   3183 (@pxref{Source Path, ,Specifying Source Directories}).  You can also use
   3184 the @code{file} command to load the program.  @xref{Files, ,Commands to
   3185 Specify Files}.
   3186 
   3187 @anchor{set exec-file-mismatch}
   3188 If the debugger can determine that the executable file running in the
   3189 process it is attaching to does not match the current exec-file loaded
   3190 by @value{GDBN}, the option @code{exec-file-mismatch} specifies how to
   3191 handle the mismatch.  @value{GDBN} tries to compare the files by
   3192 comparing their build IDs (@pxref{build ID}), if available.
   3193 
   3194 @table @code
   3195 @kindex exec-file-mismatch
   3196 @cindex set exec-file-mismatch
   3197 @item set exec-file-mismatch @samp{ask|warn|off}
   3198 
   3199 Whether to detect mismatch between the current executable file loaded
   3200 by @value{GDBN} and the executable file used to start the process.  If
   3201 @samp{ask}, the default, display a warning and ask the user whether to
   3202 load the process executable file; if @samp{warn}, just display a
   3203 warning; if @samp{off}, don't attempt to detect a mismatch.
   3204 If the user confirms loading the process executable file, then its symbols
   3205 will be loaded as well.
   3206 
   3207 @cindex show exec-file-mismatch
   3208 @item show exec-file-mismatch
   3209 Show the current value of @code{exec-file-mismatch}.
   3210 
   3211 @end table
   3212 
   3213 The first thing @value{GDBN} does after arranging to debug the specified
   3214 process is to stop it.  You can examine and modify an attached process
   3215 with all the @value{GDBN} commands that are ordinarily available when
   3216 you start processes with @code{run}.  You can insert breakpoints; you
   3217 can step and continue; you can modify storage.  If you would rather the
   3218 process continue running, you may use the @code{continue} command after
   3219 attaching @value{GDBN} to the process.
   3220 
   3221 @table @code
   3222 @kindex detach
   3223 @item detach
   3224 When you have finished debugging the attached process, you can use the
   3225 @code{detach} command to release it from @value{GDBN} control.  Detaching
   3226 the process continues its execution.  After the @code{detach} command,
   3227 that process and @value{GDBN} become completely independent once more, and you
   3228 are ready to @code{attach} another process or start one with @code{run}.
   3229 @code{detach} does not repeat if you press @key{RET} again after
   3230 executing the command.
   3231 @end table
   3232 
   3233 If you exit @value{GDBN} while you have an attached process, you detach
   3234 that process.  If you use the @code{run} command, you kill that process.
   3235 By default, @value{GDBN} asks for confirmation if you try to do either of these
   3236 things; you can control whether or not you need to confirm by using the
   3237 @code{set confirm} command (@pxref{Messages/Warnings, ,Optional Warnings and
   3238 Messages}).
   3239 
   3240 @node Kill Process
   3241 @section Killing the Child Process
   3242 
   3243 @table @code
   3244 @kindex kill
   3245 @item kill
   3246 Kill the child process in which your program is running under @value{GDBN}.
   3247 @end table
   3248 
   3249 This command is useful if you wish to debug a core dump instead of a
   3250 running process.  @value{GDBN} ignores any core dump file while your program
   3251 is running.
   3252 
   3253 On some operating systems, a program cannot be executed outside @value{GDBN}
   3254 while you have breakpoints set on it inside @value{GDBN}.  You can use the
   3255 @code{kill} command in this situation to permit running your program
   3256 outside the debugger.
   3257 
   3258 The @code{kill} command is also useful if you wish to recompile and
   3259 relink your program, since on many systems it is impossible to modify an
   3260 executable file while it is running in a process.  In this case, when you
   3261 next type @code{run}, @value{GDBN} notices that the file has changed, and
   3262 reads the symbol table again (while trying to preserve your current
   3263 breakpoint settings).
   3264 
   3265 @node Inferiors Connections and Programs
   3266 @section Debugging Multiple Inferiors Connections and Programs
   3267 
   3268 @value{GDBN} lets you run and debug multiple programs in a single
   3269 session.  In addition, @value{GDBN} on some systems may let you run
   3270 several programs simultaneously (otherwise you have to exit from one
   3271 before starting another).  On some systems @value{GDBN} may even let
   3272 you debug several programs simultaneously on different remote systems.
   3273 In the most general case, you can have multiple threads of execution
   3274 in each of multiple processes, launched from multiple executables,
   3275 running on different machines.
   3276 
   3277 @cindex inferior
   3278 @value{GDBN} represents the state of each program execution with an
   3279 object called an @dfn{inferior}.  An inferior typically corresponds to
   3280 a process, but is more general and applies also to targets that do not
   3281 have processes.  Inferiors may be created before a process runs, and
   3282 may be retained after a process exits.  Inferiors have unique
   3283 identifiers that are different from process ids.  Usually each
   3284 inferior will also have its own distinct address space, although some
   3285 embedded targets may have several inferiors running in different parts
   3286 of a single address space.  Each inferior may in turn have multiple
   3287 threads running in it.
   3288 
   3289 @cindex ID list
   3290 The commands @code{info inferiors} and @code{info connections}, which will be
   3291 introduced below, accept a space-separated @dfn{ID list} as their argument
   3292 specifying one or more elements on which to operate.  A list element can be
   3293 either a single non-negative number, like @samp{5}, or an ascending range of
   3294 such numbers, like @samp{5-7}.  A list can consist of any combination of such
   3295 elements, even duplicates or overlapping ranges are valid.  E.g.@:
   3296 @samp{1 4-6 5 4-4} or @samp{1 2 4-7}.
   3297 
   3298 To find out what inferiors exist at any moment, use @w{@code{info
   3299 inferiors}}:
   3300 
   3301 @table @code
   3302 @kindex info inferiors [ @var{id}@dots{} ]
   3303 @item info inferiors
   3304 Print a list of all inferiors currently being managed by @value{GDBN}.
   3305 By default all inferiors are printed, but the ID list @var{id}@dots{} can be
   3306 used to limit the display to just the requested inferiors.
   3307 
   3308 @value{GDBN} displays for each inferior (in this order):
   3309 
   3310 @enumerate
   3311 @item
   3312 the inferior number assigned by @value{GDBN}
   3313 
   3314 @item
   3315 the target system's inferior identifier
   3316 
   3317 @item
   3318 the target connection the inferior is bound to, including the unique
   3319 connection number assigned by @value{GDBN}, and the protocol used by
   3320 the connection.
   3321 
   3322 @item
   3323 the name of the executable the inferior is running.
   3324 
   3325 @end enumerate
   3326 
   3327 @noindent
   3328 An asterisk @samp{*} preceding the @value{GDBN} inferior number
   3329 indicates the current inferior.
   3330 
   3331 For example,
   3332 @end table
   3333 @c end table here to get a little more width for example
   3334 
   3335 @smallexample
   3336 (@value{GDBP}) info inferiors
   3337   Num  Description       Connection                      Executable
   3338 * 1    process 3401      1 (native)                      goodbye
   3339   2    process 2307      2 (extended-remote host:10000)  hello
   3340 @end smallexample
   3341 
   3342 To get information about the current inferior, use @code{inferior}:
   3343 
   3344 @table @code
   3345 @kindex inferior
   3346 @item inferior
   3347 Shows information about the current inferior.
   3348 
   3349 For example,
   3350 @end table
   3351 @c end table here to get a little more width for example
   3352 
   3353 @smallexample
   3354 (@value{GDBP}) inferior
   3355 [Current inferior is 1 [process 3401] (helloworld)]
   3356 @end smallexample
   3357 
   3358 To find out what open target connections exist at any moment, use
   3359 @w{@code{info connections}}:
   3360 
   3361 @table @code
   3362 @kindex info connections [ @var{id}@dots{} ]
   3363 @item info connections
   3364 Print a list of all open target connections currently being managed by
   3365 @value{GDBN}.  By default all connections are printed, but the ID list
   3366 @var{id}@dots{} can be used to limit the display to just the requested
   3367 connections.
   3368 
   3369 @value{GDBN} displays for each connection (in this order):
   3370 
   3371 @enumerate
   3372 @item
   3373 the connection number assigned by @value{GDBN}.
   3374 
   3375 @item
   3376 the protocol used by the connection.
   3377 
   3378 @item
   3379 a textual description of the protocol used by the connection.
   3380 
   3381 @end enumerate
   3382 
   3383 @noindent
   3384 An asterisk @samp{*} preceding the connection number indicates the
   3385 connection of the current inferior.
   3386 
   3387 For example,
   3388 @end table
   3389 @c end table here to get a little more width for example
   3390 
   3391 @smallexample
   3392 (@value{GDBP}) info connections
   3393   Num  What                        Description
   3394 * 1    extended-remote host:10000  Extended remote serial target in gdb-specific protocol
   3395   2    native                      Native process
   3396   3    core                        Local core dump file
   3397 @end smallexample
   3398 
   3399 To switch focus between inferiors, use the @code{inferior} command:
   3400 
   3401 @table @code
   3402 @kindex inferior @var{infno}
   3403 @item inferior @var{infno}
   3404 Make inferior number @var{infno} the current inferior.  The argument
   3405 @var{infno} is the inferior number assigned by @value{GDBN}, as shown
   3406 in the first field of the @samp{info inferiors} display.
   3407 @end table
   3408 
   3409 @vindex $_inferior@r{, convenience variable}
   3410 The debugger convenience variable @samp{$_inferior} contains the
   3411 number of the current inferior.  You may find this useful in writing
   3412 breakpoint conditional expressions, command scripts, and so forth.
   3413 @xref{Convenience Vars,, Convenience Variables}, for general
   3414 information on convenience variables.
   3415 
   3416 You can get multiple executables into a debugging session via the
   3417 @code{add-inferior} and @w{@code{clone-inferior}} commands.  On some
   3418 systems @value{GDBN} can add inferiors to the debug session
   3419 automatically by following calls to @code{fork} and @code{exec}.  To
   3420 remove inferiors from the debugging session use the
   3421 @w{@code{remove-inferiors}} command.
   3422 
   3423 @table @code
   3424 @anchor{add_inferior_cli}
   3425 @kindex add-inferior
   3426 @item add-inferior [ -copies @var{n} ] [ -exec @var{executable} ] [-no-connection ]
   3427 Adds @var{n} inferiors to be run using @var{executable} as the
   3428 executable; @var{n} defaults to 1.  If no executable is specified,
   3429 the inferiors begins empty, with no program.  You can still assign or
   3430 change the program assigned to the inferior at any time by using the
   3431 @code{file} command with the executable name as its argument.
   3432 
   3433 By default, the new inferior begins connected to the same target
   3434 connection as the current inferior.  For example, if the current
   3435 inferior was connected to @code{gdbserver} with @code{target remote},
   3436 then the new inferior will be connected to the same @code{gdbserver}
   3437 instance.  The @samp{-no-connection} option starts the new inferior
   3438 with no connection yet.  You can then for example use the @code{target
   3439 remote} command to connect to some other @code{gdbserver} instance,
   3440 use @code{run} to spawn a local program, etc.
   3441 
   3442 @kindex clone-inferior
   3443 @item clone-inferior [ -copies @var{n} ] [ @var{infno} ]
   3444 Adds @var{n} inferiors ready to execute the same program as inferior
   3445 @var{infno}; @var{n} defaults to 1, and @var{infno} defaults to the
   3446 number of the current inferior.  This command copies the values of the
   3447 @var{args}, @w{@var{inferior-tty}} and @var{cwd} properties from the
   3448 current inferior to the new one.  It also propagates changes the user
   3449 made to environment variables using the @w{@code{set environment}} and
   3450 @w{@code{unset environment}} commands.  This is a convenient command
   3451 when you want to run another instance of the inferior you are debugging.
   3452 
   3453 @smallexample
   3454 (@value{GDBP}) info inferiors
   3455   Num  Description       Connection   Executable
   3456 * 1    process 29964     1 (native)   helloworld
   3457 (@value{GDBP}) clone-inferior
   3458 Added inferior 2.
   3459 1 inferiors added.
   3460 (@value{GDBP}) info inferiors
   3461   Num  Description       Connection   Executable
   3462 * 1    process 29964     1 (native)   helloworld
   3463   2    <null>            1 (native)   helloworld
   3464 @end smallexample
   3465 
   3466 You can now simply switch focus to inferior 2 and run it.
   3467 
   3468 @anchor{remove_inferiors_cli}
   3469 @kindex remove-inferiors
   3470 @item remove-inferiors @var{infno}@dots{}
   3471 Removes the inferior or inferiors @var{infno}@dots{}.  It is not
   3472 possible to remove an inferior that is running with this command.  For
   3473 those, use the @code{kill} or @code{detach} command first.
   3474 
   3475 @end table
   3476 
   3477 To quit debugging one of the running inferiors that is not the current
   3478 inferior, you can either detach from it by using the @w{@code{detach
   3479 inferior}} command (allowing it to run independently), or kill it
   3480 using the @w{@code{kill inferiors}} command:
   3481 
   3482 @table @code
   3483 @kindex detach inferiors @var{infno}@dots{}
   3484 @item detach inferior @var{infno}@dots{}
   3485 Detach from the inferior or inferiors identified by @value{GDBN}
   3486 inferior number(s) @var{infno}@dots{}.  Note that the inferior's entry
   3487 still stays on the list of inferiors shown by @code{info inferiors},
   3488 but its Description will show @samp{<null>}.
   3489 
   3490 @kindex kill inferiors @var{infno}@dots{}
   3491 @item kill inferiors @var{infno}@dots{}
   3492 Kill the inferior or inferiors identified by @value{GDBN} inferior
   3493 number(s) @var{infno}@dots{}.  Note that the inferior's entry still
   3494 stays on the list of inferiors shown by @code{info inferiors}, but its
   3495 Description will show @samp{<null>}.
   3496 @end table
   3497 
   3498 After the successful completion of a command such as @code{detach},
   3499 @code{detach inferiors}, @code{kill} or @code{kill inferiors}, or after
   3500 a normal process exit, the inferior is still valid and listed with
   3501 @code{info inferiors}, ready to be restarted.
   3502 
   3503 
   3504 To be notified when inferiors are started or exit under @value{GDBN}'s
   3505 control use @w{@code{set print inferior-events}}:
   3506 
   3507 @table @code
   3508 @kindex set print inferior-events
   3509 @cindex print messages on inferior start and exit
   3510 @item set print inferior-events
   3511 @itemx set print inferior-events on
   3512 @itemx set print inferior-events off
   3513 The @code{set print inferior-events} command allows you to enable or
   3514 disable printing of messages when @value{GDBN} notices that new
   3515 inferiors have started or that inferiors have exited or have been
   3516 detached.  By default, these messages will be printed.
   3517 
   3518 @kindex show print inferior-events
   3519 @item show print inferior-events
   3520 Show whether messages will be printed when @value{GDBN} detects that
   3521 inferiors have started, exited or have been detached.
   3522 @end table
   3523 
   3524 Many commands will work the same with multiple programs as with a
   3525 single program: e.g., @code{print myglobal} will simply display the
   3526 value of @code{myglobal} in the current inferior.
   3527 
   3528 
   3529 Occasionally, when debugging @value{GDBN} itself, it may be useful to
   3530 get more info about the relationship of inferiors, programs, address
   3531 spaces in a debug session.  You can do that with the @w{@code{maint
   3532 info program-spaces}} command.
   3533 
   3534 @table @code
   3535 @kindex maint info program-spaces
   3536 @item maint info program-spaces
   3537 Print a list of all program spaces currently being managed by
   3538 @value{GDBN}.
   3539 
   3540 @value{GDBN} displays for each program space (in this order):
   3541 
   3542 @enumerate
   3543 @item
   3544 the program space number assigned by @value{GDBN}
   3545 
   3546 @item
   3547 the name of the executable loaded into the program space, with e.g.,
   3548 the @code{file} command.
   3549 
   3550 @item
   3551 the name of the core file loaded into the program space, with e.g.,
   3552 the @code{core-file} command.
   3553 
   3554 @end enumerate
   3555 
   3556 @noindent
   3557 An asterisk @samp{*} preceding the @value{GDBN} program space number
   3558 indicates the current program space.
   3559 
   3560 In addition, below each program space line, @value{GDBN} prints extra
   3561 information that isn't suitable to display in tabular form.  For
   3562 example, the list of inferiors bound to the program space.
   3563 
   3564 @smallexample
   3565 (@value{GDBP}) maint info program-spaces
   3566   Id   Executable        Core File
   3567 * 1    hello
   3568   2    goodbye
   3569         Bound inferiors: ID 1 (process 21561)
   3570 @end smallexample
   3571 
   3572 Here we can see that no inferior is running the program @code{hello},
   3573 while @code{process 21561} is running the program @code{goodbye}.  On
   3574 some targets, it is possible that multiple inferiors are bound to the
   3575 same program space.  The most common example is that of debugging both
   3576 the parent and child processes of a @code{vfork} call.  For example,
   3577 
   3578 @smallexample
   3579 (@value{GDBP}) maint info program-spaces
   3580   Id   Executable        Core File
   3581 * 1    vfork-test
   3582         Bound inferiors: ID 2 (process 18050), ID 1 (process 18045)
   3583 @end smallexample
   3584 
   3585 Here, both inferior 2 and inferior 1 are running in the same program
   3586 space as a result of inferior 1 having executed a @code{vfork} call.
   3587 @end table
   3588 
   3589 @menu
   3590 * Inferior-Specific Breakpoints::	Controlling breakpoints
   3591 @end menu
   3592 
   3593 @node Inferior-Specific Breakpoints
   3594 @subsection Inferior-Specific Breakpoints
   3595 
   3596 When debugging multiple inferiors, you can choose whether to set
   3597 breakpoints for all inferiors, or for a particular inferior.
   3598 
   3599 @table @code
   3600 @cindex breakpoints and inferiors
   3601 @cindex inferior-specific breakpoints
   3602 @kindex break @dots{} inferior @var{inferior-id}
   3603 @item break @var{locspec} inferior @var{inferior-id}
   3604 @itemx break @var{locspec} inferior @var{inferior-id} if @dots{}
   3605 @var{locspec} specifies a code location or locations in your program.
   3606 @xref{Location Specifications}, for details.
   3607 
   3608 Use the qualifier @samp{inferior @var{inferior-id}} with a breakpoint
   3609 command to specify that you only want @value{GDBN} to stop when a
   3610 particular inferior reaches this breakpoint.  The @var{inferior-id}
   3611 specifier is one of the inferior identifiers assigned by @value{GDBN},
   3612 shown in the first column of the @samp{info inferiors} output.
   3613 
   3614 If you do not specify @samp{inferior @var{inferior-id}} when you set a
   3615 breakpoint, the breakpoint applies to @emph{all} inferiors of your
   3616 program.
   3617 
   3618 You can use the @code{inferior} qualifier on conditional breakpoints as
   3619 well; in this case, place @samp{inferior @var{inferior-id}} before or
   3620 after the breakpoint condition, like this:
   3621 
   3622 @smallexample
   3623 (@value{GDBP}) break frik.c:13 inferior 2 if bartab > lim
   3624 @end smallexample
   3625 @end table
   3626 
   3627 Inferior-specific breakpoints are automatically deleted when the
   3628 corresponding inferior is removed from @value{GDBN}.  For example:
   3629 
   3630 @smallexample
   3631 (@value{GDBP}) remove-inferiors 2
   3632 Inferior-specific breakpoint 3 deleted - inferior 2 has been removed.
   3633 @end smallexample
   3634 
   3635 A breakpoint can't be both inferior-specific and thread-specific
   3636 (@pxref{Thread-Specific Breakpoints}), or task-specific (@pxref{Ada
   3637 Tasks}); using more than one of the @code{inferior}, @code{thread}, or
   3638 @code{task} keywords when creating a breakpoint will give an error.
   3639 
   3640 @node Threads
   3641 @section Debugging Programs with Multiple Threads
   3642 
   3643 @cindex threads of execution
   3644 @cindex multiple threads
   3645 @cindex switching threads
   3646 In some operating systems, such as GNU/Linux and Solaris, a single program
   3647 may have more than one @dfn{thread} of execution.  The precise semantics
   3648 of threads differ from one operating system to another, but in general
   3649 the threads of a single program are akin to multiple processes---except
   3650 that they share one address space (that is, they can all examine and
   3651 modify the same variables).  On the other hand, each thread has its own
   3652 registers and execution stack, and perhaps private memory.
   3653 
   3654 @value{GDBN} provides these facilities for debugging multi-thread
   3655 programs:
   3656 
   3657 @itemize @bullet
   3658 @item automatic notification of new threads
   3659 @item @samp{thread @var{thread-id}}, a command to switch among threads
   3660 @item @samp{info threads}, a command to inquire about existing threads
   3661 @item @samp{thread apply [@var{thread-id-list} | all] @var{args}},
   3662 a command to apply a command to a list of threads
   3663 @item thread-specific breakpoints
   3664 @item @samp{set print thread-events}, which controls printing of 
   3665 messages on thread start and exit.
   3666 @item @samp{set libthread-db-search-path @var{path}}, which lets
   3667 the user specify which @code{libthread_db} to use if the default choice
   3668 isn't compatible with the program.
   3669 @end itemize
   3670 
   3671 @cindex focus of debugging
   3672 @cindex current thread
   3673 The @value{GDBN} thread debugging facility allows you to observe all
   3674 threads while your program runs---but whenever @value{GDBN} takes
   3675 control, one thread in particular is always the focus of debugging.
   3676 This thread is called the @dfn{current thread}.  Debugging commands show
   3677 program information from the perspective of the current thread.
   3678 
   3679 @cindex @code{New} @var{systag} message
   3680 @cindex thread identifier (system)
   3681 @c FIXME-implementors!! It would be more helpful if the [New...] message
   3682 @c included GDB's numeric thread handle, so you could just go to that
   3683 @c thread without first checking `info threads'.
   3684 Whenever @value{GDBN} detects a new thread in your program, it displays
   3685 the target system's identification for the thread with a message in the
   3686 form @samp{[New @var{systag}]}, where @var{systag} is a thread identifier
   3687 whose form varies depending on the particular system.  For example, on
   3688 @sc{gnu}/Linux, you might see
   3689 
   3690 @smallexample
   3691 [New Thread 0x41e02940 (LWP 25582)]
   3692 @end smallexample
   3693 
   3694 @noindent
   3695 when @value{GDBN} notices a new thread.  In contrast, on other systems,
   3696 the @var{systag} is simply something like @samp{process 368}, with no
   3697 further qualifier.
   3698 
   3699 @c FIXME!! (1) Does the [New...] message appear even for the very first
   3700 @c         thread of a program, or does it only appear for the
   3701 @c         second---i.e.@: when it becomes obvious we have a multithread
   3702 @c         program?
   3703 @c         (2) *Is* there necessarily a first thread always?  Or do some
   3704 @c         multithread systems permit starting a program with multiple
   3705 @c         threads ab initio?
   3706 
   3707 @anchor{thread numbers}
   3708 @cindex thread number, per inferior
   3709 @cindex thread identifier (GDB)
   3710 For debugging purposes, @value{GDBN} associates its own thread number
   3711 ---always a single integer---with each thread of an inferior.  This
   3712 number is unique between all threads of an inferior, but not unique
   3713 between threads of different inferiors.
   3714 
   3715 @cindex qualified thread ID
   3716 You can refer to a given thread in an inferior using the qualified
   3717 @var{inferior-num}.@var{thread-num} syntax, also known as
   3718 @dfn{qualified thread ID}, with @var{inferior-num} being the inferior
   3719 number and @var{thread-num} being the thread number of the given
   3720 inferior.  For example, thread @code{2.3} refers to thread number 3 of
   3721 inferior 2.  If you omit @var{inferior-num} (e.g., @code{thread 3}),
   3722 then @value{GDBN} infers you're referring to a thread of the current
   3723 inferior.
   3724 
   3725 Until you create a second inferior, @value{GDBN} does not show the
   3726 @var{inferior-num} part of thread IDs, even though you can always use
   3727 the full @var{inferior-num}.@var{thread-num} form to refer to threads
   3728 of inferior 1, the initial inferior.
   3729 
   3730 @anchor{thread ID lists}
   3731 @cindex thread ID lists
   3732 Some commands accept a space-separated @dfn{thread ID list} as
   3733 argument.  A list element can be:
   3734 
   3735 @enumerate
   3736 @item
   3737 A thread ID as shown in the first field of the @samp{info threads}
   3738 display, with or without an inferior qualifier.  E.g., @samp{2.1} or
   3739 @samp{1}.
   3740 
   3741 @item
   3742 A range of thread numbers, again with or without an inferior
   3743 qualifier, as in @var{inf}.@var{thr1}-@var{thr2} or
   3744 @var{thr1}-@var{thr2}.  E.g., @samp{1.2-4} or @samp{2-4}.
   3745 
   3746 @item
   3747 All threads of an inferior, specified with a star wildcard, with or
   3748 without an inferior qualifier, as in @var{inf}.@code{*} (e.g.,
   3749 @samp{1.*}) or @code{*}.  The former refers to all threads of the
   3750 given inferior, and the latter form without an inferior qualifier
   3751 refers to all threads of the current inferior.
   3752 
   3753 @end enumerate
   3754 
   3755 For example, if the current inferior is 1, and inferior 7 has one
   3756 thread with ID 7.1, the thread list @samp{1 2-3 4.5 6.7-9 7.*}
   3757 includes threads 1 to 3 of inferior 1, thread 5 of inferior 4, threads
   3758 7 to 9 of inferior 6 and all threads of inferior 7.  That is, in
   3759 expanded qualified form, the same as @samp{1.1 1.2 1.3 4.5 6.7 6.8 6.9
   3760 7.1}.
   3761 
   3762 
   3763 @anchor{global thread numbers}
   3764 @cindex global thread number
   3765 @cindex global thread identifier (GDB)
   3766 In addition to a @emph{per-inferior} number, each thread is also
   3767 assigned a unique @emph{global} number, also known as @dfn{global
   3768 thread ID}, a single integer.  Unlike the thread number component of
   3769 the thread ID, no two threads have the same global ID, even when
   3770 you're debugging multiple inferiors.
   3771 
   3772 From @value{GDBN}'s perspective, a process always has at least one
   3773 thread.  In other words, @value{GDBN} assigns a thread number to the
   3774 program's ``main thread'' even if the program is not multi-threaded.
   3775 
   3776 @vindex $_thread@r{, convenience variable}
   3777 @vindex $_gthread@r{, convenience variable}
   3778 @vindex $_inferior_thread_count@r{, convenience variable}
   3779 The debugger convenience variables @samp{$_thread} and
   3780 @samp{$_gthread} contain, respectively, the per-inferior thread number
   3781 and the global thread number of the current thread.  You may find this
   3782 useful in writing breakpoint conditional expressions, command scripts,
   3783 and so forth.  The convenience variable @samp{$_inferior_thread_count}
   3784 contains the number of live threads in the current inferior.
   3785 @xref{Convenience Vars,, Convenience Variables}, for general
   3786 information on convenience variables.
   3787 
   3788 When running in non-stop mode (@pxref{Non-Stop Mode}), where new
   3789 threads can be created, and existing threads exit, at any time,
   3790 @samp{$_inferior_thread_count} could return a different value each
   3791 time it is evaluated.
   3792 
   3793 If @value{GDBN} detects the program is multi-threaded, it augments the
   3794 usual message about stopping at a breakpoint with the ID and name of
   3795 the thread that hit the breakpoint.
   3796 
   3797 @smallexample
   3798 Thread 2 "client" hit Breakpoint 1, send_message () at client.c:68
   3799 @end smallexample
   3800 
   3801 Likewise when the program receives a signal:
   3802 
   3803 @smallexample
   3804 Thread 1 "main" received signal SIGINT, Interrupt.
   3805 @end smallexample
   3806 
   3807 @table @code
   3808 @anchor{info_threads}
   3809 @kindex info threads
   3810 @item info threads @r{[}-gid@r{]} @r{[}@var{thread-id-list}@r{]}
   3811 
   3812 Display information about one or more threads.  With no arguments
   3813 displays information about all threads.  You can specify the list of
   3814 threads that you want to display using the thread ID list syntax
   3815 (@pxref{thread ID lists}).
   3816 
   3817 @value{GDBN} displays for each thread (in this order):
   3818 
   3819 @enumerate
   3820 @item
   3821 the per-inferior thread number assigned by @value{GDBN}
   3822 
   3823 @item
   3824 the global thread number assigned by @value{GDBN}, if the @samp{-gid}
   3825 option was specified
   3826 
   3827 @item
   3828 the target system's thread identifier (@var{systag})
   3829 
   3830 @item
   3831 the thread's name, if one is known.  A thread can either be named by
   3832 the user (see @code{thread name}, below), or, in some cases, by the
   3833 program itself.
   3834 
   3835 @item
   3836 the current stack frame summary for that thread
   3837 @end enumerate
   3838 
   3839 @noindent
   3840 An asterisk @samp{*} to the left of the @value{GDBN} thread number
   3841 indicates the current thread.
   3842 
   3843 For example,
   3844 @end table
   3845 @c end table here to get a little more width for example
   3846 
   3847 @smallexample
   3848 (@value{GDBP}) info threads
   3849   Id   Target Id             Frame
   3850 * 1    process 35 thread 13  main (argc=1, argv=0x7ffffff8)
   3851   2    process 35 thread 23  0x34e5 in sigpause ()
   3852   3    process 35 thread 27  0x34e5 in sigpause ()
   3853     at threadtest.c:68
   3854 @end smallexample
   3855 
   3856 If you're debugging multiple inferiors, @value{GDBN} displays thread
   3857 IDs using the qualified @var{inferior-num}.@var{thread-num} format.
   3858 Otherwise, only @var{thread-num} is shown.
   3859 
   3860 If you specify the @samp{-gid} option, @value{GDBN} displays a column
   3861 indicating each thread's global thread ID:
   3862 
   3863 @smallexample
   3864 (@value{GDBP}) info threads
   3865   Id   GId  Target Id             Frame
   3866   1.1  1    process 35 thread 13  main (argc=1, argv=0x7ffffff8)
   3867   1.2  3    process 35 thread 23  0x34e5 in sigpause ()
   3868   1.3  4    process 35 thread 27  0x34e5 in sigpause ()
   3869 * 2.1  2    process 65 thread 1   main (argc=1, argv=0x7ffffff8)
   3870 @end smallexample
   3871 
   3872 On Solaris, you can display more information about user threads with a
   3873 Solaris-specific command:
   3874 
   3875 @table @code
   3876 @item maint info sol-threads
   3877 @kindex maint info sol-threads
   3878 @cindex thread info (Solaris)
   3879 Display info on Solaris user threads.
   3880 @end table
   3881 
   3882 @table @code
   3883 @kindex thread @var{thread-id}
   3884 @item thread @var{thread-id}
   3885 Make thread ID @var{thread-id} the current thread.  The command
   3886 argument @var{thread-id} is the @value{GDBN} thread ID, as shown in
   3887 the first field of the @samp{info threads} display, with or without an
   3888 inferior qualifier (e.g., @samp{2.1} or @samp{1}).
   3889 
   3890 @value{GDBN} responds by displaying the system identifier of the
   3891 thread you selected, and its current stack frame summary:
   3892 
   3893 @smallexample
   3894 (@value{GDBP}) thread 2
   3895 [Switching to thread 2 (Thread 0xb7fdab70 (LWP 12747))]
   3896 #0  some_function (ignore=0x0) at example.c:8
   3897 8	    printf ("hello\n");
   3898 @end smallexample
   3899 
   3900 @noindent
   3901 As with the @samp{[New @dots{}]} message, the form of the text after
   3902 @samp{Switching to} depends on your system's conventions for identifying
   3903 threads.
   3904 
   3905 @anchor{thread apply all}
   3906 @kindex thread apply
   3907 @cindex apply command to several threads
   3908 @item thread apply [@var{thread-id-list} | all [-ascending]] [@var{flag}]@dots{} @var{command}
   3909 The @code{thread apply} command allows you to apply the named
   3910 @var{command} to one or more threads.  Specify the threads that you
   3911 want affected using the thread ID list syntax (@pxref{thread ID
   3912 lists}), or specify @code{all} to apply to all threads.  To apply a
   3913 command to all threads in descending order, type @kbd{thread apply all
   3914 @var{command}}.  To apply a command to all threads in ascending order,
   3915 type @kbd{thread apply all -ascending @var{command}}.
   3916 
   3917 The @var{flag} arguments control what output to produce and how to handle
   3918 errors raised when applying @var{command} to a thread.  @var{flag}
   3919 must start with a @code{-} directly followed by one letter in
   3920 @code{qcs}.  If several flags are provided, they must be given
   3921 individually, such as @code{-c -q}.
   3922 
   3923 By default, @value{GDBN} displays some thread information before the
   3924 output produced by @var{command}, and an error raised during the
   3925 execution of a @var{command} will abort @code{thread apply}.  The
   3926 following flags can be used to fine-tune this behavior:
   3927 
   3928 @table @code
   3929 @item -c
   3930 The flag @code{-c}, which stands for @samp{continue}, causes any
   3931 errors in @var{command} to be displayed, and the execution of
   3932 @code{thread apply} then continues.
   3933 @item -s
   3934 The flag @code{-s}, which stands for @samp{silent}, causes any errors
   3935 or empty output produced by a @var{command} to be silently ignored.
   3936 That is, the execution continues, but the thread information and errors
   3937 are not printed.
   3938 @item -q
   3939 The flag @code{-q} (@samp{quiet}) disables printing the thread
   3940 information.
   3941 @end table
   3942 
   3943 Flags @code{-c} and @code{-s} cannot be used together.
   3944 
   3945 @kindex taas
   3946 @cindex apply command to all threads (ignoring errors and empty output)
   3947 @item taas [@var{option}]@dots{} @var{command}
   3948 Shortcut for @code{thread apply all -s [@var{option}]@dots{} @var{command}}.
   3949 Applies @var{command} on all threads, ignoring errors and empty output.
   3950 
   3951 The @code{taas} command accepts the same options as the @code{thread
   3952 apply all} command.  @xref{thread apply all}.
   3953 
   3954 @kindex tfaas
   3955 @cindex apply a command to all frames of all threads (ignoring errors and empty output)
   3956 @item tfaas [@var{option}]@dots{} @var{command}
   3957 Shortcut for @code{thread apply all -s -- frame apply all -s [@var{option}]@dots{} @var{command}}.
   3958 Applies @var{command} on all frames of all threads, ignoring errors
   3959 and empty output.  Note that the flag @code{-s} is specified twice:
   3960 The first @code{-s} ensures that @code{thread apply} only shows the thread
   3961 information of the threads for which @code{frame apply} produces
   3962 some output.  The second @code{-s} is needed to ensure that @code{frame
   3963 apply} shows the frame information of a frame only if the
   3964 @var{command} successfully produced some output.
   3965 
   3966 It can for example be used to print a local variable or a function
   3967 argument without knowing the thread or frame where this variable or argument
   3968 is, using:
   3969 @smallexample
   3970 (@value{GDBP}) tfaas p some_local_var_i_do_not_remember_where_it_is
   3971 @end smallexample
   3972 
   3973 The @code{tfaas} command accepts the same options as the @code{frame
   3974 apply} command.  @xref{Frame Apply,,frame apply}.
   3975 
   3976 @kindex thread name
   3977 @cindex name a thread
   3978 @item thread name [@var{name}]
   3979 This command assigns a name to the current thread.  If no argument is
   3980 given, any existing user-specified name is removed.  The thread name
   3981 appears in the @samp{info threads} display.
   3982 
   3983 On some systems, such as @sc{gnu}/Linux, @value{GDBN} is able to
   3984 determine the name of the thread as given by the OS.  On these
   3985 systems, a name specified with @samp{thread name} will override the
   3986 system-give name, and removing the user-specified name will cause
   3987 @value{GDBN} to once again display the system-specified name.
   3988 
   3989 @kindex thread find
   3990 @cindex search for a thread
   3991 @item thread find [@var{regexp}]
   3992 Search for and display thread ids whose name or @var{systag}
   3993 matches the supplied regular expression.
   3994 
   3995 As well as being the complement to the @samp{thread name} command, 
   3996 this command also allows you to identify a thread by its target 
   3997 @var{systag}.  For instance, on @sc{gnu}/Linux, the target @var{systag}
   3998 is the LWP id.
   3999 
   4000 @smallexample
   4001 (@value{GDBP}) thread find 26688
   4002 Thread 4 has target id 'Thread 0x41e02940 (LWP 26688)'
   4003 (@value{GDBP}) info thread 4
   4004   Id   Target Id         Frame 
   4005   4    Thread 0x41e02940 (LWP 26688) 0x00000031ca6cd372 in select ()
   4006 @end smallexample
   4007 
   4008 @kindex set print thread-events
   4009 @cindex print messages on thread start and exit
   4010 @item set print thread-events
   4011 @itemx set print thread-events on
   4012 @itemx set print thread-events off
   4013 The @code{set print thread-events} command allows you to enable or
   4014 disable printing of messages when @value{GDBN} notices that new threads have
   4015 started or that threads have exited.  By default, these messages will
   4016 be printed if detection of these events is supported by the target.
   4017 Note that these messages cannot be disabled on all targets.
   4018 
   4019 @kindex show print thread-events
   4020 @item show print thread-events
   4021 Show whether messages will be printed when @value{GDBN} detects that threads
   4022 have started and exited.
   4023 @end table
   4024 
   4025 @xref{Thread Stops,,Stopping and Starting Multi-thread Programs}, for
   4026 more information about how @value{GDBN} behaves when you stop and start
   4027 programs with multiple threads.
   4028 
   4029 @xref{Set Watchpoints,,Setting Watchpoints}, for information about
   4030 watchpoints in programs with multiple threads.
   4031 
   4032 @anchor{set libthread-db-search-path}
   4033 @table @code
   4034 @kindex set libthread-db-search-path
   4035 @cindex search path for @code{libthread_db}
   4036 @item set libthread-db-search-path @r{[}@var{path}@r{]}
   4037 If this variable is set, @var{path} is a colon-separated list of
   4038 directories @value{GDBN} will use to search for @code{libthread_db}.
   4039 If you omit @var{path}, @samp{libthread-db-search-path} will be reset to
   4040 its default value (@code{$sdir:$pdir} on @sc{gnu}/Linux and Solaris systems).
   4041 Internally, the default value comes from the @code{LIBTHREAD_DB_SEARCH_PATH}
   4042 macro.
   4043 
   4044 On @sc{gnu}/Linux and Solaris systems, @value{GDBN} uses a ``helper''
   4045 @code{libthread_db} library to obtain information about threads in the
   4046 inferior process.  @value{GDBN} will use @samp{libthread-db-search-path}
   4047 to find @code{libthread_db}.  @value{GDBN} also consults first if inferior
   4048 specific thread debugging library loading is enabled
   4049 by @samp{set auto-load libthread-db} (@pxref{libthread_db.so.1 file}).
   4050 
   4051 A special entry @samp{$sdir} for @samp{libthread-db-search-path}
   4052 refers to the default system directories that are
   4053 normally searched for loading shared libraries.  The @samp{$sdir} entry
   4054 is the only kind not needing to be enabled by @samp{set auto-load libthread-db}
   4055 (@pxref{libthread_db.so.1 file}).
   4056 
   4057 A special entry @samp{$pdir} for @samp{libthread-db-search-path}
   4058 refers to the directory from which @code{libpthread}
   4059 was loaded in the inferior process.
   4060 
   4061 For any @code{libthread_db} library @value{GDBN} finds in above directories,
   4062 @value{GDBN} attempts to initialize it with the current inferior process.
   4063 If this initialization fails (which could happen because of a version
   4064 mismatch between @code{libthread_db} and @code{libpthread}), @value{GDBN}
   4065 will unload @code{libthread_db}, and continue with the next directory.
   4066 If none of @code{libthread_db} libraries initialize successfully,
   4067 @value{GDBN} will issue a warning and thread debugging will be disabled.
   4068 
   4069 Setting @code{libthread-db-search-path} is currently implemented
   4070 only on some platforms.
   4071 
   4072 @kindex show libthread-db-search-path 
   4073 @item show libthread-db-search-path 
   4074 Display current libthread_db search path.
   4075 
   4076 @kindex set debug libthread-db
   4077 @kindex show debug libthread-db
   4078 @cindex debugging @code{libthread_db}
   4079 @item set debug libthread-db
   4080 @itemx show debug libthread-db
   4081 Turns on or off display of @code{libthread_db}-related events.
   4082 Use @code{1} to enable, @code{0} to disable.
   4083 
   4084 @kindex set debug threads
   4085 @kindex show debug threads
   4086 @cindex debugging @code{threads}
   4087 @item set debug threads @r{[}on@r{|}off@r{]}
   4088 @itemx show debug threads
   4089 When @samp{on} @value{GDBN} will print additional messages when
   4090 threads are created and deleted.
   4091 @end table
   4092 
   4093 @node Forks
   4094 @section Debugging Forks
   4095 
   4096 @cindex fork, debugging programs which call
   4097 @cindex multiple processes
   4098 @cindex processes, multiple
   4099 On most systems, @value{GDBN} has no special support for debugging
   4100 programs which create additional processes using the @code{fork}
   4101 function.  When a program forks, @value{GDBN} will continue to debug the
   4102 parent process and the child process will run unimpeded.  If you have
   4103 set a breakpoint in any code which the child then executes, the child
   4104 will get a @code{SIGTRAP} signal which (unless it catches the signal)
   4105 will cause it to terminate.
   4106 
   4107 However, if you want to debug the child process there is a workaround
   4108 which isn't too painful.  Put a call to @code{sleep} in the code which
   4109 the child process executes after the fork.  It may be useful to sleep
   4110 only if a certain environment variable is set, or a certain file exists,
   4111 so that the delay need not occur when you don't want to run @value{GDBN}
   4112 on the child.  While the child is sleeping, use the @code{ps} program to
   4113 get its process ID.  Then tell @value{GDBN} (a new invocation of
   4114 @value{GDBN} if you are also debugging the parent process) to attach to
   4115 the child process (@pxref{Attach}).  From that point on you can debug
   4116 the child process just like any other process which you attached to.
   4117 
   4118 On some systems, @value{GDBN} provides support for debugging programs
   4119 that create additional processes using the @code{fork} or @code{vfork}
   4120 functions.  On @sc{gnu}/Linux platforms, this feature is supported
   4121 with kernel version 2.5.46 and later.
   4122 
   4123 The fork debugging commands are supported in native mode and when
   4124 connected to @code{gdbserver} in either @code{target remote} mode or
   4125 @code{target extended-remote} mode.
   4126 
   4127 By default, when a program forks, @value{GDBN} will continue to debug
   4128 the parent process and the child process will run unimpeded.
   4129 
   4130 If you want to follow the child process instead of the parent process,
   4131 use the command @w{@code{set follow-fork-mode}}.
   4132 
   4133 @table @code
   4134 @kindex set follow-fork-mode
   4135 @item set follow-fork-mode @var{mode}
   4136 Set the debugger response to a program call of @code{fork} or
   4137 @code{vfork}.  A call to @code{fork} or @code{vfork} creates a new
   4138 process.  The @var{mode} argument can be:
   4139 
   4140 @table @code
   4141 @item parent
   4142 The original process is debugged after a fork.  The child process runs
   4143 unimpeded.  This is the default.
   4144 
   4145 @item child
   4146 The new process is debugged after a fork.  The parent process runs
   4147 unimpeded.
   4148 
   4149 @end table
   4150 
   4151 @kindex show follow-fork-mode
   4152 @item show follow-fork-mode
   4153 Display the current debugger response to a @code{fork} or @code{vfork} call.
   4154 @end table
   4155 
   4156 @cindex debugging multiple processes
   4157 On Linux, if you want to debug both the parent and child processes, use the
   4158 command @w{@code{set detach-on-fork}}.
   4159 
   4160 @table @code
   4161 @kindex set detach-on-fork
   4162 @item set detach-on-fork @var{mode}
   4163 Tells gdb whether to detach one of the processes after a fork, or
   4164 retain debugger control over them both.
   4165 
   4166 @table @code
   4167 @item on
   4168 The child process (or parent process, depending on the value of
   4169 @code{follow-fork-mode}) will be detached and allowed to run 
   4170 independently.  This is the default.
   4171 
   4172 @item off
   4173 Both processes will be held under the control of @value{GDBN}.
   4174 One process (child or parent, depending on the value of 
   4175 @code{follow-fork-mode}) is debugged as usual, while the other
   4176 is held suspended.  
   4177 
   4178 @end table
   4179 
   4180 @kindex show detach-on-fork
   4181 @item show detach-on-fork
   4182 Show whether detach-on-fork mode is on/off.
   4183 @end table
   4184 
   4185 If you choose to set @samp{detach-on-fork} mode off, then @value{GDBN}
   4186 will retain control of all forked processes (including nested forks).
   4187 You can list the forked processes under the control of @value{GDBN} by
   4188 using the @w{@code{info inferiors}} command, and switch from one fork
   4189 to another by using the @code{inferior} command (@pxref{Inferiors Connections and
   4190 Programs, ,Debugging Multiple Inferiors Connections and Programs}).
   4191 
   4192 To quit debugging one of the forked processes, you can either detach
   4193 from it by using the @w{@code{detach inferiors}} command (allowing it
   4194 to run independently), or kill it using the @w{@code{kill inferiors}}
   4195 command.  @xref{Inferiors Connections and Programs, ,Debugging
   4196 Multiple Inferiors Connections and Programs}.
   4197 
   4198 If you ask to debug a child process and a @code{vfork} is followed by an
   4199 @code{exec}, @value{GDBN} executes the new target up to the first
   4200 breakpoint in the new target.  If you have a breakpoint set on
   4201 @code{main} in your original program, the breakpoint will also be set on
   4202 the child process's @code{main}.
   4203 
   4204 On some systems, when a child process is spawned by @code{vfork}, you
   4205 cannot debug the child or parent until an @code{exec} call completes.
   4206 
   4207 If you issue a @code{run} command to @value{GDBN} after an @code{exec}
   4208 call executes, the new target restarts.  To restart the parent
   4209 process, use the @code{file} command with the parent executable name
   4210 as its argument.  By default, after an @code{exec} call executes,
   4211 @value{GDBN} discards the symbols of the previous executable image.
   4212 You can change this behavior with the @w{@code{set follow-exec-mode}}
   4213 command.
   4214 
   4215 @table @code
   4216 @kindex set follow-exec-mode
   4217 @item set follow-exec-mode @var{mode}
   4218 
   4219 Set debugger response to a program call of @code{exec}.  An
   4220 @code{exec} call replaces the program image of a process.
   4221 
   4222 @code{follow-exec-mode} can be:
   4223 
   4224 @table @code
   4225 @item new
   4226 @value{GDBN} creates a new inferior and rebinds the process to this
   4227 new inferior.  The program the process was running before the
   4228 @code{exec} call can be restarted afterwards by restarting the
   4229 original inferior.
   4230 
   4231 For example:
   4232 
   4233 @smallexample
   4234 (@value{GDBP}) info inferiors
   4235 (@value{GDBP}) info inferior
   4236   Id   Description   Executable
   4237 * 1    <null>        prog1
   4238 (@value{GDBP}) run
   4239 process 12020 is executing new program: prog2
   4240 Program exited normally.
   4241 (@value{GDBP}) info inferiors
   4242   Id   Description   Executable
   4243   1    <null>        prog1
   4244 * 2    <null>        prog2
   4245 @end smallexample
   4246 
   4247 @item same
   4248 @value{GDBN} keeps the process bound to the same inferior.  The new
   4249 executable image replaces the previous executable loaded in the
   4250 inferior.  Restarting the inferior after the @code{exec} call, with
   4251 e.g., the @code{run} command, restarts the executable the process was
   4252 running after the @code{exec} call.  This is the default mode.
   4253 
   4254 For example:
   4255 
   4256 @smallexample
   4257 (@value{GDBP}) info inferiors
   4258   Id   Description   Executable
   4259 * 1    <null>        prog1
   4260 (@value{GDBP}) run
   4261 process 12020 is executing new program: prog2
   4262 Program exited normally.
   4263 (@value{GDBP}) info inferiors
   4264   Id   Description   Executable
   4265 * 1    <null>        prog2
   4266 @end smallexample
   4267 
   4268 @end table
   4269 @end table
   4270 
   4271 @code{follow-exec-mode} is supported in native mode and
   4272 @code{target extended-remote} mode.
   4273 
   4274 You can use the @code{catch} command to make @value{GDBN} stop whenever
   4275 a @code{fork}, @code{vfork}, or @code{exec} call is made.  @xref{Set
   4276 Catchpoints, ,Setting Catchpoints}.
   4277 
   4278 @node Checkpoint/Restart
   4279 @section Setting a @emph{Bookmark} to Return to Later
   4280 
   4281 @cindex checkpoint
   4282 @cindex restart
   4283 @cindex bookmark
   4284 @cindex snapshot of a process
   4285 @cindex rewind program state
   4286 
   4287 On certain operating systems@footnote{Currently, only
   4288 @sc{gnu}/Linux.}, @value{GDBN} is able to save a @dfn{snapshot} of a
   4289 program's state, called a @dfn{checkpoint}, and come back to it
   4290 later.
   4291 
   4292 Returning to a checkpoint effectively undoes everything that has
   4293 happened in the program since the @code{checkpoint} was saved.  This
   4294 includes changes in memory, registers, and even (within some limits)
   4295 system state.  Effectively, it is like going back in time to the
   4296 moment when the checkpoint was saved.
   4297 
   4298 Thus, if you're stepping through a program and you think you're
   4299 getting close to the point where things go wrong, you can save
   4300 a checkpoint.  Then, if you accidentally go too far and miss
   4301 the critical statement, instead of having to restart your program
   4302 from the beginning, you can just go back to the checkpoint and
   4303 start again from there.
   4304 
   4305 This can be especially useful if it takes a lot of time or 
   4306 steps to reach the point where you think the bug occurs.  
   4307 
   4308 To use the @code{checkpoint}/@code{restart} method of debugging:
   4309 
   4310 @table @code
   4311 @kindex checkpoint
   4312 @item checkpoint
   4313 Save a snapshot of the debugged program's current execution state.
   4314 The @code{checkpoint} command takes no arguments, but each checkpoint
   4315 is assigned a small integer id, similar to a breakpoint id.
   4316 
   4317 @kindex info checkpoints
   4318 @item info checkpoints
   4319 List the checkpoints that have been saved in the current debugging
   4320 session.  For each checkpoint, the following information will be
   4321 listed:
   4322 
   4323 @table @code
   4324 @item Checkpoint ID
   4325 @item Process ID
   4326 @item Code Address
   4327 @item Source line, or label
   4328 @end table
   4329 
   4330 @kindex restart @var{checkpoint-id}
   4331 @item restart @var{checkpoint-id}
   4332 Restore the program state that was saved as checkpoint number
   4333 @var{checkpoint-id}.  All program variables, registers, stack frames
   4334 etc.@:  will be returned to the values that they had when the checkpoint
   4335 was saved.  In essence, gdb will ``wind back the clock'' to the point
   4336 in time when the checkpoint was saved.
   4337 
   4338 Note that breakpoints, @value{GDBN} variables, command history etc.
   4339 are not affected by restoring a checkpoint.  In general, a checkpoint
   4340 only restores things that reside in the program being debugged, not in
   4341 the debugger.
   4342 
   4343 @kindex delete checkpoint @var{checkpoint-id}
   4344 @item delete checkpoint @var{checkpoint-id}
   4345 Delete the previously-saved checkpoint identified by @var{checkpoint-id}.
   4346 
   4347 @end table
   4348 
   4349 Returning to a previously saved checkpoint will restore the user state
   4350 of the program being debugged, plus a significant subset of the system
   4351 (OS) state, including file pointers.  It won't ``un-write'' data from
   4352 a file, but it will rewind the file pointer to the previous location,
   4353 so that the previously written data can be overwritten.  For files
   4354 opened in read mode, the pointer will also be restored so that the
   4355 previously read data can be read again.
   4356 
   4357 Of course, characters that have been sent to a printer (or other
   4358 external device) cannot be ``snatched back'', and characters received
   4359 from eg.@: a serial device can be removed from internal program buffers,
   4360 but they cannot be ``pushed back'' into the serial pipeline, ready to
   4361 be received again.  Similarly, the actual contents of files that have
   4362 been changed cannot be restored (at this time).
   4363 
   4364 However, within those constraints, you actually can ``rewind'' your
   4365 program to a previously saved point in time, and begin debugging it
   4366 again --- and you can change the course of events so as to debug a
   4367 different execution path this time.
   4368 
   4369 @cindex checkpoints and process id
   4370 Finally, there is one bit of internal program state that will be
   4371 different when you return to a checkpoint --- the program's process
   4372 id.  Each checkpoint will have a unique process id (or @var{pid}), 
   4373 and each will be different from the program's original @var{pid}.
   4374 If your program has saved a local copy of its process id, this could
   4375 potentially pose a problem.
   4376 
   4377 @subsection A Non-obvious Benefit of Using Checkpoints
   4378 
   4379 On some systems such as @sc{gnu}/Linux, address space randomization
   4380 is performed on new processes for security reasons.  This makes it 
   4381 difficult or impossible to set a breakpoint, or watchpoint, on an
   4382 absolute address if you have to restart the program, since the 
   4383 absolute location of a symbol will change from one execution to the
   4384 next.
   4385 
   4386 A checkpoint, however, is an @emph{identical} copy of a process. 
   4387 Therefore if you create a checkpoint at (eg.@:) the start of main, 
   4388 and simply return to that checkpoint instead of restarting the 
   4389 process, you can avoid the effects of address randomization and
   4390 your symbols will all stay in the same place.
   4391 
   4392 @node Stopping
   4393 @chapter Stopping and Continuing
   4394 
   4395 The principal purposes of using a debugger are so that you can stop your
   4396 program before it terminates; or so that, if your program runs into
   4397 trouble, you can investigate and find out why.
   4398 
   4399 Inside @value{GDBN}, your program may stop for any of several reasons,
   4400 such as a signal, a breakpoint, or reaching a new line after a
   4401 @value{GDBN} command such as @code{step}.  You may then examine and
   4402 change variables, set new breakpoints or remove old ones, and then
   4403 continue execution.  Usually, the messages shown by @value{GDBN} provide
   4404 ample explanation of the status of your program---but you can also
   4405 explicitly request this information at any time.
   4406 
   4407 @table @code
   4408 @kindex info program
   4409 @item info program
   4410 Display information about the status of your program: whether it is
   4411 running or not, what process it is, and why it stopped.
   4412 @end table
   4413 
   4414 @menu
   4415 * Breakpoints::                 Breakpoints, watchpoints, tracepoints,
   4416                                 and catchpoints
   4417 * Continuing and Stepping::     Resuming execution
   4418 * Skipping Over Functions and Files::
   4419                                 Skipping over functions and files
   4420 * Signals::                     Signals
   4421 * Thread Stops::                Stopping and starting multi-thread programs
   4422 @end menu
   4423 
   4424 @node Breakpoints
   4425 @section Breakpoints, Watchpoints, and Catchpoints
   4426 
   4427 @cindex breakpoints
   4428 A @dfn{breakpoint} makes your program stop whenever a certain point in
   4429 the program is reached.  For each breakpoint, you can add conditions to
   4430 control in finer detail whether your program stops.  You can set
   4431 breakpoints with the @code{break} command and its variants (@pxref{Set
   4432 Breaks, ,Setting Breakpoints}), to specify the place where your program
   4433 should stop by line number, function name or exact address in the
   4434 program.
   4435 
   4436 On some systems, you can set breakpoints in shared libraries before
   4437 the executable is run.
   4438 
   4439 @cindex watchpoints
   4440 @cindex data breakpoints
   4441 @cindex memory tracing
   4442 @cindex breakpoint on memory address
   4443 @cindex breakpoint on variable modification
   4444 A @dfn{watchpoint} is a special breakpoint that stops your program
   4445 when the value of an expression changes.  The expression may be a value
   4446 of a variable, or it could involve values of one or more variables
   4447 combined by operators, such as @samp{a + b}.  This is sometimes called
   4448 @dfn{data breakpoints}.  You must use a different command to set
   4449 watchpoints (@pxref{Set Watchpoints, ,Setting Watchpoints}), but aside
   4450 from that, you can manage a watchpoint like any other breakpoint: you
   4451 enable, disable, and delete both breakpoints and watchpoints using the
   4452 same commands.
   4453 
   4454 You can arrange to have values from your program displayed automatically
   4455 whenever @value{GDBN} stops at a breakpoint.  @xref{Auto Display,,
   4456 Automatic Display}.
   4457 
   4458 @cindex catchpoints
   4459 @cindex breakpoint on events
   4460 A @dfn{catchpoint} is another special breakpoint that stops your program
   4461 when a certain kind of event occurs, such as the throwing of a C@t{++}
   4462 exception or the loading of a library.  As with watchpoints, you use a
   4463 different command to set a catchpoint (@pxref{Set Catchpoints, ,Setting
   4464 Catchpoints}), but aside from that, you can manage a catchpoint like any
   4465 other breakpoint.  (To stop when your program receives a signal, use the
   4466 @code{handle} command; see @ref{Signals, ,Signals}.)
   4467 
   4468 @cindex breakpoint numbers
   4469 @cindex numbers for breakpoints
   4470 @value{GDBN} assigns a number to each breakpoint, watchpoint, or
   4471 catchpoint when you create it; these numbers are successive integers
   4472 starting with one.  In many of the commands for controlling various
   4473 features of breakpoints you use the breakpoint number to say which
   4474 breakpoint you want to change.  Each breakpoint may be @dfn{enabled} or
   4475 @dfn{disabled}; if disabled, it has no effect on your program until you
   4476 enable it again.
   4477 
   4478 @cindex breakpoint ranges
   4479 @cindex breakpoint lists
   4480 @cindex ranges of breakpoints
   4481 @cindex lists of breakpoints
   4482 Some @value{GDBN} commands accept a space-separated list of breakpoints
   4483 on which to operate.  A list element can be either a single breakpoint number,
   4484 like @samp{5}, or a range of such numbers, like @samp{5-7}.
   4485 When a breakpoint list is given to a command, all breakpoints in that list
   4486 are operated on.
   4487 
   4488 @menu
   4489 * Set Breaks::                  Setting breakpoints
   4490 * Set Watchpoints::             Setting watchpoints
   4491 * Set Catchpoints::             Setting catchpoints
   4492 * Delete Breaks::               Deleting breakpoints
   4493 * Disabling::                   Disabling breakpoints
   4494 * Conditions::                  Break conditions
   4495 * Break Commands::              Breakpoint command lists
   4496 * Dynamic Printf::              Dynamic printf
   4497 * Save Breakpoints::            How to save breakpoints in a file
   4498 * Static Probe Points::         Listing static probe points
   4499 * Error in Breakpoints::        ``Cannot insert breakpoints''
   4500 * Breakpoint-related Warnings:: ``Breakpoint address adjusted...''
   4501 @end menu
   4502 
   4503 @node Set Breaks
   4504 @subsection Setting Breakpoints
   4505 
   4506 @c FIXME LMB what does GDB do if no code on line of breakpt?
   4507 @c       consider in particular declaration with/without initialization.
   4508 @c
   4509 @c FIXME 2 is there stuff on this already? break at fun start, already init?
   4510 
   4511 @kindex break
   4512 @kindex b @r{(@code{break})}
   4513 @vindex $bpnum@r{, convenience variable}
   4514 @cindex latest breakpoint
   4515 Breakpoints are set with the @code{break} command (abbreviated
   4516 @code{b}).  The debugger convenience variable @samp{$bpnum} records the
   4517 number of the breakpoint you've set most recently:
   4518 @smallexample
   4519 (gdb) b main
   4520 Breakpoint 1 at 0x11c6: file zeoes.c, line 24.
   4521 (gdb) p $bpnum
   4522 $1 = 1
   4523 @end smallexample
   4524 
   4525 A breakpoint may be mapped to multiple code locations for example with
   4526 inlined functions, Ada generics, C@t{++} templates or overloaded function names.
   4527 @value{GDBN} then indicates the number of code locations in the breakpoint
   4528 command output:
   4529 @smallexample
   4530 (gdb) b some_func
   4531 Breakpoint 2 at 0x1179: some_func. (3 locations)
   4532 (gdb) p $bpnum
   4533 $2 = 2
   4534 (gdb)
   4535 @end smallexample
   4536 
   4537 @vindex $_hit_bpnum@r{, convenience variable}
   4538 @vindex $_hit_locno@r{, convenience variable}
   4539 When your program stops on a breakpoint, the convenience variables
   4540 @samp{$_hit_bpnum} and @samp{$_hit_locno} are respectively set to the number of
   4541 the encountered breakpoint and the number of the breakpoint's code location:
   4542 @smallexample
   4543 Thread 1 "zeoes" hit Breakpoint 2.1, some_func () at zeoes.c:8
   4544 8	  printf("some func\n");
   4545 (gdb) p $_hit_bpnum
   4546 $5 = 2
   4547 (gdb) p $_hit_locno
   4548 $6 = 1
   4549 (gdb)
   4550 @end smallexample
   4551 
   4552 Note that @samp{$_hit_bpnum} and @samp{$bpnum} are not equivalent:
   4553 @samp{$_hit_bpnum} is set to the breakpoint number @b{last hit}, while
   4554 @samp{$bpnum} is set to the breakpoint number @b{last set}.
   4555 
   4556 
   4557 If the encountered breakpoint has only one code location, @samp{$_hit_locno}
   4558 is set to 1:
   4559 @smallexample
   4560 Breakpoint 1, main (argc=1, argv=0x7fffffffe018) at zeoes.c:24
   4561 24	  if (argc > 1)
   4562 (gdb) p $_hit_bpnum
   4563 $3 = 1
   4564 (gdb) p $_hit_locno
   4565 $4 = 1
   4566 (gdb)
   4567 @end smallexample
   4568 
   4569 The @samp{$_hit_bpnum} and @samp{$_hit_locno} variables can typically be used
   4570 in a breakpoint command list.
   4571 (@pxref{Break Commands, ,Breakpoint Command Lists}).  For example, as
   4572 part of the breakpoint command list, you can disable completely the
   4573 encountered breakpoint using @kbd{disable $_hit_bpnum} or disable the
   4574 specific encountered breakpoint location using
   4575 @kbd{disable $_hit_bpnum.$_hit_locno}.
   4576 If a breakpoint has only one location, @samp{$_hit_locno} is set to 1
   4577 and the commands @kbd{disable $_hit_bpnum} and
   4578 @kbd{disable $_hit_bpnum.$_hit_locno} both disable the breakpoint.
   4579 
   4580 You can also define aliases to easily disable the last hit location or
   4581 last hit breakpoint:
   4582 @smallexample
   4583 (gdb) alias lld = disable $_hit_bpnum.$_hit_locno
   4584 (gdb) alias lbd = disable $_hit_bpnum
   4585 @end smallexample
   4586 
   4587 @table @code
   4588 @item break @var{locspec}
   4589 Set a breakpoint at all the code locations in your program that result
   4590 from resolving the given @var{locspec}.  @var{locspec} can specify a
   4591 function name, a line number, an address of an instruction, and more.
   4592 @xref{Location Specifications}, for the various forms of
   4593 @var{locspec}.  The breakpoint will stop your program just before it
   4594 executes the instruction at the address of any of the breakpoint's
   4595 code locations.
   4596 
   4597 When using source languages that permit overloading of symbols, such
   4598 as C@t{++}, a function name may refer to more than one symbol, and
   4599 thus more than one place to break.  @xref{Ambiguous
   4600 Expressions,,Ambiguous Expressions}, for a discussion of that
   4601 situation.
   4602 
   4603 It is also possible to insert a breakpoint that will stop the program
   4604 only if a specific thread (@pxref{Thread-Specific Breakpoints}),
   4605 specific inferior (@pxref{Inferior-Specific Breakpoints}), or a
   4606 specific task (@pxref{Ada Tasks}) hits that breakpoint.
   4607 
   4608 @item break
   4609 When called without any arguments, @code{break} sets a breakpoint at
   4610 the next instruction to be executed in the selected stack frame
   4611 (@pxref{Stack, ,Examining the Stack}).  In any selected frame but the
   4612 innermost, this makes your program stop as soon as control
   4613 returns to that frame.  This is similar to the effect of a
   4614 @code{finish} command in the frame inside the selected frame---except
   4615 that @code{finish} does not leave an active breakpoint.  If you use
   4616 @code{break} without an argument in the innermost frame, @value{GDBN} stops
   4617 the next time it reaches the current location; this may be useful
   4618 inside loops.
   4619 
   4620 @value{GDBN} normally ignores breakpoints when it resumes execution, until at
   4621 least one instruction has been executed.  If it did not do this, you
   4622 would be unable to proceed past a breakpoint without first disabling the
   4623 breakpoint.  This rule applies whether or not the breakpoint already
   4624 existed when your program stopped.
   4625 
   4626 @item break @dots{} if @var{cond}
   4627 Set a breakpoint with condition @var{cond}; evaluate the expression
   4628 @var{cond} each time the breakpoint is reached, and stop only if the
   4629 value is nonzero---that is, if @var{cond} evaluates as true.
   4630 @samp{@dots{}} stands for one of the possible arguments described
   4631 above (or no argument) specifying where to break.  @xref{Conditions,
   4632 ,Break Conditions}, for more information on breakpoint conditions.
   4633 
   4634 The breakpoint may be mapped to multiple locations.  If the breakpoint
   4635 condition @var{cond} is invalid at some but not all of the locations,
   4636 the locations for which the condition is invalid are disabled.  For
   4637 example, @value{GDBN} reports below that two of the three locations
   4638 are disabled.
   4639 
   4640 @smallexample
   4641 (@value{GDBP}) break func if a == 10
   4642 warning: failed to validate condition at location 0x11ce, disabling:
   4643   No symbol "a" in current context.
   4644 warning: failed to validate condition at location 0x11b6, disabling:
   4645   No symbol "a" in current context.
   4646 Breakpoint 1 at 0x11b6: func. (3 locations)
   4647 @end smallexample
   4648 
   4649 Locations that are disabled because of the condition are denoted by an
   4650 uppercase @code{N} in the output of the @code{info breakpoints}
   4651 command:
   4652 
   4653 @smallexample
   4654 (@value{GDBP}) info breakpoints
   4655 Num     Type           Disp Enb Address            What
   4656 1       breakpoint     keep y   <MULTIPLE>
   4657         stop only if a == 10
   4658 1.1                         N*  0x00000000000011b6 in ...
   4659 1.2                         y   0x00000000000011c2 in ...
   4660 1.3                         N*  0x00000000000011ce in ...
   4661 (*): Breakpoint condition is invalid at this location.
   4662 @end smallexample
   4663 
   4664 If the breakpoint condition @var{cond} is invalid in the context of
   4665 @emph{all} the locations of the breakpoint, @value{GDBN} refuses to
   4666 define the breakpoint.  For example, if variable @code{foo} is an
   4667 undefined variable:
   4668 
   4669 @smallexample
   4670 (@value{GDBP}) break func if foo
   4671 No symbol "foo" in current context.
   4672 @end smallexample
   4673 
   4674 @item break @dots{} -force-condition if @var{cond}
   4675 There may be cases where the condition @var{cond} is invalid at all
   4676 the current locations, but the user knows that it will be valid at a
   4677 future location; for example, because of a library load.  In such
   4678 cases, by using the @code{-force-condition} keyword before @samp{if},
   4679 @value{GDBN} can be forced to define the breakpoint with the given
   4680 condition expression instead of refusing it.
   4681 
   4682 @smallexample
   4683 (@value{GDBP}) break func -force-condition if foo
   4684 warning: failed to validate condition at location 1, disabling:
   4685   No symbol "foo" in current context.
   4686 warning: failed to validate condition at location 2, disabling:
   4687   No symbol "foo" in current context.
   4688 warning: failed to validate condition at location 3, disabling:
   4689   No symbol "foo" in current context.
   4690 Breakpoint 1 at 0x1158: test.c:18. (3 locations)
   4691 @end smallexample
   4692 
   4693 This causes all the present locations where the breakpoint would
   4694 otherwise be inserted, to be disabled, as seen in the example above.
   4695 However, if there exist locations at which the condition is valid, the
   4696 @code{-force-condition} keyword has no effect.
   4697 
   4698 @kindex tbreak
   4699 @item tbreak @var{args}
   4700 Set a breakpoint enabled only for one stop.  The @var{args} are the
   4701 same as for the @code{break} command, and the breakpoint is set in the same
   4702 way, but the breakpoint is automatically deleted after the first time your
   4703 program stops there.  @xref{Disabling, ,Disabling Breakpoints}.
   4704 
   4705 @kindex hbreak
   4706 @cindex hardware breakpoints
   4707 @item hbreak @var{args}
   4708 Set a hardware-assisted breakpoint.  The @var{args} are the same as for the
   4709 @code{break} command and the breakpoint is set in the same way, but the
   4710 breakpoint requires hardware support and some target hardware may not
   4711 have this support.  The main purpose of this is EPROM/ROM code
   4712 debugging, so you can set a breakpoint at an instruction without
   4713 changing the instruction.  This can be used with the new trap-generation
   4714 provided by SPARClite DSU and most x86-based targets.  These targets
   4715 will generate traps when a program accesses some data or instruction
   4716 address that is assigned to the debug registers.  However the hardware
   4717 breakpoint registers can take a limited number of breakpoints.  For
   4718 example, on the DSU, only two data breakpoints can be set at a time, and
   4719 @value{GDBN} will reject this command if more than two are used.  Delete
   4720 or disable unused hardware breakpoints before setting new ones
   4721 (@pxref{Disabling, ,Disabling Breakpoints}).
   4722 @xref{Conditions, ,Break Conditions}.
   4723 For remote targets, you can restrict the number of hardware
   4724 breakpoints @value{GDBN} will use, see @ref{set remote
   4725 hardware-breakpoint-limit}.
   4726 
   4727 @kindex thbreak
   4728 @item thbreak @var{args}
   4729 Set a hardware-assisted breakpoint enabled only for one stop.  The @var{args}
   4730 are the same as for the @code{hbreak} command and the breakpoint is set in
   4731 the same way.  However, like the @code{tbreak} command,
   4732 the breakpoint is automatically deleted after the
   4733 first time your program stops there.  Also, like the @code{hbreak}
   4734 command, the breakpoint requires hardware support and some target hardware
   4735 may not have this support.  @xref{Disabling, ,Disabling Breakpoints}.
   4736 See also @ref{Conditions, ,Break Conditions}.
   4737 
   4738 @kindex rbreak
   4739 @cindex regular expression
   4740 @cindex breakpoints at functions matching a regexp
   4741 @cindex set breakpoints in many functions
   4742 @item rbreak @var{regex}
   4743 Set breakpoints on all functions matching the regular expression
   4744 @var{regex}.  This command sets an unconditional breakpoint on all
   4745 matches, printing a list of all breakpoints it set.  Once these
   4746 breakpoints are set, they are treated just like the breakpoints set with
   4747 the @code{break} command.  You can delete them, disable them, or make
   4748 them conditional the same way as any other breakpoint.
   4749 
   4750 In programs using different languages, @value{GDBN} chooses the syntax
   4751 to print the list of all breakpoints it sets according to the
   4752 @samp{set language} value: using @samp{set language auto}
   4753 (see @ref{Automatically, ,Set Language Automatically}) means to use the
   4754 language of the breakpoint's function, other values mean to use
   4755 the manually specified language (see @ref{Manually, ,Set Language Manually}).
   4756 
   4757 The syntax of the regular expression is the standard one used with tools
   4758 like @file{grep}.  Note that this is different from the syntax used by
   4759 shells, so for instance @code{foo*} matches all functions that include
   4760 an @code{fo} followed by zero or more @code{o}s.  There is an implicit
   4761 @code{.*} leading and trailing the regular expression you supply, so to
   4762 match only functions that begin with @code{foo}, use @code{^foo}.
   4763 
   4764 @cindex non-member C@t{++} functions, set breakpoint in
   4765 When debugging C@t{++} programs, @code{rbreak} is useful for setting
   4766 breakpoints on overloaded functions that are not members of any special
   4767 classes.
   4768 
   4769 @cindex set breakpoints on all functions
   4770 The @code{rbreak} command can be used to set breakpoints in
   4771 @strong{all} the functions in a program, like this:
   4772 
   4773 @smallexample
   4774 (@value{GDBP}) rbreak .
   4775 @end smallexample
   4776 
   4777 @item rbreak @var{file}:@var{regex}
   4778 If @code{rbreak} is called with a filename qualification, it limits
   4779 the search for functions matching the given regular expression to the
   4780 specified @var{file}.  This can be used, for example, to set breakpoints on
   4781 every function in a given file:
   4782 
   4783 @smallexample
   4784 (@value{GDBP}) rbreak file.c:.
   4785 @end smallexample
   4786 
   4787 The colon separating the filename qualifier from the regex may
   4788 optionally be surrounded by spaces.
   4789 
   4790 @kindex info breakpoints
   4791 @cindex @code{$_} and @code{info breakpoints}
   4792 @item info breakpoints @r{[}@var{list}@dots{}@r{]}
   4793 @itemx info break @r{[}@var{list}@dots{}@r{]}
   4794 Print a table of all breakpoints, watchpoints, tracepoints, and catchpoints set
   4795 and not deleted.  Optional argument @var{n} means print information only about
   4796 the specified breakpoint(s) (or watchpoint(s) or tracepoint(s) or catchpoint(s)).
   4797 For each breakpoint, following columns are printed:
   4798 
   4799 @table @emph
   4800 @item Breakpoint Numbers
   4801 @item Type
   4802 Breakpoint, watchpoint, tracepoint, or catchpoint.
   4803 @item Disposition
   4804 Whether the breakpoint is marked to be disabled or deleted when hit.
   4805 @item Enabled or Disabled
   4806 Enabled breakpoints are marked with @samp{y}.  @samp{n} marks breakpoints
   4807 that are not enabled.
   4808 @item Address
   4809 Where the breakpoint is in your program, as a memory address.  For a
   4810 pending breakpoint whose address is not yet known, this field will
   4811 contain @samp{<PENDING>}.  Such breakpoint won't fire until a shared
   4812 library that has the symbol or line referred by breakpoint is loaded.
   4813 See below for details.  A breakpoint with several locations will
   4814 have @samp{<MULTIPLE>} in this field---see below for details.
   4815 @item What
   4816 Where the breakpoint is in the source for your program, as a file and
   4817 line number.  For a pending breakpoint, the original string passed to
   4818 the breakpoint command will be listed as it cannot be resolved until
   4819 the appropriate shared library is loaded in the future.
   4820 @end table
   4821 
   4822 @noindent
   4823 If a breakpoint is conditional, there are two evaluation modes: ``host'' and
   4824 ``target''.  If mode is ``host'', breakpoint condition evaluation is done by
   4825 @value{GDBN} on the host's side.  If it is ``target'', then the condition
   4826 is evaluated by the target.  The @code{info break} command shows
   4827 the condition on the line following the affected breakpoint, together with
   4828 its condition evaluation mode in between parentheses.
   4829 
   4830 Breakpoint commands, if any, are listed after that.  A pending breakpoint is
   4831 allowed to have a condition specified for it.  The condition is not parsed for
   4832 validity until a shared library is loaded that allows the pending
   4833 breakpoint to resolve to a valid location.
   4834 
   4835 @noindent
   4836 @code{info break} with a breakpoint
   4837 number @var{n} as argument lists only that breakpoint.  The
   4838 convenience variable @code{$_} and the default examining-address for
   4839 the @code{x} command are set to the address of the last breakpoint
   4840 listed (@pxref{Memory, ,Examining Memory}).
   4841 
   4842 @noindent
   4843 @code{info break} displays a count of the number of times the breakpoint
   4844 has been hit.  This is especially useful in conjunction with the
   4845 @code{ignore} command.  You can ignore a large number of breakpoint
   4846 hits, look at the breakpoint info to see how many times the breakpoint
   4847 was hit, and then run again, ignoring one less than that number.  This
   4848 will get you quickly to the last hit of that breakpoint.
   4849 
   4850 @noindent
   4851 For a breakpoints with an enable count (xref) greater than 1,
   4852 @code{info break} also displays that count.
   4853 
   4854 @end table
   4855 
   4856 @value{GDBN} allows you to set any number of breakpoints at the same place in
   4857 your program.  There is nothing silly or meaningless about this.  When
   4858 the breakpoints are conditional, this is even useful
   4859 (@pxref{Conditions, ,Break Conditions}).
   4860 
   4861 @cindex multiple locations, breakpoints
   4862 @cindex breakpoints, multiple locations
   4863 It is possible that a single logical breakpoint is set at several code
   4864 locations in your program.  @xref{Location Specifications}, for
   4865 examples.
   4866 
   4867 A breakpoint with multiple code locations is displayed in the
   4868 breakpoint table using several rows---one header row, followed by one
   4869 row for each code location.  The header row has @samp{<MULTIPLE>} in
   4870 the address column.  Each code location row contains the actual
   4871 address, source file, source line and function of its code location.
   4872 The number column for a code location is of the form
   4873 @var{breakpoint-number}.@var{location-number}.
   4874 
   4875 For example:
   4876 
   4877 @smallexample
   4878 Num     Type           Disp Enb  Address    What
   4879 1       breakpoint     keep y    <MULTIPLE>
   4880         stop only if i==1
   4881         breakpoint already hit 1 time
   4882 1.1                         y    0x080486a2 in void foo<int>() at t.cc:8
   4883 1.2                         y    0x080486ca in void foo<double>() at t.cc:8
   4884 @end smallexample
   4885 
   4886 You cannot delete the individual locations from a breakpoint.  However,
   4887 each location can be individually enabled or disabled by passing
   4888 @var{breakpoint-number}.@var{location-number} as argument to the
   4889 @code{enable} and @code{disable} commands.  It's also possible to
   4890 @code{enable} and @code{disable} a range of @var{location-number}
   4891 locations using a @var{breakpoint-number} and two @var{location-number}s,
   4892 in increasing order, separated by a hyphen, like
   4893 @kbd{@var{breakpoint-number}.@var{location-number1}-@var{location-number2}},
   4894 in which case @value{GDBN} acts on all the locations in the range (inclusive).
   4895 Disabling or enabling the parent breakpoint (@pxref{Disabling}) affects
   4896 all of the locations that belong to that breakpoint.
   4897 
   4898 Locations that are enabled while their parent breakpoint is disabled
   4899 won't trigger a break, and are denoted by @code{y-} in the @code{Enb}
   4900 column.  For example:
   4901 
   4902 @smallexample
   4903 (@value{GDBP}) info breakpoints
   4904 Num     Type           Disp Enb Address            What
   4905 1       breakpoint     keep n   <MULTIPLE>
   4906 1.1                         y-  0x00000000000011b6 in ...
   4907 1.2                         y-  0x00000000000011c2 in ...
   4908 1.3                         n   0x00000000000011ce in ...
   4909 @end smallexample
   4910 
   4911 @cindex pending breakpoints
   4912 It's quite common to have a breakpoint inside a shared library.
   4913 Shared libraries can be loaded and unloaded explicitly,
   4914 and possibly repeatedly, as the program is executed.  To support
   4915 this use case, @value{GDBN} updates breakpoint locations whenever
   4916 any shared library is loaded or unloaded.  Typically, you would
   4917 set a breakpoint in a shared library at the beginning of your
   4918 debugging session, when the library is not loaded, and when the
   4919 symbols from the library are not available.  When you try to set
   4920 breakpoint, @value{GDBN} will ask you if you want to set
   4921 a so called @dfn{pending breakpoint}---breakpoint whose address
   4922 is not yet resolved.
   4923 
   4924 After the program is run, whenever a new shared library is loaded,
   4925 @value{GDBN} reevaluates all the breakpoints.  When a newly loaded
   4926 shared library contains the symbol or line referred to by some
   4927 pending breakpoint, that breakpoint is resolved and becomes an
   4928 ordinary breakpoint.  When a library is unloaded, all breakpoints
   4929 that refer to its symbols or source lines become pending again.
   4930 
   4931 This logic works for breakpoints with multiple locations, too.  For
   4932 example, if you have a breakpoint in a C@t{++} template function, and
   4933 a newly loaded shared library has an instantiation of that template,
   4934 a new location is added to the list of locations for the breakpoint.
   4935 
   4936 Except for having unresolved address, pending breakpoints do not
   4937 differ from regular breakpoints.  You can set conditions or commands,
   4938 enable and disable them and perform other breakpoint operations.
   4939 
   4940 @value{GDBN} provides some additional commands for controlling what
   4941 happens when the @samp{break} command cannot resolve the location spec
   4942 to any code location in your program (@pxref{Location
   4943 Specifications}):
   4944 
   4945 @kindex set breakpoint pending
   4946 @kindex show breakpoint pending
   4947 @table @code
   4948 @item set breakpoint pending auto
   4949 This is the default behavior.  When @value{GDBN} cannot resolve the
   4950 location spec, it queries you whether a pending breakpoint should be
   4951 created.
   4952 
   4953 @item set breakpoint pending on
   4954 This indicates that when @value{GDBN} cannot resolve the location
   4955 spec, it should create a pending breakpoint without confirmation.
   4956 
   4957 @item set breakpoint pending off
   4958 This indicates that pending breakpoints are not to be created.  If
   4959 @value{GDBN} cannot resolve the location spec, it aborts the
   4960 breakpoint creation with an error.  This setting does not affect any
   4961 pending breakpoints previously created.
   4962 
   4963 @item show breakpoint pending
   4964 Show the current behavior setting for creating pending breakpoints.
   4965 @end table
   4966 
   4967 The settings above only affect the @code{break} command and its
   4968 variants.  Once a breakpoint is set, it will be automatically updated
   4969 as shared libraries are loaded and unloaded.
   4970 
   4971 @cindex automatic hardware breakpoints
   4972 For some targets, @value{GDBN} can automatically decide if hardware or
   4973 software breakpoints should be used, depending on whether the
   4974 breakpoint address is read-only or read-write.  This applies to
   4975 breakpoints set with the @code{break} command as well as to internal
   4976 breakpoints set by commands like @code{next} and @code{finish}.  For
   4977 breakpoints set with @code{hbreak}, @value{GDBN} will always use hardware
   4978 breakpoints.
   4979 
   4980 You can control this automatic behavior with the following commands:
   4981 
   4982 @kindex set breakpoint auto-hw
   4983 @kindex show breakpoint auto-hw
   4984 @table @code
   4985 @item set breakpoint auto-hw on
   4986 This is the default behavior.  When @value{GDBN} sets a breakpoint, it
   4987 will try to use the target memory map to decide if software or hardware
   4988 breakpoint must be used.
   4989 
   4990 @item set breakpoint auto-hw off
   4991 This indicates @value{GDBN} should not automatically select breakpoint
   4992 type.  If the target provides a memory map, @value{GDBN} will warn when
   4993 trying to set software breakpoint at a read-only address.
   4994 @end table
   4995 
   4996 @value{GDBN} normally implements breakpoints by replacing the program code
   4997 at the breakpoint address with a special instruction, which, when
   4998 executed, given control to the debugger.  By default, the program
   4999 code is so modified only when the program is resumed.  As soon as
   5000 the program stops, @value{GDBN} restores the original instructions.  This
   5001 behavior guards against leaving breakpoints inserted in the
   5002 target should gdb abrubptly disconnect.  However, with slow remote
   5003 targets, inserting and removing breakpoint can reduce the performance.
   5004 This behavior can be controlled with the following commands::
   5005 
   5006 @kindex set breakpoint always-inserted
   5007 @kindex show breakpoint always-inserted
   5008 @table @code
   5009 @item set breakpoint always-inserted off
   5010 All breakpoints, including newly added by the user, are inserted in
   5011 the target only when the target is resumed.  All breakpoints are
   5012 removed from the target when it stops.  This is the default mode.
   5013 
   5014 @item set breakpoint always-inserted on
   5015 Causes all breakpoints to be inserted in the target at all times.  If
   5016 the user adds a new breakpoint, or changes an existing breakpoint, the
   5017 breakpoints in the target are updated immediately.  A breakpoint is
   5018 removed from the target only when breakpoint itself is deleted.
   5019 @end table
   5020 
   5021 @value{GDBN} handles conditional breakpoints by evaluating these conditions
   5022 when a breakpoint breaks.  If the condition is true, then the process being
   5023 debugged stops, otherwise the process is resumed.
   5024 
   5025 If the target supports evaluating conditions on its end, @value{GDBN} may
   5026 download the breakpoint, together with its conditions, to it.
   5027 
   5028 This feature can be controlled via the following commands:
   5029 
   5030 @kindex set breakpoint condition-evaluation
   5031 @kindex show breakpoint condition-evaluation
   5032 @table @code
   5033 @item set breakpoint condition-evaluation host
   5034 This option commands @value{GDBN} to evaluate the breakpoint
   5035 conditions on the host's side.  Unconditional breakpoints are sent to
   5036 the target which in turn receives the triggers and reports them back to GDB
   5037 for condition evaluation.  This is the standard evaluation mode.
   5038 
   5039 @item set breakpoint condition-evaluation target
   5040 This option commands @value{GDBN} to download breakpoint conditions
   5041 to the target at the moment of their insertion.  The target
   5042 is responsible for evaluating the conditional expression and reporting
   5043 breakpoint stop events back to @value{GDBN} whenever the condition
   5044 is true.  Due to limitations of target-side evaluation, some conditions
   5045 cannot be evaluated there, e.g., conditions that depend on local data
   5046 that is only known to the host.  Examples include
   5047 conditional expressions involving convenience variables, complex types
   5048 that cannot be handled by the agent expression parser and expressions
   5049 that are too long to be sent over to the target, specially when the
   5050 target is a remote system.  In these cases, the conditions will be
   5051 evaluated by @value{GDBN}.
   5052 
   5053 @item set breakpoint condition-evaluation auto
   5054 This is the default mode.  If the target supports evaluating breakpoint
   5055 conditions on its end, @value{GDBN} will download breakpoint conditions to
   5056 the target (limitations mentioned previously apply).  If the target does
   5057 not support breakpoint condition evaluation, then @value{GDBN} will fallback
   5058 to evaluating all these conditions on the host's side.
   5059 @end table
   5060 
   5061 
   5062 @cindex negative breakpoint numbers
   5063 @cindex internal @value{GDBN} breakpoints
   5064 @value{GDBN} itself sometimes sets breakpoints in your program for
   5065 special purposes, such as proper handling of @code{longjmp} (in C
   5066 programs).  These internal breakpoints are assigned negative numbers,
   5067 starting with @code{-1}; @samp{info breakpoints} does not display them.
   5068 You can see these breakpoints with the @value{GDBN} maintenance command
   5069 @samp{maint info breakpoints} (@pxref{maint info breakpoints}).
   5070 
   5071 
   5072 @node Set Watchpoints
   5073 @subsection Setting Watchpoints
   5074 
   5075 @cindex setting watchpoints
   5076 You can use a watchpoint to stop execution whenever the value of an
   5077 expression changes, without having to predict a particular place where
   5078 this may happen.  (This is sometimes called a @dfn{data breakpoint}.)
   5079 The expression may be as simple as the value of a single variable, or
   5080 as complex as many variables combined by operators.  Examples include:
   5081 
   5082 @itemize @bullet
   5083 @item
   5084 A reference to the value of a single variable.
   5085 
   5086 @item
   5087 An address cast to an appropriate data type.  For example,
   5088 @samp{*(int *)0x12345678} will watch a 4-byte region at the specified
   5089 address (assuming an @code{int} occupies 4 bytes).
   5090 
   5091 @item
   5092 An arbitrarily complex expression, such as @samp{a*b + c/d}.  The
   5093 expression can use any operators valid in the program's native
   5094 language (@pxref{Languages}).
   5095 @end itemize
   5096 
   5097 You can set a watchpoint on an expression even if the expression can
   5098 not be evaluated yet.  For instance, you can set a watchpoint on
   5099 @samp{*global_ptr} before @samp{global_ptr} is initialized.
   5100 @value{GDBN} will stop when your program sets @samp{global_ptr} and
   5101 the expression produces a valid value.  If the expression becomes
   5102 valid in some other way than changing a variable (e.g.@: if the memory
   5103 pointed to by @samp{*global_ptr} becomes readable as the result of a
   5104 @code{malloc} call), @value{GDBN} may not stop until the next time
   5105 the expression changes.
   5106 
   5107 @cindex software watchpoints
   5108 @cindex hardware watchpoints
   5109 Depending on your system, watchpoints may be implemented in software or
   5110 hardware.  @value{GDBN} does software watchpointing by single-stepping your
   5111 program and testing the variable's value each time, which is hundreds of
   5112 times slower than normal execution.  (But this may still be worth it, to
   5113 catch errors where you have no clue what part of your program is the
   5114 culprit.)
   5115 
   5116 On some systems, such as most PowerPC or x86-based targets,
   5117 @value{GDBN} includes support for hardware watchpoints, which do not
   5118 slow down the running of your program.
   5119 
   5120 @table @code
   5121 @kindex watch
   5122 @item watch @r{[}-l@r{|}-location@r{]} @var{expr} @r{[}thread @var{thread-id}@r{]} @r{[}mask @var{maskvalue}@r{]} @r{[}task @var{task-id}@r{]}
   5123 Set a watchpoint for an expression.  @value{GDBN} will break when the
   5124 expression @var{expr} is written into by the program and its value
   5125 changes.  The simplest (and the most popular) use of this command is
   5126 to watch the value of a single variable:
   5127 
   5128 @smallexample
   5129 (@value{GDBP}) watch foo
   5130 @end smallexample
   5131 
   5132 If the command includes a @code{@r{[}thread @var{thread-id}@r{]}}
   5133 argument, @value{GDBN} breaks only when the thread identified by
   5134 @var{thread-id} changes the value of @var{expr}.  If any other threads
   5135 change the value of @var{expr}, @value{GDBN} will not break.  Note
   5136 that watchpoints restricted to a single thread in this way only work
   5137 with Hardware Watchpoints.
   5138 
   5139 Similarly, if the @code{task} argument is given, then the watchpoint
   5140 will be specific to the indicated Ada task (@pxref{Ada Tasks}).
   5141 
   5142 Ordinarily a watchpoint respects the scope of variables in @var{expr}
   5143 (see below).  The @code{-location} argument tells @value{GDBN} to
   5144 instead watch the memory referred to by @var{expr}.  In this case,
   5145 @value{GDBN} will evaluate @var{expr}, take the address of the result,
   5146 and watch the memory at that address.  The type of the result is used
   5147 to determine the size of the watched memory.  If the expression's
   5148 result does not have an address, then @value{GDBN} will print an
   5149 error.
   5150 
   5151 The @code{@r{[}mask @var{maskvalue}@r{]}} argument allows creation
   5152 of masked watchpoints, if the current architecture supports this
   5153 feature (e.g., PowerPC Embedded architecture, see @ref{PowerPC
   5154 Embedded}.)  A @dfn{masked watchpoint} specifies a mask in addition
   5155 to an address to watch.  The mask specifies that some bits of an address
   5156 (the bits which are reset in the mask) should be ignored when matching
   5157 the address accessed by the inferior against the watchpoint address.
   5158 Thus, a masked watchpoint watches many addresses simultaneously---those
   5159 addresses whose unmasked bits are identical to the unmasked bits in the
   5160 watchpoint address.  The @code{mask} argument implies @code{-location}.
   5161 Examples:
   5162 
   5163 @smallexample
   5164 (@value{GDBP}) watch foo mask 0xffff00ff
   5165 (@value{GDBP}) watch *0xdeadbeef mask 0xffffff00
   5166 @end smallexample
   5167 
   5168 @kindex rwatch
   5169 @item rwatch @r{[}-l@r{|}-location@r{]} @var{expr} @r{[}thread @var{thread-id}@r{]} @r{[}mask @var{maskvalue}@r{]}
   5170 Set a watchpoint that will break when the value of @var{expr} is read
   5171 by the program.
   5172 
   5173 @kindex awatch
   5174 @item awatch @r{[}-l@r{|}-location@r{]} @var{expr} @r{[}thread @var{thread-id}@r{]} @r{[}mask @var{maskvalue}@r{]}
   5175 Set a watchpoint that will break when @var{expr} is either read from
   5176 or written into by the program.
   5177 
   5178 @kindex info watchpoints @r{[}@var{list}@dots{}@r{]}
   5179 @item info watchpoints @r{[}@var{list}@dots{}@r{]}
   5180 This command prints a list of watchpoints, using the same format as
   5181 @code{info break} (@pxref{Set Breaks}).
   5182 @end table
   5183 
   5184 If you watch for a change in a numerically entered address you need to
   5185 dereference it, as the address itself is just a constant number which will
   5186 never change.  @value{GDBN} refuses to create a watchpoint that watches
   5187 a never-changing value:
   5188 
   5189 @smallexample
   5190 (@value{GDBP}) watch 0x600850
   5191 Cannot watch constant value 0x600850.
   5192 (@value{GDBP}) watch *(int *) 0x600850
   5193 Watchpoint 1: *(int *) 6293584
   5194 @end smallexample
   5195 
   5196 @value{GDBN} sets a @dfn{hardware watchpoint} if possible.  Hardware
   5197 watchpoints execute very quickly, and the debugger reports a change in
   5198 value at the exact instruction where the change occurs.  If @value{GDBN}
   5199 cannot set a hardware watchpoint, it sets a software watchpoint, which
   5200 executes more slowly and reports the change in value at the next
   5201 @emph{statement}, not the instruction, after the change occurs.
   5202 
   5203 @cindex use only software watchpoints
   5204 You can force @value{GDBN} to use only software watchpoints with the
   5205 @kbd{set can-use-hw-watchpoints 0} command.  With this variable set to
   5206 zero, @value{GDBN} will never try to use hardware watchpoints, even if
   5207 the underlying system supports them.  (Note that hardware-assisted
   5208 watchpoints that were set @emph{before} setting
   5209 @code{can-use-hw-watchpoints} to zero will still use the hardware
   5210 mechanism of watching expression values.)
   5211 
   5212 @table @code
   5213 @item set can-use-hw-watchpoints
   5214 @kindex set can-use-hw-watchpoints
   5215 Set whether or not to use hardware watchpoints.
   5216 
   5217 @item show can-use-hw-watchpoints
   5218 @kindex show can-use-hw-watchpoints
   5219 Show the current mode of using hardware watchpoints.
   5220 @end table
   5221 
   5222 For remote targets, you can restrict the number of hardware
   5223 watchpoints @value{GDBN} will use, see @ref{set remote
   5224 hardware-breakpoint-limit}.
   5225 
   5226 When you issue the @code{watch} command, @value{GDBN} reports
   5227 
   5228 @smallexample
   5229 Hardware watchpoint @var{num}: @var{expr}
   5230 @end smallexample
   5231 
   5232 @noindent
   5233 if it was able to set a hardware watchpoint.
   5234 
   5235 Currently, the @code{awatch} and @code{rwatch} commands can only set
   5236 hardware watchpoints, because accesses to data that don't change the
   5237 value of the watched expression cannot be detected without examining
   5238 every instruction as it is being executed, and @value{GDBN} does not do
   5239 that currently.  If @value{GDBN} finds that it is unable to set a
   5240 hardware breakpoint with the @code{awatch} or @code{rwatch} command, it
   5241 will print a message like this:
   5242 
   5243 @smallexample
   5244 Expression cannot be implemented with read/access watchpoint.
   5245 @end smallexample
   5246 
   5247 Sometimes, @value{GDBN} cannot set a hardware watchpoint because the
   5248 data type of the watched expression is wider than what a hardware
   5249 watchpoint on the target machine can handle.  For example, some systems
   5250 can only watch regions that are up to 4 bytes wide; on such systems you
   5251 cannot set hardware watchpoints for an expression that yields a
   5252 double-precision floating-point number (which is typically 8 bytes
   5253 wide).  As a work-around, it might be possible to break the large region
   5254 into a series of smaller ones and watch them with separate watchpoints.
   5255 
   5256 If you set too many hardware watchpoints, @value{GDBN} might be unable
   5257 to insert all of them when you resume the execution of your program.
   5258 Since the precise number of active watchpoints is unknown until such
   5259 time as the program is about to be resumed, @value{GDBN} might not be
   5260 able to warn you about this when you set the watchpoints, and the
   5261 warning will be printed only when the program is resumed:
   5262 
   5263 @smallexample
   5264 Hardware watchpoint @var{num}: Could not insert watchpoint
   5265 @end smallexample
   5266 
   5267 @noindent
   5268 If this happens, delete or disable some of the watchpoints.
   5269 
   5270 Watching complex expressions that reference many variables can also
   5271 exhaust the resources available for hardware-assisted watchpoints.
   5272 That's because @value{GDBN} needs to watch every variable in the
   5273 expression with separately allocated resources.
   5274 
   5275 If you call a function interactively using @code{print} or @code{call},
   5276 any watchpoints you have set will be inactive until @value{GDBN} reaches another
   5277 kind of breakpoint or the call completes.
   5278 
   5279 @value{GDBN} automatically deletes watchpoints that watch local
   5280 (automatic) variables, or expressions that involve such variables, when
   5281 they go out of scope, that is, when the execution leaves the block in
   5282 which these variables were defined.  In particular, when the program
   5283 being debugged terminates, @emph{all} local variables go out of scope,
   5284 and so only watchpoints that watch global variables remain set.  If you
   5285 rerun the program, you will need to set all such watchpoints again.  One
   5286 way of doing that would be to set a code breakpoint at the entry to the
   5287 @code{main} function and when it breaks, set all the watchpoints.
   5288 
   5289 @cindex watchpoints and threads
   5290 @cindex threads and watchpoints
   5291 In multi-threaded programs, watchpoints will detect changes to the
   5292 watched expression from every thread.
   5293 
   5294 @quotation
   5295 @emph{Warning:} In multi-threaded programs, software watchpoints
   5296 have only limited usefulness.  If @value{GDBN} creates a software
   5297 watchpoint, it can only watch the value of an expression @emph{in a
   5298 single thread}.  If you are confident that the expression can only
   5299 change due to the current thread's activity (and if you are also
   5300 confident that no other thread can become current), then you can use
   5301 software watchpoints as usual.  However, @value{GDBN} may not notice
   5302 when a non-current thread's activity changes the expression.  (Hardware
   5303 watchpoints, in contrast, watch an expression in all threads.)
   5304 @end quotation
   5305 
   5306 @xref{set remote hardware-watchpoint-limit}.
   5307 
   5308 @node Set Catchpoints
   5309 @subsection Setting Catchpoints
   5310 @cindex catchpoints, setting
   5311 @cindex exception handlers
   5312 @cindex event handling
   5313 
   5314 You can use @dfn{catchpoints} to cause the debugger to stop for certain
   5315 kinds of program events, such as C@t{++} exceptions or the loading of a
   5316 shared library.  Use the @code{catch} command to set a catchpoint.
   5317 
   5318 @table @code
   5319 @kindex catch
   5320 @item catch @var{event}
   5321 Stop when @var{event} occurs.  The @var{event} can be any of the following:
   5322 
   5323 @table @code
   5324 @item throw @r{[}@var{regexp}@r{]}
   5325 @itemx rethrow @r{[}@var{regexp}@r{]}
   5326 @itemx catch @r{[}@var{regexp}@r{]}
   5327 @kindex catch throw
   5328 @kindex catch rethrow
   5329 @kindex catch catch
   5330 @cindex stop on C@t{++} exceptions
   5331 The throwing, re-throwing, or catching of a C@t{++} exception.
   5332 
   5333 If @var{regexp} is given, then only exceptions whose type matches the
   5334 regular expression will be caught.
   5335 
   5336 @vindex $_exception@r{, convenience variable}
   5337 The convenience variable @code{$_exception} is available at an
   5338 exception-related catchpoint, on some systems.  This holds the
   5339 exception being thrown.
   5340 
   5341 There are currently some limitations to C@t{++} exception handling in
   5342 @value{GDBN}:
   5343 
   5344 @itemize @bullet
   5345 @item
   5346 The support for these commands is system-dependent.  Currently, only
   5347 systems using the @samp{gnu-v3} C@t{++} ABI (@pxref{ABI}) are
   5348 supported.
   5349 
   5350 @item
   5351 The regular expression feature and the @code{$_exception} convenience
   5352 variable rely on the presence of some SDT probes in @code{libstdc++}.
   5353 If these probes are not present, then these features cannot be used.
   5354 These probes were first available in the GCC 4.8 release, but whether
   5355 or not they are available in your GCC also depends on how it was
   5356 built.
   5357 
   5358 @item
   5359 The @code{$_exception} convenience variable is only valid at the
   5360 instruction at which an exception-related catchpoint is set.
   5361 
   5362 @item
   5363 When an exception-related catchpoint is hit, @value{GDBN} stops at a
   5364 location in the system library which implements runtime exception
   5365 support for C@t{++}, usually @code{libstdc++}.  You can use @code{up}
   5366 (@pxref{Selection}) to get to your code.
   5367 
   5368 @item
   5369 If you call a function interactively, @value{GDBN} normally returns
   5370 control to you when the function has finished executing.  If the call
   5371 raises an exception, however, the call may bypass the mechanism that
   5372 returns control to you and cause your program either to abort or to
   5373 simply continue running until it hits a breakpoint, catches a signal
   5374 that @value{GDBN} is listening for, or exits.  This is the case even if
   5375 you set a catchpoint for the exception; catchpoints on exceptions are
   5376 disabled within interactive calls.  @xref{Calling}, for information on
   5377 controlling this with @code{set unwind-on-terminating-exception}.
   5378 
   5379 @item
   5380 You cannot raise an exception interactively.
   5381 
   5382 @item
   5383 You cannot install an exception handler interactively.
   5384 @end itemize
   5385 
   5386 @item exception @r{[}@var{name}@r{]}
   5387 @kindex catch exception
   5388 @cindex Ada exception catching
   5389 @cindex catch Ada exceptions
   5390 An Ada exception being raised.  If an exception name is specified
   5391 at the end of the command (eg @code{catch exception Program_Error}),
   5392 the debugger will stop only when this specific exception is raised.
   5393 Otherwise, the debugger stops execution when any Ada exception is raised.
   5394 
   5395 When inserting an exception catchpoint on a user-defined exception whose
   5396 name is identical to one of the exceptions defined by the language, the
   5397 fully qualified name must be used as the exception name.  Otherwise,
   5398 @value{GDBN} will assume that it should stop on the pre-defined exception
   5399 rather than the user-defined one.  For instance, assuming an exception
   5400 called @code{Constraint_Error} is defined in package @code{Pck}, then
   5401 the command to use to catch such exceptions is @kbd{catch exception
   5402 Pck.Constraint_Error}.
   5403 
   5404 @vindex $_ada_exception@r{, convenience variable}
   5405 The convenience variable @code{$_ada_exception} holds the address of
   5406 the exception being thrown.  This can be useful when setting a
   5407 condition for such a catchpoint.
   5408 
   5409 @item exception unhandled
   5410 @kindex catch exception unhandled
   5411 An exception that was raised but is not handled by the program.  The
   5412 convenience variable @code{$_ada_exception} is set as for @code{catch
   5413 exception}.
   5414 
   5415 @item handlers @r{[}@var{name}@r{]}
   5416 @kindex catch handlers
   5417 @cindex Ada exception handlers catching
   5418 @cindex catch Ada exceptions when handled
   5419 An Ada exception being handled.  If an exception name is
   5420 specified at the end of the command
   5421  (eg @kbd{catch handlers Program_Error}), the debugger will stop
   5422 only when this specific exception is handled.
   5423 Otherwise, the debugger stops execution when any Ada exception is handled.
   5424 
   5425 When inserting a handlers catchpoint on a user-defined
   5426 exception whose name is identical to one of the exceptions
   5427 defined by the language, the fully qualified name must be used
   5428 as the exception name.  Otherwise, @value{GDBN} will assume that it
   5429 should stop on the pre-defined exception rather than the
   5430 user-defined one.  For instance, assuming an exception called
   5431  @code{Constraint_Error} is defined in package @code{Pck}, then the
   5432 command to use to catch such exceptions handling is
   5433 @kbd{catch handlers Pck.Constraint_Error}.
   5434 
   5435 The convenience variable @code{$_ada_exception} is set as for
   5436 @code{catch exception}.
   5437 
   5438 @item assert
   5439 @kindex catch assert
   5440 A failed Ada assertion.  Note that the convenience variable
   5441 @code{$_ada_exception} is @emph{not} set by this catchpoint.
   5442 
   5443 @item exec
   5444 @kindex catch exec
   5445 @cindex break on fork/exec
   5446 A call to @code{exec}.
   5447 
   5448 @anchor{catch syscall}
   5449 @item syscall
   5450 @itemx syscall @r{[}@var{name} @r{|} @var{number} @r{|} @r{group:}@var{groupname} @r{|} @r{g:}@var{groupname}@r{]} @dots{}
   5451 @kindex catch syscall
   5452 @cindex break on a system call.
   5453 A call to or return from a system call, a.k.a.@: @dfn{syscall}.  A
   5454 syscall is a mechanism for application programs to request a service
   5455 from the operating system (OS) or one of the OS system services.
   5456 @value{GDBN} can catch some or all of the syscalls issued by the
   5457 debuggee, and show the related information for each syscall.  If no
   5458 argument is specified, calls to and returns from all system calls
   5459 will be caught.
   5460 
   5461 @var{name} can be any system call name that is valid for the
   5462 underlying OS.  Just what syscalls are valid depends on the OS.  On
   5463 GNU and Unix systems, you can find the full list of valid syscall
   5464 names on @file{/usr/include/asm/unistd.h}.
   5465 
   5466 @c For MS-Windows, the syscall names and the corresponding numbers
   5467 @c can be found, e.g., on this URL:
   5468 @c http://www.metasploit.com/users/opcode/syscalls.html
   5469 @c but we don't support Windows syscalls yet.
   5470 
   5471 Normally, @value{GDBN} knows in advance which syscalls are valid for
   5472 each OS, so you can use the @value{GDBN} command-line completion
   5473 facilities (@pxref{Completion,, command completion}) to list the
   5474 available choices.
   5475 
   5476 You may also specify the system call numerically.  A syscall's
   5477 number is the value passed to the OS's syscall dispatcher to
   5478 identify the requested service.  When you specify the syscall by its
   5479 name, @value{GDBN} uses its database of syscalls to convert the name
   5480 into the corresponding numeric code, but using the number directly
   5481 may be useful if @value{GDBN}'s database does not have the complete
   5482 list of syscalls on your system (e.g., because @value{GDBN} lags
   5483 behind the OS upgrades).
   5484 
   5485 You may specify a group of related syscalls to be caught at once using
   5486 the @code{group:} syntax (@code{g:} is a shorter equivalent).  For
   5487 instance, on some platforms @value{GDBN} allows you to catch all
   5488 network related syscalls, by passing the argument @code{group:network}
   5489 to @code{catch syscall}.  Note that not all syscall groups are
   5490 available in every system.  You can use the command completion
   5491 facilities (@pxref{Completion,, command completion}) to list the
   5492 syscall groups available on your environment.
   5493 
   5494 The example below illustrates how this command works if you don't provide
   5495 arguments to it:
   5496 
   5497 @smallexample
   5498 (@value{GDBP}) catch syscall
   5499 Catchpoint 1 (syscall)
   5500 (@value{GDBP}) r
   5501 Starting program: /tmp/catch-syscall
   5502 
   5503 Catchpoint 1 (call to syscall 'close'), \
   5504 	   0xffffe424 in __kernel_vsyscall ()
   5505 (@value{GDBP}) c
   5506 Continuing.
   5507 
   5508 Catchpoint 1 (returned from syscall 'close'), \
   5509 	0xffffe424 in __kernel_vsyscall ()
   5510 (@value{GDBP})
   5511 @end smallexample
   5512 
   5513 Here is an example of catching a system call by name:
   5514 
   5515 @smallexample
   5516 (@value{GDBP}) catch syscall chroot
   5517 Catchpoint 1 (syscall 'chroot' [61])
   5518 (@value{GDBP}) r
   5519 Starting program: /tmp/catch-syscall
   5520 
   5521 Catchpoint 1 (call to syscall 'chroot'), \
   5522 		   0xffffe424 in __kernel_vsyscall ()
   5523 (@value{GDBP}) c
   5524 Continuing.
   5525 
   5526 Catchpoint 1 (returned from syscall 'chroot'), \
   5527 	0xffffe424 in __kernel_vsyscall ()
   5528 (@value{GDBP})
   5529 @end smallexample
   5530 
   5531 An example of specifying a system call numerically.  In the case
   5532 below, the syscall number has a corresponding entry in the XML
   5533 file, so @value{GDBN} finds its name and prints it:
   5534 
   5535 @smallexample
   5536 (@value{GDBP}) catch syscall 252
   5537 Catchpoint 1 (syscall(s) 'exit_group')
   5538 (@value{GDBP}) r
   5539 Starting program: /tmp/catch-syscall
   5540 
   5541 Catchpoint 1 (call to syscall 'exit_group'), \
   5542 		   0xffffe424 in __kernel_vsyscall ()
   5543 (@value{GDBP}) c
   5544 Continuing.
   5545 
   5546 Program exited normally.
   5547 (@value{GDBP})
   5548 @end smallexample
   5549 
   5550 Here is an example of catching a syscall group:
   5551 
   5552 @smallexample
   5553 (@value{GDBP}) catch syscall group:process
   5554 Catchpoint 1 (syscalls 'exit' [1] 'fork' [2] 'waitpid' [7]
   5555 'execve' [11] 'wait4' [114] 'clone' [120] 'vfork' [190]
   5556 'exit_group' [252] 'waitid' [284] 'unshare' [310])
   5557 (@value{GDBP}) r
   5558 Starting program: /tmp/catch-syscall
   5559 
   5560 Catchpoint 1 (call to syscall fork), 0x00007ffff7df4e27 in open64 ()
   5561    from /lib64/ld-linux-x86-64.so.2
   5562 
   5563 (@value{GDBP}) c
   5564 Continuing.
   5565 @end smallexample
   5566 
   5567 However, there can be situations when there is no corresponding name
   5568 in XML file for that syscall number.  In this case, @value{GDBN} prints
   5569 a warning message saying that it was not able to find the syscall name,
   5570 but the catchpoint will be set anyway.  See the example below:
   5571 
   5572 @smallexample
   5573 (@value{GDBP}) catch syscall 764
   5574 warning: The number '764' does not represent a known syscall.
   5575 Catchpoint 2 (syscall 764)
   5576 (@value{GDBP})
   5577 @end smallexample
   5578 
   5579 If you configure @value{GDBN} using the @samp{--without-expat} option,
   5580 it will not be able to display syscall names.  Also, if your
   5581 architecture does not have an XML file describing its system calls,
   5582 you will not be able to see the syscall names.  It is important to
   5583 notice that these two features are used for accessing the syscall
   5584 name database.  In either case, you will see a warning like this:
   5585 
   5586 @smallexample
   5587 (@value{GDBP}) catch syscall
   5588 warning: Could not open "syscalls/i386-linux.xml"
   5589 warning: Could not load the syscall XML file 'syscalls/i386-linux.xml'.
   5590 GDB will not be able to display syscall names.
   5591 Catchpoint 1 (syscall)
   5592 (@value{GDBP})
   5593 @end smallexample
   5594 
   5595 Of course, the file name will change depending on your architecture and system.
   5596 
   5597 Still using the example above, you can also try to catch a syscall by its
   5598 number.  In this case, you would see something like:
   5599 
   5600 @smallexample
   5601 (@value{GDBP}) catch syscall 252
   5602 Catchpoint 1 (syscall(s) 252)
   5603 @end smallexample
   5604 
   5605 Again, in this case @value{GDBN} would not be able to display syscall's names.
   5606 
   5607 @item fork
   5608 @kindex catch fork
   5609 A call to @code{fork}.
   5610 
   5611 @item vfork
   5612 @kindex catch vfork
   5613 A call to @code{vfork}.
   5614 
   5615 @item load @r{[}@var{regexp}@r{]}
   5616 @itemx unload @r{[}@var{regexp}@r{]}
   5617 @kindex catch load
   5618 @kindex catch unload
   5619 The loading or unloading of a shared library.  If @var{regexp} is
   5620 given, then the catchpoint will stop only if the regular expression
   5621 matches one of the affected libraries.
   5622 
   5623 @item signal @r{[}@var{signal}@dots{} @r{|} @samp{all}@r{]}
   5624 @kindex catch signal
   5625 The delivery of a signal.
   5626 
   5627 With no arguments, this catchpoint will catch any signal that is not
   5628 used internally by @value{GDBN}, specifically, all signals except
   5629 @samp{SIGTRAP} and @samp{SIGINT}.
   5630 
   5631 With the argument @samp{all}, all signals, including those used by
   5632 @value{GDBN}, will be caught.  This argument cannot be used with other
   5633 signal names.
   5634 
   5635 Otherwise, the arguments are a list of signal names as given to
   5636 @code{handle} (@pxref{Signals}).  Only signals specified in this list
   5637 will be caught.
   5638 
   5639 One reason that @code{catch signal} can be more useful than
   5640 @code{handle} is that you can attach commands and conditions to the
   5641 catchpoint.
   5642 
   5643 When a signal is caught by a catchpoint, the signal's @code{stop} and
   5644 @code{print} settings, as specified by @code{handle}, are ignored.
   5645 However, whether the signal is still delivered to the inferior depends
   5646 on the @code{pass} setting; this can be changed in the catchpoint's
   5647 commands.
   5648 
   5649 @end table
   5650 
   5651 @item tcatch @var{event}
   5652 @kindex tcatch
   5653 Set a catchpoint that is enabled only for one stop.  The catchpoint is
   5654 automatically deleted after the first time the event is caught.
   5655 
   5656 @end table
   5657 
   5658 Use the @code{info break} command to list the current catchpoints.
   5659 
   5660 
   5661 @node Delete Breaks
   5662 @subsection Deleting Breakpoints
   5663 
   5664 @cindex clearing breakpoints, watchpoints, catchpoints
   5665 @cindex deleting breakpoints, watchpoints, catchpoints
   5666 It is often necessary to eliminate a breakpoint, watchpoint, or
   5667 catchpoint once it has done its job and you no longer want your program
   5668 to stop there.  This is called @dfn{deleting} the breakpoint.  A
   5669 breakpoint that has been deleted no longer exists; it is forgotten.
   5670 
   5671 With the @code{clear} command you can delete breakpoints according to
   5672 where they are in your program.  With the @code{delete} command you can
   5673 delete individual breakpoints, watchpoints, or catchpoints by specifying
   5674 their breakpoint numbers.
   5675 
   5676 It is not necessary to delete a breakpoint to proceed past it.  @value{GDBN}
   5677 automatically ignores breakpoints on the first instruction to be executed
   5678 when you continue execution without changing the execution address.
   5679 
   5680 @table @code
   5681 @kindex clear
   5682 @item clear
   5683 Delete any breakpoints at the next instruction to be executed in the
   5684 selected stack frame (@pxref{Selection, ,Selecting a Frame}).  When
   5685 the innermost frame is selected, this is a good way to delete a
   5686 breakpoint where your program just stopped.
   5687 
   5688 @item clear @var{locspec}
   5689 Delete any breakpoint with a code location that corresponds to
   5690 @var{locspec}.  @xref{Location Specifications}, for the various forms
   5691 of @var{locspec}.  Which code locations correspond to @var{locspec}
   5692 depends on the form used in the location specification @var{locspec}:
   5693 
   5694 @table @code
   5695 @item @var{linenum}
   5696 @itemx @var{filename}:@var{linenum}
   5697 @itemx -line @var{linenum}
   5698 @itemx -source @var{filename} -line @var{linenum}
   5699 If @var{locspec} specifies a line number, with or without a file name,
   5700 the command deletes any breakpoint with a code location that is at or
   5701 within the specified line @var{linenum} in files that match the
   5702 specified @var{filename}.  If @var{filename} is omitted, it defaults
   5703 to the current source file.
   5704 
   5705 @item *@var{address}
   5706 If @var{locspec} specifies an address, the command deletes any
   5707 breakpoint with a code location that is at the given @var{address}.
   5708 
   5709 @item @var{function}
   5710 @itemx -function @var{function}
   5711 If @var{locspec} specifies a function, the command deletes any
   5712 breakpoint with a code location that is at the entry to any function
   5713 whose name matches @var{function}.
   5714 @end table
   5715 
   5716 Ambiguity in names of files and functions can be resolved as described
   5717 in @ref{Location Specifications}.
   5718 
   5719 @cindex delete breakpoints
   5720 @kindex delete
   5721 @kindex d @r{(@code{delete})}
   5722 @item delete @r{[}breakpoints@r{]} @r{[}@var{list}@dots{}@r{]}
   5723 Delete the breakpoints, watchpoints, tracepoints, or catchpoints of the
   5724 breakpoint list specified as argument.  If no argument is specified, delete
   5725 all breakpoints, watchpoints, tracepoints, and catchpoints (@value{GDBN} asks
   5726 confirmation, unless you have @code{set confirm off}).  You can abbreviate this
   5727 command as @code{d}.
   5728 @end table
   5729 
   5730 @node Disabling
   5731 @subsection Disabling Breakpoints
   5732 
   5733 @cindex enable/disable a breakpoint
   5734 Rather than deleting a breakpoint, watchpoint, or catchpoint, you might
   5735 prefer to @dfn{disable} it.  This makes the breakpoint inoperative as if
   5736 it had been deleted, but remembers the information on the breakpoint so
   5737 that you can @dfn{enable} it again later.
   5738 
   5739 You disable and enable breakpoints, watchpoints, tracepoints, and catchpoints
   5740 with the @code{enable} and @code{disable} commands, optionally specifying
   5741 one or more breakpoint numbers as arguments.  Use @code{info break} to print
   5742 a list of all breakpoints, watchpoints, tracepoints, and catchpoints if you
   5743 do not know which numbers to use.
   5744 
   5745 Disabling and enabling a breakpoint that has multiple locations
   5746 affects all of its locations.
   5747 
   5748 A breakpoint, watchpoint, or catchpoint can have any of several
   5749 different states of enablement:
   5750 
   5751 @itemize @bullet
   5752 @item
   5753 Enabled.  The breakpoint stops your program.  A breakpoint set
   5754 with the @code{break} command starts out in this state.
   5755 @item
   5756 Disabled.  The breakpoint has no effect on your program.
   5757 @item
   5758 Enabled once.  The breakpoint stops your program, but then becomes
   5759 disabled.
   5760 @item
   5761 Enabled for a count.  The breakpoint stops your program for the next
   5762 N times, then becomes disabled.
   5763 @item
   5764 Enabled for deletion.  The breakpoint stops your program, but
   5765 immediately after it does so it is deleted permanently.  A breakpoint
   5766 set with the @code{tbreak} command starts out in this state.
   5767 @end itemize
   5768 
   5769 You can use the following commands to enable or disable breakpoints,
   5770 watchpoints, tracepoints, and catchpoints:
   5771 
   5772 @table @code
   5773 @kindex disable
   5774 @kindex dis @r{(@code{disable})}
   5775 @item disable @r{[}breakpoints@r{]} @r{[}@var{list}@dots{}@r{]}
   5776 Disable the specified breakpoints---or all breakpoints, if none are
   5777 listed.  A disabled breakpoint has no effect but is not forgotten.  All
   5778 options such as ignore-counts, conditions and commands are remembered in
   5779 case the breakpoint is enabled again later.  You may abbreviate
   5780 @code{disable} as @code{dis}.
   5781 
   5782 @kindex enable
   5783 @item enable @r{[}breakpoints@r{]} @r{[}@var{list}@dots{}@r{]}
   5784 Enable the specified breakpoints (or all defined breakpoints).  They
   5785 become effective once again in stopping your program.
   5786 
   5787 @item enable @r{[}breakpoints@r{]} once @var{list}@dots{}
   5788 Enable the specified breakpoints temporarily.  @value{GDBN} disables any
   5789 of these breakpoints immediately after stopping your program.
   5790 
   5791 @item enable @r{[}breakpoints@r{]} count @var{count} @var{list}@dots{}
   5792 Enable the specified breakpoints temporarily.  @value{GDBN} records
   5793 @var{count} with each of the specified breakpoints, and decrements a
   5794 breakpoint's count when it is hit.  When any count reaches 0,
   5795 @value{GDBN} disables that breakpoint.  If a breakpoint has an ignore
   5796 count (@pxref{Conditions, ,Break Conditions}), that will be
   5797 decremented to 0 before @var{count} is affected.
   5798 
   5799 @item enable @r{[}breakpoints@r{]} delete @var{list}@dots{}
   5800 Enable the specified breakpoints to work once, then die.  @value{GDBN}
   5801 deletes any of these breakpoints as soon as your program stops there.
   5802 Breakpoints set by the @code{tbreak} command start out in this state.
   5803 @end table
   5804 
   5805 @c FIXME: I think the following ``Except for [...] @code{tbreak}'' is
   5806 @c confusing: tbreak is also initially enabled.
   5807 Except for a breakpoint set with @code{tbreak} (@pxref{Set Breaks,
   5808 ,Setting Breakpoints}), breakpoints that you set are initially enabled;
   5809 subsequently, they become disabled or enabled only when you use one of
   5810 the commands above.  (The command @code{until} can set and delete a
   5811 breakpoint of its own, but it does not change the state of your other
   5812 breakpoints; see @ref{Continuing and Stepping, ,Continuing and
   5813 Stepping}.)
   5814 
   5815 @node Conditions
   5816 @subsection Break Conditions
   5817 @cindex conditional breakpoints
   5818 @cindex breakpoint conditions
   5819 
   5820 @c FIXME what is scope of break condition expr?  Context where wanted?
   5821 @c      in particular for a watchpoint?
   5822 The simplest sort of breakpoint breaks every time your program reaches a
   5823 specified place.  You can also specify a @dfn{condition} for a
   5824 breakpoint.  A condition is just a Boolean expression in your
   5825 programming language (@pxref{Expressions, ,Expressions}).  A breakpoint with
   5826 a condition evaluates the expression each time your program reaches it,
   5827 and your program stops only if the condition is @emph{true}.
   5828 
   5829 This is the converse of using assertions for program validation; in that
   5830 situation, you want to stop when the assertion is violated---that is,
   5831 when the condition is false.  In C, if you want to test an assertion expressed
   5832 by the condition @var{assert}, you should set the condition
   5833 @samp{! @var{assert}} on the appropriate breakpoint.
   5834 
   5835 Conditions are also accepted for watchpoints; you may not need them,
   5836 since a watchpoint is inspecting the value of an expression anyhow---but
   5837 it might be simpler, say, to just set a watchpoint on a variable name,
   5838 and specify a condition that tests whether the new value is an interesting
   5839 one.
   5840 
   5841 Break conditions can have side effects, and may even call functions in
   5842 your program.  This can be useful, for example, to activate functions
   5843 that log program progress, or to use your own print functions to
   5844 format special data structures.  The effects are completely predictable
   5845 unless there is another enabled breakpoint at the same address.  (In
   5846 that case, @value{GDBN} might see the other breakpoint first and stop your
   5847 program without checking the condition of this one.)  Note that
   5848 breakpoint commands are usually more convenient and flexible than break
   5849 conditions for the
   5850 purpose of performing side effects when a breakpoint is reached
   5851 (@pxref{Break Commands, ,Breakpoint Command Lists}).
   5852 
   5853 Breakpoint conditions can also be evaluated on the target's side if
   5854 the target supports it.  Instead of evaluating the conditions locally,
   5855 @value{GDBN} encodes the expression into an agent expression
   5856 (@pxref{Agent Expressions}) suitable for execution on the target,
   5857 independently of @value{GDBN}.  Global variables become raw memory
   5858 locations, locals become stack accesses, and so forth.
   5859 
   5860 In this case, @value{GDBN} will only be notified of a breakpoint trigger
   5861 when its condition evaluates to true.  This mechanism may provide faster
   5862 response times depending on the performance characteristics of the target
   5863 since it does not need to keep @value{GDBN} informed about
   5864 every breakpoint trigger, even those with false conditions.
   5865 
   5866 Break conditions can be specified when a breakpoint is set, by using
   5867 @samp{if} in the arguments to the @code{break} command.  @xref{Set
   5868 Breaks, ,Setting Breakpoints}.  They can also be changed at any time
   5869 with the @code{condition} command.
   5870 
   5871 You can also use the @code{if} keyword with the @code{watch} command.
   5872 The @code{catch} command does not recognize the @code{if} keyword;
   5873 @code{condition} is the only way to impose a further condition on a
   5874 catchpoint.
   5875 
   5876 @table @code
   5877 @kindex condition
   5878 @item condition @var{bnum} @var{expression}
   5879 Specify @var{expression} as the break condition for breakpoint,
   5880 watchpoint, or catchpoint number @var{bnum}.  After you set a condition,
   5881 breakpoint @var{bnum} stops your program only if the value of
   5882 @var{expression} is true (nonzero, in C).  When you use
   5883 @code{condition}, @value{GDBN} checks @var{expression} immediately for
   5884 syntactic correctness, and to determine whether symbols in it have
   5885 referents in the context of your breakpoint.  If @var{expression} uses
   5886 symbols not referenced in the context of the breakpoint, @value{GDBN}
   5887 prints an error message:
   5888 
   5889 @smallexample
   5890 No symbol "foo" in current context.
   5891 @end smallexample
   5892 
   5893 @noindent
   5894 @value{GDBN} does
   5895 not actually evaluate @var{expression} at the time the @code{condition}
   5896 command (or a command that sets a breakpoint with a condition, like
   5897 @code{break if @dots{}}) is given, however.  @xref{Expressions, ,Expressions}.
   5898 
   5899 @item condition -force @var{bnum} @var{expression}
   5900 When the @code{-force} flag is used, define the condition even if
   5901 @var{expression} is invalid at all the current locations of breakpoint
   5902 @var{bnum}.  This is similar to the @code{-force-condition} option
   5903 of the @code{break} command.
   5904 
   5905 @item condition @var{bnum}
   5906 Remove the condition from breakpoint number @var{bnum}.  It becomes
   5907 an ordinary unconditional breakpoint.
   5908 @end table
   5909 
   5910 @cindex ignore count (of breakpoint)
   5911 A special case of a breakpoint condition is to stop only when the
   5912 breakpoint has been reached a certain number of times.  This is so
   5913 useful that there is a special way to do it, using the @dfn{ignore
   5914 count} of the breakpoint.  Every breakpoint has an ignore count, which
   5915 is an integer.  Most of the time, the ignore count is zero, and
   5916 therefore has no effect.  But if your program reaches a breakpoint whose
   5917 ignore count is positive, then instead of stopping, it just decrements
   5918 the ignore count by one and continues.  As a result, if the ignore count
   5919 value is @var{n}, the breakpoint does not stop the next @var{n} times
   5920 your program reaches it.
   5921 
   5922 @table @code
   5923 @kindex ignore
   5924 @item ignore @var{bnum} @var{count}
   5925 Set the ignore count of breakpoint number @var{bnum} to @var{count}.
   5926 The next @var{count} times the breakpoint is reached, your program's
   5927 execution does not stop; other than to decrement the ignore count, @value{GDBN}
   5928 takes no action.
   5929 
   5930 To make the breakpoint stop the next time it is reached, specify
   5931 a count of zero.
   5932 
   5933 When you use @code{continue} to resume execution of your program from a
   5934 breakpoint, you can specify an ignore count directly as an argument to
   5935 @code{continue}, rather than using @code{ignore}.  @xref{Continuing and
   5936 Stepping,,Continuing and Stepping}.
   5937 
   5938 If a breakpoint has a positive ignore count and a condition, the
   5939 condition is not checked.  Once the ignore count reaches zero,
   5940 @value{GDBN} resumes checking the condition.
   5941 
   5942 You could achieve the effect of the ignore count with a condition such
   5943 as @w{@samp{$foo-- <= 0}} using a debugger convenience variable that
   5944 is decremented each time.  @xref{Convenience Vars, ,Convenience
   5945 Variables}.
   5946 @end table
   5947 
   5948 Ignore counts apply to breakpoints, watchpoints, tracepoints, and catchpoints.
   5949 
   5950 
   5951 @node Break Commands
   5952 @subsection Breakpoint Command Lists
   5953 
   5954 @cindex breakpoint commands
   5955 You can give any breakpoint (or watchpoint or catchpoint) a series of
   5956 commands to execute when your program stops due to that breakpoint.  For
   5957 example, you might want to print the values of certain expressions, or
   5958 enable other breakpoints.
   5959 
   5960 @table @code
   5961 @kindex commands
   5962 @kindex end@r{ (breakpoint commands)}
   5963 @item commands @r{[}@var{list}@dots{}@r{]}
   5964 @itemx @dots{} @var{command-list} @dots{}
   5965 @itemx end
   5966 Specify a list of commands for the given breakpoints.  The commands
   5967 themselves appear on the following lines.  Type a line containing just
   5968 @code{end} to terminate the commands.
   5969 
   5970 To remove all commands from a breakpoint, type @code{commands} and
   5971 follow it immediately with @code{end}; that is, give no commands.
   5972 
   5973 With no argument, @code{commands} refers to the last breakpoint,
   5974 watchpoint, or catchpoint set (not to the breakpoint most recently
   5975 encountered).  If the most recent breakpoints were set with a single
   5976 command, then the @code{commands} will apply to all the breakpoints
   5977 set by that command.  This applies to breakpoints set by
   5978 @code{rbreak}, and also applies when a single @code{break} command
   5979 creates multiple breakpoints (@pxref{Ambiguous Expressions,,Ambiguous
   5980 Expressions}).
   5981 @end table
   5982 
   5983 Pressing @key{RET} as a means of repeating the last @value{GDBN} command is
   5984 disabled within a @var{command-list}.
   5985 
   5986 Inside a command list, you can use the command
   5987 @kbd{disable $_hit_bpnum} to disable the encountered breakpoint.
   5988 
   5989 If your breakpoint has several code locations, the command
   5990 @kbd{disable $_hit_bpnum.$_hit_locno} will disable the specific breakpoint
   5991 code location encountered.  If the breakpoint has only one location,
   5992 this command will disable the encountered breakpoint.
   5993 
   5994 You can use breakpoint commands to start your program up again.  Simply
   5995 use the @code{continue} command, or @code{step}, or any other command
   5996 that resumes execution.
   5997 
   5998 Any other commands in the command list, after a command that resumes
   5999 execution, are ignored.  This is because any time you resume execution
   6000 (even with a simple @code{next} or @code{step}), you may encounter
   6001 another breakpoint---which could have its own command list, leading to
   6002 ambiguities about which list to execute.
   6003 
   6004 @kindex silent
   6005 If the first command you specify in a command list is @code{silent}, the
   6006 usual message about stopping at a breakpoint is not printed.  This may
   6007 be desirable for breakpoints that are to print a specific message and
   6008 then continue.  If none of the remaining commands print anything, you
   6009 see no sign that the breakpoint was reached.  @code{silent} is
   6010 meaningful only at the beginning of a breakpoint command list.
   6011 
   6012 The commands @code{echo}, @code{output}, and @code{printf} allow you to
   6013 print precisely controlled output, and are often useful in silent
   6014 breakpoints.  @xref{Output, ,Commands for Controlled Output}.
   6015 
   6016 For example, here is how you could use breakpoint commands to print the
   6017 value of @code{x} at entry to @code{foo} whenever @code{x} is positive.
   6018 
   6019 @smallexample
   6020 break foo if x>0
   6021 commands
   6022 silent
   6023 printf "x is %d\n",x
   6024 cont
   6025 end
   6026 @end smallexample
   6027 
   6028 One application for breakpoint commands is to compensate for one bug so
   6029 you can test for another.  Put a breakpoint just after the erroneous line
   6030 of code, give it a condition to detect the case in which something
   6031 erroneous has been done, and give it commands to assign correct values
   6032 to any variables that need them.  End with the @code{continue} command
   6033 so that your program does not stop, and start with the @code{silent}
   6034 command so that no output is produced.  Here is an example:
   6035 
   6036 @smallexample
   6037 break 403
   6038 commands
   6039 silent
   6040 set x = y + 4
   6041 cont
   6042 end
   6043 @end smallexample
   6044 
   6045 @node Dynamic Printf
   6046 @subsection Dynamic Printf
   6047 
   6048 @cindex dynamic printf
   6049 @cindex dprintf
   6050 The dynamic printf command @code{dprintf} combines a breakpoint with
   6051 formatted printing of your program's data to give you the effect of
   6052 inserting @code{printf} calls into your program on-the-fly, without
   6053 having to recompile it.
   6054 
   6055 In its most basic form, the output goes to the GDB console.  However,
   6056 you can set the variable @code{dprintf-style} for alternate handling.
   6057 For instance, you can ask to format the output by calling your
   6058 program's @code{printf} function.  This has the advantage that the
   6059 characters go to the program's output device, so they can recorded in
   6060 redirects to files and so forth.
   6061 
   6062 If you are doing remote debugging with a stub or agent, you can also
   6063 ask to have the printf handled by the remote agent.  In addition to
   6064 ensuring that the output goes to the remote program's device along
   6065 with any other output the program might produce, you can also ask that
   6066 the dprintf remain active even after disconnecting from the remote
   6067 target.  Using the stub/agent is also more efficient, as it can do
   6068 everything without needing to communicate with @value{GDBN}.
   6069 
   6070 @table @code
   6071 @kindex dprintf
   6072 @item dprintf @var{locspec},@var{template},@var{expression}[,@var{expression}@dots{}]
   6073 Whenever execution reaches a code location that results from resolving
   6074 @var{locspec}, print the values of one or more @var{expressions} under
   6075 the control of the string @var{template}.  To print several values,
   6076 separate them with commas.
   6077 
   6078 @item set dprintf-style @var{style}
   6079 Set the dprintf output to be handled in one of several different
   6080 styles enumerated below.  A change of style affects all existing
   6081 dynamic printfs immediately.  (If you need individual control over the
   6082 print commands, simply define normal breakpoints with
   6083 explicitly-supplied command lists.)
   6084 
   6085 @table @code
   6086 @item gdb
   6087 @kindex dprintf-style gdb
   6088 Handle the output using the @value{GDBN} @code{printf} command.  When
   6089 using this style, it is possible to use the @samp{%V} format specifier
   6090 (@pxref{%V Format Specifier}).
   6091 
   6092 @item call
   6093 @kindex dprintf-style call
   6094 Handle the output by calling a function in your program (normally
   6095 @code{printf}).  When using this style the supported format specifiers
   6096 depend entirely on the function being called.
   6097 
   6098 Most of @value{GDBN}'s format specifiers align with those supported by
   6099 the @code{printf} function, however, @value{GDBN}'s @samp{%V} format
   6100 specifier extension is not supported by @code{printf}.  When using
   6101 @samp{call} style dprintf, care should be taken to ensure that only
   6102 format specifiers supported by the output function are used, otherwise
   6103 the results will be undefined.
   6104 
   6105 @item agent
   6106 @kindex dprintf-style agent
   6107 Have the remote debugging agent (such as @code{gdbserver}) handle the
   6108 output itself.  This style is only available for agents that support
   6109 running commands on the target.  This style does not support the
   6110 @samp{%V} format specifier.
   6111 @end table
   6112 
   6113 @item set dprintf-function @var{function}
   6114 Set the function to call if the dprintf style is @code{call}.  By
   6115 default its value is @code{printf}.  You may set it to any expression
   6116 that @value{GDBN} can evaluate to a function, as per the @code{call}
   6117 command.
   6118 
   6119 @item set dprintf-channel @var{channel}
   6120 Set a ``channel'' for dprintf.  If set to a non-empty value,
   6121 @value{GDBN} will evaluate it as an expression and pass the result as
   6122 a first argument to the @code{dprintf-function}, in the manner of
   6123 @code{fprintf} and similar functions.  Otherwise, the dprintf format
   6124 string will be the first argument, in the manner of @code{printf}.
   6125 
   6126 As an example, if you wanted @code{dprintf} output to go to a logfile
   6127 that is a standard I/O stream assigned to the variable @code{mylog},
   6128 you could do the following:
   6129 
   6130 @example
   6131 (@value{GDBP}) set dprintf-style call
   6132 (@value{GDBP}) set dprintf-function fprintf
   6133 (@value{GDBP}) set dprintf-channel mylog
   6134 (@value{GDBP}) dprintf 25,"at line 25, glob=%d\n",glob
   6135 Dprintf 1 at 0x123456: file main.c, line 25.
   6136 (@value{GDBP}) info break
   6137 1       dprintf        keep y   0x00123456 in main at main.c:25
   6138         call (void) fprintf (mylog,"at line 25, glob=%d\n",glob)
   6139         continue
   6140 (@value{GDBP})
   6141 @end example
   6142 
   6143 Note that the @code{info break} displays the dynamic printf commands
   6144 as normal breakpoint commands; you can thus easily see the effect of
   6145 the variable settings.
   6146 
   6147 @item set disconnected-dprintf on
   6148 @itemx set disconnected-dprintf off
   6149 @kindex set disconnected-dprintf
   6150 Choose whether @code{dprintf} commands should continue to run if
   6151 @value{GDBN} has disconnected from the target.  This only applies
   6152 if the @code{dprintf-style} is @code{agent}.
   6153 
   6154 @item show disconnected-dprintf off
   6155 @kindex show disconnected-dprintf
   6156 Show the current choice for disconnected @code{dprintf}.
   6157 
   6158 @end table
   6159 
   6160 @value{GDBN} does not check the validity of function and channel,
   6161 relying on you to supply values that are meaningful for the contexts
   6162 in which they are being used.  For instance, the function and channel
   6163 may be the values of local variables, but if that is the case, then
   6164 all enabled dynamic prints must be at locations within the scope of
   6165 those locals.  If evaluation fails, @value{GDBN} will report an error.
   6166 
   6167 @node Save Breakpoints
   6168 @subsection How to save breakpoints to a file
   6169 
   6170 To save breakpoint definitions to a file use the @w{@code{save
   6171 breakpoints}} command.
   6172 
   6173 @table @code
   6174 @kindex save breakpoints
   6175 @cindex save breakpoints to a file for future sessions
   6176 @item save breakpoints [@var{filename}]
   6177 This command saves all current breakpoint definitions together with
   6178 their commands and ignore counts, into a file @file{@var{filename}}
   6179 suitable for use in a later debugging session.  This includes all
   6180 types of breakpoints (breakpoints, watchpoints, catchpoints,
   6181 tracepoints).  To read the saved breakpoint definitions, use the
   6182 @code{source} command (@pxref{Command Files}).  Note that watchpoints
   6183 with expressions involving local variables may fail to be recreated
   6184 because it may not be possible to access the context where the
   6185 watchpoint is valid anymore.  Because the saved breakpoint definitions
   6186 are simply a sequence of @value{GDBN} commands that recreate the
   6187 breakpoints, you can edit the file in your favorite editing program,
   6188 and remove the breakpoint definitions you're not interested in, or
   6189 that can no longer be recreated.
   6190 @end table
   6191 
   6192 @node Static Probe Points
   6193 @subsection Static Probe Points
   6194 
   6195 @cindex static probe point, SystemTap
   6196 @cindex static probe point, DTrace
   6197 @value{GDBN} supports @dfn{SDT} probes in the code.  @acronym{SDT} stands
   6198 for Statically Defined Tracing, and the probes are designed to have a tiny
   6199 runtime code and data footprint, and no dynamic relocations.
   6200 
   6201 Currently, the following types of probes are supported on
   6202 ELF-compatible systems:
   6203 
   6204 @itemize @bullet
   6205 
   6206 @item @code{SystemTap} (@uref{http://sourceware.org/systemtap/})
   6207 @acronym{SDT} probes@footnote{See
   6208 @uref{http://sourceware.org/systemtap/wiki/AddingUserSpaceProbingToApps}
   6209 for more information on how to add @code{SystemTap} @acronym{SDT}
   6210 probes in your applications.}.  @code{SystemTap} probes are usable
   6211 from assembly, C and C@t{++} languages@footnote{See
   6212 @uref{http://sourceware.org/systemtap/wiki/UserSpaceProbeImplementation}
   6213 for a good reference on how the @acronym{SDT} probes are implemented.}.  
   6214 
   6215 @item @code{DTrace} (@uref{http://oss.oracle.com/projects/DTrace})
   6216 @acronym{USDT} probes.  @code{DTrace} probes are usable from C and
   6217 C@t{++} languages.
   6218 @end itemize
   6219 
   6220 @cindex semaphores on static probe points
   6221 Some @code{SystemTap} probes have an associated semaphore variable;
   6222 for instance, this happens automatically if you defined your probe
   6223 using a DTrace-style @file{.d} file.  If your probe has a semaphore,
   6224 @value{GDBN} will automatically enable it when you specify a
   6225 breakpoint using the @samp{-probe-stap} notation.  But, if you put a
   6226 breakpoint at a probe's location by some other method (e.g.,
   6227 @code{break file:line}), then @value{GDBN} will not automatically set
   6228 the semaphore.  @code{DTrace} probes do not support semaphores.
   6229 
   6230 You can examine the available static static probes using @code{info
   6231 probes}, with optional arguments:
   6232 
   6233 @table @code
   6234 @kindex info probes
   6235 @item info probes @r{[}@var{type}@r{]} @r{[}@var{provider} @r{[}@var{name} @r{[}@var{objfile}@r{]}@r{]}@r{]}
   6236 If given, @var{type} is either @code{stap} for listing
   6237 @code{SystemTap} probes or @code{dtrace} for listing @code{DTrace}
   6238 probes.  If omitted all probes are listed regardless of their types.
   6239 
   6240 If given, @var{provider} is a regular expression used to match against provider
   6241 names when selecting which probes to list.  If omitted, probes by all
   6242 probes from all providers are listed.
   6243 
   6244 If given, @var{name} is a regular expression to match against probe names
   6245 when selecting which probes to list.  If omitted, probe names are not
   6246 considered when deciding whether to display them.
   6247 
   6248 If given, @var{objfile} is a regular expression used to select which
   6249 object files (executable or shared libraries) to examine.  If not
   6250 given, all object files are considered.
   6251 
   6252 @item info probes all
   6253 List the available static probes, from all types.
   6254 @end table
   6255 
   6256 @cindex enabling and disabling probes
   6257 Some probe points can be enabled and/or disabled.  The effect of
   6258 enabling or disabling a probe depends on the type of probe being
   6259 handled.  Some @code{DTrace} probes can be enabled or
   6260 disabled, but @code{SystemTap} probes cannot be disabled.
   6261 
   6262 You can enable (or disable) one or more probes using the following
   6263 commands, with optional arguments:
   6264 
   6265 @anchor{enable probes}
   6266 @table @code
   6267 @kindex enable probes
   6268 @item enable probes @r{[}@var{provider} @r{[}@var{name} @r{[}@var{objfile}@r{]}@r{]}@r{]}
   6269 If given, @var{provider} is a regular expression used to match against
   6270 provider names when selecting which probes to enable.  If omitted,
   6271 all probes from all providers are enabled.
   6272 
   6273 If given, @var{name} is a regular expression to match against probe
   6274 names when selecting which probes to enable.  If omitted, probe names
   6275 are not considered when deciding whether to enable them.
   6276 
   6277 If given, @var{objfile} is a regular expression used to select which
   6278 object files (executable or shared libraries) to examine.  If not
   6279 given, all object files are considered.
   6280 
   6281 @kindex disable probes
   6282 @item disable probes @r{[}@var{provider} @r{[}@var{name} @r{[}@var{objfile}@r{]}@r{]}@r{]}
   6283 See the @code{enable probes} command above for a description of the
   6284 optional arguments accepted by this command.
   6285 @end table
   6286 
   6287 @vindex $_probe_arg@r{, convenience variable}
   6288 A probe may specify up to twelve arguments.  These are available at the
   6289 point at which the probe is defined---that is, when the current PC is
   6290 at the probe's location.  The arguments are available using the
   6291 convenience variables (@pxref{Convenience Vars})
   6292 @code{$_probe_arg0}@dots{}@code{$_probe_arg11}.  In @code{SystemTap}
   6293 probes each probe argument is an integer of the appropriate size;
   6294 types are not preserved.  In @code{DTrace} probes types are preserved
   6295 provided that they are recognized as such by @value{GDBN}; otherwise
   6296 the value of the probe argument will be a long integer.  The
   6297 convenience variable @code{$_probe_argc} holds the number of arguments
   6298 at the current probe point.
   6299 
   6300 These variables are always available, but attempts to access them at
   6301 any location other than a probe point will cause @value{GDBN} to give
   6302 an error message.
   6303 
   6304 
   6305 @c  @ifclear BARETARGET
   6306 @node Error in Breakpoints
   6307 @subsection ``Cannot insert breakpoints''
   6308 
   6309 If you request too many active hardware-assisted breakpoints and
   6310 watchpoints, you will see this error message:
   6311 
   6312 @c FIXME: the precise wording of this message may change; the relevant
   6313 @c source change is not committed yet (Sep 3, 1999).
   6314 @smallexample
   6315 Stopped; cannot insert breakpoints.
   6316 You may have requested too many hardware breakpoints and watchpoints.
   6317 @end smallexample
   6318 
   6319 @noindent
   6320 This message is printed when you attempt to resume the program, since
   6321 only then @value{GDBN} knows exactly how many hardware breakpoints and
   6322 watchpoints it needs to insert.
   6323 
   6324 When this message is printed, you need to disable or remove some of the
   6325 hardware-assisted breakpoints and watchpoints, and then continue.
   6326 
   6327 @node Breakpoint-related Warnings
   6328 @subsection ``Breakpoint address adjusted...''
   6329 @cindex breakpoint address adjusted
   6330 
   6331 Some processor architectures place constraints on the addresses at
   6332 which breakpoints may be placed.  For architectures thus constrained,
   6333 @value{GDBN} will attempt to adjust the breakpoint's address to comply
   6334 with the constraints dictated by the architecture.
   6335 
   6336 One example of such an architecture is the Fujitsu FR-V.  The FR-V is
   6337 a VLIW architecture in which a number of RISC-like instructions may be
   6338 bundled together for parallel execution.  The FR-V architecture
   6339 constrains the location of a breakpoint instruction within such a
   6340 bundle to the instruction with the lowest address.  @value{GDBN}
   6341 honors this constraint by adjusting a breakpoint's address to the
   6342 first in the bundle.
   6343 
   6344 It is not uncommon for optimized code to have bundles which contain
   6345 instructions from different source statements, thus it may happen that
   6346 a breakpoint's address will be adjusted from one source statement to
   6347 another.  Since this adjustment may significantly alter @value{GDBN}'s
   6348 breakpoint related behavior from what the user expects, a warning is
   6349 printed when the breakpoint is first set and also when the breakpoint
   6350 is hit.
   6351 
   6352 A warning like the one below is printed when setting a breakpoint
   6353 that's been subject to address adjustment:
   6354 
   6355 @smallexample
   6356 warning: Breakpoint address adjusted from 0x00010414 to 0x00010410.
   6357 @end smallexample
   6358 
   6359 Such warnings are printed both for user settable and @value{GDBN}'s
   6360 internal breakpoints.  If you see one of these warnings, you should
   6361 verify that a breakpoint set at the adjusted address will have the
   6362 desired affect.  If not, the breakpoint in question may be removed and
   6363 other breakpoints may be set which will have the desired behavior.
   6364 E.g., it may be sufficient to place the breakpoint at a later
   6365 instruction.  A conditional breakpoint may also be useful in some
   6366 cases to prevent the breakpoint from triggering too often.
   6367 
   6368 @value{GDBN} will also issue a warning when stopping at one of these
   6369 adjusted breakpoints:
   6370 
   6371 @smallexample
   6372 warning: Breakpoint 1 address previously adjusted from 0x00010414
   6373 to 0x00010410.
   6374 @end smallexample
   6375 
   6376 When this warning is encountered, it may be too late to take remedial
   6377 action except in cases where the breakpoint is hit earlier or more
   6378 frequently than expected.
   6379 
   6380 @node Continuing and Stepping
   6381 @section Continuing and Stepping
   6382 
   6383 @cindex stepping
   6384 @cindex continuing
   6385 @cindex resuming execution
   6386 @dfn{Continuing} means resuming program execution until your program
   6387 completes normally.  In contrast, @dfn{stepping} means executing just
   6388 one more ``step'' of your program, where ``step'' may mean either one
   6389 line of source code, or one machine instruction (depending on what
   6390 particular command you use).  Either when continuing or when stepping,
   6391 your program may stop even sooner, due to a breakpoint or a signal.  (If
   6392 it stops due to a signal, you may want to use @code{handle}, or use
   6393 @samp{signal 0} to resume execution (@pxref{Signals, ,Signals}),
   6394 or you may step into the signal's handler (@pxref{stepping and signal
   6395 handlers}).)
   6396 
   6397 @table @code
   6398 @kindex continue
   6399 @kindex c @r{(@code{continue})}
   6400 @kindex fg @r{(resume foreground execution)}
   6401 @item continue @r{[}@var{ignore-count}@r{]}
   6402 @itemx c @r{[}@var{ignore-count}@r{]}
   6403 @itemx fg @r{[}@var{ignore-count}@r{]}
   6404 Resume program execution, at the address where your program last stopped;
   6405 any breakpoints set at that address are bypassed.  The optional argument
   6406 @var{ignore-count} allows you to specify a further number of times to
   6407 ignore a breakpoint at this location; its effect is like that of
   6408 @code{ignore} (@pxref{Conditions, ,Break Conditions}).
   6409 
   6410 The argument @var{ignore-count} is meaningful only when your program
   6411 stopped due to a breakpoint.  At other times, the argument to
   6412 @code{continue} is ignored.
   6413 
   6414 The synonyms @code{c} and @code{fg} (for @dfn{foreground}, as the
   6415 debugged program is deemed to be the foreground program) are provided
   6416 purely for convenience, and have exactly the same behavior as
   6417 @code{continue}.
   6418 @end table
   6419 
   6420 To resume execution at a different place, you can use @code{return}
   6421 (@pxref{Returning, ,Returning from a Function}) to go back to the
   6422 calling function; or @code{jump} (@pxref{Jumping, ,Continuing at a
   6423 Different Address}) to go to an arbitrary location in your program.
   6424 
   6425 A typical technique for using stepping is to set a breakpoint
   6426 (@pxref{Breakpoints, ,Breakpoints; Watchpoints; and Catchpoints}) at the
   6427 beginning of the function or the section of your program where a problem
   6428 is believed to lie, run your program until it stops at that breakpoint,
   6429 and then step through the suspect area, examining the variables that are
   6430 interesting, until you see the problem happen.
   6431 
   6432 @table @code
   6433 @kindex step
   6434 @kindex s @r{(@code{step})}
   6435 @item step
   6436 Continue running your program until control reaches a different source
   6437 line, then stop it and return control to @value{GDBN}.  This command is
   6438 abbreviated @code{s}.
   6439 
   6440 @quotation
   6441 @c "without debugging information" is imprecise; actually "without line
   6442 @c numbers in the debugging information".  (gcc -g1 has debugging info but
   6443 @c not line numbers).  But it seems complex to try to make that
   6444 @c distinction here.
   6445 @emph{Warning:} If you use the @code{step} command while control is
   6446 within a function that was compiled without debugging information,
   6447 execution proceeds until control reaches a function that does have
   6448 debugging information.  Likewise, it will not step into a function which
   6449 is compiled without debugging information.  To step through functions
   6450 without debugging information, use the @code{stepi} command, described
   6451 below.
   6452 @end quotation
   6453 
   6454 The @code{step} command only stops at the first instruction of a source
   6455 line.  This prevents the multiple stops that could otherwise occur in
   6456 @code{switch} statements, @code{for} loops, etc.  @code{step} continues
   6457 to stop if a function that has debugging information is called within
   6458 the line.  In other words, @code{step} @emph{steps inside} any functions
   6459 called within the line.
   6460 
   6461 Also, the @code{step} command only enters a function if there is line
   6462 number information for the function.  Otherwise it acts like the
   6463 @code{next} command.  This avoids problems when using @code{cc -gl}
   6464 on @acronym{MIPS} machines.  Previously, @code{step} entered subroutines if there
   6465 was any debugging information about the routine.
   6466 
   6467 @item step @var{count}
   6468 Continue running as in @code{step}, but do so @var{count} times.  If a
   6469 breakpoint is reached, or a signal not related to stepping occurs before
   6470 @var{count} steps, stepping stops right away.
   6471 
   6472 @kindex next
   6473 @kindex n @r{(@code{next})}
   6474 @item next @r{[}@var{count}@r{]}
   6475 Continue to the next source line in the current (innermost) stack frame.
   6476 This is similar to @code{step}, but function calls that appear within
   6477 the line of code are executed without stopping.  Execution stops when
   6478 control reaches a different line of code at the original stack level
   6479 that was executing when you gave the @code{next} command.  This command
   6480 is abbreviated @code{n}.
   6481 
   6482 An argument @var{count} is a repeat count, as for @code{step}.
   6483 
   6484 
   6485 @c  FIX ME!!  Do we delete this, or is there a way it fits in with
   6486 @c  the following paragraph?   ---  Vctoria
   6487 @c
   6488 @c  @code{next} within a function that lacks debugging information acts like
   6489 @c  @code{step}, but any function calls appearing within the code of the
   6490 @c  function are executed without stopping.
   6491 
   6492 The @code{next} command only stops at the first instruction of a
   6493 source line.  This prevents multiple stops that could otherwise occur in
   6494 @code{switch} statements, @code{for} loops, etc.
   6495 
   6496 @kindex set step-mode
   6497 @item set step-mode
   6498 @cindex functions without line info, and stepping
   6499 @cindex stepping into functions with no line info
   6500 @itemx set step-mode on
   6501 The @code{set step-mode on} command causes the @code{step} command to
   6502 stop at the first instruction of a function which contains no debug line
   6503 information rather than stepping over it.
   6504 
   6505 This is useful in cases where you may be interested in inspecting the
   6506 machine instructions of a function which has no symbolic info and do not
   6507 want @value{GDBN} to automatically skip over this function.
   6508 
   6509 @item set step-mode off
   6510 Causes the @code{step} command to step over any functions which contains no
   6511 debug information.  This is the default.
   6512 
   6513 @item show step-mode
   6514 Show whether @value{GDBN} will stop in or step over functions without
   6515 source line debug information.
   6516 
   6517 @kindex finish
   6518 @kindex fin @r{(@code{finish})}
   6519 @item finish
   6520 Continue running until just after function in the selected stack frame
   6521 returns.  Print the returned value (if any).  This command can be
   6522 abbreviated as @code{fin}.
   6523 
   6524 Contrast this with the @code{return} command (@pxref{Returning,
   6525 ,Returning from a Function}).
   6526 
   6527 @kindex set print finish
   6528 @kindex show print finish
   6529 @item set print finish @r{[}on|off@r{]}
   6530 @itemx show print finish
   6531 By default the @code{finish} command will show the value that is
   6532 returned by the function.  This can be disabled using @code{set print
   6533 finish off}.  When disabled, the value is still entered into the value
   6534 history (@pxref{Value History}), but not displayed.
   6535 
   6536 @kindex until
   6537 @kindex u @r{(@code{until})}
   6538 @cindex run until specified location
   6539 @item until
   6540 @itemx u
   6541 Continue running until a source line past the current line, in the
   6542 current stack frame, is reached.  This command is used to avoid single
   6543 stepping through a loop more than once.  It is like the @code{next}
   6544 command, except that when @code{until} encounters a jump, it
   6545 automatically continues execution until the program counter is greater
   6546 than the address of the jump.
   6547 
   6548 This means that when you reach the end of a loop after single stepping
   6549 though it, @code{until} makes your program continue execution until it
   6550 exits the loop.  In contrast, a @code{next} command at the end of a loop
   6551 simply steps back to the beginning of the loop, which forces you to step
   6552 through the next iteration.
   6553 
   6554 @code{until} always stops your program if it attempts to exit the current
   6555 stack frame.
   6556 
   6557 @code{until} may produce somewhat counterintuitive results if the order
   6558 of machine code does not match the order of the source lines.  For
   6559 example, in the following excerpt from a debugging session, the @code{f}
   6560 (@code{frame}) command shows that execution is stopped at line
   6561 @code{206}; yet when we use @code{until}, we get to line @code{195}:
   6562 
   6563 @smallexample
   6564 (@value{GDBP}) f
   6565 #0  main (argc=4, argv=0xf7fffae8) at m4.c:206
   6566 206                 expand_input();
   6567 (@value{GDBP}) until
   6568 195             for ( ; argc > 0; NEXTARG) @{
   6569 @end smallexample
   6570 
   6571 This happened because, for execution efficiency, the compiler had
   6572 generated code for the loop closure test at the end, rather than the
   6573 start, of the loop---even though the test in a C @code{for}-loop is
   6574 written before the body of the loop.  The @code{until} command appeared
   6575 to step back to the beginning of the loop when it advanced to this
   6576 expression; however, it has not really gone to an earlier
   6577 statement---not in terms of the actual machine code.
   6578 
   6579 @code{until} with no argument works by means of single
   6580 instruction stepping, and hence is slower than @code{until} with an
   6581 argument.
   6582 
   6583 @item until @var{locspec}
   6584 @itemx u @var{locspec}
   6585 Continue running your program until either it reaches a code location
   6586 that results from resolving @var{locspec}, or the current stack frame
   6587 returns.  @var{locspec} is any of the forms described in @ref{Location
   6588 Specifications}.
   6589 This form of the command uses temporary breakpoints, and
   6590 hence is quicker than @code{until} without an argument.  The specified
   6591 location is actually reached only if it is in the current frame.  This
   6592 implies that @code{until} can be used to skip over recursive function
   6593 invocations.  For instance in the code below, if the current location is
   6594 line @code{96}, issuing @code{until 99} will execute the program up to
   6595 line @code{99} in the same invocation of factorial, i.e., after the inner
   6596 invocations have returned.
   6597 
   6598 @smallexample
   6599 94	int factorial (int value)
   6600 95	@{
   6601 96	    if (value > 1) @{
   6602 97            value *= factorial (value - 1);
   6603 98	    @}
   6604 99	    return (value);
   6605 100     @}
   6606 @end smallexample
   6607 
   6608 
   6609 @kindex advance @var{locspec}
   6610 @item advance @var{locspec}
   6611 Continue running your program until either it reaches a code location
   6612 that results from resolving @var{locspec}, or the current stack frame
   6613 returns.  @var{locspec} is any of the forms described in @ref{Location
   6614 Specifications}.  This command is similar to @code{until}, but
   6615 @code{advance} will not skip over recursive function calls, and the
   6616 target code location doesn't have to be in the same frame as the
   6617 current one.
   6618 
   6619 
   6620 @kindex stepi
   6621 @kindex si @r{(@code{stepi})}
   6622 @item stepi
   6623 @itemx stepi @var{arg}
   6624 @itemx si
   6625 Execute one machine instruction, then stop and return to the debugger.
   6626 
   6627 It is often useful to do @samp{display/i $pc} when stepping by machine
   6628 instructions.  This makes @value{GDBN} automatically display the next
   6629 instruction to be executed, each time your program stops.  @xref{Auto
   6630 Display,, Automatic Display}.
   6631 
   6632 An argument is a repeat count, as in @code{step}.
   6633 
   6634 @need 750
   6635 @kindex nexti
   6636 @kindex ni @r{(@code{nexti})}
   6637 @item nexti
   6638 @itemx nexti @var{arg}
   6639 @itemx ni
   6640 Execute one machine instruction, but if it is a function call,
   6641 proceed until the function returns.
   6642 
   6643 An argument is a repeat count, as in @code{next}.
   6644 
   6645 @end table
   6646 
   6647 @anchor{range stepping}
   6648 @cindex range stepping
   6649 @cindex target-assisted range stepping
   6650 By default, and if available, @value{GDBN} makes use of
   6651 target-assisted @dfn{range stepping}.  In other words, whenever you
   6652 use a stepping command (e.g., @code{step}, @code{next}), @value{GDBN}
   6653 tells the target to step the corresponding range of instruction
   6654 addresses instead of issuing multiple single-steps.  This speeds up
   6655 line stepping, particularly for remote targets.  Ideally, there should
   6656 be no reason you would want to turn range stepping off.  However, it's
   6657 possible that a bug in the debug info, a bug in the remote stub (for
   6658 remote targets), or even a bug in @value{GDBN} could make line
   6659 stepping behave incorrectly when target-assisted range stepping is
   6660 enabled.  You can use the following command to turn off range stepping
   6661 if necessary:
   6662 
   6663 @table @code
   6664 @kindex set range-stepping
   6665 @kindex show range-stepping
   6666 @item set range-stepping
   6667 @itemx show range-stepping
   6668 Control whether range stepping is enabled.
   6669 
   6670 If @code{on}, and the target supports it, @value{GDBN} tells the
   6671 target to step a range of addresses itself, instead of issuing
   6672 multiple single-steps.  If @code{off}, @value{GDBN} always issues
   6673 single-steps, even if range stepping is supported by the target.  The
   6674 default is @code{on}.
   6675 
   6676 @end table
   6677 
   6678 @node Skipping Over Functions and Files
   6679 @section Skipping Over Functions and Files
   6680 @cindex skipping over functions and files
   6681 
   6682 The program you are debugging may contain some functions which are
   6683 uninteresting to debug.  The @code{skip} command lets you tell @value{GDBN} to
   6684 skip a function, all functions in a file or a particular function in
   6685 a particular file when stepping.
   6686 
   6687 For example, consider the following C function:
   6688 
   6689 @smallexample
   6690 101     int func()
   6691 102     @{
   6692 103         foo(boring());
   6693 104         bar(boring());
   6694 105     @}
   6695 @end smallexample
   6696 
   6697 @noindent
   6698 Suppose you wish to step into the functions @code{foo} and @code{bar}, but you
   6699 are not interested in stepping through @code{boring}.  If you run @code{step}
   6700 at line 103, you'll enter @code{boring()}, but if you run @code{next}, you'll
   6701 step over both @code{foo} and @code{boring}!
   6702 
   6703 One solution is to @code{step} into @code{boring} and use the @code{finish}
   6704 command to immediately exit it.  But this can become tedious if @code{boring}
   6705 is called from many places.
   6706 
   6707 A more flexible solution is to execute @kbd{skip boring}.  This instructs
   6708 @value{GDBN} never to step into @code{boring}.  Now when you execute
   6709 @code{step} at line 103, you'll step over @code{boring} and directly into
   6710 @code{foo}.
   6711 
   6712 Functions may be skipped by providing either a function name, linespec
   6713 (@pxref{Location Specifications}), regular expression that matches the function's
   6714 name, file name or a @code{glob}-style pattern that matches the file name.
   6715 
   6716 On Posix systems the form of the regular expression is
   6717 ``Extended Regular Expressions''.  See for example @samp{man 7 regex}
   6718 on @sc{gnu}/Linux systems.  On non-Posix systems the form of the regular
   6719 expression is whatever is provided by the @code{regcomp} function of
   6720 the underlying system.
   6721 See for example @samp{man 7 glob} on @sc{gnu}/Linux systems for a
   6722 description of @code{glob}-style patterns.
   6723 
   6724 @table @code
   6725 @kindex skip
   6726 @item skip @r{[}@var{options}@r{]}
   6727 The basic form of the @code{skip} command takes zero or more options
   6728 that specify what to skip.
   6729 The @var{options} argument is any useful combination of the following:
   6730 
   6731 @table @code
   6732 @item -file @var{file}
   6733 @itemx -fi @var{file}
   6734 Functions in @var{file} will be skipped over when stepping.
   6735 
   6736 @item -gfile @var{file-glob-pattern}
   6737 @itemx -gfi @var{file-glob-pattern}
   6738 @cindex skipping over files via glob-style patterns
   6739 Functions in files matching @var{file-glob-pattern} will be skipped
   6740 over when stepping.
   6741 
   6742 @smallexample
   6743 (@value{GDBP}) skip -gfi utils/*.c
   6744 @end smallexample
   6745 
   6746 @item -function @var{linespec}
   6747 @itemx -fu @var{linespec}
   6748 Functions named by @var{linespec} or the function containing the line
   6749 named by @var{linespec} will be skipped over when stepping.
   6750 @xref{Location Specifications}.
   6751 
   6752 @item -rfunction @var{regexp}
   6753 @itemx -rfu @var{regexp}
   6754 @cindex skipping over functions via regular expressions
   6755 Functions whose name matches @var{regexp} will be skipped over when stepping.
   6756 
   6757 This form is useful for complex function names.
   6758 For example, there is generally no need to step into C@t{++} @code{std::string}
   6759 constructors or destructors.  Plus with C@t{++} templates it can be hard to
   6760 write out the full name of the function, and often it doesn't matter what
   6761 the template arguments are.  Specifying the function to be skipped as a
   6762 regular expression makes this easier.
   6763 
   6764 @smallexample
   6765 (@value{GDBP}) skip -rfu ^std::(allocator|basic_string)<.*>::~?\1 *\(
   6766 @end smallexample
   6767 
   6768 If you want to skip every templated C@t{++} constructor and destructor
   6769 in the @code{std} namespace you can do:
   6770 
   6771 @smallexample
   6772 (@value{GDBP}) skip -rfu ^std::([a-zA-z0-9_]+)<.*>::~?\1 *\(
   6773 @end smallexample
   6774 @end table
   6775 
   6776 If no options are specified, the function you're currently debugging
   6777 will be skipped.
   6778 
   6779 @kindex skip function
   6780 @item skip function @r{[}@var{linespec}@r{]}
   6781 After running this command, the function named by @var{linespec} or the
   6782 function containing the line named by @var{linespec} will be skipped over when
   6783 stepping.  @xref{Location Specifications}.
   6784 
   6785 If you do not specify @var{linespec}, the function you're currently debugging
   6786 will be skipped.
   6787 
   6788 (If you have a function called @code{file} that you want to skip, use
   6789 @kbd{skip function file}.)
   6790 
   6791 @kindex skip file
   6792 @item skip file @r{[}@var{filename}@r{]}
   6793 After running this command, any function whose source lives in @var{filename}
   6794 will be skipped over when stepping.
   6795 
   6796 @smallexample
   6797 (@value{GDBP}) skip file boring.c
   6798 File boring.c will be skipped when stepping.
   6799 @end smallexample
   6800 
   6801 If you do not specify @var{filename}, functions whose source lives in the file
   6802 you're currently debugging will be skipped.
   6803 @end table
   6804 
   6805 Skips can be listed, deleted, disabled, and enabled, much like breakpoints.
   6806 These are the commands for managing your list of skips:
   6807 
   6808 @table @code
   6809 @kindex info skip
   6810 @item info skip @r{[}@var{range}@r{]}
   6811 Print details about the specified skip(s).  If @var{range} is not specified,
   6812 print a table with details about all functions and files marked for skipping.
   6813 @code{info skip} prints the following information about each skip:
   6814 
   6815 @table @emph
   6816 @item Identifier
   6817 A number identifying this skip.
   6818 @item Enabled or Disabled
   6819 Enabled skips are marked with @samp{y}.
   6820 Disabled skips are marked with @samp{n}.
   6821 @item Glob
   6822 If the file name is a @samp{glob} pattern this is @samp{y}.
   6823 Otherwise it is @samp{n}.
   6824 @item File
   6825 The name or @samp{glob} pattern of the file to be skipped.
   6826 If no file is specified this is @samp{<none>}.
   6827 @item RE
   6828 If the function name is a @samp{regular expression} this is @samp{y}.
   6829 Otherwise it is @samp{n}.
   6830 @item Function
   6831 The name or regular expression of the function to skip.
   6832 If no function is specified this is @samp{<none>}.
   6833 @end table
   6834 
   6835 @kindex skip delete
   6836 @item skip delete @r{[}@var{range}@r{]}
   6837 Delete the specified skip(s).  If @var{range} is not specified, delete all
   6838 skips.
   6839 
   6840 @kindex skip enable
   6841 @item skip enable @r{[}@var{range}@r{]}
   6842 Enable the specified skip(s).  If @var{range} is not specified, enable all
   6843 skips.
   6844 
   6845 @kindex skip disable
   6846 @item skip disable @r{[}@var{range}@r{]}
   6847 Disable the specified skip(s).  If @var{range} is not specified, disable all
   6848 skips.
   6849 
   6850 @kindex set debug skip
   6851 @item set debug skip @r{[}on|off@r{]}
   6852 Set whether to print the debug output about skipping files and functions.
   6853 
   6854 @kindex show debug skip
   6855 @item show debug skip
   6856 Show whether the debug output about skipping files and functions is printed.
   6857 
   6858 @end table
   6859 
   6860 @node Signals
   6861 @section Signals
   6862 @cindex signals
   6863 
   6864 A signal is an asynchronous event that can happen in a program.  The
   6865 operating system defines the possible kinds of signals, and gives each
   6866 kind a name and a number.  For example, in Unix @code{SIGINT} is the
   6867 signal a program gets when you type an interrupt character (often @kbd{Ctrl-c});
   6868 @code{SIGSEGV} is the signal a program gets from referencing a place in
   6869 memory far away from all the areas in use; @code{SIGALRM} occurs when
   6870 the alarm clock timer goes off (which happens only if your program has
   6871 requested an alarm).
   6872 
   6873 @cindex fatal signals
   6874 Some signals, including @code{SIGALRM}, are a normal part of the
   6875 functioning of your program.  Others, such as @code{SIGSEGV}, indicate
   6876 errors; these signals are @dfn{fatal} (they kill your program immediately) if the
   6877 program has not specified in advance some other way to handle the signal.
   6878 @code{SIGINT} does not indicate an error in your program, but it is normally
   6879 fatal so it can carry out the purpose of the interrupt: to kill the program.
   6880 
   6881 @value{GDBN} has the ability to detect any occurrence of a signal in your
   6882 program.  You can tell @value{GDBN} in advance what to do for each kind of
   6883 signal.
   6884 
   6885 @cindex handling signals
   6886 Normally, @value{GDBN} is set up to let the non-erroneous signals like
   6887 @code{SIGALRM} be silently passed to your program
   6888 (so as not to interfere with their role in the program's functioning)
   6889 but to stop your program immediately whenever an error signal happens.
   6890 You can change these settings with the @code{handle} command.
   6891 
   6892 @table @code
   6893 @kindex info signals
   6894 @kindex info handle
   6895 @item info signals
   6896 @itemx info handle
   6897 Print a table of all the kinds of signals and how @value{GDBN} has been told to
   6898 handle each one.  You can use this to see the signal numbers of all
   6899 the defined types of signals.
   6900 
   6901 @item info signals @var{sig}
   6902 Similar, but print information only about the specified signal number.
   6903 
   6904 @code{info handle} is an alias for @code{info signals}.
   6905 
   6906 @item catch signal @r{[}@var{signal}@dots{} @r{|} @samp{all}@r{]}
   6907 Set a catchpoint for the indicated signals.  @xref{Set Catchpoints},
   6908 for details about this command.
   6909 
   6910 @kindex handle
   6911 @item handle @var{signal} @r{[} @var{signal} @dots{} @r{]} @r{[}@var{keywords}@dots{}@r{]}
   6912 Change the way @value{GDBN} handles each @var{signal}.  Each
   6913 @var{signal} can be the number of a signal or its name (with or
   6914 without the @samp{SIG} at the beginning); a list of signal numbers of
   6915 the form @samp{@var{low}-@var{high}}; or the word @samp{all}, meaning
   6916 all the known signals, except @code{SIGINT} and @code{SIGTRAP}, which
   6917 are used by @value{GDBN}.  Optional argument @var{keywords}, described
   6918 below, say what changes to make to all of the specified signals.
   6919 @end table
   6920 
   6921 @c @group
   6922 The keywords allowed by the @code{handle} command can be abbreviated.
   6923 Their full names are:
   6924 
   6925 @table @code
   6926 @item nostop
   6927 @value{GDBN} should not stop your program when this signal happens.  It may
   6928 still print a message telling you that the signal has come in.
   6929 
   6930 @item stop
   6931 @value{GDBN} should stop your program when this signal happens.  This implies
   6932 the @code{print} keyword as well.
   6933 
   6934 @item print
   6935 @value{GDBN} should print a message when this signal happens.
   6936 
   6937 @item noprint
   6938 @value{GDBN} should not mention the occurrence of the signal at all.  This
   6939 implies the @code{nostop} keyword as well.
   6940 
   6941 @item pass
   6942 @itemx noignore
   6943 @value{GDBN} should allow your program to see this signal; your program
   6944 can handle the signal, or else it may terminate if the signal is fatal
   6945 and not handled.  @code{pass} and @code{noignore} are synonyms.
   6946 
   6947 @item nopass
   6948 @itemx ignore
   6949 @value{GDBN} should not allow your program to see this signal.
   6950 @code{nopass} and @code{ignore} are synonyms.
   6951 @end table
   6952 @c @end group
   6953 
   6954 When a signal stops your program, the signal is not visible to the
   6955 program until you
   6956 continue.  Your program sees the signal then, if @code{pass} is in
   6957 effect for the signal in question @emph{at that time}.  In other words,
   6958 after @value{GDBN} reports a signal, you can use the @code{handle}
   6959 command with @code{pass} or @code{nopass} to control whether your
   6960 program sees that signal when you continue.
   6961 
   6962 The default is set to @code{nostop}, @code{noprint}, @code{pass} for
   6963 non-erroneous signals such as @code{SIGALRM}, @code{SIGWINCH} and
   6964 @code{SIGCHLD}, and to @code{stop}, @code{print}, @code{pass} for the
   6965 erroneous signals.
   6966 
   6967 You can also use the @code{signal} command to prevent your program from
   6968 seeing a signal, or cause it to see a signal it normally would not see,
   6969 or to give it any signal at any time.  For example, if your program stopped
   6970 due to some sort of memory reference error, you might store correct
   6971 values into the erroneous variables and continue, hoping to see more
   6972 execution; but your program would probably terminate immediately as
   6973 a result of the fatal signal once it saw the signal.  To prevent this,
   6974 you can continue with @samp{signal 0}.  @xref{Signaling, ,Giving your
   6975 Program a Signal}.
   6976 
   6977 @cindex stepping and signal handlers
   6978 @anchor{stepping and signal handlers}
   6979 
   6980 @value{GDBN} optimizes for stepping the mainline code.  If a signal
   6981 that has @code{handle nostop} and @code{handle pass} set arrives while
   6982 a stepping command (e.g., @code{stepi}, @code{step}, @code{next}) is
   6983 in progress, @value{GDBN} lets the signal handler run and then resumes
   6984 stepping the mainline code once the signal handler returns.  In other
   6985 words, @value{GDBN} steps over the signal handler.  This prevents
   6986 signals that you've specified as not interesting (with @code{handle
   6987 nostop}) from changing the focus of debugging unexpectedly.  Note that
   6988 the signal handler itself may still hit a breakpoint, stop for another
   6989 signal that has @code{handle stop} in effect, or for any other event
   6990 that normally results in stopping the stepping command sooner.  Also
   6991 note that @value{GDBN} still informs you that the program received a
   6992 signal if @code{handle print} is set.
   6993 
   6994 @anchor{stepping into signal handlers}
   6995 
   6996 If you set @code{handle pass} for a signal, and your program sets up a
   6997 handler for it, then issuing a stepping command, such as @code{step}
   6998 or @code{stepi}, when your program is stopped due to the signal will
   6999 step @emph{into} the signal handler (if the target supports that).
   7000 
   7001 Likewise, if you use the @code{queue-signal} command to queue a signal
   7002 to be delivered to the current thread when execution of the thread
   7003 resumes (@pxref{Signaling, ,Giving your Program a Signal}), then a
   7004 stepping command will step into the signal handler.
   7005 
   7006 Here's an example, using @code{stepi} to step to the first instruction
   7007 of @code{SIGUSR1}'s handler:
   7008 
   7009 @smallexample
   7010 (@value{GDBP}) handle SIGUSR1
   7011 Signal        Stop      Print   Pass to program Description
   7012 SIGUSR1       Yes       Yes     Yes             User defined signal 1
   7013 (@value{GDBP}) c
   7014 Continuing.
   7015 
   7016 Program received signal SIGUSR1, User defined signal 1.
   7017 main () sigusr1.c:28
   7018 28        p = 0;
   7019 (@value{GDBP}) si
   7020 sigusr1_handler () at sigusr1.c:9
   7021 9       @{
   7022 @end smallexample
   7023 
   7024 The same, but using @code{queue-signal} instead of waiting for the
   7025 program to receive the signal first:
   7026 
   7027 @smallexample
   7028 (@value{GDBP}) n
   7029 28        p = 0;
   7030 (@value{GDBP}) queue-signal SIGUSR1
   7031 (@value{GDBP}) si
   7032 sigusr1_handler () at sigusr1.c:9
   7033 9       @{
   7034 (@value{GDBP})
   7035 @end smallexample
   7036 
   7037 @cindex extra signal information
   7038 @anchor{extra signal information}
   7039 
   7040 On some targets, @value{GDBN} can inspect extra signal information
   7041 associated with the intercepted signal, before it is actually
   7042 delivered to the program being debugged.  This information is exported
   7043 by the convenience variable @code{$_siginfo}, and consists of data
   7044 that is passed by the kernel to the signal handler at the time of the
   7045 receipt of a signal.  The data type of the information itself is
   7046 target dependent.  You can see the data type using the @code{ptype
   7047 $_siginfo} command.  On Unix systems, it typically corresponds to the
   7048 standard @code{siginfo_t} type, as defined in the @file{signal.h}
   7049 system header.
   7050 
   7051 Here's an example, on a @sc{gnu}/Linux system, printing the stray
   7052 referenced address that raised a segmentation fault.
   7053 
   7054 @smallexample
   7055 @group
   7056 (@value{GDBP}) continue
   7057 Program received signal SIGSEGV, Segmentation fault.
   7058 0x0000000000400766 in main ()
   7059 69        *(int *)p = 0;
   7060 (@value{GDBP}) ptype $_siginfo
   7061 type = struct @{
   7062     int si_signo;
   7063     int si_errno;
   7064     int si_code;
   7065     union @{
   7066         int _pad[28];
   7067         struct @{...@} _kill;
   7068         struct @{...@} _timer;
   7069         struct @{...@} _rt;
   7070         struct @{...@} _sigchld;
   7071         struct @{...@} _sigfault;
   7072         struct @{...@} _sigpoll;
   7073     @} _sifields;
   7074 @}
   7075 (@value{GDBP}) ptype $_siginfo._sifields._sigfault
   7076 type = struct @{
   7077     void *si_addr;
   7078 @}
   7079 (@value{GDBP}) p $_siginfo._sifields._sigfault.si_addr
   7080 $1 = (void *) 0x7ffff7ff7000
   7081 @end group
   7082 @end smallexample
   7083 
   7084 Depending on target support, @code{$_siginfo} may also be writable.
   7085 
   7086 @node Thread Stops
   7087 @section Stopping and Starting Multi-thread Programs
   7088 
   7089 @cindex stopped threads
   7090 @cindex threads, stopped
   7091 
   7092 @cindex continuing threads
   7093 @cindex threads, continuing
   7094 
   7095 @value{GDBN} supports debugging programs with multiple threads
   7096 (@pxref{Threads,, Debugging Programs with Multiple Threads}).  There
   7097 are two modes of controlling execution of your program within the
   7098 debugger.  In the default mode, referred to as @dfn{all-stop mode},
   7099 when any thread in your program stops (for example, at a breakpoint 
   7100 or while being stepped), all other threads in the program are also stopped by 
   7101 @value{GDBN}.  On some targets, @value{GDBN} also supports 
   7102 @dfn{non-stop mode}, in which other threads can continue to run freely while
   7103 you examine the stopped thread in the debugger.
   7104 
   7105 @menu
   7106 * All-Stop Mode::               All threads stop when GDB takes control
   7107 * Non-Stop Mode::               Other threads continue to execute
   7108 * Background Execution::        Running your program asynchronously
   7109 * Thread-Specific Breakpoints:: Controlling breakpoints
   7110 * Interrupted System Calls::    GDB may interfere with system calls
   7111 * Observer Mode::               GDB does not alter program behavior
   7112 @end menu
   7113 
   7114 @node All-Stop Mode
   7115 @subsection All-Stop Mode
   7116 
   7117 @cindex all-stop mode
   7118 
   7119 In all-stop mode, whenever your program stops under @value{GDBN} for any reason,
   7120 @emph{all} threads of execution stop, not just the current thread.  This
   7121 allows you to examine the overall state of the program, including
   7122 switching between threads, without worrying that things may change
   7123 underfoot.
   7124 
   7125 Conversely, whenever you restart the program, @emph{all} threads start
   7126 executing.  @emph{This is true even when single-stepping} with commands
   7127 like @code{step} or @code{next}.
   7128 
   7129 In particular, @value{GDBN} cannot single-step all threads in lockstep.
   7130 Since thread scheduling is up to your debugging target's operating
   7131 system (not controlled by @value{GDBN}), other threads may
   7132 execute more than one statement while the current thread completes a
   7133 single step.  Moreover, in general other threads stop in the middle of a
   7134 statement, rather than at a clean statement boundary, when the program
   7135 stops.
   7136 
   7137 You might even find your program stopped in another thread after
   7138 continuing or even single-stepping.  This happens whenever some other
   7139 thread runs into a breakpoint, a signal, or an exception before the
   7140 first thread completes whatever you requested.
   7141 
   7142 @cindex automatic thread selection
   7143 @cindex switching threads automatically
   7144 @cindex threads, automatic switching
   7145 Whenever @value{GDBN} stops your program, due to a breakpoint or a
   7146 signal, it automatically selects the thread where that breakpoint or
   7147 signal happened.  @value{GDBN} alerts you to the context switch with a
   7148 message such as @samp{[Switching to Thread @var{n}]} to identify the
   7149 thread.  
   7150 
   7151 @anchor{set scheduler-locking}
   7152 
   7153 On some OSes, you can modify @value{GDBN}'s default behavior by
   7154 locking the OS scheduler to allow only a single thread to run.
   7155 
   7156 @table @code
   7157 @item set scheduler-locking @var{mode}
   7158 @cindex scheduler-locking
   7159 @cindex scheduler locking mode
   7160 @cindex lock scheduler
   7161 Set the scheduler locking mode.  It applies to normal execution,
   7162 record mode, and replay mode.  @var{mode} can be one of
   7163 the following:
   7164 
   7165 @table @code
   7166 @item off
   7167 There is no locking and any thread may run at any time.
   7168 
   7169 @item on
   7170 Only the current thread may run when the inferior is resumed.  New
   7171 threads created by the resumed thread are held stopped at their entry
   7172 point, before they execute any instruction.
   7173 
   7174 @item step
   7175 Behaves like @code{on} when stepping, and @code{off} otherwise.
   7176 Threads other than the current never get a chance to run when you
   7177 step, and they are completely free to run when you use commands like
   7178 @samp{continue}, @samp{until}, or @samp{finish}.
   7179 
   7180 This mode optimizes for single-stepping; it prevents other threads
   7181 from preempting the current thread while you are stepping, so that the
   7182 focus of debugging does not change unexpectedly.  However, unless
   7183 another thread hits a breakpoint during its timeslice, @value{GDBN}
   7184 does not change the current thread away from the thread that you are
   7185 debugging.
   7186 
   7187 @item replay
   7188 Behaves like @code{on} in replay mode, and @code{off} in either record
   7189 mode or during normal execution.  This is the default mode.
   7190 @end table
   7191 
   7192 @item show scheduler-locking
   7193 Display the current scheduler locking mode.
   7194 @end table
   7195 
   7196 @cindex resume threads of multiple processes simultaneously
   7197 By default, when you issue one of the execution commands such as
   7198 @code{continue}, @code{next} or @code{step}, @value{GDBN} allows only
   7199 threads of the current inferior to run.  For example, if @value{GDBN}
   7200 is attached to two inferiors, each with two threads, the
   7201 @code{continue} command resumes only the two threads of the current
   7202 inferior.  This is useful, for example, when you debug a program that
   7203 forks and you want to hold the parent stopped (so that, for instance,
   7204 it doesn't run to exit), while you debug the child.  In other
   7205 situations, you may not be interested in inspecting the current state
   7206 of any of the processes @value{GDBN} is attached to, and you may want
   7207 to resume them all until some breakpoint is hit.  In the latter case,
   7208 you can instruct @value{GDBN} to allow all threads of all the
   7209 inferiors to run with the @w{@code{set schedule-multiple}} command.
   7210 
   7211 @table @code
   7212 @kindex set schedule-multiple
   7213 @item set schedule-multiple
   7214 Set the mode for allowing threads of multiple processes to be resumed
   7215 when an execution command is issued.  When @code{on}, all threads of
   7216 all processes are allowed to run.  When @code{off}, only the threads
   7217 of the current process are resumed.  The default is @code{off}.  The
   7218 @code{scheduler-locking} mode takes precedence when set to @code{on},
   7219 or while you are stepping and set to @code{step}.
   7220 
   7221 @item show schedule-multiple
   7222 Display the current mode for resuming the execution of threads of
   7223 multiple processes.
   7224 @end table
   7225 
   7226 @node Non-Stop Mode
   7227 @subsection Non-Stop Mode
   7228 
   7229 @cindex non-stop mode
   7230 
   7231 @c This section is really only a place-holder, and needs to be expanded
   7232 @c with more details.
   7233 
   7234 For some multi-threaded targets, @value{GDBN} supports an optional
   7235 mode of operation in which you can examine stopped program threads in
   7236 the debugger while other threads continue to execute freely.  This
   7237 minimizes intrusion when debugging live systems, such as programs
   7238 where some threads have real-time constraints or must continue to
   7239 respond to external events.  This is referred to as @dfn{non-stop} mode.
   7240 
   7241 In non-stop mode, when a thread stops to report a debugging event,
   7242 @emph{only} that thread is stopped; @value{GDBN} does not stop other
   7243 threads as well, in contrast to the all-stop mode behavior.  Additionally,
   7244 execution commands such as @code{continue} and @code{step} apply by default
   7245 only to the current thread in non-stop mode, rather than all threads as
   7246 in all-stop mode.  This allows you to control threads explicitly in
   7247 ways that are not possible in all-stop mode --- for example, stepping
   7248 one thread while allowing others to run freely, stepping
   7249 one thread while holding all others stopped, or stepping several threads
   7250 independently and simultaneously.
   7251 
   7252 To enter non-stop mode, use this sequence of commands before you run
   7253 or attach to your program:
   7254 
   7255 @smallexample
   7256 # If using the CLI, pagination breaks non-stop.
   7257 set pagination off
   7258 
   7259 # Finally, turn it on!
   7260 set non-stop on
   7261 @end smallexample
   7262 
   7263 You can use these commands to manipulate the non-stop mode setting:
   7264 
   7265 @table @code
   7266 @kindex set non-stop
   7267 @item set non-stop on
   7268 Enable selection of non-stop mode.
   7269 @item set non-stop off
   7270 Disable selection of non-stop mode.
   7271 @kindex show non-stop
   7272 @item show non-stop
   7273 Show the current non-stop enablement setting.
   7274 @end table
   7275 
   7276 Note these commands only reflect whether non-stop mode is enabled,
   7277 not whether the currently-executing program is being run in non-stop mode.
   7278 In particular, the @code{set non-stop} preference is only consulted when
   7279 @value{GDBN} starts or connects to the target program, and it is generally
   7280 not possible to switch modes once debugging has started.  Furthermore,
   7281 since not all targets support non-stop mode, even when you have enabled
   7282 non-stop mode, @value{GDBN} may still fall back to all-stop operation by
   7283 default.
   7284 
   7285 In non-stop mode, all execution commands apply only to the current thread
   7286 by default.  That is, @code{continue} only continues one thread.
   7287 To continue all threads, issue @code{continue -a} or @code{c -a}.
   7288 
   7289 You can use @value{GDBN}'s background execution commands
   7290 (@pxref{Background Execution}) to run some threads in the background
   7291 while you continue to examine or step others from @value{GDBN}.
   7292 The MI execution commands (@pxref{GDB/MI Program Execution}) are
   7293 always executed asynchronously in non-stop mode.
   7294 
   7295 Suspending execution is done with the @code{interrupt} command when
   7296 running in the background, or @kbd{Ctrl-c} during foreground execution.
   7297 In all-stop mode, this stops the whole process;
   7298 but in non-stop mode the interrupt applies only to the current thread.
   7299 To stop the whole program, use @code{interrupt -a}.
   7300 
   7301 Other execution commands do not currently support the @code{-a} option.
   7302 
   7303 In non-stop mode, when a thread stops, @value{GDBN} doesn't automatically make
   7304 that thread current, as it does in all-stop mode.  This is because the
   7305 thread stop notifications are asynchronous with respect to @value{GDBN}'s
   7306 command interpreter, and it would be confusing if @value{GDBN} unexpectedly
   7307 changed to a different thread just as you entered a command to operate on the
   7308 previously current thread.
   7309 
   7310 @node Background Execution
   7311 @subsection Background Execution
   7312 
   7313 @cindex foreground execution
   7314 @cindex background execution
   7315 @cindex asynchronous execution
   7316 @cindex execution, foreground, background and asynchronous
   7317 
   7318 @value{GDBN}'s execution commands have two variants:  the normal
   7319 foreground (synchronous) behavior, and a background
   7320 (asynchronous) behavior.  In foreground execution, @value{GDBN} waits for
   7321 the program to report that some thread has stopped before prompting for
   7322 another command.  In background execution, @value{GDBN} immediately gives
   7323 a command prompt so that you can issue other commands while your program runs.
   7324 
   7325 If the target doesn't support async mode, @value{GDBN} issues an error
   7326 message if you attempt to use the background execution commands.
   7327 
   7328 @cindex @code{&}, background execution of commands
   7329 To specify background execution, add a @code{&} to the command.  For example,
   7330 the background form of the @code{continue} command is @code{continue&}, or
   7331 just @code{c&}.  The execution commands that accept background execution
   7332 are:
   7333 
   7334 @table @code
   7335 @kindex run&
   7336 @item run
   7337 @xref{Starting, , Starting your Program}.
   7338 
   7339 @item attach
   7340 @kindex attach&
   7341 @xref{Attach, , Debugging an Already-running Process}.
   7342 
   7343 @item step
   7344 @kindex step&
   7345 @xref{Continuing and Stepping, step}.
   7346 
   7347 @item stepi
   7348 @kindex stepi&
   7349 @xref{Continuing and Stepping, stepi}.
   7350 
   7351 @item next
   7352 @kindex next&
   7353 @xref{Continuing and Stepping, next}.
   7354 
   7355 @item nexti
   7356 @kindex nexti&
   7357 @xref{Continuing and Stepping, nexti}.
   7358 
   7359 @item continue
   7360 @kindex continue&
   7361 @xref{Continuing and Stepping, continue}.
   7362 
   7363 @item finish
   7364 @kindex finish&
   7365 @xref{Continuing and Stepping, finish}.
   7366 
   7367 @item until
   7368 @kindex until&
   7369 @xref{Continuing and Stepping, until}.
   7370 
   7371 @end table
   7372 
   7373 Background execution is especially useful in conjunction with non-stop
   7374 mode for debugging programs with multiple threads; see @ref{Non-Stop Mode}.
   7375 However, you can also use these commands in the normal all-stop mode with
   7376 the restriction that you cannot issue another execution command until the
   7377 previous one finishes.  Examples of commands that are valid in all-stop
   7378 mode while the program is running include @code{help} and @code{info break}.
   7379 
   7380 You can interrupt your program while it is running in the background by
   7381 using the @code{interrupt} command.
   7382 
   7383 @table @code
   7384 @kindex interrupt
   7385 @item interrupt
   7386 @itemx interrupt -a
   7387 
   7388 Suspend execution of the running program.  In all-stop mode,
   7389 @code{interrupt} stops the whole process, but in non-stop mode, it stops
   7390 only the current thread.  To stop the whole program in non-stop mode,
   7391 use @code{interrupt -a}.
   7392 @end table
   7393 
   7394 @node Thread-Specific Breakpoints
   7395 @subsection Thread-Specific Breakpoints
   7396 
   7397 When your program has multiple threads (@pxref{Threads,, Debugging
   7398 Programs with Multiple Threads}), you can choose whether to set
   7399 breakpoints on all threads, or on a particular thread.
   7400 
   7401 @table @code
   7402 @cindex breakpoints and threads
   7403 @cindex thread breakpoints
   7404 @kindex break @dots{} thread @var{thread-id}
   7405 @item break @var{locspec} thread @var{thread-id}
   7406 @itemx break @var{locspec} thread @var{thread-id} if @dots{}
   7407 @var{locspec} specifies a code location or locations in your program.
   7408 @xref{Location Specifications}, for details.
   7409 
   7410 Use the qualifier @samp{thread @var{thread-id}} with a breakpoint command
   7411 to specify that you only want @value{GDBN} to stop the program when a
   7412 particular thread reaches this breakpoint.  The @var{thread-id} specifier
   7413 is one of the thread identifiers assigned by @value{GDBN}, shown
   7414 in the first column of the @samp{info threads} display.
   7415 
   7416 If you do not specify @samp{thread @var{thread-id}} when you set a
   7417 breakpoint, the breakpoint applies to @emph{all} threads of your
   7418 program.
   7419 
   7420 You can use the @code{thread} qualifier on conditional breakpoints as
   7421 well; in this case, place @samp{thread @var{thread-id}} before or
   7422 after the breakpoint condition, like this:
   7423 
   7424 @smallexample
   7425 (@value{GDBP}) break frik.c:13 thread 28 if bartab > lim
   7426 @end smallexample
   7427 
   7428 @end table
   7429 
   7430 Thread-specific breakpoints are automatically deleted when
   7431 @value{GDBN} detects the corresponding thread is no longer in the
   7432 thread list.  For example:
   7433 
   7434 @smallexample
   7435 (@value{GDBP}) c
   7436 Thread-specific breakpoint 3 deleted - thread 28 no longer in the thread list.
   7437 @end smallexample
   7438 
   7439 There are several ways for a thread to disappear, such as a regular
   7440 thread exit, but also when you detach from the process with the
   7441 @code{detach} command (@pxref{Attach, ,Debugging an Already-running
   7442 Process}), or if @value{GDBN} loses the remote connection
   7443 (@pxref{Remote Debugging}), etc.  Note that with some targets,
   7444 @value{GDBN} is only able to detect a thread has exited when the user
   7445 explicitly asks for the thread list with the @code{info threads}
   7446 command.
   7447 
   7448 A breakpoint can't be both thread-specific and inferior-specific
   7449 (@pxref{Inferior-Specific Breakpoints}), or task-specific (@pxref{Ada
   7450 Tasks}); using more than one of the @code{thread}, @code{inferior}, or
   7451 @code{task} keywords when creating a breakpoint will give an error.
   7452 
   7453 @node Interrupted System Calls
   7454 @subsection Interrupted System Calls 
   7455 
   7456 @cindex thread breakpoints and system calls
   7457 @cindex system calls and thread breakpoints
   7458 @cindex premature return from system calls
   7459 There is an unfortunate side effect when using @value{GDBN} to debug
   7460 multi-threaded programs.  If one thread stops for a
   7461 breakpoint, or for some other reason, and another thread is blocked in a
   7462 system call, then the system call may return prematurely.  This is a
   7463 consequence of the interaction between multiple threads and the signals
   7464 that @value{GDBN} uses to implement breakpoints and other events that
   7465 stop execution.
   7466 
   7467 To handle this problem, your program should check the return value of
   7468 each system call and react appropriately.  This is good programming
   7469 style anyways.
   7470 
   7471 For example, do not write code like this:
   7472 
   7473 @smallexample
   7474   sleep (10);
   7475 @end smallexample
   7476 
   7477 The call to @code{sleep} will return early if a different thread stops
   7478 at a breakpoint or for some other reason.
   7479 
   7480 Instead, write this:
   7481 
   7482 @smallexample
   7483   int unslept = 10;
   7484   while (unslept > 0)
   7485     unslept = sleep (unslept);
   7486 @end smallexample
   7487 
   7488 A system call is allowed to return early, so the system is still
   7489 conforming to its specification.  But @value{GDBN} does cause your
   7490 multi-threaded program to behave differently than it would without
   7491 @value{GDBN}.
   7492 
   7493 Also, @value{GDBN} uses internal breakpoints in the thread library to
   7494 monitor certain events such as thread creation and thread destruction.
   7495 When such an event happens, a system call in another thread may return
   7496 prematurely, even though your program does not appear to stop.
   7497 
   7498 @node Observer Mode
   7499 @subsection Observer Mode
   7500 
   7501 If you want to build on non-stop mode and observe program behavior
   7502 without any chance of disruption by @value{GDBN}, you can set
   7503 variables to disable all of the debugger's attempts to modify state,
   7504 whether by writing memory, inserting breakpoints, etc.  These operate
   7505 at a low level, intercepting operations from all commands.
   7506 
   7507 When all of these are set to @code{off}, then @value{GDBN} is said to
   7508 be @dfn{observer mode}.  As a convenience, the variable
   7509 @code{observer} can be set to disable these, plus enable non-stop
   7510 mode.
   7511 
   7512 Note that @value{GDBN} will not prevent you from making nonsensical
   7513 combinations of these settings. For instance, if you have enabled
   7514 @code{may-insert-breakpoints} but disabled @code{may-write-memory},
   7515 then breakpoints that work by writing trap instructions into the code
   7516 stream will still not be able to be placed.
   7517 
   7518 @table @code
   7519 
   7520 @kindex observer
   7521 @item set observer on
   7522 @itemx set observer off
   7523 When set to @code{on}, this disables all the permission variables
   7524 below (except for @code{insert-fast-tracepoints}), plus enables
   7525 non-stop debugging.  Setting this to @code{off} switches back to
   7526 normal debugging, though remaining in non-stop mode.
   7527 
   7528 @item show observer
   7529 Show whether observer mode is on or off.
   7530 
   7531 @kindex may-write-registers
   7532 @item set may-write-registers on
   7533 @itemx set may-write-registers off
   7534 This controls whether @value{GDBN} will attempt to alter the values of
   7535 registers, such as with assignment expressions in @code{print}, or the
   7536 @code{jump} command.  It defaults to @code{on}.
   7537 
   7538 @item show may-write-registers
   7539 Show the current permission to write registers.
   7540 
   7541 @kindex may-write-memory
   7542 @item set may-write-memory on
   7543 @itemx set may-write-memory off
   7544 This controls whether @value{GDBN} will attempt to alter the contents
   7545 of memory, such as with assignment expressions in @code{print}.  It
   7546 defaults to @code{on}.
   7547 
   7548 @item show may-write-memory
   7549 Show the current permission to write memory.
   7550 
   7551 @kindex may-insert-breakpoints
   7552 @item set may-insert-breakpoints on
   7553 @itemx set may-insert-breakpoints off
   7554 This controls whether @value{GDBN} will attempt to insert breakpoints.
   7555 This affects all breakpoints, including internal breakpoints defined
   7556 by @value{GDBN}.  It defaults to @code{on}.
   7557 
   7558 @item show may-insert-breakpoints
   7559 Show the current permission to insert breakpoints.
   7560 
   7561 @kindex may-insert-tracepoints
   7562 @item set may-insert-tracepoints on
   7563 @itemx set may-insert-tracepoints off
   7564 This controls whether @value{GDBN} will attempt to insert (regular)
   7565 tracepoints at the beginning of a tracing experiment.  It affects only
   7566 non-fast tracepoints, fast tracepoints being under the control of
   7567 @code{may-insert-fast-tracepoints}.  It defaults to @code{on}.
   7568 
   7569 @item show may-insert-tracepoints
   7570 Show the current permission to insert tracepoints.
   7571 
   7572 @kindex may-insert-fast-tracepoints
   7573 @item set may-insert-fast-tracepoints on
   7574 @itemx set may-insert-fast-tracepoints off
   7575 This controls whether @value{GDBN} will attempt to insert fast
   7576 tracepoints at the beginning of a tracing experiment.  It affects only
   7577 fast tracepoints, regular (non-fast) tracepoints being under the
   7578 control of @code{may-insert-tracepoints}.  It defaults to @code{on}.
   7579 
   7580 @item show may-insert-fast-tracepoints
   7581 Show the current permission to insert fast tracepoints.
   7582 
   7583 @kindex may-interrupt
   7584 @item set may-interrupt on
   7585 @itemx set may-interrupt off
   7586 This controls whether @value{GDBN} will attempt to interrupt or stop
   7587 program execution.  When this variable is @code{off}, the
   7588 @code{interrupt} command will have no effect, nor will
   7589 @kbd{Ctrl-c}. It defaults to @code{on}.
   7590 
   7591 @item show may-interrupt
   7592 Show the current permission to interrupt or stop the program.
   7593 
   7594 @end table
   7595 
   7596 @node Reverse Execution
   7597 @chapter Running programs backward
   7598 @cindex reverse execution
   7599 @cindex running programs backward
   7600 
   7601 When you are debugging a program, it is not unusual to realize that
   7602 you have gone too far, and some event of interest has already happened.
   7603 If the target environment supports it, @value{GDBN} can allow you to
   7604 ``rewind'' the program by running it backward.
   7605 
   7606 A target environment that supports reverse execution should be able
   7607 to ``undo'' the changes in machine state that have taken place as the
   7608 program was executing normally.  Variables, registers etc.@: should
   7609 revert to their previous values.  Obviously this requires a great
   7610 deal of sophistication on the part of the target environment; not
   7611 all target environments can support reverse execution.
   7612 
   7613 When a program is executed in reverse, the instructions that
   7614 have most recently been executed are ``un-executed'', in reverse
   7615 order.  The program counter runs backward, following the previous
   7616 thread of execution in reverse.  As each instruction is ``un-executed'',
   7617 the values of memory and/or registers that were changed by that
   7618 instruction are reverted to their previous states.  After executing
   7619 a piece of source code in reverse, all side effects of that code
   7620 should be ``undone'', and all variables should be returned to their
   7621 prior values@footnote{
   7622 Note that some side effects are easier to undo than others.  For instance,
   7623 memory and registers are relatively easy, but device I/O is hard.  Some
   7624 targets may be able undo things like device I/O, and some may not.
   7625 
   7626 The contract between @value{GDBN} and the reverse executing target
   7627 requires only that the target do something reasonable when
   7628 @value{GDBN} tells it to execute backwards, and then report the 
   7629 results back to @value{GDBN}.  Whatever the target reports back to
   7630 @value{GDBN}, @value{GDBN} will report back to the user.  @value{GDBN}
   7631 assumes that the memory and registers that the target reports are in a
   7632 consistent state, but @value{GDBN} accepts whatever it is given.
   7633 }.
   7634 
   7635 On some platforms, @value{GDBN} has built-in support for reverse
   7636 execution, activated with the @code{record} or @code{record btrace}
   7637 commands.  @xref{Process Record and Replay}.  Some remote targets,
   7638 typically full system emulators, support reverse execution directly
   7639 without requiring any special command.
   7640 
   7641 If you are debugging in a target environment that supports
   7642 reverse execution, @value{GDBN} provides the following commands.
   7643 
   7644 @table @code
   7645 @kindex reverse-continue
   7646 @kindex rc @r{(@code{reverse-continue})}
   7647 @item reverse-continue @r{[}@var{ignore-count}@r{]}
   7648 @itemx rc @r{[}@var{ignore-count}@r{]}
   7649 Beginning at the point where your program last stopped, start executing
   7650 in reverse.  Reverse execution will stop for breakpoints and synchronous
   7651 exceptions (signals), just like normal execution.  Behavior of
   7652 asynchronous signals depends on the target environment.
   7653 
   7654 @kindex reverse-step
   7655 @kindex rs @r{(@code{step})}
   7656 @item reverse-step @r{[}@var{count}@r{]}
   7657 Run the program backward until control reaches the start of a
   7658 different source line; then stop it, and return control to @value{GDBN}.
   7659 
   7660 Like the @code{step} command, @code{reverse-step} will only stop
   7661 at the beginning of a source line.  It ``un-executes'' the previously
   7662 executed source line.  If the previous source line included calls to
   7663 debuggable functions, @code{reverse-step} will step (backward) into
   7664 the called function, stopping at the beginning of the @emph{last}
   7665 statement in the called function (typically a return statement).
   7666 
   7667 Also, as with the @code{step} command, if non-debuggable functions are
   7668 called, @code{reverse-step} will run through them backward without stopping.
   7669 
   7670 @kindex reverse-stepi
   7671 @kindex rsi @r{(@code{reverse-stepi})}
   7672 @item reverse-stepi @r{[}@var{count}@r{]}
   7673 Reverse-execute one machine instruction.  Note that the instruction
   7674 to be reverse-executed is @emph{not} the one pointed to by the program
   7675 counter, but the instruction executed prior to that one.  For instance,
   7676 if the last instruction was a jump, @code{reverse-stepi} will take you
   7677 back from the destination of the jump to the jump instruction itself.
   7678 
   7679 @kindex reverse-next
   7680 @kindex rn @r{(@code{reverse-next})}
   7681 @item reverse-next @r{[}@var{count}@r{]}
   7682 Run backward to the beginning of the previous line executed in
   7683 the current (innermost) stack frame.  If the line contains function
   7684 calls, they will be ``un-executed'' without stopping.  Starting from
   7685 the first line of a function, @code{reverse-next} will take you back
   7686 to the caller of that function, @emph{before} the function was called,
   7687 just as the normal @code{next} command would take you from the last 
   7688 line of a function back to its return to its caller
   7689 @footnote{Unless the code is too heavily optimized.}.
   7690 
   7691 @kindex reverse-nexti
   7692 @kindex rni @r{(@code{reverse-nexti})}
   7693 @item reverse-nexti @r{[}@var{count}@r{]}
   7694 Like @code{nexti}, @code{reverse-nexti} executes a single instruction
   7695 in reverse, except that called functions are ``un-executed'' atomically.
   7696 That is, if the previously executed instruction was a return from
   7697 another function, @code{reverse-nexti} will continue to execute
   7698 in reverse until the call to that function (from the current stack
   7699 frame) is reached.
   7700 
   7701 @kindex reverse-finish
   7702 @item reverse-finish
   7703 Just as the @code{finish} command takes you to the point where the
   7704 current function returns, @code{reverse-finish} takes you to the point
   7705 where it was called.  Instead of ending up at the end of the current
   7706 function invocation, you end up at the beginning.
   7707 
   7708 @kindex set exec-direction
   7709 @item set exec-direction
   7710 Set the direction of target execution.
   7711 @item set exec-direction reverse
   7712 @cindex execute forward or backward in time
   7713 @value{GDBN} will perform all execution commands in reverse, until the
   7714 exec-direction mode is changed to ``forward''.  Affected commands include
   7715 @code{step, stepi, next, nexti, continue, and finish}.  The @code{return}
   7716 command cannot be used in reverse mode.
   7717 @item set exec-direction forward
   7718 @value{GDBN} will perform all execution commands in the normal fashion.
   7719 This is the default.
   7720 @end table
   7721 
   7722 
   7723 @node Process Record and Replay
   7724 @chapter Recording Inferior's Execution and Replaying It
   7725 @cindex process record and replay
   7726 @cindex recording inferior's execution and replaying it
   7727 
   7728 On some platforms, @value{GDBN} provides a special @dfn{process record
   7729 and replay} target that can record a log of the process execution, and
   7730 replay it later with both forward and reverse execution commands.
   7731 
   7732 @cindex replay mode
   7733 When this target is in use, if the execution log includes the record
   7734 for the next instruction, @value{GDBN} will debug in @dfn{replay
   7735 mode}.  In the replay mode, the inferior does not really execute code
   7736 instructions.  Instead, all the events that normally happen during
   7737 code execution are taken from the execution log.  While code is not
   7738 really executed in replay mode, the values of registers (including the
   7739 program counter register) and the memory of the inferior are still
   7740 changed as they normally would.  Their contents are taken from the
   7741 execution log.
   7742 
   7743 @cindex record mode
   7744 If the record for the next instruction is not in the execution log,
   7745 @value{GDBN} will debug in @dfn{record mode}.  In this mode, the
   7746 inferior executes normally, and @value{GDBN} records the execution log
   7747 for future replay.
   7748 
   7749 The process record and replay target supports reverse execution
   7750 (@pxref{Reverse Execution}), even if the platform on which the
   7751 inferior runs does not.  However, the reverse execution is limited in
   7752 this case by the range of the instructions recorded in the execution
   7753 log.  In other words, reverse execution on platforms that don't
   7754 support it directly can only be done in the replay mode.
   7755 
   7756 When debugging in the reverse direction, @value{GDBN} will work in
   7757 replay mode as long as the execution log includes the record for the
   7758 previous instruction; otherwise, it will work in record mode, if the
   7759 platform supports reverse execution, or stop if not.
   7760 
   7761 Currently, process record and replay is supported on ARM, Aarch64,
   7762 LoongArch, Moxie, PowerPC, PowerPC64, S/390, and x86 (i386/amd64) running
   7763 GNU/Linux.  Process record and replay can be used both when native
   7764 debugging, and when remote debugging via @code{gdbserver}.
   7765 
   7766 When recording an inferior, @value{GDBN} may print auxiliary information
   7767 during stepping commands and commands displaying the execution history.
   7768 
   7769 For architecture environments that support process record and replay,
   7770 @value{GDBN} provides the following commands:
   7771 
   7772 @table @code
   7773 @kindex target record
   7774 @kindex target record-full
   7775 @kindex target record-btrace
   7776 @kindex record
   7777 @kindex record full
   7778 @kindex record btrace
   7779 @kindex record btrace bts
   7780 @kindex record btrace pt
   7781 @kindex record bts
   7782 @kindex record pt
   7783 @kindex rec
   7784 @kindex rec full
   7785 @kindex rec btrace
   7786 @kindex rec btrace bts
   7787 @kindex rec btrace pt
   7788 @kindex rec bts
   7789 @kindex rec pt
   7790 @item record @var{method}
   7791 This command starts the process record and replay target.  The
   7792 recording method can be specified as parameter.  Without a parameter
   7793 the command uses the @code{full} recording method.  The following
   7794 recording methods are available:
   7795 
   7796 @table @code
   7797 @item full
   7798 Full record/replay recording using @value{GDBN}'s software record and
   7799 replay implementation.  This method allows replaying and reverse
   7800 execution.
   7801 
   7802 @item btrace @var{format}
   7803 Hardware-supported instruction recording, supported on Intel
   7804 processors.  This method does not record data.  Further, the data is
   7805 collected in a ring buffer so old data will be overwritten when the
   7806 buffer is full.  It allows limited reverse execution.  Variables and
   7807 registers are not available during reverse execution.  In remote
   7808 debugging, recording continues on disconnect.  Recorded data can be
   7809 inspected after reconnecting.  The recording may be stopped using
   7810 @code{record stop}.
   7811 
   7812 The recording format can be specified as parameter.  Without a parameter
   7813 the command chooses the recording format.  The following recording
   7814 formats are available:
   7815 
   7816 @table @code
   7817 @item bts
   7818 @cindex branch trace store
   7819 Use the @dfn{Branch Trace Store} (@acronym{BTS}) recording format.  In
   7820 this format, the processor stores a from/to record for each executed
   7821 branch in the btrace ring buffer.
   7822 
   7823 @item pt
   7824 @cindex Intel Processor Trace
   7825 Use the @dfn{Intel Processor Trace} recording format.  In this
   7826 format, the processor stores the execution trace in a compressed form
   7827 that is afterwards decoded by @value{GDBN}.
   7828 
   7829 The trace can be recorded with very low overhead.  The compressed
   7830 trace format also allows small trace buffers to already contain a big
   7831 number of instructions compared to @acronym{BTS}.
   7832 
   7833 Decoding the recorded execution trace, on the other hand, is more
   7834 expensive than decoding @acronym{BTS} trace.  This is mostly due to the
   7835 increased number of instructions to process.  You should increase the
   7836 buffer-size with care.
   7837 @end table
   7838 
   7839 Not all recording formats may be available on all processors.
   7840 @end table
   7841 
   7842 The process record and replay target can only debug a process that is
   7843 already running.  Therefore, you need first to start the process with
   7844 the @kbd{run} or @kbd{start} commands, and then start the recording
   7845 with the @kbd{record @var{method}} command.
   7846 
   7847 @cindex displaced stepping, and process record and replay
   7848 Displaced stepping (@pxref{Maintenance Commands,, displaced stepping})
   7849 will be automatically disabled when process record and replay target
   7850 is started.  That's because the process record and replay target
   7851 doesn't support displaced stepping.
   7852 
   7853 @cindex non-stop mode, and process record and replay
   7854 @cindex asynchronous execution, and process record and replay
   7855 If the inferior is in the non-stop mode (@pxref{Non-Stop Mode}) or in
   7856 the asynchronous execution mode (@pxref{Background Execution}), not
   7857 all recording methods are available.  The @code{full} recording method
   7858 does not support these two modes.
   7859 
   7860 @kindex record stop
   7861 @kindex rec s
   7862 @item record stop
   7863 Stop the process record and replay target.  When process record and
   7864 replay target stops, the entire execution log will be deleted and the
   7865 inferior will either be terminated, or will remain in its final state.
   7866 
   7867 When you stop the process record and replay target in record mode (at
   7868 the end of the execution log), the inferior will be stopped at the
   7869 next instruction that would have been recorded.  In other words, if
   7870 you record for a while and then stop recording, the inferior process
   7871 will be left in the same state as if the recording never happened.
   7872 
   7873 On the other hand, if the process record and replay target is stopped
   7874 while in replay mode (that is, not at the end of the execution log,
   7875 but at some earlier point), the inferior process will become ``live''
   7876 at that earlier state, and it will then be possible to continue the
   7877 usual ``live'' debugging of the process from that state.
   7878 
   7879 When the inferior process exits, or @value{GDBN} detaches from it,
   7880 process record and replay target will automatically stop itself.
   7881 
   7882 @kindex record goto
   7883 @item record goto
   7884 Go to a specific location in the execution log.  There are several
   7885 ways to specify the location to go to:
   7886 
   7887 @table @code
   7888 @item record goto begin
   7889 @itemx record goto start
   7890 Go to the beginning of the execution log.
   7891 
   7892 @item record goto end
   7893 Go to the end of the execution log.
   7894 
   7895 @item record goto @var{n}
   7896 Go to instruction number @var{n} in the execution log.
   7897 @end table
   7898 
   7899 @kindex record save
   7900 @item record save @var{filename}
   7901 Save the execution log to a file @file{@var{filename}}.
   7902 Default filename is @file{gdb_record.@var{process_id}}, where
   7903 @var{process_id} is the process ID of the inferior.
   7904 
   7905 This command may not be available for all recording methods.
   7906 
   7907 @kindex record restore
   7908 @item record restore @var{filename}
   7909 Restore the execution log from a file @file{@var{filename}}.
   7910 File must have been created with @code{record save}.
   7911 
   7912 @kindex set record full
   7913 @item set record full insn-number-max @var{limit}
   7914 @itemx set record full insn-number-max unlimited
   7915 Set the limit of instructions to be recorded for the @code{full}
   7916 recording method.  Default value is 200000.
   7917 
   7918 If @var{limit} is a positive number, then @value{GDBN} will start
   7919 deleting instructions from the log once the number of the record
   7920 instructions becomes greater than @var{limit}.  For every new recorded
   7921 instruction, @value{GDBN} will delete the earliest recorded
   7922 instruction to keep the number of recorded instructions at the limit.
   7923 (Since deleting recorded instructions loses information, @value{GDBN}
   7924 lets you control what happens when the limit is reached, by means of
   7925 the @code{stop-at-limit} option, described below.)
   7926 
   7927 If @var{limit} is @code{unlimited} or zero, @value{GDBN} will never
   7928 delete recorded instructions from the execution log.  The number of
   7929 recorded instructions is limited only by the available memory.
   7930 
   7931 @kindex show record full
   7932 @item show record full insn-number-max
   7933 Show the limit of instructions to be recorded with the @code{full}
   7934 recording method.
   7935 
   7936 @item set record full stop-at-limit
   7937 Control the behavior of the  @code{full} recording method when the
   7938 number of recorded instructions reaches the limit.  If ON (the
   7939 default), @value{GDBN} will stop when the limit is reached for the
   7940 first time and ask you whether you want to stop the inferior or
   7941 continue running it and recording the execution log.  If you decide
   7942 to continue recording, each new recorded instruction will cause the
   7943 oldest one to be deleted.
   7944 
   7945 If this option is OFF, @value{GDBN} will automatically delete the
   7946 oldest record to make room for each new one, without asking.
   7947 
   7948 @item show record full stop-at-limit
   7949 Show the current setting of @code{stop-at-limit}.
   7950 
   7951 @item set record full memory-query
   7952 Control the behavior when @value{GDBN} is unable to record memory
   7953 changes caused by an instruction for the @code{full} recording method.
   7954 If ON, @value{GDBN} will query whether to stop the inferior in that
   7955 case.
   7956 
   7957 If this option is OFF (the default), @value{GDBN} will automatically
   7958 ignore the effect of such instructions on memory.  Later, when
   7959 @value{GDBN} replays this execution log, it will mark the log of this
   7960 instruction as not accessible, and it will not affect the replay
   7961 results.
   7962 
   7963 @item show record full memory-query
   7964 Show the current setting of @code{memory-query}.
   7965 
   7966 @kindex set record btrace
   7967 The @code{btrace} record target does not trace data.  As a
   7968 convenience, when replaying, @value{GDBN} reads read-only memory off
   7969 the live program directly, assuming that the addresses of the
   7970 read-only areas don't change.  This for example makes it possible to
   7971 disassemble code while replaying, but not to print variables.
   7972 In some cases, being able to inspect variables might be useful.
   7973 You can use the following command for that:
   7974 
   7975 @item set record btrace replay-memory-access
   7976 Control the behavior of the @code{btrace} recording method when
   7977 accessing memory during replay.  If @code{read-only} (the default),
   7978 @value{GDBN} will only allow accesses to read-only memory.
   7979 If @code{read-write}, @value{GDBN} will allow accesses to read-only
   7980 and to read-write memory.  Beware that the accessed memory corresponds
   7981 to the live target and not necessarily to the current replay
   7982 position.
   7983 
   7984 @item set record btrace cpu @var{identifier}
   7985 Set the processor to be used for enabling workarounds for processor
   7986 errata when decoding the trace.
   7987 
   7988 Processor errata are defects in processor operation, caused by its
   7989 design or manufacture.  They can cause a trace not to match the
   7990 specification.  This, in turn, may cause trace decode to fail.
   7991 @value{GDBN} can detect erroneous trace packets and correct them, thus
   7992 avoiding the decoding failures.  These corrections are known as
   7993 @dfn{errata workarounds}, and are enabled based on the processor on
   7994 which the trace was recorded.
   7995 
   7996 By default, @value{GDBN} attempts to detect the processor
   7997 automatically, and apply the necessary workarounds for it.  However,
   7998 you may need to specify the processor if @value{GDBN} does not yet
   7999 support it.  This command allows you to do that, and also allows to
   8000 disable the workarounds.
   8001 
   8002 The argument @var{identifier} identifies the @sc{cpu} and is of the
   8003 form: @code{@var{vendor}:@var{processor identifier}}.  In addition,
   8004 there are two special identifiers, @code{none} and @code{auto}
   8005 (default).
   8006 
   8007 The following vendor identifiers and corresponding processor
   8008 identifiers are currently supported:
   8009 
   8010 @multitable @columnfractions .1 .9
   8011 
   8012 @item @code{intel}
   8013 @tab @var{family}/@var{model}[/@var{stepping}]
   8014 
   8015 @end multitable
   8016 
   8017 On GNU/Linux systems, the processor @var{family}, @var{model}, and
   8018 @var{stepping} can be obtained from @code{/proc/cpuinfo}.
   8019 
   8020 If @var{identifier} is @code{auto}, enable errata workarounds for the
   8021 processor on which the trace was recorded.  If @var{identifier} is
   8022 @code{none}, errata workarounds are disabled.
   8023 
   8024 For example, when using an old @value{GDBN} on a new system, decode
   8025 may fail because @value{GDBN} does not support the new processor.  It
   8026 often suffices to specify an older processor that @value{GDBN}
   8027 supports.
   8028 
   8029 @smallexample
   8030 (@value{GDBP}) info record
   8031 Active record target: record-btrace
   8032 Recording format: Intel Processor Trace.
   8033 Buffer size: 16kB.
   8034 Failed to configure the Intel Processor Trace decoder: unknown cpu.
   8035 (@value{GDBP}) set record btrace cpu intel:6/158
   8036 (@value{GDBP}) info record
   8037 Active record target: record-btrace
   8038 Recording format: Intel Processor Trace.
   8039 Buffer size: 16kB.
   8040 Recorded 84872 instructions in 3189 functions (0 gaps) for thread 1 (...).
   8041 @end smallexample
   8042 
   8043 @kindex show record btrace
   8044 @item show record btrace replay-memory-access
   8045 Show the current setting of @code{replay-memory-access}.
   8046 
   8047 @item show record btrace cpu
   8048 Show the processor to be used for enabling trace decode errata
   8049 workarounds.
   8050 
   8051 @kindex set record btrace bts
   8052 @item set record btrace bts buffer-size @var{size}
   8053 @itemx set record btrace bts buffer-size unlimited
   8054 Set the requested ring buffer size for branch tracing in @acronym{BTS}
   8055 format.  Default is 64KB.
   8056 
   8057 If @var{size} is a positive number, then @value{GDBN} will try to
   8058 allocate a buffer of at least @var{size} bytes for each new thread
   8059 that uses the btrace recording method and the @acronym{BTS} format.
   8060 The actually obtained buffer size may differ from the requested
   8061 @var{size}.  Use the @code{info record} command to see the actual
   8062 buffer size for each thread that uses the btrace recording method and
   8063 the @acronym{BTS} format.
   8064 
   8065 If @var{limit} is @code{unlimited} or zero, @value{GDBN} will try to
   8066 allocate a buffer of 4MB.
   8067 
   8068 Bigger buffers mean longer traces.  On the other hand, @value{GDBN} will
   8069 also need longer to process the branch trace data before it can be used.
   8070 
   8071 @item show record btrace bts buffer-size @var{size}
   8072 Show the current setting of the requested ring buffer size for branch
   8073 tracing in @acronym{BTS} format.
   8074 
   8075 @kindex set record btrace pt
   8076 @item set record btrace pt buffer-size @var{size}
   8077 @itemx set record btrace pt buffer-size unlimited
   8078 Set the requested ring buffer size for branch tracing in Intel
   8079 Processor Trace format.  Default is 16KB.
   8080 
   8081 If @var{size} is a positive number, then @value{GDBN} will try to
   8082 allocate a buffer of at least @var{size} bytes for each new thread
   8083 that uses the btrace recording method and the Intel Processor Trace
   8084 format.  The actually obtained buffer size may differ from the
   8085 requested @var{size}.  Use the @code{info record} command to see the
   8086 actual buffer size for each thread.
   8087 
   8088 If @var{limit} is @code{unlimited} or zero, @value{GDBN} will try to
   8089 allocate a buffer of 4MB.
   8090 
   8091 Bigger buffers mean longer traces.  On the other hand, @value{GDBN} will
   8092 also need longer to process the branch trace data before it can be used.
   8093 
   8094 @item show record btrace pt buffer-size @var{size}
   8095 Show the current setting of the requested ring buffer size for branch
   8096 tracing in Intel Processor Trace format.
   8097 
   8098 @item set record btrace pt event-tracing
   8099 Enable or disable event tracing for branch tracing in Intel Processor
   8100 Trace format.  When enabled, events are recorded during execution as
   8101 auxiliary information and will be printed during stepping commands and
   8102 commands displaying the execution history.  Changing this setting has no
   8103 effect on an active recording.  The default is off.
   8104 
   8105 @item show record btrace pt event-tracing
   8106 Show the current setting of Intel Processor Trace event tracing.
   8107 
   8108 @kindex info record
   8109 @item info record
   8110 Show various statistics about the recording depending on the recording
   8111 method:
   8112 
   8113 @table @code
   8114 @item full
   8115 For the @code{full} recording method, it shows the state of process
   8116 record and its in-memory execution log buffer, including:
   8117 
   8118 @itemize @bullet
   8119 @item
   8120 Whether in record mode or replay mode.
   8121 @item
   8122 Lowest recorded instruction number (counting from when the current execution log started recording instructions).
   8123 @item
   8124 Highest recorded instruction number.
   8125 @item
   8126 Current instruction about to be replayed (if in replay mode).
   8127 @item
   8128 Number of instructions contained in the execution log.
   8129 @item
   8130 Maximum number of instructions that may be contained in the execution log.
   8131 @end itemize
   8132 
   8133 @item btrace
   8134 For the @code{btrace} recording method, it shows:
   8135 
   8136 @itemize @bullet
   8137 @item
   8138 Recording format.
   8139 @item
   8140 Number of instructions that have been recorded.
   8141 @item
   8142 Number of blocks of sequential control-flow formed by the recorded
   8143 instructions.
   8144 @item
   8145 Whether in record mode or replay mode.
   8146 @end itemize
   8147 
   8148 For the @code{bts} recording format, it also shows:
   8149 @itemize @bullet
   8150 @item
   8151 Size of the perf ring buffer.
   8152 @end itemize
   8153 
   8154 For the @code{pt} recording format, it also shows:
   8155 @itemize @bullet
   8156 @item
   8157 Size of the perf ring buffer.
   8158 @end itemize
   8159 @end table
   8160 
   8161 @kindex record delete
   8162 @kindex rec del
   8163 @item record delete
   8164 When record target runs in replay mode (``in the past''), delete the
   8165 subsequent execution log and begin to record a new execution log starting
   8166 from the current address.  This means you will abandon the previously
   8167 recorded ``future'' and begin recording a new ``future''.
   8168 
   8169 @kindex record instruction-history
   8170 @kindex rec instruction-history
   8171 @item record instruction-history
   8172 Disassembles instructions from the recorded execution log.  By
   8173 default, ten instructions are disassembled.  This can be changed using
   8174 the @code{set record instruction-history-size} command.  Instructions
   8175 are printed in execution order.
   8176 
   8177 It can also print mixed source+disassembly if you specify the the
   8178 @code{/m} or @code{/s} modifier, and print the raw instructions in hex
   8179 as well as in symbolic form by specifying the @code{/r} or @code{/b}
   8180 modifier.  The behavior of the @code{/m}, @code{/s}, @code{/r}, and
   8181 @code{/b} modifiers are the same as for the @kbd{disassemble} command
   8182 (@pxref{disassemble,,@kbd{disassemble}}).
   8183 
   8184 The current position marker is printed for the instruction at the
   8185 current program counter value.  This instruction can appear multiple
   8186 times in the trace and the current position marker will be printed
   8187 every time.  To omit the current position marker, specify the
   8188 @code{/p} modifier.
   8189 
   8190 To better align the printed instructions when the trace contains
   8191 instructions from more than one function, the function name may be
   8192 omitted by specifying the @code{/f} modifier.
   8193 
   8194 Printing auxiliary information is enabled by default and can be
   8195 omitted with the @code{/a} modifier.
   8196 
   8197 Speculatively executed instructions are prefixed with @samp{?}.  This
   8198 feature is not available for all recording formats.
   8199 
   8200 There are several ways to specify what part of the execution log to
   8201 disassemble:
   8202 
   8203 @table @code
   8204 @item record instruction-history @var{insn}
   8205 Disassembles ten instructions starting from instruction number
   8206 @var{insn}.
   8207 
   8208 @item record instruction-history @var{insn}, +/-@var{n}
   8209 Disassembles @var{n} instructions around instruction number
   8210 @var{insn}.  If @var{n} is preceded with @code{+}, disassembles
   8211 @var{n} instructions after instruction number @var{insn}.  If
   8212 @var{n} is preceded with @code{-}, disassembles @var{n}
   8213 instructions before instruction number @var{insn}.
   8214 
   8215 @item record instruction-history
   8216 Disassembles ten more instructions after the last disassembly.
   8217 
   8218 @item record instruction-history -
   8219 Disassembles ten more instructions before the last disassembly.
   8220 
   8221 @item record instruction-history @var{begin}, @var{end}
   8222 Disassembles instructions beginning with instruction number
   8223 @var{begin} until instruction number @var{end}.  The instruction
   8224 number @var{end} is included.
   8225 @end table
   8226 
   8227 This command may not be available for all recording methods.
   8228 
   8229 @kindex set record
   8230 @item set record instruction-history-size @var{size}
   8231 @itemx set record instruction-history-size unlimited
   8232 Define how many instructions to disassemble in the @code{record
   8233 instruction-history} command.  The default value is 10.
   8234 A @var{size} of @code{unlimited} means unlimited instructions.
   8235 
   8236 @kindex show record
   8237 @item show record instruction-history-size
   8238 Show how many instructions to disassemble in the @code{record
   8239 instruction-history} command.
   8240 
   8241 @kindex record function-call-history
   8242 @kindex rec function-call-history
   8243 @item record function-call-history
   8244 Prints the execution history at function granularity.  For each sequence
   8245 of instructions that belong to the same function, it prints the name of
   8246 that function, the source lines for this instruction sequence (if the
   8247 @code{/l} modifier is specified), and the instructions numbers that form
   8248 the sequence (if the @code{/i} modifier is specified).  The function names
   8249 are indented to reflect the call stack depth if the @code{/c} modifier is
   8250 specified.  Printing auxiliary information is enabled by default and can be
   8251 omitted with the @code{/a} modifier.  The @code{/l}, @code{/i}, @code{/a},
   8252 and @code{/c} modifiers can be given together.
   8253 
   8254 @smallexample
   8255 (@value{GDBP}) @b{list 1, 10}
   8256 1   void foo (void)
   8257 2   @{
   8258 3   @}
   8259 4
   8260 5   void bar (void)
   8261 6   @{
   8262 7     ...
   8263 8     foo ();
   8264 9     ...
   8265 10  @}
   8266 (@value{GDBP}) @b{record function-call-history /ilc}
   8267 1  bar     inst 1,4     at foo.c:6,8
   8268 2    foo   inst 5,10    at foo.c:2,3
   8269 3  bar     inst 11,13   at foo.c:9,10
   8270 @end smallexample
   8271 
   8272 By default, ten functions are printed.  This can be changed using the
   8273 @code{set record function-call-history-size} command.  Functions are
   8274 printed in execution order.  There are several ways to specify what
   8275 to print:
   8276 
   8277 @table @code
   8278 @item record function-call-history @var{func}
   8279 Prints ten functions starting from function number @var{func}.
   8280 
   8281 @item record function-call-history @var{func}, +/-@var{n}
   8282 Prints @var{n} functions around function number @var{func}.  If
   8283 @var{n} is preceded with @code{+}, prints @var{n} functions after
   8284 function number @var{func}.  If @var{n} is preceded with @code{-},
   8285 prints @var{n} functions before function number @var{func}.
   8286 
   8287 @item record function-call-history
   8288 Prints ten more functions after the last ten-function print.
   8289 
   8290 @item record function-call-history -
   8291 Prints ten more functions before the last ten-function print.
   8292 
   8293 @item record function-call-history @var{begin}, @var{end}
   8294 Prints functions beginning with function number @var{begin} until
   8295 function number @var{end}.  The function number @var{end} is included.
   8296 @end table
   8297 
   8298 This command may not be available for all recording methods.
   8299 
   8300 @item set record function-call-history-size @var{size}
   8301 @itemx set record function-call-history-size unlimited
   8302 Define how many functions to print in the
   8303 @code{record function-call-history} command.  The default value is 10.
   8304 A size of @code{unlimited} means unlimited functions.
   8305 
   8306 @item show record function-call-history-size
   8307 Show how many functions to print in the
   8308 @code{record function-call-history} command.
   8309 @end table
   8310 
   8311 
   8312 @node Stack
   8313 @chapter Examining the Stack
   8314 
   8315 When your program has stopped, the first thing you need to know is where it
   8316 stopped and how it got there.
   8317 
   8318 @cindex call stack
   8319 Each time your program performs a function call, information about the call
   8320 is generated.
   8321 That information includes the location of the call in your program,
   8322 the arguments of the call,
   8323 and the local variables of the function being called.
   8324 The information is saved in a block of data called a @dfn{stack frame}.
   8325 The stack frames are allocated in a region of memory called the @dfn{call
   8326 stack}.
   8327 
   8328 When your program stops, the @value{GDBN} commands for examining the
   8329 stack allow you to see all of this information.
   8330 
   8331 @cindex selected frame
   8332 One of the stack frames is @dfn{selected} by @value{GDBN} and many
   8333 @value{GDBN} commands refer implicitly to the selected frame.  In
   8334 particular, whenever you ask @value{GDBN} for the value of a variable in
   8335 your program, the value is found in the selected frame.  There are
   8336 special @value{GDBN} commands to select whichever frame you are
   8337 interested in.  @xref{Selection, ,Selecting a Frame}.
   8338 
   8339 When your program stops, @value{GDBN} automatically selects the
   8340 currently executing frame and describes it briefly, similar to the
   8341 @code{frame} command (@pxref{Frame Info, ,Information about a Frame}).
   8342 
   8343 @menu
   8344 * Frames::                      Stack frames
   8345 * Backtrace::                   Backtraces
   8346 * Selection::                   Selecting a frame
   8347 * Frame Info::                  Information on a frame
   8348 * Frame Apply::                 Applying a command to several frames
   8349 * Frame Filter Management::     Managing frame filters
   8350 
   8351 @end menu
   8352 
   8353 @node Frames
   8354 @section Stack Frames
   8355 
   8356 @cindex frame, definition
   8357 @cindex stack frame
   8358 The call stack is divided up into contiguous pieces called @dfn{stack
   8359 frames}, or @dfn{frames} for short; each frame is the data associated
   8360 with one call to one function.  The frame contains the arguments given
   8361 to the function, the function's local variables, and the address at
   8362 which the function is executing.
   8363 
   8364 @cindex initial frame
   8365 @cindex outermost frame
   8366 @cindex innermost frame
   8367 When your program is started, the stack has only one frame, that of the
   8368 function @code{main}.  This is called the @dfn{initial} frame or the
   8369 @dfn{outermost} frame.  Each time a function is called, a new frame is
   8370 made.  Each time a function returns, the frame for that function invocation
   8371 is eliminated.  If a function is recursive, there can be many frames for
   8372 the same function.  The frame for the function in which execution is
   8373 actually occurring is called the @dfn{innermost} frame.  This is the most
   8374 recently created of all the stack frames that still exist.
   8375 
   8376 @cindex frame pointer
   8377 Inside your program, stack frames are identified by their addresses.  A
   8378 stack frame consists of many bytes, each of which has its own address; each
   8379 kind of computer has a convention for choosing one byte whose
   8380 address serves as the address of the frame.  Usually this address is kept
   8381 in a register called the @dfn{frame pointer register}
   8382 (@pxref{Registers, $fp}) while execution is going on in that frame.
   8383 
   8384 @cindex frame level
   8385 @cindex frame number
   8386 @value{GDBN} labels each existing stack frame with a @dfn{level}, a
   8387 number that is zero for the innermost frame, one for the frame that
   8388 called it, and so on upward.  These level numbers give you a way of
   8389 designating stack frames in @value{GDBN} commands.  The terms
   8390 @dfn{frame number} and @dfn{frame level} can be used interchangeably to
   8391 describe this number.
   8392 
   8393 @c The -fomit-frame-pointer below perennially causes hbox overflow
   8394 @c underflow problems.
   8395 @cindex frameless execution
   8396 Some compilers provide a way to compile functions so that they operate
   8397 without stack frames.  (For example, the @value{NGCC} option
   8398 @smallexample
   8399 @samp{-fomit-frame-pointer}
   8400 @end smallexample
   8401 generates functions without a frame.)
   8402 This is occasionally done with heavily used library functions to save
   8403 the frame setup time.  @value{GDBN} has limited facilities for dealing
   8404 with these function invocations.  If the innermost function invocation
   8405 has no stack frame, @value{GDBN} nevertheless regards it as though
   8406 it had a separate frame, which is numbered zero as usual, allowing
   8407 correct tracing of the function call chain.  However, @value{GDBN} has
   8408 no provision for frameless functions elsewhere in the stack.
   8409 
   8410 @node Backtrace
   8411 @section Backtraces
   8412 
   8413 @cindex traceback
   8414 @cindex call stack traces
   8415 A backtrace is a summary of how your program got where it is.  It shows one
   8416 line per frame, for many frames, starting with the currently executing
   8417 frame (frame zero), followed by its caller (frame one), and on up the
   8418 stack.
   8419 
   8420 @anchor{backtrace-command}
   8421 @kindex backtrace
   8422 @kindex bt @r{(@code{backtrace})}
   8423 To print a backtrace of the entire stack, use the @code{backtrace}
   8424 command, or its alias @code{bt}.  This command will print one line per
   8425 frame for frames in the stack.  By default, all stack frames are
   8426 printed.  You can stop the backtrace at any time by typing the system
   8427 interrupt character, normally @kbd{Ctrl-c}.
   8428 
   8429 @table @code
   8430 @item backtrace [@var{option}]@dots{} [@var{qualifier}]@dots{} [@var{count}]
   8431 @itemx bt [@var{option}]@dots{} [@var{qualifier}]@dots{} [@var{count}]
   8432 Print the backtrace of the entire stack.
   8433 
   8434 The optional @var{count} can be one of the following:
   8435 
   8436 @table @code
   8437 @item @var{n}
   8438 @itemx @var{n}
   8439 Print only the innermost @var{n} frames, where @var{n} is a positive
   8440 number.
   8441 
   8442 @item -@var{n}
   8443 @itemx -@var{n}
   8444 Print only the outermost @var{n} frames, where @var{n} is a positive
   8445 number.
   8446 @end table
   8447 
   8448 Options:
   8449 
   8450 @table @code
   8451 @item -full
   8452 Print the values of the local variables also.  This can be combined
   8453 with the optional @var{count} to limit the number of frames shown.
   8454 
   8455 @item -no-filters
   8456 Do not run Python frame filters on this backtrace.  @xref{Frame
   8457 Filter API}, for more information.  Additionally use @ref{disable
   8458 frame-filter all} to turn off all frame filters.  This is only
   8459 relevant when @value{GDBN} has been configured with @code{Python}
   8460 support.
   8461 
   8462 @item -hide
   8463 A Python frame filter might decide to ``elide'' some frames.  Normally
   8464 such elided frames are still printed, but they are indented relative
   8465 to the filtered frames that cause them to be elided.  The @code{-hide}
   8466 option causes elided frames to not be printed at all.
   8467 @end table
   8468 
   8469 The @code{backtrace} command also supports a number of options that
   8470 allow overriding relevant global print settings as set by @code{set
   8471 backtrace} and @code{set print} subcommands:
   8472 
   8473 @table @code
   8474 @item -past-main [@code{on}|@code{off}]
   8475 Set whether backtraces should continue past @code{main}.  Related setting:
   8476 @ref{set backtrace past-main}.
   8477 
   8478 @item -past-entry [@code{on}|@code{off}]
   8479 Set whether backtraces should continue past the entry point of a program.
   8480 Related setting: @ref{set backtrace past-entry}.
   8481 
   8482 @item -entry-values @code{no}|@code{only}|@code{preferred}|@code{if-needed}|@code{both}|@code{compact}|@code{default}
   8483 Set printing of function arguments at function entry.
   8484 Related setting: @ref{set print entry-values}.
   8485 
   8486 @item -frame-arguments @code{all}|@code{scalars}|@code{none}
   8487 Set printing of non-scalar frame arguments.
   8488 Related setting: @ref{set print frame-arguments}.
   8489 
   8490 @item -raw-frame-arguments [@code{on}|@code{off}]
   8491 Set whether to print frame arguments in raw form.
   8492 Related setting: @ref{set print raw-frame-arguments}.
   8493 
   8494 @item -frame-info @code{auto}|@code{source-line}|@code{location}|@code{source-and-location}|@code{location-and-address}|@code{short-location}
   8495 Set printing of frame information.
   8496 Related setting: @ref{set print frame-info}.
   8497 @end table
   8498 
   8499 The optional @var{qualifier} is maintained for backward compatibility.
   8500 It can be one of the following:
   8501 
   8502 @table @code
   8503 @item full
   8504 Equivalent to the @code{-full} option.
   8505 
   8506 @item no-filters
   8507 Equivalent to the @code{-no-filters} option.
   8508 
   8509 @item hide
   8510 Equivalent to the @code{-hide} option.
   8511 @end table
   8512 
   8513 @end table
   8514 
   8515 @kindex where
   8516 @kindex info stack
   8517 The names @code{where} and @code{info stack} (abbreviated @code{info s})
   8518 are additional aliases for @code{backtrace}.
   8519 
   8520 @cindex multiple threads, backtrace
   8521 In a multi-threaded program, @value{GDBN} by default shows the
   8522 backtrace only for the current thread.  To display the backtrace for
   8523 several or all of the threads, use the command @code{thread apply}
   8524 (@pxref{Threads, thread apply}).  For example, if you type @kbd{thread
   8525 apply all backtrace}, @value{GDBN} will display the backtrace for all
   8526 the threads; this is handy when you debug a core dump of a
   8527 multi-threaded program.
   8528 
   8529 Each line in the backtrace shows the frame number and the function name.
   8530 The program counter value is also shown---unless you use @code{set
   8531 print address off}.  The backtrace also shows the source file name and
   8532 line number, as well as the arguments to the function.  The program
   8533 counter value is omitted if it is at the beginning of the code for that
   8534 line number.
   8535 
   8536 Here is an example of a backtrace.  It was made with the command
   8537 @samp{bt 3}, so it shows the innermost three frames.
   8538 
   8539 @smallexample
   8540 @group
   8541 #0  m4_traceon (obs=0x24eb0, argc=1, argv=0x2b8c8)
   8542     at builtin.c:993
   8543 #1  0x6e38 in expand_macro (sym=0x2b600, data=...) at macro.c:242
   8544 #2  0x6840 in expand_token (obs=0x0, t=177664, td=0xf7fffb08)
   8545     at macro.c:71
   8546 (More stack frames follow...)
   8547 @end group
   8548 @end smallexample
   8549 
   8550 @noindent
   8551 The display for frame zero does not begin with a program counter
   8552 value, indicating that your program has stopped at the beginning of the
   8553 code for line @code{993} of @code{builtin.c}.
   8554 
   8555 @noindent
   8556 The value of parameter @code{data} in frame 1 has been replaced by
   8557 @code{@dots{}}.  By default, @value{GDBN} prints the value of a parameter
   8558 only if it is a scalar (integer, pointer, enumeration, etc).  See command
   8559 @kbd{set print frame-arguments} in @ref{Print Settings} for more details
   8560 on how to configure the way function parameter values are printed.
   8561 The command @kbd{set print frame-info} (@pxref{Print Settings}) controls
   8562 what frame information is printed.
   8563 
   8564 @cindex optimized out, in backtrace
   8565 @cindex function call arguments, optimized out
   8566 If your program was compiled with optimizations, some compilers will
   8567 optimize away arguments passed to functions if those arguments are
   8568 never used after the call.  Such optimizations generate code that
   8569 passes arguments through registers, but doesn't store those arguments
   8570 in the stack frame.  @value{GDBN} has no way of displaying such
   8571 arguments in stack frames other than the innermost one.  Here's what
   8572 such a backtrace might look like:
   8573 
   8574 @smallexample
   8575 @group
   8576 #0  m4_traceon (obs=0x24eb0, argc=1, argv=0x2b8c8)
   8577     at builtin.c:993
   8578 #1  0x6e38 in expand_macro (sym=<optimized out>) at macro.c:242
   8579 #2  0x6840 in expand_token (obs=0x0, t=<optimized out>, td=0xf7fffb08)
   8580     at macro.c:71
   8581 (More stack frames follow...)
   8582 @end group
   8583 @end smallexample
   8584 
   8585 @noindent
   8586 The values of arguments that were not saved in their stack frames are
   8587 shown as @samp{<optimized out>}.
   8588 
   8589 If you need to display the values of such optimized-out arguments,
   8590 either deduce that from other variables whose values depend on the one
   8591 you are interested in, or recompile without optimizations.
   8592 
   8593 @cindex backtrace beyond @code{main} function
   8594 @cindex program entry point
   8595 @cindex startup code, and backtrace
   8596 Most programs have a standard user entry point---a place where system
   8597 libraries and startup code transition into user code.  For C this is
   8598 @code{main}@footnote{
   8599 Note that embedded programs (the so-called ``free-standing''
   8600 environment) are not required to have a @code{main} function as the
   8601 entry point.  They could even have multiple entry points.}.
   8602 When @value{GDBN} finds the entry function in a backtrace
   8603 it will terminate the backtrace, to avoid tracing into highly
   8604 system-specific (and generally uninteresting) code.
   8605 
   8606 If you need to examine the startup code, or limit the number of levels
   8607 in a backtrace, you can change this behavior:
   8608 
   8609 @table @code
   8610 @item set backtrace past-main
   8611 @itemx set backtrace past-main on
   8612 @anchor{set backtrace past-main}
   8613 @kindex set backtrace
   8614 Backtraces will continue past the user entry point.
   8615 
   8616 @item set backtrace past-main off
   8617 Backtraces will stop when they encounter the user entry point.  This is the
   8618 default.
   8619 
   8620 @item show backtrace past-main
   8621 @kindex show backtrace
   8622 Display the current user entry point backtrace policy.
   8623 
   8624 @item set backtrace past-entry
   8625 @itemx set backtrace past-entry on
   8626 @anchor{set backtrace past-entry}
   8627 Backtraces will continue past the internal entry point of an application.
   8628 This entry point is encoded by the linker when the application is built,
   8629 and is likely before the user entry point @code{main} (or equivalent) is called.
   8630 
   8631 @item set backtrace past-entry off
   8632 Backtraces will stop when they encounter the internal entry point of an
   8633 application.  This is the default.
   8634 
   8635 @item show backtrace past-entry
   8636 Display the current internal entry point backtrace policy.
   8637 
   8638 @item set backtrace limit @var{n}
   8639 @itemx set backtrace limit 0
   8640 @itemx set backtrace limit unlimited
   8641 @anchor{set backtrace limit}
   8642 @cindex backtrace limit
   8643 Limit the backtrace to @var{n} levels.  A value of @code{unlimited}
   8644 or zero means unlimited levels.
   8645 
   8646 @item show backtrace limit
   8647 Display the current limit on backtrace levels.
   8648 @end table
   8649 
   8650 You can control how file names are displayed.
   8651 
   8652 @table @code
   8653 @item set filename-display
   8654 @itemx set filename-display relative
   8655 @cindex filename-display
   8656 Display file names relative to the compilation directory.  This is the default.
   8657 
   8658 @item set filename-display basename
   8659 Display only basename of a filename.
   8660 
   8661 @item set filename-display absolute
   8662 Display an absolute filename.
   8663 
   8664 @item show filename-display
   8665 Show the current way to display filenames.
   8666 @end table
   8667 
   8668 @node Selection
   8669 @section Selecting a Frame
   8670 
   8671 Most commands for examining the stack and other data in your program work on
   8672 whichever stack frame is selected at the moment.  Here are the commands for
   8673 selecting a stack frame; all of them finish by printing a brief description
   8674 of the stack frame just selected.
   8675 
   8676 @table @code
   8677 @kindex frame@r{, selecting}
   8678 @kindex f @r{(@code{frame})}
   8679 @item frame @r{[} @var{frame-selection-spec} @r{]}
   8680 @item f @r{[} @var{frame-selection-spec} @r{]}
   8681 The @command{frame} command allows different stack frames to be
   8682 selected.  The @var{frame-selection-spec} can be any of the following:
   8683 
   8684 @table @code
   8685 @kindex frame level
   8686 @item @var{num}
   8687 @item level @var{num}
   8688 Select frame level @var{num}.  Recall that frame zero is the innermost
   8689 (currently executing) frame, frame one is the frame that called the
   8690 innermost one, and so on.  The highest level frame is usually the one
   8691 for @code{main}.
   8692 
   8693 As this is the most common method of navigating the frame stack, the
   8694 string @command{level} can be omitted.  For example, the following two
   8695 commands are equivalent:
   8696 
   8697 @smallexample
   8698 (@value{GDBP}) frame 3
   8699 (@value{GDBP}) frame level 3
   8700 @end smallexample
   8701 
   8702 @kindex frame address
   8703 @item address @var{stack-address}
   8704 Select the frame with stack address @var{stack-address}.  The
   8705 @var{stack-address} for a frame can be seen in the output of
   8706 @command{info frame}, for example:
   8707 
   8708 @smallexample
   8709 (@value{GDBP}) info frame
   8710 Stack level 1, frame at 0x7fffffffda30:
   8711  rip = 0x40066d in b (amd64-entry-value.cc:59); saved rip 0x4004c5
   8712  tail call frame, caller of frame at 0x7fffffffda30
   8713  source language c++.
   8714  Arglist at unknown address.
   8715  Locals at unknown address, Previous frame's sp is 0x7fffffffda30
   8716 @end smallexample
   8717 
   8718 The @var{stack-address} for this frame is @code{0x7fffffffda30} as
   8719 indicated by the line:
   8720 
   8721 @smallexample
   8722 Stack level 1, frame at 0x7fffffffda30:
   8723 @end smallexample
   8724 
   8725 @kindex frame function
   8726 @item function @var{function-name}
   8727 Select the stack frame for function @var{function-name}.  If there are
   8728 multiple stack frames for function @var{function-name} then the inner
   8729 most stack frame is selected.
   8730 
   8731 @kindex frame view
   8732 @item view @var{stack-address} @r{[} @var{pc-addr} @r{]}
   8733 View a frame that is not part of @value{GDBN}'s backtrace.  The frame
   8734 viewed has stack address @var{stack-addr}, and optionally, a program
   8735 counter address of @var{pc-addr}.
   8736 
   8737 This is useful mainly if the chaining of stack frames has been
   8738 damaged by a bug, making it impossible for @value{GDBN} to assign
   8739 numbers properly to all frames.  In addition, this can be useful
   8740 when your program has multiple stacks and switches between them.
   8741 
   8742 When viewing a frame outside the current backtrace using
   8743 @command{frame view} then you can always return to the original
   8744 stack using one of the previous stack frame selection instructions,
   8745 for example @command{frame level 0}.
   8746 
   8747 @end table
   8748 
   8749 @kindex up
   8750 @item up @var{n}
   8751 Move @var{n} frames up the stack; @var{n} defaults to 1.  For positive
   8752 numbers @var{n}, this advances toward the outermost frame, to higher
   8753 frame numbers, to frames that have existed longer.
   8754 
   8755 @kindex down
   8756 @kindex do @r{(@code{down})}
   8757 @item down @var{n}
   8758 Move @var{n} frames down the stack; @var{n} defaults to 1.  For
   8759 positive numbers @var{n}, this advances toward the innermost frame, to
   8760 lower frame numbers, to frames that were created more recently.
   8761 You may abbreviate @code{down} as @code{do}.
   8762 @end table
   8763 
   8764 All of these commands end by printing two lines of output describing the
   8765 frame.  The first line shows the frame number, the function name, the
   8766 arguments, and the source file and line number of execution in that
   8767 frame.  The second line shows the text of that source line.
   8768 
   8769 @need 1000
   8770 For example:
   8771 
   8772 @smallexample
   8773 @group
   8774 (@value{GDBP}) up
   8775 #1  0x22f0 in main (argc=1, argv=0xf7fffbf4, env=0xf7fffbfc)
   8776     at env.c:10
   8777 10              read_input_file (argv[i]);
   8778 @end group
   8779 @end smallexample
   8780 
   8781 After such a printout, the @code{list} command with no arguments
   8782 prints ten lines centered on the point of execution in the frame.
   8783 You can also edit the program at the point of execution with your favorite
   8784 editing program by typing @code{edit}.
   8785 @xref{List, ,Printing Source Lines},
   8786 for details.
   8787 
   8788 @table @code
   8789 @kindex select-frame
   8790 @item select-frame @r{[} @var{frame-selection-spec} @r{]}
   8791 The @code{select-frame} command is a variant of @code{frame} that does
   8792 not display the new frame after selecting it.  This command is
   8793 intended primarily for use in @value{GDBN} command scripts, where the
   8794 output might be unnecessary and distracting.  The
   8795 @var{frame-selection-spec} is as for the @command{frame} command
   8796 described in @ref{Selection, ,Selecting a Frame}.
   8797 
   8798 @kindex down-silently
   8799 @kindex up-silently
   8800 @item up-silently @var{n}
   8801 @itemx down-silently @var{n}
   8802 These two commands are variants of @code{up} and @code{down},
   8803 respectively; they differ in that they do their work silently, without
   8804 causing display of the new frame.  They are intended primarily for use
   8805 in @value{GDBN} command scripts, where the output might be unnecessary and
   8806 distracting.
   8807 @end table
   8808 
   8809 @node Frame Info
   8810 @section Information About a Frame
   8811 
   8812 There are several other commands to print information about the selected
   8813 stack frame.
   8814 
   8815 @table @code
   8816 @item frame
   8817 @itemx f
   8818 When used without any argument, this command does not change which
   8819 frame is selected, but prints a brief description of the currently
   8820 selected stack frame.  It can be abbreviated @code{f}.  With an
   8821 argument, this command is used to select a stack frame.
   8822 @xref{Selection, ,Selecting a Frame}.
   8823 
   8824 @kindex info frame
   8825 @kindex info f @r{(@code{info frame})}
   8826 @item info frame
   8827 @itemx info f
   8828 This command prints a verbose description of the selected stack frame,
   8829 including:
   8830 
   8831 @itemize @bullet
   8832 @item
   8833 the address of the frame
   8834 @item
   8835 the address of the next frame down (called by this frame)
   8836 @item
   8837 the address of the next frame up (caller of this frame)
   8838 @item
   8839 the language in which the source code corresponding to this frame is written
   8840 @item
   8841 the address of the frame's arguments
   8842 @item
   8843 the address of the frame's local variables
   8844 @item
   8845 the program counter saved in it (the address of execution in the caller frame)
   8846 @item
   8847 which registers were saved in the frame
   8848 @end itemize
   8849 
   8850 @noindent The verbose description is useful when
   8851 something has gone wrong that has made the stack format fail to fit
   8852 the usual conventions.
   8853 
   8854 @item info frame @r{[} @var{frame-selection-spec} @r{]}
   8855 @itemx info f @r{[} @var{frame-selection-spec} @r{]}
   8856 Print a verbose description of the frame selected by
   8857 @var{frame-selection-spec}.  The @var{frame-selection-spec} is the
   8858 same as for the @command{frame} command (@pxref{Selection, ,Selecting
   8859 a Frame}).  The selected frame remains unchanged by this command.
   8860 
   8861 @kindex info args
   8862 @item info args [-q]
   8863 Print the arguments of the selected frame, each on a separate line.
   8864 
   8865 The optional flag @samp{-q}, which stands for @samp{quiet}, disables
   8866 printing header information and messages explaining why no argument
   8867 have been printed.
   8868 
   8869 @item info args [-q] [-t @var{type_regexp}] [@var{regexp}]
   8870 Like @kbd{info args}, but only print the arguments selected
   8871 with the provided regexp(s).
   8872 
   8873 If @var{regexp} is provided, print only the arguments whose names
   8874 match the regular expression @var{regexp}.
   8875 
   8876 If @var{type_regexp} is provided, print only the arguments whose
   8877 types, as printed by the @code{whatis} command, match
   8878 the regular expression @var{type_regexp}.
   8879 If @var{type_regexp} contains space(s), it should be enclosed in
   8880 quote characters.  If needed, use backslash to escape the meaning
   8881 of special characters or quotes.
   8882 
   8883 If both @var{regexp} and @var{type_regexp} are provided, an argument
   8884 is printed only if its name matches @var{regexp} and its type matches
   8885 @var{type_regexp}.
   8886 
   8887 @item info locals [-q]
   8888 @kindex info locals
   8889 Print the local variables of the selected frame, each on a separate
   8890 line.  These are all variables (declared either static or automatic)
   8891 accessible at the point of execution of the selected frame.
   8892 
   8893 The optional flag @samp{-q}, which stands for @samp{quiet}, disables
   8894 printing header information and messages explaining why no local variables
   8895 have been printed.
   8896 
   8897 @item info locals [-q] [-t @var{type_regexp}] [@var{regexp}]
   8898 Like @kbd{info locals}, but only print the local variables selected
   8899 with the provided regexp(s).
   8900 
   8901 If @var{regexp} is provided, print only the local variables whose names
   8902 match the regular expression @var{regexp}.
   8903 
   8904 If @var{type_regexp} is provided, print only the local variables whose
   8905 types, as printed by the @code{whatis} command, match
   8906 the regular expression @var{type_regexp}.
   8907 If @var{type_regexp} contains space(s), it should be enclosed in
   8908 quote characters.  If needed, use backslash to escape the meaning
   8909 of special characters or quotes.
   8910 
   8911 If both @var{regexp} and @var{type_regexp} are provided, a local variable
   8912 is printed only if its name matches @var{regexp} and its type matches
   8913 @var{type_regexp}.
   8914 
   8915 The command @kbd{info locals -q -t @var{type_regexp}} can usefully be
   8916 combined with the commands @kbd{frame apply} and @kbd{thread apply}.
   8917 For example, your program might use Resource Acquisition Is
   8918 Initialization types (RAII) such as @code{lock_something_t}: each
   8919 local variable of type @code{lock_something_t} automatically places a
   8920 lock that is destroyed when the variable goes out of scope.  You can
   8921 then list all acquired locks in your program by doing
   8922 @smallexample
   8923 thread apply all -s frame apply all -s info locals -q -t lock_something_t
   8924 @end smallexample
   8925 @noindent
   8926 or the equivalent shorter form
   8927 @smallexample
   8928 tfaas i lo -q -t lock_something_t
   8929 @end smallexample
   8930 
   8931 @end table
   8932 
   8933 @node Frame Apply
   8934 @section Applying a Command to Several Frames.
   8935 @kindex frame apply
   8936 @cindex apply command to several frames
   8937 @table @code
   8938 @item frame apply [all | @var{count} | @var{-count} | level @var{level}@dots{}] [@var{option}]@dots{} @var{command}
   8939 The @code{frame apply} command allows you to apply the named
   8940 @var{command} to one or more frames.
   8941 
   8942 @table @code
   8943 @item @code{all}
   8944 Specify @code{all} to apply @var{command} to all frames.
   8945 
   8946 @item @var{count}
   8947 Use @var{count} to apply @var{command} to the innermost @var{count}
   8948 frames, where @var{count} is a positive number.
   8949 
   8950 @item @var{-count}
   8951 Use @var{-count} to apply @var{command} to the outermost @var{count}
   8952 frames, where @var{count} is a positive number.
   8953 
   8954 @item @code{level}
   8955 Use @code{level} to apply @var{command} to the set of frames identified
   8956 by the @var{level} list.  @var{level} is a frame level or a range of frame
   8957 levels as @var{level1}-@var{level2}.  The frame level is the number shown
   8958 in the first field of the @samp{backtrace} command output.
   8959 E.g., @samp{2-4 6-8 3} indicates to apply @var{command} for the frames
   8960 at levels 2, 3, 4, 6, 7, 8, and then again on frame at level 3.
   8961 
   8962 @end table
   8963 
   8964 Note that the frames on which @code{frame apply} applies a command are
   8965 also influenced by the @code{set backtrace} settings such as @code{set
   8966 backtrace past-main} and @code{set backtrace limit N}.
   8967 @xref{Backtrace,,Backtraces}.
   8968 
   8969 The @code{frame apply} command also supports a number of options that
   8970 allow overriding relevant @code{set backtrace} settings:
   8971 
   8972 @table @code
   8973 @item -past-main [@code{on}|@code{off}]
   8974 Whether backtraces should continue past @code{main}.
   8975 Related setting: @ref{set backtrace past-main}.
   8976 
   8977 @item -past-entry [@code{on}|@code{off}]
   8978 Whether backtraces should continue past the entry point of a program.
   8979 Related setting: @ref{set backtrace past-entry}.
   8980 @end table
   8981 
   8982 By default, @value{GDBN} displays some frame information before the
   8983 output produced by @var{command}, and an error raised during the
   8984 execution of a @var{command} will abort @code{frame apply}.  The
   8985 following options can be used to fine-tune these behaviors:
   8986 
   8987 @table @code
   8988 @item -c
   8989 The flag @code{-c}, which stands for @samp{continue}, causes any
   8990 errors in @var{command} to be displayed, and the execution of
   8991 @code{frame apply} then continues.
   8992 @item -s
   8993 The flag @code{-s}, which stands for @samp{silent}, causes any errors
   8994 or empty output produced by a @var{command} to be silently ignored.
   8995 That is, the execution continues, but the frame information and errors
   8996 are not printed.
   8997 @item -q
   8998 The flag @code{-q} (@samp{quiet}) disables printing the frame
   8999 information.
   9000 @end table
   9001 
   9002 The following example shows how the flags @code{-c} and @code{-s} are
   9003 working when applying the command @code{p j} to all frames, where
   9004 variable @code{j} can only be successfully printed in the outermost
   9005 @code{#1 main} frame.
   9006 
   9007 @smallexample
   9008 @group
   9009 (@value{GDBP}) frame apply all p j
   9010 #0  some_function (i=5) at fun.c:4
   9011 No symbol "j" in current context.
   9012 (@value{GDBP}) frame apply all -c p j
   9013 #0  some_function (i=5) at fun.c:4
   9014 No symbol "j" in current context.
   9015 #1  0x565555fb in main (argc=1, argv=0xffffd2c4) at fun.c:11
   9016 $1 = 5
   9017 (@value{GDBP}) frame apply all -s p j
   9018 #1  0x565555fb in main (argc=1, argv=0xffffd2c4) at fun.c:11
   9019 $2 = 5
   9020 (@value{GDBP})
   9021 @end group
   9022 @end smallexample
   9023 
   9024 By default, @samp{frame apply}, prints the frame location
   9025 information before the command output:
   9026 
   9027 @smallexample
   9028 @group
   9029 (@value{GDBP}) frame apply all p $sp
   9030 #0  some_function (i=5) at fun.c:4
   9031 $4 = (void *) 0xffffd1e0
   9032 #1  0x565555fb in main (argc=1, argv=0xffffd2c4) at fun.c:11
   9033 $5 = (void *) 0xffffd1f0
   9034 (@value{GDBP})
   9035 @end group
   9036 @end smallexample
   9037 
   9038 If the flag @code{-q} is given, no frame information is printed:
   9039 @smallexample
   9040 @group
   9041 (@value{GDBP}) frame apply all -q p $sp
   9042 $12 = (void *) 0xffffd1e0
   9043 $13 = (void *) 0xffffd1f0
   9044 (@value{GDBP})
   9045 @end group
   9046 @end smallexample
   9047 
   9048 @end table
   9049 
   9050 @table @code
   9051 
   9052 @kindex faas
   9053 @cindex apply a command to all frames (ignoring errors and empty output)
   9054 @item faas @var{command}
   9055 Shortcut for @code{frame apply all -s @var{command}}.
   9056 Applies @var{command} on all frames, ignoring errors and empty output.
   9057 
   9058 It can for example be used to print a local variable or a function
   9059 argument without knowing the frame where this variable or argument
   9060 is, using:
   9061 @smallexample
   9062 (@value{GDBP}) faas p some_local_var_i_do_not_remember_where_it_is
   9063 @end smallexample
   9064 
   9065 The @code{faas} command accepts the same options as the @code{frame
   9066 apply} command.  @xref{Frame Apply,,frame apply}.
   9067 
   9068 Note that the command @code{tfaas @var{command}} applies @var{command}
   9069 on all frames of all threads.  See @xref{Threads,,Threads}.
   9070 @end table
   9071 
   9072 
   9073 @node Frame Filter Management
   9074 @section Management of Frame Filters.
   9075 @cindex managing frame filters
   9076 
   9077 Frame filters are Python based utilities to manage and decorate the
   9078 output of frames.  @xref{Frame Filter API}, for further information.
   9079 
   9080 Managing frame filters is performed by several commands available
   9081 within @value{GDBN}, detailed here.
   9082 
   9083 @table @code
   9084 @kindex info frame-filter
   9085 @item info frame-filter
   9086 Print a list of installed frame filters from all dictionaries, showing
   9087 their name, priority and enabled status.
   9088 
   9089 @kindex disable frame-filter
   9090 @anchor{disable frame-filter all}
   9091 @item disable frame-filter @var{filter-dictionary} @var{filter-name}
   9092 Disable a frame filter in the dictionary matching
   9093 @var{filter-dictionary} and @var{filter-name}.  The
   9094 @var{filter-dictionary} may be @code{all}, @code{global},
   9095 @code{progspace}, or the name of the object file where the frame filter
   9096 dictionary resides.  When @code{all} is specified, all frame filters
   9097 across all dictionaries are disabled.  The @var{filter-name} is the name
   9098 of the frame filter and is used when @code{all} is not the option for
   9099 @var{filter-dictionary}.  A disabled frame-filter is not deleted, it
   9100 may be enabled again later.
   9101 
   9102 @kindex enable frame-filter
   9103 @item enable frame-filter @var{filter-dictionary} @var{filter-name}
   9104 Enable a frame filter in the dictionary matching
   9105 @var{filter-dictionary} and @var{filter-name}.  The
   9106 @var{filter-dictionary} may be @code{all}, @code{global},
   9107 @code{progspace} or the name of the object file where the frame filter
   9108 dictionary resides.  When @code{all} is specified, all frame filters across
   9109 all dictionaries are enabled.  The @var{filter-name} is the name of the frame
   9110 filter and is used when @code{all} is not the option for
   9111 @var{filter-dictionary}.
   9112 
   9113 Example:
   9114 
   9115 @smallexample
   9116 (@value{GDBP}) info frame-filter
   9117 
   9118 global frame-filters:
   9119   Priority  Enabled  Name
   9120   1000      No       PrimaryFunctionFilter
   9121   100       Yes      Reverse
   9122 
   9123 progspace /build/test frame-filters:
   9124   Priority  Enabled  Name
   9125   100       Yes      ProgspaceFilter
   9126 
   9127 objfile /build/test frame-filters:
   9128   Priority  Enabled  Name
   9129   999       Yes      BuildProgramFilter
   9130 
   9131 (@value{GDBP}) disable frame-filter /build/test BuildProgramFilter
   9132 (@value{GDBP}) info frame-filter
   9133 
   9134 global frame-filters:
   9135   Priority  Enabled  Name
   9136   1000      No       PrimaryFunctionFilter
   9137   100       Yes      Reverse
   9138 
   9139 progspace /build/test frame-filters:
   9140   Priority  Enabled  Name
   9141   100       Yes      ProgspaceFilter
   9142 
   9143 objfile /build/test frame-filters:
   9144   Priority  Enabled  Name
   9145   999       No       BuildProgramFilter
   9146 
   9147 (@value{GDBP}) enable frame-filter global PrimaryFunctionFilter
   9148 (@value{GDBP}) info frame-filter
   9149 
   9150 global frame-filters:
   9151   Priority  Enabled  Name
   9152   1000      Yes      PrimaryFunctionFilter
   9153   100       Yes      Reverse
   9154 
   9155 progspace /build/test frame-filters:
   9156   Priority  Enabled  Name
   9157   100       Yes      ProgspaceFilter
   9158 
   9159 objfile /build/test frame-filters:
   9160   Priority  Enabled  Name
   9161   999       No       BuildProgramFilter
   9162 @end smallexample
   9163 
   9164 @kindex set frame-filter priority
   9165 @item set frame-filter priority @var{filter-dictionary} @var{filter-name} @var{priority}
   9166 Set the @var{priority} of a frame filter in the dictionary matching
   9167 @var{filter-dictionary}, and the frame filter name matching
   9168 @var{filter-name}.  The @var{filter-dictionary} may be @code{global},
   9169 @code{progspace} or the name of the object file where the frame filter
   9170 dictionary resides.  The @var{priority} is an integer.
   9171 
   9172 @kindex show frame-filter priority
   9173 @item show frame-filter priority @var{filter-dictionary} @var{filter-name}
   9174 Show the @var{priority} of a frame filter in the dictionary matching
   9175 @var{filter-dictionary}, and the frame filter name matching
   9176 @var{filter-name}.  The @var{filter-dictionary} may be @code{global},
   9177 @code{progspace} or the name of the object file where the frame filter
   9178 dictionary resides.
   9179 
   9180 Example:
   9181 
   9182 @smallexample
   9183 (@value{GDBP}) info frame-filter
   9184 
   9185 global frame-filters:
   9186   Priority  Enabled  Name
   9187   1000      Yes      PrimaryFunctionFilter
   9188   100       Yes      Reverse
   9189 
   9190 progspace /build/test frame-filters:
   9191   Priority  Enabled  Name
   9192   100       Yes      ProgspaceFilter
   9193 
   9194 objfile /build/test frame-filters:
   9195   Priority  Enabled  Name
   9196   999       No       BuildProgramFilter
   9197 
   9198 (@value{GDBP}) set frame-filter priority global Reverse 50
   9199 (@value{GDBP}) info frame-filter
   9200 
   9201 global frame-filters:
   9202   Priority  Enabled  Name
   9203   1000      Yes      PrimaryFunctionFilter
   9204   50        Yes      Reverse
   9205 
   9206 progspace /build/test frame-filters:
   9207   Priority  Enabled  Name
   9208   100       Yes      ProgspaceFilter
   9209 
   9210 objfile /build/test frame-filters:
   9211   Priority  Enabled  Name
   9212   999       No       BuildProgramFilter
   9213 @end smallexample
   9214 @end table
   9215 
   9216 @node Source
   9217 @chapter Examining Source Files
   9218 
   9219 @value{GDBN} can print parts of your program's source, since the debugging
   9220 information recorded in the program tells @value{GDBN} what source files were
   9221 used to build it.  When your program stops, @value{GDBN} spontaneously prints
   9222 the line where it stopped.  Likewise, when you select a stack frame
   9223 (@pxref{Selection, ,Selecting a Frame}), @value{GDBN} prints the line where
   9224 execution in that frame has stopped.  You can print other portions of
   9225 source files by explicit command.
   9226 
   9227 If you use @value{GDBN} through its @sc{gnu} Emacs interface, you may
   9228 prefer to use Emacs facilities to view source; see @ref{Emacs, ,Using
   9229 @value{GDBN} under @sc{gnu} Emacs}.
   9230 
   9231 @menu
   9232 * List::                        Printing source lines
   9233 * Location Specifications::     How to specify code locations
   9234 * Edit::                        Editing source files
   9235 * Search::                      Searching source files
   9236 * Source Path::                 Specifying source directories
   9237 * Machine Code::                Source and machine code
   9238 * Disable Reading Source::      Disable Reading Source Code
   9239 @end menu
   9240 
   9241 @node List
   9242 @section Printing Source Lines
   9243 
   9244 @kindex list
   9245 @kindex l @r{(@code{list})}
   9246 To print lines from a source file, use the @code{list} command
   9247 (abbreviated @code{l}).  By default, ten lines are printed.
   9248 There are several ways to specify what part of the file you want to
   9249 print; see @ref{Location Specifications}, for the full list.
   9250 
   9251 Here are the forms of the @code{list} command most commonly used:
   9252 
   9253 @table @code
   9254 @item list @var{linenum}
   9255 Print lines centered around line number @var{linenum} in the
   9256 current source file.
   9257 
   9258 @item list @var{function}
   9259 Print lines centered around the beginning of function
   9260 @var{function}.
   9261 
   9262 @item list
   9263 Print more lines.  If the last lines printed were printed with a
   9264 @code{list} command, this prints lines following the last lines
   9265 printed; however, if the last line printed was a solitary line printed
   9266 as part of displaying a stack frame (@pxref{Stack, ,Examining the
   9267 Stack}), this prints lines centered around that line.  If no
   9268 @code{list} command has been used and no solitary line was printed,
   9269 it prints the lines around the function @code{main}.
   9270 
   9271 @item list +
   9272 Same as using with no arguments.
   9273 
   9274 @item list -
   9275 Print lines just before the lines last printed.
   9276 
   9277 @item list .
   9278 Print the lines surrounding the point of execution within the
   9279 currently selected frame.  If the inferior is not running, print lines
   9280 around the start of the main function instead.
   9281 @end table
   9282 
   9283 @cindex @code{list}, how many lines to display
   9284 By default, @value{GDBN} prints ten source lines with any of these forms of
   9285 the @code{list} command.  You can change this using @code{set listsize}:
   9286 
   9287 @table @code
   9288 @kindex set listsize
   9289 @item set listsize @var{count}
   9290 @itemx set listsize unlimited
   9291 Make the @code{list} command display @var{count} source lines (unless
   9292 the @code{list} argument explicitly specifies some other number).
   9293 Setting @var{count} to @code{unlimited} or 0 means there's no limit.
   9294 
   9295 @kindex show listsize
   9296 @item show listsize
   9297 Display the number of lines that @code{list} prints.
   9298 @end table
   9299 
   9300 Repeating a @code{list} command with @key{RET} discards the argument,
   9301 so it is equivalent to typing just @code{list}.  This is more useful
   9302 than listing the same lines again.  An exception is made for an
   9303 argument of @samp{-}; that argument is preserved in repetition so that
   9304 each repetition moves up in the source file.
   9305 
   9306 In general, the @code{list} command expects you to supply zero, one or
   9307 two location specs.  These location specs are interpreted to resolve
   9308 to source code lines; there are several ways of writing them
   9309 (@pxref{Location Specifications}), but the effect is always to resolve
   9310 to some source lines to display.
   9311 
   9312 Here is a complete description of the possible arguments for @code{list}:
   9313 
   9314 @table @code
   9315 @item list @var{locspec}
   9316 Print lines centered around the line or lines of all the code
   9317 locations that result from resolving @var{locspec}.
   9318 
   9319 @item list @var{first},@var{last}
   9320 Print lines from @var{first} to @var{last}.  Both arguments are
   9321 location specs.  When a @code{list} command has two location specs,
   9322 and the source file of the second location spec is omitted, this
   9323 refers to the same source file as the first location spec.  If either
   9324 @var{first} or @var{last} resolve to more than one source line in the
   9325 program, then the list command shows the list of resolved source
   9326 lines and does not proceed with the source code listing.
   9327 
   9328 @item list ,@var{last}
   9329 Print lines ending with @var{last}.
   9330 
   9331 Likewise, if @var{last} resolves to more than one source line in the
   9332 program, then the list command prints the list of resolved source
   9333 lines and does not proceed with the source code listing.
   9334 
   9335 @item list @var{first},
   9336 Print lines starting with @var{first}.
   9337 
   9338 @item list +
   9339 Print lines just after the lines last printed.
   9340 
   9341 @item list -
   9342 Print lines just before the lines last printed.
   9343 
   9344 @item list
   9345 As described in the preceding table.
   9346 @end table
   9347 
   9348 @node Location Specifications
   9349 @section Location Specifications
   9350 @cindex specifying location
   9351 @cindex locspec
   9352 @cindex source location
   9353 @cindex code location
   9354 
   9355 @cindex location spec
   9356 Several @value{GDBN} commands accept arguments that specify a location
   9357 or locations of your program's code.  Many times locations are
   9358 specified using a source line number, but they can also be specified
   9359 by a function name, an address, a label, etc.  The different
   9360 forms of specifying a location that @value{GDBN} recognizes are
   9361 collectively known as forms of @dfn{location specification}, or
   9362 @dfn{location spec}.  This section documents the forms of specifying
   9363 locations that @value{GDBN} recognizes.
   9364 
   9365 @cindex location resolution
   9366 @cindex resolution of location spec
   9367 When you specify a location, @value{GDBN} needs to find the place in
   9368 your program, known as @dfn{code location}, that corresponds to the
   9369 given location spec.  We call this process of finding actual code
   9370 locations corresponding to a location spec @dfn{location resolution}.
   9371 
   9372 A concrete code location in your program is uniquely identifiable by a
   9373 set of several attributes: its source line number, the name of its
   9374 source file, the fully-qualified and prototyped function in which it
   9375 is defined, and an instruction address.  Because each inferior has its
   9376 own address space, the inferior number is also a necessary part of
   9377 these attributes.
   9378 
   9379 By contrast, location specs you type will many times omit some of
   9380 these attributes.  For example, it is customary to specify just the
   9381 source line number to mean a line in the current source file, or
   9382 specify just the basename of the file, omitting its directories.  In
   9383 other words, a location spec is usually incomplete, a kind of
   9384 blueprint, and @value{GDBN} needs to complete the missing attributes
   9385 by using the implied defaults, and by considering the source code and
   9386 the debug information available to it.  This is what location
   9387 resolution is about.
   9388 
   9389 The resolution of an incomplete location spec can produce more than a
   9390 single code location, if the spec doesn't allow distinguishing between
   9391 them.  Here are some examples of situations that result in a location
   9392 spec matching multiple code locations in your program:
   9393 
   9394 @itemize @bullet
   9395 @item
   9396 The location spec specifies a function name, and there are several
   9397 functions in the program which have that name.  (To distinguish
   9398 between them, you can specify a fully-qualified and prototyped
   9399 function name, such as @code{A::func(int)} instead of just
   9400 @code{func}.)
   9401 
   9402 @item
   9403 The location spec specifies a source file name, and there are several
   9404 source files in the program that share the same name, for example
   9405 several files with the same basename in different subdirectories.  (To
   9406 distinguish between them, specify enough leading directories with the
   9407 file name.)
   9408 
   9409 @item
   9410 For a C@t{++} constructor, the @value{NGCC} compiler generates several
   9411 instances of the function body, used in different cases, but their
   9412 source-level names are identical.
   9413 
   9414 @item
   9415 For a C@t{++} template function, a given line in the function can
   9416 correspond to any number of instantiations.
   9417 
   9418 @item
   9419 For an inlined function, a given source line can correspond to several
   9420 actual code locations with that function's inlined code.
   9421 @end itemize
   9422 
   9423 Resolution of a location spec can also fail to produce a complete code
   9424 location, or even fail to produce any code location.  Here are some
   9425 examples of such situations:
   9426 
   9427 @itemize @bullet
   9428 @item
   9429 Some parts of the program lack detailed enough debug info, so the
   9430 resolved code location lacks some attributes, like source file name
   9431 and line number, leaving just the instruction address and perhaps also
   9432 a function name.  Such an incomplete code location is only usable in
   9433 contexts that work with addresses and/or function names.  Some
   9434 commands can only work with complete code locations.
   9435 
   9436 @item
   9437 The location spec specifies a function name, and there are no
   9438 functions in the program by that name, or they only exist in a
   9439 yet-unloaded shared library.
   9440 
   9441 @item
   9442 The location spec specifies a source file name, and there are no
   9443 source files in the program by that name, or they only exist in a
   9444 yet-unloaded shared library.
   9445 
   9446 @item
   9447 The location spec specifies both a source file name and a source line
   9448 number, and even though there are source files in the program that
   9449 match the file name, none of those files has the specified line
   9450 number.
   9451 @end itemize
   9452 
   9453 Locations may be specified using three different formats: linespec
   9454 locations, explicit locations, or address locations.  The following
   9455 subsections describe these formats.
   9456 
   9457 @menu
   9458 * Linespec Locations::                Linespec locations
   9459 * Explicit Locations::                Explicit locations
   9460 * Address Locations::                 Address locations
   9461 @end menu
   9462 
   9463 @node Linespec Locations
   9464 @subsection Linespec Locations
   9465 @cindex linespec locations
   9466 
   9467 A @dfn{linespec} is a colon-separated list of source location parameters such
   9468 as file name, function name, etc.  Here are all the different ways of
   9469 specifying a linespec:
   9470 
   9471 @table @code
   9472 @item @var{linenum}
   9473 Specifies the line number @var{linenum} of the current source file.
   9474 
   9475 @item -@var{offset}
   9476 @itemx +@var{offset}
   9477 Specifies the line @var{offset} lines before or after the @dfn{current
   9478 line}.  For the @code{list} command, the current line is the last one
   9479 printed; for the breakpoint commands, this is the line at which
   9480 execution stopped in the currently selected @dfn{stack frame}
   9481 (@pxref{Frames, ,Frames}, for a description of stack frames.)  When
   9482 used as the second of the two linespecs in a @code{list} command,
   9483 this specifies the line @var{offset} lines up or down from the first
   9484 linespec.
   9485 
   9486 @item @var{filename}:@var{linenum}
   9487 Specifies the line @var{linenum} in the source file @var{filename}.
   9488 If @var{filename} is a relative file name, then it will match any
   9489 source file name with the same trailing components.  For example, if
   9490 @var{filename} is @samp{gcc/expr.c}, then it will match source file
   9491 name of @file{/build/trunk/gcc/expr.c}, but not
   9492 @file{/build/trunk/libcpp/expr.c} or @file{/build/trunk/gcc/x-expr.c}.
   9493 
   9494 @item @var{function}
   9495 Specifies the line that begins the body of the function @var{function}.
   9496 For example, in C, this is the line with the open brace.
   9497 
   9498 By default, in C@t{++} and Ada, @var{function} is interpreted as
   9499 specifying all functions named @var{function} in all scopes.  For
   9500 C@t{++}, this means in all namespaces and classes.  For Ada, this
   9501 means in all packages.
   9502 
   9503 For example, assuming a program with C@t{++} symbols named
   9504 @code{A::B::func} and @code{B::func}, both commands @w{@kbd{break
   9505 func}} and @w{@kbd{break B::func}} set a breakpoint on both symbols.
   9506 
   9507 Commands that accept a linespec let you override this with the
   9508 @code{-qualified} option.  For example, @w{@kbd{break -qualified
   9509 func}} sets a breakpoint on a free-function named @code{func} ignoring
   9510 any C@t{++} class methods and namespace functions called @code{func}.
   9511 
   9512 @xref{Explicit Locations}.
   9513 
   9514 @item @var{function}:@var{label}
   9515 Specifies the line where @var{label} appears in @var{function}.
   9516 
   9517 @item @var{filename}:@var{function}
   9518 Specifies the line that begins the body of the function @var{function}
   9519 in the file @var{filename}.  You only need the file name with a
   9520 function name to avoid ambiguity when there are identically named
   9521 functions in different source files.
   9522 
   9523 @item @var{label}
   9524 Specifies the line at which the label named @var{label} appears
   9525 in the function corresponding to the currently selected stack frame.
   9526 If there is no current selected stack frame (for instance, if the inferior
   9527 is not running), then @value{GDBN} will not search for a label.
   9528 
   9529 @cindex breakpoint at static probe point
   9530 @item -pstap|-probe-stap @r{[}@var{objfile}:@r{[}@var{provider}:@r{]}@r{]}@var{name}
   9531 The @sc{gnu}/Linux tool @code{SystemTap} provides a way for
   9532 applications to embed static probes.  @xref{Static Probe Points}, for more
   9533 information on finding and using static probes.  This form of linespec
   9534 specifies the location of such a static probe.
   9535 
   9536 If @var{objfile} is given, only probes coming from that shared library
   9537 or executable matching @var{objfile} as a regular expression are considered.
   9538 If @var{provider} is given, then only probes from that provider are considered.
   9539 If several probes match the spec, @value{GDBN} will insert a breakpoint at
   9540 each one of those probes.
   9541 @end table
   9542 
   9543 @node Explicit Locations
   9544 @subsection Explicit Locations
   9545 @cindex explicit locations
   9546 
   9547 @dfn{Explicit locations} allow the user to directly specify the source
   9548 location's parameters using option-value pairs.
   9549 
   9550 Explicit locations are useful when several functions, labels, or
   9551 file names have the same name (base name for files) in the program's
   9552 sources.  In these cases, explicit locations point to the source
   9553 line you meant more accurately and unambiguously.  Also, using
   9554 explicit locations might be faster in large programs.
   9555 
   9556 For example, the linespec @samp{foo:bar} may refer to a function @code{bar}
   9557 defined in the file named @file{foo} or the label @code{bar} in a function
   9558 named @code{foo}.  @value{GDBN} must search either the file system or
   9559 the symbol table to know.
   9560 
   9561 The list of valid explicit location options is summarized in the
   9562 following table:
   9563 
   9564 @table @code
   9565 @item -source @var{filename}
   9566 The value specifies the source file name.  To differentiate between
   9567 files with the same base name, prepend as many directories as is necessary
   9568 to uniquely identify the desired file, e.g., @file{foo/bar/baz.c}.  Otherwise
   9569 @value{GDBN} will use the first file it finds with the given base
   9570 name.   This option requires the use of either @code{-function} or @code{-line}.
   9571 
   9572 @item -function @var{function}
   9573 The value specifies the name of a function.  Operations
   9574 on function locations unmodified by other options (such as @code{-label}
   9575 or @code{-line}) refer to the line that begins the body of the function.
   9576 In C, for example, this is the line with the open brace.
   9577 
   9578 By default, in C@t{++} and Ada, @var{function} is interpreted as
   9579 specifying all functions named @var{function} in all scopes.  For
   9580 C@t{++}, this means in all namespaces and classes.  For Ada, this
   9581 means in all packages.
   9582 
   9583 For example, assuming a program with C@t{++} symbols named
   9584 @code{A::B::func} and @code{B::func}, both commands @w{@kbd{break
   9585 -function func}} and @w{@kbd{break -function B::func}} set a
   9586 breakpoint on both symbols.
   9587 
   9588 You can use the @kbd{-qualified} flag to override this (see below).
   9589 
   9590 @item -qualified
   9591 
   9592 This flag makes @value{GDBN} interpret a function name specified with
   9593 @kbd{-function} as a complete fully-qualified name.
   9594 
   9595 For example, assuming a C@t{++} program with symbols named
   9596 @code{A::B::func} and @code{B::func}, the @w{@kbd{break -qualified
   9597 -function B::func}} command sets a breakpoint on @code{B::func}, only.
   9598 
   9599 (Note: the @kbd{-qualified} option can precede a linespec as well
   9600 (@pxref{Linespec Locations}), so the particular example above could be
   9601 simplified as @w{@kbd{break -qualified B::func}}.)
   9602 
   9603 @item -label @var{label}
   9604 The value specifies the name of a label.  When the function
   9605 name is not specified, the label is searched in the function of the currently
   9606 selected stack frame.
   9607 
   9608 @item -line @var{number}
   9609 The value specifies a line offset for the location.  The offset may either
   9610 be absolute (@code{-line 3}) or relative (@code{-line +3}), depending on
   9611 the command.  When specified without any other options, the line offset is
   9612 relative to the current line.
   9613 @end table
   9614 
   9615 Explicit location options may be abbreviated by omitting any non-unique
   9616 trailing characters from the option name, e.g., @w{@kbd{break -s main.c -li 3}}.
   9617 
   9618 @node Address Locations
   9619 @subsection Address Locations
   9620 @cindex address locations
   9621 
   9622 @dfn{Address locations} indicate a specific program address.  They have
   9623 the generalized form *@var{address}.
   9624 
   9625 For line-oriented commands, such as @code{list} and @code{edit}, this
   9626 specifies a source line that contains @var{address}.  For @code{break} and
   9627 other breakpoint-oriented commands, this can be used to set breakpoints in
   9628 parts of your program which do not have debugging information or
   9629 source files.
   9630 
   9631 Here @var{address} may be any expression valid in the current working
   9632 language (@pxref{Languages, working language}) that specifies a code
   9633 address.  In addition, as a convenience, @value{GDBN} extends the
   9634 semantics of expressions used in locations to cover several situations
   9635 that frequently occur during debugging.  Here are the various forms
   9636 of @var{address}:
   9637 
   9638 @table @code
   9639 @item @var{expression}
   9640 Any expression valid in the current working language.
   9641 
   9642 @item @var{funcaddr}
   9643 An address of a function or procedure derived from its name.  In C,
   9644 C@t{++}, Objective-C, Fortran, minimal, and assembly, this is
   9645 simply the function's name @var{function} (and actually a special case
   9646 of a valid expression).  In Pascal and Modula-2, this is
   9647 @code{&@var{function}}.  In Ada, this is @code{@var{function}'Address}
   9648 (although the Pascal form also works).
   9649 
   9650 This form specifies the address of the function's first instruction,
   9651 before the stack frame and arguments have been set up.
   9652 
   9653 @item '@var{filename}':@var{funcaddr}
   9654 Like @var{funcaddr} above, but also specifies the name of the source
   9655 file explicitly.  This is useful if the name of the function does not
   9656 specify the function unambiguously, e.g., if there are several
   9657 functions with identical names in different source files.
   9658 @end table
   9659 
   9660 @node Edit
   9661 @section Editing Source Files
   9662 @cindex editing source files
   9663 
   9664 @kindex edit
   9665 @kindex e @r{(@code{edit})}
   9666 To edit the lines in a source file, use the @code{edit} command.
   9667 The editing program of your choice
   9668 is invoked with the current line set to
   9669 the active line in the program.
   9670 Alternatively, there are several ways to specify what part of the file you
   9671 want to print if you want to see other parts of the program:
   9672 
   9673 @table @code
   9674 @item edit @var{locspec}
   9675 Edit the source file of the code location that results from resolving
   9676 @code{locspec}.  Editing starts at the source file and source line
   9677 @code{locspec} resolves to.
   9678 @xref{Location Specifications}, for all the possible forms of the
   9679 @var{locspec} argument.
   9680 
   9681 If @code{locspec} resolves to more than one source line in your
   9682 program, then the command prints the list of resolved source lines and
   9683 does not proceed with the editing.
   9684 
   9685 Here are the forms of the @code{edit} command most commonly used:
   9686 
   9687 @table @code
   9688 @item edit @var{number}
   9689 Edit the current source file with @var{number} as the active line number.
   9690 
   9691 @item edit @var{function}
   9692 Edit the file containing @var{function} at the beginning of its definition.
   9693 @end table
   9694 
   9695 @end table
   9696 
   9697 @subsection Choosing your Editor
   9698 You can customize @value{GDBN} to use any editor you want
   9699 @footnote{
   9700 The only restriction is that your editor (say @code{ex}), recognizes the
   9701 following command-line syntax:
   9702 @smallexample
   9703 ex +@var{number} file
   9704 @end smallexample
   9705 The optional numeric value +@var{number} specifies the number of the line in
   9706 the file where to start editing.}.
   9707 By default, it is @file{@value{EDITOR}}, but you can change this
   9708 by setting the environment variable @env{EDITOR} before using
   9709 @value{GDBN}.  For example, to configure @value{GDBN} to use the
   9710 @code{vi} editor, you could use these commands with the @code{sh} shell:
   9711 @smallexample
   9712 EDITOR=/usr/bin/vi
   9713 export EDITOR
   9714 gdb @dots{}
   9715 @end smallexample
   9716 or in the @code{csh} shell,
   9717 @smallexample
   9718 setenv EDITOR /usr/bin/vi
   9719 gdb @dots{}
   9720 @end smallexample
   9721 
   9722 @node Search
   9723 @section Searching Source Files
   9724 @cindex searching source files
   9725 
   9726 There are two commands for searching through the current source file for a
   9727 regular expression.
   9728 
   9729 @table @code
   9730 @kindex search
   9731 @kindex forward-search
   9732 @kindex fo @r{(@code{forward-search})}
   9733 @item forward-search @var{regexp}
   9734 @itemx search @var{regexp}
   9735 The command @samp{forward-search @var{regexp}} checks each line,
   9736 starting with the one following the last line listed, for a match for
   9737 @var{regexp}.  It lists the line that is found.  You can use the
   9738 synonym @samp{search @var{regexp}} or abbreviate the command name as
   9739 @code{fo}.
   9740 
   9741 @kindex reverse-search
   9742 @item reverse-search @var{regexp}
   9743 The command @samp{reverse-search @var{regexp}} checks each line, starting
   9744 with the one before the last line listed and going backward, for a match
   9745 for @var{regexp}.  It lists the line that is found.  You can abbreviate
   9746 this command as @code{rev}.
   9747 @end table
   9748 
   9749 @node Source Path
   9750 @section Specifying Source Directories
   9751 
   9752 @cindex source path
   9753 @cindex directories for source files
   9754 Executable programs sometimes do not record the directories of the source
   9755 files from which they were compiled, just the names.  Even when they do,
   9756 the directories could be moved between the compilation and your debugging
   9757 session.  @value{GDBN} has a list of directories to search for source files;
   9758 this is called the @dfn{source path}.  Each time @value{GDBN} wants a source file,
   9759 it tries all the directories in the list, in the order they are present
   9760 in the list, until it finds a file with the desired name.
   9761 
   9762 For example, suppose an executable references the file
   9763 @file{/usr/src/foo-1.0/lib/foo.c}, does not record a compilation
   9764 directory, and the @dfn{source path} is @file{/mnt/cross}.
   9765 @value{GDBN} would look for the source file in the following
   9766 locations:
   9767 
   9768 @enumerate
   9769 
   9770 @item @file{/usr/src/foo-1.0/lib/foo.c}
   9771 @item @file{/mnt/cross/usr/src/foo-1.0/lib/foo.c}
   9772 @item @file{/mnt/cross/foo.c}
   9773 
   9774 @end enumerate
   9775 
   9776 If the source file is not present at any of the above locations then
   9777 an error is printed.  @value{GDBN} does not look up the parts of the
   9778 source file name, such as @file{/mnt/cross/src/foo-1.0/lib/foo.c}.
   9779 Likewise, the subdirectories of the source path are not searched: if
   9780 the source path is @file{/mnt/cross}, and the binary refers to
   9781 @file{foo.c}, @value{GDBN} would not find it under
   9782 @file{/mnt/cross/usr/src/foo-1.0/lib}.
   9783 
   9784 Plain file names, relative file names with leading directories, file
   9785 names containing dots, etc.@: are all treated as described above,
   9786 except that non-absolute file names are not looked up literally.  If
   9787 the @dfn{source path} is @file{/mnt/cross}, the source file is
   9788 recorded as @file{../lib/foo.c}, and no compilation directory is
   9789 recorded, then @value{GDBN} will search in the following locations:
   9790 
   9791 @enumerate
   9792 
   9793 @item @file{/mnt/cross/../lib/foo.c}
   9794 @item @file{/mnt/cross/foo.c}
   9795 
   9796 @end enumerate
   9797 
   9798 @kindex cdir
   9799 @kindex cwd
   9800 @vindex $cdir@r{, convenience variable}
   9801 @vindex $cwd@r{, convenience variable}
   9802 @cindex compilation directory
   9803 @cindex current directory
   9804 @cindex working directory
   9805 @cindex directory, current
   9806 @cindex directory, compilation
   9807 The @dfn{source path} will always include two special entries
   9808 @samp{$cdir} and @samp{$cwd}, these refer to the compilation directory
   9809 (if one is recorded) and the current working directory respectively.
   9810 
   9811 @samp{$cdir} causes @value{GDBN} to search within the compilation
   9812 directory, if one is recorded in the debug information.  If no
   9813 compilation directory is recorded in the debug information then
   9814 @samp{$cdir} is ignored.
   9815 
   9816 @samp{$cwd} is not the same as @samp{.}---the former tracks the
   9817 current working directory as it changes during your @value{GDBN}
   9818 session, while the latter is immediately expanded to the current
   9819 directory at the time you add an entry to the source path.
   9820 
   9821 If a compilation directory is recorded in the debug information, and
   9822 @value{GDBN} has not found the source file after the first search
   9823 using @dfn{source path}, then @value{GDBN} will combine the
   9824 compilation directory and the filename, and then search for the source
   9825 file again using the @dfn{source path}.
   9826 
   9827 For example, if the executable records the source file as
   9828 @file{/usr/src/foo-1.0/lib/foo.c}, the compilation directory is
   9829 recorded as @file{/project/build}, and the @dfn{source path} is
   9830 @file{/mnt/cross:$cdir:$cwd} while the current working directory of
   9831 the @value{GDBN} session is @file{/home/user}, then @value{GDBN} will
   9832 search for the source file in the following locations:
   9833 
   9834 @enumerate
   9835 
   9836 @item @file{/usr/src/foo-1.0/lib/foo.c}
   9837 @item @file{/mnt/cross/usr/src/foo-1.0/lib/foo.c}
   9838 @item @file{/project/build/usr/src/foo-1.0/lib/foo.c}
   9839 @item @file{/home/user/usr/src/foo-1.0/lib/foo.c}
   9840 @item @file{/mnt/cross/project/build/usr/src/foo-1.0/lib/foo.c}
   9841 @item @file{/project/build/project/build/usr/src/foo-1.0/lib/foo.c}
   9842 @item @file{/home/user/project/build/usr/src/foo-1.0/lib/foo.c}
   9843 @item @file{/mnt/cross/foo.c}
   9844 @item @file{/project/build/foo.c}
   9845 @item @file{/home/user/foo.c}
   9846 
   9847 @end enumerate
   9848 
   9849 If the file name in the previous example had been recorded in the
   9850 executable as a relative path rather than an absolute path, then the
   9851 first look up would not have occurred, but all of the remaining steps
   9852 would be similar.
   9853 
   9854 When searching for source files on MS-DOS and MS-Windows, where
   9855 absolute paths start with a drive letter (e.g.@:
   9856 @file{C:/project/foo.c}), @value{GDBN} will remove the drive letter
   9857 from the file name before appending it to a search directory from
   9858 @dfn{source path}; for instance if the executable references the
   9859 source file @file{C:/project/foo.c} and @dfn{source path} is set to
   9860 @file{D:/mnt/cross}, then @value{GDBN} will search in the following
   9861 locations for the source file:
   9862 
   9863 @enumerate
   9864 
   9865 @item @file{C:/project/foo.c}
   9866 @item @file{D:/mnt/cross/project/foo.c}
   9867 @item @file{D:/mnt/cross/foo.c}
   9868 
   9869 @end enumerate
   9870 
   9871 Note that the executable search path is @emph{not} used to locate the
   9872 source files.
   9873 
   9874 Whenever you reset or rearrange the source path, @value{GDBN} clears out
   9875 any information it has cached about where source files are found and where
   9876 each line is in the file.
   9877 
   9878 @kindex directory
   9879 @kindex dir
   9880 When you start @value{GDBN}, its source path includes only @samp{$cdir}
   9881 and @samp{$cwd}, in that order.
   9882 To add other directories, use the @code{directory} command.
   9883 
   9884 The search path is used to find both program source files and @value{GDBN}
   9885 script files (read using the @samp{-command} option and @samp{source} command).
   9886 
   9887 In addition to the source path, @value{GDBN} provides a set of commands
   9888 that manage a list of source path substitution rules.  A @dfn{substitution
   9889 rule} specifies how to rewrite source directories stored in the program's
   9890 debug information in case the sources were moved to a different
   9891 directory between compilation and debugging.  A rule is made of
   9892 two strings, the first specifying what needs to be rewritten in
   9893 the path, and the second specifying how it should be rewritten.
   9894 In @ref{set substitute-path}, we name these two parts @var{from} and
   9895 @var{to} respectively.  @value{GDBN} does a simple string replacement
   9896 of @var{from} with @var{to} at the start of the directory part of the
   9897 source file name, and uses that result instead of the original file
   9898 name to look up the sources.
   9899 
   9900 Using the previous example, suppose the @file{foo-1.0} tree has been
   9901 moved from @file{/usr/src} to @file{/mnt/cross}, then you can tell
   9902 @value{GDBN} to replace @file{/usr/src} in all source path names with
   9903 @file{/mnt/cross}.  The first lookup will then be
   9904 @file{/mnt/cross/foo-1.0/lib/foo.c} in place of the original location
   9905 of @file{/usr/src/foo-1.0/lib/foo.c}.  To define a source path
   9906 substitution rule, use the @code{set substitute-path} command
   9907 (@pxref{set substitute-path}).
   9908 
   9909 To avoid unexpected substitution results, a rule is applied only if the
   9910 @var{from} part of the directory name ends at a directory separator.
   9911 For instance, a rule substituting  @file{/usr/source} into
   9912 @file{/mnt/cross} will be applied to @file{/usr/source/foo-1.0} but
   9913 not to @file{/usr/sourceware/foo-2.0}.  And because the substitution
   9914 is applied only at the beginning of the directory name, this rule will
   9915 not be applied to @file{/root/usr/source/baz.c} either.
   9916 
   9917 In many cases, you can achieve the same result using the @code{directory}
   9918 command.  However, @code{set substitute-path} can be more efficient in
   9919 the case where the sources are organized in a complex tree with multiple
   9920 subdirectories.  With the @code{directory} command, you need to add each
   9921 subdirectory of your project.  If you moved the entire tree while
   9922 preserving its internal organization, then @code{set substitute-path}
   9923 allows you to direct the debugger to all the sources with one single
   9924 command.
   9925 
   9926 @code{set substitute-path} is also more than just a shortcut command.
   9927 The source path is only used if the file at the original location no
   9928 longer exists.  On the other hand, @code{set substitute-path} modifies
   9929 the debugger behavior to look at the rewritten location instead.  So, if
   9930 for any reason a source file that is not relevant to your executable is
   9931 located at the original location, a substitution rule is the only
   9932 method available to point @value{GDBN} at the new location.
   9933 
   9934 @cindex @samp{--with-relocated-sources}
   9935 @cindex default source path substitution
   9936 You can configure a default source path substitution rule by
   9937 configuring @value{GDBN} with the
   9938 @samp{--with-relocated-sources=@var{dir}} option.  The @var{dir}
   9939 should be the name of a directory under @value{GDBN}'s configured
   9940 prefix (set with @samp{--prefix} or @samp{--exec-prefix}), and
   9941 directory names in debug information under @var{dir} will be adjusted
   9942 automatically if the installed @value{GDBN} is moved to a new
   9943 location.  This is useful if @value{GDBN}, libraries or executables
   9944 with debug information and corresponding source code are being moved
   9945 together.
   9946 
   9947 @table @code
   9948 @item directory @var{dirname} @dots{}
   9949 @item dir @var{dirname} @dots{}
   9950 Add directory @var{dirname} to the front of the source path.  Several
   9951 directory names may be given to this command, separated by @samp{:}
   9952 (@samp{;} on MS-DOS and MS-Windows, where @samp{:} usually appears as
   9953 part of absolute file names) or
   9954 whitespace.  You may specify a directory that is already in the source
   9955 path; this moves it forward, so @value{GDBN} searches it sooner.
   9956 
   9957 The special strings @samp{$cdir} (to refer to the compilation
   9958 directory, if one is recorded), and @samp{$cwd} (to refer to the
   9959 current working directory) can also be included in the list of
   9960 directories @var{dirname}.  Though these will already be in the source
   9961 path they will be moved forward in the list so @value{GDBN} searches
   9962 them sooner.
   9963 
   9964 @item directory
   9965 Reset the source path to its default value (@samp{$cdir:$cwd} on Unix systems).  This requires confirmation.
   9966 
   9967 @c RET-repeat for @code{directory} is explicitly disabled, but since
   9968 @c repeating it would be a no-op we do not say that.  (thanks to RMS)
   9969 
   9970 @item set directories @var{path-list}
   9971 @kindex set directories
   9972 Set the source path to @var{path-list}.
   9973 @samp{$cdir:$cwd} are added if missing.
   9974 
   9975 @item show directories
   9976 @kindex show directories
   9977 Print the source path: show which directories it contains.
   9978 
   9979 @anchor{set substitute-path}
   9980 @item set substitute-path @var{from} @var{to}
   9981 @kindex set substitute-path
   9982 Define a source path substitution rule, and add it at the end of the
   9983 current list of existing substitution rules.  If a rule with the same
   9984 @var{from} was already defined, then the old rule is also deleted.
   9985 
   9986 For example, if the file @file{/foo/bar/baz.c} was moved to
   9987 @file{/mnt/cross/baz.c}, then the command
   9988 
   9989 @smallexample
   9990 (@value{GDBP}) set substitute-path /foo/bar /mnt/cross
   9991 @end smallexample
   9992 
   9993 @noindent
   9994 will tell @value{GDBN} to replace @samp{/foo/bar} with
   9995 @samp{/mnt/cross}, which will allow @value{GDBN} to find the file
   9996 @file{baz.c} even though it was moved.
   9997 
   9998 In the case when more than one substitution rule have been defined,
   9999 the rules are evaluated one by one in the order where they have been
   10000 defined.  The first one matching, if any, is selected to perform
   10001 the substitution.
   10002 
   10003 For instance, if we had entered the following commands:
   10004 
   10005 @smallexample
   10006 (@value{GDBP}) set substitute-path /usr/src/include /mnt/include
   10007 (@value{GDBP}) set substitute-path /usr/src /mnt/src
   10008 @end smallexample
   10009 
   10010 @noindent
   10011 @value{GDBN} would then rewrite @file{/usr/src/include/defs.h} into
   10012 @file{/mnt/include/defs.h} by using the first rule.  However, it would
   10013 use the second rule to rewrite @file{/usr/src/lib/foo.c} into
   10014 @file{/mnt/src/lib/foo.c}.
   10015 
   10016 
   10017 @item unset substitute-path [path]
   10018 @kindex unset substitute-path
   10019 If a path is specified, search the current list of substitution rules
   10020 for a rule that would rewrite that path.  Delete that rule if found.
   10021 A warning is emitted by the debugger if no rule could be found.
   10022 
   10023 If no path is specified, then all substitution rules are deleted.
   10024 
   10025 @item show substitute-path [path]
   10026 @kindex show substitute-path
   10027 If a path is specified, then print the source path substitution rule
   10028 which would rewrite that path, if any.
   10029 
   10030 If no path is specified, then print all existing source path substitution
   10031 rules.
   10032 
   10033 @end table
   10034 
   10035 If your source path is cluttered with directories that are no longer of
   10036 interest, @value{GDBN} may sometimes cause confusion by finding the wrong
   10037 versions of source.  You can correct the situation as follows:
   10038 
   10039 @enumerate
   10040 @item
   10041 Use @code{directory} with no argument to reset the source path to its default value.
   10042 
   10043 @item
   10044 Use @code{directory} with suitable arguments to reinstall the
   10045 directories you want in the source path.  You can add all the
   10046 directories in one command.
   10047 @end enumerate
   10048 
   10049 @node Machine Code
   10050 @section Source and Machine Code
   10051 @cindex source line and its code address
   10052 
   10053 You can use the command @code{info line} to map source lines to program
   10054 addresses (and vice versa), and the command @code{disassemble} to display
   10055 a range of addresses as machine instructions.  You can use the command
   10056 @code{set disassemble-next-line} to set whether to disassemble next
   10057 source line when execution stops.  When run under @sc{gnu} Emacs
   10058 mode, the @code{info line} command causes the arrow to point to the
   10059 line specified.  Also, @code{info line} prints addresses in symbolic form as
   10060 well as hex.
   10061 
   10062 @table @code
   10063 @kindex info line
   10064 @item info line
   10065 @itemx info line @var{locspec}
   10066 Print the starting and ending addresses of the compiled code for the
   10067 source lines of the code locations that result from resolving
   10068 @var{locspec}.  @xref{Location Specifications}, for the various forms
   10069 of @var{locspec}.
   10070 With no @var{locspec}, information about the current source line is
   10071 printed.
   10072 @end table
   10073 
   10074 For example, we can use @code{info line} to discover the location of
   10075 the object code for the first line of function
   10076 @code{m4_changequote}:
   10077 
   10078 @smallexample
   10079 (@value{GDBP}) info line m4_changequote
   10080 Line 895 of "builtin.c" starts at pc 0x634c <m4_changequote> and \
   10081         ends at 0x6350 <m4_changequote+4>.
   10082 @end smallexample
   10083 
   10084 @noindent
   10085 @cindex code address and its source line
   10086 We can also inquire, using @code{*@var{addr}} as the form for
   10087 @var{locspec}, what source line covers a particular address
   10088 @var{addr}:
   10089 @smallexample
   10090 (@value{GDBP}) info line *0x63ff
   10091 Line 926 of "builtin.c" starts at pc 0x63e4 <m4_changequote+152> and \
   10092         ends at 0x6404 <m4_changequote+184>.
   10093 @end smallexample
   10094 
   10095 @cindex @code{$_} and @code{info line}
   10096 @cindex @code{x} command, default address
   10097 @kindex x@r{(examine), and} info line
   10098 After @code{info line}, the default address for the @code{x} command
   10099 is changed to the starting address of the line, so that @samp{x/i} is
   10100 sufficient to begin examining the machine code (@pxref{Memory,
   10101 ,Examining Memory}).  Also, this address is saved as the value of the
   10102 convenience variable @code{$_} (@pxref{Convenience Vars, ,Convenience
   10103 Variables}).
   10104 
   10105 @cindex info line, repeated calls
   10106 After @code{info line}, using @code{info line} again without
   10107 specifying a location will display information about the next source
   10108 line.
   10109 
   10110 @anchor{disassemble}
   10111 @table @code
   10112 @kindex disassemble
   10113 @cindex assembly instructions
   10114 @cindex instructions, assembly
   10115 @cindex machine instructions
   10116 @cindex listing machine instructions
   10117 @item disassemble
   10118 @itemx disassemble /m
   10119 @itemx disassemble /s
   10120 @itemx disassemble /r
   10121 @itemx disassemble /b
   10122 This specialized command dumps a range of memory as machine
   10123 instructions.  It can also print mixed source+disassembly by specifying
   10124 the @code{/m} or @code{/s} modifier and print the raw instructions in
   10125 hex as well as in symbolic form by specifying the @code{/r} or @code{/b}
   10126 modifier.
   10127 
   10128 Only one of @code{/m} and @code{/s} can be used, attempting to use
   10129 both flag will give an error.
   10130 
   10131 Only one of @code{/r} and @code{/b} can be used, attempting to use
   10132 both flag will give an error.
   10133 
   10134 The default memory range is the function surrounding the program
   10135 counter of the selected frame.  A single argument to this command is a
   10136 program counter value; @value{GDBN} dumps the function surrounding
   10137 this value.  When two arguments are given, they should be separated by
   10138 a comma, possibly surrounded by whitespace.  The arguments specify a
   10139 range of addresses to dump, in one of two forms:
   10140 
   10141 @table @code
   10142 @item @var{start},@var{end}
   10143 the addresses from @var{start} (inclusive) to @var{end} (exclusive)
   10144 @item @var{start},+@var{length}
   10145 the addresses from @var{start} (inclusive) to
   10146 @code{@var{start}+@var{length}} (exclusive).
   10147 @end table
   10148 
   10149 @noindent
   10150 When 2 arguments are specified, the name of the function is also
   10151 printed (since there could be several functions in the given range).
   10152 
   10153 The argument(s) can be any expression yielding a numeric value, such as
   10154 @samp{0x32c4}, @samp{&main+10} or @samp{$pc - 8}.
   10155 
   10156 If the range of memory being disassembled contains current program counter,
   10157 the instruction at that location is shown with a @code{=>} marker.
   10158 @end table
   10159 
   10160 The following example shows the disassembly of a range of addresses of
   10161 HP PA-RISC 2.0 code:
   10162 
   10163 @smallexample
   10164 (@value{GDBP}) disas 0x32c4, 0x32e4
   10165 Dump of assembler code from 0x32c4 to 0x32e4:
   10166    0x32c4 <main+204>:      addil 0,dp
   10167    0x32c8 <main+208>:      ldw 0x22c(sr0,r1),r26
   10168    0x32cc <main+212>:      ldil 0x3000,r31
   10169    0x32d0 <main+216>:      ble 0x3f8(sr4,r31)
   10170    0x32d4 <main+220>:      ldo 0(r31),rp
   10171    0x32d8 <main+224>:      addil -0x800,dp
   10172    0x32dc <main+228>:      ldo 0x588(r1),r26
   10173    0x32e0 <main+232>:      ldil 0x3000,r31
   10174 End of assembler dump.
   10175 @end smallexample
   10176 
   10177 The following two examples are for RISC-V, and demonstrates the
   10178 difference between the @code{/r} and @code{/b} modifiers.  First with
   10179 @code{/b}, the bytes of the instruction are printed, in hex, in memory
   10180 order:
   10181 
   10182 @smallexample
   10183 (@value{GDBP}) disassemble /b 0x00010150,0x0001015c
   10184 Dump of assembler code from 0x10150 to 0x1015c:
   10185    0x00010150 <call_me+4>:      22 dc                 	sw	s0,56(sp)
   10186    0x00010152 <call_me+6>:      80 00                 	addi	s0,sp,64
   10187    0x00010154 <call_me+8>:      23 26 a4 fe           	sw	a0,-20(s0)
   10188    0x00010158 <call_me+12>:     23 24 b4 fe           	sw	a1,-24(s0)
   10189 End of assembler dump.
   10190 @end smallexample
   10191 
   10192 In contrast, with @code{/r} the bytes of the instruction are displayed
   10193 in the instruction order, for RISC-V this means that the bytes have been
   10194 swapped to little-endian order:
   10195 
   10196 @smallexample
   10197 (@value{GDBP}) disassemble /r 0x00010150,0x0001015c
   10198 Dump of assembler code from 0x10150 to 0x1015c:
   10199    0x00010150 <call_me+4>:      dc22              	sw	s0,56(sp)
   10200    0x00010152 <call_me+6>:      0080              	addi	s0,sp,64
   10201    0x00010154 <call_me+8>:      fea42623        	sw	a0,-20(s0)
   10202    0x00010158 <call_me+12>:     feb42423        	sw	a1,-24(s0)
   10203 End of assembler dump.
   10204 @end smallexample
   10205 
   10206 Here is an example showing mixed source+assembly for Intel x86
   10207 with @code{/m} or @code{/s}, when the program is stopped just after
   10208 function prologue in a non-optimized function with no inline code.
   10209 
   10210 @smallexample
   10211 (@value{GDBP}) disas /m main
   10212 Dump of assembler code for function main:
   10213 5       @{
   10214    0x08048330 <+0>:    push   %ebp
   10215    0x08048331 <+1>:    mov    %esp,%ebp
   10216    0x08048333 <+3>:    sub    $0x8,%esp
   10217    0x08048336 <+6>:    and    $0xfffffff0,%esp
   10218    0x08048339 <+9>:    sub    $0x10,%esp
   10219 
   10220 6         printf ("Hello.\n");
   10221 => 0x0804833c <+12>:   movl   $0x8048440,(%esp)
   10222    0x08048343 <+19>:   call   0x8048284 <puts@@plt>
   10223 
   10224 7         return 0;
   10225 8       @}
   10226    0x08048348 <+24>:   mov    $0x0,%eax
   10227    0x0804834d <+29>:   leave
   10228    0x0804834e <+30>:   ret
   10229 
   10230 End of assembler dump.
   10231 @end smallexample
   10232 
   10233 The @code{/m} option is deprecated as its output is not useful when
   10234 there is either inlined code or re-ordered code.
   10235 The @code{/s} option is the preferred choice.
   10236 Here is an example for AMD x86-64 showing the difference between
   10237 @code{/m} output and @code{/s} output.
   10238 This example has one inline function defined in a header file,
   10239 and the code is compiled with @samp{-O2} optimization.
   10240 Note how the @code{/m} output is missing the disassembly of
   10241 several instructions that are present in the @code{/s} output.
   10242 
   10243 @file{foo.h}:
   10244 
   10245 @smallexample
   10246 int
   10247 foo (int a)
   10248 @{
   10249   if (a < 0)
   10250     return a * 2;
   10251   if (a == 0)
   10252     return 1;
   10253   return a + 10;
   10254 @}
   10255 @end smallexample
   10256 
   10257 @file{foo.c}:
   10258 
   10259 @smallexample
   10260 #include "foo.h"
   10261 volatile int x, y;
   10262 int
   10263 main ()
   10264 @{
   10265   x = foo (y);
   10266   return 0;
   10267 @}
   10268 @end smallexample
   10269 
   10270 @smallexample
   10271 (@value{GDBP}) disas /m main
   10272 Dump of assembler code for function main:
   10273 5	@{
   10274 
   10275 6	  x = foo (y);
   10276    0x0000000000400400 <+0>:	mov    0x200c2e(%rip),%eax # 0x601034 <y>
   10277    0x0000000000400417 <+23>:	mov    %eax,0x200c13(%rip) # 0x601030 <x>
   10278 
   10279 7	  return 0;
   10280 8	@}
   10281    0x000000000040041d <+29>:	xor    %eax,%eax
   10282    0x000000000040041f <+31>:	retq
   10283    0x0000000000400420 <+32>:	add    %eax,%eax
   10284    0x0000000000400422 <+34>:	jmp    0x400417 <main+23>
   10285 
   10286 End of assembler dump.
   10287 (@value{GDBP}) disas /s main
   10288 Dump of assembler code for function main:
   10289 foo.c:
   10290 5	@{
   10291 6	  x = foo (y);
   10292    0x0000000000400400 <+0>:	mov    0x200c2e(%rip),%eax # 0x601034 <y>
   10293 
   10294 foo.h:
   10295 4	  if (a < 0)
   10296    0x0000000000400406 <+6>:	test   %eax,%eax
   10297    0x0000000000400408 <+8>:	js     0x400420 <main+32>
   10298 
   10299 6	  if (a == 0)
   10300 7	    return 1;
   10301 8	  return a + 10;
   10302    0x000000000040040a <+10>:	lea    0xa(%rax),%edx
   10303    0x000000000040040d <+13>:	test   %eax,%eax
   10304    0x000000000040040f <+15>:	mov    $0x1,%eax
   10305    0x0000000000400414 <+20>:	cmovne %edx,%eax
   10306 
   10307 foo.c:
   10308 6	  x = foo (y);
   10309    0x0000000000400417 <+23>:	mov    %eax,0x200c13(%rip) # 0x601030 <x>
   10310 
   10311 7	  return 0;
   10312 8	@}
   10313    0x000000000040041d <+29>:	xor    %eax,%eax
   10314    0x000000000040041f <+31>:	retq
   10315 
   10316 foo.h:
   10317 5	    return a * 2;
   10318    0x0000000000400420 <+32>:	add    %eax,%eax
   10319    0x0000000000400422 <+34>:	jmp    0x400417 <main+23>
   10320 End of assembler dump.
   10321 @end smallexample
   10322 
   10323 Here is another example showing raw instructions in hex for AMD x86-64,
   10324 
   10325 @smallexample
   10326 (@value{GDBP}) disas /r 0x400281,+10
   10327 Dump of assembler code from 0x400281 to 0x40028b:
   10328    0x0000000000400281:  38 36  cmp    %dh,(%rsi)
   10329    0x0000000000400283:  2d 36 34 2e 73 sub    $0x732e3436,%eax
   10330    0x0000000000400288:  6f     outsl  %ds:(%rsi),(%dx)
   10331    0x0000000000400289:  2e 32 00       xor    %cs:(%rax),%al
   10332 End of assembler dump.
   10333 @end smallexample
   10334 
   10335 Note that the @samp{disassemble} command's address arguments are
   10336 specified using expressions in your programming language
   10337 (@pxref{Expressions, ,Expressions}), not location specs
   10338 (@pxref{Location Specifications}).  So, for example, if you want to
   10339 disassemble function @code{bar} in file @file{foo.c}, you must type
   10340 @samp{disassemble 'foo.c'::bar} and not @samp{disassemble foo.c:bar}.
   10341 
   10342 Some architectures have more than one commonly-used set of instruction
   10343 mnemonics or other syntax.
   10344 
   10345 For programs that were dynamically linked and use shared libraries,
   10346 instructions that call functions or branch to locations in the shared
   10347 libraries might show a seemingly bogus location---it's actually a
   10348 location of the relocation table.  On some architectures, @value{GDBN}
   10349 might be able to resolve these to actual function names.
   10350 
   10351 @table @code
   10352 @kindex set disassembler-options
   10353 @cindex disassembler options
   10354 @item set disassembler-options @var{option1}[,@var{option2}@dots{}]
   10355 This command controls the passing of target specific information to
   10356 the disassembler.  For a list of valid options, please refer to the
   10357 @code{-M}/@code{--disassembler-options} section of the @samp{objdump}
   10358 manual and/or the output of @kbd{objdump --help}
   10359 (@pxref{objdump,,objdump,binutils,The GNU Binary Utilities}).
   10360 The default value is the empty string.
   10361 
   10362 If it is necessary to specify more than one disassembler option, then
   10363 multiple options can be placed together into a comma separated list.
   10364 Currently this command is only supported on targets ARC, ARM, MIPS,
   10365 PowerPC and S/390.
   10366 
   10367 @kindex show disassembler-options
   10368 @item show disassembler-options
   10369 Show the current setting of the disassembler options.
   10370 @end table
   10371 
   10372 @table @code
   10373 @kindex set disassembly-flavor
   10374 @cindex Intel disassembly flavor
   10375 @cindex AT&T disassembly flavor
   10376 @item set disassembly-flavor @var{instruction-set}
   10377 Select the instruction set to use when disassembling the
   10378 program via the @code{disassemble} or @code{x/i} commands.
   10379 
   10380 Currently this command is only defined for the Intel x86 family.  You
   10381 can set @var{instruction-set} to either @code{intel} or @code{att}.
   10382 The default is @code{att}, the AT&T flavor used by default by Unix
   10383 assemblers for x86-based targets.
   10384 
   10385 @kindex show disassembly-flavor
   10386 @item show disassembly-flavor
   10387 Show the current setting of the disassembly flavor.
   10388 @end table
   10389 
   10390 @table @code
   10391 @kindex set disassemble-next-line
   10392 @kindex show disassemble-next-line
   10393 @item set disassemble-next-line
   10394 @itemx show disassemble-next-line
   10395 Control whether or not @value{GDBN} will disassemble the next source
   10396 line or instruction when execution stops.  If ON, @value{GDBN} will
   10397 display disassembly of the next source line when execution of the
   10398 program being debugged stops.  This is @emph{in addition} to
   10399 displaying the source line itself, which @value{GDBN} always does if
   10400 possible.  If the next source line cannot be displayed for some reason
   10401 (e.g., if @value{GDBN} cannot find the source file, or there's no line
   10402 info in the debug info), @value{GDBN} will display disassembly of the
   10403 next @emph{instruction} instead of showing the next source line.  If
   10404 AUTO, @value{GDBN} will display disassembly of next instruction only
   10405 if the source line cannot be displayed.  This setting causes
   10406 @value{GDBN} to display some feedback when you step through a function
   10407 with no line info or whose source file is unavailable.  The default is
   10408 OFF, which means never display the disassembly of the next line or
   10409 instruction.
   10410 @end table
   10411 
   10412 @node Disable Reading Source
   10413 @section Disable Reading Source Code
   10414 @cindex source code, disable access
   10415 
   10416 In some cases it can be desirable to prevent @value{GDBN} from
   10417 accessing source code files.  One case where this might be desirable
   10418 is if the source code files are located over a slow network
   10419 connection.
   10420 
   10421 The following command can be used to control whether @value{GDBN}
   10422 should access source code files or not:
   10423 
   10424 @table @code
   10425 @kindex set source open
   10426 @kindex show source open
   10427 @item set source open @r{[}on@r{|}off@r{]}
   10428 @itemx show source open
   10429 When this option is @code{on}, which is the default, @value{GDBN} will
   10430 access source code files when needed, for example to print source
   10431 lines when @value{GDBN} stops, or in response to the @code{list}
   10432 command.
   10433 
   10434 When this option is @code{off}, @value{GDBN} will not access source
   10435 code files.
   10436 @end table
   10437 
   10438 @node Data
   10439 @chapter Examining Data
   10440 
   10441 @cindex printing data
   10442 @cindex examining data
   10443 @kindex print
   10444 @kindex inspect
   10445 The usual way to examine data in your program is with the @code{print}
   10446 command (abbreviated @code{p}), or its synonym @code{inspect}.  It
   10447 evaluates and prints the value of an expression of the language your
   10448 program is written in (@pxref{Languages, ,Using @value{GDBN} with
   10449 Different Languages}).  It may also print the expression using a
   10450 Python-based pretty-printer (@pxref{Pretty Printing}).
   10451 
   10452 @table @code
   10453 @item print [[@var{options}] --] @var{expr}
   10454 @itemx print [[@var{options}] --] /@var{f} @var{expr}
   10455 @var{expr} is an expression (in the source language).  By default the
   10456 value of @var{expr} is printed in a format appropriate to its data type;
   10457 you can choose a different format by specifying @samp{/@var{f}}, where
   10458 @var{f} is a letter specifying the format; see @ref{Output Formats,,Output
   10459 Formats}.
   10460 
   10461 @anchor{print options}
   10462 The @code{print} command supports a number of options that allow
   10463 overriding relevant global print settings as set by @code{set print}
   10464 subcommands:
   10465 
   10466 @table @code
   10467 @item -address [@code{on}|@code{off}]
   10468 Set printing of addresses.
   10469 Related setting: @ref{set print address}.
   10470 
   10471 @item -array [@code{on}|@code{off}]
   10472 Pretty formatting of arrays.
   10473 Related setting: @ref{set print array}.
   10474 
   10475 @item -array-indexes [@code{on}|@code{off}]
   10476 Set printing of array indexes.
   10477 Related setting: @ref{set print array-indexes}.
   10478 
   10479 @item -characters @var{number-of-characters}|@code{elements}|@code{unlimited}
   10480 Set limit on string characters to print.  The value @code{elements}
   10481 causes the limit on array elements to print to be used.  The value
   10482 @code{unlimited} causes there to be no limit.  Related setting:
   10483 @ref{set print characters}.
   10484 
   10485 @item -elements @var{number-of-elements}|@code{unlimited}
   10486 Set limit on array elements and optionally string characters to print.
   10487 See @ref{set print characters}, and the @code{-characters} option above
   10488 for when this option applies to strings.  The value @code{unlimited}
   10489 causes there to be no limit.  @xref{set print elements}, for a related
   10490 CLI command.
   10491 
   10492 @item -max-depth @var{depth}|@code{unlimited}
   10493 Set the threshold after which nested structures are replaced with
   10494 ellipsis.  Related setting: @ref{set print max-depth}.
   10495 
   10496 @item -nibbles [@code{on}|@code{off}]
   10497 Set whether to print binary values in groups of four bits, known
   10498 as ``nibbles''.  @xref{set print nibbles}.
   10499 
   10500 @item -memory-tag-violations [@code{on}|@code{off}]
   10501 Set printing of additional information about memory tag violations.
   10502 @xref{set print memory-tag-violations}.
   10503 
   10504 @item -null-stop [@code{on}|@code{off}]
   10505 Set printing of char arrays to stop at first null char.  Related
   10506 setting: @ref{set print null-stop}.
   10507 
   10508 @item -object [@code{on}|@code{off}]
   10509 Set printing C@t{++} virtual function tables.  Related setting:
   10510 @ref{set print object}.
   10511 
   10512 @item -pretty [@code{on}|@code{off}]
   10513 Set pretty formatting of structures.  Related setting: @ref{set print
   10514 pretty}.
   10515 
   10516 @item -raw-values [@code{on}|@code{off}]
   10517 Set whether to print values in raw form, bypassing any
   10518 pretty-printers for that value.  Related setting: @ref{set print
   10519 raw-values}.
   10520 
   10521 @item -repeats @var{number-of-repeats}|@code{unlimited}
   10522 Set threshold for repeated print elements.  @code{unlimited} causes
   10523 all elements to be individually printed.  Related setting: @ref{set
   10524 print repeats}.
   10525 
   10526 @item -static-members [@code{on}|@code{off}]
   10527 Set printing C@t{++} static members.  Related setting: @ref{set print
   10528 static-members}.
   10529 
   10530 @item -symbol [@code{on}|@code{off}]
   10531 Set printing of symbol names when printing pointers.  Related setting:
   10532 @ref{set print symbol}.
   10533 
   10534 @item -union [@code{on}|@code{off}]
   10535 Set printing of unions interior to structures.  Related setting:
   10536 @ref{set print union}.
   10537 
   10538 @item -vtbl [@code{on}|@code{off}]
   10539 Set printing of C++ virtual function tables.  Related setting:
   10540 @ref{set print vtbl}.
   10541 @end table
   10542 
   10543 Because the @code{print} command accepts arbitrary expressions which
   10544 may look like options (including abbreviations), if you specify any
   10545 command option, then you must use a double dash (@code{--}) to mark
   10546 the end of option processing.
   10547 
   10548 For example, this prints the value of the @code{-p} expression:
   10549 
   10550 @smallexample
   10551 (@value{GDBP}) print -p
   10552 @end smallexample
   10553 
   10554 While this repeats the last value in the value history (see below)
   10555 with the @code{-pretty} option in effect:
   10556 
   10557 @smallexample
   10558 (@value{GDBP}) print -p --
   10559 @end smallexample
   10560 
   10561 Here is an example including both on option and an expression:
   10562 
   10563 @smallexample
   10564 @group
   10565 (@value{GDBP}) print -pretty -- *myptr
   10566 $1 = @{
   10567   next = 0x0,
   10568   flags = @{
   10569     sweet = 1,
   10570     sour = 1
   10571   @},
   10572   meat = 0x54 "Pork"
   10573 @}
   10574 @end group
   10575 @end smallexample
   10576 
   10577 @item print [@var{options}]
   10578 @itemx print [@var{options}] /@var{f}
   10579 @cindex reprint the last value
   10580 If you omit @var{expr}, @value{GDBN} displays the last value again (from the
   10581 @dfn{value history}; @pxref{Value History, ,Value History}).  This allows you to
   10582 conveniently inspect the same value in an alternative format.
   10583 @end table
   10584 
   10585 If the architecture supports memory tagging, the @code{print} command will
   10586 display pointer/memory tag mismatches if what is being printed is a pointer
   10587 or reference type. @xref{Memory Tagging}.
   10588 
   10589 A more low-level way of examining data is with the @code{x} command.
   10590 It examines data in memory at a specified address and prints it in a
   10591 specified format.  @xref{Memory, ,Examining Memory}.
   10592 
   10593 If you are interested in information about types, or about how the
   10594 fields of a struct or a class are declared, use the @code{ptype @var{expr}}
   10595 command rather than @code{print}.  @xref{Symbols, ,Examining the Symbol
   10596 Table}.
   10597 
   10598 @cindex exploring hierarchical data structures
   10599 @kindex explore
   10600 Another way of examining values of expressions and type information is
   10601 through the Python extension command @code{explore} (available only if
   10602 the @value{GDBN} build is configured with @code{--with-python}).  It
   10603 offers an interactive way to start at the highest level (or, the most
   10604 abstract level) of the data type of an expression (or, the data type
   10605 itself) and explore all the way down to leaf scalar values/fields
   10606 embedded in the higher level data types.
   10607 
   10608 @table @code
   10609 @item explore @var{arg}
   10610 @var{arg} is either an expression (in the source language), or a type
   10611 visible in the current context of the program being debugged.
   10612 @end table
   10613 
   10614 The working of the @code{explore} command can be illustrated with an
   10615 example.  If a data type @code{struct ComplexStruct} is defined in your
   10616 C program as
   10617 
   10618 @smallexample
   10619 struct SimpleStruct
   10620 @{
   10621   int i;
   10622   double d;
   10623 @};
   10624 
   10625 struct ComplexStruct
   10626 @{
   10627   struct SimpleStruct *ss_p;
   10628   int arr[10];
   10629 @};
   10630 @end smallexample
   10631 
   10632 @noindent
   10633 followed by variable declarations as
   10634 
   10635 @smallexample
   10636 struct SimpleStruct ss = @{ 10, 1.11 @};
   10637 struct ComplexStruct cs = @{ &ss, @{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 @} @};
   10638 @end smallexample
   10639 
   10640 @noindent
   10641 then, the value of the variable @code{cs} can be explored using the
   10642 @code{explore} command as follows.
   10643 
   10644 @smallexample
   10645 (@value{GDBP}) explore cs
   10646 The value of `cs' is a struct/class of type `struct ComplexStruct' with
   10647 the following fields:
   10648 
   10649   ss_p = <Enter 0 to explore this field of type `struct SimpleStruct *'>
   10650    arr = <Enter 1 to explore this field of type `int [10]'>
   10651 
   10652 Enter the field number of choice:
   10653 @end smallexample
   10654 
   10655 @noindent
   10656 Since the fields of @code{cs} are not scalar values, you are being
   10657 prompted to chose the field you want to explore.  Let's say you choose
   10658 the field @code{ss_p} by entering @code{0}.  Then, since this field is a
   10659 pointer, you will be asked if it is pointing to a single value.  From
   10660 the declaration of @code{cs} above, it is indeed pointing to a single
   10661 value, hence you enter @code{y}.  If you enter @code{n}, then you will
   10662 be asked if it were pointing to an array of values, in which case this
   10663 field will be explored as if it were an array.
   10664 
   10665 @smallexample
   10666 `cs.ss_p' is a pointer to a value of type `struct SimpleStruct'
   10667 Continue exploring it as a pointer to a single value [y/n]: y
   10668 The value of `*(cs.ss_p)' is a struct/class of type `struct
   10669 SimpleStruct' with the following fields:
   10670 
   10671   i = 10 .. (Value of type `int')
   10672   d = 1.1100000000000001 .. (Value of type `double')
   10673 
   10674 Press enter to return to parent value:
   10675 @end smallexample
   10676 
   10677 @noindent
   10678 If the field @code{arr} of @code{cs} was chosen for exploration by
   10679 entering @code{1} earlier, then since it is as array, you will be
   10680 prompted to enter the index of the element in the array that you want
   10681 to explore.
   10682 
   10683 @smallexample
   10684 `cs.arr' is an array of `int'.
   10685 Enter the index of the element you want to explore in `cs.arr': 5
   10686 
   10687 `(cs.arr)[5]' is a scalar value of type `int'.
   10688 
   10689 (cs.arr)[5] = 4
   10690 
   10691 Press enter to return to parent value: 
   10692 @end smallexample
   10693 
   10694 In general, at any stage of exploration, you can go deeper towards the
   10695 leaf values by responding to the prompts appropriately, or hit the
   10696 return key to return to the enclosing data structure (the @i{higher}
   10697 level data structure).
   10698 
   10699 Similar to exploring values, you can use the @code{explore} command to
   10700 explore types.  Instead of specifying a value (which is typically a
   10701 variable name or an expression valid in the current context of the
   10702 program being debugged), you specify a type name.  If you consider the
   10703 same example as above, your can explore the type
   10704 @code{struct ComplexStruct} by passing the argument
   10705 @code{struct ComplexStruct} to the @code{explore} command.
   10706 
   10707 @smallexample
   10708 (@value{GDBP}) explore struct ComplexStruct
   10709 @end smallexample
   10710 
   10711 @noindent
   10712 By responding to the prompts appropriately in the subsequent interactive
   10713 session, you can explore the type @code{struct ComplexStruct} in a
   10714 manner similar to how the value @code{cs} was explored in the above
   10715 example.
   10716 
   10717 The @code{explore} command also has two sub-commands,
   10718 @code{explore value} and @code{explore type}. The former sub-command is
   10719 a way to explicitly specify that value exploration of the argument is
   10720 being invoked, while the latter is a way to explicitly specify that type
   10721 exploration of the argument is being invoked.
   10722 
   10723 @table @code
   10724 @item explore value @var{expr}
   10725 @cindex explore value
   10726 This sub-command of @code{explore} explores the value of the
   10727 expression @var{expr} (if @var{expr} is an expression valid in the
   10728 current context of the program being debugged).  The behavior of this
   10729 command is identical to that of the behavior of the @code{explore}
   10730 command being passed the argument @var{expr}.
   10731 
   10732 @item explore type @var{arg}
   10733 @cindex explore type
   10734 This sub-command of @code{explore} explores the type of @var{arg} (if
   10735 @var{arg} is a type visible in the current context of program being
   10736 debugged), or the type of the value/expression @var{arg} (if @var{arg}
   10737 is an expression valid in the current context of the program being
   10738 debugged).  If @var{arg} is a type, then the behavior of this command is
   10739 identical to that of the @code{explore} command being passed the
   10740 argument @var{arg}.  If @var{arg} is an expression, then the behavior of
   10741 this command will be identical to that of the @code{explore} command
   10742 being passed the type of @var{arg} as the argument.
   10743 @end table
   10744 
   10745 @menu
   10746 * Expressions::                 Expressions
   10747 * Ambiguous Expressions::       Ambiguous Expressions
   10748 * Variables::                   Program variables
   10749 * Arrays::                      Artificial arrays
   10750 * Output Formats::              Output formats
   10751 * Memory::                      Examining memory
   10752 * Memory Tagging::              Memory Tagging
   10753 * Auto Display::                Automatic display
   10754 * Print Settings::              Print settings
   10755 * Pretty Printing::             Python pretty printing
   10756 * Value History::               Value history
   10757 * Convenience Vars::            Convenience variables
   10758 * Convenience Funs::            Convenience functions
   10759 * Registers::                   Registers
   10760 * Floating Point Hardware::     Floating point hardware
   10761 * Vector Unit::                 Vector Unit
   10762 * OS Information::              Auxiliary data provided by operating system
   10763 * Memory Region Attributes::    Memory region attributes
   10764 * Dump/Restore Files::          Copy between memory and a file
   10765 * Core File Generation::        Cause a program dump its core
   10766 * Character Sets::              Debugging programs that use a different
   10767                                 character set than GDB does
   10768 * Caching Target Data::         Data caching for targets
   10769 * Searching Memory::            Searching memory for a sequence of bytes
   10770 * Value Sizes::                 Managing memory allocated for values
   10771 @end menu
   10772 
   10773 @node Expressions
   10774 @section Expressions
   10775 
   10776 @cindex expressions
   10777 @code{print} and many other @value{GDBN} commands accept an expression and
   10778 compute its value.  Any kind of constant, variable or operator defined
   10779 by the programming language you are using is valid in an expression in
   10780 @value{GDBN}.  This includes conditional expressions, function calls,
   10781 casts, and string constants.  It also includes preprocessor macros, if
   10782 you compiled your program to include this information; see
   10783 @ref{Compilation}.
   10784 
   10785 @cindex arrays in expressions
   10786 @value{GDBN} supports array constants in expressions input by
   10787 the user.  The syntax is @{@var{element}, @var{element}@dots{}@}.  For example,
   10788 you can use the command @code{print @{1, 2, 3@}} to create an array
   10789 of three integers.  If you pass an array to a function or assign it
   10790 to a program variable, @value{GDBN} copies the array to memory that
   10791 is @code{malloc}ed in the target program.
   10792 
   10793 Because C is so widespread, most of the expressions shown in examples in
   10794 this manual are in C.  @xref{Languages, , Using @value{GDBN} with Different
   10795 Languages}, for information on how to use expressions in other
   10796 languages.
   10797 
   10798 In this section, we discuss operators that you can use in @value{GDBN}
   10799 expressions regardless of your programming language.
   10800 
   10801 @cindex casts, in expressions
   10802 Casts are supported in all languages, not just in C, because it is so
   10803 useful to cast a number into a pointer in order to examine a structure
   10804 at that address in memory.
   10805 @c FIXME: casts supported---Mod2 true?
   10806 
   10807 @value{GDBN} supports these operators, in addition to those common
   10808 to programming languages:
   10809 
   10810 @table @code
   10811 @item @@
   10812 @samp{@@} is a binary operator for treating parts of memory as arrays.
   10813 @xref{Arrays, ,Artificial Arrays}, for more information.
   10814 
   10815 @item ::
   10816 @samp{::} allows you to specify a variable in terms of the file or
   10817 function where it is defined.  @xref{Variables, ,Program Variables}.
   10818 
   10819 @cindex @{@var{type}@}
   10820 @cindex type casting memory
   10821 @cindex memory, viewing as typed object
   10822 @cindex casts, to view memory
   10823 @item @{@var{type}@} @var{addr}
   10824 Refers to an object of type @var{type} stored at address @var{addr} in
   10825 memory.  The address @var{addr} may be any expression whose value is
   10826 an integer or pointer (but parentheses are required around binary
   10827 operators, just as in a cast).  This construct is allowed regardless
   10828 of what kind of data is normally supposed to reside at @var{addr}.
   10829 @end table
   10830 
   10831 @node Ambiguous Expressions
   10832 @section Ambiguous Expressions
   10833 @cindex ambiguous expressions
   10834 
   10835 Expressions can sometimes contain some ambiguous elements.  For instance,
   10836 some programming languages (notably Ada, C@t{++} and Objective-C) permit
   10837 a single function name to be defined several times, for application in
   10838 different contexts.  This is called @dfn{overloading}.  Another example
   10839 involving Ada is generics.  A @dfn{generic package} is similar to C@t{++}
   10840 templates and is typically instantiated several times, resulting in
   10841 the same function name being defined in different contexts.
   10842 
   10843 In some cases and depending on the language, it is possible to adjust
   10844 the expression to remove the ambiguity.  For instance in C@t{++}, you
   10845 can specify the signature of the function you want to break on, as in
   10846 @kbd{break @var{function}(@var{types})}.  In Ada, using the fully
   10847 qualified name of your function often makes the expression unambiguous
   10848 as well.
   10849 
   10850 When an ambiguity that needs to be resolved is detected, the debugger
   10851 has the capability to display a menu of numbered choices for each
   10852 possibility, and then waits for the selection with the prompt @samp{>}.
   10853 The first option is always @samp{[0] cancel}, and typing @kbd{0 @key{RET}}
   10854 aborts the current command.  If the command in which the expression was
   10855 used allows more than one choice to be selected, the next option in the
   10856 menu is @samp{[1] all}, and typing @kbd{1 @key{RET}} selects all possible
   10857 choices.
   10858 
   10859 For example, the following session excerpt shows an attempt to set a
   10860 breakpoint at the overloaded symbol @code{String::after}.
   10861 We choose three particular definitions of that function name:
   10862 
   10863 @c FIXME! This is likely to change to show arg type lists, at least
   10864 @smallexample
   10865 @group
   10866 (@value{GDBP}) b String::after
   10867 [0] cancel
   10868 [1] all
   10869 [2] file:String.cc; line number:867
   10870 [3] file:String.cc; line number:860
   10871 [4] file:String.cc; line number:875
   10872 [5] file:String.cc; line number:853
   10873 [6] file:String.cc; line number:846
   10874 [7] file:String.cc; line number:735
   10875 > 2 4 6
   10876 Breakpoint 1 at 0xb26c: file String.cc, line 867.
   10877 Breakpoint 2 at 0xb344: file String.cc, line 875.
   10878 Breakpoint 3 at 0xafcc: file String.cc, line 846.
   10879 Multiple breakpoints were set.
   10880 Use the "delete" command to delete unwanted
   10881  breakpoints.
   10882 (@value{GDBP})
   10883 @end group
   10884 @end smallexample
   10885 
   10886 @table @code
   10887 @kindex set multiple-symbols
   10888 @item set multiple-symbols @var{mode}
   10889 @cindex multiple-symbols menu
   10890 
   10891 This option allows you to adjust the debugger behavior when an expression
   10892 is ambiguous.
   10893 
   10894 By default, @var{mode} is set to @code{all}.  If the command with which
   10895 the expression is used allows more than one choice, then @value{GDBN}
   10896 automatically selects all possible choices.  For instance, inserting
   10897 a breakpoint on a function using an ambiguous name results in a breakpoint
   10898 inserted on each possible match.  However, if a unique choice must be made,
   10899 then @value{GDBN} uses the menu to help you disambiguate the expression.
   10900 For instance, printing the address of an overloaded function will result
   10901 in the use of the menu.
   10902 
   10903 When @var{mode} is set to @code{ask}, the debugger always uses the menu
   10904 when an ambiguity is detected.
   10905 
   10906 Finally, when @var{mode} is set to @code{cancel}, the debugger reports
   10907 an error due to the ambiguity and the command is aborted.
   10908 
   10909 @kindex show multiple-symbols
   10910 @item show multiple-symbols
   10911 Show the current value of the @code{multiple-symbols} setting.
   10912 @end table
   10913 
   10914 @node Variables
   10915 @section Program Variables
   10916 
   10917 The most common kind of expression to use is the name of a variable
   10918 in your program.
   10919 
   10920 Variables in expressions are understood in the selected stack frame
   10921 (@pxref{Selection, ,Selecting a Frame}); they must be either:
   10922 
   10923 @itemize @bullet
   10924 @item
   10925 global (or file-static)
   10926 @end itemize
   10927 
   10928 @noindent or
   10929 
   10930 @itemize @bullet
   10931 @item
   10932 visible according to the scope rules of the
   10933 programming language from the point of execution in that frame
   10934 @end itemize
   10935 
   10936 @noindent This means that in the function
   10937 
   10938 @smallexample
   10939 foo (a)
   10940      int a;
   10941 @{
   10942   bar (a);
   10943   @{
   10944     int b = test ();
   10945     bar (b);
   10946   @}
   10947 @}
   10948 @end smallexample
   10949 
   10950 @noindent
   10951 you can examine and use the variable @code{a} whenever your program is
   10952 executing within the function @code{foo}, but you can only use or
   10953 examine the variable @code{b} while your program is executing inside
   10954 the block where @code{b} is declared.
   10955 
   10956 @cindex variable name conflict
   10957 There is an exception: you can refer to a variable or function whose
   10958 scope is a single source file even if the current execution point is not
   10959 in this file.  But it is possible to have more than one such variable or
   10960 function with the same name (in different source files).  If that
   10961 happens, referring to that name has unpredictable effects.  If you wish,
   10962 you can specify a static variable in a particular function or file by
   10963 using the colon-colon (@code{::}) notation:
   10964 
   10965 @cindex colon-colon, context for variables/functions
   10966 @ifnotinfo
   10967 @c info cannot cope with a :: index entry, but why deprive hard copy readers?
   10968 @cindex @code{::}, context for variables/functions
   10969 @end ifnotinfo
   10970 @smallexample
   10971 @var{file}::@var{variable}
   10972 @var{function}::@var{variable}
   10973 @end smallexample
   10974 
   10975 @noindent
   10976 Here @var{file} or @var{function} is the name of the context for the
   10977 static @var{variable}.  In the case of file names, you can use quotes to
   10978 make sure @value{GDBN} parses the file name as a single word---for example,
   10979 to print a global value of @code{x} defined in @file{f2.c}:
   10980 
   10981 @smallexample
   10982 (@value{GDBP}) p 'f2.c'::x
   10983 @end smallexample
   10984 
   10985 The @code{::} notation is normally used for referring to
   10986 static variables, since you typically disambiguate uses of local variables
   10987 in functions by selecting the appropriate frame and using the
   10988 simple name of the variable.  However, you may also use this notation
   10989 to refer to local variables in frames enclosing the selected frame:
   10990 
   10991 @smallexample
   10992 void
   10993 foo (int a)
   10994 @{
   10995   if (a < 10)
   10996     bar (a);
   10997   else
   10998     process (a);    /* Stop here */
   10999 @}
   11000 
   11001 int
   11002 bar (int a)
   11003 @{
   11004   foo (a + 5);
   11005 @}
   11006 @end smallexample
   11007 
   11008 @noindent
   11009 For example, if there is a breakpoint at the commented line,
   11010 here is what you might see
   11011 when the program stops after executing the call @code{bar(0)}:
   11012 
   11013 @smallexample
   11014 (@value{GDBP}) p a
   11015 $1 = 10
   11016 (@value{GDBP}) p bar::a
   11017 $2 = 5
   11018 (@value{GDBP}) up 2
   11019 #2  0x080483d0 in foo (a=5) at foobar.c:12
   11020 (@value{GDBP}) p a
   11021 $3 = 5
   11022 (@value{GDBP}) p bar::a
   11023 $4 = 0
   11024 @end smallexample
   11025 
   11026 @cindex C@t{++} scope resolution
   11027 These uses of @samp{::} are very rarely in conflict with the very
   11028 similar use of the same notation in C@t{++}.  When they are in
   11029 conflict, the C@t{++} meaning takes precedence; however, this can be
   11030 overridden by quoting the file or function name with single quotes.
   11031 
   11032 For example, suppose the program is stopped in a method of a class
   11033 that has a field named @code{includefile}, and there is also an
   11034 include file named @file{includefile} that defines a variable,
   11035 @code{some_global}.
   11036 
   11037 @smallexample
   11038 (@value{GDBP}) p includefile
   11039 $1 = 23
   11040 (@value{GDBP}) p includefile::some_global
   11041 A syntax error in expression, near `'.
   11042 (@value{GDBP}) p 'includefile'::some_global
   11043 $2 = 27
   11044 @end smallexample
   11045 
   11046 @cindex wrong values
   11047 @cindex variable values, wrong
   11048 @cindex function entry/exit, wrong values of variables
   11049 @cindex optimized code, wrong values of variables
   11050 @quotation
   11051 @emph{Warning:} Occasionally, a local variable may appear to have the
   11052 wrong value at certain points in a function---just after entry to a new
   11053 scope, and just before exit.
   11054 @end quotation
   11055 You may see this problem when you are stepping by machine instructions.
   11056 This is because, on most machines, it takes more than one instruction to
   11057 set up a stack frame (including local variable definitions); if you are
   11058 stepping by machine instructions, variables may appear to have the wrong
   11059 values until the stack frame is completely built.  On exit, it usually
   11060 also takes more than one machine instruction to destroy a stack frame;
   11061 after you begin stepping through that group of instructions, local
   11062 variable definitions may be gone.
   11063 
   11064 This may also happen when the compiler does significant optimizations.
   11065 To be sure of always seeing accurate values, turn off all optimization
   11066 when compiling.
   11067 
   11068 @cindex ``No symbol "foo" in current context''
   11069 Another possible effect of compiler optimizations is to optimize
   11070 unused variables out of existence, or assign variables to registers (as
   11071 opposed to memory addresses).  Depending on the support for such cases
   11072 offered by the debug info format used by the compiler, @value{GDBN}
   11073 might not be able to display values for such local variables.  If that
   11074 happens, @value{GDBN} will print a message like this:
   11075 
   11076 @smallexample
   11077 No symbol "foo" in current context.
   11078 @end smallexample
   11079 
   11080 To solve such problems, either recompile without optimizations, or use a
   11081 different debug info format, if the compiler supports several such
   11082 formats.  @xref{Compilation}, for more information on choosing compiler
   11083 options.  @xref{C, ,C and C@t{++}}, for more information about debug
   11084 info formats that are best suited to C@t{++} programs.
   11085 
   11086 If you ask to print an object whose contents are unknown to
   11087 @value{GDBN}, e.g., because its data type is not completely specified
   11088 by the debug information, @value{GDBN} will say @samp{<incomplete
   11089 type>}.  @xref{Symbols, incomplete type}, for more about this.
   11090 
   11091 @cindex no debug info variables
   11092 If you try to examine or use the value of a (global) variable for
   11093 which @value{GDBN} has no type information, e.g., because the program
   11094 includes no debug information, @value{GDBN} displays an error message.
   11095 @xref{Symbols, unknown type}, for more about unknown types.  If you
   11096 cast the variable to its declared type, @value{GDBN} gets the
   11097 variable's value using the cast-to type as the variable's type.  For
   11098 example, in a C program:
   11099 
   11100 @smallexample
   11101   (@value{GDBP}) p var
   11102   'var' has unknown type; cast it to its declared type
   11103   (@value{GDBP}) p (float) var
   11104   $1 = 3.14
   11105 @end smallexample
   11106 
   11107 If you append @kbd{@@entry} string to a function parameter name you get its
   11108 value at the time the function got called.  If the value is not available an
   11109 error message is printed.  Entry values are available only with some compilers.
   11110 Entry values are normally also printed at the function parameter list according
   11111 to @ref{set print entry-values}.
   11112 
   11113 @smallexample
   11114 Breakpoint 1, d (i=30) at gdb.base/entry-value.c:29
   11115 29	  i++;
   11116 (@value{GDBP}) next
   11117 30	  e (i);
   11118 (@value{GDBP}) print i
   11119 $1 = 31
   11120 (@value{GDBP}) print i@@entry
   11121 $2 = 30
   11122 @end smallexample
   11123 
   11124 Strings are identified as arrays of @code{char} values without specified
   11125 signedness.  Arrays of either @code{signed char} or @code{unsigned char} get
   11126 printed as arrays of 1 byte sized integers.  @code{-fsigned-char} or
   11127 @code{-funsigned-char} @value{NGCC} options have no effect as @value{GDBN}
   11128 defines literal string type @code{"char"} as @code{char} without a sign.
   11129 For program code
   11130 
   11131 @smallexample
   11132 char var0[] = "A";
   11133 signed char var1[] = "A";
   11134 @end smallexample
   11135 
   11136 You get during debugging
   11137 @smallexample
   11138 (@value{GDBP}) print var0
   11139 $1 = "A"
   11140 (@value{GDBP}) print var1
   11141 $2 = @{65 'A', 0 '\0'@}
   11142 @end smallexample
   11143 
   11144 @node Arrays
   11145 @section Artificial Arrays
   11146 
   11147 @cindex artificial array
   11148 @cindex arrays
   11149 @kindex @@@r{, referencing memory as an array}
   11150 It is often useful to print out several successive objects of the
   11151 same type in memory; a section of an array, or an array of
   11152 dynamically determined size for which only a pointer exists in the
   11153 program.
   11154 
   11155 You can do this by referring to a contiguous span of memory as an
   11156 @dfn{artificial array}, using the binary operator @samp{@@}.  The left
   11157 operand of @samp{@@} should be the first element of the desired array
   11158 and be an individual object.  The right operand should be the desired length
   11159 of the array.  The result is an array value whose elements are all of
   11160 the type of the left argument.  The first element is actually the left
   11161 argument; the second element comes from bytes of memory immediately
   11162 following those that hold the first element, and so on.  Here is an
   11163 example.  If a program says
   11164 
   11165 @smallexample
   11166 int *array = (int *) malloc (len * sizeof (int));
   11167 @end smallexample
   11168 
   11169 @noindent
   11170 you can print the contents of @code{array} with
   11171 
   11172 @smallexample
   11173 p *array@@len
   11174 @end smallexample
   11175 
   11176 The left operand of @samp{@@} must reside in memory.  Array values made
   11177 with @samp{@@} in this way behave just like other arrays in terms of
   11178 subscripting, and are coerced to pointers when used in expressions.
   11179 Artificial arrays most often appear in expressions via the value history
   11180 (@pxref{Value History, ,Value History}), after printing one out.
   11181 
   11182 Another way to create an artificial array is to use a cast.
   11183 This re-interprets a value as if it were an array.
   11184 The value need not be in memory:
   11185 @smallexample
   11186 (@value{GDBP}) p/x (short[2])0x12345678
   11187 $1 = @{0x1234, 0x5678@}
   11188 @end smallexample
   11189 
   11190 As a convenience, if you leave the array length out (as in
   11191 @samp{(@var{type}[])@var{value}}) @value{GDBN} calculates the size to fill
   11192 the value (as @samp{sizeof(@var{value})/sizeof(@var{type})}:
   11193 @smallexample
   11194 (@value{GDBP}) p/x (short[])0x12345678
   11195 $2 = @{0x1234, 0x5678@}
   11196 @end smallexample
   11197 
   11198 Sometimes the artificial array mechanism is not quite enough; in
   11199 moderately complex data structures, the elements of interest may not
   11200 actually be adjacent---for example, if you are interested in the values
   11201 of pointers in an array.  One useful work-around in this situation is
   11202 to use a convenience variable (@pxref{Convenience Vars, ,Convenience
   11203 Variables}) as a counter in an expression that prints the first
   11204 interesting value, and then repeat that expression via @key{RET}.  For
   11205 instance, suppose you have an array @code{dtab} of pointers to
   11206 structures, and you are interested in the values of a field @code{fv}
   11207 in each structure.  Here is an example of what you might type:
   11208 
   11209 @smallexample
   11210 set $i = 0
   11211 p dtab[$i++]->fv
   11212 @key{RET}
   11213 @key{RET}
   11214 @dots{}
   11215 @end smallexample
   11216 
   11217 @node Output Formats
   11218 @section Output Formats
   11219 
   11220 @cindex formatted output
   11221 @cindex output formats
   11222 By default, @value{GDBN} prints a value according to its data type.  Sometimes
   11223 this is not what you want.  For example, you might want to print a number
   11224 in hex, or a pointer in decimal.  Or you might want to view data in memory
   11225 at a certain address as a character string or as an instruction.  To do
   11226 these things, specify an @dfn{output format} when you print a value.
   11227 
   11228 The simplest use of output formats is to say how to print a value
   11229 already computed.  This is done by starting the arguments of the
   11230 @code{print} command with a slash and a format letter.  The format
   11231 letters supported are:
   11232 
   11233 @table @code
   11234 @item x
   11235 Print the binary representation of the value in hexadecimal.
   11236 
   11237 @item d
   11238 Print the binary representation of the value in decimal.
   11239 
   11240 @item u
   11241 Print the binary representation of the value as an decimal, as if it
   11242 were unsigned.
   11243 
   11244 @item o
   11245 Print the binary representation of the value in octal.
   11246 
   11247 @item t
   11248 Print the binary representation of the value in binary.  The letter
   11249 @samp{t} stands for ``two''.  @footnote{@samp{b} cannot be used
   11250 because these format letters are also used with the @code{x} command,
   11251 where @samp{b} stands for ``byte''; see @ref{Memory,,Examining
   11252 Memory}.}
   11253 
   11254 @item a
   11255 @cindex unknown address, locating
   11256 @cindex locate address
   11257 Print as an address, both absolute in hexadecimal and as an offset from
   11258 the nearest preceding symbol.  You can use this format used to discover
   11259 where (in what function) an unknown address is located:
   11260 
   11261 @smallexample
   11262 (@value{GDBP}) p/a 0x54320
   11263 $3 = 0x54320 <_initialize_vx+396>
   11264 @end smallexample
   11265 
   11266 @noindent
   11267 The command @code{info symbol 0x54320} yields similar results.
   11268 @xref{Symbols, info symbol}.
   11269 
   11270 @item c
   11271 Cast the value to an integer (unlike other formats, this does not just
   11272 reinterpret the underlying bits) and print it as a character constant.
   11273 This prints both the numerical value and its character representation.
   11274 The character representation is replaced with the octal escape
   11275 @samp{\nnn} for characters outside the 7-bit @sc{ascii} range.
   11276 
   11277 Without this format, @value{GDBN} displays @code{char},
   11278 @w{@code{unsigned char}}, and @w{@code{signed char}} data as character
   11279 constants.  Single-byte members of vectors are displayed as integer
   11280 data.
   11281 
   11282 @item f
   11283 Regard the bits of the value as a floating point number and print
   11284 using typical floating point syntax.
   11285 
   11286 @item s
   11287 @cindex printing strings
   11288 @cindex printing byte arrays
   11289 Regard as a string, if possible.  With this format, pointers to single-byte
   11290 data are displayed as null-terminated strings and arrays of single-byte data
   11291 are displayed as fixed-length strings.  Other values are displayed in their
   11292 natural types.
   11293 
   11294 Without this format, @value{GDBN} displays pointers to and arrays of
   11295 @code{char}, @w{@code{unsigned char}}, and @w{@code{signed char}} as
   11296 strings.  Single-byte members of a vector are displayed as an integer
   11297 array.
   11298 
   11299 @item z
   11300 Like @samp{x} formatting, the value is treated as an integer and
   11301 printed as hexadecimal, but leading zeros are printed to pad the value
   11302 to the size of the integer type.
   11303 
   11304 @item r
   11305 @cindex raw printing
   11306 Print using the @samp{raw} formatting.  By default, @value{GDBN} will
   11307 use a Python-based pretty-printer, if one is available (@pxref{Pretty
   11308 Printing}).  This typically results in a higher-level display of the
   11309 value's contents.  The @samp{r} format bypasses any Python
   11310 pretty-printer which might exist.
   11311 @end table
   11312 
   11313 For example, to print the program counter in hex (@pxref{Registers}), type
   11314 
   11315 @smallexample
   11316 p/x $pc
   11317 @end smallexample
   11318 
   11319 @noindent
   11320 Note that no space is required before the slash; this is because command
   11321 names in @value{GDBN} cannot contain a slash.
   11322 
   11323 To reprint the last value in the value history with a different format,
   11324 you can use the @code{print} command with just a format and no
   11325 expression.  For example, @samp{p/x} reprints the last value in hex.
   11326 
   11327 @node Memory
   11328 @section Examining Memory
   11329 
   11330 You can use the command @code{x} (for ``examine'') to examine memory in
   11331 any of several formats, independently of your program's data types.
   11332 
   11333 @cindex examining memory
   11334 @table @code
   11335 @kindex x @r{(examine memory)}
   11336 @item x/@var{nfu} @var{addr}
   11337 @itemx x @var{addr}
   11338 @itemx x
   11339 Use the @code{x} command to examine memory.
   11340 @end table
   11341 
   11342 @var{n}, @var{f}, and @var{u} are all optional parameters that specify how
   11343 much memory to display and how to format it; @var{addr} is an
   11344 expression giving the address where you want to start displaying memory.
   11345 If you use defaults for @var{nfu}, you need not type the slash @samp{/}.
   11346 Several commands set convenient defaults for @var{addr}.
   11347 
   11348 @table @r
   11349 @item @var{n}, the repeat count
   11350 The repeat count is a decimal integer; the default is 1.  It specifies
   11351 how much memory (counting by units @var{u}) to display.  If a negative
   11352 number is specified, memory is examined backward from @var{addr}.
   11353 @c This really is **decimal**; unaffected by 'set radix' as of GDB
   11354 @c 4.1.2.
   11355 
   11356 @item @var{f}, the display format
   11357 The display format is one of the formats used by @code{print}
   11358 (@samp{x}, @samp{d}, @samp{u}, @samp{o}, @samp{t}, @samp{a}, @samp{c},
   11359 @samp{f}, @samp{s}), @samp{i} (for machine instructions) and
   11360 @samp{m} (for displaying memory tags).
   11361 The default is @samp{x} (hexadecimal) initially.  The default changes
   11362 each time you use either @code{x} or @code{print}.
   11363 
   11364 @item @var{u}, the unit size
   11365 The unit size is any of
   11366 
   11367 @table @code
   11368 @item b
   11369 Bytes.
   11370 @item h
   11371 Halfwords (two bytes).
   11372 @item w
   11373 Words (four bytes).  This is the initial default.
   11374 @item g
   11375 Giant words (eight bytes).
   11376 @end table
   11377 
   11378 Each time you specify a unit size with @code{x}, that size becomes the
   11379 default unit the next time you use @code{x}.  For the @samp{i} format,
   11380 the unit size is ignored and is normally not written.  For the @samp{s} format,
   11381 the unit size defaults to @samp{b}, unless it is explicitly given.
   11382 Use @kbd{x /hs} to display 16-bit char strings and @kbd{x /ws} to display
   11383 32-bit strings.  The next use of @kbd{x /s} will again display 8-bit strings.
   11384 Note that the results depend on the programming language of the
   11385 current compilation unit.  If the language is C, the @samp{s}
   11386 modifier will use the UTF-16 encoding while @samp{w} will use
   11387 UTF-32.  The encoding is set by the programming language and cannot
   11388 be altered.
   11389 
   11390 @item @var{addr}, starting display address
   11391 @var{addr} is the address where you want @value{GDBN} to begin displaying
   11392 memory.  The expression need not have a pointer value (though it may);
   11393 it is always interpreted as an integer address of a byte of memory.
   11394 @xref{Expressions, ,Expressions}, for more information on expressions.  The default for
   11395 @var{addr} is usually just after the last address examined---but several
   11396 other commands also set the default address: @code{info breakpoints} (to
   11397 the address of the last breakpoint listed), @code{info line} (to the
   11398 starting address of a line), and @code{print} (if you use it to display
   11399 a value from memory).
   11400 @end table
   11401 
   11402 For example, @samp{x/3uh 0x54320} is a request to display three halfwords
   11403 (@code{h}) of memory, formatted as unsigned decimal integers (@samp{u}),
   11404 starting at address @code{0x54320}.  @samp{x/4xw $sp} prints the four
   11405 words (@samp{w}) of memory above the stack pointer (here, @samp{$sp};
   11406 @pxref{Registers, ,Registers}) in hexadecimal (@samp{x}).
   11407 
   11408 You can also specify a negative repeat count to examine memory backward
   11409 from the given address.  For example, @samp{x/-3uh 0x54320} prints three
   11410 halfwords (@code{h}) at @code{0x5431a}, @code{0x5431c}, and @code{0x5431e}.
   11411 
   11412 Since the letters indicating unit sizes are all distinct from the
   11413 letters specifying output formats, you do not have to remember whether
   11414 unit size or format comes first; either order works.  The output
   11415 specifications @samp{4xw} and @samp{4wx} mean exactly the same thing.
   11416 (However, the count @var{n} must come first; @samp{wx4} does not work.)
   11417 
   11418 Even though the unit size @var{u} is ignored for the formats @samp{s}
   11419 and @samp{i}, you might still want to use a count @var{n}; for example,
   11420 @samp{3i} specifies that you want to see three machine instructions,
   11421 including any operands.  For convenience, especially when used with
   11422 the @code{display} command, the @samp{i} format also prints branch delay
   11423 slot instructions, if any, beyond the count specified, which immediately
   11424 follow the last instruction that is within the count.  The command
   11425 @code{disassemble} gives an alternative way of inspecting machine
   11426 instructions; see @ref{Machine Code,,Source and Machine Code}.
   11427 
   11428 If a negative repeat count is specified for the formats @samp{s} or @samp{i},
   11429 the command displays null-terminated strings or instructions before the given
   11430 address as many as the absolute value of the given number.  For the @samp{i}
   11431 format, we use line number information in the debug info to accurately locate
   11432 instruction boundaries while disassembling backward.  If line info is not
   11433 available, the command stops examining memory with an error message.
   11434 
   11435 All the defaults for the arguments to @code{x} are designed to make it
   11436 easy to continue scanning memory with minimal specifications each time
   11437 you use @code{x}.  For example, after you have inspected three machine
   11438 instructions with @samp{x/3i @var{addr}}, you can inspect the next seven
   11439 with just @samp{x/7}.  If you use @key{RET} to repeat the @code{x} command,
   11440 the repeat count @var{n} is used again; the other arguments default as
   11441 for successive uses of @code{x}.
   11442 
   11443 When examining machine instructions, the instruction at current program
   11444 counter is shown with a @code{=>} marker. For example:
   11445 
   11446 @smallexample
   11447 (@value{GDBP}) x/5i $pc-6
   11448    0x804837f <main+11>: mov    %esp,%ebp
   11449    0x8048381 <main+13>: push   %ecx
   11450    0x8048382 <main+14>: sub    $0x4,%esp
   11451 => 0x8048385 <main+17>: movl   $0x8048460,(%esp)
   11452    0x804838c <main+24>: call   0x80482d4 <puts@@plt>
   11453 @end smallexample
   11454 
   11455 If the architecture supports memory tagging, the tags can be displayed by
   11456 using @samp{m}.  @xref{Memory Tagging}.
   11457 
   11458 The information will be displayed once per granule size
   11459 (the amount of bytes a particular memory tag covers).  For example, AArch64
   11460 has a granule size of 16 bytes, so it will display a tag every 16 bytes.
   11461 
   11462 Due to the way @value{GDBN} prints information with the @code{x} command (not
   11463 aligned to a particular boundary), the tag information will refer to the
   11464 initial address displayed on a particular line.  If a memory tag boundary
   11465 is crossed in the middle of a line displayed by the @code{x} command, it
   11466 will be displayed on the next line.
   11467 
   11468 The @samp{m} format doesn't affect any other specified formats that were
   11469 passed to the @code{x} command.
   11470 
   11471 @cindex @code{$_}, @code{$__}, and value history
   11472 The addresses and contents printed by the @code{x} command are not saved
   11473 in the value history because there is often too much of them and they
   11474 would get in the way.  Instead, @value{GDBN} makes these values available for
   11475 subsequent use in expressions as values of the convenience variables
   11476 @code{$_} and @code{$__}.  After an @code{x} command, the last address
   11477 examined is available for use in expressions in the convenience variable
   11478 @code{$_}.  The contents of that address, as examined, are available in
   11479 the convenience variable @code{$__}.
   11480 
   11481 If the @code{x} command has a repeat count, the address and contents saved
   11482 are from the last memory unit printed; this is not the same as the last
   11483 address printed if several units were printed on the last line of output.
   11484 
   11485 @anchor{addressable memory unit}
   11486 @cindex addressable memory unit
   11487 Most targets have an addressable memory unit size of 8 bits.  This means
   11488 that to each memory address are associated 8 bits of data.  Some
   11489 targets, however, have other addressable memory unit sizes.
   11490 Within @value{GDBN} and this document, the term
   11491 @dfn{addressable memory unit} (or @dfn{memory unit} for short) is used
   11492 when explicitly referring to a chunk of data of that size.  The word
   11493 @dfn{byte} is used to refer to a chunk of data of 8 bits, regardless of
   11494 the addressable memory unit size of the target.  For most systems,
   11495 addressable memory unit is a synonym of byte.
   11496 
   11497 @cindex remote memory comparison
   11498 @cindex target memory comparison
   11499 @cindex verify remote memory image
   11500 @cindex verify target memory image
   11501 When you are debugging a program running on a remote target machine
   11502 (@pxref{Remote Debugging}), you may wish to verify the program's image
   11503 in the remote machine's memory against the executable file you
   11504 downloaded to the target.  Or, on any target, you may want to check
   11505 whether the program has corrupted its own read-only sections.  The
   11506 @code{compare-sections} command is provided for such situations.
   11507 
   11508 @table @code
   11509 @kindex compare-sections
   11510 @item compare-sections @r{[}@var{section-name}@r{|}@code{-r}@r{]}
   11511 Compare the data of a loadable section @var{section-name} in the
   11512 executable file of the program being debugged with the same section in
   11513 the target machine's memory, and report any mismatches.  With no
   11514 arguments, compares all loadable sections.  With an argument of
   11515 @code{-r}, compares all loadable read-only sections.
   11516 
   11517 Note: for remote targets, this command can be accelerated if the
   11518 target supports computing the CRC checksum of a block of memory
   11519 (@pxref{qCRC packet}).
   11520 @end table
   11521 
   11522 @node Memory Tagging
   11523 @section Memory Tagging
   11524 
   11525 Memory tagging is a memory protection technology that uses a pair of tags to
   11526 validate memory accesses through pointers.  The tags are integer values
   11527 usually comprised of a few bits, depending on the architecture.
   11528 
   11529 There are two types of tags that are used in this setup: logical and
   11530 allocation.  A logical tag is stored in the pointers themselves, usually at the
   11531 higher bits of the pointers.  An allocation tag is the tag associated
   11532 with particular ranges of memory in the physical address space, against which
   11533 the logical tags from pointers are compared.
   11534 
   11535 The pointer tag (logical tag) must match the memory tag (allocation tag)
   11536 for the memory access to be valid.  If the logical tag does not match the
   11537 allocation tag, that will raise a memory violation.
   11538 
   11539 Allocation tags cover multiple contiguous bytes of physical memory.  This
   11540 range of bytes is called a memory tag granule and is architecture-specific.
   11541 For example,  AArch64 has a tag granule of 16 bytes, meaning each allocation
   11542 tag spans 16 bytes of memory.
   11543 
   11544 If the underlying architecture supports memory tagging, like AArch64 MTE
   11545 or SPARC ADI do,  @value{GDBN} can make use of it to validate pointers
   11546 against memory allocation tags.
   11547 
   11548 The @code{print} (@pxref{Data}) and @code{x} (@pxref{Memory}) commands will
   11549 display tag information when appropriate, and a command prefix of
   11550 @code{memory-tag} gives access to the various memory tagging commands.
   11551 
   11552 The @code{memory-tag} commands are the following:
   11553 
   11554 @table @code
   11555 @kindex memory-tag print-logical-tag
   11556 @item memory-tag print-logical-tag @var{pointer_expression}
   11557 Print the logical tag stored in @var{pointer_expression}.
   11558 @kindex memory-tag with-logical-tag
   11559 @item memory-tag with-logical-tag @var{pointer_expression} @var{tag_bytes}
   11560 Print the pointer given by @var{pointer_expression}, augmented with a logical
   11561 tag of @var{tag_bytes}.
   11562 @kindex memory-tag print-allocation-tag
   11563 @item memory-tag print-allocation-tag @var{address_expression}
   11564 Print the allocation tag associated with the memory address given by
   11565 @var{address_expression}.
   11566 @kindex memory-tag setatag
   11567 @item memory-tag setatag @var{starting_address} @var{length} @var{tag_bytes}
   11568 Set the allocation tag(s) for memory range @r{[}@var{starting_address},
   11569 @var{starting_address} + @var{length}@r{)} to @var{tag_bytes}.
   11570 @kindex memory-tag check
   11571 @item memory-tag check @var{pointer_expression}
   11572 Check if the logical tag in the pointer given by @var{pointer_expression}
   11573 matches the allocation tag for the memory referenced by the pointer.
   11574 
   11575 This essentially emulates the hardware validation that is done when tagged
   11576 memory is accessed through a pointer, but does not cause a memory fault as
   11577 it would during hardware validation.
   11578 
   11579 It can be used to inspect potential memory tagging violations in the running
   11580 process, before any faults get triggered.
   11581 @end table
   11582 
   11583 @node Auto Display
   11584 @section Automatic Display
   11585 @cindex automatic display
   11586 @cindex display of expressions
   11587 
   11588 If you find that you want to print the value of an expression frequently
   11589 (to see how it changes), you might want to add it to the @dfn{automatic
   11590 display list} so that @value{GDBN} prints its value each time your program stops.
   11591 Each expression added to the list is given a number to identify it;
   11592 to remove an expression from the list, you specify that number.
   11593 The automatic display looks like this:
   11594 
   11595 @smallexample
   11596 2: foo = 38
   11597 3: bar[5] = (struct hack *) 0x3804
   11598 @end smallexample
   11599 
   11600 @noindent
   11601 This display shows item numbers, expressions and their current values.  As with
   11602 displays you request manually using @code{x} or @code{print}, you can
   11603 specify the output format you prefer; in fact, @code{display} decides
   11604 whether to use @code{print} or @code{x} depending your format
   11605 specification---it uses @code{x} if you specify either the @samp{i}
   11606 or @samp{s} format, or a unit size; otherwise it uses @code{print}.
   11607 
   11608 @table @code
   11609 @kindex display
   11610 @item display @var{expr}
   11611 Add the expression @var{expr} to the list of expressions to display
   11612 each time your program stops.  @xref{Expressions, ,Expressions}.
   11613 
   11614 @code{display} does not repeat if you press @key{RET} again after using it.
   11615 
   11616 @item display/@var{fmt} @var{expr}
   11617 For @var{fmt} specifying only a display format and not a size or
   11618 count, add the expression @var{expr} to the auto-display list but
   11619 arrange to display it each time in the specified format @var{fmt}.
   11620 @xref{Output Formats,,Output Formats}.
   11621 
   11622 @item display/@var{fmt} @var{addr}
   11623 For @var{fmt} @samp{i} or @samp{s}, or including a unit-size or a
   11624 number of units, add the expression @var{addr} as a memory address to
   11625 be examined each time your program stops.  Examining means in effect
   11626 doing @samp{x/@var{fmt} @var{addr}}.  @xref{Memory, ,Examining Memory}.
   11627 @end table
   11628 
   11629 For example, @samp{display/i $pc} can be helpful, to see the machine
   11630 instruction about to be executed each time execution stops (@samp{$pc}
   11631 is a common name for the program counter; @pxref{Registers, ,Registers}).
   11632 
   11633 @table @code
   11634 @kindex delete display
   11635 @kindex undisplay
   11636 @item undisplay @var{dnums}@dots{}
   11637 @itemx delete display @var{dnums}@dots{}
   11638 Remove items from the list of expressions to display.  Specify the
   11639 numbers of the displays that you want affected with the command
   11640 argument @var{dnums}.  It can be a single display number, one of the
   11641 numbers shown in the first field of the @samp{info display} display;
   11642 or it could be a range of display numbers, as in @code{2-4}.
   11643 
   11644 @code{undisplay} does not repeat if you press @key{RET} after using it.
   11645 (Otherwise you would just get the error @samp{No display number @dots{}}.)
   11646 
   11647 @kindex disable display
   11648 @item disable display @var{dnums}@dots{}
   11649 Disable the display of item numbers @var{dnums}.  A disabled display
   11650 item is not printed automatically, but is not forgotten.  It may be
   11651 enabled again later.  Specify the numbers of the displays that you
   11652 want affected with the command argument @var{dnums}.  It can be a
   11653 single display number, one of the numbers shown in the first field of
   11654 the @samp{info display} display; or it could be a range of display
   11655 numbers, as in @code{2-4}.
   11656 
   11657 @kindex enable display
   11658 @item enable display @var{dnums}@dots{}
   11659 Enable display of item numbers @var{dnums}.  It becomes effective once
   11660 again in auto display of its expression, until you specify otherwise.
   11661 Specify the numbers of the displays that you want affected with the
   11662 command argument @var{dnums}.  It can be a single display number, one
   11663 of the numbers shown in the first field of the @samp{info display}
   11664 display; or it could be a range of display numbers, as in @code{2-4}.
   11665 
   11666 @item display
   11667 Display the current values of the expressions on the list, just as is
   11668 done when your program stops.
   11669 
   11670 @kindex info display
   11671 @item info display
   11672 Print the list of expressions previously set up to display
   11673 automatically, each one with its item number, but without showing the
   11674 values.  This includes disabled expressions, which are marked as such.
   11675 It also includes expressions which would not be displayed right now
   11676 because they refer to automatic variables not currently available.
   11677 @end table
   11678 
   11679 @cindex display disabled out of scope
   11680 If a display expression refers to local variables, then it does not make
   11681 sense outside the lexical context for which it was set up.  Such an
   11682 expression is disabled when execution enters a context where one of its
   11683 variables is not defined.  For example, if you give the command
   11684 @code{display last_char} while inside a function with an argument
   11685 @code{last_char}, @value{GDBN} displays this argument while your program
   11686 continues to stop inside that function.  When it stops elsewhere---where
   11687 there is no variable @code{last_char}---the display is disabled
   11688 automatically.  The next time your program stops where @code{last_char}
   11689 is meaningful, you can enable the display expression once again.
   11690 
   11691 @node Print Settings
   11692 @section Print Settings
   11693 
   11694 @cindex format options
   11695 @cindex print settings
   11696 @value{GDBN} provides the following ways to control how arrays, structures,
   11697 and symbols are printed.
   11698 
   11699 @noindent
   11700 These settings are useful for debugging programs in any language:
   11701 
   11702 @table @code
   11703 @kindex set print
   11704 @anchor{set print address}
   11705 @item set print address
   11706 @itemx set print address on
   11707 @cindex print/don't print memory addresses
   11708 @value{GDBN} prints memory addresses showing the location of stack
   11709 traces, structure values, pointer values, breakpoints, and so forth,
   11710 even when it also displays the contents of those addresses.  The default
   11711 is @code{on}.  For example, this is what a stack frame display looks like with
   11712 @code{set print address on}:
   11713 
   11714 @smallexample
   11715 @group
   11716 (@value{GDBP}) f
   11717 #0  set_quotes (lq=0x34c78 "<<", rq=0x34c88 ">>")
   11718     at input.c:530
   11719 530         if (lquote != def_lquote)
   11720 @end group
   11721 @end smallexample
   11722 
   11723 @item set print address off
   11724 Do not print addresses when displaying their contents.  For example,
   11725 this is the same stack frame displayed with @code{set print address off}:
   11726 
   11727 @smallexample
   11728 @group
   11729 (@value{GDBP}) set print addr off
   11730 (@value{GDBP}) f
   11731 #0  set_quotes (lq="<<", rq=">>") at input.c:530
   11732 530         if (lquote != def_lquote)
   11733 @end group
   11734 @end smallexample
   11735 
   11736 You can use @samp{set print address off} to eliminate all machine
   11737 dependent displays from the @value{GDBN} interface.  For example, with
   11738 @code{print address off}, you should get the same text for backtraces on
   11739 all machines---whether or not they involve pointer arguments.
   11740 
   11741 @kindex show print
   11742 @item show print address
   11743 Show whether or not addresses are to be printed.
   11744 @end table
   11745 
   11746 When @value{GDBN} prints a symbolic address, it normally prints the
   11747 closest earlier symbol plus an offset.  If that symbol does not uniquely
   11748 identify the address (for example, it is a name whose scope is a single
   11749 source file), you may need to clarify.  One way to do this is with
   11750 @code{info line}, for example @samp{info line *0x4537}.  Alternately,
   11751 you can set @value{GDBN} to print the source file and line number when
   11752 it prints a symbolic address:
   11753 
   11754 @table @code
   11755 @item set print symbol-filename on
   11756 @cindex source file and line of a symbol
   11757 @cindex symbol, source file and line
   11758 Tell @value{GDBN} to print the source file name and line number of a
   11759 symbol in the symbolic form of an address.
   11760 
   11761 @item set print symbol-filename off
   11762 Do not print source file name and line number of a symbol.  This is the
   11763 default.
   11764 
   11765 @item show print symbol-filename
   11766 Show whether or not @value{GDBN} will print the source file name and
   11767 line number of a symbol in the symbolic form of an address.
   11768 @end table
   11769 
   11770 Another situation where it is helpful to show symbol filenames and line
   11771 numbers is when disassembling code; @value{GDBN} shows you the line
   11772 number and source file that corresponds to each instruction.
   11773 
   11774 Also, you may wish to see the symbolic form only if the address being
   11775 printed is reasonably close to the closest earlier symbol:
   11776 
   11777 @table @code
   11778 @item set print max-symbolic-offset @var{max-offset}
   11779 @itemx set print max-symbolic-offset unlimited
   11780 @cindex maximum value for offset of closest symbol
   11781 Tell @value{GDBN} to only display the symbolic form of an address if the
   11782 offset between the closest earlier symbol and the address is less than
   11783 @var{max-offset}.  The default is @code{unlimited}, which tells @value{GDBN}
   11784 to always print the symbolic form of an address if any symbol precedes
   11785 it.  Zero is equivalent to @code{unlimited}.
   11786 
   11787 @item show print max-symbolic-offset
   11788 Ask how large the maximum offset is that @value{GDBN} prints in a
   11789 symbolic address.
   11790 @end table
   11791 
   11792 @cindex wild pointer, interpreting
   11793 @cindex pointer, finding referent
   11794 If you have a pointer and you are not sure where it points, try
   11795 @samp{set print symbol-filename on}.  Then you can determine the name
   11796 and source file location of the variable where it points, using
   11797 @samp{p/a @var{pointer}}.  This interprets the address in symbolic form.
   11798 For example, here @value{GDBN} shows that a variable @code{ptt} points
   11799 at another variable @code{t}, defined in @file{hi2.c}:
   11800 
   11801 @smallexample
   11802 (@value{GDBP}) set print symbol-filename on
   11803 (@value{GDBP}) p/a ptt
   11804 $4 = 0xe008 <t in hi2.c>
   11805 @end smallexample
   11806 
   11807 @quotation
   11808 @emph{Warning:} For pointers that point to a local variable, @samp{p/a}
   11809 does not show the symbol name and filename of the referent, even with
   11810 the appropriate @code{set print} options turned on.
   11811 @end quotation
   11812 
   11813 You can also enable @samp{/a}-like formatting all the time using
   11814 @samp{set print symbol on}:
   11815 
   11816 @anchor{set print symbol}
   11817 @table @code
   11818 @item set print symbol on
   11819 Tell @value{GDBN} to print the symbol corresponding to an address, if
   11820 one exists.
   11821 
   11822 @item set print symbol off
   11823 Tell @value{GDBN} not to print the symbol corresponding to an
   11824 address.  In this mode, @value{GDBN} will still print the symbol
   11825 corresponding to pointers to functions.  This is the default.
   11826 
   11827 @item show print symbol
   11828 Show whether @value{GDBN} will display the symbol corresponding to an
   11829 address.
   11830 @end table
   11831 
   11832 Other settings control how different kinds of objects are printed:
   11833 
   11834 @table @code
   11835 @anchor{set print array}
   11836 @item set print array
   11837 @itemx set print array on
   11838 @cindex pretty print arrays
   11839 Pretty print arrays.  This format is more convenient to read,
   11840 but uses more space.  The default is off.
   11841 
   11842 @item set print array off
   11843 Return to compressed format for arrays.
   11844 
   11845 @item show print array
   11846 Show whether compressed or pretty format is selected for displaying
   11847 arrays.
   11848 
   11849 @cindex print array indexes
   11850 @anchor{set print array-indexes}
   11851 @item set print array-indexes
   11852 @itemx set print array-indexes on
   11853 Print the index of each element when displaying arrays.  May be more
   11854 convenient to locate a given element in the array or quickly find the
   11855 index of a given element in that printed array.  The default is off.
   11856 
   11857 @item set print array-indexes off
   11858 Stop printing element indexes when displaying arrays.
   11859 
   11860 @item show print array-indexes
   11861 Show whether the index of each element is printed when displaying
   11862 arrays.
   11863 
   11864 @anchor{set print nibbles}
   11865 @item set print nibbles
   11866 @itemx set print nibbles on
   11867 @cindex print binary values in groups of four bits
   11868 Print binary values in groups of four bits, known as @dfn{nibbles},
   11869 when using the print command of @value{GDBN} with the option @samp{/t}.
   11870 For example, this is what it looks like with @code{set print nibbles on}:
   11871 
   11872 @smallexample
   11873 @group
   11874 (@value{GDBP}) print val_flags
   11875 $1 = 1230
   11876 (@value{GDBP}) print/t val_flags
   11877 $2 = 0100 1100 1110
   11878 @end group
   11879 @end smallexample
   11880 
   11881 @item set print nibbles off
   11882 Don't printing binary values in groups.  This is the default.
   11883 
   11884 @item show print nibbles
   11885 Show whether to print binary values in groups of four bits.
   11886 
   11887 @anchor{set print characters}
   11888 @item set print characters @var{number-of-characters}
   11889 @itemx set print characters elements
   11890 @itemx set print characters unlimited
   11891 @cindex number of string characters to print
   11892 @cindex limit on number of printed string characters
   11893 Set a limit on how many characters of a string @value{GDBN} will print.
   11894 If @value{GDBN} is printing a large string, it stops printing after it
   11895 has printed the number of characters set by the @code{set print
   11896 characters} command.  This equally applies to multi-byte and wide
   11897 character strings, that is for strings whose character type is
   11898 @code{wchar_t}, @code{char16_t}, or @code{char32_t} it is the number of
   11899 actual characters rather than underlying bytes the encoding uses that
   11900 this setting controls.
   11901 Setting @var{number-of-characters} to @code{elements} means that the
   11902 limit on the number of characters to print follows one for array
   11903 elements; see @ref{set print elements}.
   11904 Setting @var{number-of-characters} to @code{unlimited} means that the
   11905 number of characters to print is unlimited.
   11906 When @value{GDBN} starts, this limit is set to @code{elements}.
   11907 
   11908 @item show print characters
   11909 Display the number of characters of a large string that @value{GDBN}
   11910 will print.
   11911 
   11912 @anchor{set print elements}
   11913 @item set print elements @var{number-of-elements}
   11914 @itemx set print elements unlimited
   11915 @cindex number of array elements to print
   11916 @cindex limit on number of printed array elements
   11917 Set a limit on how many elements of an array @value{GDBN} will print.
   11918 If @value{GDBN} is printing a large array, it stops printing after it has
   11919 printed the number of elements set by the @code{set print elements} command.
   11920 By default this limit also applies to the display of strings; see
   11921 @ref{set print characters}.
   11922 When @value{GDBN} starts, this limit is set to 200.
   11923 Setting @var{number-of-elements} to @code{unlimited} or zero means
   11924 that the number of elements to print is unlimited.
   11925 
   11926 When printing very large arrays, whose size is greater than
   11927 @code{max-value-size} (@pxref{set max-value-size,,max-value-size}),
   11928 if the @code{print elements} is set such that the size of the elements
   11929 being printed is less than or equal to @code{max-value-size}, then
   11930 @value{GDBN} will print the array (up to the @code{print elements} limit),
   11931 and only @code{max-value-size} worth of data will be added into the value
   11932 history (@pxref{Value History, ,Value History}).
   11933 
   11934 @item show print elements
   11935 Display the number of elements of a large array that @value{GDBN} will print.
   11936 
   11937 @anchor{set print frame-arguments}
   11938 @item set print frame-arguments @var{value}
   11939 @kindex set print frame-arguments
   11940 @cindex printing frame argument values
   11941 @cindex print all frame argument values
   11942 @cindex print frame argument values for scalars only
   11943 @cindex do not print frame arguments
   11944 This command allows to control how the values of arguments are printed
   11945 when the debugger prints a frame (@pxref{Frames}).  The possible
   11946 values are:
   11947 
   11948 @table @code
   11949 @item all
   11950 The values of all arguments are printed.
   11951 
   11952 @item scalars
   11953 Print the value of an argument only if it is a scalar.  The value of more
   11954 complex arguments such as arrays, structures, unions, etc, is replaced
   11955 by @code{@dots{}}.  This is the default.  Here is an example where
   11956 only scalar arguments are shown:
   11957 
   11958 @smallexample
   11959 #1  0x08048361 in call_me (i=3, s=@dots{}, ss=0xbf8d508c, u=@dots{}, e=green)
   11960   at frame-args.c:23
   11961 @end smallexample
   11962 
   11963 @item none
   11964 None of the argument values are printed.  Instead, the value of each argument
   11965 is replaced by @code{@dots{}}.  In this case, the example above now becomes:
   11966 
   11967 @smallexample
   11968 #1  0x08048361 in call_me (i=@dots{}, s=@dots{}, ss=@dots{}, u=@dots{}, e=@dots{})
   11969   at frame-args.c:23
   11970 @end smallexample
   11971 
   11972 @item presence
   11973 Only the presence of arguments is indicated by @code{@dots{}}.
   11974 The @code{@dots{}} are not printed for function without any arguments.
   11975 None of the argument names and values are printed.
   11976 In this case, the example above now becomes:
   11977 
   11978 @smallexample
   11979 #1  0x08048361 in call_me (@dots{}) at frame-args.c:23
   11980 @end smallexample
   11981 
   11982 @end table
   11983 
   11984 By default, only scalar arguments are printed.  This command can be used
   11985 to configure the debugger to print the value of all arguments, regardless
   11986 of their type.  However, it is often advantageous to not print the value
   11987 of more complex parameters.  For instance, it reduces the amount of
   11988 information printed in each frame, making the backtrace more readable.
   11989 Also, it improves performance when displaying Ada frames, because
   11990 the computation of large arguments can sometimes be CPU-intensive,
   11991 especially in large applications.  Setting @code{print frame-arguments}
   11992 to @code{scalars} (the default), @code{none} or @code{presence} avoids
   11993 this computation, thus speeding up the display of each Ada frame.
   11994 
   11995 @item show print frame-arguments
   11996 Show how the value of arguments should be displayed when printing a frame.
   11997 
   11998 @anchor{set print raw-frame-arguments}
   11999 @item set print raw-frame-arguments on
   12000 Print frame arguments in raw, non pretty-printed, form.
   12001 
   12002 @item set print raw-frame-arguments off
   12003 Print frame arguments in pretty-printed form, if there is a pretty-printer
   12004 for the value (@pxref{Pretty Printing}),
   12005 otherwise print the value in raw form.
   12006 This is the default.
   12007 
   12008 @item show print raw-frame-arguments
   12009 Show whether to print frame arguments in raw form.
   12010 
   12011 @anchor{set print entry-values}
   12012 @item set print entry-values @var{value}
   12013 @kindex set print entry-values
   12014 Set printing of frame argument values at function entry.  In some cases
   12015 @value{GDBN} can determine the value of function argument which was passed by
   12016 the function caller, even if the value was modified inside the called function
   12017 and therefore is different.  With optimized code, the current value could be
   12018 unavailable, but the entry value may still be known.
   12019 
   12020 The default value is @code{default} (see below for its description).  Older
   12021 @value{GDBN} behaved as with the setting @code{no}.  Compilers not supporting
   12022 this feature will behave in the @code{default} setting the same way as with the
   12023 @code{no} setting.
   12024 
   12025 This functionality is currently supported only by DWARF 2 debugging format and
   12026 the compiler has to produce @samp{DW_TAG_call_site} tags.  With
   12027 @value{NGCC}, you need to specify @option{-O -g} during compilation, to get
   12028 this information.
   12029 
   12030 The @var{value} parameter can be one of the following:
   12031 
   12032 @table @code
   12033 @item no
   12034 Print only actual parameter values, never print values from function entry
   12035 point.
   12036 @smallexample
   12037 #0  equal (val=5)
   12038 #0  different (val=6)
   12039 #0  lost (val=<optimized out>)
   12040 #0  born (val=10)
   12041 #0  invalid (val=<optimized out>)
   12042 @end smallexample
   12043 
   12044 @item only
   12045 Print only parameter values from function entry point.  The actual parameter
   12046 values are never printed.
   12047 @smallexample
   12048 #0  equal (val@@entry=5)
   12049 #0  different (val@@entry=5)
   12050 #0  lost (val@@entry=5)
   12051 #0  born (val@@entry=<optimized out>)
   12052 #0  invalid (val@@entry=<optimized out>)
   12053 @end smallexample
   12054 
   12055 @item preferred
   12056 Print only parameter values from function entry point.  If value from function
   12057 entry point is not known while the actual value is known, print the actual
   12058 value for such parameter.
   12059 @smallexample
   12060 #0  equal (val@@entry=5)
   12061 #0  different (val@@entry=5)
   12062 #0  lost (val@@entry=5)
   12063 #0  born (val=10)
   12064 #0  invalid (val@@entry=<optimized out>)
   12065 @end smallexample
   12066 
   12067 @item if-needed
   12068 Print actual parameter values.  If actual parameter value is not known while
   12069 value from function entry point is known, print the entry point value for such
   12070 parameter.
   12071 @smallexample
   12072 #0  equal (val=5)
   12073 #0  different (val=6)
   12074 #0  lost (val@@entry=5)
   12075 #0  born (val=10)
   12076 #0  invalid (val=<optimized out>)
   12077 @end smallexample
   12078 
   12079 @item both
   12080 Always print both the actual parameter value and its value from function entry
   12081 point, even if values of one or both are not available due to compiler
   12082 optimizations.
   12083 @smallexample
   12084 #0  equal (val=5, val@@entry=5)
   12085 #0  different (val=6, val@@entry=5)
   12086 #0  lost (val=<optimized out>, val@@entry=5)
   12087 #0  born (val=10, val@@entry=<optimized out>)
   12088 #0  invalid (val=<optimized out>, val@@entry=<optimized out>)
   12089 @end smallexample
   12090 
   12091 @item compact
   12092 Print the actual parameter value if it is known and also its value from
   12093 function entry point if it is known.  If neither is known, print for the actual
   12094 value @code{<optimized out>}.  If not in MI mode (@pxref{GDB/MI}) and if both
   12095 values are known and identical, print the shortened
   12096 @code{param=param@@entry=VALUE} notation.
   12097 @smallexample
   12098 #0  equal (val=val@@entry=5)
   12099 #0  different (val=6, val@@entry=5)
   12100 #0  lost (val@@entry=5)
   12101 #0  born (val=10)
   12102 #0  invalid (val=<optimized out>)
   12103 @end smallexample
   12104 
   12105 @item default
   12106 Always print the actual parameter value.  Print also its value from function
   12107 entry point, but only if it is known.  If not in MI mode (@pxref{GDB/MI}) and
   12108 if both values are known and identical, print the shortened
   12109 @code{param=param@@entry=VALUE} notation.
   12110 @smallexample
   12111 #0  equal (val=val@@entry=5)
   12112 #0  different (val=6, val@@entry=5)
   12113 #0  lost (val=<optimized out>, val@@entry=5)
   12114 #0  born (val=10)
   12115 #0  invalid (val=<optimized out>)
   12116 @end smallexample
   12117 @end table
   12118 
   12119 For analysis messages on possible failures of frame argument values at function
   12120 entry resolution see @ref{set debug entry-values}.
   12121 
   12122 @item show print entry-values
   12123 Show the method being used for printing of frame argument values at function
   12124 entry.
   12125 
   12126 @anchor{set print frame-info}
   12127 @item set print frame-info @var{value}
   12128 @kindex set print frame-info
   12129 @cindex printing frame information
   12130 @cindex frame information, printing
   12131 This command allows to control the information printed when
   12132 the debugger prints a frame.  See @ref{Frames}, @ref{Backtrace},
   12133 for a general explanation about frames and frame information.
   12134 Note that some other settings (such as @code{set print frame-arguments}
   12135 and @code{set print address}) are also influencing if and how some frame
   12136 information is displayed.  In particular, the frame program counter is never
   12137 printed if @code{set print address} is off.
   12138 
   12139 The possible values for @code{set print frame-info} are:
   12140 @table @code
   12141 @item short-location
   12142 Print the frame level, the program counter (if not at the
   12143 beginning of the location source line), the function, the function
   12144 arguments.
   12145 @item location
   12146 Same as @code{short-location} but also print the source file and source line
   12147 number.
   12148 @item location-and-address
   12149 Same as @code{location} but print the program counter even if located at the
   12150 beginning of the location source line.
   12151 @item source-line
   12152 Print the program counter (if not at the beginning of the location
   12153 source line), the line number and the source line.
   12154 @item source-and-location
   12155 Print what @code{location} and @code{source-line} are printing.
   12156 @item auto
   12157 The information printed for a frame is decided automatically
   12158 by the @value{GDBN} command that prints a frame.
   12159 For example, @code{frame} prints the information printed by
   12160 @code{source-and-location} while @code{stepi} will switch between
   12161 @code{source-line} and @code{source-and-location} depending on the program
   12162 counter.
   12163 The default value is @code{auto}.
   12164 @end table
   12165 
   12166 @anchor{set print repeats}
   12167 @item set print repeats @var{number-of-repeats}
   12168 @itemx set print repeats unlimited
   12169 @cindex repeated array elements
   12170 Set the threshold for suppressing display of repeated array
   12171 elements.  When the number of consecutive identical elements of an
   12172 array exceeds the threshold, @value{GDBN} prints the string
   12173 @code{"<repeats @var{n} times>"}, where @var{n} is the number of
   12174 identical repetitions, instead of displaying the identical elements
   12175 themselves.  Setting the threshold to @code{unlimited} or zero will
   12176 cause all elements to be individually printed.  The default threshold
   12177 is 10.
   12178 
   12179 @item show print repeats
   12180 Display the current threshold for printing repeated identical
   12181 elements.
   12182 
   12183 @anchor{set print max-depth}
   12184 @item set print max-depth @var{depth}
   12185 @item set print max-depth unlimited
   12186 @cindex printing nested structures
   12187 Set the threshold after which nested structures are replaced with
   12188 ellipsis, this can make visualising deeply nested structures easier.
   12189 
   12190 For example, given this C code
   12191 
   12192 @smallexample
   12193 typedef struct s1 @{ int a; @} s1;
   12194 typedef struct s2 @{ s1 b; @} s2;
   12195 typedef struct s3 @{ s2 c; @} s3;
   12196 typedef struct s4 @{ s3 d; @} s4;
   12197 
   12198 s4 var = @{ @{ @{ @{ 3 @} @} @} @};
   12199 @end smallexample
   12200 
   12201 The following table shows how different values of @var{depth} will
   12202 effect how @code{var} is printed by @value{GDBN}:
   12203 
   12204 @multitable @columnfractions .3 .7
   12205 @headitem @var{depth} setting @tab Result of @samp{p var}
   12206 @item unlimited
   12207 @tab @code{$1 = @{d = @{c = @{b = @{a = 3@}@}@}@}}
   12208 @item @code{0}
   12209 @tab @code{$1 = @{...@}}
   12210 @item @code{1}
   12211 @tab @code{$1 = @{d = @{...@}@}}
   12212 @item @code{2}
   12213 @tab @code{$1 = @{d = @{c = @{...@}@}@}}
   12214 @item @code{3}
   12215 @tab @code{$1 = @{d = @{c = @{b = @{...@}@}@}@}}
   12216 @item @code{4}
   12217 @tab @code{$1 = @{d = @{c = @{b = @{a = 3@}@}@}@}}
   12218 @end multitable
   12219 
   12220 To see the contents of structures that have been hidden the user can
   12221 either increase the print max-depth, or they can print the elements of
   12222 the structure that are visible, for example
   12223 
   12224 @smallexample
   12225 (@value{GDBP}) set print max-depth 2
   12226 (@value{GDBP}) p var
   12227 $1 = @{d = @{c = @{...@}@}@}
   12228 (@value{GDBP}) p var.d
   12229 $2 = @{c = @{b = @{...@}@}@}
   12230 (@value{GDBP}) p var.d.c
   12231 $3 = @{b = @{a = 3@}@}
   12232 @end smallexample
   12233 
   12234 The pattern used to replace nested structures varies based on
   12235 language, for most languages @code{@{...@}} is used, but Fortran uses
   12236 @code{(...)}.
   12237 
   12238 @item show print max-depth
   12239 Display the current threshold after which nested structures are
   12240 replaces with ellipsis.
   12241 
   12242 @anchor{set print memory-tag-violations}
   12243 @cindex printing memory tag violation information
   12244 @item set print memory-tag-violations
   12245 @itemx set print memory-tag-violations on
   12246 Cause @value{GDBN} to display additional information about memory tag violations
   12247 when printing pointers and addresses.
   12248 
   12249 @item set print memory-tag-violations off
   12250 Stop printing memory tag violation information.
   12251 
   12252 @item show print memory-tag-violations
   12253 Show whether memory tag violation information is displayed when printing
   12254 pointers and addresses.
   12255 
   12256 @anchor{set print null-stop}
   12257 @item set print null-stop
   12258 @cindex @sc{null} elements in arrays
   12259 Cause @value{GDBN} to stop printing the characters of an array when the first
   12260 @sc{null} is encountered.  This is useful when large arrays actually
   12261 contain only short strings.
   12262 The default is off.
   12263 
   12264 @item show print null-stop
   12265 Show whether @value{GDBN} stops printing an array on the first
   12266 @sc{null} character.
   12267 
   12268 @anchor{set print pretty}
   12269 @item set print pretty on
   12270 @cindex print structures in indented form
   12271 @cindex indentation in structure display
   12272 Cause @value{GDBN} to print structures in an indented format with one member
   12273 per line, like this:
   12274 
   12275 @smallexample
   12276 @group
   12277 $1 = @{
   12278   next = 0x0,
   12279   flags = @{
   12280     sweet = 1,
   12281     sour = 1
   12282   @},
   12283   meat = 0x54 "Pork"
   12284 @}
   12285 @end group
   12286 @end smallexample
   12287 
   12288 @item set print pretty off
   12289 Cause @value{GDBN} to print structures in a compact format, like this:
   12290 
   12291 @smallexample
   12292 @group
   12293 $1 = @{next = 0x0, flags = @{sweet = 1, sour = 1@}, \
   12294 meat = 0x54 "Pork"@}
   12295 @end group
   12296 @end smallexample
   12297 
   12298 @noindent
   12299 This is the default format.
   12300 
   12301 @item show print pretty
   12302 Show which format @value{GDBN} is using to print structures.
   12303 
   12304 @anchor{set print raw-values}
   12305 @item set print raw-values on
   12306 Print values in raw form, without applying the pretty
   12307 printers for the value.
   12308 
   12309 @item set print raw-values off
   12310 Print values in pretty-printed form, if there is a pretty-printer
   12311 for the value (@pxref{Pretty Printing}),
   12312 otherwise print the value in raw form.
   12313 
   12314 The default setting is ``off''.
   12315 
   12316 @item show print raw-values
   12317 Show whether to print values in raw form.
   12318 
   12319 @item set print sevenbit-strings on
   12320 @cindex eight-bit characters in strings
   12321 @cindex octal escapes in strings
   12322 Print using only seven-bit characters; if this option is set,
   12323 @value{GDBN} displays any eight-bit characters (in strings or
   12324 character values) using the notation @code{\}@var{nnn}.  This setting is
   12325 best if you are working in English (@sc{ascii}) and you use the
   12326 high-order bit of characters as a marker or ``meta'' bit.
   12327 
   12328 @item set print sevenbit-strings off
   12329 Print full eight-bit characters.  This allows the use of more
   12330 international character sets, and is the default.
   12331 
   12332 @item show print sevenbit-strings
   12333 Show whether or not @value{GDBN} is printing only seven-bit characters.
   12334 
   12335 @anchor{set print union}
   12336 @item set print union on
   12337 @cindex unions in structures, printing
   12338 Tell @value{GDBN} to print unions which are contained in structures
   12339 and other unions.  This is the default setting.
   12340 
   12341 @item set print union off
   12342 Tell @value{GDBN} not to print unions which are contained in
   12343 structures and other unions.  @value{GDBN} will print @code{"@{...@}"}
   12344 instead.
   12345 
   12346 @item show print union
   12347 Ask @value{GDBN} whether or not it will print unions which are contained in
   12348 structures and other unions.
   12349 
   12350 For example, given the declarations
   12351 
   12352 @smallexample
   12353 typedef enum @{Tree, Bug@} Species;
   12354 typedef enum @{Big_tree, Acorn, Seedling@} Tree_forms;
   12355 typedef enum @{Caterpillar, Cocoon, Butterfly@}
   12356               Bug_forms;
   12357 
   12358 struct thing @{
   12359   Species it;
   12360   union @{
   12361     Tree_forms tree;
   12362     Bug_forms bug;
   12363   @} form;
   12364 @};
   12365 
   12366 struct thing foo = @{Tree, @{Acorn@}@};
   12367 @end smallexample
   12368 
   12369 @noindent
   12370 with @code{set print union on} in effect @samp{p foo} would print
   12371 
   12372 @smallexample
   12373 $1 = @{it = Tree, form = @{tree = Acorn, bug = Cocoon@}@}
   12374 @end smallexample
   12375 
   12376 @noindent
   12377 and with @code{set print union off} in effect it would print
   12378 
   12379 @smallexample
   12380 $1 = @{it = Tree, form = @{...@}@}
   12381 @end smallexample
   12382 
   12383 @noindent
   12384 @code{set print union} affects programs written in C-like languages
   12385 and in Pascal.
   12386 @end table
   12387 
   12388 @need 1000
   12389 @noindent
   12390 These settings are of interest when debugging C@t{++} programs:
   12391 
   12392 @table @code
   12393 @cindex demangling C@t{++} names
   12394 @item set print demangle
   12395 @itemx set print demangle on
   12396 Print C@t{++} names in their source form rather than in the encoded
   12397 (``mangled'') form passed to the assembler and linker for type-safe
   12398 linkage.  The default is on.
   12399 
   12400 @item show print demangle
   12401 Show whether C@t{++} names are printed in mangled or demangled form.
   12402 
   12403 @item set print asm-demangle
   12404 @itemx set print asm-demangle on
   12405 Print C@t{++} names in their source form rather than their mangled form, even
   12406 in assembler code printouts such as instruction disassemblies.
   12407 The default is off.
   12408 
   12409 @item show print asm-demangle
   12410 Show whether C@t{++} names in assembly listings are printed in mangled
   12411 or demangled form.
   12412 
   12413 @cindex C@t{++} symbol decoding style
   12414 @cindex symbol decoding style, C@t{++}
   12415 @kindex set demangle-style
   12416 @item set demangle-style @var{style}
   12417 Choose among several encoding schemes used by different compilers to represent
   12418 C@t{++} names.  If you omit @var{style}, you will see a list of possible
   12419 formats.  The default value is @var{auto}, which lets @value{GDBN} choose a
   12420 decoding style by inspecting your program.
   12421 
   12422 @item show demangle-style
   12423 Display the encoding style currently in use for decoding C@t{++} symbols.
   12424 
   12425 @anchor{set print object}
   12426 @item set print object
   12427 @itemx set print object on
   12428 @cindex derived type of an object, printing
   12429 @cindex display derived types
   12430 When displaying a pointer to an object, identify the @emph{actual}
   12431 (derived) type of the object rather than the @emph{declared} type, using
   12432 the virtual function table.  Note that the virtual function table is
   12433 required---this feature can only work for objects that have run-time
   12434 type identification; a single virtual method in the object's declared
   12435 type is sufficient.  Note that this setting is also taken into account when
   12436 working with variable objects via MI (@pxref{GDB/MI}).
   12437 
   12438 @item set print object off
   12439 Display only the declared type of objects, without reference to the
   12440 virtual function table.  This is the default setting.
   12441 
   12442 @item show print object
   12443 Show whether actual, or declared, object types are displayed.
   12444 
   12445 @anchor{set print static-members}
   12446 @item set print static-members
   12447 @itemx set print static-members on
   12448 @cindex static members of C@t{++} objects
   12449 Print static members when displaying a C@t{++} object.  The default is on.
   12450 
   12451 @item set print static-members off
   12452 Do not print static members when displaying a C@t{++} object.
   12453 
   12454 @item show print static-members
   12455 Show whether C@t{++} static members are printed or not.
   12456 
   12457 @item set print pascal_static-members
   12458 @itemx set print pascal_static-members on
   12459 @cindex static members of Pascal objects
   12460 @cindex Pascal objects, static members display
   12461 Print static members when displaying a Pascal object.  The default is on.
   12462 
   12463 @item set print pascal_static-members off
   12464 Do not print static members when displaying a Pascal object.
   12465 
   12466 @item show print pascal_static-members
   12467 Show whether Pascal static members are printed or not.
   12468 
   12469 @c These don't work with HP ANSI C++ yet.
   12470 @anchor{set print vtbl}
   12471 @item set print vtbl
   12472 @itemx set print vtbl on
   12473 @cindex pretty print C@t{++} virtual function tables
   12474 @cindex virtual functions (C@t{++}) display
   12475 @cindex VTBL display
   12476 Pretty print C@t{++} virtual function tables.  The default is off.
   12477 (The @code{vtbl} commands do not work on programs compiled with the HP
   12478 ANSI C@t{++} compiler (@code{aCC}).)
   12479 
   12480 @item set print vtbl off
   12481 Do not pretty print C@t{++} virtual function tables.
   12482 
   12483 @item show print vtbl
   12484 Show whether C@t{++} virtual function tables are pretty printed, or not.
   12485 @end table
   12486 
   12487 @node Pretty Printing
   12488 @section Pretty Printing
   12489 
   12490 @value{GDBN} provides a mechanism to allow pretty-printing of values using
   12491 Python code.  It greatly simplifies the display of complex objects.  This
   12492 mechanism works for both MI and the CLI.
   12493 
   12494 @menu
   12495 * Pretty-Printer Introduction::  Introduction to pretty-printers
   12496 * Pretty-Printer Example::       An example pretty-printer
   12497 * Pretty-Printer Commands::      Pretty-printer commands
   12498 @end menu
   12499 
   12500 @node Pretty-Printer Introduction
   12501 @subsection Pretty-Printer Introduction
   12502 
   12503 When @value{GDBN} prints a value, it first sees if there is a pretty-printer
   12504 registered for the value.  If there is then @value{GDBN} invokes the
   12505 pretty-printer to print the value.  Otherwise the value is printed normally.
   12506 
   12507 Pretty-printers are normally named.  This makes them easy to manage.
   12508 The @samp{info pretty-printer} command will list all the installed
   12509 pretty-printers with their names.
   12510 If a pretty-printer can handle multiple data types, then its
   12511 @dfn{subprinters} are the printers for the individual data types.
   12512 Each such subprinter has its own name.
   12513 The format of the name is @var{printer-name};@var{subprinter-name}.
   12514 
   12515 Pretty-printers are installed by @dfn{registering} them with @value{GDBN}.
   12516 Typically they are automatically loaded and registered when the corresponding
   12517 debug information is loaded, thus making them available without having to
   12518 do anything special.
   12519 
   12520 There are three places where a pretty-printer can be registered.
   12521 
   12522 @itemize @bullet
   12523 @item
   12524 Pretty-printers registered globally are available when debugging
   12525 all inferiors.
   12526 
   12527 @item
   12528 Pretty-printers registered with a program space are available only
   12529 when debugging that program.
   12530 @xref{Progspaces In Python}, for more details on program spaces in Python.
   12531 
   12532 @item
   12533 Pretty-printers registered with an objfile are loaded and unloaded
   12534 with the corresponding objfile (e.g., shared library).
   12535 @xref{Objfiles In Python}, for more details on objfiles in Python.
   12536 @end itemize
   12537 
   12538 @xref{Selecting Pretty-Printers}, for further information on how 
   12539 pretty-printers are selected,
   12540 
   12541 @xref{Writing a Pretty-Printer}, for implementing pretty printers
   12542 for new types.
   12543 
   12544 @node Pretty-Printer Example
   12545 @subsection Pretty-Printer Example
   12546 
   12547 Here is how a C@t{++} @code{std::string} looks without a pretty-printer:
   12548 
   12549 @smallexample
   12550 (@value{GDBP}) print s
   12551 $1 = @{
   12552   static npos = 4294967295, 
   12553   _M_dataplus = @{
   12554     <std::allocator<char>> = @{
   12555       <__gnu_cxx::new_allocator<char>> = @{
   12556         <No data fields>@}, <No data fields>
   12557       @},
   12558     members of std::basic_string<char, std::char_traits<char>,
   12559       std::allocator<char> >::_Alloc_hider:
   12560     _M_p = 0x804a014 "abcd"
   12561   @}
   12562 @}
   12563 @end smallexample
   12564 
   12565 With a pretty-printer for @code{std::string} only the contents are printed:
   12566 
   12567 @smallexample
   12568 (@value{GDBP}) print s
   12569 $2 = "abcd"
   12570 @end smallexample
   12571 
   12572 @node Pretty-Printer Commands
   12573 @subsection Pretty-Printer Commands
   12574 @cindex pretty-printer commands
   12575 
   12576 @table @code
   12577 @kindex info pretty-printer
   12578 @item info pretty-printer [@var{object-regexp} [@var{name-regexp}]]
   12579 Print the list of installed pretty-printers.
   12580 This includes disabled pretty-printers, which are marked as such.
   12581 
   12582 @var{object-regexp} is a regular expression matching the objects
   12583 whose pretty-printers to list.
   12584 Objects can be @code{global}, the program space's file
   12585 (@pxref{Progspaces In Python}),
   12586 and the object files within that program space (@pxref{Objfiles In Python}).
   12587 @xref{Selecting Pretty-Printers}, for details on how @value{GDBN}
   12588 looks up a printer from these three objects.
   12589 
   12590 @var{name-regexp} is a regular expression matching the name of the printers
   12591 to list.
   12592 
   12593 @kindex disable pretty-printer
   12594 @item disable pretty-printer [@var{object-regexp} [@var{name-regexp}]]
   12595 Disable pretty-printers matching @var{object-regexp} and @var{name-regexp}.
   12596 A disabled pretty-printer is not forgotten, it may be enabled again later.
   12597 
   12598 @kindex enable pretty-printer
   12599 @item enable pretty-printer [@var{object-regexp} [@var{name-regexp}]]
   12600 Enable pretty-printers matching @var{object-regexp} and @var{name-regexp}.
   12601 @end table
   12602 
   12603 Example:
   12604 
   12605 Suppose we have three pretty-printers installed: one from library1.so
   12606 named @code{foo} that prints objects of type @code{foo}, and
   12607 another from library2.so named @code{bar} that prints two types of objects,
   12608 @code{bar1} and @code{bar2}.
   12609 
   12610 @smallexample
   12611 @group
   12612 (@value{GDBP}) info pretty-printer
   12613 library1.so:
   12614   foo
   12615 library2.so:
   12616   bar
   12617     bar1
   12618     bar2
   12619 @end group
   12620 @group
   12621 (@value{GDBP}) info pretty-printer library2
   12622 library2.so:
   12623   bar
   12624     bar1
   12625     bar2
   12626 @end group
   12627 @group
   12628 (@value{GDBP}) disable pretty-printer library1
   12629 1 printer disabled
   12630 2 of 3 printers enabled
   12631 (@value{GDBP}) info pretty-printer
   12632 library1.so:
   12633   foo [disabled]
   12634 library2.so:
   12635   bar
   12636     bar1
   12637     bar2
   12638 @end group
   12639 @group
   12640 (@value{GDBP}) disable pretty-printer library2 bar;bar1
   12641 1 printer disabled
   12642 1 of 3 printers enabled
   12643 (@value{GDBP}) info pretty-printer library2
   12644 library2.so:
   12645   bar
   12646     bar1 [disabled]
   12647     bar2
   12648 @end group
   12649 @group
   12650 (@value{GDBP}) disable pretty-printer library2 bar
   12651 1 printer disabled
   12652 0 of 3 printers enabled
   12653 (@value{GDBP}) info pretty-printer
   12654 library1.so:
   12655   foo [disabled]
   12656 library2.so:
   12657   bar [disabled]
   12658     bar1 [disabled]
   12659     bar2
   12660 @end group
   12661 @end smallexample
   12662 
   12663 Note that for @code{bar} the entire printer can be disabled,
   12664 as can each individual subprinter.
   12665 
   12666 Printing values and frame arguments is done by default using
   12667 the enabled pretty printers.
   12668 
   12669 The print option @code{-raw-values} and @value{GDBN} setting
   12670 @code{set print raw-values} (@pxref{set print raw-values}) can be
   12671 used to print values without applying the enabled pretty printers.
   12672 
   12673 Similarly, the backtrace option @code{-raw-frame-arguments} and
   12674 @value{GDBN} setting @code{set print raw-frame-arguments}
   12675 (@pxref{set print raw-frame-arguments}) can be used to ignore the
   12676 enabled pretty printers when printing frame argument values.
   12677 
   12678 @node Value History
   12679 @section Value History
   12680 
   12681 @cindex value history
   12682 @cindex history of values printed by @value{GDBN}
   12683 Values printed by the @code{print} command are saved in the @value{GDBN}
   12684 @dfn{value history}.  This allows you to refer to them in other expressions.
   12685 Values are kept until the symbol table is re-read or discarded
   12686 (for example with the @code{file} or @code{symbol-file} commands).
   12687 When the symbol table changes, the value history is discarded,
   12688 since the values may contain pointers back to the types defined in the
   12689 symbol table.
   12690 
   12691 @cindex @code{$}
   12692 @cindex @code{$$}
   12693 @cindex history number
   12694 The values printed are given @dfn{history numbers} by which you can
   12695 refer to them.  These are successive integers starting with one.
   12696 @code{print} shows you the history number assigned to a value by
   12697 printing @samp{$@var{num} = } before the value; here @var{num} is the
   12698 history number.
   12699 
   12700 To refer to any previous value, use @samp{$} followed by the value's
   12701 history number.  The way @code{print} labels its output is designed to
   12702 remind you of this.  Just @code{$} refers to the most recent value in
   12703 the history, and @code{$$} refers to the value before that.
   12704 @code{$$@var{n}} refers to the @var{n}th value from the end; @code{$$2}
   12705 is the value just prior to @code{$$}, @code{$$1} is equivalent to
   12706 @code{$$}, and @code{$$0} is equivalent to @code{$}.
   12707 
   12708 For example, suppose you have just printed a pointer to a structure and
   12709 want to see the contents of the structure.  It suffices to type
   12710 
   12711 @smallexample
   12712 p *$
   12713 @end smallexample
   12714 
   12715 If you have a chain of structures where the component @code{next} points
   12716 to the next one, you can print the contents of the next one with this:
   12717 
   12718 @smallexample
   12719 p *$.next
   12720 @end smallexample
   12721 
   12722 @noindent
   12723 You can print successive links in the chain by repeating this
   12724 command---which you can do by just typing @key{RET}.
   12725 
   12726 Note that the history records values, not expressions.  If the value of
   12727 @code{x} is 4 and you type these commands:
   12728 
   12729 @smallexample
   12730 print x
   12731 set x=5
   12732 @end smallexample
   12733 
   12734 @noindent
   12735 then the value recorded in the value history by the @code{print} command
   12736 remains 4 even though the value of @code{x} has changed.
   12737 
   12738 @table @code
   12739 @kindex show values
   12740 @item show values
   12741 Print the last ten values in the value history, with their item numbers.
   12742 This is like @samp{p@ $$9} repeated ten times, except that @code{show
   12743 values} does not change the history.
   12744 
   12745 @item show values @var{n}
   12746 Print ten history values centered on history item number @var{n}.
   12747 
   12748 @item show values +
   12749 Print ten history values just after the values last printed.  If no more
   12750 values are available, @code{show values +} produces no display.
   12751 @end table
   12752 
   12753 Pressing @key{RET} to repeat @code{show values @var{n}} has exactly the
   12754 same effect as @samp{show values +}.
   12755 
   12756 @node Convenience Vars
   12757 @section Convenience Variables
   12758 
   12759 @cindex convenience variables
   12760 @cindex user-defined variables
   12761 @value{GDBN} provides @dfn{convenience variables} that you can use within
   12762 @value{GDBN} to hold on to a value and refer to it later.  These variables
   12763 exist entirely within @value{GDBN}; they are not part of your program, and
   12764 setting a convenience variable has no direct effect on further execution
   12765 of your program.  That is why you can use them freely.
   12766 
   12767 Convenience variables are prefixed with @samp{$}.  Any name preceded by
   12768 @samp{$} can be used for a convenience variable, unless it is one of
   12769 the predefined machine-specific register names (@pxref{Registers, ,Registers}).
   12770 (Value history references, in contrast, are @emph{numbers} preceded
   12771 by @samp{$}.  @xref{Value History, ,Value History}.)
   12772 
   12773 You can save a value in a convenience variable with an assignment
   12774 expression, just as you would set a variable in your program.
   12775 For example:
   12776 
   12777 @smallexample
   12778 set $foo = *object_ptr
   12779 @end smallexample
   12780 
   12781 @noindent
   12782 would save in @code{$foo} the value contained in the object pointed to by
   12783 @code{object_ptr}.
   12784 
   12785 Using a convenience variable for the first time creates it, but its
   12786 value is @code{void} until you assign a new value.  You can alter the
   12787 value with another assignment at any time.
   12788 
   12789 Convenience variables have no fixed types.  You can assign a convenience
   12790 variable any type of value, including structures and arrays, even if
   12791 that variable already has a value of a different type.  The convenience
   12792 variable, when used as an expression, has the type of its current value.
   12793 
   12794 @table @code
   12795 @kindex show convenience
   12796 @cindex show all user variables and functions
   12797 @item show convenience
   12798 Print a list of convenience variables used so far, and their values,
   12799 as well as a list of the convenience functions.
   12800 Abbreviated @code{show conv}.
   12801 
   12802 @kindex init-if-undefined
   12803 @cindex convenience variables, initializing
   12804 @item init-if-undefined $@var{variable} = @var{expression}
   12805 Set a convenience variable if it has not already been set.  This is useful
   12806 for user-defined commands that keep some state.  It is similar, in concept,
   12807 to using local static variables with initializers in C (except that
   12808 convenience variables are global).  It can also be used to allow users to
   12809 override default values used in a command script.
   12810 
   12811 If the variable is already defined then the expression is not evaluated so
   12812 any side-effects do not occur.
   12813 @end table
   12814 
   12815 One of the ways to use a convenience variable is as a counter to be
   12816 incremented or a pointer to be advanced.  For example, to print
   12817 a field from successive elements of an array of structures:
   12818 
   12819 @smallexample
   12820 set $i = 0
   12821 print bar[$i++]->contents
   12822 @end smallexample
   12823 
   12824 @noindent
   12825 Repeat that command by typing @key{RET}.
   12826 
   12827 Some convenience variables are created automatically by @value{GDBN} and given
   12828 values likely to be useful.
   12829 
   12830 @table @code
   12831 @vindex $_@r{, convenience variable}
   12832 @item $_
   12833 The variable @code{$_} is automatically set by the @code{x} command to
   12834 the last address examined (@pxref{Memory, ,Examining Memory}).  Other
   12835 commands which provide a default address for @code{x} to examine also
   12836 set @code{$_} to that address; these commands include @code{info line}
   12837 and @code{info breakpoint}.  The type of @code{$_} is @code{void *}
   12838 except when set by the @code{x} command, in which case it is a pointer
   12839 to the type of @code{$__}.
   12840 
   12841 @vindex $__@r{, convenience variable}
   12842 @item $__
   12843 The variable @code{$__} is automatically set by the @code{x} command
   12844 to the value found in the last address examined.  Its type is chosen
   12845 to match the format in which the data was printed.
   12846 
   12847 @item $_exitcode
   12848 @vindex $_exitcode@r{, convenience variable}
   12849 When the program being debugged terminates normally, @value{GDBN}
   12850 automatically sets this variable to the exit code of the program, and
   12851 resets @code{$_exitsignal} to @code{void}.
   12852 
   12853 @item $_exitsignal
   12854 @vindex $_exitsignal@r{, convenience variable}
   12855 When the program being debugged dies due to an uncaught signal,
   12856 @value{GDBN} automatically sets this variable to that signal's number,
   12857 and resets @code{$_exitcode} to @code{void}.
   12858 
   12859 To distinguish between whether the program being debugged has exited
   12860 (i.e., @code{$_exitcode} is not @code{void}) or signalled (i.e.,
   12861 @code{$_exitsignal} is not @code{void}), the convenience function
   12862 @code{$_isvoid} can be used (@pxref{Convenience Funs,, Convenience
   12863 Functions}).  For example, considering the following source code:
   12864 
   12865 @smallexample
   12866 #include <signal.h>
   12867 
   12868 int
   12869 main (int argc, char *argv[])
   12870 @{
   12871   raise (SIGALRM);
   12872   return 0;
   12873 @}
   12874 @end smallexample
   12875 
   12876 A valid way of telling whether the program being debugged has exited
   12877 or signalled would be:
   12878 
   12879 @smallexample
   12880 (@value{GDBP}) define has_exited_or_signalled
   12881 Type commands for definition of ``has_exited_or_signalled''.
   12882 End with a line saying just ``end''.
   12883 >if $_isvoid ($_exitsignal)
   12884  >echo The program has exited\n
   12885  >else
   12886  >echo The program has signalled\n
   12887  >end
   12888 >end
   12889 (@value{GDBP}) run
   12890 Starting program:
   12891 
   12892 Program terminated with signal SIGALRM, Alarm clock.
   12893 The program no longer exists.
   12894 (@value{GDBP}) has_exited_or_signalled
   12895 The program has signalled
   12896 @end smallexample
   12897 
   12898 As can be seen, @value{GDBN} correctly informs that the program being
   12899 debugged has signalled, since it calls @code{raise} and raises a
   12900 @code{SIGALRM} signal.  If the program being debugged had not called
   12901 @code{raise}, then @value{GDBN} would report a normal exit:
   12902 
   12903 @smallexample
   12904 (@value{GDBP}) has_exited_or_signalled
   12905 The program has exited
   12906 @end smallexample
   12907 
   12908 @item $_exception
   12909 The variable @code{$_exception} is set to the exception object being
   12910 thrown at an exception-related catchpoint.  @xref{Set Catchpoints}.
   12911 
   12912 @item $_ada_exception
   12913 The variable @code{$_ada_exception} is set to the address of the
   12914 exception being caught or thrown at an Ada exception-related
   12915 catchpoint.  @xref{Set Catchpoints}.
   12916 
   12917 @item $_probe_argc
   12918 @itemx $_probe_arg0@dots{}$_probe_arg11
   12919 Arguments to a static probe.  @xref{Static Probe Points}.
   12920 
   12921 @item $_sdata
   12922 @vindex $_sdata@r{, inspect, convenience variable}
   12923 The variable @code{$_sdata} contains extra collected static tracepoint
   12924 data.  @xref{Tracepoint Actions,,Tracepoint Action Lists}.  Note that
   12925 @code{$_sdata} could be empty, if not inspecting a trace buffer, or
   12926 if extra static tracepoint data has not been collected.
   12927 
   12928 @item $_siginfo
   12929 @vindex $_siginfo@r{, convenience variable}
   12930 The variable @code{$_siginfo} contains extra signal information
   12931 (@pxref{extra signal information}).  Note that @code{$_siginfo}
   12932 could be empty, if the application has not yet received any signals.
   12933 For example, it will be empty before you execute the @code{run} command.
   12934 
   12935 @item $_tlb
   12936 @vindex $_tlb@r{, convenience variable}
   12937 The variable @code{$_tlb} is automatically set when debugging
   12938 applications running on MS-Windows in native mode or connected to
   12939 gdbserver that supports the @code{qGetTIBAddr} request.
   12940 @xref{General Query Packets}.
   12941 This variable contains the address of the thread information block.
   12942 
   12943 @item $_inferior
   12944 The number of the current inferior.  @xref{Inferiors Connections and
   12945 Programs, ,Debugging Multiple Inferiors Connections and Programs}.
   12946 
   12947 @item $_thread
   12948 The thread number of the current thread.  @xref{thread numbers}.
   12949 
   12950 @item $_gthread
   12951 The global number of the current thread.  @xref{global thread numbers}.
   12952 
   12953 @item $_inferior_thread_count
   12954 The number of live threads in the current inferior.  @xref{Threads}.
   12955 
   12956 @item $_gdb_major
   12957 @itemx $_gdb_minor
   12958 @vindex $_gdb_major@r{, convenience variable}
   12959 @vindex $_gdb_minor@r{, convenience variable}
   12960 The major and minor version numbers of the running @value{GDBN}.
   12961 Development snapshots and pretest versions have their minor version
   12962 incremented by one; thus, @value{GDBN} pretest 9.11.90 will produce
   12963 the value 12 for @code{$_gdb_minor}.  These variables allow you to
   12964 write scripts that work with different versions of @value{GDBN}
   12965 without errors caused by features unavailable in some of those
   12966 versions.
   12967 
   12968 @item $_shell_exitcode
   12969 @itemx $_shell_exitsignal
   12970 @vindex $_shell_exitcode@r{, convenience variable}
   12971 @vindex $_shell_exitsignal@r{, convenience variable}
   12972 @cindex shell command, exit code
   12973 @cindex shell command, exit signal
   12974 @cindex exit status of shell commands
   12975 @value{GDBN} commands such as @code{shell} and @code{|} are launching
   12976 shell commands.  When a launched command terminates, @value{GDBN}
   12977 automatically maintains the variables @code{$_shell_exitcode}
   12978 and @code{$_shell_exitsignal} according to the exit status of the last
   12979 launched command.  These variables are set and used similarly to
   12980 the variables @code{$_exitcode} and @code{$_exitsignal}.
   12981 
   12982 @end table
   12983 
   12984 @node Convenience Funs
   12985 @section Convenience Functions
   12986 
   12987 @cindex convenience functions
   12988 @value{GDBN} also supplies some @dfn{convenience functions}.  These
   12989 have a syntax similar to convenience variables.  A convenience
   12990 function can be used in an expression just like an ordinary function;
   12991 however, a convenience function is implemented internally to
   12992 @value{GDBN}.
   12993 
   12994 These functions do not require @value{GDBN} to be configured with
   12995 @code{Python} support, which means that they are always available.
   12996 
   12997 @table @code
   12998 
   12999 @findex $_isvoid@r{, convenience function}
   13000 @item $_isvoid (@var{expr})
   13001 Return one if the expression @var{expr} is @code{void}.  Otherwise it
   13002 returns zero.
   13003 
   13004 A @code{void} expression is an expression where the type of the result
   13005 is @code{void}.  For example, you can examine a convenience variable
   13006 (see @ref{Convenience Vars,, Convenience Variables}) to check whether
   13007 it is @code{void}:
   13008 
   13009 @smallexample
   13010 (@value{GDBP}) print $_exitcode
   13011 $1 = void
   13012 (@value{GDBP}) print $_isvoid ($_exitcode)
   13013 $2 = 1
   13014 (@value{GDBP}) run
   13015 Starting program: ./a.out
   13016 [Inferior 1 (process 29572) exited normally]
   13017 (@value{GDBP}) print $_exitcode
   13018 $3 = 0
   13019 (@value{GDBP}) print $_isvoid ($_exitcode)
   13020 $4 = 0
   13021 @end smallexample
   13022 
   13023 In the example above, we used @code{$_isvoid} to check whether
   13024 @code{$_exitcode} is @code{void} before and after the execution of the
   13025 program being debugged.  Before the execution there is no exit code to
   13026 be examined, therefore @code{$_exitcode} is @code{void}.  After the
   13027 execution the program being debugged returned zero, therefore
   13028 @code{$_exitcode} is zero, which means that it is not @code{void}
   13029 anymore.
   13030 
   13031 The @code{void} expression can also be a call of a function from the
   13032 program being debugged.  For example, given the following function:
   13033 
   13034 @smallexample
   13035 void
   13036 foo (void)
   13037 @{
   13038 @}
   13039 @end smallexample
   13040 
   13041 The result of calling it inside @value{GDBN} is @code{void}:
   13042 
   13043 @smallexample
   13044 (@value{GDBP}) print foo ()
   13045 $1 = void
   13046 (@value{GDBP}) print $_isvoid (foo ())
   13047 $2 = 1
   13048 (@value{GDBP}) set $v = foo ()
   13049 (@value{GDBP}) print $v
   13050 $3 = void
   13051 (@value{GDBP}) print $_isvoid ($v)
   13052 $4 = 1
   13053 @end smallexample
   13054 
   13055 @findex $_gdb_setting_str@r{, convenience function}
   13056 @item $_gdb_setting_str (@var{setting})
   13057 Return the value of the @value{GDBN} @var{setting} as a string.
   13058 @var{setting} is any setting that can be used in a @code{set} or
   13059 @code{show} command (@pxref{Controlling GDB}).
   13060 
   13061 @smallexample
   13062 (@value{GDBP}) show print frame-arguments
   13063 Printing of non-scalar frame arguments is "scalars".
   13064 (@value{GDBP}) p $_gdb_setting_str("print frame-arguments")
   13065 $1 = "scalars"
   13066 (@value{GDBP}) p $_gdb_setting_str("height")
   13067 $2 = "30"
   13068 (@value{GDBP})
   13069 @end smallexample
   13070 
   13071 @findex $_gdb_setting@r{, convenience function}
   13072 @item $_gdb_setting (@var{setting})
   13073 Return the value of the @value{GDBN} @var{setting}.
   13074 The type of the returned value depends on the setting.
   13075 
   13076 The value type for boolean and auto boolean settings is @code{int}.
   13077 The boolean values @code{off} and @code{on} are converted to
   13078 the integer values @code{0} and @code{1}.  The value @code{auto} is
   13079 converted to the value @code{-1}.
   13080 
   13081 The value type for integer settings is either @code{unsigned int}
   13082 or @code{int}, depending on the setting.
   13083 
   13084 Some integer settings accept an @code{unlimited} value.
   13085 Depending on the setting, the @code{set} command also accepts
   13086 the value @code{0} or the value @code{@minus{}1} as a synonym for
   13087 @code{unlimited}.
   13088 For example, @code{set height unlimited} is equivalent to
   13089 @code{set height 0}.
   13090 
   13091 Some other settings that accept the @code{unlimited} value
   13092 use the value @code{0} to literally mean zero.
   13093 For example, @code{set history size 0} indicates to not
   13094 record any @value{GDBN} commands in the command history.
   13095 For such settings, @code{@minus{}1} is the synonym
   13096 for @code{unlimited}.
   13097 
   13098 See the documentation of the corresponding @code{set} command for
   13099 the numerical value equivalent to @code{unlimited}.
   13100 
   13101 The @code{$_gdb_setting} function converts the unlimited value
   13102 to a @code{0} or a @code{@minus{}1} value according to what the
   13103 @code{set} command uses.
   13104 
   13105 @smallexample
   13106 @group
   13107 (@value{GDBP}) p $_gdb_setting_str("height")
   13108 $1 = "30"
   13109 (@value{GDBP}) p $_gdb_setting("height")
   13110 $2 = 30
   13111 (@value{GDBP}) set height unlimited
   13112 (@value{GDBP}) p $_gdb_setting_str("height")
   13113 $3 = "unlimited"
   13114 (@value{GDBP}) p $_gdb_setting("height")
   13115 $4 = 0
   13116 @end group
   13117 @group
   13118 (@value{GDBP}) p $_gdb_setting_str("history size")
   13119 $5 = "unlimited"
   13120 (@value{GDBP}) p $_gdb_setting("history size")
   13121 $6 = -1
   13122 (@value{GDBP}) p $_gdb_setting_str("disassemble-next-line")
   13123 $7 = "auto"
   13124 (@value{GDBP}) p $_gdb_setting("disassemble-next-line")
   13125 $8 = -1
   13126 (@value{GDBP})
   13127 @end group
   13128 @end smallexample
   13129 
   13130 Other setting types (enum, filename, optional filename, string, string noescape)
   13131 are returned as string values.
   13132 
   13133 
   13134 @findex $_gdb_maint_setting_str@r{, convenience function}
   13135 @item $_gdb_maint_setting_str (@var{setting})
   13136 Like the @code{$_gdb_setting_str} function, but works with
   13137 @code{maintenance set} variables.
   13138 
   13139 @findex $_gdb_maint_setting@r{, convenience function}
   13140 @item $_gdb_maint_setting (@var{setting})
   13141 Like the @code{$_gdb_setting} function, but works with
   13142 @code{maintenance set} variables.
   13143 
   13144 @anchor{$_shell convenience function}
   13145 @findex $_shell@r{, convenience function}
   13146 @item $_shell (@var{command-string})
   13147 
   13148 Invoke a shell to execute @var{command-string}.  @var{command-string}
   13149 must be a string.  The shell runs on the host machine, the machine
   13150 @value{GDBN} is running on.  Returns the command's exit status.  On
   13151 Unix systems, a command which exits with a zero exit status has
   13152 succeeded, and non-zero exit status indicates failure.  When a command
   13153 terminates on a fatal signal whose number is @var{N}, @value{GDBN}
   13154 uses the value 128+@var{N} as the exit status, as is standard in Unix
   13155 shells.  Note that @var{N} is a host signal number, not a target
   13156 signal number.  If you're native debugging, they will be the same, but
   13157 if cross debugging, the host vs target signal numbers may be
   13158 completely unrelated.  Please consult your host operating system's
   13159 documentation for the mapping between host signal numbers and signal
   13160 names.  The shell to run is determined in the same way as for the
   13161 @code{shell} command.  @xref{Shell Commands, ,Shell Commands}.
   13162 
   13163 @smallexample
   13164 (@value{GDBP}) print $_shell("true")
   13165 $1 = 0
   13166 (@value{GDBP}) print $_shell("false")
   13167 $2 = 1
   13168 (@value{GDBP}) p $_shell("echo hello")
   13169 hello
   13170 $3 = 0
   13171 (@value{GDBP}) p $_shell("foobar")
   13172 bash: line 1: foobar: command not found
   13173 $4 = 127
   13174 @end smallexample
   13175 
   13176 This may also be useful in breakpoint conditions.  For example:
   13177 
   13178 @smallexample
   13179 (@value{GDBP}) break function if $_shell("some command") == 0
   13180 @end smallexample
   13181 
   13182 In this scenario, you'll want to make sure that the shell command you
   13183 run in the breakpoint condition takes the least amount of time
   13184 possible.  For example, avoid running a command that may block
   13185 indefinitely, or that sleeps for a while before exiting.  Prefer a
   13186 command or script which analyzes some state and exits immediately.
   13187 This is important because the debugged program stops for the
   13188 breakpoint every time, and then @value{GDBN} evaluates the breakpoint
   13189 condition.  If the condition is false, the program is re-resumed
   13190 transparently, without informing you of the stop.  A quick shell
   13191 command thus avoids significantly slowing down the debugged program
   13192 unnecessarily.
   13193 
   13194 Note: unlike the @code{shell} command, the @code{$_shell} convenience
   13195 function does not affect the @code{$_shell_exitcode} and
   13196 @code{$_shell_exitsignal} convenience variables.
   13197 
   13198 @end table
   13199 
   13200 The following functions require @value{GDBN} to be configured with
   13201 @code{Python} support.
   13202 
   13203 @table @code
   13204 
   13205 @findex $_memeq@r{, convenience function}
   13206 @item $_memeq(@var{buf1}, @var{buf2}, @var{length})
   13207 Returns one if the @var{length} bytes at the addresses given by
   13208 @var{buf1} and @var{buf2} are equal.
   13209 Otherwise it returns zero.
   13210 
   13211 @findex $_regex@r{, convenience function}
   13212 @item $_regex(@var{str}, @var{regex})
   13213 Returns one if the string @var{str} matches the regular expression
   13214 @var{regex}.  Otherwise it returns zero.
   13215 The syntax of the regular expression is that specified by @code{Python}'s
   13216 regular expression support.
   13217 
   13218 @findex $_streq@r{, convenience function}
   13219 @item $_streq(@var{str1}, @var{str2})
   13220 Returns one if the strings @var{str1} and @var{str2} are equal.
   13221 Otherwise it returns zero.
   13222 
   13223 @findex $_strlen@r{, convenience function}
   13224 @item $_strlen(@var{str})
   13225 Returns the length of string @var{str}.
   13226 
   13227 @findex $_caller_is@r{, convenience function}
   13228 @item $_caller_is(@var{name}@r{[}, @var{number_of_frames}@r{]})
   13229 Returns one if the calling function's name is equal to @var{name}.
   13230 Otherwise it returns zero.
   13231 
   13232 If the optional argument @var{number_of_frames} is provided,
   13233 it is the number of frames up in the stack to look.
   13234 The default is 1.
   13235 
   13236 Example:
   13237 
   13238 @smallexample
   13239 (@value{GDBP}) backtrace
   13240 #0  bottom_func ()
   13241     at testsuite/gdb.python/py-caller-is.c:21
   13242 #1  0x00000000004005a0 in middle_func ()
   13243     at testsuite/gdb.python/py-caller-is.c:27
   13244 #2  0x00000000004005ab in top_func ()
   13245     at testsuite/gdb.python/py-caller-is.c:33
   13246 #3  0x00000000004005b6 in main ()
   13247     at testsuite/gdb.python/py-caller-is.c:39
   13248 (@value{GDBP}) print $_caller_is ("middle_func")
   13249 $1 = 1
   13250 (@value{GDBP}) print $_caller_is ("top_func", 2)
   13251 $1 = 1
   13252 @end smallexample
   13253 
   13254 @findex $_caller_matches@r{, convenience function}
   13255 @item $_caller_matches(@var{regexp}@r{[}, @var{number_of_frames}@r{]})
   13256 Returns one if the calling function's name matches the regular expression
   13257 @var{regexp}.  Otherwise it returns zero.
   13258 
   13259 If the optional argument @var{number_of_frames} is provided,
   13260 it is the number of frames up in the stack to look.
   13261 The default is 1.
   13262 
   13263 @findex $_any_caller_is@r{, convenience function}
   13264 @item $_any_caller_is(@var{name}@r{[}, @var{number_of_frames}@r{]})
   13265 Returns one if any calling function's name is equal to @var{name}.
   13266 Otherwise it returns zero.
   13267 
   13268 If the optional argument @var{number_of_frames} is provided,
   13269 it is the number of frames up in the stack to look.
   13270 The default is 1.
   13271 
   13272 This function differs from @code{$_caller_is} in that this function
   13273 checks all stack frames from the immediate caller to the frame specified
   13274 by @var{number_of_frames}, whereas @code{$_caller_is} only checks the
   13275 frame specified by @var{number_of_frames}.
   13276 
   13277 @findex $_any_caller_matches@r{, convenience function}
   13278 @item $_any_caller_matches(@var{regexp}@r{[}, @var{number_of_frames}@r{]})
   13279 Returns one if any calling function's name matches the regular expression
   13280 @var{regexp}.  Otherwise it returns zero.
   13281 
   13282 If the optional argument @var{number_of_frames} is provided,
   13283 it is the number of frames up in the stack to look.
   13284 The default is 1.
   13285 
   13286 This function differs from @code{$_caller_matches} in that this function
   13287 checks all stack frames from the immediate caller to the frame specified
   13288 by @var{number_of_frames}, whereas @code{$_caller_matches} only checks the
   13289 frame specified by @var{number_of_frames}.
   13290 
   13291 @findex $_as_string@r{, convenience function}
   13292 @item $_as_string(@var{value})
   13293 This convenience function is considered deprecated, and could be
   13294 removed from future versions of @value{GDBN}.  Use the @samp{%V} format
   13295 specifier instead (@pxref{%V Format Specifier}).
   13296 
   13297 Return the string representation of @var{value}.
   13298 
   13299 This function is useful to obtain the textual label (enumerator) of an
   13300 enumeration value.  For example, assuming the variable @var{node} is of
   13301 an enumerated type:
   13302 
   13303 @smallexample
   13304 (@value{GDBP}) printf "Visiting node of type %s\n", $_as_string(node)
   13305 Visiting node of type NODE_INTEGER
   13306 @end smallexample
   13307 
   13308 @findex $_cimag@r{, convenience function}
   13309 @findex $_creal@r{, convenience function}
   13310 @item $_cimag(@var{value})
   13311 @itemx $_creal(@var{value})
   13312 Return the imaginary (@code{$_cimag}) or real (@code{$_creal}) part of
   13313 the complex number @var{value}.
   13314 
   13315 The type of the imaginary or real part depends on the type of the
   13316 complex number, e.g., using @code{$_cimag} on a @code{float complex}
   13317 will return an imaginary part of type @code{float}.
   13318 
   13319 @end table
   13320 
   13321 @value{GDBN} provides the ability to list and get help on
   13322 convenience functions.
   13323 
   13324 @table @code
   13325 @item help function
   13326 @kindex help function
   13327 @cindex show all convenience functions
   13328 Print a list of all convenience functions.
   13329 @end table
   13330 
   13331 @node Registers
   13332 @section Registers
   13333 
   13334 @cindex registers
   13335 You can refer to machine register contents, in expressions, as variables
   13336 with names starting with @samp{$}.  The names of registers are different
   13337 for each machine; use @code{info registers} to see the names used on
   13338 your machine.
   13339 
   13340 @table @code
   13341 @kindex info registers
   13342 @item info registers
   13343 Print the names and values of all registers except floating-point
   13344 and vector registers (in the selected stack frame).
   13345 
   13346 @kindex info all-registers
   13347 @cindex floating point registers
   13348 @item info all-registers
   13349 Print the names and values of all registers, including floating-point
   13350 and vector registers (in the selected stack frame).
   13351 
   13352 @anchor{info_registers_reggroup}
   13353 @item info registers @var{reggroup} @dots{}
   13354 Print the name and value of the registers in each of the specified
   13355 @var{reggroup}s.  The @var{reggroup} can be any of those returned by
   13356 @code{maint print reggroups} (@pxref{Maintenance Commands}).
   13357 
   13358 @item info registers @var{regname} @dots{}
   13359 Print the @dfn{relativized} value of each specified register @var{regname}.
   13360 As discussed in detail below, register values are normally relative to
   13361 the selected stack frame.  The @var{regname} may be any register name valid on
   13362 the machine you are using, with or without the initial @samp{$}.
   13363 @end table
   13364 
   13365 @anchor{standard registers}
   13366 @cindex stack pointer register
   13367 @cindex program counter register
   13368 @cindex process status register
   13369 @cindex frame pointer register
   13370 @cindex standard registers
   13371 @value{GDBN} has four ``standard'' register names that are available (in
   13372 expressions) on most machines---whenever they do not conflict with an
   13373 architecture's canonical mnemonics for registers.  The register names
   13374 @code{$pc} and @code{$sp} are used for the program counter register and
   13375 the stack pointer.  @code{$fp} is used for a register that contains a
   13376 pointer to the current stack frame, and @code{$ps} is used for a
   13377 register that contains the processor status.  For example,
   13378 you could print the program counter in hex with
   13379 
   13380 @smallexample
   13381 p/x $pc
   13382 @end smallexample
   13383 
   13384 @noindent
   13385 or print the instruction to be executed next with
   13386 
   13387 @smallexample
   13388 x/i $pc
   13389 @end smallexample
   13390 
   13391 @noindent
   13392 or add four to the stack pointer@footnote{This is a way of removing
   13393 one word from the stack, on machines where stacks grow downward in
   13394 memory (most machines, nowadays).  This assumes that the innermost
   13395 stack frame is selected; setting @code{$sp} is not allowed when other
   13396 stack frames are selected.  To pop entire frames off the stack,
   13397 regardless of machine architecture, use @code{return};
   13398 see @ref{Returning, ,Returning from a Function}.} with
   13399 
   13400 @smallexample
   13401 set $sp += 4
   13402 @end smallexample
   13403 
   13404 Whenever possible, these four standard register names are available on
   13405 your machine even though the machine has different canonical mnemonics,
   13406 so long as there is no conflict.  The @code{info registers} command
   13407 shows the canonical names.  For example, on the SPARC, @code{info
   13408 registers} displays the processor status register as @code{$psr} but you
   13409 can also refer to it as @code{$ps}; and on x86-based machines @code{$ps}
   13410 is an alias for the @sc{eflags} register.
   13411 
   13412 @value{GDBN} always considers the contents of an ordinary register as an
   13413 integer when the register is examined in this way.  Some machines have
   13414 special registers which can hold nothing but floating point; these
   13415 registers are considered to have floating point values.  There is no way
   13416 to refer to the contents of an ordinary register as floating point value
   13417 (although you can @emph{print} it as a floating point value with
   13418 @samp{print/f $@var{regname}}).
   13419 
   13420 Some registers have distinct ``raw'' and ``virtual'' data formats.  This
   13421 means that the data format in which the register contents are saved by
   13422 the operating system is not the same one that your program normally
   13423 sees.  For example, the registers of the 68881 floating point
   13424 coprocessor are always saved in ``extended'' (raw) format, but all C
   13425 programs expect to work with ``double'' (virtual) format.  In such
   13426 cases, @value{GDBN} normally works with the virtual format only (the format
   13427 that makes sense for your program), but the @code{info registers} command
   13428 prints the data in both formats.
   13429 
   13430 @cindex SSE registers (x86)
   13431 @cindex MMX registers (x86)
   13432 Some machines have special registers whose contents can be interpreted
   13433 in several different ways.  For example, modern x86-based machines
   13434 have SSE and MMX registers that can hold several values packed
   13435 together in several different formats.  @value{GDBN} refers to such
   13436 registers in @code{struct} notation:
   13437 
   13438 @smallexample
   13439 (@value{GDBP}) print $xmm1
   13440 $1 = @{
   13441   v4_float = @{0, 3.43859137e-038, 1.54142831e-044, 1.821688e-044@},
   13442   v2_double = @{9.92129282474342e-303, 2.7585945287983262e-313@},
   13443   v16_int8 = "\000\000\000\000\3706;\001\v\000\000\000\r\000\000",
   13444   v8_int16 = @{0, 0, 14072, 315, 11, 0, 13, 0@},
   13445   v4_int32 = @{0, 20657912, 11, 13@},
   13446   v2_int64 = @{88725056443645952, 55834574859@},
   13447   uint128 = 0x0000000d0000000b013b36f800000000
   13448 @}
   13449 @end smallexample
   13450 
   13451 @noindent
   13452 To set values of such registers, you need to tell @value{GDBN} which
   13453 view of the register you wish to change, as if you were assigning
   13454 value to a @code{struct} member:
   13455 
   13456 @smallexample
   13457  (@value{GDBP}) set $xmm1.uint128 = 0x000000000000000000000000FFFFFFFF
   13458 @end smallexample
   13459 
   13460 Normally, register values are relative to the selected stack frame
   13461 (@pxref{Selection, ,Selecting a Frame}).  This means that you get the
   13462 value that the register would contain if all stack frames farther in
   13463 were exited and their saved registers restored.  In order to see the
   13464 true contents of hardware registers, you must select the innermost
   13465 frame (with @samp{frame 0}).
   13466 
   13467 @cindex caller-saved registers
   13468 @cindex call-clobbered registers
   13469 @cindex volatile registers
   13470 @cindex <not saved> values
   13471 Usually ABIs reserve some registers as not needed to be saved by the
   13472 callee (a.k.a.: ``caller-saved'', ``call-clobbered'' or ``volatile''
   13473 registers).  It may therefore not be possible for @value{GDBN} to know
   13474 the value a register had before the call (in other words, in the outer
   13475 frame), if the register value has since been changed by the callee.
   13476 @value{GDBN} tries to deduce where the inner frame saved
   13477 (``callee-saved'') registers, from the debug info, unwind info, or the
   13478 machine code generated by your compiler.  If some register is not
   13479 saved, and @value{GDBN} knows the register is ``caller-saved'' (via
   13480 its own knowledge of the ABI, or because the debug/unwind info
   13481 explicitly says the register's value is undefined), @value{GDBN}
   13482 displays @w{@samp{<not saved>}} as the register's value.  With targets
   13483 that @value{GDBN} has no knowledge of the register saving convention,
   13484 if a register was not saved by the callee, then its value and location
   13485 in the outer frame are assumed to be the same of the inner frame.
   13486 This is usually harmless, because if the register is call-clobbered,
   13487 the caller either does not care what is in the register after the
   13488 call, or has code to restore the value that it does care about.  Note,
   13489 however, that if you change such a register in the outer frame, you
   13490 may also be affecting the inner frame.  Also, the more ``outer'' the
   13491 frame is you're looking at, the more likely a call-clobbered
   13492 register's value is to be wrong, in the sense that it doesn't actually
   13493 represent the value the register had just before the call.
   13494 
   13495 @node Floating Point Hardware
   13496 @section Floating Point Hardware
   13497 @cindex floating point
   13498 
   13499 Depending on the configuration, @value{GDBN} may be able to give
   13500 you more information about the status of the floating point hardware.
   13501 
   13502 @table @code
   13503 @kindex info float
   13504 @item info float
   13505 Display hardware-dependent information about the floating
   13506 point unit.  The exact contents and layout vary depending on the
   13507 floating point chip.  Currently, @samp{info float} is supported on
   13508 the ARM and x86 machines.
   13509 @end table
   13510 
   13511 @node Vector Unit
   13512 @section Vector Unit
   13513 @cindex vector unit
   13514 
   13515 Depending on the configuration, @value{GDBN} may be able to give you
   13516 more information about the status of the vector unit.
   13517 
   13518 @table @code
   13519 @kindex info vector
   13520 @item info vector
   13521 Display information about the vector unit.  The exact contents and
   13522 layout vary depending on the hardware.
   13523 @end table
   13524 
   13525 @node OS Information
   13526 @section Operating System Auxiliary Information
   13527 @cindex OS information
   13528 
   13529 @value{GDBN} provides interfaces to useful OS facilities that can help
   13530 you debug your program.
   13531 
   13532 @cindex auxiliary vector
   13533 @cindex vector, auxiliary
   13534 Some operating systems supply an @dfn{auxiliary vector} to programs at
   13535 startup.  This is akin to the arguments and environment that you
   13536 specify for a program, but contains a system-dependent variety of
   13537 binary values that tell system libraries important details about the
   13538 hardware, operating system, and process.  Each value's purpose is
   13539 identified by an integer tag; the meanings are well-known but system-specific.
   13540 Depending on the configuration and operating system facilities,
   13541 @value{GDBN} may be able to show you this information.  For remote
   13542 targets, this functionality may further depend on the remote stub's
   13543 support of the @samp{qXfer:auxv:read} packet, see
   13544 @ref{qXfer auxiliary vector read}.
   13545 
   13546 @table @code
   13547 @kindex info auxv
   13548 @item info auxv
   13549 Display the auxiliary vector of the inferior, which can be either a
   13550 live process or a core dump file.  @value{GDBN} prints each tag value
   13551 numerically, and also shows names and text descriptions for recognized
   13552 tags.  Some values in the vector are numbers, some bit masks, and some
   13553 pointers to strings or other data.  @value{GDBN} displays each value in the
   13554 most appropriate form for a recognized tag, and in hexadecimal for
   13555 an unrecognized tag.
   13556 @end table
   13557 
   13558 On some targets, @value{GDBN} can access operating system-specific
   13559 information and show it to you.  The types of information available
   13560 will differ depending on the type of operating system running on the
   13561 target.  The mechanism used to fetch the data is described in
   13562 @ref{Operating System Information}.  For remote targets, this
   13563 functionality depends on the remote stub's support of the
   13564 @samp{qXfer:osdata:read} packet, see @ref{qXfer osdata read}.
   13565 
   13566 @table @code
   13567 @kindex info os
   13568 @item info os @var{infotype}
   13569 
   13570 Display OS information of the requested type.
   13571 
   13572 On @sc{gnu}/Linux, the following values of @var{infotype} are valid:
   13573 
   13574 @anchor{linux info os infotypes}
   13575 @table @code
   13576 @kindex info os cpus
   13577 @item cpus
   13578 Display the list of all CPUs/cores. For each CPU/core, @value{GDBN} prints
   13579 the available fields from /proc/cpuinfo. For each supported architecture
   13580 different fields are available. Two common entries are processor which gives
   13581 CPU number and bogomips; a system constant that is calculated during
   13582 kernel initialization.
   13583 
   13584 @kindex info os files
   13585 @item files
   13586 Display the list of open file descriptors on the target.  For each
   13587 file descriptor, @value{GDBN} prints the identifier of the process
   13588 owning the descriptor, the command of the owning process, the value
   13589 of the descriptor, and the target of the descriptor.
   13590 
   13591 @kindex info os modules
   13592 @item modules
   13593 Display the list of all loaded kernel modules on the target.  For each
   13594 module, @value{GDBN} prints the module name, the size of the module in
   13595 bytes, the number of times the module is used, the dependencies of the
   13596 module, the status of the module, and the address of the loaded module
   13597 in memory.
   13598 
   13599 @kindex info os msg
   13600 @item msg
   13601 Display the list of all System V message queues on the target.  For each
   13602 message queue, @value{GDBN} prints the message queue key, the message
   13603 queue identifier, the access permissions, the current number of bytes
   13604 on the queue, the current number of messages on the queue, the processes
   13605 that last sent and received a message on the queue, the user and group
   13606 of the owner and creator of the message queue, the times at which a
   13607 message was last sent and received on the queue, and the time at which
   13608 the message queue was last changed.
   13609 
   13610 @kindex info os processes
   13611 @item processes
   13612 Display the list of processes on the target.  For each process,
   13613 @value{GDBN} prints the process identifier, the name of the user, the
   13614 command corresponding to the process, and the list of processor cores
   13615 that the process is currently running on.  (To understand what these
   13616 properties mean, for this and the following info types, please consult
   13617 the general @sc{gnu}/Linux documentation.)
   13618 
   13619 @kindex info os procgroups
   13620 @item procgroups
   13621 Display the list of process groups on the target.  For each process,
   13622 @value{GDBN} prints the identifier of the process group that it belongs
   13623 to, the command corresponding to the process group leader, the process
   13624 identifier, and the command line of the process.  The list is sorted
   13625 first by the process group identifier, then by the process identifier,
   13626 so that processes belonging to the same process group are grouped together
   13627 and the process group leader is listed first.
   13628 
   13629 @kindex info os semaphores
   13630 @item semaphores
   13631 Display the list of all System V semaphore sets on the target.  For each
   13632 semaphore set, @value{GDBN} prints the semaphore set key, the semaphore
   13633 set identifier, the access permissions, the number of semaphores in the
   13634 set, the user and group of the owner and creator of the semaphore set,
   13635 and the times at which the semaphore set was operated upon and changed.
   13636 
   13637 @kindex info os shm
   13638 @item shm
   13639 Display the list of all System V shared-memory regions on the target.
   13640 For each shared-memory region, @value{GDBN} prints the region key,
   13641 the shared-memory identifier, the access permissions, the size of the
   13642 region, the process that created the region, the process that last
   13643 attached to or detached from the region, the current number of live
   13644 attaches to the region, and the times at which the region was last
   13645 attached to, detach from, and changed.
   13646 
   13647 @kindex info os sockets
   13648 @item sockets
   13649 Display the list of Internet-domain sockets on the target.  For each
   13650 socket, @value{GDBN} prints the address and port of the local and
   13651 remote endpoints, the current state of the connection, the creator of
   13652 the socket, the IP address family of the socket, and the type of the
   13653 connection.
   13654 
   13655 @kindex info os threads
   13656 @item threads
   13657 Display the list of threads running on the target.  For each thread,
   13658 @value{GDBN} prints the identifier of the process that the thread
   13659 belongs to, the command of the process, the thread identifier, and the
   13660 processor core that it is currently running on.  The main thread of a
   13661 process is not listed.
   13662 @end table
   13663 
   13664 @item info os
   13665 If @var{infotype} is omitted, then list the possible values for
   13666 @var{infotype} and the kind of OS information available for each
   13667 @var{infotype}.  If the target does not return a list of possible
   13668 types, this command will report an error.
   13669 @end table
   13670 
   13671 @node Memory Region Attributes
   13672 @section Memory Region Attributes
   13673 @cindex memory region attributes
   13674 
   13675 @dfn{Memory region attributes} allow you to describe special handling
   13676 required by regions of your target's memory.  @value{GDBN} uses
   13677 attributes to determine whether to allow certain types of memory
   13678 accesses; whether to use specific width accesses; and whether to cache
   13679 target memory.  By default the description of memory regions is
   13680 fetched from the target (if the current target supports this), but the
   13681 user can override the fetched regions.
   13682 
   13683 Defined memory regions can be individually enabled and disabled.  When a
   13684 memory region is disabled, @value{GDBN} uses the default attributes when
   13685 accessing memory in that region.  Similarly, if no memory regions have
   13686 been defined, @value{GDBN} uses the default attributes when accessing
   13687 all memory.
   13688 
   13689 When a memory region is defined, it is given a number to identify it;
   13690 to enable, disable, or remove a memory region, you specify that number.
   13691 
   13692 @table @code
   13693 @kindex mem
   13694 @item mem @var{lower} @var{upper} @var{attributes}@dots{}
   13695 Define a memory region bounded by @var{lower} and @var{upper} with
   13696 attributes @var{attributes}@dots{}, and add it to the list of regions
   13697 monitored by @value{GDBN}.  Note that @var{upper} == 0 is a special
   13698 case: it is treated as the target's maximum memory address.
   13699 (0xffff on 16 bit targets, 0xffffffff on 32 bit targets, etc.)
   13700 
   13701 @item mem auto
   13702 Discard any user changes to the memory regions and use target-supplied
   13703 regions, if available, or no regions if the target does not support.
   13704 
   13705 @kindex delete mem
   13706 @item delete mem @var{nums}@dots{}
   13707 Remove memory regions @var{nums}@dots{} from the list of regions
   13708 monitored by @value{GDBN}.
   13709 
   13710 @kindex disable mem
   13711 @item disable mem @var{nums}@dots{}
   13712 Disable monitoring of memory regions @var{nums}@dots{}.
   13713 A disabled memory region is not forgotten.
   13714 It may be enabled again later.
   13715 
   13716 @kindex enable mem
   13717 @item enable mem @var{nums}@dots{}
   13718 Enable monitoring of memory regions @var{nums}@dots{}.
   13719 
   13720 @kindex info mem
   13721 @item info mem
   13722 Print a table of all defined memory regions, with the following columns
   13723 for each region:
   13724 
   13725 @table @emph
   13726 @item Memory Region Number
   13727 @item Enabled or Disabled.
   13728 Enabled memory regions are marked with @samp{y}.
   13729 Disabled memory regions are marked with @samp{n}.
   13730 
   13731 @item Lo Address
   13732 The address defining the inclusive lower bound of the memory region.
   13733 
   13734 @item Hi Address
   13735 The address defining the exclusive upper bound of the memory region.
   13736 
   13737 @item Attributes
   13738 The list of attributes set for this memory region.
   13739 @end table
   13740 @end table
   13741 
   13742 
   13743 @subsection Attributes
   13744 
   13745 @subsubsection Memory Access Mode
   13746 The access mode attributes set whether @value{GDBN} may make read or
   13747 write accesses to a memory region.
   13748 
   13749 While these attributes prevent @value{GDBN} from performing invalid
   13750 memory accesses, they do nothing to prevent the target system, I/O DMA,
   13751 etc.@: from accessing memory.
   13752 
   13753 @table @code
   13754 @item ro
   13755 Memory is read only.
   13756 @item wo
   13757 Memory is write only.
   13758 @item rw
   13759 Memory is read/write.  This is the default.
   13760 @end table
   13761 
   13762 @subsubsection Memory Access Size
   13763 The access size attribute tells @value{GDBN} to use specific sized
   13764 accesses in the memory region.  Often memory mapped device registers
   13765 require specific sized accesses.  If no access size attribute is
   13766 specified, @value{GDBN} may use accesses of any size.
   13767 
   13768 @table @code
   13769 @item 8
   13770 Use 8 bit memory accesses.
   13771 @item 16
   13772 Use 16 bit memory accesses.
   13773 @item 32
   13774 Use 32 bit memory accesses.
   13775 @item 64
   13776 Use 64 bit memory accesses.
   13777 @end table
   13778 
   13779 @c @subsubsection Hardware/Software Breakpoints
   13780 @c The hardware/software breakpoint attributes set whether @value{GDBN}
   13781 @c will use hardware or software breakpoints for the internal breakpoints
   13782 @c used by the step, next, finish, until, etc. commands.
   13783 @c
   13784 @c @table @code
   13785 @c @item hwbreak
   13786 @c Always use hardware breakpoints
   13787 @c @item swbreak (default)
   13788 @c @end table
   13789 
   13790 @subsubsection Data Cache
   13791 The data cache attributes set whether @value{GDBN} will cache target
   13792 memory.  While this generally improves performance by reducing debug
   13793 protocol overhead, it can lead to incorrect results because @value{GDBN}
   13794 does not know about volatile variables or memory mapped device
   13795 registers.
   13796 
   13797 @table @code
   13798 @item cache
   13799 Enable @value{GDBN} to cache target memory.
   13800 @item nocache
   13801 Disable @value{GDBN} from caching target memory.  This is the default.
   13802 @end table
   13803 
   13804 @subsection Memory Access Checking
   13805 @value{GDBN} can be instructed to refuse accesses to memory that is
   13806 not explicitly described.  This can be useful if accessing such
   13807 regions has undesired effects for a specific target, or to provide
   13808 better error checking.  The following commands control this behavior.
   13809 
   13810 @table @code
   13811 @kindex set mem inaccessible-by-default
   13812 @item set mem inaccessible-by-default [on|off]
   13813 If @code{on} is specified, make  @value{GDBN} treat memory not
   13814 explicitly described by the memory ranges as non-existent and refuse accesses
   13815 to such memory.  The checks are only performed if there's at least one
   13816 memory range defined.  If @code{off} is specified, make @value{GDBN}
   13817 treat the memory not explicitly described by the memory ranges as RAM.
   13818 The default value is @code{on}.
   13819 @kindex show mem inaccessible-by-default
   13820 @item show mem inaccessible-by-default
   13821 Show the current handling of accesses to unknown memory.
   13822 @end table
   13823 
   13824 
   13825 @c @subsubsection Memory Write Verification
   13826 @c The memory write verification attributes set whether @value{GDBN}
   13827 @c will re-reads data after each write to verify the write was successful.
   13828 @c
   13829 @c @table @code
   13830 @c @item verify
   13831 @c @item noverify (default)
   13832 @c @end table
   13833 
   13834 @node Dump/Restore Files
   13835 @section Copy Between Memory and a File
   13836 @cindex dump/restore files
   13837 @cindex append data to a file
   13838 @cindex dump data to a file
   13839 @cindex restore data from a file
   13840 
   13841 You can use the commands @code{dump}, @code{append}, and
   13842 @code{restore} to copy data between target memory and a file.  The
   13843 @code{dump} and @code{append} commands write data to a file, and the
   13844 @code{restore} command reads data from a file back into the inferior's
   13845 memory.  Files may be in binary, Motorola S-record, Intel hex,
   13846 Tektronix Hex, or Verilog Hex format; however, @value{GDBN} can only
   13847 append to binary files, and cannot read from Verilog Hex files.
   13848 
   13849 @table @code
   13850 
   13851 @kindex dump
   13852 @item dump @r{[}@var{format}@r{]} memory @var{filename} @var{start_addr} @var{end_addr}
   13853 @itemx dump @r{[}@var{format}@r{]} value @var{filename} @var{expr}
   13854 Dump the contents of memory from @var{start_addr} to @var{end_addr},
   13855 or the value of @var{expr}, to @var{filename} in the given format.
   13856 
   13857 The @var{format} parameter may be any one of:
   13858 @table @code
   13859 @item binary
   13860 Raw binary form.
   13861 @item ihex
   13862 Intel hex format.
   13863 @item srec
   13864 Motorola S-record format.
   13865 @item tekhex
   13866 Tektronix Hex format.
   13867 @item verilog
   13868 Verilog Hex format.
   13869 @end table
   13870 
   13871 @value{GDBN} uses the same definitions of these formats as the
   13872 @sc{gnu} binary utilities, like @samp{objdump} and @samp{objcopy}.  If
   13873 @var{format} is omitted, @value{GDBN} dumps the data in raw binary
   13874 form.
   13875 
   13876 @kindex append
   13877 @item append @r{[}binary@r{]} memory @var{filename} @var{start_addr} @var{end_addr}
   13878 @itemx append @r{[}binary@r{]} value @var{filename} @var{expr}
   13879 Append the contents of memory from @var{start_addr} to @var{end_addr},
   13880 or the value of @var{expr}, to the file @var{filename}, in raw binary form.
   13881 (@value{GDBN} can only append data to files in raw binary form.)
   13882 
   13883 @kindex restore
   13884 @item restore @var{filename} @r{[}binary@r{]} @var{bias} @var{start} @var{end}
   13885 Restore the contents of file @var{filename} into memory.  The
   13886 @code{restore} command can automatically recognize any known @sc{bfd}
   13887 file format, except for raw binary.  To restore a raw binary file you
   13888 must specify the optional keyword @code{binary} after the filename.
   13889 
   13890 If @var{bias} is non-zero, its value will be added to the addresses
   13891 contained in the file.  Binary files always start at address zero, so
   13892 they will be restored at address @var{bias}.  Other bfd files have
   13893 a built-in location; they will be restored at offset @var{bias}
   13894 from that location.
   13895 
   13896 If @var{start} and/or @var{end} are non-zero, then only data between
   13897 file offset @var{start} and file offset @var{end} will be restored.
   13898 These offsets are relative to the addresses in the file, before
   13899 the @var{bias} argument is applied.
   13900 
   13901 @end table
   13902 
   13903 @node Core File Generation
   13904 @section How to Produce a Core File from Your Program
   13905 @cindex dump core from inferior
   13906 
   13907 A @dfn{core file} or @dfn{core dump} is a file that records the memory
   13908 image of a running process and its process status (register values
   13909 etc.).  Its primary use is post-mortem debugging of a program that
   13910 crashed while it ran outside a debugger.  A program that crashes
   13911 automatically produces a core file, unless this feature is disabled by
   13912 the user.  @xref{Files}, for information on invoking @value{GDBN} in
   13913 the post-mortem debugging mode.
   13914 
   13915 Occasionally, you may wish to produce a core file of the program you
   13916 are debugging in order to preserve a snapshot of its state.
   13917 @value{GDBN} has a special command for that.
   13918 
   13919 @table @code
   13920 @kindex gcore
   13921 @kindex generate-core-file
   13922 @item generate-core-file [@var{file}]
   13923 @itemx gcore [@var{file}]
   13924 Produce a core dump of the inferior process.  The optional argument
   13925 @var{file} specifies the file name where to put the core dump.  If not
   13926 specified, the file name defaults to @file{core.@var{pid}}, where
   13927 @var{pid} is the inferior process ID.
   13928 
   13929 If supported by the filesystem where the core is written to,
   13930 @value{GDBN} generates a sparse core dump file.
   13931 
   13932 Note that this command is implemented only for some systems (as of
   13933 this writing, @sc{gnu}/Linux, FreeBSD, Solaris, and S390).
   13934 
   13935 On @sc{gnu}/Linux, this command can take into account the value of the
   13936 file @file{/proc/@var{pid}/coredump_filter} when generating the core
   13937 dump (@pxref{set use-coredump-filter}), and by default honors the
   13938 @code{VM_DONTDUMP} flag for mappings where it is present in the file
   13939 @file{/proc/@var{pid}/smaps} (@pxref{set dump-excluded-mappings}).
   13940 
   13941 @kindex set use-coredump-filter
   13942 @anchor{set use-coredump-filter}
   13943 @item set use-coredump-filter on
   13944 @itemx set use-coredump-filter off
   13945 Enable or disable the use of the file
   13946 @file{/proc/@var{pid}/coredump_filter} when generating core dump
   13947 files.  This file is used by the Linux kernel to decide what types of
   13948 memory mappings will be dumped or ignored when generating a core dump
   13949 file.  @var{pid} is the process ID of a currently running process.
   13950 
   13951 To make use of this feature, you have to write in the
   13952 @file{/proc/@var{pid}/coredump_filter} file a value, in hexadecimal,
   13953 which is a bit mask representing the memory mapping types.  If a bit
   13954 is set in the bit mask, then the memory mappings of the corresponding
   13955 types will be dumped; otherwise, they will be ignored.  This
   13956 configuration is inherited by child processes.  For more information
   13957 about the bits that can be set in the
   13958 @file{/proc/@var{pid}/coredump_filter} file, please refer to the
   13959 manpage of @code{core(5)}.
   13960 
   13961 By default, this option is @code{on}.  If this option is turned
   13962 @code{off}, @value{GDBN} does not read the @file{coredump_filter} file
   13963 and instead uses the same default value as the Linux kernel in order
   13964 to decide which pages will be dumped in the core dump file.  This
   13965 value is currently @code{0x33}, which means that bits @code{0}
   13966 (anonymous private mappings), @code{1} (anonymous shared mappings),
   13967 @code{4} (ELF headers) and @code{5} (private huge pages) are active.
   13968 This will cause these memory mappings to be dumped automatically.
   13969 
   13970 @kindex set dump-excluded-mappings
   13971 @anchor{set dump-excluded-mappings}
   13972 @item set dump-excluded-mappings on
   13973 @itemx set dump-excluded-mappings off
   13974 If @code{on} is specified, @value{GDBN} will dump memory mappings
   13975 marked with the @code{VM_DONTDUMP} flag.  This flag is represented in
   13976 the file @file{/proc/@var{pid}/smaps} with the acronym @code{dd}.
   13977 
   13978 The default value is @code{off}.
   13979 @end table
   13980 
   13981 @node Character Sets
   13982 @section Character Sets
   13983 @cindex character sets
   13984 @cindex charset
   13985 @cindex translating between character sets
   13986 @cindex host character set
   13987 @cindex target character set
   13988 
   13989 If the program you are debugging uses a different character set to
   13990 represent characters and strings than the one @value{GDBN} uses itself,
   13991 @value{GDBN} can automatically translate between the character sets for
   13992 you.  The character set @value{GDBN} uses we call the @dfn{host
   13993 character set}; the one the inferior program uses we call the
   13994 @dfn{target character set}.
   13995 
   13996 For example, if you are running @value{GDBN} on a @sc{gnu}/Linux system, which
   13997 uses the ISO Latin 1 character set, but you are using @value{GDBN}'s
   13998 remote protocol (@pxref{Remote Debugging}) to debug a program
   13999 running on an IBM mainframe, which uses the @sc{ebcdic} character set,
   14000 then the host character set is Latin-1, and the target character set is
   14001 @sc{ebcdic}.  If you give @value{GDBN} the command @code{set
   14002 target-charset EBCDIC-US}, then @value{GDBN} translates between
   14003 @sc{ebcdic} and Latin 1 as you print character or string values, or use
   14004 character and string literals in expressions.
   14005 
   14006 @value{GDBN} has no way to automatically recognize which character set
   14007 the inferior program uses; you must tell it, using the @code{set
   14008 target-charset} command, described below.
   14009 
   14010 Here are the commands for controlling @value{GDBN}'s character set
   14011 support:
   14012 
   14013 @table @code
   14014 @item set target-charset @var{charset}
   14015 @kindex set target-charset
   14016 Set the current target character set to @var{charset}.  To display the
   14017 list of supported target character sets, type
   14018 @kbd{@w{set target-charset @key{TAB}@key{TAB}}}.
   14019 
   14020 @item set host-charset @var{charset}
   14021 @kindex set host-charset
   14022 Set the current host character set to @var{charset}.
   14023 
   14024 By default, @value{GDBN} uses a host character set appropriate to the
   14025 system it is running on; you can override that default using the
   14026 @code{set host-charset} command.  On some systems, @value{GDBN} cannot
   14027 automatically determine the appropriate host character set.  In this
   14028 case, @value{GDBN} uses @samp{UTF-8}.
   14029 
   14030 @value{GDBN} can only use certain character sets as its host character
   14031 set.  If you type @kbd{@w{set host-charset @key{TAB}@key{TAB}}},
   14032 @value{GDBN} will list the host character sets it supports.
   14033 
   14034 @item set charset @var{charset}
   14035 @kindex set charset
   14036 Set the current host and target character sets to @var{charset}.  As
   14037 above, if you type @kbd{@w{set charset @key{TAB}@key{TAB}}},
   14038 @value{GDBN} will list the names of the character sets that can be used
   14039 for both host and target.
   14040 
   14041 @item show charset
   14042 @kindex show charset
   14043 Show the names of the current host and target character sets.
   14044 
   14045 @item show host-charset
   14046 @kindex show host-charset
   14047 Show the name of the current host character set.
   14048 
   14049 @item show target-charset
   14050 @kindex show target-charset
   14051 Show the name of the current target character set.
   14052 
   14053 @item set target-wide-charset @var{charset}
   14054 @kindex set target-wide-charset
   14055 Set the current target's wide character set to @var{charset}.  This is
   14056 the character set used by the target's @code{wchar_t} type.  To
   14057 display the list of supported wide character sets, type
   14058 @kbd{@w{set target-wide-charset @key{TAB}@key{TAB}}}.
   14059 
   14060 @item show target-wide-charset
   14061 @kindex show target-wide-charset
   14062 Show the name of the current target's wide character set.
   14063 @end table
   14064 
   14065 Here is an example of @value{GDBN}'s character set support in action.
   14066 Assume that the following source code has been placed in the file
   14067 @file{charset-test.c}:
   14068 
   14069 @smallexample
   14070 #include <stdio.h>
   14071 
   14072 char ascii_hello[]
   14073   = @{72, 101, 108, 108, 111, 44, 32, 119,
   14074      111, 114, 108, 100, 33, 10, 0@};
   14075 char ibm1047_hello[]
   14076   = @{200, 133, 147, 147, 150, 107, 64, 166,
   14077      150, 153, 147, 132, 90, 37, 0@};
   14078 
   14079 main ()
   14080 @{
   14081   printf ("Hello, world!\n");
   14082 @}
   14083 @end smallexample
   14084 
   14085 In this program, @code{ascii_hello} and @code{ibm1047_hello} are arrays
   14086 containing the string @samp{Hello, world!} followed by a newline,
   14087 encoded in the @sc{ascii} and @sc{ibm1047} character sets.
   14088 
   14089 We compile the program, and invoke the debugger on it:
   14090 
   14091 @smallexample
   14092 $ gcc -g charset-test.c -o charset-test
   14093 $ gdb -nw charset-test
   14094 GNU gdb 2001-12-19-cvs
   14095 Copyright 2001 Free Software Foundation, Inc.
   14096 @dots{}
   14097 (@value{GDBP})
   14098 @end smallexample
   14099 
   14100 We can use the @code{show charset} command to see what character sets
   14101 @value{GDBN} is currently using to interpret and display characters and
   14102 strings:
   14103 
   14104 @smallexample
   14105 (@value{GDBP}) show charset
   14106 The current host and target character set is `ISO-8859-1'.
   14107 (@value{GDBP})
   14108 @end smallexample
   14109 
   14110 For the sake of printing this manual, let's use @sc{ascii} as our
   14111 initial character set:
   14112 @smallexample
   14113 (@value{GDBP}) set charset ASCII
   14114 (@value{GDBP}) show charset
   14115 The current host and target character set is `ASCII'.
   14116 (@value{GDBP})
   14117 @end smallexample
   14118 
   14119 Let's assume that @sc{ascii} is indeed the correct character set for our
   14120 host system --- in other words, let's assume that if @value{GDBN} prints
   14121 characters using the @sc{ascii} character set, our terminal will display
   14122 them properly.  Since our current target character set is also
   14123 @sc{ascii}, the contents of @code{ascii_hello} print legibly:
   14124 
   14125 @smallexample
   14126 (@value{GDBP}) print ascii_hello
   14127 $1 = 0x401698 "Hello, world!\n"
   14128 (@value{GDBP}) print ascii_hello[0]
   14129 $2 = 72 'H'
   14130 (@value{GDBP})
   14131 @end smallexample
   14132 
   14133 @value{GDBN} uses the target character set for character and string
   14134 literals you use in expressions:
   14135 
   14136 @smallexample
   14137 (@value{GDBP}) print '+'
   14138 $3 = 43 '+'
   14139 (@value{GDBP})
   14140 @end smallexample
   14141 
   14142 The @sc{ascii} character set uses the number 43 to encode the @samp{+}
   14143 character.
   14144 
   14145 @value{GDBN} relies on the user to tell it which character set the
   14146 target program uses.  If we print @code{ibm1047_hello} while our target
   14147 character set is still @sc{ascii}, we get jibberish:
   14148 
   14149 @smallexample
   14150 (@value{GDBP}) print ibm1047_hello
   14151 $4 = 0x4016a8 "\310\205\223\223\226k@@\246\226\231\223\204Z%"
   14152 (@value{GDBP}) print ibm1047_hello[0]
   14153 $5 = 200 '\310'
   14154 (@value{GDBP})
   14155 @end smallexample
   14156 
   14157 If we invoke the @code{set target-charset} followed by @key{TAB}@key{TAB},
   14158 @value{GDBN} tells us the character sets it supports:
   14159 
   14160 @smallexample
   14161 (@value{GDBP}) set target-charset
   14162 ASCII       EBCDIC-US   IBM1047     ISO-8859-1
   14163 (@value{GDBP}) set target-charset
   14164 @end smallexample
   14165 
   14166 We can select @sc{ibm1047} as our target character set, and examine the
   14167 program's strings again.  Now the @sc{ascii} string is wrong, but
   14168 @value{GDBN} translates the contents of @code{ibm1047_hello} from the
   14169 target character set, @sc{ibm1047}, to the host character set,
   14170 @sc{ascii}, and they display correctly:
   14171 
   14172 @smallexample
   14173 (@value{GDBP}) set target-charset IBM1047
   14174 (@value{GDBP}) show charset
   14175 The current host character set is `ASCII'.
   14176 The current target character set is `IBM1047'.
   14177 (@value{GDBP}) print ascii_hello
   14178 $6 = 0x401698 "\110\145%%?\054\040\167?\162%\144\041\012"
   14179 (@value{GDBP}) print ascii_hello[0]
   14180 $7 = 72 '\110'
   14181 (@value{GDBP}) print ibm1047_hello
   14182 $8 = 0x4016a8 "Hello, world!\n"
   14183 (@value{GDBP}) print ibm1047_hello[0]
   14184 $9 = 200 'H'
   14185 (@value{GDBP})
   14186 @end smallexample
   14187 
   14188 As above, @value{GDBN} uses the target character set for character and
   14189 string literals you use in expressions:
   14190 
   14191 @smallexample
   14192 (@value{GDBP}) print '+'
   14193 $10 = 78 '+'
   14194 (@value{GDBP})
   14195 @end smallexample
   14196 
   14197 The @sc{ibm1047} character set uses the number 78 to encode the @samp{+}
   14198 character.
   14199 
   14200 @node Caching Target Data
   14201 @section Caching Data of Targets
   14202 @cindex caching data of targets
   14203 
   14204 @value{GDBN} caches data exchanged between the debugger and a target.
   14205 Each cache is associated with the address space of the inferior.
   14206 @xref{Inferiors Connections and Programs}, about inferior and address space.
   14207 Such caching generally improves performance in remote debugging
   14208 (@pxref{Remote Debugging}), because it reduces the overhead of the
   14209 remote protocol by bundling memory reads and writes into large chunks.
   14210 Unfortunately, simply caching everything would lead to incorrect results,
   14211 since @value{GDBN} does not necessarily know anything about volatile
   14212 values, memory-mapped I/O addresses, etc.  Furthermore, in non-stop mode
   14213 (@pxref{Non-Stop Mode}) memory can be changed @emph{while} a gdb command
   14214 is executing.
   14215 Therefore, by default, @value{GDBN} only caches data
   14216 known to be on the stack@footnote{In non-stop mode, it is moderately
   14217 rare for a running thread to modify the stack of a stopped thread
   14218 in a way that would interfere with a backtrace, and caching of
   14219 stack reads provides a significant speed up of remote backtraces.} or
   14220 in the code segment.
   14221 Other regions of memory can be explicitly marked as
   14222 cacheable; @pxref{Memory Region Attributes}.
   14223 
   14224 @table @code
   14225 @kindex set remotecache
   14226 @item set remotecache on
   14227 @itemx set remotecache off
   14228 This option no longer does anything; it exists for compatibility
   14229 with old scripts.
   14230 
   14231 @kindex show remotecache
   14232 @item show remotecache
   14233 Show the current state of the obsolete remotecache flag.
   14234 
   14235 @kindex set stack-cache
   14236 @item set stack-cache on
   14237 @itemx set stack-cache off
   14238 Enable or disable caching of stack accesses.  When @code{on}, use
   14239 caching.  By default, this option is @code{on}.
   14240 
   14241 @kindex show stack-cache
   14242 @item show stack-cache
   14243 Show the current state of data caching for memory accesses.
   14244 
   14245 @kindex set code-cache
   14246 @item set code-cache on
   14247 @itemx set code-cache off
   14248 Enable or disable caching of code segment accesses.  When @code{on},
   14249 use caching.  By default, this option is @code{on}.  This improves
   14250 performance of disassembly in remote debugging.
   14251 
   14252 @kindex show code-cache
   14253 @item show code-cache
   14254 Show the current state of target memory cache for code segment
   14255 accesses.
   14256 
   14257 @kindex info dcache
   14258 @item info dcache @r{[}line@r{]}
   14259 Print the information about the performance of data cache of the
   14260 current inferior's address space.  The information displayed
   14261 includes the dcache width and depth, and for each cache line, its
   14262 number, address, and how many times it was referenced.  This
   14263 command is useful for debugging the data cache operation.
   14264 
   14265 If a line number is specified, the contents of that line will be
   14266 printed in hex.
   14267 
   14268 @item set dcache size @var{size}
   14269 @cindex dcache size
   14270 @kindex set dcache size
   14271 Set maximum number of entries in dcache (dcache depth above).
   14272 
   14273 @item set dcache line-size @var{line-size}
   14274 @cindex dcache line-size
   14275 @kindex set dcache line-size
   14276 Set number of bytes each dcache entry caches (dcache width above).
   14277 Must be a power of 2.
   14278 
   14279 @item show dcache size
   14280 @kindex show dcache size
   14281 Show maximum number of dcache entries.  @xref{Caching Target Data, info dcache}.
   14282 
   14283 @item show dcache line-size
   14284 @kindex show dcache line-size
   14285 Show default size of dcache lines.
   14286 
   14287 @item maint flush dcache
   14288 @cindex dcache, flushing
   14289 @kindex maint flush dcache
   14290 Flush the contents (if any) of the dcache.  This maintainer command is
   14291 useful when debugging the dcache implementation.
   14292 
   14293 @end table
   14294 
   14295 @node Searching Memory
   14296 @section Search Memory
   14297 @cindex searching memory
   14298 
   14299 Memory can be searched for a particular sequence of bytes with the
   14300 @code{find} command.
   14301 
   14302 @table @code
   14303 @kindex find
   14304 @item find @r{[}/@var{sn}@r{]} @var{start_addr}, +@var{len}, @var{val1} @r{[}, @var{val2}, @dots{}@r{]}
   14305 @itemx find @r{[}/@var{sn}@r{]} @var{start_addr}, @var{end_addr}, @var{val1} @r{[}, @var{val2}, @dots{}@r{]}
   14306 Search memory for the sequence of bytes specified by @var{val1}, @var{val2},
   14307 etc.  The search begins at address @var{start_addr} and continues for either
   14308 @var{len} bytes or through to @var{end_addr} inclusive.
   14309 @end table
   14310 
   14311 @var{s} and @var{n} are optional parameters.
   14312 They may be specified in either order, apart or together.
   14313 
   14314 @table @r
   14315 @item @var{s}, search query size
   14316 The size of each search query value.
   14317 
   14318 @table @code
   14319 @item b
   14320 bytes
   14321 @item h
   14322 halfwords (two bytes)
   14323 @item w
   14324 words (four bytes)
   14325 @item g
   14326 giant words (eight bytes)
   14327 @end table
   14328 
   14329 All values are interpreted in the current language.
   14330 This means, for example, that if the current source language is C/C@t{++}
   14331 then searching for the string ``hello'' includes the trailing '\0'.
   14332 The null terminator can be removed from searching by using casts,
   14333 e.g.: @samp{@{char[5]@}"hello"}.
   14334 
   14335 If the value size is not specified, it is taken from the
   14336 value's type in the current language.
   14337 This is useful when one wants to specify the search
   14338 pattern as a mixture of types.
   14339 Note that this means, for example, that in the case of C-like languages
   14340 a search for an untyped 0x42 will search for @samp{(int) 0x42}
   14341 which is typically four bytes.
   14342 
   14343 @item @var{n}, maximum number of finds
   14344 The maximum number of matches to print.  The default is to print all finds.
   14345 @end table
   14346 
   14347 You can use strings as search values.  Quote them with double-quotes
   14348  (@code{"}).
   14349 The string value is copied into the search pattern byte by byte,
   14350 regardless of the endianness of the target and the size specification.
   14351 
   14352 The address of each match found is printed as well as a count of the
   14353 number of matches found.
   14354 
   14355 The address of the last value found is stored in convenience variable
   14356 @samp{$_}.
   14357 A count of the number of matches is stored in @samp{$numfound}.
   14358 
   14359 For example, if stopped at the @code{printf} in this function:
   14360 
   14361 @smallexample
   14362 void
   14363 hello ()
   14364 @{
   14365   static char hello[] = "hello-hello";
   14366   static struct @{ char c; short s; int i; @}
   14367     __attribute__ ((packed)) mixed
   14368     = @{ 'c', 0x1234, 0x87654321 @};
   14369   printf ("%s\n", hello);
   14370 @}
   14371 @end smallexample
   14372 
   14373 @noindent
   14374 you get during debugging:
   14375 
   14376 @smallexample
   14377 (@value{GDBP}) find &hello[0], +sizeof(hello), "hello"
   14378 0x804956d <hello.1620+6>
   14379 1 pattern found
   14380 (@value{GDBP}) find &hello[0], +sizeof(hello), 'h', 'e', 'l', 'l', 'o'
   14381 0x8049567 <hello.1620>
   14382 0x804956d <hello.1620+6>
   14383 2 patterns found.
   14384 (@value{GDBP}) find &hello[0], +sizeof(hello), @{char[5]@}"hello"
   14385 0x8049567 <hello.1620>
   14386 0x804956d <hello.1620+6>
   14387 2 patterns found.
   14388 (@value{GDBP}) find /b1 &hello[0], +sizeof(hello), 'h', 0x65, 'l'
   14389 0x8049567 <hello.1620>
   14390 1 pattern found
   14391 (@value{GDBP}) find &mixed, +sizeof(mixed), (char) 'c', (short) 0x1234, (int) 0x87654321
   14392 0x8049560 <mixed.1625>
   14393 1 pattern found
   14394 (@value{GDBP}) print $numfound
   14395 $1 = 1
   14396 (@value{GDBP}) print $_
   14397 $2 = (void *) 0x8049560
   14398 @end smallexample
   14399 
   14400 @node Value Sizes
   14401 @section Value Sizes
   14402 
   14403 Whenever @value{GDBN} prints a value memory will be allocated within
   14404 @value{GDBN} to hold the contents of the value.  It is possible in
   14405 some languages with dynamic typing systems, that an invalid program
   14406 may indicate a value that is incorrectly large, this in turn may cause
   14407 @value{GDBN} to try and allocate an overly large amount of memory.
   14408 
   14409 @table @code
   14410 @anchor{set max-value-size}
   14411 @kindex set max-value-size
   14412 @item set max-value-size @var{bytes}
   14413 @itemx set max-value-size unlimited
   14414 Set the maximum size of memory that @value{GDBN} will allocate for the
   14415 contents of a value to @var{bytes}, trying to display a value that
   14416 requires more memory than that will result in an error.
   14417 
   14418 Setting this variable does not effect values that have already been
   14419 allocated within @value{GDBN}, only future allocations.
   14420 
   14421 There's a minimum size that @code{max-value-size} can be set to in
   14422 order that @value{GDBN} can still operate correctly, this minimum is
   14423 currently 16 bytes.
   14424 
   14425 The limit applies to the results of some subexpressions as well as to
   14426 complete expressions.  For example, an expression denoting a simple
   14427 integer component, such as @code{x.y.z}, may fail if the size of
   14428 @var{x.y} is dynamic and exceeds @var{bytes}.  On the other hand,
   14429 @value{GDBN} is sometimes clever; the expression @code{A[i]}, where
   14430 @var{A} is an array variable with non-constant size, will generally
   14431 succeed regardless of the bounds on @var{A}, as long as the component
   14432 size is less than @var{bytes}.
   14433 
   14434 The default value of @code{max-value-size} is currently 64k.
   14435 
   14436 @kindex show max-value-size
   14437 @item show max-value-size
   14438 Show the maximum size of memory, in bytes, that @value{GDBN} will
   14439 allocate for the contents of a value.
   14440 @end table
   14441 
   14442 @node Optimized Code
   14443 @chapter Debugging Optimized Code
   14444 @cindex optimized code, debugging
   14445 @cindex debugging optimized code
   14446 
   14447 Almost all compilers support optimization.  With optimization
   14448 disabled, the compiler generates assembly code that corresponds
   14449 directly to your source code, in a simplistic way.  As the compiler
   14450 applies more powerful optimizations, the generated assembly code
   14451 diverges from your original source code.  With help from debugging
   14452 information generated by the compiler, @value{GDBN} can map from
   14453 the running program back to constructs from your original source.
   14454 
   14455 @value{GDBN} is more accurate with optimization disabled.  If you
   14456 can recompile without optimization, it is easier to follow the
   14457 progress of your program during debugging.  But, there are many cases
   14458 where you may need to debug an optimized version.
   14459 
   14460 When you debug a program compiled with @samp{-g -O}, remember that the
   14461 optimizer has rearranged your code; the debugger shows you what is
   14462 really there.  Do not be too surprised when the execution path does not
   14463 exactly match your source file!  An extreme example: if you define a
   14464 variable, but never use it, @value{GDBN} never sees that
   14465 variable---because the compiler optimizes it out of existence.
   14466 
   14467 Some things do not work as well with @samp{-g -O} as with just
   14468 @samp{-g}, particularly on machines with instruction scheduling.  If in
   14469 doubt, recompile with @samp{-g} alone, and if this fixes the problem,
   14470 please report it to us as a bug (including a test case!).
   14471 @xref{Variables}, for more information about debugging optimized code.
   14472 
   14473 @menu
   14474 * Inline Functions::            How @value{GDBN} presents inlining
   14475 * Tail Call Frames::            @value{GDBN} analysis of jumps to functions
   14476 @end menu
   14477 
   14478 @node Inline Functions
   14479 @section Inline Functions
   14480 @cindex inline functions, debugging
   14481 
   14482 @dfn{Inlining} is an optimization that inserts a copy of the function
   14483 body directly at each call site, instead of jumping to a shared
   14484 routine.  @value{GDBN} displays inlined functions just like
   14485 non-inlined functions.  They appear in backtraces.  You can view their
   14486 arguments and local variables, step into them with @code{step}, skip
   14487 them with @code{next}, and escape from them with @code{finish}.
   14488 You can check whether a function was inlined by using the
   14489 @code{info frame} command.
   14490 
   14491 For @value{GDBN} to support inlined functions, the compiler must
   14492 record information about inlining in the debug information ---
   14493 @value{NGCC} using the @sc{dwarf 2} format does this, and several
   14494 other compilers do also.  @value{GDBN} only supports inlined functions
   14495 when using @sc{dwarf 2}.  Versions of @value{NGCC} before 4.1
   14496 do not emit two required attributes (@samp{DW_AT_call_file} and
   14497 @samp{DW_AT_call_line}); @value{GDBN} does not display inlined
   14498 function calls with earlier versions of @value{NGCC}.  It instead
   14499 displays the arguments and local variables of inlined functions as
   14500 local variables in the caller.
   14501 
   14502 The body of an inlined function is directly included at its call site;
   14503 unlike a non-inlined function, there are no instructions devoted to
   14504 the call.  @value{GDBN} still pretends that the call site and the
   14505 start of the inlined function are different instructions.  Stepping to
   14506 the call site shows the call site, and then stepping again shows
   14507 the first line of the inlined function, even though no additional
   14508 instructions are executed.
   14509 
   14510 This makes source-level debugging much clearer; you can see both the
   14511 context of the call and then the effect of the call.  Only stepping by
   14512 a single instruction using @code{stepi} or @code{nexti} does not do
   14513 this; single instruction steps always show the inlined body.
   14514 
   14515 There are some ways that @value{GDBN} does not pretend that inlined
   14516 function calls are the same as normal calls:
   14517 
   14518 @itemize @bullet
   14519 @item
   14520 Setting breakpoints at the call site of an inlined function may not
   14521 work, because the call site does not contain any code.  @value{GDBN}
   14522 may incorrectly move the breakpoint to the next line of the enclosing
   14523 function, after the call.  This limitation will be removed in a future
   14524 version of @value{GDBN}; until then, set a breakpoint on an earlier line
   14525 or inside the inlined function instead.
   14526 
   14527 @item
   14528 @value{GDBN} cannot locate the return value of inlined calls after
   14529 using the @code{finish} command.  This is a limitation of compiler-generated
   14530 debugging information; after @code{finish}, you can step to the next line
   14531 and print a variable where your program stored the return value.
   14532 
   14533 @end itemize
   14534 
   14535 @node Tail Call Frames
   14536 @section Tail Call Frames
   14537 @cindex tail call frames, debugging
   14538 
   14539 Function @code{B} can call function @code{C} in its very last statement.  In
   14540 unoptimized compilation the call of @code{C} is immediately followed by return
   14541 instruction at the end of @code{B} code.  Optimizing compiler may replace the
   14542 call and return in function @code{B} into one jump to function @code{C}
   14543 instead.  Such use of a jump instruction is called @dfn{tail call}.
   14544 
   14545 During execution of function @code{C}, there will be no indication in the
   14546 function call stack frames that it was tail-called from @code{B}.  If function
   14547 @code{A} regularly calls function @code{B} which tail-calls function @code{C},
   14548 then @value{GDBN} will see @code{A} as the caller of @code{C}.  However, in
   14549 some cases @value{GDBN} can determine that @code{C} was tail-called from
   14550 @code{B}, and it will then create fictitious call frame for that, with the
   14551 return address set up as if @code{B} called @code{C} normally.
   14552 
   14553 This functionality is currently supported only by DWARF 2 debugging format and
   14554 the compiler has to produce @samp{DW_TAG_call_site} tags.  With
   14555 @value{NGCC}, you need to specify @option{-O -g} during compilation, to get
   14556 this information.
   14557 
   14558 @kbd{info frame} command (@pxref{Frame Info}) will indicate the tail call frame
   14559 kind by text @code{tail call frame} such as in this sample @value{GDBN} output:
   14560 
   14561 @smallexample
   14562 (@value{GDBP}) x/i $pc - 2
   14563    0x40066b <b(int, double)+11>: jmp 0x400640 <c(int, double)>
   14564 (@value{GDBP}) info frame
   14565 Stack level 1, frame at 0x7fffffffda30:
   14566  rip = 0x40066d in b (amd64-entry-value.cc:59); saved rip 0x4004c5
   14567  tail call frame, caller of frame at 0x7fffffffda30
   14568  source language c++.
   14569  Arglist at unknown address.
   14570  Locals at unknown address, Previous frame's sp is 0x7fffffffda30
   14571 @end smallexample
   14572 
   14573 The detection of all the possible code path executions can find them ambiguous.
   14574 There is no execution history stored (possible @ref{Reverse Execution} is never
   14575 used for this purpose) and the last known caller could have reached the known
   14576 callee by multiple different jump sequences.  In such case @value{GDBN} still
   14577 tries to show at least all the unambiguous top tail callers and all the
   14578 unambiguous bottom tail callees, if any.
   14579 
   14580 @table @code
   14581 @anchor{set debug entry-values}
   14582 @item set debug entry-values
   14583 @kindex set debug entry-values
   14584 When set to on, enables printing of analysis messages for both frame argument
   14585 values at function entry and tail calls.  It will show all the possible valid
   14586 tail calls code paths it has considered.  It will also print the intersection
   14587 of them with the final unambiguous (possibly partial or even empty) code path
   14588 result.
   14589 
   14590 @item show debug entry-values
   14591 @kindex show debug entry-values
   14592 Show the current state of analysis messages printing for both frame argument
   14593 values at function entry and tail calls.
   14594 @end table
   14595 
   14596 The analysis messages for tail calls can for example show why the virtual tail
   14597 call frame for function @code{c} has not been recognized (due to the indirect
   14598 reference by variable @code{x}):
   14599 
   14600 @smallexample
   14601 static void __attribute__((noinline, noclone)) c (void);
   14602 void (*x) (void) = c;
   14603 static void __attribute__((noinline, noclone)) a (void) @{ x++; @}
   14604 static void __attribute__((noinline, noclone)) c (void) @{ a (); @}
   14605 int main (void) @{ x (); return 0; @}
   14606 
   14607 Breakpoint 1, DW_OP_entry_value resolving cannot find
   14608 DW_TAG_call_site 0x40039a in main
   14609 a () at t.c:3
   14610 3	static void __attribute__((noinline, noclone)) a (void) @{ x++; @}
   14611 (@value{GDBP}) bt
   14612 #0  a () at t.c:3
   14613 #1  0x000000000040039a in main () at t.c:5
   14614 @end smallexample
   14615 
   14616 Another possibility is an ambiguous virtual tail call frames resolution:
   14617 
   14618 @smallexample
   14619 int i;
   14620 static void __attribute__((noinline, noclone)) f (void) @{ i++; @}
   14621 static void __attribute__((noinline, noclone)) e (void) @{ f (); @}
   14622 static void __attribute__((noinline, noclone)) d (void) @{ f (); @}
   14623 static void __attribute__((noinline, noclone)) c (void) @{ d (); @}
   14624 static void __attribute__((noinline, noclone)) b (void)
   14625 @{ if (i) c (); else e (); @}
   14626 static void __attribute__((noinline, noclone)) a (void) @{ b (); @}
   14627 int main (void) @{ a (); return 0; @}
   14628 
   14629 tailcall: initial: 0x4004d2(a) 0x4004ce(b) 0x4004b2(c) 0x4004a2(d)
   14630 tailcall: compare: 0x4004d2(a) 0x4004cc(b) 0x400492(e)
   14631 tailcall: reduced: 0x4004d2(a) |
   14632 (@value{GDBP}) bt
   14633 #0  f () at t.c:2
   14634 #1  0x00000000004004d2 in a () at t.c:8
   14635 #2  0x0000000000400395 in main () at t.c:9
   14636 @end smallexample
   14637 
   14638 @set CALLSEQ1A @code{main@value{ARROW}a@value{ARROW}b@value{ARROW}c@value{ARROW}d@value{ARROW}f}
   14639 @set CALLSEQ2A @code{main@value{ARROW}a@value{ARROW}b@value{ARROW}e@value{ARROW}f}
   14640 
   14641 @c Convert CALLSEQ#A to CALLSEQ#B depending on HAVE_MAKEINFO_CLICK.
   14642 @ifset HAVE_MAKEINFO_CLICK
   14643 @set ARROW @click{}
   14644 @set CALLSEQ1B @clicksequence{@value{CALLSEQ1A}}
   14645 @set CALLSEQ2B @clicksequence{@value{CALLSEQ2A}}
   14646 @end ifset
   14647 @ifclear HAVE_MAKEINFO_CLICK
   14648 @set ARROW ->
   14649 @set CALLSEQ1B @value{CALLSEQ1A}
   14650 @set CALLSEQ2B @value{CALLSEQ2A}
   14651 @end ifclear
   14652 
   14653 Frames #0 and #2 are real, #1 is a virtual tail call frame.
   14654 The code can have possible execution paths @value{CALLSEQ1B} or
   14655 @value{CALLSEQ2B}, @value{GDBN} cannot find which one from the inferior state.
   14656 
   14657 @code{initial:} state shows some random possible calling sequence @value{GDBN}
   14658 has found.  It then finds another possible calling sequence - that one is
   14659 prefixed by @code{compare:}.  The non-ambiguous intersection of these two is
   14660 printed as the @code{reduced:} calling sequence.  That one could have many
   14661 further @code{compare:} and @code{reduced:} statements as long as there remain
   14662 any non-ambiguous sequence entries.
   14663 
   14664 For the frame of function @code{b} in both cases there are different possible
   14665 @code{$pc} values (@code{0x4004cc} or @code{0x4004ce}), therefore this frame is
   14666 also ambiguous.  The only non-ambiguous frame is the one for function @code{a},
   14667 therefore this one is displayed to the user while the ambiguous frames are
   14668 omitted.
   14669 
   14670 There can be also reasons why printing of frame argument values at function
   14671 entry may fail:
   14672 
   14673 @smallexample
   14674 int v;
   14675 static void __attribute__((noinline, noclone)) c (int i) @{ v++; @}
   14676 static void __attribute__((noinline, noclone)) a (int i);
   14677 static void __attribute__((noinline, noclone)) b (int i) @{ a (i); @}
   14678 static void __attribute__((noinline, noclone)) a (int i)
   14679 @{ if (i) b (i - 1); else c (0); @}
   14680 int main (void) @{ a (5); return 0; @}
   14681 
   14682 (@value{GDBP}) bt
   14683 #0  c (i=i@@entry=0) at t.c:2
   14684 #1  0x0000000000400428 in a (DW_OP_entry_value resolving has found
   14685 function "a" at 0x400420 can call itself via tail calls
   14686 i=<optimized out>) at t.c:6
   14687 #2  0x000000000040036e in main () at t.c:7
   14688 @end smallexample
   14689 
   14690 @value{GDBN} cannot find out from the inferior state if and how many times did
   14691 function @code{a} call itself (via function @code{b}) as these calls would be
   14692 tail calls.  Such tail calls would modify the @code{i} variable, therefore
   14693 @value{GDBN} cannot be sure the value it knows would be right - @value{GDBN}
   14694 prints @code{<optimized out>} instead.
   14695 
   14696 @node Macros
   14697 @chapter C Preprocessor Macros
   14698 
   14699 Some languages, such as C and C@t{++}, provide a way to define and invoke
   14700 ``preprocessor macros'' which expand into strings of tokens.
   14701 @value{GDBN} can evaluate expressions containing macro invocations, show
   14702 the result of macro expansion, and show a macro's definition, including
   14703 where it was defined.
   14704 
   14705 You may need to compile your program specially to provide @value{GDBN}
   14706 with information about preprocessor macros.  Most compilers do not
   14707 include macros in their debugging information, even when you compile
   14708 with the @option{-g} flag.  @xref{Compilation}.
   14709 
   14710 A program may define a macro at one point, remove that definition later,
   14711 and then provide a different definition after that.  Thus, at different
   14712 points in the program, a macro may have different definitions, or have
   14713 no definition at all.  If there is a current stack frame, @value{GDBN}
   14714 uses the macros in scope at that frame's source code line.  Otherwise,
   14715 @value{GDBN} uses the macros in scope at the current listing location;
   14716 see @ref{List}.
   14717 
   14718 Whenever @value{GDBN} evaluates an expression, it always expands any
   14719 macro invocations present in the expression.  @value{GDBN} also provides
   14720 the following commands for working with macros explicitly.
   14721 
   14722 @table @code
   14723 
   14724 @kindex macro expand
   14725 @cindex macro expansion, showing the results of preprocessor
   14726 @cindex preprocessor macro expansion, showing the results of
   14727 @cindex expanding preprocessor macros
   14728 @item macro expand @var{expression}
   14729 @itemx macro exp @var{expression}
   14730 Show the results of expanding all preprocessor macro invocations in
   14731 @var{expression}.  Since @value{GDBN} simply expands macros, but does
   14732 not parse the result, @var{expression} need not be a valid expression;
   14733 it can be any string of tokens.
   14734 
   14735 @kindex macro exp1
   14736 @item macro expand-once @var{expression}
   14737 @itemx macro exp1 @var{expression}
   14738 @cindex expand macro once
   14739 @i{(This command is not yet implemented.)}  Show the results of
   14740 expanding those preprocessor macro invocations that appear explicitly in
   14741 @var{expression}.  Macro invocations appearing in that expansion are
   14742 left unchanged.  This command allows you to see the effect of a
   14743 particular macro more clearly, without being confused by further
   14744 expansions.  Since @value{GDBN} simply expands macros, but does not
   14745 parse the result, @var{expression} need not be a valid expression; it
   14746 can be any string of tokens.
   14747 
   14748 @kindex info macro
   14749 @cindex macro definition, showing
   14750 @cindex definition of a macro, showing
   14751 @cindex macros, from debug info
   14752 @item info macro [-a|-all] [--] @var{macro}
   14753 Show the current definition or all definitions of the named @var{macro},
   14754 and describe the source location or compiler command-line where that
   14755 definition was established.  The optional double dash is to signify the end of
   14756 argument processing and the beginning of @var{macro} for non C-like macros where
   14757 the macro may begin with a hyphen.
   14758 
   14759 @kindex info macros
   14760 @item info macros @var{locspec}
   14761 Show all macro definitions that are in effect at the source line of
   14762 the code location that results from resolving @var{locspec}, and
   14763 describe the source location or compiler command-line where those
   14764 definitions were established.
   14765 
   14766 @kindex macro define
   14767 @cindex user-defined macros
   14768 @cindex defining macros interactively
   14769 @cindex macros, user-defined
   14770 @item macro define @var{macro} @var{replacement-list}
   14771 @itemx macro define @var{macro}(@var{arglist}) @var{replacement-list}
   14772 Introduce a definition for a preprocessor macro named @var{macro},
   14773 invocations of which are replaced by the tokens given in
   14774 @var{replacement-list}.  The first form of this command defines an
   14775 ``object-like'' macro, which takes no arguments; the second form
   14776 defines a ``function-like'' macro, which takes the arguments given in
   14777 @var{arglist}.
   14778 
   14779 A definition introduced by this command is in scope in every
   14780 expression evaluated in @value{GDBN}, until it is removed with the
   14781 @code{macro undef} command, described below.  The definition overrides
   14782 all definitions for @var{macro} present in the program being debugged,
   14783 as well as any previous user-supplied definition.
   14784 
   14785 @kindex macro undef
   14786 @item macro undef @var{macro}
   14787 Remove any user-supplied definition for the macro named @var{macro}.
   14788 This command only affects definitions provided with the @code{macro
   14789 define} command, described above; it cannot remove definitions present
   14790 in the program being debugged.
   14791 
   14792 @kindex macro list
   14793 @item macro list
   14794 List all the macros defined using the @code{macro define} command.
   14795 @end table
   14796 
   14797 @cindex macros, example of debugging with
   14798 Here is a transcript showing the above commands in action.  First, we
   14799 show our source files:
   14800 
   14801 @smallexample
   14802 $ cat sample.c
   14803 #include <stdio.h>
   14804 #include "sample.h"
   14805 
   14806 #define M 42
   14807 #define ADD(x) (M + x)
   14808 
   14809 main ()
   14810 @{
   14811 #define N 28
   14812   printf ("Hello, world!\n");
   14813 #undef N
   14814   printf ("We're so creative.\n");
   14815 #define N 1729
   14816   printf ("Goodbye, world!\n");
   14817 @}
   14818 $ cat sample.h
   14819 #define Q <
   14820 $
   14821 @end smallexample
   14822 
   14823 Now, we compile the program using the @sc{gnu} C compiler,
   14824 @value{NGCC}.  We pass the @option{-gdwarf-2}@footnote{This is the
   14825 minimum.  Recent versions of @value{NGCC} support @option{-gdwarf-3}
   14826 and @option{-gdwarf-4}; we recommend always choosing the most recent
   14827 version of DWARF.} @emph{and} @option{-g3} flags to ensure the compiler
   14828 includes information about preprocessor macros in the debugging
   14829 information.
   14830 
   14831 @smallexample
   14832 $ gcc -gdwarf-2 -g3 sample.c -o sample
   14833 $
   14834 @end smallexample
   14835 
   14836 Now, we start @value{GDBN} on our sample program:
   14837 
   14838 @smallexample
   14839 $ gdb -nw sample
   14840 GNU gdb 2002-05-06-cvs
   14841 Copyright 2002 Free Software Foundation, Inc.
   14842 GDB is free software, @dots{}
   14843 (@value{GDBP})
   14844 @end smallexample
   14845 
   14846 We can expand macros and examine their definitions, even when the
   14847 program is not running.  @value{GDBN} uses the current listing position
   14848 to decide which macro definitions are in scope:
   14849 
   14850 @smallexample
   14851 (@value{GDBP}) list main
   14852 3
   14853 4       #define M 42
   14854 5       #define ADD(x) (M + x)
   14855 6
   14856 7       main ()
   14857 8       @{
   14858 9       #define N 28
   14859 10        printf ("Hello, world!\n");
   14860 11      #undef N
   14861 12        printf ("We're so creative.\n");
   14862 (@value{GDBP}) info macro ADD
   14863 Defined at /home/jimb/gdb/macros/play/sample.c:5
   14864 #define ADD(x) (M + x)
   14865 (@value{GDBP}) info macro Q
   14866 Defined at /home/jimb/gdb/macros/play/sample.h:1
   14867   included at /home/jimb/gdb/macros/play/sample.c:2
   14868 #define Q <
   14869 (@value{GDBP}) macro expand ADD(1)
   14870 expands to: (42 + 1)
   14871 (@value{GDBP}) macro expand-once ADD(1)
   14872 expands to: once (M + 1)
   14873 (@value{GDBP})
   14874 @end smallexample
   14875 
   14876 In the example above, note that @code{macro expand-once} expands only
   14877 the macro invocation explicit in the original text --- the invocation of
   14878 @code{ADD} --- but does not expand the invocation of the macro @code{M},
   14879 which was introduced by @code{ADD}.
   14880 
   14881 Once the program is running, @value{GDBN} uses the macro definitions in
   14882 force at the source line of the current stack frame:
   14883 
   14884 @smallexample
   14885 (@value{GDBP}) break main
   14886 Breakpoint 1 at 0x8048370: file sample.c, line 10.
   14887 (@value{GDBP}) run
   14888 Starting program: /home/jimb/gdb/macros/play/sample
   14889 
   14890 Breakpoint 1, main () at sample.c:10
   14891 10        printf ("Hello, world!\n");
   14892 (@value{GDBP})
   14893 @end smallexample
   14894 
   14895 At line 10, the definition of the macro @code{N} at line 9 is in force:
   14896 
   14897 @smallexample
   14898 (@value{GDBP}) info macro N
   14899 Defined at /home/jimb/gdb/macros/play/sample.c:9
   14900 #define N 28
   14901 (@value{GDBP}) macro expand N Q M
   14902 expands to: 28 < 42
   14903 (@value{GDBP}) print N Q M
   14904 $1 = 1
   14905 (@value{GDBP})
   14906 @end smallexample
   14907 
   14908 As we step over directives that remove @code{N}'s definition, and then
   14909 give it a new definition, @value{GDBN} finds the definition (or lack
   14910 thereof) in force at each point:
   14911 
   14912 @smallexample
   14913 (@value{GDBP}) next
   14914 Hello, world!
   14915 12        printf ("We're so creative.\n");
   14916 (@value{GDBP}) info macro N
   14917 The symbol `N' has no definition as a C/C++ preprocessor macro
   14918 at /home/jimb/gdb/macros/play/sample.c:12
   14919 (@value{GDBP}) next
   14920 We're so creative.
   14921 14        printf ("Goodbye, world!\n");
   14922 (@value{GDBP}) info macro N
   14923 Defined at /home/jimb/gdb/macros/play/sample.c:13
   14924 #define N 1729
   14925 (@value{GDBP}) macro expand N Q M
   14926 expands to: 1729 < 42
   14927 (@value{GDBP}) print N Q M
   14928 $2 = 0
   14929 (@value{GDBP})
   14930 @end smallexample
   14931 
   14932 In addition to source files, macros can be defined on the compilation command
   14933 line using the @option{-D@var{name}=@var{value}} syntax.  For macros defined in
   14934 such a way, @value{GDBN} displays the location of their definition as line zero
   14935 of the source file submitted to the compiler.
   14936 
   14937 @smallexample
   14938 (@value{GDBP}) info macro __STDC__
   14939 Defined at /home/jimb/gdb/macros/play/sample.c:0
   14940 -D__STDC__=1
   14941 (@value{GDBP})
   14942 @end smallexample
   14943 
   14944 
   14945 @node Tracepoints
   14946 @chapter Tracepoints
   14947 @c This chapter is based on the documentation written by Michael
   14948 @c Snyder, David Taylor, Jim Blandy, and Elena Zannoni.
   14949 
   14950 @cindex tracepoints
   14951 In some applications, it is not feasible for the debugger to interrupt
   14952 the program's execution long enough for the developer to learn
   14953 anything helpful about its behavior.  If the program's correctness
   14954 depends on its real-time behavior, delays introduced by a debugger
   14955 might cause the program to change its behavior drastically, or perhaps
   14956 fail, even when the code itself is correct.  It is useful to be able
   14957 to observe the program's behavior without interrupting it.
   14958 
   14959 Using @value{GDBN}'s @code{trace} and @code{collect} commands, you can
   14960 specify locations in the program, called @dfn{tracepoints}, and
   14961 arbitrary expressions to evaluate when those tracepoints are reached.
   14962 Later, using the @code{tfind} command, you can examine the values
   14963 those expressions had when the program hit the tracepoints.  The
   14964 expressions may also denote objects in memory---structures or arrays,
   14965 for example---whose values @value{GDBN} should record; while visiting
   14966 a particular tracepoint, you may inspect those objects as if they were
   14967 in memory at that moment.  However, because @value{GDBN} records these
   14968 values without interacting with you, it can do so quickly and
   14969 unobtrusively, hopefully not disturbing the program's behavior.
   14970 
   14971 The tracepoint facility is currently available only for remote
   14972 targets.  @xref{Targets}.  In addition, your remote target must know
   14973 how to collect trace data.  This functionality is implemented in the
   14974 remote stub; however, none of the stubs distributed with @value{GDBN}
   14975 support tracepoints as of this writing.  The format of the remote
   14976 packets used to implement tracepoints are described in @ref{Tracepoint
   14977 Packets}.
   14978 
   14979 It is also possible to get trace data from a file, in a manner reminiscent
   14980 of corefiles; you specify the filename, and use @code{tfind} to search
   14981 through the file.  @xref{Trace Files}, for more details.
   14982 
   14983 This chapter describes the tracepoint commands and features.
   14984 
   14985 @menu
   14986 * Set Tracepoints::
   14987 * Analyze Collected Data::
   14988 * Tracepoint Variables::
   14989 * Trace Files::
   14990 @end menu
   14991 
   14992 @node Set Tracepoints
   14993 @section Commands to Set Tracepoints
   14994 
   14995 Before running such a @dfn{trace experiment}, an arbitrary number of
   14996 tracepoints can be set.  A tracepoint is actually a special type of
   14997 breakpoint (@pxref{Set Breaks}), so you can manipulate it using
   14998 standard breakpoint commands.  For instance, as with breakpoints,
   14999 tracepoint numbers are successive integers starting from one, and many
   15000 of the commands associated with tracepoints take the tracepoint number
   15001 as their argument, to identify which tracepoint to work on.
   15002 
   15003 For each tracepoint, you can specify, in advance, some arbitrary set
   15004 of data that you want the target to collect in the trace buffer when
   15005 it hits that tracepoint.  The collected data can include registers,
   15006 local variables, or global data.  Later, you can use @value{GDBN}
   15007 commands to examine the values these data had at the time the
   15008 tracepoint was hit.
   15009 
   15010 Tracepoints do not support every breakpoint feature.  Ignore counts on
   15011 tracepoints have no effect, and tracepoints cannot run @value{GDBN}
   15012 commands when they are hit.  Tracepoints may not be thread-specific
   15013 either.
   15014 
   15015 @cindex fast tracepoints
   15016 Some targets may support @dfn{fast tracepoints}, which are inserted in
   15017 a different way (such as with a jump instead of a trap), that is
   15018 faster but possibly restricted in where they may be installed.
   15019 
   15020 @cindex static tracepoints
   15021 @cindex markers, static tracepoints
   15022 @cindex probing markers, static tracepoints
   15023 Regular and fast tracepoints are dynamic tracing facilities, meaning
   15024 that they can be used to insert tracepoints at (almost) any location
   15025 in the target.  Some targets may also support controlling @dfn{static
   15026 tracepoints} from @value{GDBN}.  With static tracing, a set of
   15027 instrumentation points, also known as @dfn{markers}, are embedded in
   15028 the target program, and can be activated or deactivated by name or
   15029 address.  These are usually placed at locations which facilitate
   15030 investigating what the target is actually doing.  @value{GDBN}'s
   15031 support for static tracing includes being able to list instrumentation
   15032 points, and attach them with @value{GDBN} defined high level
   15033 tracepoints that expose the whole range of convenience of
   15034 @value{GDBN}'s tracepoints support.  Namely, support for collecting
   15035 registers values and values of global or local (to the instrumentation
   15036 point) variables; tracepoint conditions and trace state variables.
   15037 The act of installing a @value{GDBN} static tracepoint on an
   15038 instrumentation point, or marker, is referred to as @dfn{probing} a
   15039 static tracepoint marker.
   15040 
   15041 @code{gdbserver} supports tracepoints on some target systems.
   15042 @xref{Server,,Tracepoints support in @code{gdbserver}}.
   15043 
   15044 This section describes commands to set tracepoints and associated
   15045 conditions and actions.
   15046 
   15047 @menu
   15048 * Create and Delete Tracepoints::
   15049 * Enable and Disable Tracepoints::
   15050 * Tracepoint Passcounts::
   15051 * Tracepoint Conditions::
   15052 * Trace State Variables::
   15053 * Tracepoint Actions::
   15054 * Listing Tracepoints::
   15055 * Listing Static Tracepoint Markers::
   15056 * Starting and Stopping Trace Experiments::
   15057 * Tracepoint Restrictions::
   15058 @end menu
   15059 
   15060 @node Create and Delete Tracepoints
   15061 @subsection Create and Delete Tracepoints
   15062 
   15063 @table @code
   15064 @cindex set tracepoint
   15065 @kindex trace
   15066 @item trace @var{locspec}
   15067 The @code{trace} command is very similar to the @code{break} command.
   15068 Its argument @var{locspec} can be any valid location specification.
   15069 @xref{Location Specifications}.  The @code{trace} command defines a tracepoint,
   15070 which is a point in the target program where the debugger will briefly stop,
   15071 collect some data, and then allow the program to continue.  Setting a tracepoint
   15072 or changing its actions takes effect immediately if the remote stub
   15073 supports the @samp{InstallInTrace} feature (@pxref{install tracepoint
   15074 in tracing}).
   15075 If remote stub doesn't support the @samp{InstallInTrace} feature, all
   15076 these changes don't take effect until the next @code{tstart}
   15077 command, and once a trace experiment is running, further changes will
   15078 not have any effect until the next trace experiment starts.  In addition,
   15079 @value{GDBN} supports @dfn{pending tracepoints}---tracepoints whose
   15080 address is not yet resolved.  (This is similar to pending breakpoints.)
   15081 Pending tracepoints are not downloaded to the target and not installed
   15082 until they are resolved.  The resolution of pending tracepoints requires
   15083 @value{GDBN} support---when debugging with the remote target, and
   15084 @value{GDBN} disconnects from the remote stub (@pxref{disconnected
   15085 tracing}), pending tracepoints can not be resolved (and downloaded to
   15086 the remote stub) while @value{GDBN} is disconnected.
   15087 
   15088 Here are some examples of using the @code{trace} command:
   15089 
   15090 @smallexample
   15091 (@value{GDBP}) @b{trace foo.c:121}    // a source file and line number
   15092 
   15093 (@value{GDBP}) @b{trace +2}           // 2 lines forward
   15094 
   15095 (@value{GDBP}) @b{trace my_function}  // first source line of function
   15096 
   15097 (@value{GDBP}) @b{trace *my_function} // EXACT start address of function
   15098 
   15099 (@value{GDBP}) @b{trace *0x2117c4}    // an address
   15100 @end smallexample
   15101 
   15102 @noindent
   15103 You can abbreviate @code{trace} as @code{tr}.
   15104 
   15105 @item trace @var{locspec} if @var{cond}
   15106 Set a tracepoint with condition @var{cond}; evaluate the expression
   15107 @var{cond} each time the tracepoint is reached, and collect data only
   15108 if the value is nonzero---that is, if @var{cond} evaluates as true.
   15109 @xref{Tracepoint Conditions, ,Tracepoint Conditions}, for more
   15110 information on tracepoint conditions.
   15111 
   15112 @item ftrace @var{locspec} [ if @var{cond} ]
   15113 @cindex set fast tracepoint
   15114 @cindex fast tracepoints, setting
   15115 @kindex ftrace
   15116 The @code{ftrace} command sets a fast tracepoint.  For targets that
   15117 support them, fast tracepoints will use a more efficient but possibly
   15118 less general technique to trigger data collection, such as a jump
   15119 instruction instead of a trap, or some sort of hardware support.  It
   15120 may not be possible to create a fast tracepoint at the desired
   15121 location, in which case the command will exit with an explanatory
   15122 message.
   15123 
   15124 @value{GDBN} handles arguments to @code{ftrace} exactly as for
   15125 @code{trace}.
   15126 
   15127 On 32-bit x86-architecture systems, fast tracepoints normally need to
   15128 be placed at an instruction that is 5 bytes or longer, but can be
   15129 placed at 4-byte instructions if the low 64K of memory of the target
   15130 program is available to install trampolines.  Some Unix-type systems,
   15131 such as @sc{gnu}/Linux, exclude low addresses from the program's
   15132 address space; but for instance with the Linux kernel it is possible
   15133 to let @value{GDBN} use this area by doing a @command{sysctl} command
   15134 to set the @code{mmap_min_addr} kernel parameter, as in
   15135 
   15136 @example
   15137 sudo sysctl -w vm.mmap_min_addr=32768
   15138 @end example
   15139 
   15140 @noindent
   15141 which sets the low address to 32K, which leaves plenty of room for
   15142 trampolines.  The minimum address should be set to a page boundary.
   15143 
   15144 @item strace [@var{locspec} | -m @var{marker}] [ if @var{cond} ]
   15145 @cindex set static tracepoint
   15146 @cindex static tracepoints, setting
   15147 @cindex probe static tracepoint marker
   15148 @kindex strace
   15149 The @code{strace} command sets a static tracepoint.  For targets that
   15150 support it, setting a static tracepoint probes a static
   15151 instrumentation point, or marker, found at the code locations that
   15152 result from resolving @var{locspec}.  It may not be possible to set a
   15153 static tracepoint at the desired code location, in which case the
   15154 command will exit with an explanatory message.
   15155 
   15156 @value{GDBN} handles arguments to @code{strace} exactly as for
   15157 @code{trace}, with the addition that the user can also specify
   15158 @code{-m @var{marker}} instead of a location spec.  This probes the marker
   15159 identified by the @var{marker} string identifier.  This identifier
   15160 depends on the static tracepoint backend library your program is
   15161 using.  You can find all the marker identifiers in the @samp{ID} field
   15162 of the @code{info static-tracepoint-markers} command output.
   15163 @xref{Listing Static Tracepoint Markers,,Listing Static Tracepoint
   15164 Markers}.  For example, in the following small program using the UST
   15165 tracing engine:
   15166 
   15167 @smallexample
   15168 main ()
   15169 @{
   15170   trace_mark(ust, bar33, "str %s", "FOOBAZ");
   15171 @}
   15172 @end smallexample
   15173 
   15174 @noindent
   15175 the marker id is composed of joining the first two arguments to the
   15176 @code{trace_mark} call with a slash, which translates to:
   15177 
   15178 @smallexample
   15179 (@value{GDBP}) info static-tracepoint-markers
   15180 Cnt Enb ID         Address            What
   15181 1   n   ust/bar33  0x0000000000400ddc in main at stexample.c:22
   15182          Data: "str %s"
   15183 [etc...]
   15184 @end smallexample
   15185 
   15186 @noindent
   15187 so you may probe the marker above with:
   15188 
   15189 @smallexample
   15190 (@value{GDBP}) strace -m ust/bar33
   15191 @end smallexample
   15192 
   15193 Static tracepoints accept an extra collect action --- @code{collect
   15194 $_sdata}.  This collects arbitrary user data passed in the probe point
   15195 call to the tracing library.  In the UST example above, you'll see
   15196 that the third argument to @code{trace_mark} is a printf-like format
   15197 string.  The user data is then the result of running that formatting
   15198 string against the following arguments.  Note that @code{info
   15199 static-tracepoint-markers} command output lists that format string in
   15200 the @samp{Data:} field.
   15201 
   15202 You can inspect this data when analyzing the trace buffer, by printing
   15203 the $_sdata variable like any other variable available to
   15204 @value{GDBN}.  @xref{Tracepoint Actions,,Tracepoint Action Lists}.
   15205 
   15206 @vindex $tpnum
   15207 @cindex last tracepoint number
   15208 @cindex recent tracepoint number
   15209 @cindex tracepoint number
   15210 The convenience variable @code{$tpnum} records the tracepoint number
   15211 of the most recently set tracepoint.
   15212 
   15213 @kindex delete tracepoint
   15214 @cindex tracepoint deletion
   15215 @item delete tracepoint @r{[}@var{num}@r{]}
   15216 Permanently delete one or more tracepoints.  With no argument, the
   15217 default is to delete all tracepoints.  Note that the regular
   15218 @code{delete} command can remove tracepoints also.
   15219 
   15220 Examples:
   15221 
   15222 @smallexample
   15223 (@value{GDBP}) @b{delete trace 1 2 3} // remove three tracepoints
   15224 
   15225 (@value{GDBP}) @b{delete trace}       // remove all tracepoints
   15226 @end smallexample
   15227 
   15228 @noindent
   15229 You can abbreviate this command as @code{del tr}.
   15230 @end table
   15231 
   15232 @node Enable and Disable Tracepoints
   15233 @subsection Enable and Disable Tracepoints
   15234 
   15235 These commands are deprecated; they are equivalent to plain @code{disable} and @code{enable}.
   15236 
   15237 @table @code
   15238 @kindex disable tracepoint
   15239 @item disable tracepoint @r{[}@var{num}@r{]}
   15240 Disable tracepoint @var{num}, or all tracepoints if no argument
   15241 @var{num} is given.  A disabled tracepoint will have no effect during
   15242 a trace experiment, but it is not forgotten.  You can re-enable
   15243 a disabled tracepoint using the @code{enable tracepoint} command.
   15244 If the command is issued during a trace experiment and the debug target
   15245 has support for disabling tracepoints during a trace experiment, then the
   15246 change will be effective immediately.  Otherwise, it will be applied to the
   15247 next trace experiment.
   15248 
   15249 @kindex enable tracepoint
   15250 @item enable tracepoint @r{[}@var{num}@r{]}
   15251 Enable tracepoint @var{num}, or all tracepoints.  If this command is
   15252 issued during a trace experiment and the debug target supports enabling
   15253 tracepoints during a trace experiment, then the enabled tracepoints will
   15254 become effective immediately.  Otherwise, they will become effective the
   15255 next time a trace experiment is run.
   15256 @end table
   15257 
   15258 @node Tracepoint Passcounts
   15259 @subsection Tracepoint Passcounts
   15260 
   15261 @table @code
   15262 @kindex passcount
   15263 @cindex tracepoint pass count
   15264 @item passcount @r{[}@var{n} @r{[}@var{num}@r{]]}
   15265 Set the @dfn{passcount} of a tracepoint.  The passcount is a way to
   15266 automatically stop a trace experiment.  If a tracepoint's passcount is
   15267 @var{n}, then the trace experiment will be automatically stopped on
   15268 the @var{n}'th time that tracepoint is hit.  If the tracepoint number
   15269 @var{num} is not specified, the @code{passcount} command sets the
   15270 passcount of the most recently defined tracepoint.  If no passcount is
   15271 given, the trace experiment will run until stopped explicitly by the
   15272 user.
   15273 
   15274 Examples:
   15275 
   15276 @smallexample
   15277 (@value{GDBP}) @b{passcount 5 2} // Stop on the 5th execution of
   15278 @exdent @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @code{// tracepoint 2}
   15279 
   15280 (@value{GDBP}) @b{passcount 12}  // Stop on the 12th execution of the
   15281 @exdent @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @code{// most recently defined tracepoint.}
   15282 (@value{GDBP}) @b{trace foo}
   15283 (@value{GDBP}) @b{pass 3}
   15284 (@value{GDBP}) @b{trace bar}
   15285 (@value{GDBP}) @b{pass 2}
   15286 (@value{GDBP}) @b{trace baz}
   15287 (@value{GDBP}) @b{pass 1}        // Stop tracing when foo has been
   15288 @exdent @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @code{// executed 3 times OR when bar has}
   15289 @exdent @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @code{// been executed 2 times}
   15290 @exdent @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @code{// OR when baz has been executed 1 time.}
   15291 @end smallexample
   15292 @end table
   15293 
   15294 @node Tracepoint Conditions
   15295 @subsection Tracepoint Conditions
   15296 @cindex conditional tracepoints
   15297 @cindex tracepoint conditions
   15298 
   15299 The simplest sort of tracepoint collects data every time your program
   15300 reaches a specified place.  You can also specify a @dfn{condition} for
   15301 a tracepoint.  A condition is just a Boolean expression in your
   15302 programming language (@pxref{Expressions, ,Expressions}).  A
   15303 tracepoint with a condition evaluates the expression each time your
   15304 program reaches it, and data collection happens only if the condition
   15305 is true.
   15306 
   15307 Tracepoint conditions can be specified when a tracepoint is set, by
   15308 using @samp{if} in the arguments to the @code{trace} command.
   15309 @xref{Create and Delete Tracepoints, ,Setting Tracepoints}.  They can
   15310 also be set or changed at any time with the @code{condition} command,
   15311 just as with breakpoints.
   15312 
   15313 Unlike breakpoint conditions, @value{GDBN} does not actually evaluate
   15314 the conditional expression itself.  Instead, @value{GDBN} encodes the
   15315 expression into an agent expression (@pxref{Agent Expressions})
   15316 suitable for execution on the target, independently of @value{GDBN}.
   15317 Global variables become raw memory locations, locals become stack
   15318 accesses, and so forth.
   15319 
   15320 For instance, suppose you have a function that is usually called
   15321 frequently, but should not be called after an error has occurred.  You
   15322 could use the following tracepoint command to collect data about calls
   15323 of that function that happen while the error code is propagating
   15324 through the program; an unconditional tracepoint could end up
   15325 collecting thousands of useless trace frames that you would have to
   15326 search through.
   15327 
   15328 @smallexample
   15329 (@value{GDBP}) @kbd{trace normal_operation if errcode > 0}
   15330 @end smallexample
   15331 
   15332 @node Trace State Variables
   15333 @subsection Trace State Variables
   15334 @cindex trace state variables
   15335 
   15336 A @dfn{trace state variable} is a special type of variable that is
   15337 created and managed by target-side code.  The syntax is the same as
   15338 that for GDB's convenience variables (a string prefixed with ``$''),
   15339 but they are stored on the target.  They must be created explicitly,
   15340 using a @code{tvariable} command.  They are always 64-bit signed
   15341 integers.
   15342 
   15343 Trace state variables are remembered by @value{GDBN}, and downloaded
   15344 to the target along with tracepoint information when the trace
   15345 experiment starts.  There are no intrinsic limits on the number of
   15346 trace state variables, beyond memory limitations of the target.
   15347 
   15348 @cindex convenience variables, and trace state variables
   15349 Although trace state variables are managed by the target, you can use
   15350 them in print commands and expressions as if they were convenience
   15351 variables; @value{GDBN} will get the current value from the target
   15352 while the trace experiment is running.  Trace state variables share
   15353 the same namespace as other ``$'' variables, which means that you
   15354 cannot have trace state variables with names like @code{$23} or
   15355 @code{$pc}, nor can you have a trace state variable and a convenience
   15356 variable with the same name.
   15357 
   15358 @table @code
   15359 
   15360 @item tvariable $@var{name} [ = @var{expression} ]
   15361 @kindex tvariable
   15362 The @code{tvariable} command creates a new trace state variable named
   15363 @code{$@var{name}}, and optionally gives it an initial value of
   15364 @var{expression}.  The @var{expression} is evaluated when this command is
   15365 entered; the result will be converted to an integer if possible,
   15366 otherwise @value{GDBN} will report an error. A subsequent
   15367 @code{tvariable} command specifying the same name does not create a
   15368 variable, but instead assigns the supplied initial value to the
   15369 existing variable of that name, overwriting any previous initial
   15370 value. The default initial value is 0.
   15371 
   15372 @item info tvariables
   15373 @kindex info tvariables
   15374 List all the trace state variables along with their initial values.
   15375 Their current values may also be displayed, if the trace experiment is
   15376 currently running.
   15377 
   15378 @item delete tvariable @r{[} $@var{name} @dots{} @r{]}
   15379 @kindex delete tvariable
   15380 Delete the given trace state variables, or all of them if no arguments
   15381 are specified.
   15382 
   15383 @end table
   15384 
   15385 @node Tracepoint Actions
   15386 @subsection Tracepoint Action Lists
   15387 
   15388 @table @code
   15389 @kindex actions
   15390 @cindex tracepoint actions
   15391 @item actions @r{[}@var{num}@r{]}
   15392 This command will prompt for a list of actions to be taken when the
   15393 tracepoint is hit.  If the tracepoint number @var{num} is not
   15394 specified, this command sets the actions for the one that was most
   15395 recently defined (so that you can define a tracepoint and then say
   15396 @code{actions} without bothering about its number).  You specify the
   15397 actions themselves on the following lines, one action at a time, and
   15398 terminate the actions list with a line containing just @code{end}.  So
   15399 far, the only defined actions are @code{collect}, @code{teval}, and
   15400 @code{while-stepping}.
   15401 
   15402 @code{actions} is actually equivalent to @code{commands} (@pxref{Break
   15403 Commands, ,Breakpoint Command Lists}), except that only the defined
   15404 actions are allowed; any other @value{GDBN} command is rejected.
   15405 
   15406 @cindex remove actions from a tracepoint
   15407 To remove all actions from a tracepoint, type @samp{actions @var{num}}
   15408 and follow it immediately with @samp{end}.
   15409 
   15410 @smallexample
   15411 (@value{GDBP}) @b{collect @var{data}} // collect some data
   15412 
   15413 (@value{GDBP}) @b{while-stepping 5} // single-step 5 times, collect data
   15414 
   15415 (@value{GDBP}) @b{end}              // signals the end of actions.
   15416 @end smallexample
   15417 
   15418 In the following example, the action list begins with @code{collect}
   15419 commands indicating the things to be collected when the tracepoint is
   15420 hit.  Then, in order to single-step and collect additional data
   15421 following the tracepoint, a @code{while-stepping} command is used,
   15422 followed by the list of things to be collected after each step in a
   15423 sequence of single steps.  The @code{while-stepping} command is
   15424 terminated by its own separate @code{end} command.  Lastly, the action
   15425 list is terminated by an @code{end} command.
   15426 
   15427 @smallexample
   15428 (@value{GDBP}) @b{trace foo}
   15429 (@value{GDBP}) @b{actions}
   15430 Enter actions for tracepoint 1, one per line:
   15431 > collect bar,baz
   15432 > collect $regs
   15433 > while-stepping 12
   15434   > collect $pc, arr[i]
   15435   > end
   15436 end
   15437 @end smallexample
   15438 
   15439 @kindex collect @r{(tracepoints)}
   15440 @item collect@r{[}/@var{mods}@r{]} @var{expr1}, @var{expr2}, @dots{}
   15441 Collect values of the given expressions when the tracepoint is hit.
   15442 This command accepts a comma-separated list of any valid expressions.
   15443 In addition to global, static, or local variables, the following
   15444 special arguments are supported:
   15445 
   15446 @table @code
   15447 @item $regs
   15448 Collect all registers.
   15449 
   15450 @item $args
   15451 Collect all function arguments.
   15452 
   15453 @item $locals
   15454 Collect all local variables.
   15455 
   15456 @item $_ret
   15457 Collect the return address.  This is helpful if you want to see more
   15458 of a backtrace.
   15459 
   15460 @emph{Note:} The return address location can not always be reliably
   15461 determined up front, and the wrong address / registers may end up
   15462 collected instead.  On some architectures the reliability is higher
   15463 for tracepoints at function entry, while on others it's the opposite.
   15464 When this happens, backtracing will stop because the return address is
   15465 found unavailable (unless another collect rule happened to match it).
   15466 
   15467 @item $_probe_argc
   15468 Collects the number of arguments from the static probe at which the
   15469 tracepoint is located.
   15470 @xref{Static Probe Points}.
   15471 
   15472 @item $_probe_arg@var{n}
   15473 @var{n} is an integer between 0 and 11.  Collects the @var{n}th argument
   15474 from the static probe at which the tracepoint is located.
   15475 @xref{Static Probe Points}.
   15476 
   15477 @item $_sdata
   15478 @vindex $_sdata@r{, collect}
   15479 Collect static tracepoint marker specific data.  Only available for
   15480 static tracepoints.  @xref{Tracepoint Actions,,Tracepoint Action
   15481 Lists}.  On the UST static tracepoints library backend, an
   15482 instrumentation point resembles a @code{printf} function call.  The
   15483 tracing library is able to collect user specified data formatted to a
   15484 character string using the format provided by the programmer that
   15485 instrumented the program.  Other backends have similar mechanisms.
   15486 Here's an example of a UST marker call:
   15487 
   15488 @smallexample
   15489  const char master_name[] = "$your_name";
   15490  trace_mark(channel1, marker1, "hello %s", master_name)
   15491 @end smallexample
   15492 
   15493 In this case, collecting @code{$_sdata} collects the string
   15494 @samp{hello $yourname}.  When analyzing the trace buffer, you can
   15495 inspect @samp{$_sdata} like any other variable available to
   15496 @value{GDBN}.
   15497 @end table
   15498 
   15499 You can give several consecutive @code{collect} commands, each one
   15500 with a single argument, or one @code{collect} command with several
   15501 arguments separated by commas; the effect is the same.
   15502 
   15503 The optional @var{mods} changes the usual handling of the arguments.
   15504 @code{s} requests that pointers to chars be handled as strings, in
   15505 particular collecting the contents of the memory being pointed at, up
   15506 to the first zero.  The upper bound is by default the value of the
   15507 @code{print characters} variable; if @code{s} is followed by a decimal
   15508 number, that is the upper bound instead.  So for instance
   15509 @samp{collect/s25 mystr} collects as many as 25 characters at
   15510 @samp{mystr}.
   15511 
   15512 The command @code{info scope} (@pxref{Symbols, info scope}) is
   15513 particularly useful for figuring out what data to collect.
   15514 
   15515 @kindex teval @r{(tracepoints)}
   15516 @item teval @var{expr1}, @var{expr2}, @dots{}
   15517 Evaluate the given expressions when the tracepoint is hit.  This
   15518 command accepts a comma-separated list of expressions.  The results
   15519 are discarded, so this is mainly useful for assigning values to trace
   15520 state variables (@pxref{Trace State Variables}) without adding those
   15521 values to the trace buffer, as would be the case if the @code{collect}
   15522 action were used.
   15523 
   15524 @kindex while-stepping @r{(tracepoints)}
   15525 @item while-stepping @var{n}
   15526 Perform @var{n} single-step instruction traces after the tracepoint,
   15527 collecting new data after each step.  The @code{while-stepping}
   15528 command is followed by the list of what to collect while stepping
   15529 (followed by its own @code{end} command):
   15530 
   15531 @smallexample
   15532 > while-stepping 12
   15533   > collect $regs, myglobal
   15534   > end
   15535 >
   15536 @end smallexample
   15537 
   15538 @noindent
   15539 Note that @code{$pc} is not automatically collected by
   15540 @code{while-stepping}; you need to explicitly collect that register if
   15541 you need it.  You may abbreviate @code{while-stepping} as @code{ws} or
   15542 @code{stepping}.
   15543 
   15544 @item set default-collect @var{expr1}, @var{expr2}, @dots{}
   15545 @kindex set default-collect
   15546 @cindex default collection action
   15547 This variable is a list of expressions to collect at each tracepoint
   15548 hit.  It is effectively an additional @code{collect} action prepended
   15549 to every tracepoint action list.  The expressions are parsed
   15550 individually for each tracepoint, so for instance a variable named
   15551 @code{xyz} may be interpreted as a global for one tracepoint, and a
   15552 local for another, as appropriate to the tracepoint's location.
   15553 
   15554 @item show default-collect
   15555 @kindex show default-collect
   15556 Show the list of expressions that are collected by default at each
   15557 tracepoint hit.
   15558 
   15559 @end table
   15560 
   15561 @node Listing Tracepoints
   15562 @subsection Listing Tracepoints
   15563 
   15564 @table @code
   15565 @kindex info tracepoints @r{[}@var{n}@dots{}@r{]}
   15566 @kindex info tp @r{[}@var{n}@dots{}@r{]}
   15567 @cindex information about tracepoints
   15568 @item info tracepoints @r{[}@var{num}@dots{}@r{]}
   15569 Display information about the tracepoint @var{num}.  If you don't
   15570 specify a tracepoint number, displays information about all the
   15571 tracepoints defined so far.  The format is similar to that used for
   15572 @code{info breakpoints}; in fact, @code{info tracepoints} is the same
   15573 command, simply restricting itself to tracepoints.
   15574 
   15575 A tracepoint's listing may include additional information specific to
   15576 tracing:
   15577 
   15578 @itemize @bullet
   15579 @item
   15580 its passcount as given by the @code{passcount @var{n}} command
   15581 
   15582 @item
   15583 the state about installed on target of each location
   15584 @end itemize
   15585 
   15586 @smallexample
   15587 (@value{GDBP}) @b{info trace}
   15588 Num     Type           Disp Enb Address    What
   15589 1       tracepoint     keep y   0x0804ab57 in foo() at main.cxx:7
   15590         while-stepping 20
   15591           collect globfoo, $regs
   15592         end
   15593         collect globfoo2
   15594         end
   15595         pass count 1200 
   15596 2       tracepoint     keep y   <MULTIPLE>
   15597         collect $eip
   15598 2.1                         y     0x0804859c in func4 at change-loc.h:35
   15599         installed on target
   15600 2.2                         y     0xb7ffc480 in func4 at change-loc.h:35
   15601         installed on target
   15602 2.3                         y     <PENDING>  set_tracepoint
   15603 3       tracepoint     keep y   0x080485b1 in foo at change-loc.c:29
   15604         not installed on target
   15605 (@value{GDBP})
   15606 @end smallexample
   15607 
   15608 @noindent
   15609 This command can be abbreviated @code{info tp}.
   15610 @end table
   15611 
   15612 @node Listing Static Tracepoint Markers
   15613 @subsection Listing Static Tracepoint Markers
   15614 
   15615 @table @code
   15616 @kindex info static-tracepoint-markers
   15617 @cindex information about static tracepoint markers
   15618 @item info static-tracepoint-markers
   15619 Display information about all static tracepoint markers defined in the
   15620 program.
   15621 
   15622 For each marker, the following columns are printed:
   15623 
   15624 @table @emph
   15625 @item Count
   15626 An incrementing counter, output to help readability.  This is not a
   15627 stable identifier.
   15628 @item ID
   15629 The marker ID, as reported by the target.
   15630 @item Enabled or Disabled
   15631 Probed markers are tagged with @samp{y}.  @samp{n} identifies marks
   15632 that are not enabled.
   15633 @item Address
   15634 Where the marker is in your program, as a memory address.
   15635 @item What
   15636 Where the marker is in the source for your program, as a file and line
   15637 number.  If the debug information included in the program does not
   15638 allow @value{GDBN} to locate the source of the marker, this column
   15639 will be left blank.
   15640 @end table
   15641 
   15642 @noindent
   15643 In addition, the following information may be printed for each marker:
   15644 
   15645 @table @emph
   15646 @item Data
   15647 User data passed to the tracing library by the marker call.  In the
   15648 UST backend, this is the format string passed as argument to the
   15649 marker call.
   15650 @item Static tracepoints probing the marker
   15651 The list of static tracepoints attached to the marker.
   15652 @end table
   15653 
   15654 @smallexample
   15655 (@value{GDBP}) info static-tracepoint-markers
   15656 Cnt ID         Enb Address            What
   15657 1   ust/bar2   y   0x0000000000400e1a in main at stexample.c:25
   15658      Data: number1 %d number2 %d
   15659      Probed by static tracepoints: #2
   15660 2   ust/bar33  n   0x0000000000400c87 in main at stexample.c:24
   15661      Data: str %s
   15662 (@value{GDBP})
   15663 @end smallexample
   15664 @end table
   15665 
   15666 @node Starting and Stopping Trace Experiments
   15667 @subsection Starting and Stopping Trace Experiments
   15668 
   15669 @table @code
   15670 @kindex tstart [ @var{notes} ]
   15671 @cindex start a new trace experiment
   15672 @cindex collected data discarded
   15673 @item tstart
   15674 This command starts the trace experiment, and begins collecting data.
   15675 It has the side effect of discarding all the data collected in the
   15676 trace buffer during the previous trace experiment.  If any arguments
   15677 are supplied, they are taken as a note and stored with the trace
   15678 experiment's state.  The notes may be arbitrary text, and are
   15679 especially useful with disconnected tracing in a multi-user context;
   15680 the notes can explain what the trace is doing, supply user contact
   15681 information, and so forth.
   15682 
   15683 @kindex tstop [ @var{notes} ]
   15684 @cindex stop a running trace experiment
   15685 @item tstop
   15686 This command stops the trace experiment.  If any arguments are
   15687 supplied, they are recorded with the experiment as a note.  This is
   15688 useful if you are stopping a trace started by someone else, for
   15689 instance if the trace is interfering with the system's behavior and
   15690 needs to be stopped quickly.
   15691 
   15692 @strong{Note}: a trace experiment and data collection may stop
   15693 automatically if any tracepoint's passcount is reached
   15694 (@pxref{Tracepoint Passcounts}), or if the trace buffer becomes full.
   15695 
   15696 @kindex tstatus
   15697 @cindex status of trace data collection
   15698 @cindex trace experiment, status of
   15699 @item tstatus
   15700 This command displays the status of the current trace data
   15701 collection.
   15702 @end table
   15703 
   15704 Here is an example of the commands we described so far:
   15705 
   15706 @smallexample
   15707 (@value{GDBP}) @b{trace gdb_c_test}
   15708 (@value{GDBP}) @b{actions}
   15709 Enter actions for tracepoint #1, one per line.
   15710 > collect $regs,$locals,$args
   15711 > while-stepping 11
   15712   > collect $regs
   15713   > end
   15714 > end
   15715 (@value{GDBP}) @b{tstart}
   15716 	[time passes @dots{}]
   15717 (@value{GDBP}) @b{tstop}
   15718 @end smallexample
   15719 
   15720 @anchor{disconnected tracing}
   15721 @cindex disconnected tracing
   15722 You can choose to continue running the trace experiment even if
   15723 @value{GDBN} disconnects from the target, voluntarily or
   15724 involuntarily.  For commands such as @code{detach}, the debugger will
   15725 ask what you want to do with the trace.  But for unexpected
   15726 terminations (@value{GDBN} crash, network outage), it would be
   15727 unfortunate to lose hard-won trace data, so the variable
   15728 @code{disconnected-tracing} lets you decide whether the trace should
   15729 continue running without @value{GDBN}.
   15730 
   15731 @table @code
   15732 @item set disconnected-tracing on
   15733 @itemx set disconnected-tracing off
   15734 @kindex set disconnected-tracing
   15735 Choose whether a tracing run should continue to run if @value{GDBN}
   15736 has disconnected from the target.  Note that @code{detach} or
   15737 @code{quit} will ask you directly what to do about a running trace no
   15738 matter what this variable's setting, so the variable is mainly useful
   15739 for handling unexpected situations, such as loss of the network.
   15740 
   15741 @item show disconnected-tracing
   15742 @kindex show disconnected-tracing
   15743 Show the current choice for disconnected tracing.
   15744 
   15745 @end table
   15746 
   15747 When you reconnect to the target, the trace experiment may or may not
   15748 still be running; it might have filled the trace buffer in the
   15749 meantime, or stopped for one of the other reasons.  If it is running,
   15750 it will continue after reconnection.
   15751 
   15752 Upon reconnection, the target will upload information about the
   15753 tracepoints in effect.  @value{GDBN} will then compare that
   15754 information to the set of tracepoints currently defined, and attempt
   15755 to match them up, allowing for the possibility that the numbers may
   15756 have changed due to creation and deletion in the meantime.  If one of
   15757 the target's tracepoints does not match any in @value{GDBN}, the
   15758 debugger will create a new tracepoint, so that you have a number with
   15759 which to specify that tracepoint.  This matching-up process is
   15760 necessarily heuristic, and it may result in useless tracepoints being
   15761 created; you may simply delete them if they are of no use.
   15762 
   15763 @cindex circular trace buffer
   15764 If your target agent supports a @dfn{circular trace buffer}, then you
   15765 can run a trace experiment indefinitely without filling the trace
   15766 buffer; when space runs out, the agent deletes already-collected trace
   15767 frames, oldest first, until there is enough room to continue
   15768 collecting.  This is especially useful if your tracepoints are being
   15769 hit too often, and your trace gets terminated prematurely because the
   15770 buffer is full.  To ask for a circular trace buffer, simply set
   15771 @samp{circular-trace-buffer} to on.  You can set this at any time,
   15772 including during tracing; if the agent can do it, it will change
   15773 buffer handling on the fly, otherwise it will not take effect until
   15774 the next run.
   15775 
   15776 @table @code
   15777 @item set circular-trace-buffer on
   15778 @itemx set circular-trace-buffer off
   15779 @kindex set circular-trace-buffer
   15780 Choose whether a tracing run should use a linear or circular buffer
   15781 for trace data.  A linear buffer will not lose any trace data, but may
   15782 fill up prematurely, while a circular buffer will discard old trace
   15783 data, but it will have always room for the latest tracepoint hits.
   15784 
   15785 @item show circular-trace-buffer
   15786 @kindex show circular-trace-buffer
   15787 Show the current choice for the trace buffer.  Note that this may not
   15788 match the agent's current buffer handling, nor is it guaranteed to
   15789 match the setting that might have been in effect during a past run,
   15790 for instance if you are looking at frames from a trace file.
   15791 
   15792 @end table
   15793 
   15794 @table @code
   15795 @item set trace-buffer-size @var{n}
   15796 @itemx set trace-buffer-size unlimited
   15797 @kindex set trace-buffer-size
   15798 Request that the target use a trace buffer of @var{n} bytes.  Not all
   15799 targets will honor the request; they may have a compiled-in size for
   15800 the trace buffer, or some other limitation.  Set to a value of
   15801 @code{unlimited} or @code{-1} to let the target use whatever size it
   15802 likes.  This is also the default.
   15803 
   15804 @item show trace-buffer-size
   15805 @kindex show trace-buffer-size
   15806 Show the current requested size for the trace buffer.  Note that this
   15807 will only match the actual size if the target supports size-setting,
   15808 and was able to handle the requested size.  For instance, if the
   15809 target can only change buffer size between runs, this variable will
   15810 not reflect the change until the next run starts.  Use @code{tstatus}
   15811 to get a report of the actual buffer size.
   15812 @end table
   15813 
   15814 @table @code
   15815 @item set trace-user @var{text}
   15816 @kindex set trace-user
   15817 
   15818 @item show trace-user
   15819 @kindex show trace-user
   15820 
   15821 @item set trace-notes @var{text}
   15822 @kindex set trace-notes
   15823 Set the trace run's notes.
   15824 
   15825 @item show trace-notes
   15826 @kindex show trace-notes
   15827 Show the trace run's notes.
   15828 
   15829 @item set trace-stop-notes @var{text}
   15830 @kindex set trace-stop-notes
   15831 Set the trace run's stop notes.  The handling of the note is as for
   15832 @code{tstop} arguments; the set command is convenient way to fix a
   15833 stop note that is mistaken or incomplete.
   15834 
   15835 @item show trace-stop-notes
   15836 @kindex show trace-stop-notes
   15837 Show the trace run's stop notes.
   15838 
   15839 @end table
   15840 
   15841 @node Tracepoint Restrictions
   15842 @subsection Tracepoint Restrictions
   15843 
   15844 @cindex tracepoint restrictions
   15845 There are a number of restrictions on the use of tracepoints.  As
   15846 described above, tracepoint data gathering occurs on the target
   15847 without interaction from @value{GDBN}.  Thus the full capabilities of
   15848 the debugger are not available during data gathering, and then at data
   15849 examination time, you will be limited by only having what was
   15850 collected.  The following items describe some common problems, but it
   15851 is not exhaustive, and you may run into additional difficulties not
   15852 mentioned here.
   15853 
   15854 @itemize @bullet
   15855 
   15856 @item
   15857 Tracepoint expressions are intended to gather objects (lvalues).  Thus
   15858 the full flexibility of GDB's expression evaluator is not available.
   15859 You cannot call functions, cast objects to aggregate types, access
   15860 convenience variables or modify values (except by assignment to trace
   15861 state variables).  Some language features may implicitly call
   15862 functions (for instance Objective-C fields with accessors), and therefore
   15863 cannot be collected either.
   15864 
   15865 @item
   15866 Collection of local variables, either individually or in bulk with
   15867 @code{$locals} or @code{$args}, during @code{while-stepping} may
   15868 behave erratically.  The stepping action may enter a new scope (for
   15869 instance by stepping into a function), or the location of the variable
   15870 may change (for instance it is loaded into a register).  The
   15871 tracepoint data recorded uses the location information for the
   15872 variables that is correct for the tracepoint location.  When the
   15873 tracepoint is created, it is not possible, in general, to determine
   15874 where the steps of a @code{while-stepping} sequence will advance the
   15875 program---particularly if a conditional branch is stepped.
   15876 
   15877 @item
   15878 Collection of an incompletely-initialized or partially-destroyed object
   15879 may result in something that @value{GDBN} cannot display, or displays
   15880 in a misleading way.
   15881 
   15882 @item
   15883 When @value{GDBN} displays a pointer to character it automatically
   15884 dereferences the pointer to also display characters of the string
   15885 being pointed to.  However, collecting the pointer during tracing does
   15886 not automatically collect the string.  You need to explicitly
   15887 dereference the pointer and provide size information if you want to
   15888 collect not only the pointer, but the memory pointed to.  For example,
   15889 @code{*ptr@@50} can be used to collect the 50 element array pointed to
   15890 by @code{ptr}.
   15891 
   15892 @item
   15893 It is not possible to collect a complete stack backtrace at a
   15894 tracepoint.  Instead, you may collect the registers and a few hundred
   15895 bytes from the stack pointer with something like @code{*(unsigned char *)$esp@@300}
   15896 (adjust to use the name of the actual stack pointer register on your
   15897 target architecture, and the amount of stack you wish to capture).
   15898 Then the @code{backtrace} command will show a partial backtrace when
   15899 using a trace frame.  The number of stack frames that can be examined
   15900 depends on the sizes of the frames in the collected stack.  Note that
   15901 if you ask for a block so large that it goes past the bottom of the
   15902 stack, the target agent may report an error trying to read from an
   15903 invalid address.
   15904 
   15905 @item
   15906 If you do not collect registers at a tracepoint, @value{GDBN} can
   15907 infer that the value of @code{$pc} must be the same as the address of
   15908 the tracepoint and use that when you are looking at a trace frame
   15909 for that tracepoint.  However, this cannot work if the tracepoint has
   15910 multiple locations (for instance if it was set in a function that was
   15911 inlined), or if it has a @code{while-stepping} loop.  In those cases
   15912 @value{GDBN} will warn you that it can't infer @code{$pc}, and default
   15913 it to zero.
   15914 
   15915 @end itemize
   15916 
   15917 @node Analyze Collected Data
   15918 @section Using the Collected Data
   15919 
   15920 After the tracepoint experiment ends, you use @value{GDBN} commands
   15921 for examining the trace data.  The basic idea is that each tracepoint
   15922 collects a trace @dfn{snapshot} every time it is hit and another
   15923 snapshot every time it single-steps.  All these snapshots are
   15924 consecutively numbered from zero and go into a buffer, and you can
   15925 examine them later.  The way you examine them is to @dfn{focus} on a
   15926 specific trace snapshot.  When the remote stub is focused on a trace
   15927 snapshot, it will respond to all @value{GDBN} requests for memory and
   15928 registers by reading from the buffer which belongs to that snapshot,
   15929 rather than from @emph{real} memory or registers of the program being
   15930 debugged.  This means that @strong{all} @value{GDBN} commands
   15931 (@code{print}, @code{info registers}, @code{backtrace}, etc.) will
   15932 behave as if we were currently debugging the program state as it was
   15933 when the tracepoint occurred.  Any requests for data that are not in
   15934 the buffer will fail.
   15935 
   15936 @menu
   15937 * tfind::                       How to select a trace snapshot
   15938 * tdump::                       How to display all data for a snapshot
   15939 * save tracepoints::            How to save tracepoints for a future run
   15940 @end menu
   15941 
   15942 @node tfind
   15943 @subsection @code{tfind @var{n}}
   15944 
   15945 @kindex tfind
   15946 @cindex select trace snapshot
   15947 @cindex find trace snapshot
   15948 The basic command for selecting a trace snapshot from the buffer is
   15949 @code{tfind @var{n}}, which finds trace snapshot number @var{n},
   15950 counting from zero.  If no argument @var{n} is given, the next
   15951 snapshot is selected.
   15952 
   15953 Here are the various forms of using the @code{tfind} command.
   15954 
   15955 @table @code
   15956 @item tfind start
   15957 Find the first snapshot in the buffer.  This is a synonym for
   15958 @code{tfind 0} (since 0 is the number of the first snapshot).
   15959 
   15960 @item tfind none
   15961 Stop debugging trace snapshots, resume @emph{live} debugging.
   15962 
   15963 @item tfind end
   15964 Same as @samp{tfind none}.
   15965 
   15966 @item tfind
   15967 No argument means find the next trace snapshot or find the first
   15968 one if no trace snapshot is selected.
   15969 
   15970 @item tfind -
   15971 Find the previous trace snapshot before the current one.  This permits
   15972 retracing earlier steps.
   15973 
   15974 @item tfind tracepoint @var{num}
   15975 Find the next snapshot associated with tracepoint @var{num}.  Search
   15976 proceeds forward from the last examined trace snapshot.  If no
   15977 argument @var{num} is given, it means find the next snapshot collected
   15978 for the same tracepoint as the current snapshot.
   15979 
   15980 @item tfind pc @var{addr}
   15981 Find the next snapshot associated with the value @var{addr} of the
   15982 program counter.  Search proceeds forward from the last examined trace
   15983 snapshot.  If no argument @var{addr} is given, it means find the next
   15984 snapshot with the same value of PC as the current snapshot.
   15985 
   15986 @item tfind outside @var{addr1}, @var{addr2}
   15987 Find the next snapshot whose PC is outside the given range of
   15988 addresses (exclusive).
   15989 
   15990 @item tfind range @var{addr1}, @var{addr2}
   15991 Find the next snapshot whose PC is between @var{addr1} and
   15992 @var{addr2} (inclusive).
   15993 
   15994 @item tfind line @r{[}@var{file}:@r{]}@var{n}
   15995 Find the next snapshot associated with the source line @var{n}.  If
   15996 the optional argument @var{file} is given, refer to line @var{n} in
   15997 that source file.  Search proceeds forward from the last examined
   15998 trace snapshot.  If no argument @var{n} is given, it means find the
   15999 next line other than the one currently being examined; thus saying
   16000 @code{tfind line} repeatedly can appear to have the same effect as
   16001 stepping from line to line in a @emph{live} debugging session.
   16002 @end table
   16003 
   16004 The default arguments for the @code{tfind} commands are specifically
   16005 designed to make it easy to scan through the trace buffer.  For
   16006 instance, @code{tfind} with no argument selects the next trace
   16007 snapshot, and @code{tfind -} with no argument selects the previous
   16008 trace snapshot.  So, by giving one @code{tfind} command, and then
   16009 simply hitting @key{RET} repeatedly you can examine all the trace
   16010 snapshots in order.  Or, by saying @code{tfind -} and then hitting
   16011 @key{RET} repeatedly you can examine the snapshots in reverse order.
   16012 The @code{tfind line} command with no argument selects the snapshot
   16013 for the next source line executed.  The @code{tfind pc} command with
   16014 no argument selects the next snapshot with the same program counter
   16015 (PC) as the current frame.  The @code{tfind tracepoint} command with
   16016 no argument selects the next trace snapshot collected by the same
   16017 tracepoint as the current one.
   16018 
   16019 In addition to letting you scan through the trace buffer manually,
   16020 these commands make it easy to construct @value{GDBN} scripts that
   16021 scan through the trace buffer and print out whatever collected data
   16022 you are interested in.  Thus, if we want to examine the PC, FP, and SP
   16023 registers from each trace frame in the buffer, we can say this:
   16024 
   16025 @smallexample
   16026 (@value{GDBP}) @b{tfind start}
   16027 (@value{GDBP}) @b{while ($trace_frame != -1)}
   16028 > printf "Frame %d, PC = %08X, SP = %08X, FP = %08X\n", \
   16029           $trace_frame, $pc, $sp, $fp
   16030 > tfind
   16031 > end
   16032 
   16033 Frame 0, PC = 0020DC64, SP = 0030BF3C, FP = 0030BF44
   16034 Frame 1, PC = 0020DC6C, SP = 0030BF38, FP = 0030BF44
   16035 Frame 2, PC = 0020DC70, SP = 0030BF34, FP = 0030BF44
   16036 Frame 3, PC = 0020DC74, SP = 0030BF30, FP = 0030BF44
   16037 Frame 4, PC = 0020DC78, SP = 0030BF2C, FP = 0030BF44
   16038 Frame 5, PC = 0020DC7C, SP = 0030BF28, FP = 0030BF44
   16039 Frame 6, PC = 0020DC80, SP = 0030BF24, FP = 0030BF44
   16040 Frame 7, PC = 0020DC84, SP = 0030BF20, FP = 0030BF44
   16041 Frame 8, PC = 0020DC88, SP = 0030BF1C, FP = 0030BF44
   16042 Frame 9, PC = 0020DC8E, SP = 0030BF18, FP = 0030BF44
   16043 Frame 10, PC = 00203F6C, SP = 0030BE3C, FP = 0030BF14
   16044 @end smallexample
   16045 
   16046 Or, if we want to examine the variable @code{X} at each source line in
   16047 the buffer:
   16048 
   16049 @smallexample
   16050 (@value{GDBP}) @b{tfind start}
   16051 (@value{GDBP}) @b{while ($trace_frame != -1)}
   16052 > printf "Frame %d, X == %d\n", $trace_frame, X
   16053 > tfind line
   16054 > end
   16055 
   16056 Frame 0, X = 1
   16057 Frame 7, X = 2
   16058 Frame 13, X = 255
   16059 @end smallexample
   16060 
   16061 @node tdump
   16062 @subsection @code{tdump}
   16063 @kindex tdump
   16064 @cindex dump all data collected at tracepoint
   16065 @cindex tracepoint data, display
   16066 
   16067 This command takes no arguments.  It prints all the data collected at
   16068 the current trace snapshot.
   16069 
   16070 @smallexample
   16071 (@value{GDBP}) @b{trace 444}
   16072 (@value{GDBP}) @b{actions}
   16073 Enter actions for tracepoint #2, one per line:
   16074 > collect $regs, $locals, $args, gdb_long_test
   16075 > end
   16076 
   16077 (@value{GDBP}) @b{tstart}
   16078 
   16079 (@value{GDBP}) @b{tfind line 444}
   16080 #0  gdb_test (p1=0x11, p2=0x22, p3=0x33, p4=0x44, p5=0x55, p6=0x66)
   16081 at gdb_test.c:444
   16082 444        printp( "%s: arguments = 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X\n", )
   16083 
   16084 (@value{GDBP}) @b{tdump}
   16085 Data collected at tracepoint 2, trace frame 1:
   16086 d0             0xc4aa0085       -995491707
   16087 d1             0x18     24
   16088 d2             0x80     128
   16089 d3             0x33     51
   16090 d4             0x71aea3d        119204413
   16091 d5             0x22     34
   16092 d6             0xe0     224
   16093 d7             0x380035 3670069
   16094 a0             0x19e24a 1696330
   16095 a1             0x3000668        50333288
   16096 a2             0x100    256
   16097 a3             0x322000 3284992
   16098 a4             0x3000698        50333336
   16099 a5             0x1ad3cc 1758156
   16100 fp             0x30bf3c 0x30bf3c
   16101 sp             0x30bf34 0x30bf34
   16102 ps             0x0      0
   16103 pc             0x20b2c8 0x20b2c8
   16104 fpcontrol      0x0      0
   16105 fpstatus       0x0      0
   16106 fpiaddr        0x0      0
   16107 p = 0x20e5b4 "gdb-test"
   16108 p1 = (void *) 0x11
   16109 p2 = (void *) 0x22
   16110 p3 = (void *) 0x33
   16111 p4 = (void *) 0x44
   16112 p5 = (void *) 0x55
   16113 p6 = (void *) 0x66
   16114 gdb_long_test = 17 '\021'
   16115 
   16116 (@value{GDBP})
   16117 @end smallexample
   16118 
   16119 @code{tdump} works by scanning the tracepoint's current collection
   16120 actions and printing the value of each expression listed.  So
   16121 @code{tdump} can fail, if after a run, you change the tracepoint's
   16122 actions to mention variables that were not collected during the run.
   16123 
   16124 Also, for tracepoints with @code{while-stepping} loops, @code{tdump}
   16125 uses the collected value of @code{$pc} to distinguish between trace
   16126 frames that were collected at the tracepoint hit, and frames that were
   16127 collected while stepping.  This allows it to correctly choose whether
   16128 to display the basic list of collections, or the collections from the
   16129 body of the while-stepping loop.  However, if @code{$pc} was not collected,
   16130 then @code{tdump} will always attempt to dump using the basic collection
   16131 list, and may fail if a while-stepping frame does not include all the
   16132 same data that is collected at the tracepoint hit.
   16133 @c This is getting pretty arcane, example would be good.
   16134 
   16135 @node save tracepoints
   16136 @subsection @code{save tracepoints @var{filename}}
   16137 @kindex save tracepoints
   16138 @kindex save-tracepoints
   16139 @cindex save tracepoints for future sessions
   16140 
   16141 This command saves all current tracepoint definitions together with
   16142 their actions and passcounts, into a file @file{@var{filename}}
   16143 suitable for use in a later debugging session.  To read the saved
   16144 tracepoint definitions, use the @code{source} command (@pxref{Command
   16145 Files}).  The @w{@code{save-tracepoints}} command is a deprecated
   16146 alias for @w{@code{save tracepoints}}
   16147 
   16148 @node Tracepoint Variables
   16149 @section Convenience Variables for Tracepoints
   16150 @cindex tracepoint variables
   16151 @cindex convenience variables for tracepoints
   16152 
   16153 @table @code
   16154 @vindex $trace_frame
   16155 @item (int) $trace_frame
   16156 The current trace snapshot (a.k.a.@: @dfn{frame}) number, or -1 if no
   16157 snapshot is selected.
   16158 
   16159 @vindex $tracepoint
   16160 @item (int) $tracepoint
   16161 The tracepoint for the current trace snapshot.
   16162 
   16163 @vindex $trace_line
   16164 @item (int) $trace_line
   16165 The line number for the current trace snapshot.
   16166 
   16167 @vindex $trace_file
   16168 @item (char []) $trace_file
   16169 The source file for the current trace snapshot.
   16170 
   16171 @vindex $trace_func
   16172 @item (char []) $trace_func
   16173 The name of the function containing @code{$tracepoint}.
   16174 @end table
   16175 
   16176 Note: @code{$trace_file} is not suitable for use in @code{printf},
   16177 use @code{output} instead.
   16178 
   16179 Here's a simple example of using these convenience variables for
   16180 stepping through all the trace snapshots and printing some of their
   16181 data.  Note that these are not the same as trace state variables,
   16182 which are managed by the target.
   16183 
   16184 @smallexample
   16185 (@value{GDBP}) @b{tfind start}
   16186 
   16187 (@value{GDBP}) @b{while $trace_frame != -1}
   16188 > output $trace_file
   16189 > printf ", line %d (tracepoint #%d)\n", $trace_line, $tracepoint
   16190 > tfind
   16191 > end
   16192 @end smallexample
   16193 
   16194 @node Trace Files
   16195 @section Using Trace Files
   16196 @cindex trace files
   16197 
   16198 In some situations, the target running a trace experiment may no
   16199 longer be available; perhaps it crashed, or the hardware was needed
   16200 for a different activity.  To handle these cases, you can arrange to
   16201 dump the trace data into a file, and later use that file as a source
   16202 of trace data, via the @code{target tfile} command.
   16203 
   16204 @table @code
   16205 
   16206 @kindex tsave
   16207 @item tsave [ -r ] @var{filename}
   16208 @itemx tsave [-ctf] @var{dirname}
   16209 Save the trace data to @var{filename}.  By default, this command
   16210 assumes that @var{filename} refers to the host filesystem, so if
   16211 necessary @value{GDBN} will copy raw trace data up from the target and
   16212 then save it.  If the target supports it, you can also supply the
   16213 optional argument @code{-r} (``remote'') to direct the target to save
   16214 the data directly into @var{filename} in its own filesystem, which may be
   16215 more efficient if the trace buffer is very large.  (Note, however, that
   16216 @code{target tfile} can only read from files accessible to the host.)
   16217 By default, this command will save trace frame in tfile format.
   16218 You can supply the optional argument @code{-ctf} to save data in CTF
   16219 format.  The @dfn{Common Trace Format} (CTF) is proposed as a trace format
   16220 that can be shared by multiple debugging and tracing tools.  Please go to
   16221 @indicateurl{http://www.efficios.com/ctf} to get more information.
   16222 
   16223 @kindex target tfile
   16224 @kindex tfile
   16225 @kindex target ctf
   16226 @kindex ctf
   16227 @item target tfile @var{filename}
   16228 @itemx target ctf @var{dirname}
   16229 Use the file named @var{filename} or directory named @var{dirname} as
   16230 a source of trace data.  Commands that examine data work as they do with
   16231 a live target, but it is not possible to run any new trace experiments.
   16232 @code{tstatus} will report the state of the trace run at the moment
   16233 the data was saved, as well as the current trace frame you are examining.
   16234 Both @var{filename} and @var{dirname} must be on a filesystem accessible to
   16235 the host.
   16236 
   16237 The @var{filename} and @var{dirname} arguments supports escaping and
   16238 quoting, see @ref{Filename Arguments,,Filenames As Command Arguments}.
   16239 
   16240 @smallexample
   16241 (@value{GDBP}) target ctf ctf.ctf
   16242 (@value{GDBP}) tfind
   16243 Found trace frame 0, tracepoint 2
   16244 39            ++a;  /* set tracepoint 1 here */
   16245 (@value{GDBP}) tdump
   16246 Data collected at tracepoint 2, trace frame 0:
   16247 i = 0
   16248 a = 0
   16249 b = 1 '\001'
   16250 c = @{"123", "456", "789", "123", "456", "789"@}
   16251 d = @{@{@{a = 1, b = 2@}, @{a = 3, b = 4@}@}, @{@{a = 5, b = 6@}, @{a = 7, b = 8@}@}@}
   16252 (@value{GDBP}) p b
   16253 $1 = 1
   16254 @end smallexample
   16255 
   16256 @end table
   16257 
   16258 @node Overlays
   16259 @chapter Debugging Programs That Use Overlays
   16260 @cindex overlays
   16261 
   16262 If your program is too large to fit completely in your target system's
   16263 memory, you can sometimes use @dfn{overlays} to work around this
   16264 problem.  @value{GDBN} provides some support for debugging programs that
   16265 use overlays.
   16266 
   16267 @menu
   16268 * How Overlays Work::              A general explanation of overlays.
   16269 * Overlay Commands::               Managing overlays in @value{GDBN}.
   16270 * Automatic Overlay Debugging::    @value{GDBN} can find out which overlays are
   16271                                    mapped by asking the inferior.
   16272 * Overlay Sample Program::         A sample program using overlays.
   16273 @end menu
   16274 
   16275 @node How Overlays Work
   16276 @section How Overlays Work
   16277 @cindex mapped overlays
   16278 @cindex unmapped overlays
   16279 @cindex load address, overlay's
   16280 @cindex mapped address
   16281 @cindex overlay area
   16282 
   16283 Suppose you have a computer whose instruction address space is only 64
   16284 kilobytes long, but which has much more memory which can be accessed by
   16285 other means: special instructions, segment registers, or memory
   16286 management hardware, for example.  Suppose further that you want to
   16287 adapt a program which is larger than 64 kilobytes to run on this system.
   16288 
   16289 One solution is to identify modules of your program which are relatively
   16290 independent, and need not call each other directly; call these modules
   16291 @dfn{overlays}.  Separate the overlays from the main program, and place
   16292 their machine code in the larger memory.  Place your main program in
   16293 instruction memory, but leave at least enough space there to hold the
   16294 largest overlay as well.
   16295 
   16296 Now, to call a function located in an overlay, you must first copy that
   16297 overlay's machine code from the large memory into the space set aside
   16298 for it in the instruction memory, and then jump to its entry point
   16299 there.
   16300 
   16301 @c NB:  In the below the mapped area's size is greater or equal to the
   16302 @c size of all overlays.  This is intentional to remind the developer
   16303 @c that overlays don't necessarily need to be the same size.
   16304 
   16305 @smallexample
   16306 @group
   16307     Data             Instruction            Larger
   16308 Address Space       Address Space        Address Space
   16309 +-----------+       +-----------+        +-----------+
   16310 |           |       |           |        |           |
   16311 +-----------+       +-----------+        +-----------+<-- overlay 1
   16312 | program   |       |   main    |   .----| overlay 1 | load address
   16313 | variables |       |  program  |   |    +-----------+
   16314 | and heap  |       |           |   |    |           |
   16315 +-----------+       |           |   |    +-----------+<-- overlay 2
   16316 |           |       +-----------+   |    |           | load address
   16317 +-----------+       |           |   |  .-| overlay 2 |
   16318                     |           |   |  | |           |
   16319          mapped --->+-----------+   |  | +-----------+
   16320          address    |           |   |  | |           |
   16321                     |  overlay  | <-'  | |           |
   16322                     |   area    |  <---' +-----------+<-- overlay 3
   16323                     |           | <---.  |           | load address
   16324                     +-----------+     `--| overlay 3 |
   16325                     |           |        |           |
   16326                     +-----------+        |           |
   16327                                          +-----------+
   16328                                          |           |
   16329                                          +-----------+
   16330 
   16331                     @anchor{A code overlay}A code overlay
   16332 @end group
   16333 @end smallexample
   16334 
   16335 The diagram (@pxref{A code overlay}) shows a system with separate data
   16336 and instruction address spaces.  To map an overlay, the program copies
   16337 its code from the larger address space to the instruction address space.
   16338 Since the overlays shown here all use the same mapped address, only one
   16339 may be mapped at a time.  For a system with a single address space for
   16340 data and instructions, the diagram would be similar, except that the
   16341 program variables and heap would share an address space with the main
   16342 program and the overlay area.
   16343 
   16344 An overlay loaded into instruction memory and ready for use is called a
   16345 @dfn{mapped} overlay; its @dfn{mapped address} is its address in the
   16346 instruction memory.  An overlay not present (or only partially present)
   16347 in instruction memory is called @dfn{unmapped}; its @dfn{load address}
   16348 is its address in the larger memory.  The mapped address is also called
   16349 the @dfn{virtual memory address}, or @dfn{VMA}; the load address is also
   16350 called the @dfn{load memory address}, or @dfn{LMA}.
   16351 
   16352 Unfortunately, overlays are not a completely transparent way to adapt a
   16353 program to limited instruction memory.  They introduce a new set of
   16354 global constraints you must keep in mind as you design your program:
   16355 
   16356 @itemize @bullet
   16357 
   16358 @item
   16359 Before calling or returning to a function in an overlay, your program
   16360 must make sure that overlay is actually mapped.  Otherwise, the call or
   16361 return will transfer control to the right address, but in the wrong
   16362 overlay, and your program will probably crash.
   16363 
   16364 @item
   16365 If the process of mapping an overlay is expensive on your system, you
   16366 will need to choose your overlays carefully to minimize their effect on
   16367 your program's performance.
   16368 
   16369 @item
   16370 The executable file you load onto your system must contain each
   16371 overlay's instructions, appearing at the overlay's load address, not its
   16372 mapped address.  However, each overlay's instructions must be relocated
   16373 and its symbols defined as if the overlay were at its mapped address.
   16374 You can use GNU linker scripts to specify different load and relocation
   16375 addresses for pieces of your program; see @ref{Overlay Description,,,
   16376 ld.info, Using ld: the GNU linker}.
   16377 
   16378 @item
   16379 The procedure for loading executable files onto your system must be able
   16380 to load their contents into the larger address space as well as the
   16381 instruction and data spaces.
   16382 
   16383 @end itemize
   16384 
   16385 The overlay system described above is rather simple, and could be
   16386 improved in many ways:
   16387 
   16388 @itemize @bullet
   16389 
   16390 @item
   16391 If your system has suitable bank switch registers or memory management
   16392 hardware, you could use those facilities to make an overlay's load area
   16393 contents simply appear at their mapped address in instruction space.
   16394 This would probably be faster than copying the overlay to its mapped
   16395 area in the usual way.
   16396 
   16397 @item
   16398 If your overlays are small enough, you could set aside more than one
   16399 overlay area, and have more than one overlay mapped at a time.
   16400 
   16401 @item
   16402 You can use overlays to manage data, as well as instructions.  In
   16403 general, data overlays are even less transparent to your design than
   16404 code overlays: whereas code overlays only require care when you call or
   16405 return to functions, data overlays require care every time you access
   16406 the data.  Also, if you change the contents of a data overlay, you
   16407 must copy its contents back out to its load address before you can copy a
   16408 different data overlay into the same mapped area.
   16409 
   16410 @end itemize
   16411 
   16412 
   16413 @node Overlay Commands
   16414 @section Overlay Commands
   16415 
   16416 To use @value{GDBN}'s overlay support, each overlay in your program must
   16417 correspond to a separate section of the executable file.  The section's
   16418 virtual memory address and load memory address must be the overlay's
   16419 mapped and load addresses.  Identifying overlays with sections allows
   16420 @value{GDBN} to determine the appropriate address of a function or
   16421 variable, depending on whether the overlay is mapped or not.
   16422 
   16423 @value{GDBN}'s overlay commands all start with the word @code{overlay};
   16424 you can abbreviate this as @code{ov} or @code{ovly}.  The commands are:
   16425 
   16426 @table @code
   16427 @item overlay off
   16428 @kindex overlay
   16429 Disable @value{GDBN}'s overlay support.  When overlay support is
   16430 disabled, @value{GDBN} assumes that all functions and variables are
   16431 always present at their mapped addresses.  By default, @value{GDBN}'s
   16432 overlay support is disabled.
   16433 
   16434 @item overlay manual
   16435 @cindex manual overlay debugging
   16436 Enable @dfn{manual} overlay debugging.  In this mode, @value{GDBN}
   16437 relies on you to tell it which overlays are mapped, and which are not,
   16438 using the @code{overlay map-overlay} and @code{overlay unmap-overlay}
   16439 commands described below.
   16440 
   16441 @item overlay map-overlay @var{overlay}
   16442 @itemx overlay map @var{overlay}
   16443 @cindex map an overlay
   16444 Tell @value{GDBN} that @var{overlay} is now mapped; @var{overlay} must
   16445 be the name of the object file section containing the overlay.  When an
   16446 overlay is mapped, @value{GDBN} assumes it can find the overlay's
   16447 functions and variables at their mapped addresses.  @value{GDBN} assumes
   16448 that any other overlays whose mapped ranges overlap that of
   16449 @var{overlay} are now unmapped.
   16450 
   16451 @item overlay unmap-overlay @var{overlay}
   16452 @itemx overlay unmap @var{overlay}
   16453 @cindex unmap an overlay
   16454 Tell @value{GDBN} that @var{overlay} is no longer mapped; @var{overlay}
   16455 must be the name of the object file section containing the overlay.
   16456 When an overlay is unmapped, @value{GDBN} assumes it can find the
   16457 overlay's functions and variables at their load addresses.
   16458 
   16459 @item overlay auto
   16460 Enable @dfn{automatic} overlay debugging.  In this mode, @value{GDBN}
   16461 consults a data structure the overlay manager maintains in the inferior
   16462 to see which overlays are mapped.  For details, see @ref{Automatic
   16463 Overlay Debugging}.
   16464 
   16465 @item overlay load-target
   16466 @itemx overlay load
   16467 @cindex reloading the overlay table
   16468 Re-read the overlay table from the inferior.  Normally, @value{GDBN}
   16469 re-reads the table @value{GDBN} automatically each time the inferior
   16470 stops, so this command should only be necessary if you have changed the
   16471 overlay mapping yourself using @value{GDBN}.  This command is only
   16472 useful when using automatic overlay debugging.
   16473 
   16474 @item overlay list-overlays
   16475 @itemx overlay list
   16476 @cindex listing mapped overlays
   16477 Display a list of the overlays currently mapped, along with their mapped
   16478 addresses, load addresses, and sizes.
   16479 
   16480 @end table
   16481 
   16482 Normally, when @value{GDBN} prints a code address, it includes the name
   16483 of the function the address falls in:
   16484 
   16485 @smallexample
   16486 (@value{GDBP}) print main
   16487 $3 = @{int ()@} 0x11a0 <main>
   16488 @end smallexample
   16489 @noindent
   16490 When overlay debugging is enabled, @value{GDBN} recognizes code in
   16491 unmapped overlays, and prints the names of unmapped functions with
   16492 asterisks around them.  For example, if @code{foo} is a function in an
   16493 unmapped overlay, @value{GDBN} prints it this way:
   16494 
   16495 @smallexample
   16496 (@value{GDBP}) overlay list
   16497 No sections are mapped.
   16498 (@value{GDBP}) print foo
   16499 $5 = @{int (int)@} 0x100000 <*foo*>
   16500 @end smallexample
   16501 @noindent
   16502 When @code{foo}'s overlay is mapped, @value{GDBN} prints the function's
   16503 name normally:
   16504 
   16505 @smallexample
   16506 (@value{GDBP}) overlay list
   16507 Section .ov.foo.text, loaded at 0x100000 - 0x100034,
   16508         mapped at 0x1016 - 0x104a
   16509 (@value{GDBP}) print foo
   16510 $6 = @{int (int)@} 0x1016 <foo>
   16511 @end smallexample
   16512 
   16513 When overlay debugging is enabled, @value{GDBN} can find the correct
   16514 address for functions and variables in an overlay, whether or not the
   16515 overlay is mapped.  This allows most @value{GDBN} commands, like
   16516 @code{break} and @code{disassemble}, to work normally, even on unmapped
   16517 code.  However, @value{GDBN}'s breakpoint support has some limitations:
   16518 
   16519 @itemize @bullet
   16520 @item
   16521 @cindex breakpoints in overlays
   16522 @cindex overlays, setting breakpoints in
   16523 You can set breakpoints in functions in unmapped overlays, as long as
   16524 @value{GDBN} can write to the overlay at its load address.
   16525 @item
   16526 @value{GDBN} can not set hardware or simulator-based breakpoints in
   16527 unmapped overlays.  However, if you set a breakpoint at the end of your
   16528 overlay manager (and tell @value{GDBN} which overlays are now mapped, if
   16529 you are using manual overlay management), @value{GDBN} will re-set its
   16530 breakpoints properly.
   16531 @end itemize
   16532 
   16533 
   16534 @node Automatic Overlay Debugging
   16535 @section Automatic Overlay Debugging
   16536 @cindex automatic overlay debugging
   16537 
   16538 @value{GDBN} can automatically track which overlays are mapped and which
   16539 are not, given some simple co-operation from the overlay manager in the
   16540 inferior.  If you enable automatic overlay debugging with the
   16541 @code{overlay auto} command (@pxref{Overlay Commands}), @value{GDBN}
   16542 looks in the inferior's memory for certain variables describing the
   16543 current state of the overlays.
   16544 
   16545 Here are the variables your overlay manager must define to support
   16546 @value{GDBN}'s automatic overlay debugging:
   16547 
   16548 @table @asis
   16549 
   16550 @item @code{_ovly_table}:
   16551 This variable must be an array of the following structures:
   16552 
   16553 @smallexample
   16554 struct
   16555 @{
   16556   /* The overlay's mapped address.  */
   16557   unsigned long vma;
   16558 
   16559   /* The size of the overlay, in bytes.  */
   16560   unsigned long size;
   16561 
   16562   /* The overlay's load address.  */
   16563   unsigned long lma;
   16564 
   16565   /* Non-zero if the overlay is currently mapped;
   16566      zero otherwise.  */
   16567   unsigned long mapped;
   16568 @}
   16569 @end smallexample
   16570 
   16571 @item @code{_novlys}:
   16572 This variable must be a four-byte signed integer, holding the total
   16573 number of elements in @code{_ovly_table}.
   16574 
   16575 @end table
   16576 
   16577 To decide whether a particular overlay is mapped or not, @value{GDBN}
   16578 looks for an entry in @w{@code{_ovly_table}} whose @code{vma} and
   16579 @code{lma} members equal the VMA and LMA of the overlay's section in the
   16580 executable file.  When @value{GDBN} finds a matching entry, it consults
   16581 the entry's @code{mapped} member to determine whether the overlay is
   16582 currently mapped.
   16583 
   16584 In addition, your overlay manager may define a function called
   16585 @code{_ovly_debug_event}.  If this function is defined, @value{GDBN}
   16586 will silently set a breakpoint there.  If the overlay manager then
   16587 calls this function whenever it has changed the overlay table, this
   16588 will enable @value{GDBN} to accurately keep track of which overlays
   16589 are in program memory, and update any breakpoints that may be set
   16590 in overlays.  This will allow breakpoints to work even if the
   16591 overlays are kept in ROM or other non-writable memory while they
   16592 are not being executed.
   16593 
   16594 @node Overlay Sample Program
   16595 @section Overlay Sample Program
   16596 @cindex overlay example program
   16597 
   16598 When linking a program which uses overlays, you must place the overlays
   16599 at their load addresses, while relocating them to run at their mapped
   16600 addresses.  To do this, you must write a linker script (@pxref{Overlay
   16601 Description,,, ld.info, Using ld: the GNU linker}).  Unfortunately,
   16602 since linker scripts are specific to a particular host system, target
   16603 architecture, and target memory layout, this manual cannot provide
   16604 portable sample code demonstrating @value{GDBN}'s overlay support.
   16605 
   16606 However, the @value{GDBN} source distribution does contain an overlaid
   16607 program, with linker scripts for a few systems, as part of its test
   16608 suite.  The program consists of the following files from
   16609 @file{gdb/testsuite/gdb.base}:
   16610 
   16611 @table @file
   16612 @item overlays.c
   16613 The main program file.
   16614 @item ovlymgr.c
   16615 A simple overlay manager, used by @file{overlays.c}.
   16616 @item foo.c
   16617 @itemx bar.c
   16618 @itemx baz.c
   16619 @itemx grbx.c
   16620 Overlay modules, loaded and used by @file{overlays.c}.
   16621 @item d10v.ld
   16622 @itemx m32r.ld
   16623 Linker scripts for linking the test program on the @code{d10v-elf}
   16624 and @code{m32r-elf} targets.
   16625 @end table
   16626 
   16627 You can build the test program using the @code{d10v-elf} GCC
   16628 cross-compiler like this:
   16629 
   16630 @smallexample
   16631 $ d10v-elf-gcc -g -c overlays.c
   16632 $ d10v-elf-gcc -g -c ovlymgr.c
   16633 $ d10v-elf-gcc -g -c foo.c
   16634 $ d10v-elf-gcc -g -c bar.c
   16635 $ d10v-elf-gcc -g -c baz.c
   16636 $ d10v-elf-gcc -g -c grbx.c
   16637 $ d10v-elf-gcc -g overlays.o ovlymgr.o foo.o bar.o \
   16638                   baz.o grbx.o -Wl,-Td10v.ld -o overlays
   16639 @end smallexample
   16640 
   16641 The build process is identical for any other architecture, except that
   16642 you must substitute the appropriate compiler and linker script for the
   16643 target system for @code{d10v-elf-gcc} and @code{d10v.ld}.
   16644 
   16645 
   16646 @node Languages
   16647 @chapter Using @value{GDBN} with Different Languages
   16648 @cindex languages
   16649 
   16650 Although programming languages generally have common aspects, they are
   16651 rarely expressed in the same manner.  For instance, in ANSI C,
   16652 dereferencing a pointer @code{p} is accomplished by @code{*p}, but in
   16653 Modula-2, it is accomplished by @code{p^}.  Values can also be
   16654 represented (and displayed) differently.  Hex numbers in C appear as
   16655 @samp{0x1ae}, while in Modula-2 they appear as @samp{1AEH}.
   16656 
   16657 @cindex working language
   16658 Language-specific information is built into @value{GDBN} for some languages,
   16659 allowing you to express operations like the above in your program's
   16660 native language, and allowing @value{GDBN} to output values in a manner
   16661 consistent with the syntax of your program's native language.  The
   16662 language you use to build expressions is called the @dfn{working
   16663 language}.
   16664 
   16665 @menu
   16666 * Setting::                     Switching between source languages
   16667 * Show::                        Displaying the language
   16668 * Checks::                      Type and range checks
   16669 * Supported Languages::         Supported languages
   16670 * Unsupported Languages::       Unsupported languages
   16671 @end menu
   16672 
   16673 @node Setting
   16674 @section Switching Between Source Languages
   16675 
   16676 There are two ways to control the working language---either have @value{GDBN}
   16677 set it automatically, or select it manually yourself.  You can use the
   16678 @code{set language} command for either purpose.  On startup, @value{GDBN}
   16679 defaults to setting the language automatically.  The working language is
   16680 used to determine how expressions you type are interpreted, how values
   16681 are printed, etc.
   16682 
   16683 In addition to the working language, every source file that
   16684 @value{GDBN} knows about has its own working language.  For some object
   16685 file formats, the compiler might indicate which language a particular
   16686 source file is in.  However, most of the time @value{GDBN} infers the
   16687 language from the name of the file.  The language of a source file
   16688 controls whether C@t{++} names are demangled---this way @code{backtrace} can
   16689 show each frame appropriately for its own language.  There is no way to
   16690 set the language of a source file from within @value{GDBN}, but you can
   16691 set the language associated with a filename extension.  @xref{Show, ,
   16692 Displaying the Language}.
   16693 
   16694 This is most commonly a problem when you use a program, such
   16695 as @code{cfront} or @code{f2c}, that generates C but is written in
   16696 another language.  In that case, make the
   16697 program use @code{#line} directives in its C output; that way
   16698 @value{GDBN} will know the correct language of the source code of the original
   16699 program, and will display that source code, not the generated C code.
   16700 
   16701 @menu
   16702 * Filenames::                   Filename extensions and languages.
   16703 * Manually::                    Setting the working language manually
   16704 * Automatically::               Having @value{GDBN} infer the source language
   16705 @end menu
   16706 
   16707 @node Filenames
   16708 @subsection List of Filename Extensions and Languages
   16709 
   16710 If a source file name ends in one of the following extensions, then
   16711 @value{GDBN} infers that its language is the one indicated.
   16712 
   16713 @table @file
   16714 @item .ada
   16715 @itemx .ads
   16716 @itemx .adb
   16717 @itemx .a
   16718 Ada source file.
   16719 
   16720 @item .c
   16721 C source file
   16722 
   16723 @item .C
   16724 @itemx .cc
   16725 @itemx .cp
   16726 @itemx .cpp
   16727 @itemx .cxx
   16728 @itemx .c++
   16729 C@t{++} source file
   16730 
   16731 @item .d
   16732 D source file
   16733 
   16734 @item .m
   16735 Objective-C source file
   16736 
   16737 @item .f
   16738 @itemx .F
   16739 Fortran source file
   16740 
   16741 @item .mod
   16742 Modula-2 source file
   16743 
   16744 @item .s
   16745 @itemx .S
   16746 Assembler source file.  This actually behaves almost like C, but
   16747 @value{GDBN} does not skip over function prologues when stepping.
   16748 @end table
   16749 
   16750 In addition, you may set the language associated with a filename
   16751 extension.  @xref{Show, , Displaying the Language}.
   16752 
   16753 @node Manually
   16754 @subsection Setting the Working Language
   16755 
   16756 If you allow @value{GDBN} to set the language automatically,
   16757 expressions are interpreted the same way in your debugging session and
   16758 your program.
   16759 
   16760 @kindex set language
   16761 If you wish, you may set the language manually.  To do this, issue the
   16762 command @samp{set language @var{lang}}, where @var{lang} is the name of
   16763 a language, such as
   16764 @code{c} or @code{modula-2}.
   16765 For a list of the supported languages, type @samp{set language}.
   16766 
   16767 Setting the language manually prevents @value{GDBN} from updating the working
   16768 language automatically.  This can lead to confusion if you try
   16769 to debug a program when the working language is not the same as the
   16770 source language, when an expression is acceptable to both
   16771 languages---but means different things.  For instance, if the current
   16772 source file were written in C, and @value{GDBN} was parsing Modula-2, a
   16773 command such as:
   16774 
   16775 @smallexample
   16776 print a = b + c
   16777 @end smallexample
   16778 
   16779 @noindent
   16780 might not have the effect you intended.  In C, this means to add
   16781 @code{b} and @code{c} and place the result in @code{a}.  The result
   16782 printed would be the value of @code{a}.  In Modula-2, this means to compare
   16783 @code{a} to the result of @code{b+c}, yielding a @code{BOOLEAN} value.
   16784 
   16785 @node Automatically
   16786 @subsection Having @value{GDBN} Infer the Source Language
   16787 
   16788 To have @value{GDBN} set the working language automatically, use
   16789 @samp{set language local} or @samp{set language auto}.  @value{GDBN}
   16790 then infers the working language.  That is, when your program stops in a
   16791 frame (usually by encountering a breakpoint), @value{GDBN} sets the
   16792 working language to the language recorded for the function in that
   16793 frame.  If the language for a frame is unknown (that is, if the function
   16794 or block corresponding to the frame was defined in a source file that
   16795 does not have a recognized extension), the current working language is
   16796 not changed, and @value{GDBN} issues a warning.
   16797 
   16798 This may not seem necessary for most programs, which are written
   16799 entirely in one source language.  However, program modules and libraries
   16800 written in one source language can be used by a main program written in
   16801 a different source language.  Using @samp{set language auto} in this
   16802 case frees you from having to set the working language manually.
   16803 
   16804 The warning is enabled by default, but it can be controlled via a
   16805 setting:
   16806 
   16807 @table @code
   16808 @item set warn-language-frame-mismatch [on|off]
   16809 @kindex warn-language-frame-mismatch
   16810 Enable or disable the warning that is issued when the current language
   16811 is set to a value that does not match the current frame.
   16812 
   16813 @item show warn-language-frame-mismatch
   16814 Show whether the frame-mismatch warning will be issued.
   16815 @end table
   16816 
   16817 @node Show
   16818 @section Displaying the Language
   16819 
   16820 The following commands help you find out which language is the
   16821 working language, and also what language source files were written in.
   16822 
   16823 @table @code
   16824 @item show language
   16825 @anchor{show language}
   16826 @kindex show language
   16827 Display the current working language.  This is the
   16828 language you can use with commands such as @code{print} to
   16829 build and compute expressions that may involve variables in your program.
   16830 
   16831 @item info frame
   16832 @kindex info frame@r{, show the source language}
   16833 Display the source language for this frame.  This language becomes the
   16834 working language if you use an identifier from this frame.
   16835 @xref{Frame Info, ,Information about a Frame}, to identify the other
   16836 information listed here.
   16837 
   16838 @item info source
   16839 @kindex info source@r{, show the source language}
   16840 Display the source language of this source file.
   16841 @xref{Symbols, ,Examining the Symbol Table}, to identify the other
   16842 information listed here.
   16843 @end table
   16844 
   16845 In unusual circumstances, you may have source files with extensions
   16846 not in the standard list.  You can then set the extension associated
   16847 with a language explicitly:
   16848 
   16849 @table @code
   16850 @item set extension-language @var{ext} @var{language}
   16851 @kindex set extension-language
   16852 Tell @value{GDBN} that source files with extension @var{ext} are to be
   16853 assumed as written in the source language @var{language}.
   16854 
   16855 @item info extensions
   16856 @kindex info extensions
   16857 List all the filename extensions and the associated languages.
   16858 @end table
   16859 
   16860 @node Checks
   16861 @section Type and Range Checking
   16862 
   16863 Some languages are designed to guard you against making seemingly common
   16864 errors through a series of compile- and run-time checks.  These include
   16865 checking the type of arguments to functions and operators and making
   16866 sure mathematical overflows are caught at run time.  Checks such as
   16867 these help to ensure a program's correctness once it has been compiled
   16868 by eliminating type mismatches and providing active checks for range
   16869 errors when your program is running.
   16870 
   16871 By default @value{GDBN} checks for these errors according to the
   16872 rules of the current source language.  Although @value{GDBN} does not check
   16873 the statements in your program, it can check expressions entered directly
   16874 into @value{GDBN} for evaluation via the @code{print} command, for example.
   16875 
   16876 @menu
   16877 * Type Checking::               An overview of type checking
   16878 * Range Checking::              An overview of range checking
   16879 @end menu
   16880 
   16881 @cindex type checking
   16882 @cindex checks, type
   16883 @node Type Checking
   16884 @subsection An Overview of Type Checking
   16885 
   16886 Some languages, such as C and C@t{++}, are strongly typed, meaning that the
   16887 arguments to operators and functions have to be of the correct type,
   16888 otherwise an error occurs.  These checks prevent type mismatch
   16889 errors from ever causing any run-time problems.  For example,
   16890 
   16891 @smallexample
   16892 int klass::my_method(char *b) @{ return  b ? 1 : 2; @}
   16893 
   16894 (@value{GDBP}) print obj.my_method (0)
   16895 $1 = 2
   16896 @exdent but
   16897 (@value{GDBP}) print obj.my_method (0x1234)
   16898 Cannot resolve method klass::my_method to any overloaded instance
   16899 @end smallexample
   16900 
   16901 The second example fails because in C@t{++} the integer constant
   16902 @samp{0x1234} is not type-compatible with the pointer parameter type.
   16903 
   16904 For the expressions you use in @value{GDBN} commands, you can tell
   16905 @value{GDBN} to not enforce strict type checking or
   16906 to treat any mismatches as errors and abandon the expression;
   16907 When type checking is disabled, @value{GDBN} successfully evaluates
   16908 expressions like the second example above.
   16909 
   16910 Even if type checking is off, there may be other reasons
   16911 related to type that prevent @value{GDBN} from evaluating an expression.
   16912 For instance, @value{GDBN} does not know how to add an @code{int} and
   16913 a @code{struct foo}.  These particular type errors have nothing to do
   16914 with the language in use and usually arise from expressions which make
   16915 little sense to evaluate anyway.
   16916 
   16917 @value{GDBN} provides some additional commands for controlling type checking:
   16918 
   16919 @kindex set check type
   16920 @kindex show check type
   16921 @table @code
   16922 @item set check type on
   16923 @itemx set check type off
   16924 Set strict type checking on or off.  If any type mismatches occur in
   16925 evaluating an expression while type checking is on, @value{GDBN} prints a
   16926 message and aborts evaluation of the expression.
   16927 
   16928 @item show check type
   16929 Show the current setting of type checking and whether @value{GDBN}
   16930 is enforcing strict type checking rules.
   16931 @end table
   16932 
   16933 @cindex range checking
   16934 @cindex checks, range
   16935 @node Range Checking
   16936 @subsection An Overview of Range Checking
   16937 
   16938 In some languages (such as Modula-2), it is an error to exceed the
   16939 bounds of a type; this is enforced with run-time checks.  Such range
   16940 checking is meant to ensure program correctness by making sure
   16941 computations do not overflow, or indices on an array element access do
   16942 not exceed the bounds of the array.
   16943 
   16944 For expressions you use in @value{GDBN} commands, you can tell
   16945 @value{GDBN} to treat range errors in one of three ways: ignore them,
   16946 always treat them as errors and abandon the expression, or issue
   16947 warnings but evaluate the expression anyway.
   16948 
   16949 A range error can result from numerical overflow, from exceeding an
   16950 array index bound, or when you type a constant that is not a member
   16951 of any type.  Some languages, however, do not treat overflows as an
   16952 error.  In many implementations of C, mathematical overflow causes the
   16953 result to ``wrap around'' to lower values---for example, if @var{m} is
   16954 the largest integer value, and @var{s} is the smallest, then
   16955 
   16956 @smallexample
   16957 @var{m} + 1 @result{} @var{s}
   16958 @end smallexample
   16959 
   16960 This, too, is specific to individual languages, and in some cases
   16961 specific to individual compilers or machines.  @xref{Supported Languages, ,
   16962 Supported Languages}, for further details on specific languages.
   16963 
   16964 @value{GDBN} provides some additional commands for controlling the range checker:
   16965 
   16966 @kindex set check range
   16967 @kindex show check range
   16968 @table @code
   16969 @item set check range auto
   16970 Set range checking on or off based on the current working language.
   16971 @xref{Supported Languages, ,Supported Languages}, for the default settings for
   16972 each language.
   16973 
   16974 @item set check range on
   16975 @itemx set check range off
   16976 Set range checking on or off, overriding the default setting for the
   16977 current working language.  A warning is issued if the setting does not
   16978 match the language default.  If a range error occurs and range checking is on,
   16979 then a message is printed and evaluation of the expression is aborted.
   16980 
   16981 @item set check range warn
   16982 Output messages when the @value{GDBN} range checker detects a range error,
   16983 but attempt to evaluate the expression anyway.  Evaluating the
   16984 expression may still be impossible for other reasons, such as accessing
   16985 memory that the process does not own (a typical example from many Unix
   16986 systems).
   16987 
   16988 @item show check range
   16989 Show the current setting of the range checker, and whether or not it is
   16990 being set automatically by @value{GDBN}.
   16991 @end table
   16992 
   16993 @node Supported Languages
   16994 @section Supported Languages
   16995 
   16996 @value{GDBN} supports C, C@t{++}, D, Go, Objective-C, Fortran,
   16997 OpenCL C, Pascal, Rust, assembly, Modula-2, and Ada.
   16998 @c This is false ...
   16999 Some @value{GDBN} features may be used in expressions regardless of the
   17000 language you use: the @value{GDBN} @code{@@} and @code{::} operators,
   17001 and the @samp{@{type@}addr} construct (@pxref{Expressions,
   17002 ,Expressions}) can be used with the constructs of any supported
   17003 language.
   17004 
   17005 The following sections detail to what degree each source language is
   17006 supported by @value{GDBN}.  These sections are not meant to be language
   17007 tutorials or references, but serve only as a reference guide to what the
   17008 @value{GDBN} expression parser accepts, and what input and output
   17009 formats should look like for different languages.  There are many good
   17010 books written on each of these languages; please look to these for a
   17011 language reference or tutorial.
   17012 
   17013 @menu
   17014 * C::                           C and C@t{++}
   17015 * D::                           D
   17016 * Go::                          Go
   17017 * Objective-C::                 Objective-C
   17018 * OpenCL C::                    OpenCL C
   17019 * Fortran::                     Fortran
   17020 * Pascal::                      Pascal
   17021 * Rust::                        Rust
   17022 * Modula-2::                    Modula-2
   17023 * Ada::                         Ada
   17024 @end menu
   17025 
   17026 @node C
   17027 @subsection C and C@t{++}
   17028 
   17029 @cindex C and C@t{++}
   17030 @cindex expressions in C or C@t{++}
   17031 
   17032 Since C and C@t{++} are so closely related, many features of @value{GDBN} apply
   17033 to both languages.  Whenever this is the case, we discuss those languages
   17034 together.
   17035 
   17036 @cindex C@t{++}
   17037 @cindex @code{g++}, @sc{gnu} C@t{++} compiler
   17038 @cindex @sc{gnu} C@t{++}
   17039 The C@t{++} debugging facilities are jointly implemented by the C@t{++}
   17040 compiler and @value{GDBN}.  Therefore, to debug your C@t{++} code
   17041 effectively, you must compile your C@t{++} programs with a supported
   17042 C@t{++} compiler, such as @sc{gnu} @code{g++}, or the HP ANSI C@t{++}
   17043 compiler (@code{aCC}).
   17044 
   17045 @menu
   17046 * C Operators::                 C and C@t{++} operators
   17047 * C Constants::                 C and C@t{++} constants
   17048 * C Plus Plus Expressions::     C@t{++} expressions
   17049 * C Defaults::                  Default settings for C and C@t{++}
   17050 * C Checks::                    C and C@t{++} type and range checks
   17051 * Debugging C::                 @value{GDBN} and C
   17052 * Debugging C Plus Plus::       @value{GDBN} features for C@t{++}
   17053 * Decimal Floating Point::      Numbers in Decimal Floating Point format
   17054 @end menu
   17055 
   17056 @node C Operators
   17057 @subsubsection C and C@t{++} Operators
   17058 
   17059 @cindex C and C@t{++} operators
   17060 
   17061 Operators must be defined on values of specific types.  For instance,
   17062 @code{+} is defined on numbers, but not on structures.  Operators are
   17063 often defined on groups of types.
   17064 
   17065 For the purposes of C and C@t{++}, the following definitions hold:
   17066 
   17067 @itemize @bullet
   17068 
   17069 @item
   17070 @emph{Integral types} include @code{int} with any of its storage-class
   17071 specifiers; @code{char}; @code{enum}; and, for C@t{++}, @code{bool}.
   17072 
   17073 @item
   17074 @emph{Floating-point types} include @code{float}, @code{double}, and
   17075 @code{long double} (if supported by the target platform).
   17076 
   17077 @item
   17078 @emph{Pointer types} include all types defined as @code{(@var{type} *)}.
   17079 
   17080 @item
   17081 @emph{Scalar types} include all of the above.
   17082 
   17083 @end itemize
   17084 
   17085 @noindent
   17086 The following operators are supported.  They are listed here
   17087 in order of increasing precedence:
   17088 
   17089 @table @code
   17090 @item ,
   17091 The comma or sequencing operator.  Expressions in a comma-separated list
   17092 are evaluated from left to right, with the result of the entire
   17093 expression being the last expression evaluated.
   17094 
   17095 @item =
   17096 Assignment.  The value of an assignment expression is the value
   17097 assigned.  Defined on scalar types.
   17098 
   17099 @item @var{op}=
   17100 Used in an expression of the form @w{@code{@var{a} @var{op}= @var{b}}},
   17101 and translated to @w{@code{@var{a} = @var{a op b}}}.
   17102 @w{@code{@var{op}=}} and @code{=} have the same precedence.  The operator
   17103 @var{op} is any one of the operators @code{|}, @code{^}, @code{&},
   17104 @code{<<}, @code{>>}, @code{+}, @code{-}, @code{*}, @code{/}, @code{%}.
   17105 
   17106 @item ?:
   17107 The ternary operator.  @code{@var{a} ? @var{b} : @var{c}} can be thought
   17108 of as:  if @var{a} then @var{b} else @var{c}.  The argument @var{a}
   17109 should be of an integral type.
   17110 
   17111 @item ||
   17112 Logical @sc{or}.  Defined on integral types.
   17113 
   17114 @item &&
   17115 Logical @sc{and}.  Defined on integral types.
   17116 
   17117 @item |
   17118 Bitwise @sc{or}.  Defined on integral types.
   17119 
   17120 @item ^
   17121 Bitwise exclusive-@sc{or}.  Defined on integral types.
   17122 
   17123 @item &
   17124 Bitwise @sc{and}.  Defined on integral types.
   17125 
   17126 @item ==@r{, }!=
   17127 Equality and inequality.  Defined on scalar types.  The value of these
   17128 expressions is 0 for false and non-zero for true.
   17129 
   17130 @item <@r{, }>@r{, }<=@r{, }>=
   17131 Less than, greater than, less than or equal, greater than or equal.
   17132 Defined on scalar types.  The value of these expressions is 0 for false
   17133 and non-zero for true.
   17134 
   17135 @item <<@r{, }>>
   17136 left shift, and right shift.  Defined on integral types.
   17137 
   17138 @item @@
   17139 The @value{GDBN} ``artificial array'' operator (@pxref{Expressions, ,Expressions}).
   17140 
   17141 @item +@r{, }-
   17142 Addition and subtraction.  Defined on integral types, floating-point types and
   17143 pointer types.
   17144 
   17145 @item *@r{, }/@r{, }%
   17146 Multiplication, division, and modulus.  Multiplication and division are
   17147 defined on integral and floating-point types.  Modulus is defined on
   17148 integral types.
   17149 
   17150 @item ++@r{, }--
   17151 Increment and decrement.  When appearing before a variable, the
   17152 operation is performed before the variable is used in an expression;
   17153 when appearing after it, the variable's value is used before the
   17154 operation takes place.
   17155 
   17156 @item *
   17157 Pointer dereferencing.  Defined on pointer types.  Same precedence as
   17158 @code{++}.
   17159 
   17160 @item &
   17161 Address operator.  Defined on variables.  Same precedence as @code{++}.
   17162 
   17163 For debugging C@t{++}, @value{GDBN} implements a use of @samp{&} beyond what is
   17164 allowed in the C@t{++} language itself: you can use @samp{&(&@var{ref})}
   17165 to examine the address
   17166 where a C@t{++} reference variable (declared with @samp{&@var{ref}}) is
   17167 stored.
   17168 
   17169 @item -
   17170 Negative.  Defined on integral and floating-point types.  Same
   17171 precedence as @code{++}.
   17172 
   17173 @item !
   17174 Logical negation.  Defined on integral types.  Same precedence as
   17175 @code{++}.
   17176 
   17177 @item ~
   17178 Bitwise complement operator.  Defined on integral types.  Same precedence as
   17179 @code{++}.
   17180 
   17181 
   17182 @item .@r{, }->
   17183 Structure member, and pointer-to-structure member.  For convenience,
   17184 @value{GDBN} regards the two as equivalent, choosing whether to dereference a
   17185 pointer based on the stored type information.
   17186 Defined on @code{struct} and @code{union} data.
   17187 
   17188 @item .*@r{, }->*
   17189 Dereferences of pointers to members.
   17190 
   17191 @item []
   17192 Array indexing.  @code{@var{a}[@var{i}]} is defined as
   17193 @code{*(@var{a}+@var{i})}.  Same precedence as @code{->}.
   17194 
   17195 @item ()
   17196 Function parameter list.  Same precedence as @code{->}.
   17197 
   17198 @item ::
   17199 C@t{++} scope resolution operator.  Defined on @code{struct}, @code{union},
   17200 and @code{class} types.
   17201 
   17202 @item ::
   17203 Doubled colons also represent the @value{GDBN} scope operator
   17204 (@pxref{Expressions, ,Expressions}).  Same precedence as @code{::},
   17205 above.
   17206 @end table
   17207 
   17208 If an operator is redefined in the user code, @value{GDBN} usually
   17209 attempts to invoke the redefined version instead of using the operator's
   17210 predefined meaning.
   17211 
   17212 @node C Constants
   17213 @subsubsection C and C@t{++} Constants
   17214 
   17215 @cindex C and C@t{++} constants
   17216 
   17217 @value{GDBN} allows you to express the constants of C and C@t{++} in the
   17218 following ways:
   17219 
   17220 @itemize @bullet
   17221 @item
   17222 Integer constants are a sequence of digits.  Octal constants are
   17223 specified by a leading @samp{0} (i.e.@: zero), and hexadecimal constants
   17224 by a leading @samp{0x} or @samp{0X}.  Constants may also end with a letter
   17225 @samp{l}, specifying that the constant should be treated as a
   17226 @code{long} value.
   17227 
   17228 @item
   17229 Floating point constants are a sequence of digits, followed by a decimal
   17230 point, followed by a sequence of digits, and optionally followed by an
   17231 exponent.  An exponent is of the form:
   17232 @samp{@w{e@r{[[}+@r{]|}-@r{]}@var{nnn}}}, where @var{nnn} is another
   17233 sequence of digits.  The @samp{+} is optional for positive exponents.
   17234 A floating-point constant may also end with a letter @samp{f} or
   17235 @samp{F}, specifying that the constant should be treated as being of
   17236 the @code{float} (as opposed to the default @code{double}) type; or with
   17237 a letter @samp{l} or @samp{L}, which specifies a @code{long double}
   17238 constant.
   17239 
   17240 @item
   17241 Enumerated constants consist of enumerated identifiers, or their
   17242 integral equivalents.
   17243 
   17244 @item
   17245 Character constants are a single character surrounded by single quotes
   17246 (@code{'}), or a number---the ordinal value of the corresponding character
   17247 (usually its @sc{ascii} value).  Within quotes, the single character may
   17248 be represented by a letter or by @dfn{escape sequences}, which are of
   17249 the form @samp{\@var{nnn}}, where @var{nnn} is the octal representation
   17250 of the character's ordinal value; or of the form @samp{\@var{x}}, where
   17251 @samp{@var{x}} is a predefined special character---for example,
   17252 @samp{\n} for newline.
   17253 
   17254 Wide character constants can be written by prefixing a character
   17255 constant with @samp{L}, as in C.  For example, @samp{L'x'} is the wide
   17256 form of @samp{x}.  The target wide character set is used when
   17257 computing the value of this constant (@pxref{Character Sets}).
   17258 
   17259 @item
   17260 String constants are a sequence of character constants surrounded by
   17261 double quotes (@code{"}).  Any valid character constant (as described
   17262 above) may appear.  Double quotes within the string must be preceded by
   17263 a backslash, so for instance @samp{"a\"b'c"} is a string of five
   17264 characters.
   17265 
   17266 Wide string constants can be written by prefixing a string constant
   17267 with @samp{L}, as in C.  The target wide character set is used when
   17268 computing the value of this constant (@pxref{Character Sets}).
   17269 
   17270 @item
   17271 Pointer constants are an integral value.  You can also write pointers
   17272 to constants using the C operator @samp{&}.
   17273 
   17274 @item
   17275 Array constants are comma-separated lists surrounded by braces @samp{@{}
   17276 and @samp{@}}; for example, @samp{@{1,2,3@}} is a three-element array of
   17277 integers, @samp{@{@{1,2@}, @{3,4@}, @{5,6@}@}} is a three-by-two array,
   17278 and @samp{@{&"hi", &"there", &"fred"@}} is a three-element array of pointers.
   17279 @end itemize
   17280 
   17281 @node C Plus Plus Expressions
   17282 @subsubsection C@t{++} Expressions
   17283 
   17284 @cindex expressions in C@t{++}
   17285 @value{GDBN} expression handling can interpret most C@t{++} expressions.
   17286 
   17287 @cindex debugging C@t{++} programs
   17288 @cindex C@t{++} compilers
   17289 @cindex debug formats and C@t{++}
   17290 @cindex @value{NGCC} and C@t{++}
   17291 @quotation
   17292 @emph{Warning:} @value{GDBN} can only debug C@t{++} code if you use
   17293 the proper compiler and the proper debug format.  Currently,
   17294 @value{GDBN} works best when debugging C@t{++} code that is compiled
   17295 with the most recent version of @value{NGCC} possible.  The DWARF
   17296 debugging format is preferred; @value{NGCC} defaults to this on most
   17297 popular platforms.  Other compilers and/or debug formats are likely to
   17298 work badly or not at all when using @value{GDBN} to debug C@t{++}
   17299 code.  @xref{Compilation}.
   17300 @end quotation
   17301 
   17302 @enumerate
   17303 
   17304 @cindex member functions
   17305 @item
   17306 Member function calls are allowed; you can use expressions like
   17307 
   17308 @smallexample
   17309 count = aml->GetOriginal(x, y)
   17310 @end smallexample
   17311 
   17312 @vindex this@r{, inside C@t{++} member functions}
   17313 @cindex namespace in C@t{++}
   17314 @item
   17315 While a member function is active (in the selected stack frame), your
   17316 expressions have the same namespace available as the member function;
   17317 that is, @value{GDBN} allows implicit references to the class instance
   17318 pointer @code{this} following the same rules as C@t{++}.  @code{using}
   17319 declarations in the current scope are also respected by @value{GDBN}.
   17320 
   17321 @cindex call overloaded functions
   17322 @cindex overloaded functions, calling
   17323 @cindex type conversions in C@t{++}
   17324 @item
   17325 You can call overloaded functions; @value{GDBN} resolves the function
   17326 call to the right definition, with some restrictions.  @value{GDBN} does not
   17327 perform overload resolution involving user-defined type conversions,
   17328 calls to constructors, or instantiations of templates that do not exist
   17329 in the program.  It also cannot handle ellipsis argument lists or
   17330 default arguments.
   17331 
   17332 It does perform integral conversions and promotions, floating-point
   17333 promotions, arithmetic conversions, pointer conversions, conversions of
   17334 class objects to base classes, and standard conversions such as those of
   17335 functions or arrays to pointers; it requires an exact match on the
   17336 number of function arguments.
   17337 
   17338 Overload resolution is always performed, unless you have specified
   17339 @code{set overload-resolution off}.  @xref{Debugging C Plus Plus,
   17340 ,@value{GDBN} Features for C@t{++}}.
   17341 
   17342 You must specify @code{set overload-resolution off} in order to use an
   17343 explicit function signature to call an overloaded function, as in
   17344 @smallexample
   17345 p 'foo(char,int)'('x', 13)
   17346 @end smallexample
   17347 
   17348 The @value{GDBN} command-completion facility can simplify this;
   17349 see @ref{Completion, ,Command Completion}.
   17350 
   17351 @cindex reference declarations
   17352 @item
   17353 @value{GDBN} understands variables declared as C@t{++} lvalue or rvalue
   17354 references; you can use them in expressions just as you do in C@t{++}
   17355 source---they are automatically dereferenced.
   17356 
   17357 In the parameter list shown when @value{GDBN} displays a frame, the values of
   17358 reference variables are not displayed (unlike other variables); this
   17359 avoids clutter, since references are often used for large structures.
   17360 The @emph{address} of a reference variable is always shown, unless
   17361 you have specified @samp{set print address off}.
   17362 
   17363 @item
   17364 @value{GDBN} supports the C@t{++} name resolution operator @code{::}---your
   17365 expressions can use it just as expressions in your program do.  Since
   17366 one scope may be defined in another, you can use @code{::} repeatedly if
   17367 necessary, for example in an expression like
   17368 @samp{@var{scope1}::@var{scope2}::@var{name}}.  @value{GDBN} also allows
   17369 resolving name scope by reference to source files, in both C and C@t{++}
   17370 debugging (@pxref{Variables, ,Program Variables}).
   17371 
   17372 @item
   17373 @value{GDBN} performs argument-dependent lookup, following the C@t{++}
   17374 specification.
   17375 @end enumerate
   17376 
   17377 @node C Defaults
   17378 @subsubsection C and C@t{++} Defaults
   17379 
   17380 @cindex C and C@t{++} defaults
   17381 
   17382 If you allow @value{GDBN} to set range checking automatically, it
   17383 defaults to @code{off} whenever the working language changes to
   17384 C or C@t{++}.  This happens regardless of whether you or @value{GDBN}
   17385 selects the working language.
   17386 
   17387 If you allow @value{GDBN} to set the language automatically, it
   17388 recognizes source files whose names end with @file{.c}, @file{.C}, or
   17389 @file{.cc}, etc, and when @value{GDBN} enters code compiled from one of
   17390 these files, it sets the working language to C or C@t{++}.
   17391 @xref{Automatically, ,Having @value{GDBN} Infer the Source Language},
   17392 for further details.
   17393 
   17394 @node C Checks
   17395 @subsubsection C and C@t{++} Type and Range Checks
   17396 
   17397 @cindex C and C@t{++} checks
   17398 
   17399 By default, when @value{GDBN} parses C or C@t{++} expressions, strict type
   17400 checking is used.  However, if you turn type checking off, @value{GDBN}
   17401 will allow certain non-standard conversions, such as promoting integer
   17402 constants to pointers.
   17403 
   17404 Range checking, if turned on, is done on mathematical operations.  Array
   17405 indices are not checked, since they are often used to index a pointer
   17406 that is not itself an array.
   17407 
   17408 @node Debugging C
   17409 @subsubsection @value{GDBN} and C
   17410 
   17411 The @code{set print union} and @code{show print union} commands apply to
   17412 the @code{union} type.  When set to @samp{on}, any @code{union} that is
   17413 inside a @code{struct} or @code{class} is also printed.  Otherwise, it
   17414 appears as @samp{@{...@}}.
   17415 
   17416 The @code{@@} operator aids in the debugging of dynamic arrays, formed
   17417 with pointers and a memory allocation function.  @xref{Expressions,
   17418 ,Expressions}.
   17419 
   17420 @node Debugging C Plus Plus
   17421 @subsubsection @value{GDBN} Features for C@t{++}
   17422 
   17423 @cindex commands for C@t{++}
   17424 
   17425 Some @value{GDBN} commands are particularly useful with C@t{++}, and some are
   17426 designed specifically for use with C@t{++}.  Here is a summary:
   17427 
   17428 @table @code
   17429 @cindex break in overloaded functions
   17430 @item @r{breakpoint menus}
   17431 When you want a breakpoint in a function whose name is overloaded,
   17432 @value{GDBN} has the capability to display a menu of possible breakpoint
   17433 locations to help you specify which function definition you want.
   17434 @xref{Ambiguous Expressions,,Ambiguous Expressions}.
   17435 
   17436 @cindex overloading in C@t{++}
   17437 @item rbreak @var{regex}
   17438 Setting breakpoints using regular expressions is helpful for setting
   17439 breakpoints on overloaded functions that are not members of any special
   17440 classes.
   17441 @xref{Set Breaks, ,Setting Breakpoints}.
   17442 
   17443 @cindex C@t{++} exception handling
   17444 @item catch throw
   17445 @itemx catch rethrow
   17446 @itemx catch catch
   17447 Debug C@t{++} exception handling using these commands.  @xref{Set
   17448 Catchpoints, , Setting Catchpoints}.
   17449 
   17450 @cindex inheritance
   17451 @item ptype @var{typename}
   17452 Print inheritance relationships as well as other information for type
   17453 @var{typename}.
   17454 @xref{Symbols, ,Examining the Symbol Table}.
   17455 
   17456 @item info vtbl @var{expression}.
   17457 The @code{info vtbl} command can be used to display the virtual
   17458 method tables of the object computed by @var{expression}.  This shows
   17459 one entry per virtual table; there may be multiple virtual tables when
   17460 multiple inheritance is in use.
   17461 
   17462 @cindex C@t{++} demangling
   17463 @item demangle @var{name}
   17464 Demangle @var{name}.
   17465 @xref{Symbols}, for a more complete description of the @code{demangle} command.
   17466 
   17467 @cindex C@t{++} symbol display
   17468 @item set print demangle
   17469 @itemx show print demangle
   17470 @itemx set print asm-demangle
   17471 @itemx show print asm-demangle
   17472 Control whether C@t{++} symbols display in their source form, both when
   17473 displaying code as C@t{++} source and when displaying disassemblies.
   17474 @xref{Print Settings, ,Print Settings}.
   17475 
   17476 @item set print object
   17477 @itemx show print object
   17478 Choose whether to print derived (actual) or declared types of objects.
   17479 @xref{Print Settings, ,Print Settings}.
   17480 
   17481 @item set print vtbl
   17482 @itemx show print vtbl
   17483 Control the format for printing virtual function tables.
   17484 @xref{Print Settings, ,Print Settings}.
   17485 (The @code{vtbl} commands do not work on programs compiled with the HP
   17486 ANSI C@t{++} compiler (@code{aCC}).)
   17487 
   17488 @kindex set overload-resolution
   17489 @cindex overloaded functions, overload resolution
   17490 @item set overload-resolution on
   17491 Enable overload resolution for C@t{++} expression evaluation.  The default
   17492 is on.  For overloaded functions, @value{GDBN} evaluates the arguments
   17493 and searches for a function whose signature matches the argument types,
   17494 using the standard C@t{++} conversion rules (see @ref{C Plus Plus
   17495 Expressions, ,C@t{++} Expressions}, for details).
   17496 If it cannot find a match, it emits a message.
   17497 
   17498 @item set overload-resolution off
   17499 Disable overload resolution for C@t{++} expression evaluation.  For
   17500 overloaded functions that are not class member functions, @value{GDBN}
   17501 chooses the first function of the specified name that it finds in the
   17502 symbol table, whether or not its arguments are of the correct type.  For
   17503 overloaded functions that are class member functions, @value{GDBN}
   17504 searches for a function whose signature @emph{exactly} matches the
   17505 argument types.
   17506 
   17507 @kindex show overload-resolution
   17508 @item show overload-resolution
   17509 Show the current setting of overload resolution.
   17510 
   17511 @item @r{Overloaded symbol names}
   17512 You can specify a particular definition of an overloaded symbol, using
   17513 the same notation that is used to declare such symbols in C@t{++}: type
   17514 @code{@var{symbol}(@var{types})} rather than just @var{symbol}.  You can
   17515 also use the @value{GDBN} command-line word completion facilities to list the
   17516 available choices, or to finish the type list for you.
   17517 @xref{Completion,, Command Completion}, for details on how to do this.
   17518 
   17519 @item @r{Breakpoints in template functions}
   17520 
   17521 Similar to how overloaded symbols are handled, @value{GDBN} will ignore
   17522 template parameter lists when it encounters a symbol which includes a
   17523 C@t{++} template.  This permits setting breakpoints on families of template functions
   17524 or functions whose parameters include template types.
   17525 
   17526 The @kbd{-qualified} flag may be used to override this behavior, causing
   17527 @value{GDBN} to search for a specific function or type.
   17528 
   17529 The @value{GDBN} command-line word completion facility also understands
   17530 template parameters and may be used to list available choices or finish
   17531 template parameter lists for you. @xref{Completion,, Command Completion}, for
   17532 details on how to do this.
   17533 
   17534 @item @r{Breakpoints in functions with ABI tags}
   17535 
   17536 The GNU C@t{++} compiler introduced the notion of ABI ``tags'', which
   17537 correspond to changes in the ABI of a type, function, or variable that
   17538 would not otherwise be reflected in a mangled name.  See
   17539 @url{https://developers.redhat.com/blog/2015/02/05/gcc5-and-the-c11-abi/}
   17540 for more detail.
   17541 
   17542 The ABI tags are visible in C@t{++} demangled names.  For example, a
   17543 function that returns a std::string:
   17544 
   17545 @smallexample
   17546 std::string function(int);
   17547 @end smallexample
   17548 
   17549 @noindent
   17550 when compiled for the C++11 ABI is marked with the @code{cxx11} ABI
   17551 tag, and @value{GDBN} displays the symbol like this:
   17552 
   17553 @smallexample
   17554 function[abi:cxx11](int)
   17555 @end smallexample
   17556 
   17557 You can set a breakpoint on such functions simply as if they had no
   17558 tag.  For example:
   17559 
   17560 @smallexample
   17561 (@value{GDBP}) b function(int)
   17562 Breakpoint 2 at 0x40060d: file main.cc, line 10.
   17563 (@value{GDBP}) info breakpoints
   17564 Num     Type           Disp Enb Address    What
   17565 1       breakpoint     keep y   0x0040060d in function[abi:cxx11](int)
   17566                                            at main.cc:10
   17567 @end smallexample
   17568 
   17569 On the rare occasion you need to disambiguate between different ABI
   17570 tags, you can do so by simply including the ABI tag in the function
   17571 name, like:
   17572 
   17573 @smallexample
   17574 (@value{GDBP}) b ambiguous[abi:other_tag](int)
   17575 @end smallexample
   17576 @end table
   17577 
   17578 @node Decimal Floating Point
   17579 @subsubsection Decimal Floating Point format
   17580 @cindex decimal floating point format
   17581 
   17582 @value{GDBN} can examine, set and perform computations with numbers in
   17583 decimal floating point format, which in the C language correspond to the
   17584 @code{_Decimal32}, @code{_Decimal64} and @code{_Decimal128} types as
   17585 specified by the extension to support decimal floating-point arithmetic.
   17586 
   17587 There are two encodings in use, depending on the architecture: BID (Binary
   17588 Integer Decimal) for x86 and x86-64, and DPD (Densely Packed Decimal) for
   17589 PowerPC and S/390.  @value{GDBN} will use the appropriate encoding for the
   17590 configured target.
   17591 
   17592 Because of a limitation in @file{libdecnumber}, the library used by @value{GDBN}
   17593 to manipulate decimal floating point numbers, it is not possible to convert
   17594 (using a cast, for example) integers wider than 32-bit to decimal float.
   17595 
   17596 In addition, in order to imitate @value{GDBN}'s behavior with binary floating
   17597 point computations, error checking in decimal float operations ignores
   17598 underflow, overflow and divide by zero exceptions.
   17599 
   17600 In the PowerPC architecture, @value{GDBN} provides a set of pseudo-registers
   17601 to inspect @code{_Decimal128} values stored in floating point registers.
   17602 See @ref{PowerPC,,PowerPC} for more details.
   17603 
   17604 @node D
   17605 @subsection D
   17606 
   17607 @cindex D
   17608 @value{GDBN} can be used to debug programs written in D and compiled with
   17609 GDC, LDC or DMD compilers. Currently @value{GDBN} supports only one D
   17610 specific feature --- dynamic arrays.
   17611 
   17612 @node Go
   17613 @subsection Go
   17614 
   17615 @cindex Go (programming language)
   17616 @value{GDBN} can be used to debug programs written in Go and compiled with
   17617 @file{gccgo} or @file{6g} compilers.
   17618 
   17619 Here is a summary of the Go-specific features and restrictions:
   17620 
   17621 @table @code
   17622 @cindex current Go package
   17623 @item The current Go package
   17624 The name of the current package does not need to be specified when
   17625 specifying global variables and functions.
   17626 
   17627 For example, given the program:
   17628 
   17629 @example
   17630 package main
   17631 var myglob = "Shall we?"
   17632 func main () @{
   17633   // ...
   17634 @}
   17635 @end example
   17636 
   17637 When stopped inside @code{main} either of these work:
   17638 
   17639 @example
   17640 (@value{GDBP}) p myglob
   17641 (@value{GDBP}) p main.myglob
   17642 @end example
   17643 
   17644 @cindex builtin Go types
   17645 @item Builtin Go types
   17646 The @code{string} type is recognized by @value{GDBN} and is printed
   17647 as a string.
   17648 
   17649 @cindex builtin Go functions
   17650 @item Builtin Go functions
   17651 The @value{GDBN} expression parser recognizes the @code{unsafe.Sizeof}
   17652 function and handles it internally.
   17653 
   17654 @cindex restrictions on Go expressions
   17655 @item Restrictions on Go expressions
   17656 All Go operators are supported except @code{&^}.
   17657 The Go @code{_} ``blank identifier'' is not supported.
   17658 Automatic dereferencing of pointers is not supported.
   17659 @end table
   17660 
   17661 @node Objective-C
   17662 @subsection Objective-C
   17663 
   17664 @cindex Objective-C
   17665 This section provides information about some commands and command
   17666 options that are useful for debugging Objective-C code.  See also
   17667 @ref{Symbols, info classes}, and @ref{Symbols, info selectors}, for a
   17668 few more commands specific to Objective-C support.
   17669 
   17670 @menu
   17671 * Method Names in Commands::
   17672 * The Print Command with Objective-C::
   17673 @end menu
   17674 
   17675 @node Method Names in Commands
   17676 @subsubsection Method Names in Commands
   17677 
   17678 The following commands have been extended to accept Objective-C method
   17679 names as line specifications:
   17680 
   17681 @kindex clear@r{, and Objective-C}
   17682 @kindex break@r{, and Objective-C}
   17683 @kindex info line@r{, and Objective-C}
   17684 @kindex jump@r{, and Objective-C}
   17685 @kindex list@r{, and Objective-C}
   17686 @itemize
   17687 @item @code{clear}
   17688 @item @code{break}
   17689 @item @code{info line}
   17690 @item @code{jump}
   17691 @item @code{list}
   17692 @end itemize
   17693 
   17694 A fully qualified Objective-C method name is specified as
   17695 
   17696 @smallexample
   17697 -[@var{Class} @var{methodName}]
   17698 @end smallexample
   17699 
   17700 where the minus sign is used to indicate an instance method and a
   17701 plus sign (not shown) is used to indicate a class method.  The class
   17702 name @var{Class} and method name @var{methodName} are enclosed in
   17703 brackets, similar to the way messages are specified in Objective-C
   17704 source code.  For example, to set a breakpoint at the @code{create}
   17705 instance method of class @code{Fruit} in the program currently being
   17706 debugged, enter:
   17707 
   17708 @smallexample
   17709 break -[Fruit create]
   17710 @end smallexample
   17711 
   17712 To list ten program lines around the @code{initialize} class method,
   17713 enter:
   17714 
   17715 @smallexample
   17716 list +[NSText initialize]
   17717 @end smallexample
   17718 
   17719 In the current version of @value{GDBN}, the plus or minus sign is
   17720 required.  In future versions of @value{GDBN}, the plus or minus
   17721 sign will be optional, but you can use it to narrow the search.  It
   17722 is also possible to specify just a method name:
   17723 
   17724 @smallexample
   17725 break create
   17726 @end smallexample
   17727 
   17728 You must specify the complete method name, including any colons.  If
   17729 your program's source files contain more than one @code{create} method,
   17730 you'll be presented with a numbered list of classes that implement that
   17731 method.  Indicate your choice by number, or type @samp{0} to exit if
   17732 none apply.
   17733 
   17734 As another example, to clear a breakpoint established at the
   17735 @code{makeKeyAndOrderFront:} method of the @code{NSWindow} class, enter:
   17736 
   17737 @smallexample
   17738 clear -[NSWindow makeKeyAndOrderFront:]
   17739 @end smallexample
   17740 
   17741 @node The Print Command with Objective-C
   17742 @subsubsection The Print Command With Objective-C
   17743 @cindex Objective-C, print objects
   17744 @kindex print-object
   17745 @kindex po @r{(@code{print-object})}
   17746 
   17747 The print command has also been extended to accept methods.  For example:
   17748 
   17749 @smallexample
   17750 print -[@var{object} hash]
   17751 @end smallexample
   17752 
   17753 @cindex print an Objective-C object description
   17754 @cindex @code{_NSPrintForDebugger}, and printing Objective-C objects
   17755 @noindent
   17756 will tell @value{GDBN} to send the @code{hash} message to @var{object}
   17757 and print the result.  Also, an additional command has been added,
   17758 @code{print-object} or @code{po} for short, which is meant to print
   17759 the description of an object.  However, this command may only work
   17760 with certain Objective-C libraries that have a particular hook
   17761 function, @code{_NSPrintForDebugger}, defined.
   17762 
   17763 @node OpenCL C
   17764 @subsection OpenCL C
   17765 
   17766 @cindex OpenCL C
   17767 This section provides information about @value{GDBN}s OpenCL C support.
   17768 
   17769 @menu
   17770 * OpenCL C Datatypes::
   17771 * OpenCL C Expressions::
   17772 * OpenCL C Operators::
   17773 @end menu
   17774 
   17775 @node OpenCL C Datatypes
   17776 @subsubsection OpenCL C Datatypes
   17777 
   17778 @cindex OpenCL C Datatypes
   17779 @value{GDBN} supports the builtin scalar and vector datatypes specified
   17780 by OpenCL 1.1.  In addition the half- and double-precision floating point
   17781 data types of the @code{cl_khr_fp16} and @code{cl_khr_fp64} OpenCL
   17782 extensions are also known to @value{GDBN}.
   17783 
   17784 @node OpenCL C Expressions
   17785 @subsubsection OpenCL C Expressions
   17786 
   17787 @cindex OpenCL C Expressions
   17788 @value{GDBN} supports accesses to vector components including the access as
   17789 lvalue where possible.  Since OpenCL C is based on C99 most C expressions
   17790 supported by @value{GDBN} can be used as well.
   17791 
   17792 @node OpenCL C Operators
   17793 @subsubsection OpenCL C Operators
   17794 
   17795 @cindex OpenCL C Operators
   17796 @value{GDBN} supports the operators specified by OpenCL 1.1 for scalar and
   17797 vector data types.
   17798 
   17799 @node Fortran
   17800 @subsection Fortran
   17801 @cindex Fortran-specific support in @value{GDBN}
   17802 
   17803 @value{GDBN} can be used to debug programs written in Fortran.  Note, that not
   17804 all Fortran language features are available yet.
   17805 
   17806 @cindex trailing underscore, in Fortran symbols
   17807 Some Fortran compilers (@sc{gnu} Fortran 77 and Fortran 95 compilers
   17808 among them) append an underscore to the names of variables and
   17809 functions.  When you debug programs compiled by those compilers, you
   17810 will need to refer to variables and functions with a trailing
   17811 underscore.
   17812 
   17813 @cindex Fortran Defaults
   17814 Fortran symbols are usually case-insensitive, so @value{GDBN} by
   17815 default uses case-insensitive matching for Fortran symbols.  You can
   17816 change that with the @samp{set case-insensitive} command, see
   17817 @ref{Symbols}, for the details.
   17818 
   17819 @menu
   17820 * Fortran Types::               Fortran builtin types
   17821 * Fortran Operators::           Fortran operators and expressions
   17822 * Fortran Intrinsics::          Fortran intrinsic functions
   17823 * Special Fortran Commands::    Special @value{GDBN} commands for Fortran
   17824 @end menu
   17825 
   17826 @node Fortran Types
   17827 @subsubsection Fortran Types
   17828 
   17829 @cindex Fortran Types
   17830 
   17831 In Fortran the primitive data-types have an associated @code{KIND} type
   17832 parameter, written as @samp{@var{type}*@var{kindparam}},
   17833 @samp{@var{type}*@var{kindparam}}, or in the @value{GDBN}-only dialect
   17834 @samp{@var{type}_@var{kindparam}}.  A concrete example would be
   17835 @samp{@code{Real*4}}, @samp{@code{Real(kind=4)}}, and @samp{@code{Real_4}}.
   17836 The kind of a type can be retrieved by using the intrinsic function
   17837 @code{KIND}, see @ref{Fortran Intrinsics}.
   17838 
   17839 Generally, the actual implementation of the @code{KIND} type parameter is
   17840 compiler specific.  In @value{GDBN} the kind parameter is implemented in
   17841 accordance with its use in the @sc{gnu} @command{gfortran} compiler.  Here, the
   17842 kind parameter for a given @var{type} specifies its size in memory --- a
   17843 Fortran @code{Integer*4} or @code{Integer(kind=4)} would be an integer type
   17844 occupying 4 bytes of memory.  An exception to this rule is the @code{Complex}
   17845 type for which the kind of the type does not specify its entire size, but
   17846 the size of each of the two @code{Real}'s it is composed of.  A
   17847 @code{Complex*4} would thus consist of two @code{Real*4}s and occupy 8 bytes
   17848 of memory.
   17849 
   17850 For every type there is also a default kind associated with it, e.g.@
   17851 @code{Integer} in @value{GDBN} will internally be an @code{Integer*4} (see the
   17852 table below for default types).  The default types are the same as in @sc{gnu}
   17853 compilers but note, that the @sc{gnu} default types can actually be changed by
   17854 compiler flags such as @option{-fdefault-integer-8} and
   17855 @option{-fdefault-real-8}.
   17856 
   17857 Not every kind parameter is valid for every type and in @value{GDBN} the
   17858 following type kinds are available.
   17859 
   17860 @table @code
   17861 @item Integer
   17862 @code{Integer*1}, @code{Integer*2}, @code{Integer*4}, @code{Integer*8}, and
   17863 @code{Integer} = @code{Integer*4}.
   17864 
   17865 @item Logical
   17866 @code{Logical*1}, @code{Logical*2}, @code{Logical*4}, @code{Logical*8}, and
   17867 @code{Logical} = @code{Logical*4}.
   17868 
   17869 @item Real
   17870 @code{Real*4}, @code{Real*8}, @code{Real*16}, and @code{Real} = @code{Real*4}.
   17871 
   17872 @item Complex
   17873 @code{Complex*4}, @code{Complex*8}, @code{Complex*16}, and @code{Complex} =
   17874 @code{Complex*4}.
   17875 
   17876 @end table
   17877 
   17878 @node Fortran Operators
   17879 @subsubsection Fortran Operators and Expressions
   17880 
   17881 @cindex Fortran operators and expressions
   17882 
   17883 Operators must be defined on values of specific types.  For instance,
   17884 @code{+} is defined on numbers, but not on characters or other non-
   17885 arithmetic types.  Operators are often defined on groups of types.
   17886 
   17887 @table @code
   17888 @item **
   17889 The exponentiation operator.  It raises the first operand to the power
   17890 of the second one.
   17891 
   17892 @item :
   17893 The range operator.  Normally used in the form of array(low:high) to
   17894 represent a section of array.
   17895 
   17896 @item %
   17897 The access component operator.  Normally used to access elements in derived
   17898 types.  Also suitable for unions.  As unions aren't part of regular Fortran,
   17899 this can only happen when accessing a register that uses a gdbarch-defined
   17900 union type.
   17901 @item ::
   17902 The scope operator.  Normally used to access variables in modules or
   17903 to set breakpoints on subroutines nested in modules or in other
   17904 subroutines (internal subroutines).
   17905 @end table
   17906 
   17907 @node Fortran Intrinsics
   17908 @subsubsection Fortran Intrinsics
   17909 
   17910 @cindex Fortran Intrinsics
   17911 
   17912 Fortran provides a large set of intrinsic procedures.  @value{GDBN} implements
   17913 an incomplete subset of those procedures and their overloads.  Some of these
   17914 procedures take an optional @code{KIND} parameter, see @ref{Fortran Types}.
   17915 
   17916 @table @code
   17917 @item ABS(@var{a})
   17918 Computes the absolute value of its argument @var{a}.  Currently not supported
   17919 for @code{Complex} arguments.
   17920 
   17921 @item ALLOCATE(@var{array})
   17922 Returns whether @var{array} is allocated or not.
   17923 
   17924 @item ASSOCIATED(@var{pointer} [, @var{target}])
   17925 Returns the association status of the pointer @var{pointer} or, if @var{target}
   17926 is present, whether @var{pointer} is associated with the target @var{target}.
   17927 
   17928 @item CEILING(@var{a} [, @var{kind}])
   17929 Computes the least integer greater than or equal to @var{a}.  The optional
   17930 parameter @var{kind} specifies the kind of the return type
   17931 @code{Integer(@var{kind})}.
   17932 
   17933 @item CMPLX(@var{x} [, @var{y} [, @var{kind}]])
   17934 Returns a complex number where @var{x} is converted to the real component.  If
   17935 @var{y} is present it is converted to the imaginary component.  If @var{y} is
   17936 not present then the imaginary component is set to @code{0.0} except if @var{x}
   17937 itself is of @code{Complex} type.  The optional parameter @var{kind} specifies
   17938 the kind of the return type @code{Complex(@var{kind})}.
   17939 
   17940 @item FLOOR(@var{a} [, @var{kind}])
   17941 Computes the greatest integer less than or equal to @var{a}.  The optional
   17942 parameter @var{kind} specifies the kind of the return type
   17943 @code{Integer(@var{kind})}.
   17944 
   17945 @item KIND(@var{a})
   17946 Returns the kind value of the argument @var{a}, see @ref{Fortran Types}.
   17947 
   17948 @item LBOUND(@var{array} [, @var{dim} [, @var{kind}]])
   17949 Returns the lower bounds of an @var{array}, or a single lower bound along the
   17950 @var{dim} dimension if present.  The optional parameter @var{kind} specifies
   17951 the kind of the return type @code{Integer(@var{kind})}.
   17952 
   17953 @item LOC(@var{x})
   17954 Returns the address of @var{x} as an @code{Integer}.
   17955 
   17956 @item MOD(@var{a}, @var{p})
   17957 Computes the remainder of the division of @var{a} by @var{p}.
   17958 
   17959 @item MODULO(@var{a}, @var{p})
   17960 Computes the @var{a} modulo @var{p}.
   17961 
   17962 @item RANK(@var{a})
   17963 Returns the rank of a scalar or array (scalars have rank @code{0}).
   17964 
   17965 @item SHAPE(@var{a})
   17966 Returns the shape of a scalar or array (scalars have shape @samp{()}).
   17967 
   17968 @item SIZE(@var{array}[, @var{dim} [, @var{kind}]])
   17969 Returns the extent of @var{array} along a specified dimension @var{dim}, or the
   17970 total number of elements in @var{array} if @var{dim} is absent.  The optional
   17971 parameter @var{kind} specifies the kind of the return type
   17972 @code{Integer(@var{kind})}.
   17973 
   17974 @item UBOUND(@var{array} [, @var{dim} [, @var{kind}]])
   17975 Returns the upper bounds of an @var{array}, or a single upper bound along the
   17976 @var{dim} dimension if present.  The optional parameter @var{kind} specifies
   17977 the kind of the return type @code{Integer(@var{kind})}.
   17978 
   17979 @end table
   17980 
   17981 @node Special Fortran Commands
   17982 @subsubsection Special Fortran Commands
   17983 
   17984 @cindex Special Fortran commands
   17985 
   17986 @value{GDBN} has some commands to support Fortran-specific features,
   17987 such as displaying common blocks.
   17988 
   17989 @table @code
   17990 @cindex @code{COMMON} blocks, Fortran
   17991 @kindex info common
   17992 @item info common @r{[}@var{common-name}@r{]}
   17993 This command prints the values contained in the Fortran @code{COMMON}
   17994 block whose name is @var{common-name}.  With no argument, the names of
   17995 all @code{COMMON} blocks visible at the current program location are
   17996 printed.
   17997 @cindex arrays slices (Fortran)
   17998 @kindex set fortran repack-array-slices
   17999 @kindex show fortran repack-array-slices
   18000 @item set fortran repack-array-slices [on|off]
   18001 @item show fortran repack-array-slices
   18002 When taking a slice from an array, a Fortran compiler can choose to
   18003 either produce an array descriptor that describes the slice in place,
   18004 or it may repack the slice, copying the elements of the slice into a
   18005 new region of memory.
   18006 
   18007 When this setting is on, then @value{GDBN} will also repack array
   18008 slices in some situations.  When this setting is off, then
   18009 @value{GDBN} will create array descriptors for slices that reference
   18010 the original data in place.
   18011 
   18012 @value{GDBN} will never repack an array slice if the data for the
   18013 slice is contiguous within the original array.
   18014 
   18015 @value{GDBN} will always repack string slices if the data for the
   18016 slice is non-contiguous within the original string as @value{GDBN}
   18017 does not support printing non-contiguous strings.
   18018 
   18019 The default for this setting is @code{off}.
   18020 @end table
   18021 
   18022 @node Pascal
   18023 @subsection Pascal
   18024 
   18025 @cindex Pascal support in @value{GDBN}, limitations
   18026 Debugging Pascal programs which use sets, subranges, file variables, or
   18027 nested functions does not currently work.  @value{GDBN} does not support
   18028 entering expressions, printing values, or similar features using Pascal
   18029 syntax.
   18030 
   18031 The Pascal-specific command @code{set print pascal_static-members}
   18032 controls whether static members of Pascal objects are displayed.
   18033 @xref{Print Settings, pascal_static-members}.
   18034 
   18035 @node Rust
   18036 @subsection Rust
   18037 
   18038 @value{GDBN} supports the @url{https://www.rust-lang.org/, Rust
   18039 Programming Language}.  Type- and value-printing, and expression
   18040 parsing, are reasonably complete.  However, there are a few
   18041 peculiarities and holes to be aware of.
   18042 
   18043 @itemize @bullet
   18044 @item
   18045 Linespecs (@pxref{Location Specifications}) are never relative to the
   18046 current crate.  Instead, they act as if there were a global namespace
   18047 of crates, somewhat similar to the way @code{extern crate} behaves.
   18048 
   18049 That is, if @value{GDBN} is stopped at a breakpoint in a function in
   18050 crate @samp{A}, module @samp{B}, then @code{break B::f} will attempt
   18051 to set a breakpoint in a function named @samp{f} in a crate named
   18052 @samp{B}.
   18053 
   18054 As a consequence of this approach, linespecs also cannot refer to
   18055 items using @samp{self::} or @samp{super::}.
   18056 
   18057 @item
   18058 Because @value{GDBN} implements Rust name-lookup semantics in
   18059 expressions, it will sometimes prepend the current crate to a name.
   18060 For example, if @value{GDBN} is stopped at a breakpoint in the crate
   18061 @samp{K}, then @code{print ::x::y} will try to find the symbol
   18062 @samp{K::x::y}.
   18063 
   18064 However, since it is useful to be able to refer to other crates when
   18065 debugging, @value{GDBN} provides the @code{extern} extension to
   18066 circumvent this.  To use the extension, just put @code{extern} before
   18067 a path expression to refer to the otherwise unavailable ``global''
   18068 scope.
   18069 
   18070 In the above example, if you wanted to refer to the symbol @samp{y} in
   18071 the crate @samp{x}, you would use @code{print extern x::y}.
   18072 
   18073 @item
   18074 The Rust expression evaluator does not support ``statement-like''
   18075 expressions such as @code{if} or @code{match}, or lambda expressions.
   18076 
   18077 @item
   18078 Tuple expressions are not implemented.
   18079 
   18080 @item
   18081 The Rust expression evaluator does not currently implement the
   18082 @code{Drop} trait.  Objects that may be created by the evaluator will
   18083 never be destroyed.
   18084 
   18085 @item
   18086 @value{GDBN} does not implement type inference for generics.  In order
   18087 to call generic functions or otherwise refer to generic items, you
   18088 will have to specify the type parameters manually.
   18089 
   18090 @item
   18091 @value{GDBN} currently uses the C@t{++} demangler for Rust.  In most
   18092 cases this does not cause any problems.  However, in an expression
   18093 context, completing a generic function name will give syntactically
   18094 invalid results.  This happens because Rust requires the @samp{::}
   18095 operator between the function name and its generic arguments.  For
   18096 example, @value{GDBN} might provide a completion like
   18097 @code{crate::f<u32>}, where the parser would require
   18098 @code{crate::f::<u32>}.
   18099 
   18100 @item
   18101 As of this writing, the Rust compiler (version 1.8) has a few holes in
   18102 the debugging information it generates.  These holes prevent certain
   18103 features from being implemented by @value{GDBN}:
   18104 @itemize @bullet
   18105 
   18106 @item
   18107 Method calls cannot be made via traits.
   18108 
   18109 @item
   18110 Operator overloading is not implemented.
   18111 
   18112 @item
   18113 When debugging in a monomorphized function, you cannot use the generic
   18114 type names.
   18115 
   18116 @item
   18117 The type @code{Self} is not available.
   18118 
   18119 @item
   18120 @code{use} statements are not available, so some names may not be
   18121 available in the crate.
   18122 @end itemize
   18123 @end itemize
   18124 
   18125 @node Modula-2
   18126 @subsection Modula-2
   18127 
   18128 @cindex Modula-2, @value{GDBN} support
   18129 
   18130 The extensions made to @value{GDBN} to support Modula-2 only support
   18131 output from the @sc{gnu} Modula-2 compiler (which is currently being
   18132 developed).  Other Modula-2 compilers are not currently supported, and
   18133 attempting to debug executables produced by them is most likely
   18134 to give an error as @value{GDBN} reads in the executable's symbol
   18135 table.
   18136 
   18137 @cindex expressions in Modula-2
   18138 @menu
   18139 * M2 Operators::                Built-in operators
   18140 * Built-In Func/Proc::          Built-in functions and procedures
   18141 * M2 Constants::                Modula-2 constants
   18142 * M2 Types::                    Modula-2 types
   18143 * M2 Defaults::                 Default settings for Modula-2
   18144 * Deviations::                  Deviations from standard Modula-2
   18145 * M2 Checks::                   Modula-2 type and range checks
   18146 * M2 Scope::                    The scope operators @code{::} and @code{.}
   18147 * GDB/M2::                      @value{GDBN} and Modula-2
   18148 @end menu
   18149 
   18150 @node M2 Operators
   18151 @subsubsection Operators
   18152 @cindex Modula-2 operators
   18153 
   18154 Operators must be defined on values of specific types.  For instance,
   18155 @code{+} is defined on numbers, but not on structures.  Operators are
   18156 often defined on groups of types.  For the purposes of Modula-2, the
   18157 following definitions hold:
   18158 
   18159 @itemize @bullet
   18160 
   18161 @item
   18162 @emph{Integral types} consist of @code{INTEGER}, @code{CARDINAL}, and
   18163 their subranges.
   18164 
   18165 @item
   18166 @emph{Character types} consist of @code{CHAR} and its subranges.
   18167 
   18168 @item
   18169 @emph{Floating-point types} consist of @code{REAL}.
   18170 
   18171 @item
   18172 @emph{Pointer types} consist of anything declared as @code{POINTER TO
   18173 @var{type}}.
   18174 
   18175 @item
   18176 @emph{Scalar types} consist of all of the above.
   18177 
   18178 @item
   18179 @emph{Set types} consist of @code{SET} and @code{BITSET} types.
   18180 
   18181 @item
   18182 @emph{Boolean types} consist of @code{BOOLEAN}.
   18183 @end itemize
   18184 
   18185 @noindent
   18186 The following operators are supported, and appear in order of
   18187 increasing precedence:
   18188 
   18189 @table @code
   18190 @item ,
   18191 Function argument or array index separator.
   18192 
   18193 @item :=
   18194 Assignment.  The value of @var{var} @code{:=} @var{value} is
   18195 @var{value}.
   18196 
   18197 @item <@r{, }>
   18198 Less than, greater than on integral, floating-point, or enumerated
   18199 types.
   18200 
   18201 @item <=@r{, }>=
   18202 Less than or equal to, greater than or equal to
   18203 on integral, floating-point and enumerated types, or set inclusion on
   18204 set types.  Same precedence as @code{<}.
   18205 
   18206 @item =@r{, }<>@r{, }#
   18207 Equality and two ways of expressing inequality, valid on scalar types.
   18208 Same precedence as @code{<}.  In @value{GDBN} scripts, only @code{<>} is
   18209 available for inequality, since @code{#} conflicts with the script
   18210 comment character.
   18211 
   18212 @item IN
   18213 Set membership.  Defined on set types and the types of their members.
   18214 Same precedence as @code{<}.
   18215 
   18216 @item OR
   18217 Boolean disjunction.  Defined on boolean types.
   18218 
   18219 @item AND@r{, }&
   18220 Boolean conjunction.  Defined on boolean types.
   18221 
   18222 @item @@
   18223 The @value{GDBN} ``artificial array'' operator (@pxref{Expressions, ,Expressions}).
   18224 
   18225 @item +@r{, }-
   18226 Addition and subtraction on integral and floating-point types, or union
   18227 and difference on set types.
   18228 
   18229 @item *
   18230 Multiplication on integral and floating-point types, or set intersection
   18231 on set types.
   18232 
   18233 @item /
   18234 Division on floating-point types, or symmetric set difference on set
   18235 types.  Same precedence as @code{*}.
   18236 
   18237 @item DIV@r{, }MOD
   18238 Integer division and remainder.  Defined on integral types.  Same
   18239 precedence as @code{*}.
   18240 
   18241 @item -
   18242 Negative.  Defined on @code{INTEGER} and @code{REAL} data.
   18243 
   18244 @item ^
   18245 Pointer dereferencing.  Defined on pointer types.
   18246 
   18247 @item NOT
   18248 Boolean negation.  Defined on boolean types.  Same precedence as
   18249 @code{^}.
   18250 
   18251 @item .
   18252 @code{RECORD} field selector.  Defined on @code{RECORD} data.  Same
   18253 precedence as @code{^}.
   18254 
   18255 @item []
   18256 Array indexing.  Defined on @code{ARRAY} data.  Same precedence as @code{^}.
   18257 
   18258 @item ()
   18259 Procedure argument list.  Defined on @code{PROCEDURE} objects.  Same precedence
   18260 as @code{^}.
   18261 
   18262 @item ::@r{, }.
   18263 @value{GDBN} and Modula-2 scope operators.
   18264 @end table
   18265 
   18266 @quotation
   18267 @emph{Warning:} Set expressions and their operations are not yet supported, so @value{GDBN}
   18268 treats the use of the operator @code{IN}, or the use of operators
   18269 @code{+}, @code{-}, @code{*}, @code{/}, @code{=}, , @code{<>}, @code{#},
   18270 @code{<=}, and @code{>=} on sets as an error.
   18271 @end quotation
   18272 
   18273 
   18274 @node Built-In Func/Proc
   18275 @subsubsection Built-in Functions and Procedures
   18276 @cindex Modula-2 built-ins
   18277 
   18278 Modula-2 also makes available several built-in procedures and functions.
   18279 In describing these, the following metavariables are used:
   18280 
   18281 @table @var
   18282 
   18283 @item a
   18284 represents an @code{ARRAY} variable.
   18285 
   18286 @item c
   18287 represents a @code{CHAR} constant or variable.
   18288 
   18289 @item i
   18290 represents a variable or constant of integral type.
   18291 
   18292 @item m
   18293 represents an identifier that belongs to a set.  Generally used in the
   18294 same function with the metavariable @var{s}.  The type of @var{s} should
   18295 be @code{SET OF @var{mtype}} (where @var{mtype} is the type of @var{m}).
   18296 
   18297 @item n
   18298 represents a variable or constant of integral or floating-point type.
   18299 
   18300 @item r
   18301 represents a variable or constant of floating-point type.
   18302 
   18303 @item t
   18304 represents a type.
   18305 
   18306 @item v
   18307 represents a variable.
   18308 
   18309 @item x
   18310 represents a variable or constant of one of many types.  See the
   18311 explanation of the function for details.
   18312 @end table
   18313 
   18314 All Modula-2 built-in procedures also return a result, described below.
   18315 
   18316 @table @code
   18317 @item ABS(@var{n})
   18318 Returns the absolute value of @var{n}.
   18319 
   18320 @item ADR(@var{n})
   18321 Returns the memory address of @var{n}.
   18322 
   18323 @item CAP(@var{c})
   18324 If @var{c} is a lower case letter, it returns its upper case
   18325 equivalent, otherwise it returns its argument.
   18326 
   18327 @item CHR(@var{i})
   18328 Returns the character whose ordinal value is @var{i}.
   18329 
   18330 @item DEC(@var{v})
   18331 Decrements the value in the variable @var{v} by one.  Returns the new value.
   18332 
   18333 @item DEC(@var{v},@var{i})
   18334 Decrements the value in the variable @var{v} by @var{i}.  Returns the
   18335 new value.
   18336 
   18337 @item EXCL(@var{m},@var{s})
   18338 Removes the element @var{m} from the set @var{s}.  Returns the new
   18339 set.
   18340 
   18341 @item FLOAT(@var{i})
   18342 Returns the floating point equivalent of the integer @var{i}.
   18343 
   18344 @item HIGH(@var{a})
   18345 Returns the index of the last member of @var{a}.
   18346 
   18347 @item INC(@var{v})
   18348 Increments the value in the variable @var{v} by one.  Returns the new value.
   18349 
   18350 @item INC(@var{v},@var{i})
   18351 Increments the value in the variable @var{v} by @var{i}.  Returns the
   18352 new value.
   18353 
   18354 @item INCL(@var{m},@var{s})
   18355 Adds the element @var{m} to the set @var{s} if it is not already
   18356 there.  Returns the new set.
   18357 
   18358 @item MAX(@var{t})
   18359 Returns the maximum value of the type @var{t}.
   18360 
   18361 @item MIN(@var{t})
   18362 Returns the minimum value of the type @var{t}.
   18363 
   18364 @item ODD(@var{i})
   18365 Returns boolean TRUE if @var{i} is an odd number.
   18366 
   18367 @item ORD(@var{x})
   18368 Returns the ordinal value of its argument.  For example, the ordinal
   18369 value of a character is its @sc{ascii} value (on machines supporting
   18370 the @sc{ascii} character set).  The argument @var{x} must be of an
   18371 ordered type, which include integral, character and enumerated types.
   18372 
   18373 @item SIZE(@var{x})
   18374 Returns the size of its argument.  The argument @var{x} can be a
   18375 variable or a type.
   18376 
   18377 @item TRUNC(@var{r})
   18378 Returns the integral part of @var{r}.
   18379 
   18380 @item TSIZE(@var{x})
   18381 Returns the size of its argument.  The argument @var{x} can be a
   18382 variable or a type.
   18383 
   18384 @item VAL(@var{t},@var{i})
   18385 Returns the member of the type @var{t} whose ordinal value is @var{i}.
   18386 @end table
   18387 
   18388 @quotation
   18389 @emph{Warning:}  Sets and their operations are not yet supported, so
   18390 @value{GDBN} treats the use of procedures @code{INCL} and @code{EXCL} as
   18391 an error.
   18392 @end quotation
   18393 
   18394 @cindex Modula-2 constants
   18395 @node M2 Constants
   18396 @subsubsection Constants
   18397 
   18398 @value{GDBN} allows you to express the constants of Modula-2 in the following
   18399 ways:
   18400 
   18401 @itemize @bullet
   18402 
   18403 @item
   18404 Integer constants are simply a sequence of digits.  When used in an
   18405 expression, a constant is interpreted to be type-compatible with the
   18406 rest of the expression.  Hexadecimal integers are specified by a
   18407 trailing @samp{H}, and octal integers by a trailing @samp{B}.
   18408 
   18409 @item
   18410 Floating point constants appear as a sequence of digits, followed by a
   18411 decimal point and another sequence of digits.  An optional exponent can
   18412 then be specified, in the form @samp{E@r{[}+@r{|}-@r{]}@var{nnn}}, where
   18413 @samp{@r{[}+@r{|}-@r{]}@var{nnn}} is the desired exponent.  All of the
   18414 digits of the floating point constant must be valid decimal (base 10)
   18415 digits.
   18416 
   18417 @item
   18418 Character constants consist of a single character enclosed by a pair of
   18419 like quotes, either single (@code{'}) or double (@code{"}).  They may
   18420 also be expressed by their ordinal value (their @sc{ascii} value, usually)
   18421 followed by a @samp{C}.
   18422 
   18423 @item
   18424 String constants consist of a sequence of characters enclosed by a
   18425 pair of like quotes, either single (@code{'}) or double (@code{"}).
   18426 Escape sequences in the style of C are also allowed.  @xref{C
   18427 Constants, ,C and C@t{++} Constants}, for a brief explanation of escape
   18428 sequences.
   18429 
   18430 @item
   18431 Enumerated constants consist of an enumerated identifier.
   18432 
   18433 @item
   18434 Boolean constants consist of the identifiers @code{TRUE} and
   18435 @code{FALSE}.
   18436 
   18437 @item
   18438 Pointer constants consist of integral values only.
   18439 
   18440 @item
   18441 Set constants are not yet supported.
   18442 @end itemize
   18443 
   18444 @node M2 Types
   18445 @subsubsection Modula-2 Types
   18446 @cindex Modula-2 types
   18447 
   18448 Currently @value{GDBN} can print the following data types in Modula-2
   18449 syntax: array types, record types, set types, pointer types, procedure
   18450 types, enumerated types, subrange types and base types.  You can also
   18451 print the contents of variables declared using these type.
   18452 This section gives a number of simple source code examples together with
   18453 sample @value{GDBN} sessions.
   18454 
   18455 The first example contains the following section of code:
   18456 
   18457 @smallexample
   18458 VAR
   18459    s: SET OF CHAR ;
   18460    r: [20..40] ;
   18461 @end smallexample
   18462 
   18463 @noindent
   18464 and you can request @value{GDBN} to interrogate the type and value of
   18465 @code{r} and @code{s}.
   18466 
   18467 @smallexample
   18468 (@value{GDBP}) print s
   18469 @{'A'..'C', 'Z'@}
   18470 (@value{GDBP}) ptype s
   18471 SET OF CHAR
   18472 (@value{GDBP}) print r
   18473 21
   18474 (@value{GDBP}) ptype r
   18475 [20..40]
   18476 @end smallexample
   18477 
   18478 @noindent
   18479 Likewise if your source code declares @code{s} as:
   18480 
   18481 @smallexample
   18482 VAR
   18483    s: SET ['A'..'Z'] ;
   18484 @end smallexample
   18485 
   18486 @noindent
   18487 then you may query the type of @code{s} by:
   18488 
   18489 @smallexample
   18490 (@value{GDBP}) ptype s
   18491 type = SET ['A'..'Z']
   18492 @end smallexample
   18493 
   18494 @noindent
   18495 Note that at present you cannot interactively manipulate set
   18496 expressions using the debugger.
   18497 
   18498 The following example shows how you might declare an array in Modula-2
   18499 and how you can interact with @value{GDBN} to print its type and contents:
   18500 
   18501 @smallexample
   18502 VAR
   18503    s: ARRAY [-10..10] OF CHAR ;
   18504 @end smallexample
   18505 
   18506 @smallexample
   18507 (@value{GDBP}) ptype s
   18508 ARRAY [-10..10] OF CHAR
   18509 @end smallexample
   18510 
   18511 Note that the array handling is not yet complete and although the type
   18512 is printed correctly, expression handling still assumes that all
   18513 arrays have a lower bound of zero and not @code{-10} as in the example
   18514 above.
   18515 
   18516 Here are some more type related Modula-2 examples:
   18517 
   18518 @smallexample
   18519 TYPE
   18520    colour = (blue, red, yellow, green) ;
   18521    t = [blue..yellow] ;
   18522 VAR
   18523    s: t ;
   18524 BEGIN
   18525    s := blue ;
   18526 @end smallexample
   18527 
   18528 @noindent
   18529 The @value{GDBN} interaction shows how you can query the data type
   18530 and value of a variable.
   18531 
   18532 @smallexample
   18533 (@value{GDBP}) print s
   18534 $1 = blue
   18535 (@value{GDBP}) ptype t
   18536 type = [blue..yellow]
   18537 @end smallexample
   18538 
   18539 @noindent
   18540 In this example a Modula-2 array is declared and its contents
   18541 displayed.  Observe that the contents are written in the same way as
   18542 their @code{C} counterparts.
   18543 
   18544 @smallexample
   18545 VAR
   18546    s: ARRAY [1..5] OF CARDINAL ;
   18547 BEGIN
   18548    s[1] := 1 ;
   18549 @end smallexample
   18550 
   18551 @smallexample
   18552 (@value{GDBP}) print s
   18553 $1 = @{1, 0, 0, 0, 0@}
   18554 (@value{GDBP}) ptype s
   18555 type = ARRAY [1..5] OF CARDINAL
   18556 @end smallexample
   18557 
   18558 The Modula-2 language interface to @value{GDBN} also understands
   18559 pointer types as shown in this example:
   18560 
   18561 @smallexample
   18562 VAR
   18563    s: POINTER TO ARRAY [1..5] OF CARDINAL ;
   18564 BEGIN
   18565    NEW(s) ;
   18566    s^[1] := 1 ;
   18567 @end smallexample
   18568 
   18569 @noindent
   18570 and you can request that @value{GDBN} describes the type of @code{s}.
   18571 
   18572 @smallexample
   18573 (@value{GDBP}) ptype s
   18574 type = POINTER TO ARRAY [1..5] OF CARDINAL
   18575 @end smallexample
   18576 
   18577 @value{GDBN} handles compound types as we can see in this example.
   18578 Here we combine array types, record types, pointer types and subrange
   18579 types:
   18580 
   18581 @smallexample
   18582 TYPE
   18583    foo = RECORD
   18584             f1: CARDINAL ;
   18585             f2: CHAR ;
   18586             f3: myarray ;
   18587          END ;
   18588 
   18589    myarray = ARRAY myrange OF CARDINAL ;
   18590    myrange = [-2..2] ;
   18591 VAR
   18592    s: POINTER TO ARRAY myrange OF foo ;
   18593 @end smallexample
   18594 
   18595 @noindent
   18596 and you can ask @value{GDBN} to describe the type of @code{s} as shown
   18597 below.
   18598 
   18599 @smallexample
   18600 (@value{GDBP}) ptype s
   18601 type = POINTER TO ARRAY [-2..2] OF foo = RECORD
   18602     f1 : CARDINAL;
   18603     f2 : CHAR;
   18604     f3 : ARRAY [-2..2] OF CARDINAL;
   18605 END 
   18606 @end smallexample
   18607 
   18608 @node M2 Defaults
   18609 @subsubsection Modula-2 Defaults
   18610 @cindex Modula-2 defaults
   18611 
   18612 If type and range checking are set automatically by @value{GDBN}, they
   18613 both default to @code{on} whenever the working language changes to
   18614 Modula-2.  This happens regardless of whether you or @value{GDBN}
   18615 selected the working language.
   18616 
   18617 If you allow @value{GDBN} to set the language automatically, then entering
   18618 code compiled from a file whose name ends with @file{.mod} sets the
   18619 working language to Modula-2.  @xref{Automatically, ,Having @value{GDBN}
   18620 Infer the Source Language}, for further details.
   18621 
   18622 @node Deviations
   18623 @subsubsection Deviations from Standard Modula-2
   18624 @cindex Modula-2, deviations from
   18625 
   18626 A few changes have been made to make Modula-2 programs easier to debug.
   18627 This is done primarily via loosening its type strictness:
   18628 
   18629 @itemize @bullet
   18630 @item
   18631 Unlike in standard Modula-2, pointer constants can be formed by
   18632 integers.  This allows you to modify pointer variables during
   18633 debugging.  (In standard Modula-2, the actual address contained in a
   18634 pointer variable is hidden from you; it can only be modified
   18635 through direct assignment to another pointer variable or expression that
   18636 returned a pointer.)
   18637 
   18638 @item
   18639 C escape sequences can be used in strings and characters to represent
   18640 non-printable characters.  @value{GDBN} prints out strings with these
   18641 escape sequences embedded.  Single non-printable characters are
   18642 printed using the @samp{CHR(@var{nnn})} format.
   18643 
   18644 @item
   18645 The assignment operator (@code{:=}) returns the value of its right-hand
   18646 argument.
   18647 
   18648 @item
   18649 All built-in procedures both modify @emph{and} return their argument.
   18650 @end itemize
   18651 
   18652 @node M2 Checks
   18653 @subsubsection Modula-2 Type and Range Checks
   18654 @cindex Modula-2 checks
   18655 
   18656 @quotation
   18657 @emph{Warning:} in this release, @value{GDBN} does not yet perform type or
   18658 range checking.
   18659 @end quotation
   18660 @c FIXME remove warning when type/range checks added
   18661 
   18662 @value{GDBN} considers two Modula-2 variables type equivalent if:
   18663 
   18664 @itemize @bullet
   18665 @item
   18666 They are of types that have been declared equivalent via a @code{TYPE
   18667 @var{t1} = @var{t2}} statement
   18668 
   18669 @item
   18670 They have been declared on the same line.  (Note:  This is true of the
   18671 @sc{gnu} Modula-2 compiler, but it may not be true of other compilers.)
   18672 @end itemize
   18673 
   18674 As long as type checking is enabled, any attempt to combine variables
   18675 whose types are not equivalent is an error.
   18676 
   18677 Range checking is done on all mathematical operations, assignment, array
   18678 index bounds, and all built-in functions and procedures.
   18679 
   18680 @node M2 Scope
   18681 @subsubsection The Scope Operators @code{::} and @code{.}
   18682 @cindex scope
   18683 @cindex @code{.}, Modula-2 scope operator
   18684 @cindex colon, doubled as scope operator
   18685 @ifinfo
   18686 @vindex colon-colon@r{, in Modula-2}
   18687 @c Info cannot handle :: but TeX can.
   18688 @end ifinfo
   18689 @ifnotinfo
   18690 @vindex ::@r{, in Modula-2}
   18691 @end ifnotinfo
   18692 
   18693 There are a few subtle differences between the Modula-2 scope operator
   18694 (@code{.}) and the @value{GDBN} scope operator (@code{::}).  The two have
   18695 similar syntax:
   18696 
   18697 @smallexample
   18698 
   18699 @var{module} . @var{id}
   18700 @var{scope} :: @var{id}
   18701 @end smallexample
   18702 
   18703 @noindent
   18704 where @var{scope} is the name of a module or a procedure,
   18705 @var{module} the name of a module, and @var{id} is any declared
   18706 identifier within your program, except another module.
   18707 
   18708 Using the @code{::} operator makes @value{GDBN} search the scope
   18709 specified by @var{scope} for the identifier @var{id}.  If it is not
   18710 found in the specified scope, then @value{GDBN} searches all scopes
   18711 enclosing the one specified by @var{scope}.
   18712 
   18713 Using the @code{.} operator makes @value{GDBN} search the current scope for
   18714 the identifier specified by @var{id} that was imported from the
   18715 definition module specified by @var{module}.  With this operator, it is
   18716 an error if the identifier @var{id} was not imported from definition
   18717 module @var{module}, or if @var{id} is not an identifier in
   18718 @var{module}.
   18719 
   18720 @node GDB/M2
   18721 @subsubsection @value{GDBN} and Modula-2
   18722 
   18723 Some @value{GDBN} commands have little use when debugging Modula-2 programs.
   18724 Five subcommands of @code{set print} and @code{show print} apply
   18725 specifically to C and C@t{++}: @samp{vtbl}, @samp{demangle},
   18726 @samp{asm-demangle}, @samp{object}, and @samp{union}.  The first four
   18727 apply to C@t{++}, and the last to the C @code{union} type, which has no direct
   18728 analogue in Modula-2.
   18729 
   18730 The @code{@@} operator (@pxref{Expressions, ,Expressions}), while available
   18731 with any language, is not useful with Modula-2.  Its
   18732 intent is to aid the debugging of @dfn{dynamic arrays}, which cannot be
   18733 created in Modula-2 as they can in C or C@t{++}.  However, because an
   18734 address can be specified by an integral constant, the construct
   18735 @samp{@{@var{type}@}@var{adrexp}} is still useful.
   18736 
   18737 @cindex @code{#} in Modula-2
   18738 In @value{GDBN} scripts, the Modula-2 inequality operator @code{#} is
   18739 interpreted as the beginning of a comment.  Use @code{<>} instead.
   18740 
   18741 @node Ada
   18742 @subsection Ada
   18743 @cindex Ada
   18744 
   18745 The extensions made to @value{GDBN} for Ada only support
   18746 output from the @sc{gnu} Ada (GNAT) compiler.
   18747 Other Ada compilers are not currently supported, and
   18748 attempting to debug executables produced by them is most likely
   18749 to be difficult.
   18750 
   18751 
   18752 @cindex expressions in Ada
   18753 @menu
   18754 * Ada Mode Intro::              General remarks on the Ada syntax 
   18755                                    and semantics supported by Ada mode 
   18756                                    in @value{GDBN}.
   18757 * Omissions from Ada::          Restrictions on the Ada expression syntax.
   18758 * Additions to Ada::            Extensions of the Ada expression syntax.
   18759 * Overloading support for Ada:: Support for expressions involving overloaded
   18760                                    subprograms.
   18761 * Stopping Before Main Program:: Debugging the program during elaboration.
   18762 * Ada Exceptions::              Ada Exceptions
   18763 * Ada Tasks::                   Listing and setting breakpoints in tasks.
   18764 * Ada Tasks and Core Files::    Tasking Support when Debugging Core Files
   18765 * Ravenscar Profile::           Tasking Support when using the Ravenscar
   18766                                    Profile
   18767 * Ada Source Character Set::    Character set of Ada source files.
   18768 * Ada Glitches::                Known peculiarities of Ada mode.
   18769 @end menu
   18770 
   18771 @node Ada Mode Intro
   18772 @subsubsection Introduction
   18773 @cindex Ada mode, general
   18774 
   18775 The Ada mode of @value{GDBN} supports a fairly large subset of Ada expression 
   18776 syntax, with some extensions.
   18777 The philosophy behind the design of this subset is 
   18778 
   18779 @itemize @bullet
   18780 @item
   18781 That @value{GDBN} should provide basic literals and access to operations for 
   18782 arithmetic, dereferencing, field selection, indexing, and subprogram calls, 
   18783 leaving more sophisticated computations to subprograms written into the
   18784 program (which therefore may be called from @value{GDBN}).
   18785 
   18786 @item 
   18787 That type safety and strict adherence to Ada language restrictions
   18788 are not particularly important to the @value{GDBN} user.
   18789 
   18790 @item 
   18791 That brevity is important to the @value{GDBN} user.
   18792 @end itemize
   18793 
   18794 Thus, for brevity, the debugger acts as if all names declared in
   18795 user-written packages are directly visible, even if they are not visible
   18796 according to Ada rules, thus making it unnecessary to fully qualify most
   18797 names with their packages, regardless of context.  Where this causes
   18798 ambiguity, @value{GDBN} asks the user's intent.
   18799 
   18800 The debugger will start in Ada mode if it detects an Ada main program. 
   18801 As for other languages, it will enter Ada mode when stopped in a program that
   18802 was translated from an Ada source file.
   18803 
   18804 While in Ada mode, you may use `@t{--}' for comments.  This is useful 
   18805 mostly for documenting command files.  The standard @value{GDBN} comment 
   18806 (@samp{#}) still works at the beginning of a line in Ada mode, but not in the 
   18807 middle (to allow based literals).
   18808 
   18809 @node Omissions from Ada
   18810 @subsubsection Omissions from Ada
   18811 @cindex Ada, omissions from
   18812 
   18813 Here are the notable omissions from the subset:
   18814 
   18815 @itemize @bullet
   18816 @item
   18817 Only a subset of the attributes are supported:
   18818 
   18819 @itemize @minus
   18820 @item
   18821 @t{'First}, @t{'Last}, and @t{'Length}
   18822  on array objects (not on types and subtypes).
   18823 
   18824 @item
   18825 @t{'Min} and @t{'Max}.  
   18826 
   18827 @item 
   18828 @t{'Pos} and @t{'Val}. 
   18829 
   18830 @item
   18831 @t{'Tag}.
   18832 
   18833 @item
   18834 @t{'Range} on array objects (not subtypes), but only as the right
   18835 operand of the membership (@code{in}) operator.
   18836 
   18837 @item 
   18838 @t{'Access}, @t{'Unchecked_Access}, and 
   18839 @t{'Unrestricted_Access} (a GNAT extension).
   18840 
   18841 @item
   18842 @t{'Address}.
   18843 
   18844 @item
   18845 @t{'Size} is available for objects (not types).
   18846 
   18847 @item
   18848 @t{'Object_Size} is available, but not for indefinite types.
   18849 @end itemize
   18850 
   18851 @item
   18852 The names in @code{Characters.Latin_1} are not available.
   18853 
   18854 @item
   18855 Equality tests (@samp{=} and @samp{/=}) on arrays test for bitwise
   18856 equality of representations.  They will generally work correctly
   18857 for strings and arrays whose elements have integer or enumeration types.
   18858 They may not work correctly for arrays whose element
   18859 types have user-defined equality, for arrays of real values 
   18860 (in particular, IEEE-conformant floating point, because of negative
   18861 zeroes and NaNs), and for arrays whose elements contain unused bits with
   18862 indeterminate values.  
   18863 
   18864 @item
   18865 The other component-by-component array operations (@code{and}, @code{or}, 
   18866 @code{xor}, @code{not}, and relational tests other than equality)
   18867 are not implemented. 
   18868 
   18869 @item 
   18870 @cindex array aggregates (Ada)
   18871 @cindex record aggregates (Ada)
   18872 @cindex aggregates (Ada) 
   18873 There is limited support for array and record aggregates.  They are
   18874 permitted only on the right sides of assignments, as in these examples:
   18875 
   18876 @smallexample
   18877 (@value{GDBP}) set An_Array := (1, 2, 3, 4, 5, 6)
   18878 (@value{GDBP}) set An_Array := (1, others => 0)
   18879 (@value{GDBP}) set An_Array := (0|4 => 1, 1..3 => 2, 5 => 6)
   18880 (@value{GDBP}) set A_2D_Array := ((1, 2, 3), (4, 5, 6), (7, 8, 9))
   18881 (@value{GDBP}) set A_Record := (1, "Peter", True);
   18882 (@value{GDBP}) set A_Record := (Name => "Peter", Id => 1, Alive => True)
   18883 @end smallexample
   18884 
   18885 Changing a
   18886 discriminant's value by assigning an aggregate has an
   18887 undefined effect if that discriminant is used within the record.
   18888 However, you can first modify discriminants by directly assigning to
   18889 them (which normally would not be allowed in Ada), and then performing an
   18890 aggregate assignment.  For example, given a variable @code{A_Rec} 
   18891 declared to have a type such as:
   18892 
   18893 @smallexample
   18894 type Rec (Len : Small_Integer := 0) is record
   18895     Id : Integer;
   18896     Vals : IntArray (1 .. Len);
   18897 end record;
   18898 @end smallexample
   18899 
   18900 you can assign a value with a different size of @code{Vals} with two
   18901 assignments:
   18902 
   18903 @smallexample
   18904 (@value{GDBP}) set A_Rec.Len := 4
   18905 (@value{GDBP}) set A_Rec := (Id => 42, Vals => (1, 2, 3, 4))
   18906 @end smallexample
   18907 
   18908 As this example also illustrates, @value{GDBN} is very loose about the usual
   18909 rules concerning aggregates.  You may leave out some of the
   18910 components of an array or record aggregate (such as the @code{Len} 
   18911 component in the assignment to @code{A_Rec} above); they will retain their
   18912 original values upon assignment.  You may freely use dynamic values as
   18913 indices in component associations.  You may even use overlapping or
   18914 redundant component associations, although which component values are
   18915 assigned in such cases is not defined.
   18916 
   18917 @item
   18918 Calls to dispatching subprograms are not implemented.
   18919 
   18920 @item
   18921 The overloading algorithm is much more limited (i.e., less selective)
   18922 than that of real Ada.  It makes only limited use of the context in
   18923 which a subexpression appears to resolve its meaning, and it is much
   18924 looser in its rules for allowing type matches.  As a result, some
   18925 function calls will be ambiguous, and the user will be asked to choose
   18926 the proper resolution.
   18927 
   18928 @item
   18929 The @code{new} operator is not implemented.
   18930 
   18931 @item
   18932 Entry calls are not implemented.
   18933 
   18934 @item 
   18935 Aside from printing, arithmetic operations on the native VAX floating-point 
   18936 formats are not supported.
   18937 
   18938 @item
   18939 It is not possible to slice a packed array.
   18940 
   18941 @item
   18942 The names @code{True} and @code{False}, when not part of a qualified name, 
   18943 are interpreted as if implicitly prefixed by @code{Standard}, regardless of 
   18944 context.
   18945 Should your program
   18946 redefine these names in a package or procedure (at best a dubious practice),
   18947 you will have to use fully qualified names to access their new definitions.
   18948 
   18949 @item
   18950 Based real literals are not implemented.
   18951 @end itemize
   18952 
   18953 @node Additions to Ada
   18954 @subsubsection Additions to Ada
   18955 @cindex Ada, deviations from 
   18956 
   18957 As it does for other languages, @value{GDBN} makes certain generic
   18958 extensions to Ada (@pxref{Expressions}):
   18959 
   18960 @itemize @bullet
   18961 @item
   18962 If the expression @var{E} is a variable residing in memory (typically
   18963 a local variable or array element) and @var{N} is a positive integer,
   18964 then @code{@var{E}@@@var{N}} displays the values of @var{E} and the
   18965 @var{N}-1 adjacent variables following it in memory as an array.  In
   18966 Ada, this operator is generally not necessary, since its prime use is
   18967 in displaying parts of an array, and slicing will usually do this in
   18968 Ada.  However, there are occasional uses when debugging programs in
   18969 which certain debugging information has been optimized away.
   18970 
   18971 @item
   18972 @code{@var{B}::@var{var}} means ``the variable named @var{var} that
   18973 appears in function or file @var{B}.''  When @var{B} is a file name,
   18974 you must typically surround it in single quotes.
   18975 
   18976 @item 
   18977 The expression @code{@{@var{type}@} @var{addr}} means ``the variable of type
   18978 @var{type} that appears at address @var{addr}.''
   18979 
   18980 @item
   18981 A name starting with @samp{$} is a convenience variable 
   18982 (@pxref{Convenience Vars}) or a machine register (@pxref{Registers}).
   18983 @end itemize
   18984 
   18985 In addition, @value{GDBN} provides a few other shortcuts and outright
   18986 additions specific to Ada:
   18987 
   18988 @itemize @bullet
   18989 @item 
   18990 The assignment statement is allowed as an expression, returning
   18991 its right-hand operand as its value.  Thus, you may enter
   18992 
   18993 @smallexample
   18994 (@value{GDBP}) set x := y + 3
   18995 (@value{GDBP}) print A(tmp := y + 1)
   18996 @end smallexample
   18997 
   18998 @item 
   18999 The semicolon is allowed as an ``operator,''  returning as its value 
   19000 the value of its right-hand operand.
   19001 This allows, for example,
   19002 complex conditional breaks:
   19003 
   19004 @smallexample
   19005 (@value{GDBP}) break f
   19006 (@value{GDBP}) condition 1 (report(i); k += 1; A(k) > 100)
   19007 @end smallexample
   19008 
   19009 @item
   19010 An extension to based literals can be used to specify the exact byte
   19011 contents of a floating-point literal.  After the base, you can use
   19012 from zero to two @samp{l} characters, followed by an @samp{f}.  The
   19013 number of @samp{l} characters controls the width of the resulting real
   19014 constant: zero means @code{Float} is used, one means
   19015 @code{Long_Float}, and two means @code{Long_Long_Float}.
   19016 
   19017 @smallexample
   19018 (@value{GDBP}) print 16f#41b80000#
   19019 $1 = 23.0
   19020 @end smallexample
   19021 
   19022 @item 
   19023 Rather than use catenation and symbolic character names to introduce special 
   19024 characters into strings, one may instead use a special bracket notation, 
   19025 which is also used to print strings.  A sequence of characters of the form 
   19026 @samp{["@var{XX}"]} within a string or character literal denotes the 
   19027 (single) character whose numeric encoding is @var{XX} in hexadecimal.  The
   19028 sequence of characters @samp{["""]} also denotes a single quotation mark 
   19029 in strings.   For example,
   19030 @smallexample
   19031    "One line.["0a"]Next line.["0a"]"
   19032 @end smallexample
   19033 @noindent
   19034 contains an ASCII newline character (@code{Ada.Characters.Latin_1.LF})
   19035 after each period.
   19036 
   19037 @item
   19038 The subtype used as a prefix for the attributes @t{'Pos}, @t{'Min}, and
   19039 @t{'Max} is optional (and is ignored in any case).  For example, it is valid
   19040 to write
   19041 
   19042 @smallexample
   19043 (@value{GDBP}) print 'max(x, y)
   19044 @end smallexample
   19045 
   19046 @item
   19047 When printing arrays, @value{GDBN} uses positional notation when the 
   19048 array has a lower bound of 1, and uses a modified named notation otherwise.
   19049 For example, a one-dimensional array of three integers with a lower bound
   19050 of 3 might print as
   19051 
   19052 @smallexample
   19053 (3 => 10, 17, 1)
   19054 @end smallexample
   19055 
   19056 @noindent
   19057 That is, in contrast to valid Ada, only the first component has a @code{=>} 
   19058 clause.
   19059 
   19060 @item
   19061 You may abbreviate attributes in expressions with any unique,
   19062 multi-character subsequence of 
   19063 their names (an exact match gets preference).
   19064 For example, you may use @t{a'len}, @t{a'gth}, or @t{a'lh}
   19065 in place of  @t{a'length}.
   19066 
   19067 @item
   19068 @cindex quoting Ada internal identifiers
   19069 Since Ada is case-insensitive, the debugger normally maps identifiers you type 
   19070 to lower case.  The GNAT compiler uses upper-case characters for 
   19071 some of its internal identifiers, which are normally of no interest to users.
   19072 For the rare occasions when you actually have to look at them,
   19073 enclose them in angle brackets to avoid the lower-case mapping. 
   19074 For example,
   19075 @smallexample
   19076 (@value{GDBP}) print <JMPBUF_SAVE>[0]
   19077 @end smallexample
   19078 
   19079 @item
   19080 Printing an object of class-wide type or dereferencing an 
   19081 access-to-class-wide value will display all the components of the object's
   19082 specific type (as indicated by its run-time tag).  Likewise, component
   19083 selection on such a value will operate on the specific type of the
   19084 object.
   19085 
   19086 @end itemize
   19087 
   19088 @node Overloading support for Ada
   19089 @subsubsection Overloading support for Ada
   19090 @cindex overloading, Ada
   19091 
   19092 The debugger supports limited overloading.  Given a subprogram call in which
   19093 the function symbol has multiple definitions, it will use the number of
   19094 actual parameters and some information about their types to attempt to narrow
   19095 the set of definitions.  It also makes very limited use of context, preferring
   19096 procedures to functions in the context of the @code{call} command, and
   19097 functions to procedures elsewhere.
   19098 
   19099 If, after narrowing, the set of matching definitions still contains more than
   19100 one definition, @value{GDBN} will display a menu to query which one it should
   19101 use, for instance:
   19102 
   19103 @smallexample
   19104 (@value{GDBP}) print f(1)
   19105 Multiple matches for f
   19106 [0] cancel
   19107 [1] foo.f (integer) return boolean at foo.adb:23
   19108 [2] foo.f (foo.new_integer) return boolean at foo.adb:28
   19109 > 
   19110 @end smallexample
   19111 
   19112 In this case, just select one menu entry either to cancel expression evaluation
   19113 (type @kbd{0} and press @key{RET}) or to continue evaluation with a specific
   19114 instance (type the corresponding number and press @key{RET}).
   19115 
   19116 Here are a couple of commands to customize @value{GDBN}'s behavior in this
   19117 case:
   19118 
   19119 @table @code
   19120 
   19121 @kindex set ada print-signatures
   19122 @item set ada print-signatures
   19123 Control whether parameter types and return types are displayed in overloads
   19124 selection menus.  It is @code{on} by default.
   19125 @xref{Overloading support for Ada}.
   19126 
   19127 @kindex show ada print-signatures
   19128 @item show ada print-signatures
   19129 Show the current setting for displaying parameter types and return types in
   19130 overloads selection menu.
   19131 @xref{Overloading support for Ada}.
   19132 
   19133 @end table
   19134 
   19135 @node Stopping Before Main Program
   19136 @subsubsection Stopping at the Very Beginning
   19137 
   19138 @cindex breakpointing Ada elaboration code
   19139 It is sometimes necessary to debug the program during elaboration, and
   19140 before reaching the main procedure.
   19141 As defined in the Ada Reference
   19142 Manual, the elaboration code is invoked from a procedure called
   19143 @code{adainit}.  To run your program up to the beginning of
   19144 elaboration, simply use the following two commands:
   19145 @code{tbreak adainit} and @code{run}.
   19146 
   19147 @node Ada Exceptions
   19148 @subsubsection Ada Exceptions
   19149 
   19150 A command is provided to list all Ada exceptions:
   19151 
   19152 @table @code
   19153 @kindex info exceptions
   19154 @item info exceptions
   19155 @itemx info exceptions @var{regexp}
   19156 The @code{info exceptions} command allows you to list all Ada exceptions
   19157 defined within the program being debugged, as well as their addresses.
   19158 With a regular expression, @var{regexp}, as argument, only those exceptions
   19159 whose names match @var{regexp} are listed.
   19160 @end table
   19161 
   19162 Below is a small example, showing how the command can be used, first
   19163 without argument, and next with a regular expression passed as an
   19164 argument.
   19165 
   19166 @smallexample
   19167 (@value{GDBP}) info exceptions
   19168 All defined Ada exceptions:
   19169 constraint_error: 0x613da0
   19170 program_error: 0x613d20
   19171 storage_error: 0x613ce0
   19172 tasking_error: 0x613ca0
   19173 const.aint_global_e: 0x613b00
   19174 (@value{GDBP}) info exceptions const.aint
   19175 All Ada exceptions matching regular expression "const.aint":
   19176 constraint_error: 0x613da0
   19177 const.aint_global_e: 0x613b00
   19178 @end smallexample
   19179 
   19180 It is also possible to ask @value{GDBN} to stop your program's execution
   19181 when an exception is raised.  For more details, see @ref{Set Catchpoints}.
   19182 
   19183 @node Ada Tasks
   19184 @subsubsection Extensions for Ada Tasks
   19185 @cindex Ada, tasking
   19186 
   19187 Support for Ada tasks is analogous to that for threads (@pxref{Threads}).
   19188 @value{GDBN} provides the following task-related commands:
   19189 
   19190 @table @code
   19191 @kindex info tasks
   19192 @item info tasks
   19193 This command shows a list of current Ada tasks, as in the following example:
   19194 
   19195 
   19196 @smallexample
   19197 @iftex
   19198 @leftskip=0.5cm
   19199 @end iftex
   19200 (@value{GDBP}) info tasks
   19201   ID       TID P-ID Pri State                 Name
   19202    1   8088000   0   15 Child Activation Wait main_task
   19203    2   80a4000   1   15 Accept Statement      b
   19204    3   809a800   1   15 Child Activation Wait a
   19205 *  4   80ae800   3   15 Runnable              c
   19206 
   19207 @end smallexample
   19208 
   19209 @noindent
   19210 In this listing, the asterisk before the last task indicates it to be the
   19211 task currently being inspected.
   19212 
   19213 @table @asis
   19214 @item ID
   19215 Represents @value{GDBN}'s internal task number.
   19216 
   19217 @item TID
   19218 The Ada task ID.
   19219 
   19220 @item P-ID
   19221 The parent's task ID (@value{GDBN}'s internal task number).
   19222 
   19223 @item Pri
   19224 The base priority of the task.
   19225 
   19226 @item State
   19227 Current state of the task.
   19228 
   19229 @table @code
   19230 @item Unactivated
   19231 The task has been created but has not been activated.  It cannot be
   19232 executing.
   19233 
   19234 @item Runnable
   19235 The task is not blocked for any reason known to Ada.  (It may be waiting
   19236 for a mutex, though.) It is conceptually "executing" in normal mode.
   19237 
   19238 @item Terminated
   19239 The task is terminated, in the sense of ARM 9.3 (5).  Any dependents
   19240 that were waiting on terminate alternatives have been awakened and have
   19241 terminated themselves.
   19242 
   19243 @item Child Activation Wait
   19244 The task is waiting for created tasks to complete activation.
   19245 
   19246 @item Accept or Select Term
   19247 The task is waiting on an accept or selective wait statement.
   19248 
   19249 @item Waiting on entry call
   19250 The task is waiting on an entry call.
   19251 
   19252 @item Async Select Wait
   19253 The task is waiting to start the abortable part of an asynchronous
   19254 select statement.
   19255 
   19256 @item Delay Sleep
   19257 The task is waiting on a select statement with only a delay
   19258 alternative open.
   19259 
   19260 @item Child Termination Wait
   19261 The task is sleeping having completed a master within itself, and is
   19262 waiting for the tasks dependent on that master to become terminated or
   19263 waiting on a terminate Phase.
   19264 
   19265 @item Wait Child in Term Alt
   19266 The task is sleeping waiting for tasks on terminate alternatives to
   19267 finish terminating.
   19268 
   19269 @item Asynchronous Hold
   19270 The task has been held by @code{Ada.Asynchronous_Task_Control.Hold_Task}.
   19271 
   19272 @item Activating
   19273 The task has been created and is being made runnable.
   19274 
   19275 @item Selective Wait
   19276 The task is waiting in a selective wait statement.
   19277 
   19278 @item Accepting RV with @var{taskno}
   19279 The task is accepting a rendez-vous with the task @var{taskno}.
   19280 
   19281 @item Waiting on RV with @var{taskno}
   19282 The task is waiting for a rendez-vous with the task @var{taskno}.
   19283 @end table
   19284 
   19285 @item Name
   19286 Name of the task in the program.
   19287 
   19288 @end table
   19289 
   19290 @kindex info task @var{taskno}
   19291 @item info task @var{taskno}
   19292 This command shows detailed information on the specified task, as in
   19293 the following example:
   19294 @smallexample
   19295 @iftex
   19296 @leftskip=0.5cm
   19297 @end iftex
   19298 (@value{GDBP}) info tasks
   19299   ID       TID P-ID Pri State                  Name
   19300    1   8077880    0  15 Child Activation Wait  main_task
   19301 *  2   807c468    1  15 Runnable               task_1
   19302 (@value{GDBP}) info task 2
   19303 Ada Task: 0x807c468
   19304 Name: "task_1"
   19305 Thread: 0
   19306 LWP: 0x1fac
   19307 Parent: 1 ("main_task")
   19308 Base Priority: 15
   19309 State: Runnable
   19310 @end smallexample
   19311 
   19312 @item task
   19313 @kindex task@r{ (Ada)}
   19314 @cindex current Ada task ID
   19315 This command prints the ID and name of the current task.
   19316 
   19317 @smallexample
   19318 @iftex
   19319 @leftskip=0.5cm
   19320 @end iftex
   19321 (@value{GDBP}) info tasks
   19322   ID       TID P-ID Pri State                  Name
   19323    1   8077870    0  15 Child Activation Wait  main_task
   19324 *  2   807c458    1  15 Runnable               some_task
   19325 (@value{GDBP}) task
   19326 [Current task is 2 "some_task"]
   19327 @end smallexample
   19328 
   19329 @item task @var{taskno}
   19330 @cindex Ada task switching
   19331 This command is like the @code{thread @var{thread-id}}
   19332 command (@pxref{Threads}).  It switches the context of debugging
   19333 from the current task to the given task.
   19334 
   19335 @smallexample
   19336 @iftex
   19337 @leftskip=0.5cm
   19338 @end iftex
   19339 (@value{GDBP}) info tasks
   19340   ID       TID P-ID Pri State                  Name
   19341    1   8077870    0  15 Child Activation Wait  main_task
   19342 *  2   807c458    1  15 Runnable               some_task
   19343 (@value{GDBP}) task 1
   19344 [Switching to task 1 "main_task"]
   19345 #0  0x8067726 in pthread_cond_wait ()
   19346 (@value{GDBP}) bt
   19347 #0  0x8067726 in pthread_cond_wait ()
   19348 #1  0x8056714 in system.os_interface.pthread_cond_wait ()
   19349 #2  0x805cb63 in system.task_primitives.operations.sleep ()
   19350 #3  0x806153e in system.tasking.stages.activate_tasks ()
   19351 #4  0x804aacc in un () at un.adb:5
   19352 @end smallexample
   19353 
   19354 @item task apply [@var{task-id-list} | all] [@var{flag}]@dots{} @var{command}
   19355 The @code{task apply} command is the Ada tasking analogue of
   19356 @code{thread apply} (@pxref{Threads}).  It allows you to apply the
   19357 named @var{command} to one or more tasks.  Specify the tasks that you
   19358 want affected using a list of task IDs, or specify @code{all} to apply
   19359 to all tasks.
   19360 
   19361 The @var{flag} arguments control what output to produce and how to
   19362 handle errors raised when applying @var{command} to a task.
   19363 @var{flag} must start with a @code{-} directly followed by one letter
   19364 in @code{qcs}.  If several flags are provided, they must be given
   19365 individually, such as @code{-c -q}.
   19366 
   19367 By default, @value{GDBN} displays some task information before the
   19368 output produced by @var{command}, and an error raised during the
   19369 execution of a @var{command} will abort @code{task apply}.  The
   19370 following flags can be used to fine-tune this behavior:
   19371 
   19372 @table @code
   19373 @item -c
   19374 The flag @code{-c}, which stands for @samp{continue}, causes any
   19375 errors in @var{command} to be displayed, and the execution of
   19376 @code{task apply} then continues.
   19377 @item -s
   19378 The flag @code{-s}, which stands for @samp{silent}, causes any errors
   19379 or empty output produced by a @var{command} to be silently ignored.
   19380 That is, the execution continues, but the task information and errors
   19381 are not printed.
   19382 @item -q
   19383 The flag @code{-q} (@samp{quiet}) disables printing the task
   19384 information.
   19385 @end table
   19386 
   19387 Flags @code{-c} and @code{-s} cannot be used together.
   19388 
   19389 @item break @var{locspec} task @var{taskno}
   19390 @itemx break @var{locspec} task @var{taskno} if @dots{}
   19391 @cindex breakpoints and tasks, in Ada
   19392 @cindex task breakpoints, in Ada
   19393 @kindex break @dots{} task @var{taskno}@r{ (Ada)}
   19394 These commands are like the @code{break @dots{} thread @dots{}}
   19395 command (@pxref{Thread Stops}).  @xref{Location Specifications}, for
   19396 the various forms of @var{locspec}.
   19397 
   19398 Use the qualifier @samp{task @var{taskno}} with a breakpoint command
   19399 to specify that you only want @value{GDBN} to stop the program when a
   19400 particular Ada task reaches this breakpoint.  The @var{taskno} is one of the
   19401 numeric task identifiers assigned by @value{GDBN}, shown in the first
   19402 column of the @samp{info tasks} display.
   19403 
   19404 If you do not specify @samp{task @var{taskno}} when you set a
   19405 breakpoint, the breakpoint applies to @emph{all} tasks of your
   19406 program.
   19407 
   19408 You can use the @code{task} qualifier on conditional breakpoints as
   19409 well; in this case, place @samp{task @var{taskno}} before the
   19410 breakpoint condition (before the @code{if}).
   19411 
   19412 For example,
   19413 
   19414 @smallexample
   19415 @iftex
   19416 @leftskip=0.5cm
   19417 @end iftex
   19418 (@value{GDBP}) info tasks
   19419   ID       TID P-ID Pri State                 Name
   19420    1 140022020   0   15 Child Activation Wait main_task
   19421    2 140045060   1   15 Accept/Select Wait    t2
   19422    3 140044840   1   15 Runnable              t1
   19423 *  4 140056040   1   15 Runnable              t3
   19424 (@value{GDBP}) b 15 task 2
   19425 Breakpoint 5 at 0x120044cb0: file test_task_debug.adb, line 15.
   19426 (@value{GDBP}) cont
   19427 Continuing.
   19428 task # 1 running
   19429 task # 2 running
   19430 
   19431 Breakpoint 5, test_task_debug () at test_task_debug.adb:15
   19432 15               flush;
   19433 (@value{GDBP}) info tasks
   19434   ID       TID P-ID Pri State                 Name
   19435    1 140022020   0   15 Child Activation Wait main_task
   19436 *  2 140045060   1   15 Runnable              t2
   19437    3 140044840   1   15 Runnable              t1
   19438    4 140056040   1   15 Delay Sleep           t3
   19439 @end smallexample
   19440 @end table
   19441 
   19442 @node Ada Tasks and Core Files
   19443 @subsubsection Tasking Support when Debugging Core Files
   19444 @cindex Ada tasking and core file debugging
   19445 
   19446 When inspecting a core file, as opposed to debugging a live program,
   19447 tasking support may be limited or even unavailable, depending on
   19448 the platform being used.
   19449 For instance, on x86-linux, the list of tasks is available, but task
   19450 switching is not supported.
   19451 
   19452 On certain platforms, the debugger needs to perform some
   19453 memory writes in order to provide Ada tasking support.  When inspecting
   19454 a core file, this means that the core file must be opened with read-write
   19455 privileges, using the command @samp{"set write on"} (@pxref{Patching}).
   19456 Under these circumstances, you should make a backup copy of the core
   19457 file before inspecting it with @value{GDBN}.
   19458 
   19459 @node Ravenscar Profile
   19460 @subsubsection Tasking Support when using the Ravenscar Profile
   19461 @cindex Ravenscar Profile
   19462 
   19463 The @dfn{Ravenscar Profile} is a subset of the Ada tasking features,
   19464 specifically designed for systems with safety-critical real-time
   19465 requirements.
   19466 
   19467 @table @code
   19468 @kindex set ravenscar task-switching on
   19469 @cindex task switching with program using Ravenscar Profile
   19470 @item set ravenscar task-switching on
   19471 Allows task switching when debugging a program that uses the Ravenscar
   19472 Profile.  This is the default.
   19473 
   19474 @kindex set ravenscar task-switching off
   19475 @item set ravenscar task-switching off
   19476 Turn off task switching when debugging a program that uses the Ravenscar
   19477 Profile.  This is mostly intended to disable the code that adds support
   19478 for the Ravenscar Profile, in case a bug in either @value{GDBN} or in
   19479 the Ravenscar runtime is preventing @value{GDBN} from working properly.
   19480 To be effective, this command should be run before the program is started.
   19481 
   19482 @kindex show ravenscar task-switching
   19483 @item show ravenscar task-switching
   19484 Show whether it is possible to switch from task to task in a program
   19485 using the Ravenscar Profile.
   19486 
   19487 @end table
   19488 
   19489 @cindex Ravenscar thread
   19490 When Ravenscar task-switching is enabled, Ravenscar tasks are
   19491 announced by @value{GDBN} as if they were threads:
   19492 
   19493 @smallexample
   19494 (gdb) continue
   19495 [New Ravenscar Thread 0x2b8f0]
   19496 @end smallexample
   19497 
   19498 Both Ravenscar tasks and the underlying CPU threads will show up in
   19499 the output of @code{info threads}:
   19500 
   19501 @smallexample
   19502 (gdb) info threads
   19503   Id   Target Id                  Frame
   19504   1    Thread 1 (CPU#0 [running]) simple () at simple.adb:10
   19505   2    Thread 2 (CPU#1 [running]) 0x0000000000003d34 in __gnat_initialize_cpu_devices ()
   19506   3    Thread 3 (CPU#2 [running]) 0x0000000000003d28 in __gnat_initialize_cpu_devices ()
   19507   4    Thread 4 (CPU#3 [halted ]) 0x000000000000c6ec in system.task_primitives.operations.idle ()
   19508 * 5    Ravenscar Thread 0x2b8f0   simple () at simple.adb:10
   19509   6    Ravenscar Thread 0x2f150   0x000000000000c6ec in system.task_primitives.operations.idle ()
   19510 @end smallexample
   19511 
   19512 One known limitation of the Ravenscar support in @value{GDBN} is that
   19513 it isn't currently possible to single-step through the runtime
   19514 initialization sequence.  If you need to debug this code, you should
   19515 use @code{set ravenscar task-switching off}.
   19516 
   19517 @node Ada Source Character Set
   19518 @subsubsection Ada Source Character Set
   19519 @cindex Ada, source character set
   19520 
   19521 The GNAT compiler supports a number of character sets for source
   19522 files.  @xref{Character Set Control, , Character Set Control,
   19523 gnat_ugn}.  @value{GDBN} includes support for this as well.
   19524 
   19525 @table @code
   19526 @item set ada source-charset @var{charset}
   19527 @kindex set ada source-charset
   19528 Set the source character set for Ada.  The character set must be
   19529 supported by GNAT.  Because this setting affects the decoding of
   19530 symbols coming from the debug information in your program, the setting
   19531 should be set as early as possible.  The default is @code{ISO-8859-1},
   19532 because that is also GNAT's default.
   19533 
   19534 @item show ada source-charset
   19535 @kindex show ada source-charset
   19536 Show the current source character set for Ada.
   19537 @end table
   19538 
   19539 @node Ada Glitches
   19540 @subsubsection Known Peculiarities of Ada Mode
   19541 @cindex Ada, problems
   19542 
   19543 Besides the omissions listed previously (@pxref{Omissions from Ada}),
   19544 we know of several problems with and limitations of Ada mode in
   19545 @value{GDBN},
   19546 some of which will be fixed with planned future releases of the debugger 
   19547 and the GNU Ada compiler.
   19548 
   19549 @itemize @bullet
   19550 @item 
   19551 Static constants that the compiler chooses not to materialize as objects in 
   19552 storage are invisible to the debugger.
   19553 
   19554 @item
   19555 Named parameter associations in function argument lists are ignored (the
   19556 argument lists are treated as positional).
   19557 
   19558 @item
   19559 Many useful library packages are currently invisible to the debugger.
   19560 
   19561 @item
   19562 Fixed-point arithmetic, conversions, input, and output is carried out using 
   19563 floating-point arithmetic, and may give results that only approximate those on 
   19564 the host machine.
   19565 
   19566 @item
   19567 The GNAT compiler never generates the prefix @code{Standard} for any of 
   19568 the standard symbols defined by the Ada language.  @value{GDBN} knows about 
   19569 this: it will strip the prefix from names when you use it, and will never
   19570 look for a name you have so qualified among local symbols, nor match against
   19571 symbols in other packages or subprograms.  If you have 
   19572 defined entities anywhere in your program other than parameters and 
   19573 local variables whose simple names match names in @code{Standard}, 
   19574 GNAT's lack of qualification here can cause confusion.  When this happens,
   19575 you can usually resolve the confusion 
   19576 by qualifying the problematic names with package
   19577 @code{Standard} explicitly.  
   19578 @end itemize
   19579 
   19580 Older versions of the compiler sometimes generate erroneous debugging
   19581 information, resulting in the debugger incorrectly printing the value
   19582 of affected entities.  In some cases, the debugger is able to work
   19583 around an issue automatically. In other cases, the debugger is able
   19584 to work around the issue, but the work-around has to be specifically
   19585 enabled.
   19586 
   19587 @kindex set ada trust-PAD-over-XVS
   19588 @kindex show ada trust-PAD-over-XVS
   19589 @table @code
   19590 
   19591 @item set ada trust-PAD-over-XVS on
   19592 Configure GDB to strictly follow the GNAT encoding when computing the
   19593 value of Ada entities, particularly when @code{PAD} and @code{PAD___XVS}
   19594 types are involved (see @code{ada/exp_dbug.ads} in the GCC sources for
   19595 a complete description of the encoding used by the GNAT compiler).
   19596 This is the default.
   19597 
   19598 @item set ada trust-PAD-over-XVS off
   19599 This is related to the encoding using by the GNAT compiler.  If @value{GDBN}
   19600 sometimes prints the wrong value for certain entities, changing @code{ada
   19601 trust-PAD-over-XVS} to @code{off} activates a work-around which may fix
   19602 the issue.  It is always safe to set @code{ada trust-PAD-over-XVS} to
   19603 @code{off}, but this incurs a slight performance penalty, so it is
   19604 recommended to leave this setting to @code{on} unless necessary.
   19605 
   19606 @end table
   19607 
   19608 @cindex GNAT descriptive types
   19609 @cindex GNAT encoding
   19610 Internally, the debugger also relies on the compiler following a number
   19611 of conventions known as the @samp{GNAT Encoding}, all documented in
   19612 @file{gcc/ada/exp_dbug.ads} in the GCC sources. This encoding describes
   19613 how the debugging information should be generated for certain types.
   19614 In particular, this convention makes use of @dfn{descriptive types},
   19615 which are artificial types generated purely to help the debugger.
   19616 
   19617 These encodings were defined at a time when the debugging information
   19618 format used was not powerful enough to describe some of the more complex
   19619 types available in Ada.  Since DWARF allows us to express nearly all
   19620 Ada features, the long-term goal is to slowly replace these descriptive
   19621 types by their pure DWARF equivalent.  To facilitate that transition,
   19622 a new maintenance option is available to force the debugger to ignore
   19623 those descriptive types.  It allows the user to quickly evaluate how
   19624 well @value{GDBN} works without them.
   19625 
   19626 @table @code
   19627 
   19628 @kindex maint ada set ignore-descriptive-types
   19629 @item maintenance ada set ignore-descriptive-types [on|off]
   19630 Control whether the debugger should ignore descriptive types.
   19631 The default is not to ignore descriptives types (@code{off}).
   19632 
   19633 @kindex maint ada show ignore-descriptive-types
   19634 @item maintenance ada show ignore-descriptive-types
   19635 Show if descriptive types are ignored by @value{GDBN}.
   19636 
   19637 @end table
   19638 
   19639 @node Unsupported Languages
   19640 @section Unsupported Languages
   19641 
   19642 @cindex unsupported languages
   19643 @cindex minimal language
   19644 In addition to the other fully-supported programming languages,
   19645 @value{GDBN} also provides a pseudo-language, called @code{minimal}.
   19646 It does not represent a real programming language, but provides a set
   19647 of capabilities close to what the C or assembly languages provide.
   19648 This should allow most simple operations to be performed while debugging
   19649 an application that uses a language currently not supported by @value{GDBN}.
   19650 
   19651 If the language is set to @code{auto}, @value{GDBN} will automatically
   19652 select this language if the current frame corresponds to an unsupported
   19653 language.
   19654 
   19655 @node Symbols
   19656 @chapter Examining the Symbol Table
   19657 
   19658 The commands described in this chapter allow you to inquire about the
   19659 symbols (names of variables, functions and types) defined in your
   19660 program.  This information is inherent in the text of your program and
   19661 does not change as your program executes.  @value{GDBN} finds it in your
   19662 program's symbol table, in the file indicated when you started @value{GDBN}
   19663 (@pxref{File Options, ,Choosing Files}), or by one of the
   19664 file-management commands (@pxref{Files, ,Commands to Specify Files}).
   19665 
   19666 @cindex symbol names
   19667 @cindex names of symbols
   19668 @cindex quoting names
   19669 @anchor{quoting names}
   19670 Occasionally, you may need to refer to symbols that contain unusual
   19671 characters, which @value{GDBN} ordinarily treats as word delimiters.  The
   19672 most frequent case is in referring to static variables in other
   19673 source files (@pxref{Variables,,Program Variables}).  File names
   19674 are recorded in object files as debugging symbols, but @value{GDBN} would
   19675 ordinarily parse a typical file name, like @file{foo.c}, as the three words
   19676 @samp{foo} @samp{.} @samp{c}.  To allow @value{GDBN} to recognize
   19677 @samp{foo.c} as a single symbol, enclose it in single quotes; for example,
   19678 
   19679 @smallexample
   19680 p 'foo.c'::x
   19681 @end smallexample
   19682 
   19683 @noindent
   19684 looks up the value of @code{x} in the scope of the file @file{foo.c}.
   19685 
   19686 @table @code
   19687 @cindex case-insensitive symbol names
   19688 @cindex case sensitivity in symbol names
   19689 @kindex set case-sensitive
   19690 @item set case-sensitive on
   19691 @itemx set case-sensitive off
   19692 @itemx set case-sensitive auto
   19693 Normally, when @value{GDBN} looks up symbols, it matches their names
   19694 with case sensitivity determined by the current source language.
   19695 Occasionally, you may wish to control that.  The command @code{set
   19696 case-sensitive} lets you do that by specifying @code{on} for
   19697 case-sensitive matches or @code{off} for case-insensitive ones.  If
   19698 you specify @code{auto}, case sensitivity is reset to the default
   19699 suitable for the source language.  The default is case-sensitive
   19700 matches for all languages except for Fortran, for which the default is
   19701 case-insensitive matches.
   19702 
   19703 @kindex show case-sensitive
   19704 @item show case-sensitive
   19705 This command shows the current setting of case sensitivity for symbols
   19706 lookups.
   19707 
   19708 @kindex set print type methods
   19709 @item set print type methods
   19710 @itemx set print type methods on
   19711 @itemx set print type methods off
   19712 Normally, when @value{GDBN} prints a class, it displays any methods
   19713 declared in that class.  You can control this behavior either by
   19714 passing the appropriate flag to @code{ptype}, or using @command{set
   19715 print type methods}.  Specifying @code{on} will cause @value{GDBN} to
   19716 display the methods; this is the default.  Specifying @code{off} will
   19717 cause @value{GDBN} to omit the methods.
   19718 
   19719 @kindex show print type methods
   19720 @item show print type methods
   19721 This command shows the current setting of method display when printing
   19722 classes.
   19723 
   19724 @kindex set print type nested-type-limit
   19725 @item set print type nested-type-limit @var{limit}
   19726 @itemx set print type nested-type-limit unlimited
   19727 Set the limit of displayed nested types that the type printer will
   19728 show.  A @var{limit} of @code{unlimited} or @code{-1} will show all
   19729 nested definitions.  By default, the type printer will not show any nested
   19730 types defined in classes.
   19731 
   19732 @kindex show print type nested-type-limit
   19733 @item show print type nested-type-limit
   19734 This command shows the current display limit of nested types when
   19735 printing classes.
   19736 
   19737 @kindex set print type typedefs
   19738 @item set print type typedefs
   19739 @itemx set print type typedefs on
   19740 @itemx set print type typedefs off
   19741 
   19742 Normally, when @value{GDBN} prints a class, it displays any typedefs
   19743 defined in that class.  You can control this behavior either by
   19744 passing the appropriate flag to @code{ptype}, or using @command{set
   19745 print type typedefs}.  Specifying @code{on} will cause @value{GDBN} to
   19746 display the typedef definitions; this is the default.  Specifying
   19747 @code{off} will cause @value{GDBN} to omit the typedef definitions.
   19748 Note that this controls whether the typedef definition itself is
   19749 printed, not whether typedef names are substituted when printing other
   19750 types.
   19751 
   19752 @kindex show print type typedefs
   19753 @item show print type typedefs
   19754 This command shows the current setting of typedef display when
   19755 printing classes.
   19756 
   19757 @kindex set print type hex
   19758 @item set print type hex
   19759 @itemx set print type hex on
   19760 @itemx set print type hex off
   19761 
   19762 When @value{GDBN} prints sizes and offsets of struct members, it can use
   19763 either the decimal or hexadecimal notation.  You can select one or the
   19764 other either by passing the appropriate flag to @code{ptype}, or by using
   19765 the @command{set print type hex} command.
   19766 
   19767 @kindex show print type hex
   19768 @item show print type hex
   19769 This command shows whether the sizes and offsets of struct members are
   19770 printed in decimal or hexadecimal notation.
   19771 
   19772 @kindex info address
   19773 @cindex address of a symbol
   19774 @item info address @var{symbol}
   19775 Describe where the data for @var{symbol} is stored.  For a register
   19776 variable, this says which register it is kept in.  For a non-register
   19777 local variable, this prints the stack-frame offset at which the variable
   19778 is always stored.
   19779 
   19780 Note the contrast with @samp{print &@var{symbol}}, which does not work
   19781 at all for a register variable, and for a stack local variable prints
   19782 the exact address of the current instantiation of the variable.
   19783 
   19784 @kindex info symbol
   19785 @cindex symbol from address
   19786 @cindex closest symbol and offset for an address
   19787 @item info symbol @var{addr}
   19788 Print the name of a symbol which is stored at the address @var{addr}.
   19789 If no symbol is stored exactly at @var{addr}, @value{GDBN} prints the
   19790 nearest symbol and an offset from it:
   19791 
   19792 @smallexample
   19793 (@value{GDBP}) info symbol 0x54320
   19794 _initialize_vx + 396 in section .text
   19795 @end smallexample
   19796 
   19797 @noindent
   19798 This is the opposite of the @code{info address} command.  You can use
   19799 it to find out the name of a variable or a function given its address.
   19800 
   19801 For dynamically linked executables, the name of executable or shared
   19802 library containing the symbol is also printed:
   19803 
   19804 @smallexample
   19805 (@value{GDBP}) info symbol 0x400225
   19806 _start + 5 in section .text of /tmp/a.out
   19807 (@value{GDBP}) info symbol 0x2aaaac2811cf
   19808 __read_nocancel + 6 in section .text of /usr/lib64/libc.so.6
   19809 @end smallexample
   19810 
   19811 @kindex demangle
   19812 @cindex demangle
   19813 @item demangle @r{[}-l @var{language}@r{]} @r{[}@var{--}@r{]} @var{name}
   19814 Demangle @var{name}.
   19815 If @var{language} is provided it is the name of the language to demangle
   19816 @var{name} in.  Otherwise @var{name} is demangled in the current language.
   19817 
   19818 The @samp{--} option specifies the end of options,
   19819 and is useful when @var{name} begins with a dash.
   19820 
   19821 The parameter @code{demangle-style} specifies how to interpret the kind
   19822 of mangling used. @xref{Print Settings}.
   19823 
   19824 @kindex whatis
   19825 @item whatis[/@var{flags}] [@var{arg}]
   19826 Print the data type of @var{arg}, which can be either an expression
   19827 or a name of a data type.  With no argument, print the data type of
   19828 @code{$}, the last value in the value history.
   19829 
   19830 If @var{arg} is an expression (@pxref{Expressions, ,Expressions}), it
   19831 is not actually evaluated, and any side-effecting operations (such as
   19832 assignments or function calls) inside it do not take place.
   19833 
   19834 If @var{arg} is a variable or an expression, @code{whatis} prints its
   19835 literal type as it is used in the source code.  If the type was
   19836 defined using a @code{typedef}, @code{whatis} will @emph{not} print
   19837 the data type underlying the @code{typedef}.  If the type of the
   19838 variable or the expression is a compound data type, such as
   19839 @code{struct} or  @code{class}, @code{whatis} never prints their
   19840 fields or methods.  It just prints the @code{struct}/@code{class}
   19841 name (a.k.a.@: its @dfn{tag}).  If you want to see the members of
   19842 such a compound data type, use @code{ptype}.
   19843 
   19844 If @var{arg} is a type name that was defined using @code{typedef},
   19845 @code{whatis} @dfn{unrolls} only one level of that @code{typedef}.
   19846 Unrolling means that @code{whatis} will show the underlying type used
   19847 in the @code{typedef} declaration of @var{arg}.  However, if that
   19848 underlying type is also a @code{typedef}, @code{whatis} will not
   19849 unroll it.
   19850 
   19851 For C code, the type names may also have the form @samp{class
   19852 @var{class-name}}, @samp{struct @var{struct-tag}}, @samp{union
   19853 @var{union-tag}} or @samp{enum @var{enum-tag}}.
   19854 
   19855 @var{flags} can be used to modify how the type is displayed.
   19856 Available flags are:
   19857 
   19858 @table @code
   19859 @item r
   19860 Display in ``raw'' form.  Normally, @value{GDBN} substitutes template
   19861 parameters and typedefs defined in a class when printing the class'
   19862 members.  The @code{/r} flag disables this.
   19863 
   19864 @item m
   19865 Do not print methods defined in the class.
   19866 
   19867 @item M
   19868 Print methods defined in the class.  This is the default, but the flag
   19869 exists in case you change the default with @command{set print type methods}.
   19870 
   19871 @item t
   19872 Do not print typedefs defined in the class.  Note that this controls
   19873 whether the typedef definition itself is printed, not whether typedef
   19874 names are substituted when printing other types.
   19875 
   19876 @item T
   19877 Print typedefs defined in the class.  This is the default, but the flag
   19878 exists in case you change the default with @command{set print type typedefs}.
   19879 
   19880 @item o
   19881 Print the offsets and sizes of fields in a struct, similar to what the
   19882 @command{pahole} tool does.  This option implies the @code{/tm} flags.
   19883 
   19884 @item x
   19885 Use hexadecimal notation when printing offsets and sizes of fields in a
   19886 struct.
   19887 
   19888 @item d
   19889 Use decimal notation when printing offsets and sizes of fields in a
   19890 struct.
   19891 
   19892 For example, given the following declarations:
   19893 
   19894 @smallexample
   19895 struct tuv
   19896 @{
   19897   int a1;
   19898   char *a2;
   19899   int a3;
   19900 @};
   19901 
   19902 struct xyz
   19903 @{
   19904   int f1;
   19905   char f2;
   19906   void *f3;
   19907   struct tuv f4;
   19908 @};
   19909 
   19910 union qwe
   19911 @{
   19912   struct tuv fff1;
   19913   struct xyz fff2;
   19914 @};
   19915 
   19916 struct tyu
   19917 @{
   19918   int a1 : 1;
   19919   int a2 : 3;
   19920   int a3 : 23;
   19921   char a4 : 2;
   19922   int64_t a5;
   19923   int a6 : 5;
   19924   int64_t a7 : 3;
   19925 @};
   19926 @end smallexample
   19927 
   19928 Issuing a @kbd{ptype /o struct tuv} command would print:
   19929 
   19930 @smallexample
   19931 (@value{GDBP}) ptype /o struct tuv
   19932 /* offset      |    size */  type = struct tuv @{
   19933 /*      0      |       4 */    int a1;
   19934 /* XXX  4-byte hole      */
   19935 /*      8      |       8 */    char *a2;
   19936 /*     16      |       4 */    int a3;
   19937 
   19938                                /* total size (bytes):   24 */
   19939                              @}
   19940 @end smallexample
   19941 
   19942 Notice the format of the first column of comments.  There, you can
   19943 find two parts separated by the @samp{|} character: the @emph{offset},
   19944 which indicates where the field is located inside the struct, in
   19945 bytes, and the @emph{size} of the field.  Another interesting line is
   19946 the marker of a @emph{hole} in the struct, indicating that it may be
   19947 possible to pack the struct and make it use less space by reorganizing
   19948 its fields.
   19949 
   19950 It is also possible to print offsets inside an union:
   19951 
   19952 @smallexample
   19953 (@value{GDBP}) ptype /o union qwe
   19954 /* offset      |    size */  type = union qwe @{
   19955 /*                    24 */    struct tuv @{
   19956 /*      0      |       4 */        int a1;
   19957 /* XXX  4-byte hole      */
   19958 /*      8      |       8 */        char *a2;
   19959 /*     16      |       4 */        int a3;
   19960 
   19961                                    /* total size (bytes):   24 */
   19962                                @} fff1;
   19963 /*                    40 */    struct xyz @{
   19964 /*      0      |       4 */        int f1;
   19965 /*      4      |       1 */        char f2;
   19966 /* XXX  3-byte hole      */
   19967 /*      8      |       8 */        void *f3;
   19968 /*     16      |      24 */        struct tuv @{
   19969 /*     16      |       4 */            int a1;
   19970 /* XXX  4-byte hole      */
   19971 /*     24      |       8 */            char *a2;
   19972 /*     32      |       4 */            int a3;
   19973 
   19974                                        /* total size (bytes):   24 */
   19975                                    @} f4;
   19976 
   19977                                    /* total size (bytes):   40 */
   19978                                @} fff2;
   19979 
   19980                                /* total size (bytes):   40 */
   19981                              @}
   19982 @end smallexample
   19983 
   19984 In this case, since @code{struct tuv} and @code{struct xyz} occupy the
   19985 same space (because we are dealing with an union), the offset is not
   19986 printed for them.  However, you can still examine the offset of each
   19987 of these structures' fields.
   19988 
   19989 Another useful scenario is printing the offsets of a struct containing
   19990 bitfields:
   19991 
   19992 @smallexample
   19993 (@value{GDBP}) ptype /o struct tyu
   19994 /* offset      |    size */  type = struct tyu @{
   19995 /*      0:31   |       4 */    int a1 : 1;
   19996 /*      0:28   |       4 */    int a2 : 3;
   19997 /*      0: 5   |       4 */    int a3 : 23;
   19998 /*      3: 3   |       1 */    signed char a4 : 2;
   19999 /* XXX  3-bit hole       */
   20000 /* XXX  4-byte hole      */
   20001 /*      8      |       8 */    int64_t a5;
   20002 /*     16: 0   |       4 */    int a6 : 5;
   20003 /*     16: 5   |       8 */    int64_t a7 : 3;
   20004 /* XXX  7-byte padding   */
   20005 
   20006                                /* total size (bytes):   24 */
   20007                              @}
   20008 @end smallexample
   20009 
   20010 Note how the offset information is now extended to also include the
   20011 first bit of the bitfield.
   20012 @end table
   20013 
   20014 @kindex ptype
   20015 @item ptype[/@var{flags}] [@var{arg}]
   20016 @code{ptype} accepts the same arguments as @code{whatis}, but prints a
   20017 detailed description of the type, instead of just the name of the type.
   20018 @xref{Expressions, ,Expressions}.
   20019 
   20020 Contrary to @code{whatis}, @code{ptype} always unrolls any
   20021 @code{typedef}s in its argument declaration, whether the argument is
   20022 a variable, expression, or a data type.  This means that @code{ptype}
   20023 of a variable or an expression will not print literally its type as
   20024 present in the source code---use @code{whatis} for that.  @code{typedef}s at
   20025 the pointer or reference targets are also unrolled.  Only @code{typedef}s of
   20026 fields, methods and inner @code{class typedef}s of @code{struct}s,
   20027 @code{class}es and @code{union}s are not unrolled even with @code{ptype}.
   20028 
   20029 For example, for this variable declaration:
   20030 
   20031 @smallexample
   20032 typedef double real_t;
   20033 struct complex @{ real_t real; double imag; @};
   20034 typedef struct complex complex_t;
   20035 complex_t var;
   20036 real_t *real_pointer_var;
   20037 @end smallexample
   20038 
   20039 @noindent
   20040 the two commands give this output:
   20041 
   20042 @smallexample
   20043 @group
   20044 (@value{GDBP}) whatis var
   20045 type = complex_t
   20046 (@value{GDBP}) ptype var
   20047 type = struct complex @{
   20048     real_t real;
   20049     double imag;
   20050 @}
   20051 (@value{GDBP}) whatis complex_t
   20052 type = struct complex
   20053 (@value{GDBP}) whatis struct complex
   20054 type = struct complex
   20055 (@value{GDBP}) ptype struct complex
   20056 type = struct complex @{
   20057     real_t real;
   20058     double imag;
   20059 @}
   20060 (@value{GDBP}) whatis real_pointer_var
   20061 type = real_t *
   20062 (@value{GDBP}) ptype real_pointer_var
   20063 type = double *
   20064 @end group
   20065 @end smallexample
   20066 
   20067 @noindent
   20068 As with @code{whatis}, using @code{ptype} without an argument refers to
   20069 the type of @code{$}, the last value in the value history.
   20070 
   20071 @cindex incomplete type
   20072 Sometimes, programs use opaque data types or incomplete specifications
   20073 of complex data structure.  If the debug information included in the
   20074 program does not allow @value{GDBN} to display a full declaration of
   20075 the data type, it will say @samp{<incomplete type>}.  For example,
   20076 given these declarations:
   20077 
   20078 @smallexample
   20079     struct foo;
   20080     struct foo *fooptr;
   20081 @end smallexample
   20082 
   20083 @noindent
   20084 but no definition for @code{struct foo} itself, @value{GDBN} will say:
   20085 
   20086 @smallexample
   20087   (@value{GDBP}) ptype foo
   20088   $1 = <incomplete type>
   20089 @end smallexample
   20090 
   20091 @noindent
   20092 ``Incomplete type'' is C terminology for data types that are not
   20093 completely specified.
   20094 
   20095 @cindex unknown type
   20096 Othertimes, information about a variable's type is completely absent
   20097 from the debug information included in the program.  This most often
   20098 happens when the program or library where the variable is defined
   20099 includes no debug information at all.  @value{GDBN} knows the variable
   20100 exists from inspecting the linker/loader symbol table (e.g., the ELF
   20101 dynamic symbol table), but such symbols do not contain type
   20102 information.  Inspecting the type of a (global) variable for which
   20103 @value{GDBN} has no type information shows:
   20104 
   20105 @smallexample
   20106   (@value{GDBP}) ptype var
   20107   type = <data variable, no debug info>
   20108 @end smallexample
   20109 
   20110 @xref{Variables, no debug info variables}, for how to print the values
   20111 of such variables.
   20112 
   20113 @kindex info types
   20114 @item info types [-q] [@var{regexp}]
   20115 Print a brief description of all types whose names match the regular
   20116 expression @var{regexp} (or all types in your program, if you supply
   20117 no argument).  Each complete typename is matched as though it were a
   20118 complete line; thus, @samp{i type value} gives information on all
   20119 types in your program whose names include the string @code{value}, but
   20120 @samp{i type ^value$} gives information only on types whose complete
   20121 name is @code{value}.
   20122 
   20123 In programs using different languages, @value{GDBN} chooses the syntax
   20124 to print the type description according to the
   20125 @samp{set language} value: using @samp{set language auto}
   20126 (see @ref{Automatically, ,Set Language Automatically}) means to use the
   20127 language of the type, other values mean to use
   20128 the manually specified language (see @ref{Manually, ,Set Language Manually}).
   20129 
   20130 This command differs from @code{ptype} in two ways: first, like
   20131 @code{whatis}, it does not print a detailed description; second, it
   20132 lists all source files and line numbers where a type is defined.
   20133 
   20134 The output from @samp{into types} is proceeded with a header line
   20135 describing what types are being listed.  The optional flag @samp{-q},
   20136 which stands for @samp{quiet}, disables printing this header
   20137 information.
   20138 
   20139 @kindex info type-printers
   20140 @item info type-printers
   20141 Versions of @value{GDBN} that ship with Python scripting enabled may
   20142 have ``type printers'' available.  When using @command{ptype} or
   20143 @command{whatis}, these printers are consulted when the name of a type
   20144 is needed.  @xref{Type Printing API}, for more information on writing
   20145 type printers.
   20146 
   20147 @code{info type-printers} displays all the available type printers.
   20148 
   20149 @kindex enable type-printer
   20150 @kindex disable type-printer
   20151 @item enable type-printer @var{name}@dots{}
   20152 @item disable type-printer @var{name}@dots{}
   20153 These commands can be used to enable or disable type printers.
   20154 
   20155 @kindex info scope
   20156 @cindex local variables
   20157 @item info scope @var{locspec}
   20158 List all the variables local to the lexical scope of the code location
   20159 that results from resolving @var{locspec}.  @xref{Location
   20160 Specifications}, for details about supported forms of @var{locspec}.
   20161 For example:
   20162 
   20163 @smallexample
   20164 (@value{GDBP}) @b{info scope command_line_handler}
   20165 Scope for command_line_handler:
   20166 Symbol rl is an argument at stack/frame offset 8, length 4.
   20167 Symbol linebuffer is in static storage at address 0x150a18, length 4.
   20168 Symbol linelength is in static storage at address 0x150a1c, length 4.
   20169 Symbol p is a local variable in register $esi, length 4.
   20170 Symbol p1 is a local variable in register $ebx, length 4.
   20171 Symbol nline is a local variable in register $edx, length 4.
   20172 Symbol repeat is a local variable at frame offset -8, length 4.
   20173 @end smallexample
   20174 
   20175 @noindent
   20176 This command is especially useful for determining what data to collect
   20177 during a @dfn{trace experiment}, see @ref{Tracepoint Actions,
   20178 collect}.
   20179 
   20180 @kindex info source
   20181 @item info source
   20182 Show information about the current source file---that is, the source file for
   20183 the function containing the current point of execution:
   20184 @itemize @bullet
   20185 @item
   20186 the name of the source file, and the directory containing it,
   20187 @item
   20188 the directory it was compiled in,
   20189 @item
   20190 its length, in lines,
   20191 @item
   20192 which programming language it is written in,
   20193 @item
   20194 if the debug information provides it, the program that compiled the file
   20195 (which may include, e.g., the compiler version and command line arguments),
   20196 @item
   20197 whether the executable includes debugging information for that file, and
   20198 if so, what format the information is in (e.g., STABS, Dwarf 2, etc.), and
   20199 @item
   20200 whether the debugging information includes information about
   20201 preprocessor macros.
   20202 @end itemize
   20203 
   20204 
   20205 @kindex info sources
   20206 @item info sources @r{[}-dirname | -basename@r{]} @r{[}--@r{]} @r{[}@var{regexp}@r{]}
   20207 
   20208 
   20209 With no options @samp{info sources} prints the names of all source
   20210 files in your program for which there is debugging information.  The
   20211 source files are presented based on a list of object files
   20212 (executables and libraries) currently loaded into @value{GDBN}.  For
   20213 each object file all of the associated source files are listed.
   20214 
   20215 Each source file will only be printed once for each object file, but a
   20216 single source file can be repeated in the output if it is part of
   20217 multiple object files.
   20218 
   20219 If the optional @var{regexp} is provided, then only source files that
   20220 match the regular expression will be printed.  The matching is
   20221 case-sensitive, except on operating systems that have case-insensitive
   20222 filesystem (e.g., MS-Windows). @samp{--} can be used before
   20223 @var{regexp} to prevent @value{GDBN} interpreting @var{regexp} as a
   20224 command option (e.g. if @var{regexp} starts with @samp{-}).
   20225 
   20226 By default, the @var{regexp} is used to match anywhere in the
   20227 filename.  If @code{-dirname}, only files having a dirname matching
   20228 @var{regexp} are shown.  If @code{-basename}, only files having a
   20229 basename matching @var{regexp} are shown.
   20230 
   20231 It is possible that an object file may be printed in the list with no
   20232 associated source files.  This can happen when either no source files
   20233 match @var{regexp}, or, the object file was compiled without debug
   20234 information and so @value{GDBN} is unable to find any source file
   20235 names.
   20236 
   20237 @kindex info functions
   20238 @item info functions [-q] [-n]
   20239 Print the names and data types of all defined functions.
   20240 Similarly to @samp{info types}, this command groups its output by source
   20241 files and annotates each function definition with its source line
   20242 number.
   20243 
   20244 In programs using different languages, @value{GDBN} chooses the syntax
   20245 to print the function name and type according to the
   20246 @samp{set language} value: using @samp{set language auto}
   20247 (see @ref{Automatically, ,Set Language Automatically}) means to use the
   20248 language of the function, other values mean to use
   20249 the manually specified language (see @ref{Manually, ,Set Language Manually}).
   20250 
   20251 The @samp{-n} flag excludes @dfn{non-debugging symbols} from the
   20252 results.  A non-debugging symbol is a symbol that comes from the
   20253 executable's symbol table, not from the debug information (for
   20254 example, DWARF) associated with the executable.
   20255 
   20256 The optional flag @samp{-q}, which stands for @samp{quiet}, disables
   20257 printing header information and messages explaining why no functions
   20258 have been printed.
   20259 
   20260 @item info functions [-q] [-n] [-t @var{type_regexp}] [@var{regexp}]
   20261 Like @samp{info functions}, but only print the names and data types
   20262 of the functions selected with the provided regexp(s).
   20263 
   20264 If @var{regexp} is provided, print only the functions whose names
   20265 match the regular expression @var{regexp}.
   20266 Thus, @samp{info fun step} finds all functions whose
   20267 names include @code{step}; @samp{info fun ^step} finds those whose names
   20268 start with @code{step}.  If a function name contains characters that
   20269 conflict with the regular expression language (e.g.@:
   20270 @samp{operator*()}), they may be quoted with a backslash.
   20271 
   20272 If @var{type_regexp} is provided, print only the functions whose
   20273 types, as printed by the @code{whatis} command, match
   20274 the regular expression @var{type_regexp}.
   20275 If @var{type_regexp} contains space(s), it should be enclosed in
   20276 quote characters.  If needed, use backslash to escape the meaning
   20277 of special characters or quotes.
   20278 Thus, @samp{info fun -t '^int ('} finds the functions that return
   20279 an integer; @samp{info fun -t '(.*int.*'} finds the functions that
   20280 have an argument type containing int; @samp{info fun -t '^int (' ^step}
   20281 finds the functions whose names start with @code{step} and that return
   20282 int.
   20283 
   20284 If both @var{regexp} and @var{type_regexp} are provided, a function
   20285 is printed only if its name matches @var{regexp} and its type matches
   20286 @var{type_regexp}.
   20287 
   20288 
   20289 @kindex info variables
   20290 @item info variables [-q] [-n]
   20291 Print the names and data types of all variables that are defined
   20292 outside of functions (i.e.@: excluding local variables).
   20293 The printed variables are grouped by source files and annotated with
   20294 their respective source line numbers.
   20295 
   20296 In programs using different languages, @value{GDBN} chooses the syntax
   20297 to print the variable name and type according to the
   20298 @samp{set language} value: using @samp{set language auto}
   20299 (see @ref{Automatically, ,Set Language Automatically}) means to use the
   20300 language of the variable, other values mean to use
   20301 the manually specified language (see @ref{Manually, ,Set Language Manually}).
   20302 
   20303 The @samp{-n} flag excludes non-debugging symbols from the results.
   20304 
   20305 The optional flag @samp{-q}, which stands for @samp{quiet}, disables
   20306 printing header information and messages explaining why no variables
   20307 have been printed.
   20308 
   20309 @item info variables [-q] [-n] [-t @var{type_regexp}] [@var{regexp}]
   20310 Like @kbd{info variables}, but only print the variables selected
   20311 with the provided regexp(s).
   20312 
   20313 If @var{regexp} is provided, print only the variables whose names
   20314 match the regular expression @var{regexp}.
   20315 
   20316 If @var{type_regexp} is provided, print only the variables whose
   20317 types, as printed by the @code{whatis} command, match
   20318 the regular expression @var{type_regexp}.
   20319 If @var{type_regexp} contains space(s), it should be enclosed in
   20320 quote characters.  If needed, use backslash to escape the meaning
   20321 of special characters or quotes.
   20322 
   20323 If both @var{regexp} and @var{type_regexp} are provided, an argument
   20324 is printed only if its name matches @var{regexp} and its type matches
   20325 @var{type_regexp}.
   20326 
   20327 @kindex info modules
   20328 @cindex modules
   20329 @item info modules @r{[}-q@r{]} @r{[}@var{regexp}@r{]}
   20330 List all Fortran modules in the program, or all modules matching the
   20331 optional regular expression @var{regexp}.
   20332 
   20333 The optional flag @samp{-q}, which stands for @samp{quiet}, disables
   20334 printing header information and messages explaining why no modules
   20335 have been printed.
   20336 
   20337 @kindex info module
   20338 @cindex Fortran modules, information about
   20339 @cindex functions and variables by Fortran module
   20340 @cindex module functions and variables
   20341 @item info module functions @r{[}-q@r{]} @r{[}-m @var{module-regexp}@r{]} @r{[}-t @var{type-regexp}@r{]} @r{[}@var{regexp}@r{]}
   20342 @itemx info module variables @r{[}-q@r{]} @r{[}-m @var{module-regexp}@r{]} @r{[}-t @var{type-regexp}@r{]} @r{[}@var{regexp}@r{]}
   20343 List all functions or variables within all Fortran modules.  The set
   20344 of functions or variables listed can be limited by providing some or
   20345 all of the optional regular expressions.  If @var{module-regexp} is
   20346 provided, then only Fortran modules matching @var{module-regexp} will
   20347 be searched.  Only functions or variables whose type matches the
   20348 optional regular expression @var{type-regexp} will be listed.  And
   20349 only functions or variables whose name matches the optional regular
   20350 expression @var{regexp} will be listed.
   20351 
   20352 The optional flag @samp{-q}, which stands for @samp{quiet}, disables
   20353 printing header information and messages explaining why no functions
   20354 or variables have been printed.
   20355 
   20356 @kindex info main
   20357 @item info main
   20358 Print the name of the starting function of the program.  This serves
   20359 primarily Fortran programs, which have a user-supplied name for the
   20360 main subroutine.
   20361 
   20362 @kindex info classes
   20363 @cindex Objective-C, classes and selectors
   20364 @item info classes
   20365 @itemx info classes @var{regexp}
   20366 Display all Objective-C classes in your program, or
   20367 (with the @var{regexp} argument) all those matching a particular regular
   20368 expression.
   20369 
   20370 @kindex info selectors
   20371 @item info selectors
   20372 @itemx info selectors @var{regexp}
   20373 Display all Objective-C selectors in your program, or
   20374 (with the @var{regexp} argument) all those matching a particular regular
   20375 expression.
   20376 
   20377 @ignore
   20378 This was never implemented.
   20379 @kindex info methods
   20380 @item info methods
   20381 @itemx info methods @var{regexp}
   20382 The @code{info methods} command permits the user to examine all defined
   20383 methods within C@t{++} program, or (with the @var{regexp} argument) a
   20384 specific set of methods found in the various C@t{++} classes.  Many
   20385 C@t{++} classes provide a large number of methods.  Thus, the output
   20386 from the @code{ptype} command can be overwhelming and hard to use.  The
   20387 @code{info-methods} command filters the methods, printing only those
   20388 which match the regular-expression @var{regexp}.
   20389 @end ignore
   20390 
   20391 @cindex opaque data types
   20392 @kindex set opaque-type-resolution
   20393 @item set opaque-type-resolution on
   20394 Tell @value{GDBN} to resolve opaque types.  An opaque type is a type
   20395 declared as a pointer to a @code{struct}, @code{class}, or
   20396 @code{union}---for example, @code{struct MyType *}---that is used in one
   20397 source file although the full declaration of @code{struct MyType} is in
   20398 another source file.  The default is on.
   20399 
   20400 A change in the setting of this subcommand will not take effect until
   20401 the next time symbols for a file are loaded.
   20402 
   20403 @item set opaque-type-resolution off
   20404 Tell @value{GDBN} not to resolve opaque types.  In this case, the type
   20405 is printed as follows:
   20406 @smallexample
   20407 @{<no data fields>@}
   20408 @end smallexample
   20409 
   20410 @kindex show opaque-type-resolution
   20411 @item show opaque-type-resolution
   20412 Show whether opaque types are resolved or not.
   20413 
   20414 @kindex set print symbol-loading
   20415 @cindex print messages when symbols are loaded
   20416 @item set print symbol-loading
   20417 @itemx set print symbol-loading full
   20418 @itemx set print symbol-loading brief
   20419 @itemx set print symbol-loading off
   20420 The @code{set print symbol-loading} command allows you to control the
   20421 printing of messages when @value{GDBN} loads symbol information.
   20422 By default a message is printed for the executable and one for each
   20423 shared library, and normally this is what you want.  However, when
   20424 debugging apps with large numbers of shared libraries these messages
   20425 can be annoying.
   20426 When set to @code{brief} a message is printed for each executable,
   20427 and when @value{GDBN} loads a collection of shared libraries at once
   20428 it will only print one message regardless of the number of shared
   20429 libraries.  When set to @code{off} no messages are printed.
   20430 
   20431 @kindex show print symbol-loading
   20432 @item show print symbol-loading
   20433 Show whether messages will be printed when a @value{GDBN} command
   20434 entered from the keyboard causes symbol information to be loaded.
   20435 
   20436 @anchor{maint print symbols}
   20437 @kindex maint print symbols
   20438 @cindex symbol dump
   20439 @kindex maint print psymbols
   20440 @cindex partial symbol dump
   20441 @kindex maint print msymbols
   20442 @cindex minimal symbol dump
   20443 @item maint print symbols @r{[}-pc @var{address}@r{]} @r{[}@var{filename}@r{]}
   20444 @itemx maint print symbols @r{[}-objfile @var{objfile}@r{]} @r{[}-source @var{source}@r{]} @r{[}--@r{]} @r{[}@var{filename}@r{]}
   20445 @itemx maint print psymbols @r{[}-objfile @var{objfile}@r{]} @r{[}-pc @var{address}@r{]} @r{[}--@r{]} @r{[}@var{filename}@r{]}
   20446 @itemx maint print psymbols @r{[}-objfile @var{objfile}@r{]} @r{[}-source @var{source}@r{]} @r{[}--@r{]} @r{[}@var{filename}@r{]}
   20447 @itemx maint print msymbols @r{[}-objfile @var{objfile}@r{]} @r{[}--@r{]} @r{[}@var{filename}@r{]}
   20448 Write a dump of debugging symbol data into the file @var{filename} or
   20449 the terminal if @var{filename} is unspecified.
   20450 If @code{-objfile @var{objfile}} is specified, only dump symbols for
   20451 that objfile.
   20452 If @code{-pc @var{address}} is specified, only dump symbols for the file
   20453 with code at that address.  Note that @var{address} may be a symbol like
   20454 @code{main}.
   20455 If @code{-source @var{source}} is specified, only dump symbols for that
   20456 source file.
   20457 
   20458 These commands are used to debug the @value{GDBN} symbol-reading code.
   20459 These commands do not modify internal @value{GDBN} state, therefore
   20460 @samp{maint print symbols} will only print symbols for already expanded symbol
   20461 tables.
   20462 You can use the command @code{info sources} to find out which files these are.
   20463 If you use @samp{maint print psymbols} instead, the dump shows information
   20464 about symbols that @value{GDBN} only knows partially---that is, symbols
   20465 defined in files that @value{GDBN} has skimmed, but not yet read completely.
   20466 Finally, @samp{maint print msymbols} just dumps ``minimal symbols'', e.g.,
   20467 ``ELF symbols''.
   20468 
   20469 @xref{Files, ,Commands to Specify Files}, for a discussion of how
   20470 @value{GDBN} reads symbols (in the description of @code{symbol-file}).
   20471 
   20472 @kindex maint info symtabs
   20473 @kindex maint info psymtabs
   20474 @cindex listing @value{GDBN}'s internal symbol tables
   20475 @cindex symbol tables, listing @value{GDBN}'s internal
   20476 @cindex full symbol tables, listing @value{GDBN}'s internal
   20477 @cindex partial symbol tables, listing @value{GDBN}'s internal
   20478 @item maint info symtabs @r{[} @var{regexp} @r{]}
   20479 @itemx maint info psymtabs @r{[} @var{regexp} @r{]}
   20480 
   20481 List the @code{struct symtab} or @code{struct partial_symtab}
   20482 structures whose names match @var{regexp}.  If @var{regexp} is not
   20483 given, list them all.  The output includes expressions which you can
   20484 copy into a @value{GDBN} debugging this one to examine a particular
   20485 structure in more detail.  For example:
   20486 
   20487 @smallexample
   20488 (@value{GDBP}) maint info psymtabs dwarf2read
   20489 @{ objfile /home/gnu/build/gdb/gdb
   20490   ((struct objfile *) 0x82e69d0)
   20491   @{ psymtab /home/gnu/src/gdb/dwarf2read.c
   20492     ((struct partial_symtab *) 0x8474b10)
   20493     readin no
   20494     fullname (null)
   20495     text addresses 0x814d3c8 -- 0x8158074
   20496     globals (* (struct partial_symbol **) 0x8507a08 @@ 9)
   20497     statics (* (struct partial_symbol **) 0x40e95b78 @@ 2882)
   20498     dependencies (none)
   20499   @}
   20500 @}
   20501 (@value{GDBP}) maint info symtabs
   20502 (@value{GDBP})
   20503 @end smallexample
   20504 @noindent
   20505 We see that there is one partial symbol table whose filename contains
   20506 the string @samp{dwarf2read}, belonging to the @samp{gdb} executable;
   20507 and we see that @value{GDBN} has not read in any symtabs yet at all.
   20508 If we set a breakpoint on a function, that will cause @value{GDBN} to
   20509 read the symtab for the compilation unit containing that function:
   20510 
   20511 @smallexample
   20512 (@value{GDBP}) break dwarf2_psymtab_to_symtab
   20513 Breakpoint 1 at 0x814e5da: file /home/gnu/src/gdb/dwarf2read.c,
   20514 line 1574.
   20515 (@value{GDBP}) maint info symtabs
   20516 @{ objfile /home/gnu/build/gdb/gdb
   20517   ((struct objfile *) 0x82e69d0)
   20518   @{ symtab /home/gnu/src/gdb/dwarf2read.c
   20519     ((struct symtab *) 0x86c1f38)
   20520     dirname (null)
   20521     fullname (null)
   20522     blockvector ((struct blockvector *) 0x86c1bd0) (primary)
   20523     linetable ((struct linetable *) 0x8370fa0)
   20524     debugformat DWARF 2
   20525   @}
   20526 @}
   20527 (@value{GDBP})
   20528 @end smallexample
   20529 
   20530 @kindex maint info line-table
   20531 @cindex listing @value{GDBN}'s internal line tables
   20532 @cindex line tables, listing @value{GDBN}'s internal
   20533 @item maint info line-table @r{[} @var{regexp} @r{]}
   20534 
   20535 List the @code{struct linetable} from all @code{struct symtab}
   20536 instances whose name matches @var{regexp}.  If @var{regexp} is not
   20537 given, list the @code{struct linetable} from all @code{struct symtab}.
   20538 For example:
   20539 
   20540 @smallexample
   20541 (@value{GDBP}) maint info line-table
   20542 objfile: /home/gnu/build/a.out ((struct objfile *) 0x6120000e0d40)
   20543 compunit_symtab: simple.cpp ((struct compunit_symtab *) 0x6210000ff450)
   20544 symtab: /home/gnu/src/simple.cpp ((struct symtab *) 0x6210000ff4d0)
   20545 linetable: ((struct linetable *) 0x62100012b760):
   20546 INDEX  LINE   ADDRESS            IS-STMT PROLOGUE-END EPILOGUE-BEGIN
   20547 0      3      0x0000000000401110 Y
   20548 1      4      0x0000000000401114 Y       Y            Y
   20549 2      9      0x0000000000401120 Y
   20550 3      10     0x0000000000401124 Y       Y
   20551 4      10     0x0000000000401129 Y                    Y
   20552 5      15     0x0000000000401130 Y
   20553 6      16     0x0000000000401134 Y       Y
   20554 7      16     0x0000000000401139
   20555 8      21     0x0000000000401140 Y                    Y
   20556 9      22     0x000000000040114f Y       Y
   20557 10     22     0x0000000000401154                      Y
   20558 11     END    0x000000000040115a Y
   20559 @end smallexample
   20560 @noindent
   20561 The @samp{IS-STMT} column indicates if the address is a recommended breakpoint
   20562 location to represent a line or a statement.  The @samp{PROLOGUE-END} column
   20563 indicates that a given address is an adequate place to set a breakpoint at the
   20564 first instruction following a function prologue.  The @samp{EPILOGUE-BEGIN}
   20565 column indicates that a given address marks the point where a block's frame is
   20566 destroyed, making local variables hard or impossible to find.
   20567 
   20568 @kindex set always-read-ctf [on|off]
   20569 @kindex show always-read-ctf
   20570 @cindex always-read-ctf
   20571 @cindex CTF info, when to read
   20572 @item set always-read-ctf [on|off]
   20573 @itemx show always-read-ctf
   20574 
   20575 When off, CTF debug info is only read if DWARF debug info is not
   20576 present.  When on, CTF debug info is read regardless of whether DWARF
   20577 debug info is present.  The default value is off.
   20578 
   20579 @kindex maint set symbol-cache-size
   20580 @cindex symbol cache size
   20581 @item maint set symbol-cache-size @var{size}
   20582 Set the size of the symbol cache to @var{size}.
   20583 The default size is intended to be good enough for debugging
   20584 most applications.  This option exists to allow for experimenting
   20585 with different sizes.
   20586 
   20587 @kindex maint show symbol-cache-size
   20588 @item maint show symbol-cache-size
   20589 Show the size of the symbol cache.
   20590 
   20591 @kindex maint print symbol-cache
   20592 @cindex symbol cache, printing its contents
   20593 @item maint print symbol-cache
   20594 Print the contents of the symbol cache.
   20595 This is useful when debugging symbol cache issues.
   20596 
   20597 @kindex maint print symbol-cache-statistics
   20598 @cindex symbol cache, printing usage statistics
   20599 @item maint print symbol-cache-statistics
   20600 Print symbol cache usage statistics.
   20601 This helps determine how well the cache is being utilized.
   20602 
   20603 @kindex maint flush symbol-cache
   20604 @kindex maint flush-symbol-cache
   20605 @cindex symbol cache, flushing
   20606 @item maint flush symbol-cache
   20607 @itemx maint flush-symbol-cache
   20608 Flush the contents of the symbol cache, all entries are removed.  This
   20609 command is useful when debugging the symbol cache.  It is also useful
   20610 when collecting performance data.  The command @code{maint
   20611 flush-symbol-cache} is deprecated in favor of @code{maint flush
   20612 symbol-cache}..
   20613 
   20614 @kindex maint set ignore-prologue-end-flag
   20615 @cindex prologue-end
   20616 @item maint set ignore-prologue-end-flag [on|off]
   20617 Enable or disable the use of the @samp{PROLOGUE-END} flag from the line-table.
   20618 When @samp{off} (the default), @value{GDBN} uses the @samp{PROLOGUE-END} flag
   20619 to place breakpoints past the end of a function prologue.  When @samp{on},
   20620 @value{GDBN} ignores the flag and relies on prologue analyzers to skip function
   20621 prologues.
   20622 
   20623 @kindex maint show ignore-prologue-end-flag
   20624 @item maint show ignore-prologue-end-flag
   20625 Show whether @value{GDBN} will ignore the @samp{PROLOGUE-END} flag.
   20626 
   20627 @end table
   20628 
   20629 @node Altering
   20630 @chapter Altering Execution
   20631 
   20632 Once you think you have found an error in your program, you might want to
   20633 find out for certain whether correcting the apparent error would lead to
   20634 correct results in the rest of the run.  You can find the answer by
   20635 experiment, using the @value{GDBN} features for altering execution of the
   20636 program.
   20637 
   20638 For example, you can store new values into variables or memory
   20639 locations, give your program a signal, restart it at a different
   20640 address, or even return prematurely from a function.
   20641 
   20642 @menu
   20643 * Assignment::                  Assignment to variables
   20644 * Jumping::                     Continuing at a different address
   20645 * Signaling::                   Giving your program a signal
   20646 * Returning::                   Returning from a function
   20647 * Calling::                     Calling your program's functions
   20648 * Patching::                    Patching your program
   20649 * Compiling and Injecting Code:: Compiling and injecting code in @value{GDBN}
   20650 @end menu
   20651 
   20652 @node Assignment
   20653 @section Assignment to Variables
   20654 
   20655 @cindex assignment
   20656 @cindex setting variables
   20657 To alter the value of a variable, evaluate an assignment expression.
   20658 @xref{Expressions, ,Expressions}.  For example,
   20659 
   20660 @smallexample
   20661 print x=4
   20662 @end smallexample
   20663 
   20664 @noindent
   20665 stores the value 4 into the variable @code{x}, and then prints the
   20666 value of the assignment expression (which is 4).
   20667 @xref{Languages, ,Using @value{GDBN} with Different Languages}, for more
   20668 information on operators in supported languages.
   20669 
   20670 @kindex set variable
   20671 @cindex variables, setting
   20672 If you are not interested in seeing the value of the assignment, use the
   20673 @code{set} command instead of the @code{print} command.  @code{set} is
   20674 really the same as @code{print} except that the expression's value is
   20675 not printed and is not put in the value history (@pxref{Value History,
   20676 ,Value History}).  The expression is evaluated only for its effects.
   20677 
   20678 If the beginning of the argument string of the @code{set} command
   20679 appears identical to a @code{set} subcommand, use the @code{set
   20680 variable} command instead of just @code{set}.  This command is identical
   20681 to @code{set} except for its lack of subcommands.  For example, if your
   20682 program has a variable @code{width}, you get an error if you try to set
   20683 a new value with just @samp{set width=13}, because @value{GDBN} has the
   20684 command @code{set width}:
   20685 
   20686 @smallexample
   20687 (@value{GDBP}) whatis width
   20688 type = double
   20689 (@value{GDBP}) p width
   20690 $4 = 13
   20691 (@value{GDBP}) set width=47
   20692 Invalid syntax in expression.
   20693 @end smallexample
   20694 
   20695 @noindent
   20696 The invalid expression, of course, is @samp{=47}.  In
   20697 order to actually set the program's variable @code{width}, use
   20698 
   20699 @smallexample
   20700 (@value{GDBP}) set var width=47
   20701 @end smallexample
   20702 
   20703 Because the @code{set} command has many subcommands that can conflict
   20704 with the names of program variables, it is a good idea to use the
   20705 @code{set variable} command instead of just @code{set}.  For example, if
   20706 your program has a variable @code{g}, you run into problems if you try
   20707 to set a new value with just @samp{set g=4}, because @value{GDBN} has
   20708 the command @code{set gnutarget}, abbreviated @code{set g}:
   20709 
   20710 @smallexample
   20711 @group
   20712 (@value{GDBP}) whatis g
   20713 type = double
   20714 (@value{GDBP}) p g
   20715 $1 = 1
   20716 (@value{GDBP}) set g=4
   20717 (@value{GDBP}) p g
   20718 $2 = 1
   20719 (@value{GDBP}) r
   20720 The program being debugged has been started already.
   20721 Start it from the beginning? (y or n) y
   20722 Starting program: /home/smith/cc_progs/a.out
   20723 "/home/smith/cc_progs/a.out": can't open to read symbols:
   20724                                  Invalid bfd target.
   20725 (@value{GDBP}) show g
   20726 The current BFD target is "=4".
   20727 @end group
   20728 @end smallexample
   20729 
   20730 @noindent
   20731 The program variable @code{g} did not change, and you silently set the
   20732 @code{gnutarget} to an invalid value.  In order to set the variable
   20733 @code{g}, use
   20734 
   20735 @smallexample
   20736 (@value{GDBP}) set var g=4
   20737 @end smallexample
   20738 
   20739 @value{GDBN} allows more implicit conversions in assignments than C; you can
   20740 freely store an integer value into a pointer variable or vice versa,
   20741 and you can convert any structure to any other structure that is the
   20742 same length or shorter.
   20743 @comment FIXME: how do structs align/pad in these conversions?
   20744 @comment        /doc (a] cygnus.com 18dec1990
   20745 
   20746 To store values into arbitrary places in memory, use the @samp{@{@dots{}@}}
   20747 construct to generate a value of specified type at a specified address
   20748 (@pxref{Expressions, ,Expressions}).  For example, @code{@{int@}0x83040} refers
   20749 to memory location @code{0x83040} as an integer (which implies a certain size
   20750 and representation in memory), and
   20751 
   20752 @smallexample
   20753 set @{int@}0x83040 = 4
   20754 @end smallexample
   20755 
   20756 @noindent
   20757 stores the value 4 into that memory location.
   20758 
   20759 @node Jumping
   20760 @section Continuing at a Different Address
   20761 
   20762 Ordinarily, when you continue your program, you do so at the place where
   20763 it stopped, with the @code{continue} command.  You can instead continue at
   20764 an address of your own choosing, with the following commands:
   20765 
   20766 @table @code
   20767 @kindex jump
   20768 @kindex j @r{(@code{jump})}
   20769 @item jump @var{locspec}
   20770 @itemx j @var{locspec}
   20771 Resume execution at the address of the code location that results from
   20772 resolving @var{locspec}.
   20773 @xref{Location Specifications}, for a description of the different
   20774 forms of @var{locspec}.  If @var{locspec} resolves to more than one address,
   20775 those outside the current compilation unit are ignored.  If considering just
   20776 the addresses in the current compilation unit still doesn't yield a unique
   20777 address, the command aborts before jumping.
   20778 Execution stops again immediately if there is a breakpoint there.  It
   20779 is common practice to use the @code{tbreak} command in conjunction
   20780 with @code{jump}.  @xref{Set Breaks, ,Setting Breakpoints}.
   20781 
   20782 The @code{jump} command does not change the current stack frame, or
   20783 the stack pointer, or the contents of any memory location or any
   20784 register other than the program counter.  If @var{locspec} resolves to
   20785 an address in a different function from the one currently executing, the
   20786 results may be bizarre if the two functions expect different patterns
   20787 of arguments or of local variables.  For this reason, the @code{jump}
   20788 command requests confirmation if the jump address is not in the
   20789 function currently executing.  However, even bizarre results are
   20790 predictable if you are well acquainted with the machine-language code
   20791 of your program.
   20792 @end table
   20793 
   20794 On many systems, you can get much the same effect as the @code{jump}
   20795 command by storing a new value into the register @code{$pc}.  The
   20796 difference is that this does not start your program running; it only
   20797 changes the address of where it @emph{will} run when you continue.  For
   20798 example,
   20799 
   20800 @smallexample
   20801 set $pc = 0x485
   20802 @end smallexample
   20803 
   20804 @noindent
   20805 makes the next @code{continue} command or stepping command execute at
   20806 address @code{0x485}, rather than at the address where your program stopped.
   20807 @xref{Continuing and Stepping, ,Continuing and Stepping}.
   20808 
   20809 However, writing directly to @code{$pc} will only change the value of
   20810 the program-counter register, while using @code{jump} will ensure that
   20811 any additional auxiliary state is also updated.  For example, on
   20812 SPARC, @code{jump} will update both @code{$pc} and @code{$npc}
   20813 registers prior to resuming execution.  When using the approach of
   20814 writing directly to @code{$pc} it is your job to also update the
   20815 @code{$npc} register.
   20816 
   20817 The most common occasion to use the @code{jump} command is to back
   20818 up---perhaps with more breakpoints set---over a portion of a program
   20819 that has already executed, in order to examine its execution in more
   20820 detail.
   20821 
   20822 @c @group
   20823 @node Signaling
   20824 @section Giving your Program a Signal
   20825 @cindex deliver a signal to a program
   20826 
   20827 @table @code
   20828 @kindex signal
   20829 @item signal @var{signal}
   20830 Resume execution where your program is stopped, but immediately give it the
   20831 signal @var{signal}.  The @var{signal} can be the name or the number of a
   20832 signal.  For example, on many systems @code{signal 2} and @code{signal
   20833 SIGINT} are both ways of sending an interrupt signal.
   20834 
   20835 Alternatively, if @var{signal} is zero, continue execution without
   20836 giving a signal.  This is useful when your program stopped on account of
   20837 a signal and would ordinarily see the signal when resumed with the
   20838 @code{continue} command; @samp{signal 0} causes it to resume without a
   20839 signal.
   20840 
   20841 @emph{Note:} When resuming a multi-threaded program, @var{signal} is
   20842 delivered to the currently selected thread, not the thread that last
   20843 reported a stop.  This includes the situation where a thread was
   20844 stopped due to a signal.  So if you want to continue execution
   20845 suppressing the signal that stopped a thread, you should select that
   20846 same thread before issuing the @samp{signal 0} command.  If you issue
   20847 the @samp{signal 0} command with another thread as the selected one,
   20848 @value{GDBN} detects that and asks for confirmation.
   20849 
   20850 Invoking the @code{signal} command is not the same as invoking the
   20851 @code{kill} utility from the shell.  Sending a signal with @code{kill}
   20852 causes @value{GDBN} to decide what to do with the signal depending on
   20853 the signal handling tables (@pxref{Signals}).  The @code{signal} command
   20854 passes the signal directly to your program.
   20855 
   20856 @code{signal} does not repeat when you press @key{RET} a second time
   20857 after executing the command.
   20858 
   20859 @kindex queue-signal
   20860 @item queue-signal @var{signal}
   20861 Queue @var{signal} to be delivered immediately to the current thread
   20862 when execution of the thread resumes.  The @var{signal} can be the name or
   20863 the number of a signal.  For example, on many systems @code{signal 2} and
   20864 @code{signal SIGINT} are both ways of sending an interrupt signal.
   20865 The handling of the signal must be set to pass the signal to the program,
   20866 otherwise @value{GDBN} will report an error.
   20867 You can control the handling of signals from @value{GDBN} with the
   20868 @code{handle} command (@pxref{Signals}).
   20869 
   20870 Alternatively, if @var{signal} is zero, any currently queued signal
   20871 for the current thread is discarded and when execution resumes no signal
   20872 will be delivered.  This is useful when your program stopped on account
   20873 of a signal and would ordinarily see the signal when resumed with the
   20874 @code{continue} command.
   20875 
   20876 This command differs from the @code{signal} command in that the signal
   20877 is just queued, execution is not resumed.  And @code{queue-signal} cannot
   20878 be used to pass a signal whose handling state has been set to @code{nopass}
   20879 (@pxref{Signals}).
   20880 @end table
   20881 @c @end group
   20882 
   20883 @xref{stepping into signal handlers}, for information on how stepping
   20884 commands behave when the thread has a signal queued.
   20885 
   20886 @node Returning
   20887 @section Returning from a Function
   20888 
   20889 @table @code
   20890 @cindex returning from a function
   20891 @kindex return
   20892 @item return
   20893 @itemx return @var{expression}
   20894 You can cancel execution of a function call with the @code{return}
   20895 command.  If you give an
   20896 @var{expression} argument, its value is used as the function's return
   20897 value.
   20898 @end table
   20899 
   20900 When you use @code{return}, @value{GDBN} discards the selected stack frame
   20901 (and all frames within it).  You can think of this as making the
   20902 discarded frame return prematurely.  If you wish to specify a value to
   20903 be returned, give that value as the argument to @code{return}.
   20904 
   20905 This pops the selected stack frame (@pxref{Selection, ,Selecting a
   20906 Frame}), and any other frames inside of it, leaving its caller as the
   20907 innermost remaining frame.  That frame becomes selected.  The
   20908 specified value is stored in the registers used for returning values
   20909 of functions.
   20910 
   20911 The @code{return} command does not resume execution; it leaves the
   20912 program stopped in the state that would exist if the function had just
   20913 returned.  In contrast, the @code{finish} command (@pxref{Continuing
   20914 and Stepping, ,Continuing and Stepping}) resumes execution until the
   20915 selected stack frame returns naturally.
   20916 
   20917 @value{GDBN} needs to know how the @var{expression} argument should be set for
   20918 the inferior.  The concrete registers assignment depends on the OS ABI and the
   20919 type being returned by the selected stack frame.  For example it is common for
   20920 OS ABI to return floating point values in FPU registers while integer values in
   20921 CPU registers.  Still some ABIs return even floating point values in CPU
   20922 registers.  Larger integer widths (such as @code{long long int}) also have
   20923 specific placement rules.  @value{GDBN} already knows the OS ABI from its
   20924 current target so it needs to find out also the type being returned to make the
   20925 assignment into the right register(s).
   20926 
   20927 Normally, the selected stack frame has debug info.  @value{GDBN} will always
   20928 use the debug info instead of the implicit type of @var{expression} when the
   20929 debug info is available.  For example, if you type @kbd{return -1}, and the
   20930 function in the current stack frame is declared to return a @code{long long
   20931 int}, @value{GDBN} transparently converts the implicit @code{int} value of -1
   20932 into a @code{long long int}:
   20933 
   20934 @smallexample
   20935 Breakpoint 1, func () at gdb.base/return-nodebug.c:29
   20936 29        return 31;
   20937 (@value{GDBP}) return -1
   20938 Make func return now? (y or n) y
   20939 #0  0x004004f6 in main () at gdb.base/return-nodebug.c:43
   20940 43        printf ("result=%lld\n", func ());
   20941 (@value{GDBP})
   20942 @end smallexample
   20943 
   20944 However, if the selected stack frame does not have a debug info, e.g., if the
   20945 function was compiled without debug info, @value{GDBN} has to find out the type
   20946 to return from user.  Specifying a different type by mistake may set the value
   20947 in different inferior registers than the caller code expects.  For example,
   20948 typing @kbd{return -1} with its implicit type @code{int} would set only a part
   20949 of a @code{long long int} result for a debug info less function (on 32-bit
   20950 architectures).  Therefore the user is required to specify the return type by
   20951 an appropriate cast explicitly:
   20952 
   20953 @smallexample
   20954 Breakpoint 2, 0x0040050b in func ()
   20955 (@value{GDBP}) return -1
   20956 Return value type not available for selected stack frame.
   20957 Please use an explicit cast of the value to return.
   20958 (@value{GDBP}) return (long long int) -1
   20959 Make selected stack frame return now? (y or n) y
   20960 #0  0x00400526 in main ()
   20961 (@value{GDBP})
   20962 @end smallexample
   20963 
   20964 @node Calling
   20965 @section Calling Program Functions
   20966 
   20967 @table @code
   20968 @cindex calling functions
   20969 @cindex inferior functions, calling
   20970 @item print @var{expr}
   20971 Evaluate the expression @var{expr} and display the resulting value.
   20972 The expression may include calls to functions in the program being
   20973 debugged.
   20974 
   20975 @kindex call
   20976 @item call @var{expr}
   20977 Evaluate the expression @var{expr} without displaying @code{void}
   20978 returned values.
   20979 
   20980 You can use this variant of the @code{print} command if you want to
   20981 execute a function from your program that does not return anything
   20982 (a.k.a.@: @dfn{a void function}), but without cluttering the output
   20983 with @code{void} returned values that @value{GDBN} will otherwise
   20984 print.  If the result is not void, it is printed and saved in the
   20985 value history.
   20986 @end table
   20987 
   20988 It is possible for the function you call via the @code{print} or
   20989 @code{call} command to generate a signal (e.g., if there's a bug in
   20990 the function, or if you passed it incorrect arguments).  What happens
   20991 in that case is controlled by the @code{set unwind-on-signal} command.
   20992 
   20993 Similarly, with a C@t{++} program it is possible for the function you
   20994 call via the @code{print} or @code{call} command to generate an
   20995 exception that is not handled due to the constraints of the dummy
   20996 frame.  In this case, any exception that is raised in the frame, but has
   20997 an out-of-frame exception handler will not be found.  GDB builds a
   20998 dummy-frame for the inferior function call, and the unwinder cannot
   20999 seek for exception handlers outside of this dummy-frame.  What happens
   21000 in that case is controlled by the
   21001 @code{set unwind-on-terminating-exception} command.
   21002 
   21003 @anchor{stack unwind settings}
   21004 @table @code
   21005 @item set unwind-on-signal
   21006 @kindex set unwind-on-signal
   21007 @kindex set unwindonsignal
   21008 @cindex unwind stack in called functions
   21009 @cindex call dummy stack unwinding
   21010 Set unwinding of the stack if a signal is received while in a function
   21011 that @value{GDBN} called in the program being debugged.  If set to on,
   21012 @value{GDBN} unwinds the stack it created for the call and restores
   21013 the context to what it was before the call.  If set to off (the
   21014 default), @value{GDBN} stops in the frame where the signal was
   21015 received.
   21016 
   21017 The command @code{set unwindonsignal} is an alias for this command,
   21018 and is maintained for backward compatibility.
   21019 
   21020 @item show unwind-on-signal
   21021 @kindex show unwind-on-signal
   21022 @kindex show unwindonsignal
   21023 Show the current setting of stack unwinding in the functions called by
   21024 @value{GDBN}.
   21025 
   21026 The command @code{show unwindonsignal} is an alias for this command,
   21027 and is maintained for backward compatibility.
   21028 
   21029 @item set unwind-on-terminating-exception
   21030 @kindex set unwind-on-terminating-exception
   21031 @cindex unwind stack in called functions with unhandled exceptions
   21032 @cindex call dummy stack unwinding on unhandled exception.
   21033 Set unwinding of the stack if a C@t{++} exception is raised, but left
   21034 unhandled while in a function that @value{GDBN} called in the program being
   21035 debugged.  If set to on (the default), @value{GDBN} unwinds the stack
   21036 it created for the call and restores the context to what it was before
   21037 the call.  If set to off, @value{GDBN} the exception is delivered to
   21038 the default C@t{++} exception handler and the inferior terminated.
   21039 
   21040 @item show unwind-on-terminating-exception
   21041 @kindex show unwind-on-terminating-exception
   21042 Show the current setting of stack unwinding in the functions called by
   21043 @value{GDBN}.
   21044 
   21045 @anchor{set unwind-on-timeout}
   21046 @item set unwind-on-timeout
   21047 @kindex set unwind-on-timeout
   21048 @cindex unwind stack in called functions when timing out
   21049 @cindex call dummy stack unwinding on timeout.
   21050 Set unwinding of the stack if a function called from @value{GDBN}
   21051 times out.  If set to @code{off} (the default), @value{GDBN} stops in
   21052 the frame where the timeout occurred.  If set to @code{on},
   21053 @value{GDBN} unwinds the stack it created for the call and restores
   21054 the context to what it was before the call.
   21055 
   21056 @item show unwind-on-timeout
   21057 @kindex show unwind-on-timeout
   21058 Show whether @value{GDBN} will unwind the stack if a function called
   21059 from @value{GDBN} times out.
   21060 
   21061 @item set may-call-functions
   21062 @kindex set may-call-functions
   21063 @cindex disabling calling functions in the program
   21064 @cindex calling functions in the program, disabling
   21065 Set permission to call functions in the program.
   21066 This controls whether @value{GDBN} will attempt to call functions in
   21067 the program, such as with expressions in the @code{print} command.  It
   21068 defaults to @code{on}.
   21069 
   21070 To call a function in the program, @value{GDBN} has to temporarily
   21071 modify the state of the inferior.  This has potentially undesired side
   21072 effects.  Also, having @value{GDBN} call nested functions is likely to
   21073 be erroneous and may even crash the program being debugged.  You can
   21074 avoid such hazards by forbidding @value{GDBN} from calling functions
   21075 in the program being debugged.  If calling functions in the program
   21076 is forbidden, GDB will throw an error when a command (such as printing
   21077 an expression) starts a function call in the program.
   21078 
   21079 @item show may-call-functions
   21080 @kindex show may-call-functions
   21081 Show permission to call functions in the program.
   21082 
   21083 @end table
   21084 
   21085 When calling a function within a program, it is possible that the
   21086 program could enter a state from which the called function may never
   21087 return.  If this happens then it is possible to interrupt the function
   21088 call by typing the interrupt character (often @kbd{Ctrl-c}).
   21089 
   21090 If a called function is interrupted for any reason, including hitting
   21091 a breakpoint, or triggering a watchpoint, and the stack is not unwound
   21092 due to @code{set unwind-on-terminating-exception on}, @code{set
   21093 unwind-on-timeout on}, or @code{set unwind-on-signal on} (@pxref{stack
   21094 unwind settings}), then the dummy-frame, created by @value{GDBN} to
   21095 facilitate the call to the program function, will be visible in the
   21096 backtrace, for example frame @code{#3} in the following backtrace:
   21097 
   21098 @smallexample
   21099 (@value{GDBP}) backtrace
   21100 #0  0x00007ffff7b3d1e7 in nanosleep () from /lib64/libc.so.6
   21101 #1  0x00007ffff7b3d11e in sleep () from /lib64/libc.so.6
   21102 #2  0x000000000040113f in deadlock () at test.cc:13
   21103 #3  <function called from gdb>
   21104 #4  breakpt () at test.cc:20
   21105 #5  0x0000000000401151 in main () at test.cc:25
   21106 @end smallexample
   21107 
   21108 At this point it is possible to examine the state of the inferior just
   21109 like any other stop.
   21110 
   21111 Depending on why the function was interrupted then it may be possible
   21112 to resume the inferior (using commands like @code{continue},
   21113 @code{step}, etc).  In this case, when the inferior finally returns to
   21114 the dummy-frame, @value{GDBN} will once again halt the inferior.
   21115 
   21116 On targets that support asynchronous execution (@pxref{Background
   21117 Execution}) @value{GDBN} can place a timeout on any functions called
   21118 from @value{GDBN}.  If the timeout expires and the function call is
   21119 still ongoing, then @value{GDBN} will interrupt the program.
   21120 
   21121 If a function called from @value{GDBN} is interrupted by a timeout,
   21122 then by default the inferior is left in the frame where the timeout
   21123 occurred, this behavior can be adjusted with @samp{set
   21124 unwind-on-timeout} (@pxref{set unwind-on-timeout}).
   21125 
   21126 For targets that don't support asynchronous execution
   21127 (@pxref{Background Execution}) then timeouts for functions called from
   21128 @value{GDBN} are not supported, the timeout settings described below
   21129 will be treated as @code{unlimited}, meaning @value{GDBN} will wait
   21130 indefinitely for function call to complete, unless interrupted by the
   21131 user using @kbd{Ctrl-C}.
   21132 
   21133 @table @code
   21134 @item set direct-call-timeout @var{seconds}
   21135 @kindex set direct-call-timeout
   21136 @cindex timeout for called functions
   21137 Set the timeout used when calling functions in the program to
   21138 @var{seconds}, which should be an integer greater than zero, or the
   21139 special value @code{unlimited}, which indicates no timeout should be
   21140 used.  The default for this setting is @code{unlimited}.
   21141 
   21142 This setting is used when the user calls a function directly from the
   21143 command prompt, for example with a @code{call} or @code{print}
   21144 command.
   21145 
   21146 This setting only works for targets that support asynchronous
   21147 execution (@pxref{Background Execution}), for any other target the
   21148 setting is treated as @code{unlimited}.
   21149 
   21150 @item show direct-call-timeout
   21151 @kindex show direct-call-timeout
   21152 @cindex timeout for called functions
   21153 Show the timeout used when calling functions in the program with a
   21154 @code{call} or @code{print} command.
   21155 @end table
   21156 
   21157 It is also possible to call functions within the program from the
   21158 condition of a conditional breakpoint (@pxref{Conditions, ,Break
   21159 Conditions}).  A different setting controls the timeout used for
   21160 function calls made from a breakpoint condition.
   21161 
   21162 @table @code
   21163 @item set indirect-call-timeout @var{seconds}
   21164 @kindex set indirect-call-timeout
   21165 @cindex timeout for called functions
   21166 Set the timeout used when calling functions in the program from a
   21167 breakpoint or watchpoint condition to @var{seconds}, which should be
   21168 an integer greater than zero, or the special value @code{unlimited},
   21169 which indicates no timeout should be used.  The default for this
   21170 setting is @code{30} seconds.
   21171 
   21172 This setting only works for targets that support asynchronous
   21173 execution (@pxref{Background Execution}), for any other target the
   21174 setting is treated as @code{unlimited}.
   21175 
   21176 If a function called from a breakpoint or watchpoint condition times
   21177 out, then @value{GDBN} will stop at the point where the timeout
   21178 occurred.  The breakpoint condition evaluation will be abandoned.
   21179 
   21180 @item show indirect-call-timeout
   21181 @kindex show indirect-call-timeout
   21182 @cindex timeout for called functions
   21183 Show the timeout used when calling functions in the program from a
   21184 breakpoint or watchpoint condition.
   21185 @end table
   21186 
   21187 @subsection Calling functions with no debug info
   21188 
   21189 @cindex no debug info functions
   21190 Sometimes, a function you wish to call is missing debug information.
   21191 In such case, @value{GDBN} does not know the type of the function,
   21192 including the types of the function's parameters.  To avoid calling
   21193 the inferior function incorrectly, which could result in the called
   21194 function functioning erroneously and even crash, @value{GDBN} refuses
   21195 to call the function unless you tell it the type of the function.
   21196 
   21197 For prototyped (i.e.@: ANSI/ISO style) functions, there are two ways
   21198 to do that.  The simplest is to cast the call to the function's
   21199 declared return type.  For example:
   21200 
   21201 @smallexample
   21202 (@value{GDBP}) p getenv ("PATH")
   21203 'getenv' has unknown return type; cast the call to its declared return type
   21204 (@value{GDBP}) p (char *) getenv ("PATH")
   21205 $1 = 0x7fffffffe7ba "/usr/local/bin:/"...
   21206 @end smallexample
   21207 
   21208 Casting the return type of a no-debug function is equivalent to
   21209 casting the function to a pointer to a prototyped function that has a
   21210 prototype that matches the types of the passed-in arguments, and
   21211 calling that.  I.e., the call above is equivalent to:
   21212 
   21213 @smallexample
   21214 (@value{GDBP}) p ((char * (*) (const char *)) getenv) ("PATH")
   21215 @end smallexample
   21216 
   21217 @noindent
   21218 and given this prototyped C or C++ function with float parameters:
   21219 
   21220 @smallexample
   21221 float multiply (float v1, float v2) @{ return v1 * v2; @}
   21222 @end smallexample
   21223 
   21224 @noindent
   21225 these calls are equivalent:
   21226 
   21227 @smallexample
   21228 (@value{GDBP}) p (float) multiply (2.0f, 3.0f)
   21229 (@value{GDBP}) p ((float (*) (float, float)) multiply) (2.0f, 3.0f)
   21230 @end smallexample
   21231 
   21232 If the function you wish to call is declared as unprototyped (i.e.@:
   21233 old K&R style), you must use the cast-to-function-pointer syntax, so
   21234 that @value{GDBN} knows that it needs to apply default argument
   21235 promotions (promote float arguments to double).  @xref{ABI, float
   21236 promotion}.  For example, given this unprototyped C function with
   21237 float parameters, and no debug info:
   21238 
   21239 @smallexample
   21240 float
   21241 multiply_noproto (v1, v2)
   21242   float v1, v2;
   21243 @{
   21244   return v1 * v2;
   21245 @}
   21246 @end smallexample
   21247 
   21248 @noindent
   21249 you call it like this:
   21250 
   21251 @smallexample
   21252   (@value{GDBP}) p ((float (*) ()) multiply_noproto) (2.0f, 3.0f)
   21253 @end smallexample
   21254 
   21255 @node Patching
   21256 @section Patching Programs
   21257 
   21258 @cindex patching binaries
   21259 @cindex writing into executables
   21260 @cindex writing into corefiles
   21261 
   21262 By default, @value{GDBN} opens the file containing your program's
   21263 executable code (or the corefile) read-only.  This prevents accidental
   21264 alterations to machine code; but it also prevents you from intentionally
   21265 patching your program's binary.
   21266 
   21267 If you'd like to be able to patch the binary, you can specify that
   21268 explicitly with the @code{set write} command.  For example, you might
   21269 want to turn on internal debugging flags, or even to make emergency
   21270 repairs.
   21271 
   21272 @table @code
   21273 @kindex set write
   21274 @item set write on
   21275 @itemx set write off
   21276 If you specify @samp{set write on}, @value{GDBN} opens executable and
   21277 core files for both reading and writing; if you specify @kbd{set write
   21278 off} (the default), @value{GDBN} opens them read-only.
   21279 
   21280 If you have already loaded a file, you must load it again (using the
   21281 @code{exec-file} or @code{core-file} command) after changing @code{set
   21282 write}, for your new setting to take effect.
   21283 
   21284 @item show write
   21285 @kindex show write
   21286 Display whether executable files and core files are opened for writing
   21287 as well as reading.
   21288 @end table
   21289 
   21290 @node Compiling and Injecting Code
   21291 @section Compiling and injecting code in @value{GDBN}
   21292 @cindex injecting code
   21293 @cindex writing into executables
   21294 @cindex compiling code
   21295 
   21296 @value{GDBN} supports on-demand compilation and code injection into
   21297 programs running under @value{GDBN}.  GCC 5.0 or higher built with
   21298 @file{libcc1.so} must be installed for this functionality to be enabled.
   21299 This functionality is implemented with the following commands.
   21300 
   21301 @table @code
   21302 @kindex compile code
   21303 @item compile code @var{source-code}
   21304 @itemx compile code -raw @var{--} @var{source-code}
   21305 Compile @var{source-code} with the compiler language found as the current
   21306 language in @value{GDBN} (@pxref{Languages}).  If compilation and
   21307 injection is not supported with the current language specified in
   21308 @value{GDBN}, or the compiler does not support this feature, an error
   21309 message will be printed.  If @var{source-code} compiles and links
   21310 successfully, @value{GDBN} will load the object-code emitted,
   21311 and execute it within the context of the currently selected inferior.
   21312 It is important to note that the compiled code is executed immediately.
   21313 After execution, the compiled code is removed from @value{GDBN} and any
   21314 new types or variables you have defined will be deleted.
   21315 
   21316 The command allows you to specify @var{source-code} in two ways.
   21317 The simplest method is to provide a single line of code to the command.
   21318 E.g.:
   21319 
   21320 @smallexample
   21321 compile code printf ("hello world\n");
   21322 @end smallexample
   21323 
   21324 If you specify options on the command line as well as source code, they
   21325 may conflict.  The @samp{--} delimiter can be used to separate options
   21326 from actual source code.  E.g.:
   21327 
   21328 @smallexample
   21329 compile code -r -- printf ("hello world\n");
   21330 @end smallexample
   21331 
   21332 Alternatively you can enter source code as multiple lines of text.  To
   21333 enter this mode, invoke the @samp{compile code} command without any text
   21334 following the command.  This will start the multiple-line editor and
   21335 allow you to type as many lines of source code as required.  When you
   21336 have completed typing, enter @samp{end} on its own line to exit the
   21337 editor.
   21338 
   21339 @smallexample
   21340 compile code
   21341 >printf ("hello\n");
   21342 >printf ("world\n");
   21343 >end
   21344 @end smallexample
   21345 
   21346 Specifying @samp{-raw}, prohibits @value{GDBN} from wrapping the
   21347 provided @var{source-code} in a callable scope.  In this case, you must
   21348 specify the entry point of the code by defining a function named
   21349 @code{_gdb_expr_}.  The @samp{-raw} code cannot access variables of the
   21350 inferior.  Using @samp{-raw} option may be needed for example when
   21351 @var{source-code} requires @samp{#include} lines which may conflict with
   21352 inferior symbols otherwise.
   21353 
   21354 @kindex compile file
   21355 @item compile file @var{filename}
   21356 @itemx compile file -raw @var{filename}
   21357 Like @code{compile code}, but take the source code from @var{filename}.
   21358 
   21359 @smallexample
   21360 compile file /home/user/example.c
   21361 @end smallexample
   21362 
   21363 The @var{filename} argument supports escaping and quoting, see
   21364 @ref{Filename Arguments,,Filenames As Command Arguments}.
   21365 @end table
   21366 
   21367 @table @code
   21368 @item compile print [[@var{options}] --] @var{expr}
   21369 @itemx compile print [[@var{options}] --] /@var{f} @var{expr}
   21370 Compile and execute @var{expr} with the compiler language found as the
   21371 current language in @value{GDBN} (@pxref{Languages}).  By default the
   21372 value of @var{expr} is printed in a format appropriate to its data type;
   21373 you can choose a different format by specifying @samp{/@var{f}}, where
   21374 @var{f} is a letter specifying the format; see @ref{Output Formats,,Output
   21375 Formats}.  The @code{compile print} command accepts the same options
   21376 as the @code{print} command; see @ref{print options}.
   21377 
   21378 @item compile print [[@var{options}] --]
   21379 @itemx compile print [[@var{options}] --] /@var{f}
   21380 @cindex reprint the last value
   21381 Alternatively you can enter the expression (source code producing it) as
   21382 multiple lines of text.  To enter this mode, invoke the @samp{compile print}
   21383 command without any text following the command.  This will start the
   21384 multiple-line editor.
   21385 @end table
   21386 
   21387 @noindent
   21388 The process of compiling and injecting the code can be inspected using:
   21389 
   21390 @table @code
   21391 @anchor{set debug compile}
   21392 @item set debug compile
   21393 @cindex compile command debugging info
   21394 Turns on or off display of @value{GDBN} process of compiling and
   21395 injecting the code.  The default is off.
   21396 
   21397 @item show debug compile
   21398 Displays the current state of displaying @value{GDBN} process of
   21399 compiling and injecting the code.
   21400 
   21401 @anchor{set debug compile-cplus-types}
   21402 @item set debug compile-cplus-types
   21403 @cindex compile C@t{++} type conversion
   21404 Turns on or off the display of C@t{++} type conversion debugging information.
   21405 The default is off.
   21406 
   21407 @item show debug compile-cplus-types
   21408 Displays the current state of displaying debugging information for
   21409 C@t{++} type conversion.
   21410 @end table
   21411 
   21412 @subsection Compilation options for the @code{compile} command
   21413 
   21414 @value{GDBN} needs to specify the right compilation options for the code
   21415 to be injected, in part to make its ABI compatible with the inferior
   21416 and in part to make the injected code compatible with @value{GDBN}'s
   21417 injecting process.
   21418 
   21419 @noindent
   21420 The options used, in increasing precedence:
   21421 
   21422 @table @asis
   21423 @item target architecture and OS options (@code{gdbarch})
   21424 These options depend on target processor type and target operating
   21425 system, usually they specify at least 32-bit (@code{-m32}) or 64-bit
   21426 (@code{-m64}) compilation option.
   21427 
   21428 @item compilation options recorded in the target
   21429 @value{NGCC} (since version 4.7) stores the options used for compilation
   21430 into @code{DW_AT_producer} part of DWARF debugging information according
   21431 to the @value{NGCC} option @code{-grecord-gcc-switches}.  One has to
   21432 explicitly specify @code{-g} during inferior compilation otherwise
   21433 @value{NGCC} produces no DWARF.  This feature is only relevant for
   21434 platforms where @code{-g} produces DWARF by default, otherwise one may
   21435 try to enforce DWARF by using @code{-gdwarf-4}.
   21436 
   21437 @item compilation options set by @code{set compile-args}
   21438 @end table
   21439 
   21440 @noindent
   21441 You can override compilation options using the following command:
   21442 
   21443 @table @code
   21444 @item set compile-args
   21445 @cindex compile command options override
   21446 Set compilation options used for compiling and injecting code with the
   21447 @code{compile} commands.  These options override any conflicting ones
   21448 from the target architecture and/or options stored during inferior
   21449 compilation.
   21450 
   21451 @item show compile-args
   21452 Displays the current state of compilation options override.
   21453 This does not show all the options actually used during compilation,
   21454 use @ref{set debug compile} for that.
   21455 @end table
   21456 
   21457 @subsection Caveats when using the @code{compile} command
   21458 
   21459 There are a few caveats to keep in mind when using the @code{compile}
   21460 command.  As the caveats are different per language, the table below
   21461 highlights specific issues on a per language basis.
   21462 
   21463 @table @asis
   21464 @item C code examples and caveats
   21465 When the language in @value{GDBN} is set to @samp{C}, the compiler will
   21466 attempt to compile the source code with a @samp{C} compiler.  The source
   21467 code provided to the @code{compile} command will have much the same
   21468 access to variables and types as it normally would if it were part of
   21469 the program currently being debugged in @value{GDBN}.
   21470 
   21471 Below is a sample program that forms the basis of the examples that
   21472 follow.  This program has been compiled and loaded into @value{GDBN},
   21473 much like any other normal debugging session.
   21474 
   21475 @smallexample
   21476 void function1 (void)
   21477 @{
   21478    int i = 42;
   21479    printf ("function 1\n");
   21480 @}
   21481 
   21482 void function2 (void)
   21483 @{
   21484    int j = 12;
   21485    function1 ();
   21486 @}
   21487 
   21488 int main(void)
   21489 @{
   21490    int k = 6;
   21491    int *p;
   21492    function2 ();
   21493    return 0;
   21494 @}
   21495 @end smallexample
   21496 
   21497 For the purposes of the examples in this section, the program above has
   21498 been compiled, loaded into @value{GDBN}, stopped at the function
   21499 @code{main}, and @value{GDBN} is awaiting input from the user.
   21500 
   21501 To access variables and types for any program in @value{GDBN}, the
   21502 program must be compiled and packaged with debug information.  The
   21503 @code{compile} command is not an exception to this rule.  Without debug
   21504 information, you can still use the @code{compile} command, but you will
   21505 be very limited in what variables and types you can access.
   21506 
   21507 So with that in mind, the example above has been compiled with debug
   21508 information enabled.  The @code{compile} command will have access to
   21509 all variables and types (except those that may have been optimized
   21510 out).  Currently, as @value{GDBN} has stopped the program in the
   21511 @code{main} function, the @code{compile} command would have access to
   21512 the variable @code{k}.  You could invoke the @code{compile} command
   21513 and type some source code to set the value of @code{k}.  You can also
   21514 read it, or do anything with that variable you would normally do in
   21515 @code{C}.  Be aware that changes to inferior variables in the
   21516 @code{compile} command are persistent.  In the following example:
   21517 
   21518 @smallexample
   21519 compile code k = 3;
   21520 @end smallexample
   21521 
   21522 @noindent
   21523 the variable @code{k} is now 3.  It will retain that value until
   21524 something else in the example program changes it, or another
   21525 @code{compile} command changes it.
   21526 
   21527 Normal scope and access rules apply to source code compiled and
   21528 injected by the @code{compile} command.  In the example, the variables
   21529 @code{j} and @code{k} are not accessible yet, because the program is
   21530 currently stopped in the @code{main} function, where these variables
   21531 are not in scope.  Therefore, the following command
   21532 
   21533 @smallexample
   21534 compile code j = 3;
   21535 @end smallexample
   21536 
   21537 @noindent
   21538 will result in a compilation error message.
   21539 
   21540 Once the program is continued, execution will bring these variables in
   21541 scope, and they will become accessible; then the code you specify via
   21542 the @code{compile} command will be able to access them.
   21543 
   21544 You can create variables and types with the @code{compile} command as
   21545 part of your source code.  Variables and types that are created as part
   21546 of the @code{compile} command are not visible to the rest of the program for
   21547 the duration of its run.  This example is valid:
   21548 
   21549 @smallexample
   21550 compile code int ff = 5; printf ("ff is %d\n", ff);
   21551 @end smallexample
   21552 
   21553 However, if you were to type the following into @value{GDBN} after that
   21554 command has completed:
   21555 
   21556 @smallexample
   21557 compile code printf ("ff is %d\n'', ff);
   21558 @end smallexample
   21559 
   21560 @noindent
   21561 a compiler error would be raised as the variable @code{ff} no longer
   21562 exists.  Object code generated and injected by the @code{compile}
   21563 command is removed when its execution ends.  Caution is advised
   21564 when assigning to program variables values of variables created by the
   21565 code submitted to the @code{compile} command.  This example is valid:
   21566 
   21567 @smallexample
   21568 compile code int ff = 5; k = ff;
   21569 @end smallexample
   21570 
   21571 The value of the variable @code{ff} is assigned to @code{k}.  The variable
   21572 @code{k} does not require the existence of @code{ff} to maintain the value
   21573 it has been assigned.  However, pointers require particular care in
   21574 assignment.  If the source code compiled with the @code{compile} command
   21575 changed the address of a pointer in the example program, perhaps to a
   21576 variable created in the @code{compile} command, that pointer would point
   21577 to an invalid location when the command exits.  The following example
   21578 would likely cause issues with your debugged program:
   21579 
   21580 @smallexample
   21581 compile code int ff = 5; p = &ff;
   21582 @end smallexample
   21583 
   21584 In this example, @code{p} would point to @code{ff} when the
   21585 @code{compile} command is executing the source code provided to it.
   21586 However, as variables in the (example) program persist with their
   21587 assigned values, the variable @code{p} would point to an invalid
   21588 location when the command exists.  A general rule should be followed
   21589 in that you should either assign @code{NULL} to any assigned pointers,
   21590 or restore a valid location to the pointer before the command exits.
   21591 
   21592 Similar caution must be exercised with any structs, unions, and typedefs
   21593 defined in @code{compile} command.  Types defined in the @code{compile}
   21594 command will no longer be available in the next @code{compile} command.
   21595 Therefore, if you cast a variable to a type defined in the
   21596 @code{compile} command, care must be taken to ensure that any future
   21597 need to resolve the type can be achieved.
   21598 
   21599 @smallexample
   21600 (@value{GDBP}) compile code static struct a @{ int a; @} v = @{ 42 @}; argv = &v;
   21601 (@value{GDBP}) compile code printf ("%d\n", ((struct a *) argv)->a);
   21602 gdb command line:1:36: error: dereferencing pointer to incomplete type struct a
   21603 Compilation failed.
   21604 (@value{GDBP}) compile code struct a @{ int a; @}; printf ("%d\n", ((struct a *) argv)->a);
   21605 42
   21606 @end smallexample
   21607 
   21608 Variables that have been optimized away by the compiler are not
   21609 accessible to the code submitted to the @code{compile} command.
   21610 Access to those variables will generate a compiler error which @value{GDBN}
   21611 will print to the console.
   21612 @end table
   21613 
   21614 @subsection Compiler search for the @code{compile} command
   21615 
   21616 @value{GDBN} needs to find @value{NGCC} for the inferior being debugged
   21617 which may not be obvious for remote targets of different architecture
   21618 than where @value{GDBN} is running.  Environment variable @env{PATH} on
   21619 @value{GDBN} host is searched for @value{NGCC} binary matching the
   21620 target architecture and operating system.  This search can be overridden
   21621 by @code{set compile-gcc} @value{GDBN} command below.  @env{PATH} is
   21622 taken from shell that executed @value{GDBN}, it is not the value set by
   21623 @value{GDBN} command @code{set environment}).  @xref{Environment}.
   21624 
   21625 
   21626 Specifically @env{PATH} is searched for binaries matching regular expression
   21627 @code{@var{arch}(-[^-]*)?-@var{os}-gcc} according to the inferior target being
   21628 debugged.  @var{arch} is processor name --- multiarch is supported, so for
   21629 example both @code{i386} and @code{x86_64} targets look for pattern
   21630 @code{(x86_64|i.86)} and both @code{s390} and @code{s390x} targets look
   21631 for pattern @code{s390x?}.  @var{os} is currently supported only for
   21632 pattern @code{linux(-gnu)?}.
   21633 
   21634 On Posix hosts the compiler driver @value{GDBN} needs to find also
   21635 shared library @file{libcc1.so} from the compiler.  It is searched in
   21636 default shared library search path (overridable with usual environment
   21637 variable @env{LD_LIBRARY_PATH}), unrelated to @env{PATH} or @code{set
   21638 compile-gcc} settings.  Contrary to it @file{libcc1plugin.so} is found
   21639 according to the installation of the found compiler --- as possibly
   21640 specified by the @code{set compile-gcc} command.
   21641 
   21642 @table @code
   21643 @item set compile-gcc
   21644 @cindex compile command driver filename override
   21645 Set compilation command used for compiling and injecting code with the
   21646 @code{compile} commands.  If this option is not set (it is set to
   21647 an empty string), the search described above will occur --- that is the
   21648 default.
   21649 
   21650 @item show compile-gcc
   21651 Displays the current compile command @value{NGCC} driver filename.
   21652 If set, it is the main command @command{gcc}, found usually for example
   21653 under name @file{x86_64-linux-gnu-gcc}.
   21654 @end table
   21655 
   21656 @node GDB Files
   21657 @chapter @value{GDBN} Files
   21658 
   21659 @value{GDBN} needs to know the file name of the program to be debugged,
   21660 both in order to read its symbol table and in order to start your
   21661 program.  To debug a core dump of a previous run, you must also tell
   21662 @value{GDBN} the name of the core dump file.
   21663 
   21664 @menu
   21665 * Files::                       Commands to specify files
   21666 * File Caching::                Information about @value{GDBN}'s file caching
   21667 * Separate Debug Files::        Debugging information in separate files
   21668 * MiniDebugInfo::               Debugging information in a special section
   21669 * Index Files::                 Index files speed up GDB
   21670 * Debug Names::                 Extensions to .debug_names
   21671 * Symbol Errors::               Errors reading symbol files
   21672 * Data Files::                  GDB data files
   21673 @end menu
   21674 
   21675 @node Files
   21676 @section Commands to Specify Files
   21677 
   21678 @cindex symbol table
   21679 @cindex core dump file
   21680 
   21681 You may want to specify executable and core dump file names.  The usual
   21682 way to do this is at start-up time, using the arguments to
   21683 @value{GDBN}'s start-up commands (@pxref{Invocation, , Getting In and
   21684 Out of @value{GDBN}}).
   21685 
   21686 Occasionally it is necessary to change to a different file during a
   21687 @value{GDBN} session.  Or you may run @value{GDBN} and forget to
   21688 specify a file you want to use.  Or you are debugging a remote target
   21689 via @code{gdbserver} (@pxref{Server, file, Using the @code{gdbserver}
   21690 Program}).  In these situations the @value{GDBN} commands to specify
   21691 new files are useful.
   21692 
   21693 @table @code
   21694 @cindex executable file
   21695 @kindex file
   21696 @item file @var{filename}
   21697 Use @var{filename} as the program to be debugged.  It is read for its
   21698 symbols and for the contents of pure memory.  It is also the program
   21699 executed when you use the @code{run} command.  If you do not specify a
   21700 directory and the file is not found in the @value{GDBN} working directory,
   21701 @value{GDBN} uses the environment variable @env{PATH} as a list of
   21702 directories to search, just as the shell does when looking for a program
   21703 to run.  You can change the value of this variable, for both @value{GDBN}
   21704 and your program, using the @code{path} command.
   21705 
   21706 The @var{filename} argument supports escaping and quoting, see
   21707 @ref{Filename Arguments,,Filenames As Command Arguments}.
   21708 
   21709 @cindex unlinked object files
   21710 @cindex patching object files
   21711 You can load unlinked object @file{.o} files into @value{GDBN} using
   21712 the @code{file} command.  You will not be able to ``run'' an object
   21713 file, but you can disassemble functions and inspect variables.  Also,
   21714 if the underlying BFD functionality supports it, you could use
   21715 @kbd{gdb -write} to patch object files using this technique.  Note
   21716 that @value{GDBN} can neither interpret nor modify relocations in this
   21717 case, so branches and some initialized variables will appear to go to
   21718 the wrong place.  But this feature is still handy from time to time.
   21719 
   21720 @item file
   21721 @code{file} with no argument makes @value{GDBN} discard any information it
   21722 has on both executable file and the symbol table.
   21723 
   21724 @kindex exec-file
   21725 @item exec-file @r{[} @var{filename} @r{]}
   21726 Specify that the program to be run (but not the symbol table) is found
   21727 in @var{filename}.  @value{GDBN} searches the environment variable @env{PATH}
   21728 if necessary to locate your program.  Omitting @var{filename} means to
   21729 discard information on the executable file.
   21730 
   21731 The @var{filename} argument supports escaping and quoting, see
   21732 @ref{Filename Arguments,,Filenames As Command Arguments}.
   21733 
   21734 @kindex symbol-file
   21735 @item symbol-file @r{[} @var{filename} @r{[} -o @var{offset} @r{]]}
   21736 Read symbol table information from file @var{filename}.  @env{PATH} is
   21737 searched when necessary.  Use the @code{file} command to get both symbol
   21738 table and program to run from the same file.
   21739 
   21740 If an optional @var{offset} is specified, it is added to the start
   21741 address of each section in the symbol file.  This is useful if the
   21742 program is relocated at runtime, such as the Linux kernel with kASLR
   21743 enabled.
   21744 
   21745 @code{symbol-file} with no argument clears out @value{GDBN} information on your
   21746 program's symbol table.
   21747 
   21748 The @code{symbol-file} command causes @value{GDBN} to forget the contents of
   21749 some breakpoints and auto-display expressions.  This is because they may
   21750 contain pointers to the internal data recording symbols and data types,
   21751 which are part of the old symbol table data being discarded inside
   21752 @value{GDBN}.
   21753 
   21754 @code{symbol-file} does not repeat if you press @key{RET} again after
   21755 executing it once.
   21756 
   21757 The @var{filename} argument supports escaping and quoting, see
   21758 @ref{Filename Arguments,,Filenames As Command Arguments}.
   21759 
   21760 When @value{GDBN} is configured for a particular environment, it
   21761 understands debugging information in whatever format is the standard
   21762 generated for that environment; you may use either a @sc{gnu} compiler, or
   21763 other compilers that adhere to the local conventions.
   21764 Best results are usually obtained from @sc{gnu} compilers; for example,
   21765 using @code{@value{NGCC}} you can generate debugging information for
   21766 optimized code.
   21767 
   21768 For most kinds of object files, with the exception of old SVR3 systems
   21769 using COFF, the @code{symbol-file} command does not normally read the
   21770 symbol table in full right away.  Instead, it scans the symbol table
   21771 quickly to find which source files and which symbols are present.  The
   21772 details are read later, one source file at a time, as they are needed.
   21773 
   21774 The purpose of this two-stage reading strategy is to make @value{GDBN}
   21775 start up faster.  For the most part, it is invisible except for
   21776 occasional pauses while the symbol table details for a particular source
   21777 file are being read.  (The @code{set verbose} command can turn these
   21778 pauses into messages if desired.  @xref{Messages/Warnings, ,Optional
   21779 Warnings and Messages}.)
   21780 
   21781 We have not implemented the two-stage strategy for COFF yet.  When the
   21782 symbol table is stored in COFF format, @code{symbol-file} reads the
   21783 symbol table data in full right away.  Note that ``stabs-in-COFF''
   21784 still does the two-stage strategy, since the debug info is actually
   21785 in stabs format.
   21786 
   21787 @kindex readnow
   21788 @cindex reading symbols immediately
   21789 @cindex symbols, reading immediately
   21790 @item symbol-file @r{[} -readnow @r{]} @var{filename}
   21791 @itemx file @r{[} -readnow @r{]} @var{filename}
   21792 You can override the @value{GDBN} two-stage strategy for reading symbol
   21793 tables by using the @samp{-readnow} option with any of the commands that
   21794 load symbol table information, if you want to be sure @value{GDBN} has the
   21795 entire symbol table available.
   21796 
   21797 @cindex @code{-readnever}, option for symbol-file command
   21798 @cindex never read symbols
   21799 @cindex symbols, never read
   21800 @item symbol-file @r{[} -readnever @r{]} @var{filename}
   21801 @itemx file @r{[} -readnever @r{]} @var{filename}
   21802 You can instruct @value{GDBN} to never read the symbolic information
   21803 contained in @var{filename} by using the @samp{-readnever} option.
   21804 @xref{--readnever}.
   21805 
   21806 @c FIXME: for now no mention of directories, since this seems to be in
   21807 @c flux.  13mar1992 status is that in theory GDB would look either in
   21808 @c current dir or in same dir as myprog; but issues like competing
   21809 @c GDB's, or clutter in system dirs, mean that in practice right now
   21810 @c only current dir is used.  FFish says maybe a special GDB hierarchy
   21811 @c (eg rooted in val of env var GDBSYMS) could exist for mappable symbol
   21812 @c files.
   21813 
   21814 @anchor{core-file command}
   21815 @kindex core-file
   21816 @item core-file @r{[}@var{filename}@r{]}
   21817 @itemx core
   21818 Specify the whereabouts of a core dump file to be used as the ``contents
   21819 of memory''.  Traditionally, core files contain only some parts of the
   21820 address space of the process that generated them; @value{GDBN} can access the
   21821 executable file itself for other parts.
   21822 
   21823 @code{core-file} with no argument specifies that no core file is
   21824 to be used.
   21825 
   21826 Note that the core file is ignored when your program is actually running
   21827 under @value{GDBN}.  So, if you have been running your program and you
   21828 wish to debug a core file instead, you must kill the subprocess in which
   21829 the program is running.  To do this, use the @code{kill} command
   21830 (@pxref{Kill Process, ,Killing the Child Process}).
   21831 
   21832 @kindex add-symbol-file
   21833 @cindex dynamic linking
   21834 @item add-symbol-file @var{filename} @r{[} -readnow @r{|} -readnever @r{]} @r{[} -o @var{offset} @r{]} @r{[} @var{textaddress} @r{]} @r{[} -s @var{section} @var{address} @dots{} @r{]}
   21835 The @code{add-symbol-file} command reads additional symbol table
   21836 information from the file @var{filename}.  You would use this command
   21837 when @var{filename} has been dynamically loaded (by some other means)
   21838 into the program that is running.  The @var{textaddress} parameter gives
   21839 the memory address at which the file's text section has been loaded.
   21840 You can additionally specify the base address of other sections using
   21841 an arbitrary number of @samp{-s @var{section} @var{address}} pairs.
   21842 If a section is omitted, @value{GDBN} will use its default addresses
   21843 as found in @var{filename}.  Any @var{address} or @var{textaddress}
   21844 can be given as an expression.
   21845 
   21846 If an optional @var{offset} is specified, it is added to the start
   21847 address of each section, except those for which the address was
   21848 specified explicitly.
   21849 
   21850 The symbol table of the file @var{filename} is added to the symbol table
   21851 originally read with the @code{symbol-file} command.  You can use the
   21852 @code{add-symbol-file} command any number of times; the new symbol data
   21853 thus read is kept in addition to the old.
   21854 
   21855 The @var{filename} argument supports escaping and quoting, see
   21856 @ref{Filename Arguments,,Filenames As Command Arguments}.
   21857 
   21858 Changes can be reverted using the command @code{remove-symbol-file}.
   21859 
   21860 @cindex relocatable object files, reading symbols from
   21861 @cindex object files, relocatable, reading symbols from
   21862 @cindex reading symbols from relocatable object files
   21863 @cindex symbols, reading from relocatable object files
   21864 @cindex @file{.o} files, reading symbols from
   21865 Although @var{filename} is typically a shared library file, an
   21866 executable file, or some other object file which has been fully
   21867 relocated for loading into a process, you can also load symbolic
   21868 information from relocatable @file{.o} files, as long as:
   21869 
   21870 @itemize @bullet
   21871 @item
   21872 the file's symbolic information refers only to linker symbols defined in
   21873 that file, not to symbols defined by other object files,
   21874 @item
   21875 every section the file's symbolic information refers to has actually
   21876 been loaded into the inferior, as it appears in the file, and
   21877 @item
   21878 you can determine the address at which every section was loaded, and
   21879 provide these to the @code{add-symbol-file} command.
   21880 @end itemize
   21881 
   21882 @noindent
   21883 Some embedded operating systems, like Sun Chorus and VxWorks, can load
   21884 relocatable files into an already running program; such systems
   21885 typically make the requirements above easy to meet.  However, it's
   21886 important to recognize that many native systems use complex link
   21887 procedures (@code{.linkonce} section factoring and C@t{++} constructor table
   21888 assembly, for example) that make the requirements difficult to meet.  In
   21889 general, one cannot assume that using @code{add-symbol-file} to read a
   21890 relocatable object file's symbolic information will have the same effect
   21891 as linking the relocatable object file into the program in the normal
   21892 way.
   21893 
   21894 @code{add-symbol-file} does not repeat if you press @key{RET} after using it.
   21895 
   21896 @kindex remove-symbol-file
   21897 @item remove-symbol-file @var{filename}
   21898 @item remove-symbol-file -a @var{address}
   21899 Remove a symbol file added via the @code{add-symbol-file} command.  The
   21900 file to remove can be identified by its @var{filename} or by an @var{address}
   21901 that lies within the boundaries of this symbol file in memory.  Example:
   21902 
   21903 @smallexample
   21904 (@value{GDBP}) add-symbol-file /home/user/gdb/mylib.so 0x7ffff7ff9480
   21905 add symbol table from file "/home/user/gdb/mylib.so" at
   21906     .text_addr = 0x7ffff7ff9480
   21907 (y or n) y
   21908 Reading symbols from /home/user/gdb/mylib.so...
   21909 (@value{GDBP}) remove-symbol-file -a 0x7ffff7ff9480
   21910 Remove symbol table from file "/home/user/gdb/mylib.so"? (y or n) y
   21911 (@value{GDBP})
   21912 @end smallexample
   21913 
   21914 The @var{address} can be any expression which evaluates to an address.
   21915 
   21916 @code{remove-symbol-file} does not repeat if you press @key{RET} after using it.
   21917 
   21918 The @var{filename} argument supports escaping and quoting, see
   21919 @ref{Filename Arguments,,Filenames As Command Arguments}.
   21920 
   21921 @kindex add-symbol-file-from-memory
   21922 @cindex @code{syscall DSO}
   21923 @cindex load symbols from memory
   21924 @item add-symbol-file-from-memory @var{address}
   21925 Load symbols from the given @var{address} in a dynamically loaded
   21926 object file whose image is mapped directly into the inferior's memory.
   21927 For example, the Linux kernel maps a @code{syscall DSO} into each
   21928 process's address space; this DSO provides kernel-specific code for
   21929 some system calls.  The argument can be any expression whose
   21930 evaluation yields the address of the file's shared object file header.
   21931 For this command to work, you must have used @code{symbol-file} or
   21932 @code{exec-file} commands in advance.
   21933 
   21934 @kindex section
   21935 @item section @var{section} @var{addr}
   21936 The @code{section} command changes the base address of the named
   21937 @var{section} of the exec file to @var{addr}.  This can be used if the
   21938 exec file does not contain section addresses, (such as in the
   21939 @code{a.out} format), or when the addresses specified in the file
   21940 itself are wrong.  Each section must be changed separately.  The
   21941 @code{info files} command, described below, lists all the sections and
   21942 their addresses.
   21943 
   21944 @kindex info files
   21945 @kindex info target
   21946 @item info files
   21947 @itemx info target
   21948 @code{info files} and @code{info target} are synonymous; both print the
   21949 current target (@pxref{Targets, ,Specifying a Debugging Target}),
   21950 including the names of the executable and core dump files currently in
   21951 use by @value{GDBN}, and the files from which symbols were loaded.  The
   21952 command @code{help target} lists all possible targets rather than
   21953 current ones.
   21954 
   21955 @kindex maint info sections
   21956 @item maint info sections @r{[}-all-objects@r{]} @r{[}@var{filter-list}@r{]}
   21957 Another command that can give you extra information about program sections
   21958 is @code{maint info sections}.  In addition to the section information
   21959 displayed by @code{info files}, this command displays the flags and file
   21960 offset of each section in the executable and core dump files.
   21961 
   21962 When @samp{-all-objects} is passed then sections from all loaded object
   21963 files, including shared libraries, are printed.
   21964 
   21965 The optional @var{filter-list} is a space separated list of filter
   21966 keywords.  Sections that match any one of the filter criteria will be
   21967 printed.  There are two types of filter:
   21968 
   21969 @table @code
   21970 @item @var{section-name}
   21971 Display information about any section named @var{section-name}.
   21972 @item @var{section-flag}
   21973 Display information for any section with @var{section-flag}.  The
   21974 section flags that @value{GDBN} currently knows about are:
   21975 @table @code
   21976 @item ALLOC
   21977 Section will have space allocated in the process when loaded.
   21978 Set for all sections except those containing debug information.
   21979 @item LOAD
   21980 Section will be loaded from the file into the child process memory.
   21981 Set for pre-initialized code and data, clear for @code{.bss} sections.
   21982 @item RELOC
   21983 Section needs to be relocated before loading.
   21984 @item READONLY
   21985 Section cannot be modified by the child process.
   21986 @item CODE
   21987 Section contains executable code only.
   21988 @item DATA
   21989 Section contains data only (no executable code).
   21990 @item ROM
   21991 Section will reside in ROM.
   21992 @item CONSTRUCTOR
   21993 Section contains data for constructor/destructor lists.
   21994 @item HAS_CONTENTS
   21995 Section is not empty.
   21996 @item NEVER_LOAD
   21997 An instruction to the linker to not output the section.
   21998 @item COFF_SHARED_LIBRARY
   21999 A notification to the linker that the section contains
   22000 COFF shared library information.
   22001 @item IS_COMMON
   22002 Section contains common symbols.
   22003 @end table
   22004 @end table
   22005 
   22006 @kindex maint info target-sections
   22007 @item maint info target-sections
   22008 This command prints @value{GDBN}'s internal section table.  For each
   22009 target @value{GDBN} maintains a table containing the allocatable
   22010 sections from all currently mapped objects, along with information
   22011 about where the section is mapped.
   22012 
   22013 @kindex set trust-readonly-sections
   22014 @cindex read-only sections
   22015 @item set trust-readonly-sections on
   22016 Tell @value{GDBN} that readonly sections in your object file
   22017 really are read-only (i.e.@: that their contents will not change).
   22018 In that case, @value{GDBN} can fetch values from these sections
   22019 out of the object file, rather than from the target program.
   22020 For some targets (notably embedded ones), this can be a significant
   22021 enhancement to debugging performance.
   22022 
   22023 The default is off.
   22024 
   22025 @item set trust-readonly-sections off
   22026 Tell @value{GDBN} not to trust readonly sections.  This means that
   22027 the contents of the section might change while the program is running,
   22028 and must therefore be fetched from the target when needed.
   22029 
   22030 @item show trust-readonly-sections
   22031 Show the current setting of trusting readonly sections.
   22032 @end table
   22033 
   22034 All file-specifying commands allow both absolute and relative file names
   22035 as arguments.  @value{GDBN} always converts the file name to an absolute file
   22036 name and remembers it that way.
   22037 
   22038 @cindex shared libraries
   22039 @anchor{Shared Libraries}
   22040 @value{GDBN} supports @sc{gnu}/Linux, MS-Windows, SunOS,
   22041 Darwin/Mach-O, SVr4, IBM RS/6000 AIX, FDPIC (FR-V), and
   22042 DSBT (TIC6X) shared libraries.
   22043 
   22044 On MS-Windows @value{GDBN} must be linked with the Expat library to support
   22045 shared libraries.  @xref{Expat}.
   22046 
   22047 @value{GDBN} automatically loads symbol definitions from shared libraries
   22048 when you use the @code{run} command, or when you examine a core file.
   22049 (Before you issue the @code{run} command, @value{GDBN} does not understand
   22050 references to a function in a shared library, however---unless you are
   22051 debugging a core file).
   22052 
   22053 @c FIXME: some @value{GDBN} release may permit some refs to undef
   22054 @c FIXME...symbols---eg in a break cmd---assuming they are from a shared
   22055 @c FIXME...lib; check this from time to time when updating manual
   22056 
   22057 There are times, however, when you may wish to not automatically load
   22058 symbol definitions from shared libraries, such as when they are
   22059 particularly large or there are many of them.
   22060 
   22061 To control the automatic loading of shared library symbols, use the
   22062 commands:
   22063 
   22064 @table @code
   22065 @kindex set auto-solib-add
   22066 @item set auto-solib-add @var{mode}
   22067 If @var{mode} is @code{on}, symbols from all shared object libraries
   22068 will be loaded automatically when the inferior begins execution, you
   22069 attach to an independently started inferior, or when the dynamic linker
   22070 informs @value{GDBN} that a new library has been loaded.  If @var{mode}
   22071 is @code{off}, symbols must be loaded manually, using the
   22072 @code{sharedlibrary} command.  The default value is @code{on}.
   22073 
   22074 @cindex memory used for symbol tables
   22075 If your program uses lots of shared libraries with debug info that
   22076 takes large amounts of memory, you can decrease the @value{GDBN}
   22077 memory footprint by preventing it from automatically loading the
   22078 symbols from shared libraries.  To that end, type @kbd{set
   22079 auto-solib-add off} before running the inferior, then load each
   22080 library whose debug symbols you do need with @kbd{sharedlibrary
   22081 @var{regexp}}, where @var{regexp} is a regular expression that matches
   22082 the libraries whose symbols you want to be loaded.
   22083 
   22084 @kindex show auto-solib-add
   22085 @item show auto-solib-add
   22086 Display the current autoloading mode.
   22087 @end table
   22088 
   22089 @cindex load shared library
   22090 To explicitly load shared library symbols, use the @code{sharedlibrary}
   22091 command:
   22092 
   22093 @table @code
   22094 @kindex info sharedlibrary
   22095 @kindex info share
   22096 @item info share @var{regex}
   22097 @itemx info sharedlibrary @var{regex}
   22098 Print the names of the shared libraries which are currently loaded
   22099 that match @var{regex}.  If @var{regex} is omitted then print
   22100 all shared libraries that are loaded.
   22101 
   22102 @kindex info dll
   22103 @item info dll @var{regex}
   22104 This is an alias of @code{info sharedlibrary}.
   22105 
   22106 @kindex sharedlibrary
   22107 @kindex share
   22108 @item sharedlibrary @var{regex}
   22109 @itemx share @var{regex}
   22110 Load shared object library symbols for files matching a
   22111 Unix regular expression.
   22112 As with files loaded automatically, it only loads shared libraries
   22113 required by your program for a core file or after typing @code{run}.  If
   22114 @var{regex} is omitted all shared libraries required by your program are
   22115 loaded.
   22116 
   22117 @item nosharedlibrary
   22118 @kindex nosharedlibrary
   22119 @cindex unload symbols from shared libraries
   22120 Unload all shared object library symbols.  This discards all symbols
   22121 that have been loaded from all shared libraries.  Symbols from shared
   22122 libraries that were loaded by explicit user requests are not
   22123 discarded.
   22124 @end table
   22125 
   22126 Sometimes you may wish that @value{GDBN} stops and gives you control
   22127 when any of shared library events happen.  The best way to do this is
   22128 to use @code{catch load} and @code{catch unload} (@pxref{Set
   22129 Catchpoints}).
   22130 
   22131 @value{GDBN} also supports the @code{set stop-on-solib-events}
   22132 command for this.  This command exists for historical reasons.  It is
   22133 less useful than setting a catchpoint, because it does not allow for
   22134 conditions or commands as a catchpoint does.
   22135 
   22136 @table @code
   22137 @item set stop-on-solib-events
   22138 @kindex set stop-on-solib-events
   22139 This command controls whether @value{GDBN} should give you control
   22140 when the dynamic linker notifies it about some shared library event.
   22141 The most common event of interest is loading or unloading of a new
   22142 shared library.
   22143 
   22144 @item show stop-on-solib-events
   22145 @kindex show stop-on-solib-events
   22146 Show whether @value{GDBN} stops and gives you control when shared
   22147 library events happen.
   22148 @end table
   22149 
   22150 Shared libraries are also supported in many cross or remote debugging
   22151 configurations.  @value{GDBN} needs to have access to the target's libraries;
   22152 this can be accomplished either by providing copies of the libraries
   22153 on the host system, or by asking @value{GDBN} to automatically retrieve the
   22154 libraries from the target.  If copies of the target libraries are
   22155 provided, they need to be the same as the target libraries, although the
   22156 copies on the target can be stripped as long as the copies on the host are
   22157 not.
   22158 
   22159 @cindex where to look for shared libraries
   22160 For remote debugging, you need to tell @value{GDBN} where the target
   22161 libraries are, so that it can load the correct copies---otherwise, it
   22162 may try to load the host's libraries.  @value{GDBN} has two variables
   22163 to specify the search directories for target libraries.
   22164 
   22165 @table @code
   22166 @cindex prefix for executable and shared library file names
   22167 @cindex system root, alternate
   22168 @kindex set solib-absolute-prefix
   22169 @kindex set sysroot
   22170 @item set sysroot @var{path}
   22171 Use @var{path} as the system root for the program being debugged.  Any
   22172 absolute shared library paths will be prefixed with @var{path}; many
   22173 runtime loaders store the absolute paths to the shared library in the
   22174 target program's memory.  When starting processes remotely, and when
   22175 attaching to already-running processes (local or remote), their
   22176 executable filenames will be prefixed with @var{path} if reported to
   22177 @value{GDBN} as absolute by the operating system.  If you use
   22178 @code{set sysroot} to find executables and shared libraries, they need
   22179 to be laid out in the same way that they are on the target, with
   22180 e.g.@: a @file{/bin}, @file{/lib} and @file{/usr/lib} hierarchy under
   22181 @var{path}.
   22182 
   22183 If @var{path} starts with the sequence @file{target:} and the target
   22184 system is remote then @value{GDBN} will retrieve the target binaries
   22185 from the remote system.  This is only supported when using a remote
   22186 target that supports the @code{remote get} command (@pxref{File
   22187 Transfer,,Sending files to a remote system}).  The part of @var{path}
   22188 following the initial @file{target:} (if present) is used as system
   22189 root prefix on the remote file system.  If @var{path} starts with the
   22190 sequence @file{remote:} this is converted to the sequence
   22191 @file{target:} by @code{set sysroot}@footnote{Historically the
   22192 functionality to retrieve binaries from the remote system was
   22193 provided by prefixing @var{path} with @file{remote:}}.  If you want
   22194 to specify a local system root using a directory that happens to be
   22195 named @file{target:} or @file{remote:}, you need to use some
   22196 equivalent variant of the name like @file{./target:}.
   22197 
   22198 For targets with an MS-DOS based filesystem, such as MS-Windows,
   22199 @value{GDBN} tries prefixing a few variants of the target
   22200 absolute file name with @var{path}.  But first, on Unix hosts,
   22201 @value{GDBN} converts all backslash directory separators into forward
   22202 slashes, because the backslash is not a directory separator on Unix:
   22203 
   22204 @smallexample
   22205   c:\foo\bar.dll @result{} c:/foo/bar.dll
   22206 @end smallexample
   22207 
   22208 Then, @value{GDBN} attempts prefixing the target file name with
   22209 @var{path}, and looks for the resulting file name in the host file
   22210 system:
   22211 
   22212 @smallexample
   22213   c:/foo/bar.dll @result{} /path/to/sysroot/c:/foo/bar.dll
   22214 @end smallexample
   22215 
   22216 If that does not find the binary, @value{GDBN} tries removing
   22217 the @samp{:} character from the drive spec, both for convenience, and,
   22218 for the case of the host file system not supporting file names with
   22219 colons:
   22220 
   22221 @smallexample
   22222   c:/foo/bar.dll @result{} /path/to/sysroot/c/foo/bar.dll
   22223 @end smallexample
   22224 
   22225 This makes it possible to have a system root that mirrors a target
   22226 with more than one drive.  E.g., you may want to setup your local
   22227 copies of the target system shared libraries like so (note @samp{c} vs
   22228 @samp{z}):
   22229 
   22230 @smallexample
   22231  @file{/path/to/sysroot/c/sys/bin/foo.dll}
   22232  @file{/path/to/sysroot/c/sys/bin/bar.dll}
   22233  @file{/path/to/sysroot/z/sys/bin/bar.dll}
   22234 @end smallexample
   22235 
   22236 @noindent
   22237 and point the system root at @file{/path/to/sysroot}, so that
   22238 @value{GDBN} can find the correct copies of both
   22239 @file{c:\sys\bin\foo.dll}, and @file{z:\sys\bin\bar.dll}.
   22240 
   22241 If that still does not find the binary, @value{GDBN} tries
   22242 removing the whole drive spec from the target file name:
   22243 
   22244 @smallexample
   22245   c:/foo/bar.dll @result{} /path/to/sysroot/foo/bar.dll
   22246 @end smallexample
   22247 
   22248 This last lookup makes it possible to not care about the drive name,
   22249 if you don't want or need to.
   22250 
   22251 The @code{set solib-absolute-prefix} command is an alias for @code{set
   22252 sysroot}.
   22253 
   22254 @cindex default system root
   22255 @cindex @samp{--with-sysroot}
   22256 You can set the default system root by using the configure-time
   22257 @samp{--with-sysroot} option.  If the system root is inside
   22258 @value{GDBN}'s configured binary prefix (set with @samp{--prefix} or
   22259 @samp{--exec-prefix}), then the default system root will be updated
   22260 automatically if the installed @value{GDBN} is moved to a new
   22261 location.
   22262 
   22263 @kindex show sysroot
   22264 @item show sysroot
   22265 Display the current executable and shared library prefix.
   22266 
   22267 @kindex set solib-search-path
   22268 @item set solib-search-path @var{path}
   22269 If this variable is set, @var{path} is a colon-separated list of
   22270 directories to search for shared libraries.  @samp{solib-search-path}
   22271 is used after @samp{sysroot} fails to locate the library, or if the
   22272 path to the library is relative instead of absolute.  If you want to
   22273 use @samp{solib-search-path} instead of @samp{sysroot}, be sure to set
   22274 @samp{sysroot} to a nonexistent directory to prevent @value{GDBN} from
   22275 finding your host's libraries.  @samp{sysroot} is preferred; setting
   22276 it to a nonexistent directory may interfere with automatic loading
   22277 of shared library symbols.
   22278 
   22279 @kindex show solib-search-path
   22280 @item show solib-search-path
   22281 Display the current shared library search path.
   22282 
   22283 @cindex DOS file-name semantics of file names.
   22284 @kindex set target-file-system-kind (unix|dos-based|auto)
   22285 @kindex show target-file-system-kind
   22286 @item set target-file-system-kind @var{kind}
   22287 Set assumed file system kind for target reported file names.
   22288 
   22289 Shared library file names as reported by the target system may not
   22290 make sense as is on the system @value{GDBN} is running on.  For
   22291 example, when remote debugging a target that has MS-DOS based file
   22292 system semantics, from a Unix host, the target may be reporting to
   22293 @value{GDBN} a list of loaded shared libraries with file names such as
   22294 @file{c:\Windows\kernel32.dll}.  On Unix hosts, there's no concept of
   22295 drive letters, so the @samp{c:\} prefix is not normally understood as
   22296 indicating an absolute file name, and neither is the backslash
   22297 normally considered a directory separator character.  In that case,
   22298 the native file system would interpret this whole absolute file name
   22299 as a relative file name with no directory components.  This would make
   22300 it impossible to point @value{GDBN} at a copy of the remote target's
   22301 shared libraries on the host using @code{set sysroot}, and impractical
   22302 with @code{set solib-search-path}.  Setting
   22303 @code{target-file-system-kind} to @code{dos-based} tells @value{GDBN}
   22304 to interpret such file names similarly to how the target would, and to
   22305 map them to file names valid on @value{GDBN}'s native file system
   22306 semantics.  The value of @var{kind} can be @code{"auto"}, in addition
   22307 to one of the supported file system kinds.  In that case, @value{GDBN}
   22308 tries to determine the appropriate file system variant based on the
   22309 current target's operating system (@pxref{ABI, ,Configuring the
   22310 Current ABI}).  The supported file system settings are:
   22311 
   22312 @table @code
   22313 @item unix
   22314 Instruct @value{GDBN} to assume the target file system is of Unix
   22315 kind.  Only file names starting the forward slash (@samp{/}) character
   22316 are considered absolute, and the directory separator character is also
   22317 the forward slash.
   22318 
   22319 @item dos-based
   22320 Instruct @value{GDBN} to assume the target file system is DOS based.
   22321 File names starting with either a forward slash, or a drive letter
   22322 followed by a colon (e.g., @samp{c:}), are considered absolute, and
   22323 both the slash (@samp{/}) and the backslash (@samp{\\}) characters are
   22324 considered directory separators.
   22325 
   22326 @item auto
   22327 Instruct @value{GDBN} to use the file system kind associated with the
   22328 target operating system (@pxref{ABI, ,Configuring the Current ABI}).
   22329 This is the default.
   22330 @end table
   22331 @end table
   22332 
   22333 @cindex file name canonicalization
   22334 @cindex base name differences
   22335 When processing file names provided by the user, @value{GDBN}
   22336 frequently needs to compare them to the file names recorded in the
   22337 program's debug info.  Normally, @value{GDBN} compares just the
   22338 @dfn{base names} of the files as strings, which is reasonably fast
   22339 even for very large programs.  (The base name of a file is the last
   22340 portion of its name, after stripping all the leading directories.)
   22341 This shortcut in comparison is based upon the assumption that files
   22342 cannot have more than one base name.  This is usually true, but
   22343 references to files that use symlinks or similar filesystem
   22344 facilities violate that assumption.  If your program records files
   22345 using such facilities, or if you provide file names to @value{GDBN}
   22346 using symlinks etc., you can set @code{basenames-may-differ} to
   22347 @code{true} to instruct @value{GDBN} to completely canonicalize each
   22348 pair of file names it needs to compare.  This will make file-name
   22349 comparisons accurate, but at a price of a significant slowdown.
   22350 
   22351 @table @code
   22352 @item set basenames-may-differ
   22353 @kindex set basenames-may-differ
   22354 Set whether a source file may have multiple base names.
   22355 
   22356 @item show basenames-may-differ
   22357 @kindex show basenames-may-differ
   22358 Show whether a source file may have multiple base names.
   22359 @end table
   22360 
   22361 @node File Caching
   22362 @section File Caching
   22363 @cindex caching of opened files
   22364 @cindex caching of bfd objects
   22365 
   22366 To speed up file loading, and reduce memory usage, @value{GDBN} will
   22367 reuse the @code{bfd} objects used to track open files.  @xref{Top, ,
   22368 BFD, bfd, The Binary File Descriptor Library}.  The following commands
   22369 allow visibility and control of the caching behavior.
   22370 
   22371 @table @code
   22372 @kindex maint info bfds
   22373 @item maint info bfds
   22374 This prints information about each @code{bfd} object that is known to
   22375 @value{GDBN}.
   22376 
   22377 @kindex maint set bfd-sharing
   22378 @kindex maint show bfd-sharing
   22379 @kindex bfd caching
   22380 @item maint set bfd-sharing
   22381 @item maint show bfd-sharing
   22382 Control whether @code{bfd} objects can be shared.  When sharing is
   22383 enabled @value{GDBN} reuses already open @code{bfd} objects rather
   22384 than reopening the same file.  Turning sharing off does not cause
   22385 already shared @code{bfd} objects to be unshared, but all future files
   22386 that are opened will create a new @code{bfd} object.  Similarly,
   22387 re-enabling sharing does not cause multiple existing @code{bfd}
   22388 objects to be collapsed into a single shared @code{bfd} object.
   22389 
   22390 @kindex set debug bfd-cache @var{level}
   22391 @kindex bfd caching
   22392 @item set debug bfd-cache @var{level}
   22393 Turns on debugging of the bfd cache, setting the level to @var{level}.
   22394 
   22395 @kindex show debug bfd-cache
   22396 @kindex bfd caching
   22397 @item show debug bfd-cache
   22398 Show the current debugging level of the bfd cache.
   22399 @end table
   22400 
   22401 @node Separate Debug Files
   22402 @section Debugging Information in Separate Files
   22403 @cindex separate debugging information files
   22404 @cindex debugging information in separate files
   22405 @cindex @file{.debug} subdirectories
   22406 @cindex debugging information directory, global
   22407 @cindex global debugging information directories
   22408 @cindex build ID, and separate debugging files
   22409 @cindex @file{.build-id} directory
   22410 
   22411 @value{GDBN} allows you to put a program's debugging information in a
   22412 file separate from the executable itself, in a way that allows
   22413 @value{GDBN} to find and load the debugging information automatically.
   22414 Since debugging information can be very large---sometimes larger
   22415 than the executable code itself---some systems distribute debugging
   22416 information for their executables in separate files, which users can
   22417 install only when they need to debug a problem.
   22418 
   22419 @value{GDBN} supports two ways of specifying the separate debug info
   22420 file:
   22421 
   22422 @itemize @bullet
   22423 @item
   22424 The executable contains a @dfn{debug link} that specifies the name of
   22425 the separate debug info file.  The separate debug file's name is
   22426 usually @file{@var{executable}.debug}, where @var{executable} is the
   22427 name of the corresponding executable file without leading directories
   22428 (e.g., @file{ls.debug} for @file{/usr/bin/ls}).  In addition, the
   22429 debug link specifies a 32-bit @dfn{Cyclic Redundancy Check} (CRC)
   22430 checksum for the debug file, which @value{GDBN} uses to validate that
   22431 the executable and the debug file came from the same build.
   22432 
   22433 @item
   22434 @anchor{build ID}
   22435 The executable contains a @dfn{build ID}, a unique bit string that is
   22436 also present in the corresponding debug info file.  (This is supported
   22437 only on some operating systems, when using the ELF or PE file formats
   22438 for binary files and the @sc{gnu} Binutils.)  For more details about
   22439 this feature, see the description of the @option{--build-id}
   22440 command-line option in @ref{Options, , Command Line Options, ld,
   22441 The GNU Linker}.  The debug info file's name is not specified
   22442 explicitly by the build ID, but can be computed from the build ID, see
   22443 below.
   22444 @end itemize
   22445 
   22446 Depending on the way the debug info file is specified, @value{GDBN}
   22447 uses two different methods of looking for the debug file:
   22448 
   22449 @itemize @bullet
   22450 @item
   22451 For the ``debug link'' method, @value{GDBN} looks up the named file in
   22452 the directory of the executable file, then in a subdirectory of that
   22453 directory named @file{.debug}, and finally under each one of the
   22454 global debug directories, in a subdirectory whose name is identical to
   22455 the leading directories of the executable's absolute file name.  (On
   22456 MS-Windows/MS-DOS, the drive letter of the executable's leading
   22457 directories is converted to a one-letter subdirectory, i.e.@:
   22458 @file{d:/usr/bin/} is converted to @file{/d/usr/bin/}, because Windows
   22459 filesystems disallow colons in file names.)
   22460 
   22461 @item
   22462 For the ``build ID'' method, @value{GDBN} looks in the
   22463 @file{.build-id} subdirectory of each one of the global debug directories for
   22464 a file named @file{@var{nn}/@var{nnnnnnnn}.debug}, where @var{nn} are the
   22465 first 2 hex characters of the build ID bit string, and @var{nnnnnnnn}
   22466 are the rest of the bit string.  (Real build ID strings are 32 or more
   22467 hex characters, not 10.)  @value{GDBN} can automatically query
   22468 @code{debuginfod} servers using build IDs in order to download separate debug
   22469 files that cannot be found locally.  For more information see @ref{Debuginfod}.
   22470 @end itemize
   22471 
   22472 So, for example, suppose you ask @value{GDBN} to debug
   22473 @file{/usr/bin/ls}, which has a debug link that specifies the
   22474 file @file{ls.debug}, and a build ID whose value in hex is
   22475 @code{abcdef1234}.  If the list of the global debug directories includes
   22476 @file{/usr/lib/debug}, then @value{GDBN} will look for the following
   22477 debug information files, in the indicated order:
   22478 
   22479 @itemize @minus
   22480 @item
   22481 @file{/usr/lib/debug/.build-id/ab/cdef1234.debug}
   22482 @item
   22483 @file{/usr/bin/ls.debug}
   22484 @item
   22485 @file{/usr/bin/.debug/ls.debug}
   22486 @item
   22487 @file{/usr/lib/debug/usr/bin/ls.debug}.
   22488 @end itemize
   22489 
   22490 If the debug file still has not been found and @code{debuginfod}
   22491 (@pxref{Debuginfod}) is enabled, @value{GDBN} will attempt to download the
   22492 file from @code{debuginfod} servers.
   22493 
   22494 @anchor{debug-file-directory}
   22495 Global debugging info directories default to what is set by @value{GDBN}
   22496 configure option @option{--with-separate-debug-dir} and augmented by the
   22497 colon-separated list of directories provided via @value{GDBN} configure
   22498 option @option{--additional-debug-dirs}.  During @value{GDBN} run you can
   22499 also set the global debugging info directories, and view the list
   22500 @value{GDBN} is currently using.
   22501 
   22502 @table @code
   22503 
   22504 @kindex set debug-file-directory
   22505 @item set debug-file-directory @var{directories}
   22506 Set the directories which @value{GDBN} searches for separate debugging
   22507 information files to @var{directory}.  Multiple path components can be set
   22508 concatenating them by a path separator.
   22509 
   22510 @kindex show debug-file-directory
   22511 @item show debug-file-directory
   22512 Show the directories @value{GDBN} searches for separate debugging
   22513 information files.
   22514 
   22515 @end table
   22516 
   22517 @cindex @code{.gnu_debuglink} sections
   22518 @cindex debug link sections
   22519 A debug link is a special section of the executable file named
   22520 @code{.gnu_debuglink}.  The section must contain:
   22521 
   22522 @itemize
   22523 @item
   22524 A filename, with any leading directory components removed, followed by
   22525 a zero byte,
   22526 @item
   22527 zero to three bytes of padding, as needed to reach the next four-byte
   22528 boundary within the section, and
   22529 @item
   22530 a four-byte CRC checksum, stored in the same endianness used for the
   22531 executable file itself.  The checksum is computed on the debugging
   22532 information file's full contents by the function given below, passing
   22533 zero as the @var{crc} argument.
   22534 @end itemize
   22535 
   22536 Any executable file format can carry a debug link, as long as it can
   22537 contain a section named @code{.gnu_debuglink} with the contents
   22538 described above.
   22539 
   22540 @cindex @code{.note.gnu.build-id} sections
   22541 @cindex build ID sections
   22542 The build ID is a special section in the executable file (and in other
   22543 ELF binary files that @value{GDBN} may consider).  This section is
   22544 often named @code{.note.gnu.build-id}, but that name is not mandatory.
   22545 It contains unique identification for the built files---the ID remains
   22546 the same across multiple builds of the same build tree.  The default
   22547 algorithm SHA1 produces 160 bits (40 hexadecimal characters) of the
   22548 content for the build ID string.  The same section with an identical
   22549 value is present in the original built binary with symbols, in its
   22550 stripped variant, and in the separate debugging information file.
   22551 
   22552 The debugging information file itself should be an ordinary
   22553 executable, containing a full set of linker symbols, sections, and
   22554 debugging information.  The sections of the debugging information file
   22555 should have the same names, addresses, and sizes as the original file,
   22556 but they need not contain any data---much like a @code{.bss} section
   22557 in an ordinary executable.
   22558 
   22559 The @sc{gnu} binary utilities (Binutils) package includes the
   22560 @samp{objcopy} utility that can produce
   22561 the separated executable / debugging information file pairs using the
   22562 following commands:
   22563 
   22564 @smallexample
   22565 @kbd{objcopy --only-keep-debug foo foo.debug}
   22566 @kbd{strip -g foo}
   22567 @end smallexample
   22568 
   22569 @noindent
   22570 These commands remove the debugging
   22571 information from the executable file @file{foo} and place it in the file
   22572 @file{foo.debug}.  You can use the first, second or both methods to link the
   22573 two files:
   22574 
   22575 @itemize @bullet
   22576 @item
   22577 The debug link method needs the following additional command to also leave
   22578 behind a debug link in @file{foo}:
   22579 
   22580 @smallexample
   22581 @kbd{objcopy --add-gnu-debuglink=foo.debug foo}
   22582 @end smallexample
   22583 
   22584 Ulrich Drepper's @file{elfutils} package, starting with version 0.53, contains
   22585 a version of the @code{strip} command such that the command @kbd{strip foo -f
   22586 foo.debug} has the same functionality as the two @code{objcopy} commands and
   22587 the @code{ln -s} command above, together.
   22588 
   22589 @item
   22590 Build ID gets embedded into the main executable using @code{ld --build-id} or
   22591 the @value{NGCC} counterpart @code{gcc -Wl,--build-id}.  Build ID support plus
   22592 compatibility fixes for debug files separation are present in @sc{gnu} binary
   22593 utilities (Binutils) package since version 2.18.
   22594 @end itemize
   22595 
   22596 @noindent
   22597 
   22598 @cindex CRC algorithm definition
   22599 The CRC used in @code{.gnu_debuglink} is the CRC-32 defined in
   22600 IEEE 802.3 using the polynomial:
   22601 
   22602 @c TexInfo requires naked braces for multi-digit exponents for Tex
   22603 @c output, but this causes HTML output to barf. HTML has to be set using
   22604 @c raw commands. So we end up having to specify this equation in 2
   22605 @c different ways!
   22606 @ifhtml
   22607 @display
   22608 @html
   22609  <em>x</em><sup>32</sup> + <em>x</em><sup>26</sup> + <em>x</em><sup>23</sup> + <em>x</em><sup>22</sup> + <em>x</em><sup>16</sup> + <em>x</em><sup>12</sup> + <em>x</em><sup>11</sup>
   22610  + <em>x</em><sup>10</sup> + <em>x</em><sup>8</sup> + <em>x</em><sup>7</sup> + <em>x</em><sup>5</sup> + <em>x</em><sup>4</sup> + <em>x</em><sup>2</sup> + <em>x</em> + 1
   22611 @end html
   22612 @end display
   22613 @end ifhtml
   22614 @ifnothtml
   22615 @display
   22616  @math{x^{32} + x^{26} + x^{23} + x^{22} + x^{16} + x^{12} + x^{11}}
   22617  @math{+ x^{10} + x^8 + x^7 + x^5 + x^4 + x^2 + x + 1}
   22618 @end display
   22619 @end ifnothtml
   22620 
   22621 The function is computed byte at a time, taking the least
   22622 significant bit of each byte first.  The initial pattern
   22623 @code{0xffffffff} is used, to ensure leading zeros affect the CRC and
   22624 the final result is inverted to ensure trailing zeros also affect the
   22625 CRC.
   22626 
   22627 @emph{Note:} This is the same CRC polynomial as used in handling the
   22628 @dfn{Remote Serial Protocol} @code{qCRC} packet (@pxref{qCRC packet}).
   22629 However in the case of the Remote Serial Protocol, the CRC is computed
   22630 @emph{most} significant bit first, and the result is not inverted, so
   22631 trailing zeros have no effect on the CRC value.
   22632 
   22633 To complete the description, we show below the code of the function
   22634 which produces the CRC used in @code{.gnu_debuglink}.  Inverting the
   22635 initially supplied @code{crc} argument means that an initial call to
   22636 this function passing in zero will start computing the CRC using
   22637 @code{0xffffffff}.
   22638 
   22639 @kindex gnu_debuglink_crc32
   22640 @smallexample
   22641 unsigned long
   22642 gnu_debuglink_crc32 (unsigned long crc,
   22643                      unsigned char *buf, size_t len)
   22644 @{
   22645   static const unsigned long crc32_table[256] =
   22646     @{
   22647       0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
   22648       0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4,
   22649       0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07,
   22650       0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
   22651       0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856,
   22652       0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
   22653       0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4,
   22654       0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
   22655       0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3,
   22656       0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a,
   22657       0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599,
   22658       0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
   22659       0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190,
   22660       0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f,
   22661       0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e,
   22662       0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
   22663       0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed,
   22664       0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
   22665       0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3,
   22666       0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
   22667       0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a,
   22668       0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5,
   22669       0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010,
   22670       0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
   22671       0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17,
   22672       0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6,
   22673       0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615,
   22674       0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
   22675       0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344,
   22676       0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
   22677       0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a,
   22678       0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
   22679       0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1,
   22680       0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c,
   22681       0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef,
   22682       0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
   22683       0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe,
   22684       0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31,
   22685       0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c,
   22686       0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
   22687       0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b,
   22688       0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
   22689       0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1,
   22690       0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
   22691       0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278,
   22692       0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7,
   22693       0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66,
   22694       0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
   22695       0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605,
   22696       0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8,
   22697       0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b,
   22698       0x2d02ef8d
   22699     @};
   22700   unsigned char *end;
   22701 
   22702   crc = ~crc & 0xffffffff;
   22703   for (end = buf + len; buf < end; ++buf)
   22704     crc = crc32_table[(crc ^ *buf) & 0xff] ^ (crc >> 8);
   22705   return ~crc & 0xffffffff;
   22706 @}
   22707 @end smallexample
   22708 
   22709 @noindent
   22710 This computation does not apply to the ``build ID'' method.
   22711 
   22712 @node MiniDebugInfo
   22713 @section Debugging information in a special section
   22714 @cindex separate debug sections
   22715 @cindex @samp{.gnu_debugdata} section
   22716 
   22717 Some systems ship pre-built executables and libraries that have a
   22718 special @samp{.gnu_debugdata} section.  This feature is called
   22719 @dfn{MiniDebugInfo}.  This section holds an LZMA-compressed object and
   22720 is used to supply extra symbols for backtraces.
   22721 
   22722 The intent of this section is to provide extra minimal debugging
   22723 information for use in simple backtraces.  It is not intended to be a
   22724 replacement for full separate debugging information (@pxref{Separate
   22725 Debug Files}).  The example below shows the intended use; however,
   22726 @value{GDBN} does not currently put restrictions on what sort of
   22727 debugging information might be included in the section.
   22728 
   22729 @value{GDBN} has support for this extension.  If the section exists,
   22730 then it is used provided that no other source of debugging information
   22731 can be found, and that @value{GDBN} was configured with LZMA support.
   22732 
   22733 This section can be easily created using @command{objcopy} and other
   22734 standard utilities:
   22735 
   22736 @smallexample
   22737 # Extract the dynamic symbols from the main binary, there is no need
   22738 # to also have these in the normal symbol table.
   22739 nm -D @var{binary} --format=posix --defined-only \
   22740   | awk '@{ print $1 @}' | sort > dynsyms
   22741 
   22742 # Extract all the text (i.e. function) symbols from the debuginfo.
   22743 # (Note that we actually also accept "D" symbols, for the benefit
   22744 # of platforms like PowerPC64 that use function descriptors.)
   22745 nm @var{binary} --format=posix --defined-only \
   22746   | awk '@{ if ($2 == "T" || $2 == "t" || $2 == "D") print $1 @}' \
   22747   | sort > funcsyms
   22748 
   22749 # Keep all the function symbols not already in the dynamic symbol
   22750 # table.
   22751 comm -13 dynsyms funcsyms > keep_symbols
   22752 
   22753 # Separate full debug info into debug binary.
   22754 objcopy --only-keep-debug @var{binary} debug
   22755 
   22756 # Copy the full debuginfo, keeping only a minimal set of symbols and
   22757 # removing some unnecessary sections.
   22758 objcopy -S --remove-section .gdb_index --remove-section .comment \
   22759   --keep-symbols=keep_symbols debug mini_debuginfo
   22760 
   22761 # Drop the full debug info from the original binary.
   22762 strip --strip-all -R .comment @var{binary}
   22763 
   22764 # Inject the compressed data into the .gnu_debugdata section of the
   22765 # original binary.
   22766 xz mini_debuginfo
   22767 objcopy --add-section .gnu_debugdata=mini_debuginfo.xz @var{binary}
   22768 @end smallexample
   22769 
   22770 @node Index Files
   22771 @section Index Files Speed Up @value{GDBN}
   22772 @cindex index files
   22773 @cindex @samp{.gdb_index} section
   22774 
   22775 When @value{GDBN} finds a symbol file, it scans the symbols in the
   22776 file in order to construct an internal symbol table.  This lets most
   22777 @value{GDBN} operations work quickly---at the cost of a delay early
   22778 on.  For large programs, this delay can be quite lengthy, so
   22779 @value{GDBN} provides a way to build an index, which speeds up
   22780 startup.
   22781 
   22782 For convenience, @value{GDBN} comes with a program,
   22783 @command{gdb-add-index}, which can be used to add the index to a
   22784 symbol file.  It takes the symbol file as its only argument:
   22785 
   22786 @smallexample
   22787 $ gdb-add-index symfile
   22788 @end smallexample
   22789 
   22790 @xref{gdb-add-index}.
   22791 
   22792 It is also possible to do the work manually.  Here is what
   22793 @command{gdb-add-index} does behind the curtains.
   22794 
   22795 The index is stored as a section in the symbol file.  @value{GDBN} can
   22796 write the index to a file, then you can put it into the symbol file
   22797 using @command{objcopy}.
   22798 
   22799 To create an index file, use the @code{save gdb-index} command:
   22800 
   22801 @table @code
   22802 @item save gdb-index [-dwarf-5] @var{directory}
   22803 @kindex save gdb-index
   22804 Create index files for all symbol files currently known by
   22805 @value{GDBN}.  For each known @var{symbol-file}, this command by
   22806 default creates it produces a single file
   22807 @file{@var{symbol-file}.gdb-index}.  If you invoke this command with
   22808 the @option{-dwarf-5} option, it produces 2 files:
   22809 @file{@var{symbol-file}.debug_names} and
   22810 @file{@var{symbol-file}.debug_str}.  The files are created in the
   22811 given @var{directory}.
   22812 
   22813 The @var{directory} argument supports escaping and quoting, see
   22814 @ref{Filename Arguments,,Filenames As Command Arguments}.
   22815 @end table
   22816 
   22817 Once you have created an index file you can merge it into your symbol
   22818 file, here named @file{symfile}, using @command{objcopy}:
   22819 
   22820 @smallexample
   22821 $ objcopy --add-section .gdb_index=symfile.gdb-index \
   22822     --set-section-flags .gdb_index=readonly symfile symfile
   22823 @end smallexample
   22824 
   22825 Or for @code{-dwarf-5}:
   22826 
   22827 @smallexample
   22828 $ objcopy --dump-section .debug_str=symfile.debug_str.new symfile
   22829 $ cat symfile.debug_str >>symfile.debug_str.new
   22830 $ objcopy --add-section .debug_names=symfile.gdb-index \
   22831     --set-section-flags .debug_names=readonly \
   22832     --update-section .debug_str=symfile.debug_str.new symfile symfile
   22833 @end smallexample
   22834 
   22835 @value{GDBN} will normally ignore older versions of @file{.gdb_index}
   22836 sections that have been deprecated.  Usually they are deprecated because
   22837 they are missing a new feature or have performance issues.
   22838 To tell @value{GDBN} to use a deprecated index section anyway
   22839 specify @code{set use-deprecated-index-sections on}.
   22840 The default is @code{off}.
   22841 This can speed up startup, but may result in some functionality being lost.
   22842 @xref{Index Section Format}.
   22843 
   22844 @emph{Warning:} Setting @code{use-deprecated-index-sections} to @code{on}
   22845 must be done before gdb reads the file.  The following will not work:
   22846 
   22847 @smallexample
   22848 $ gdb -ex "set use-deprecated-index-sections on" <program>
   22849 @end smallexample
   22850 
   22851 Instead you must do, for example,
   22852 
   22853 @smallexample
   22854 $ gdb -iex "set use-deprecated-index-sections on" <program>
   22855 @end smallexample
   22856 
   22857 Indices only work when using DWARF debugging information, not stabs.
   22858 
   22859 @subsection Automatic symbol index cache
   22860 
   22861 @cindex automatic symbol index cache
   22862 It is possible for @value{GDBN} to automatically save a copy of this index in a
   22863 cache on disk and retrieve it from there when loading the same binary in the
   22864 future.  This feature can be turned on with @kbd{set index-cache enabled on}.
   22865 The following commands can be used to tweak the behavior of the index cache.
   22866 
   22867 @table @code
   22868 
   22869 @kindex set index-cache
   22870 @item set index-cache enabled on
   22871 @itemx set index-cache enabled off
   22872 Enable or disable the use of the symbol index cache.
   22873 
   22874 @item set index-cache directory @var{directory}
   22875 @kindex show index-cache
   22876 @itemx show index-cache directory
   22877 Set/show the directory where index files will be saved.
   22878 
   22879 The default value for this directory depends on the host platform.  On
   22880 most systems, the index is cached in the @file{gdb} subdirectory of
   22881 the directory pointed to by the @env{XDG_CACHE_HOME} environment
   22882 variable, if it is defined, else in the @file{.cache/gdb} subdirectory
   22883 of your home directory.  However, on some systems, the default may
   22884 differ according to local convention.
   22885 
   22886 There is no limit on the disk space used by index cache.  It is perfectly safe
   22887 to delete the content of that directory to free up disk space.
   22888 
   22889 @item show index-cache stats
   22890 Print the number of cache hits and misses since the launch of @value{GDBN}.
   22891 
   22892 @end table
   22893 
   22894 @subsection Building the index with GNU @command{gold}
   22895 
   22896 The GNU @command{gold} linker can write the index at link time into
   22897 the resulting ELF file, by passing the @command{--gdb-index} flag to
   22898 @command{gold}.
   22899 
   22900 This is especially helpful if you intend to build a program and immediately
   22901 run it under @value{GDBN}.  You may find that it is faster overall for
   22902 the linker to write the index while it has the relevant information in
   22903 memory anyways, rather than re-reloading the data from disk with
   22904 @command{gdb-add-index}, or debugging the program without an index at
   22905 all, especially for large programs.
   22906 
   22907 @node Debug Names
   22908 @section Extensions to @samp{.debug_names}
   22909 @cindex index files
   22910 @cindex @samp{.debug_names} section
   22911 
   22912 The DWARF specification documents an optional index section called
   22913 @samp{.debug_names}.  @value{GDBN} can both read and create this
   22914 section.  However, in order to work with @value{GDBN}, some extensions
   22915 were necessary.
   22916 
   22917 @value{GDBN} uses the augmentation string @samp{GDB2}.  Earlier
   22918 versions used the string @samp{GDB}, but these versions of the index
   22919 are no longer supported.
   22920 
   22921 @value{GDBN} does not use the specified hash table.  Therefore,
   22922 because this hash table is optional, @value{GDBN} also does not write
   22923 it.
   22924 
   22925 @value{GDBN} also generates and uses some extra index attributes:
   22926 @table @code
   22927 @item DW_IDX_GNU_internal
   22928 This has the value @samp{0x2000}.  It is a flag that, when set,
   22929 indicates that the associated entry has @code{static} linkage.
   22930 
   22931 @item DW_IDX_GNU_main
   22932 This has the value @samp{0x2002}.  It is a flag that, when set,
   22933 indicates that the associated entry is the program's @code{main}.
   22934 
   22935 @item DW_IDX_GNU_language
   22936 This has the value @samp{0x2003}.  It is @samp{DW_LANG_} constant,
   22937 indicating the language of the associated entry.
   22938 
   22939 @item DW_IDX_GNU_linkage_name
   22940 This has the value @samp{0x2004}.  It is a flag that, when set,
   22941 indicates that the associated entry is a linkage name, and not a
   22942 source name.
   22943 @end table
   22944 
   22945 @node Symbol Errors
   22946 @section Errors Reading Symbol Files
   22947 
   22948 While reading a symbol file, @value{GDBN} occasionally encounters problems,
   22949 such as symbol types it does not recognize, or known bugs in compiler
   22950 output.  By default, @value{GDBN} does not notify you of such problems, since
   22951 they are relatively common and primarily of interest to people
   22952 debugging compilers.  If you are interested in seeing information
   22953 about ill-constructed symbol tables, you can either ask @value{GDBN} to print
   22954 only one message about each such type of problem, no matter how many
   22955 times the problem occurs; or you can ask @value{GDBN} to print more messages,
   22956 to see how many times the problems occur, with the @code{set
   22957 complaints} command (@pxref{Messages/Warnings, ,Optional Warnings and
   22958 Messages}).
   22959 
   22960 The messages currently printed, and their meanings, include:
   22961 
   22962 @table @code
   22963 @item inner block not inside outer block in @var{symbol}
   22964 
   22965 The symbol information shows where symbol scopes begin and end
   22966 (such as at the start of a function or a block of statements).  This
   22967 error indicates that an inner scope block is not fully contained
   22968 in its outer scope blocks.
   22969 
   22970 @value{GDBN} circumvents the problem by treating the inner block as if it had
   22971 the same scope as the outer block.  In the error message, @var{symbol}
   22972 may be shown as ``@code{(don't know)}'' if the outer block is not a
   22973 function.
   22974 
   22975 @item block at @var{address} out of order
   22976 
   22977 The symbol information for symbol scope blocks should occur in
   22978 order of increasing addresses.  This error indicates that it does not
   22979 do so.
   22980 
   22981 @value{GDBN} does not circumvent this problem, and has trouble
   22982 locating symbols in the source file whose symbols it is reading.  (You
   22983 can often determine what source file is affected by specifying
   22984 @code{set verbose on}.  @xref{Messages/Warnings, ,Optional Warnings and
   22985 Messages}.)
   22986 
   22987 @item bad block start address patched
   22988 
   22989 The symbol information for a symbol scope block has a start address
   22990 smaller than the address of the preceding source line.  This is known
   22991 to occur in the SunOS 4.1.1 (and earlier) C compiler.
   22992 
   22993 @value{GDBN} circumvents the problem by treating the symbol scope block as
   22994 starting on the previous source line.
   22995 
   22996 @item bad string table offset in symbol @var{n}
   22997 
   22998 @cindex foo
   22999 Symbol number @var{n} contains a pointer into the string table which is
   23000 larger than the size of the string table.
   23001 
   23002 @value{GDBN} circumvents the problem by considering the symbol to have the
   23003 name @code{foo}, which may cause other problems if many symbols end up
   23004 with this name.
   23005 
   23006 @item unknown symbol type @code{0x@var{nn}}
   23007 
   23008 The symbol information contains new data types that @value{GDBN} does
   23009 not yet know how to read.  @code{0x@var{nn}} is the symbol type of the
   23010 uncomprehended information, in hexadecimal.
   23011 
   23012 @value{GDBN} circumvents the error by ignoring this symbol information.
   23013 This usually allows you to debug your program, though certain symbols
   23014 are not accessible.  If you encounter such a problem and feel like
   23015 debugging it, you can debug @code{@value{GDBP}} with itself, breakpoint
   23016 on @code{complain}, then go up to the function @code{read_dbx_symtab}
   23017 and examine @code{*bufp} to see the symbol.
   23018 
   23019 @item stub type has NULL name
   23020 
   23021 @value{GDBN} could not find the full definition for a struct or class.
   23022 
   23023 @item const/volatile indicator missing (ok if using g++ v1.x), got@dots{}
   23024 The symbol information for a C@t{++} member function is missing some
   23025 information that recent versions of the compiler should have output for
   23026 it.
   23027 
   23028 @item info mismatch between compiler and debugger
   23029 
   23030 @value{GDBN} could not parse a type specification output by the compiler.
   23031 
   23032 @end table
   23033 
   23034 @node Data Files
   23035 @section GDB Data Files
   23036 
   23037 @cindex prefix for data files
   23038 @value{GDBN} will sometimes read an auxiliary data file.  These files
   23039 are kept in a directory known as the @dfn{data directory}.
   23040 
   23041 You can set the data directory's name, and view the name @value{GDBN}
   23042 is currently using.
   23043 
   23044 @table @code
   23045 @kindex set data-directory
   23046 @item set data-directory @var{directory}
   23047 Set the directory which @value{GDBN} searches for auxiliary data files
   23048 to @var{directory}.
   23049 
   23050 @kindex show data-directory
   23051 @item show data-directory
   23052 Show the directory @value{GDBN} searches for auxiliary data files.
   23053 @end table
   23054 
   23055 @cindex default data directory
   23056 @cindex @samp{--with-gdb-datadir}
   23057 You can set the default data directory by using the configure-time
   23058 @samp{--with-gdb-datadir} option.  If the data directory is inside
   23059 @value{GDBN}'s configured binary prefix (set with @samp{--prefix} or
   23060 @samp{--exec-prefix}), then the default data directory will be updated
   23061 automatically if the installed @value{GDBN} is moved to a new
   23062 location.
   23063 
   23064 The data directory may also be specified with the
   23065 @code{--data-directory} command line option.
   23066 @xref{Mode Options}.
   23067 
   23068 @node Targets
   23069 @chapter Specifying a Debugging Target
   23070 
   23071 @cindex debugging target
   23072 A @dfn{target} is the execution environment occupied by your program.
   23073 
   23074 Often, @value{GDBN} runs in the same host environment as your program;
   23075 in that case, the debugging target is specified as a side effect when
   23076 you use the @code{file} or @code{core} commands.  When you need more
   23077 flexibility---for example, running @value{GDBN} on a physically separate
   23078 host, or controlling a standalone system over a serial port or a
   23079 realtime system over a TCP/IP connection---you can use the @code{target}
   23080 command to specify one of the target types configured for @value{GDBN}
   23081 (@pxref{Target Commands, ,Commands for Managing Targets}).
   23082 
   23083 @cindex target architecture
   23084 It is possible to build @value{GDBN} for several different @dfn{target
   23085 architectures}.  When @value{GDBN} is built like that, you can choose
   23086 one of the available architectures with the @kbd{set architecture}
   23087 command.
   23088 
   23089 @table @code
   23090 @kindex set architecture
   23091 @kindex show architecture
   23092 @item set architecture @var{arch}
   23093 This command sets the current target architecture to @var{arch}.  The
   23094 value of @var{arch} can be @code{"auto"}, in addition to one of the
   23095 supported architectures.
   23096 
   23097 @item show architecture
   23098 Show the current target architecture.
   23099 
   23100 @item set processor
   23101 @itemx processor
   23102 @kindex set processor
   23103 @kindex show processor
   23104 These are alias commands for, respectively, @code{set architecture}
   23105 and @code{show architecture}.
   23106 @end table
   23107 
   23108 @menu
   23109 * Active Targets::              Active targets
   23110 * Target Commands::             Commands for managing targets
   23111 * Byte Order::                  Choosing target byte order
   23112 @end menu
   23113 
   23114 @node Active Targets
   23115 @section Active Targets
   23116 
   23117 @cindex stacking targets
   23118 @cindex active targets
   23119 @cindex multiple targets
   23120 
   23121 There are multiple classes of targets such as: processes, executable files or
   23122 recording sessions.  Core files belong to the process class, making core file
   23123 and process mutually exclusive.  Otherwise, @value{GDBN} can work concurrently
   23124 on multiple active targets, one in each class.  This allows you to (for
   23125 example) start a process and inspect its activity, while still having access to
   23126 the executable file after the process finishes.  Or if you start process
   23127 recording (@pxref{Reverse Execution}) and @code{reverse-step} there, you are
   23128 presented a virtual layer of the recording target, while the process target
   23129 remains stopped at the chronologically last point of the process execution.
   23130 
   23131 Use the @code{core-file} and @code{exec-file} commands to select a new core
   23132 file or executable target (@pxref{Files, ,Commands to Specify Files}).  To
   23133 specify as a target a process that is already running, use the @code{attach}
   23134 command (@pxref{Attach, ,Debugging an Already-running Process}).
   23135 
   23136 @node Target Commands
   23137 @section Commands for Managing Targets
   23138 
   23139 @table @code
   23140 @item target @var{type} @var{parameters}
   23141 Connects the @value{GDBN} host environment to a target machine or
   23142 process.  A target is typically a protocol for talking to debugging
   23143 facilities.  You use the argument @var{type} to specify the type or
   23144 protocol of the target machine.
   23145 
   23146 Further @var{parameters} are interpreted by the target protocol, but
   23147 typically include things like device names or host names to connect
   23148 with, process numbers, and baud rates.
   23149 
   23150 The @code{target} command does not repeat if you press @key{RET} again
   23151 after executing the command.
   23152 
   23153 @kindex help target
   23154 @item help target
   23155 Displays the names of all targets available.  To display targets
   23156 currently selected, use either @code{info target} or @code{info files}
   23157 (@pxref{Files, ,Commands to Specify Files}).
   23158 
   23159 @item help target @var{name}
   23160 Describe a particular target, including any parameters necessary to
   23161 select it.
   23162 
   23163 @kindex set gnutarget
   23164 @item set gnutarget @var{args}
   23165 @value{GDBN} uses its own library BFD to read your files.  @value{GDBN}
   23166 knows whether it is reading an @dfn{executable},
   23167 a @dfn{core}, or a @dfn{.o} file; however, you can specify the file format
   23168 with the @code{set gnutarget} command.  Unlike most @code{target} commands,
   23169 with @code{gnutarget} the @code{target} refers to a program, not a machine.
   23170 
   23171 @quotation
   23172 @emph{Warning:} To specify a file format with @code{set gnutarget},
   23173 you must know the actual BFD name.
   23174 @end quotation
   23175 
   23176 @noindent
   23177 @xref{Files, , Commands to Specify Files}.
   23178 
   23179 @kindex show gnutarget
   23180 @item show gnutarget
   23181 Use the @code{show gnutarget} command to display what file format
   23182 @code{gnutarget} is set to read.  If you have not set @code{gnutarget},
   23183 @value{GDBN} will determine the file format for each file automatically,
   23184 and @code{show gnutarget} displays @samp{The current BFD target is "auto"}.
   23185 @end table
   23186 
   23187 @cindex common targets
   23188 Here are some common targets (available, or not, depending on the GDB
   23189 configuration):
   23190 
   23191 @table @code
   23192 @kindex target
   23193 @item target exec @var{program}
   23194 @cindex executable file target
   23195 An executable file.  @samp{target exec @var{program}} is the same as
   23196 @samp{exec-file @var{program}}.
   23197 
   23198 The @var{program} argument supports escaping and quoting, see
   23199 @ref{Filename Arguments,,Filenames As Command Arguments}.
   23200 
   23201 @item target core @var{filename}
   23202 @cindex core dump file target
   23203 A core dump file.  @samp{target core @var{filename}} is the same as
   23204 @samp{core-file @var{filename}}.
   23205 
   23206 The @var{filename} argument supports escaping and quoting, see
   23207 @ref{Filename Arguments,,Filenames As Command Arguments}.
   23208 
   23209 @item target remote @var{medium}
   23210 @cindex remote target
   23211 A remote system connected to @value{GDBN} via a serial line or network
   23212 connection.  This command tells @value{GDBN} to use its own remote
   23213 protocol over @var{medium} for debugging.  @xref{Remote Debugging}.
   23214 
   23215 For example, if you have a board connected to @file{/dev/ttya} on the
   23216 machine running @value{GDBN}, you could say:
   23217 
   23218 @smallexample
   23219 target remote /dev/ttya
   23220 @end smallexample
   23221 
   23222 @code{target remote} supports the @code{load} command.  This is only
   23223 useful if you have some other way of getting the stub to the target
   23224 system, and you can put it somewhere in memory where it won't get
   23225 clobbered by the download.
   23226 
   23227 @item target sim @r{[}@var{simargs}@r{]} @dots{}
   23228 @cindex built-in simulator target
   23229 Builtin CPU simulator.  @value{GDBN} includes simulators for most architectures.
   23230 In general,
   23231 @smallexample
   23232         target sim
   23233         load
   23234         run
   23235 @end smallexample
   23236 @noindent
   23237 works; however, you cannot assume that a specific memory map, device
   23238 drivers, or even basic I/O is available, although some simulators do
   23239 provide these.  For info about any processor-specific simulator details,
   23240 see the appropriate section in @ref{Embedded Processors, ,Embedded
   23241 Processors}.
   23242 
   23243 @item target native
   23244 @cindex native target
   23245 Setup for local/native process debugging.  Useful to make the
   23246 @code{run} command spawn native processes (likewise @code{attach},
   23247 etc.@:) even when @code{set auto-connect-native-target} is @code{off}
   23248 (@pxref{set auto-connect-native-target}).
   23249 
   23250 @end table
   23251 
   23252 Different targets are available on different configurations of @value{GDBN};
   23253 your configuration may have more or fewer targets.
   23254 
   23255 Many remote targets require you to download the executable's code once
   23256 you've successfully established a connection.  You may wish to control
   23257 various aspects of this process.
   23258 
   23259 @table @code
   23260 
   23261 @item set hash
   23262 @kindex set hash@r{, for remote monitors}
   23263 @cindex hash mark while downloading
   23264 This command controls whether a hash mark @samp{#} is displayed while
   23265 downloading a file to the remote monitor.  If on, a hash mark is
   23266 displayed after each S-record is successfully downloaded to the
   23267 monitor.
   23268 
   23269 @item show hash
   23270 @kindex show hash@r{, for remote monitors}
   23271 Show the current status of displaying the hash mark.
   23272 
   23273 @item set debug monitor
   23274 @kindex set debug monitor
   23275 @cindex display remote monitor communications
   23276 Enable or disable display of communications messages between
   23277 @value{GDBN} and the remote monitor.
   23278 
   23279 @item show debug monitor
   23280 @kindex show debug monitor
   23281 Show the current status of displaying communications between
   23282 @value{GDBN} and the remote monitor.
   23283 @end table
   23284 
   23285 @table @code
   23286 
   23287 @kindex load @var{filename} @var{offset}
   23288 @item load @var{filename} @var{offset}
   23289 @anchor{load}
   23290 Depending on what remote debugging facilities are configured into
   23291 @value{GDBN}, the @code{load} command may be available.  Where it exists, it
   23292 is meant to make @var{filename} (an executable) available for debugging
   23293 on the remote system---by downloading, or dynamic linking, for example.
   23294 @code{load} also records the @var{filename} symbol table in @value{GDBN}, like
   23295 the @code{add-symbol-file} command.
   23296 
   23297 If your @value{GDBN} does not have a @code{load} command, attempting to
   23298 execute it gets the error message ``@code{You can't do that when your
   23299 target is @dots{}}''
   23300 
   23301 The file is loaded at whatever address is specified in the executable.
   23302 For some object file formats, you can specify the load address when you
   23303 link the program; for other formats, like a.out, the object file format
   23304 specifies a fixed address.
   23305 @c FIXME! This would be a good place for an xref to the GNU linker doc.
   23306 
   23307 It is also possible to tell @value{GDBN} to load the executable file at a
   23308 specific offset described by the optional argument @var{offset}.  When
   23309 @var{offset} is provided, @var{filename} must also be provided.
   23310 
   23311 Depending on the remote side capabilities, @value{GDBN} may be able to
   23312 load programs into flash memory.
   23313 
   23314 @code{load} does not repeat if you press @key{RET} again after using it.
   23315 @end table
   23316 
   23317 @table @code
   23318 
   23319 @kindex flash-erase
   23320 @item flash-erase
   23321 @anchor{flash-erase}
   23322 
   23323 Erases all known flash memory regions on the target.
   23324 
   23325 @end table
   23326 
   23327 @node Byte Order
   23328 @section Choosing Target Byte Order
   23329 
   23330 @cindex choosing target byte order
   23331 @cindex target byte order
   23332 
   23333 Some types of processors, such as the @acronym{MIPS}, PowerPC, and Renesas SH,
   23334 offer the ability to run either big-endian or little-endian byte
   23335 orders.  Usually the executable or symbol will include a bit to
   23336 designate the endian-ness, and you will not need to worry about
   23337 which to use.  However, you may still find it useful to adjust
   23338 @value{GDBN}'s idea of processor endian-ness manually.
   23339 
   23340 @table @code
   23341 @kindex set endian
   23342 @item set endian big
   23343 Instruct @value{GDBN} to assume the target is big-endian.
   23344 
   23345 @item set endian little
   23346 Instruct @value{GDBN} to assume the target is little-endian.
   23347 
   23348 @item set endian auto
   23349 Instruct @value{GDBN} to use the byte order associated with the
   23350 executable.
   23351 
   23352 @item show endian
   23353 Display @value{GDBN}'s current idea of the target byte order.
   23354 
   23355 @end table
   23356 
   23357 If the @code{set endian auto} mode is in effect and no executable has
   23358 been selected, then the endianness used is the last one chosen either
   23359 by one of the @code{set endian big} and @code{set endian little}
   23360 commands or by inferring from the last executable used.  If no
   23361 endianness has been previously chosen, then the default for this mode
   23362 is inferred from the target @value{GDBN} has been built for, and is
   23363 @code{little} if the name of the target CPU has an @code{el} suffix
   23364 and @code{big} otherwise.
   23365 
   23366 Note that these commands merely adjust interpretation of symbolic
   23367 data on the host, and that they have absolutely no effect on the
   23368 target system.
   23369 
   23370 
   23371 @node Remote Debugging
   23372 @chapter Debugging Remote Programs
   23373 @cindex remote debugging
   23374 
   23375 If you are trying to debug a program running on a machine that cannot run
   23376 @value{GDBN} in the usual way, it is often useful to use remote debugging.
   23377 For example, you might use remote debugging on an operating system kernel,
   23378 or on a small system which does not have a general purpose operating system
   23379 powerful enough to run a full-featured debugger.
   23380 
   23381 Some configurations of @value{GDBN} have special serial or TCP/IP interfaces
   23382 to make this work with particular debugging targets.  In addition,
   23383 @value{GDBN} comes with a generic serial protocol (specific to @value{GDBN},
   23384 but not specific to any particular target system) which you can use if you
   23385 write the remote stubs---the code that runs on the remote system to
   23386 communicate with @value{GDBN}.
   23387 
   23388 Other remote targets may be available in your
   23389 configuration of @value{GDBN}; use @code{help target} to list them.
   23390 
   23391 @menu
   23392 * Connecting::                  Connecting to a remote target
   23393 * File Transfer::               Sending files to a remote system
   23394 * Server::                      Using the gdbserver program
   23395 * Remote Configuration::        Remote configuration
   23396 * Remote Stub::                 Implementing a remote stub
   23397 @end menu
   23398 
   23399 @node Connecting
   23400 @section Connecting to a Remote Target
   23401 @cindex remote debugging, connecting
   23402 @cindex @code{gdbserver}, connecting
   23403 @cindex remote debugging, types of connections
   23404 @cindex @code{gdbserver}, types of connections
   23405 @cindex @code{gdbserver}, @code{target remote} mode
   23406 @cindex @code{gdbserver}, @code{target extended-remote} mode
   23407 
   23408 This section describes how to connect to a remote target, including the
   23409 types of connections and their differences, how to set up executable and
   23410 symbol files on the host and target, and the commands used for
   23411 connecting to and disconnecting from the remote target.
   23412 
   23413 @subsection Types of Remote Connections
   23414 
   23415 @value{GDBN} supports two types of remote connections, @code{target remote}
   23416 mode and @code{target extended-remote} mode.  Note that many remote targets
   23417 support only @code{target remote} mode.  There are several major
   23418 differences between the two types of connections, enumerated here:
   23419 
   23420 @table @asis
   23421 
   23422 @cindex remote debugging, detach and program exit
   23423 @item Result of detach or program exit
   23424 @strong{With target remote mode:} When the debugged program exits or you
   23425 detach from it, @value{GDBN} disconnects from the target.  When using
   23426 @code{gdbserver}, @code{gdbserver} will exit.
   23427 
   23428 @strong{With target extended-remote mode:} When the debugged program exits or
   23429 you detach from it, @value{GDBN} remains connected to the target, even
   23430 though no program is running.  You can rerun the program, attach to a
   23431 running program, or use @code{monitor} commands specific to the target.
   23432 
   23433 When using @code{gdbserver} in this case, it does not exit unless it was
   23434 invoked using the @option{--once} option.  If the @option{--once} option
   23435 was not used, you can ask @code{gdbserver} to exit using the
   23436 @code{monitor exit} command (@pxref{Monitor Commands for gdbserver}).
   23437 
   23438 @item Specifying the program to debug
   23439 For both connection types you use the @code{file} command to specify the
   23440 program on the host system.  If you are using @code{gdbserver} there are
   23441 some differences in how to specify the location of the program on the
   23442 target.
   23443 
   23444 @strong{With target remote mode:} You must either specify the program to debug
   23445 on the @code{gdbserver} command line or use the @option{--attach} option
   23446 (@pxref{Attaching to a program,,Attaching to a Running Program}).
   23447 
   23448 @cindex @option{--multi}, @code{gdbserver} option
   23449 @strong{With target extended-remote mode:} You may specify the program to debug
   23450 on the @code{gdbserver} command line, or you can load the program or attach
   23451 to it using @value{GDBN} commands after connecting to @code{gdbserver}.
   23452 
   23453 @anchor{--multi Option in Types of Remote Connnections}
   23454 You can start @code{gdbserver} without supplying an initial command to run
   23455 or process ID to attach.  To do this, use the @option{--multi} command line
   23456 option.  Then you can connect using @code{target extended-remote} and start
   23457 the program you want to debug (see below for details on using the
   23458 @code{run} command in this scenario).  Note that the conditions under which
   23459 @code{gdbserver} terminates depend on how @value{GDBN} connects to it
   23460 (@code{target remote} or @code{target extended-remote}).  The
   23461 @option{--multi} option to @code{gdbserver} has no influence on that.
   23462 
   23463 @item The @code{run} command
   23464 @strong{With target remote mode:} The @code{run} command is not
   23465 supported.  Once a connection has been established, you can use all
   23466 the usual @value{GDBN} commands to examine and change data.  The
   23467 remote program is already running, so you can use commands like
   23468 @kbd{step} and @kbd{continue}.
   23469 
   23470 @strong{With target extended-remote mode:} The @code{run} command is
   23471 supported.  The @code{run} command uses the value set by
   23472 @code{set remote exec-file} (@pxref{set remote exec-file}) to select
   23473 the program to run.  Command line arguments are supported, except for
   23474 wildcard expansion and I/O redirection (@pxref{Arguments}).
   23475 
   23476 If you specify the program to debug on the command line, then the
   23477 @code{run} command is not required to start execution, and you can
   23478 resume using commands like @kbd{step} and @kbd{continue} as with
   23479 @code{target remote} mode.
   23480 
   23481 @anchor{Attaching in Types of Remote Connections}
   23482 @item Attaching
   23483 @strong{With target remote mode:} The @value{GDBN} command @code{attach} is
   23484 not supported.  To attach to a running program using @code{gdbserver}, you
   23485 must use the @option{--attach} option (@pxref{Running gdbserver}).
   23486 
   23487 @strong{With target extended-remote mode:} To attach to a running program,
   23488 you may use the @code{attach} command after the connection has been
   23489 established.  If you are using @code{gdbserver}, you may also invoke
   23490 @code{gdbserver} using the @option{--attach} option
   23491 (@pxref{Running gdbserver}).
   23492 
   23493 Some remote targets allow @value{GDBN} to determine the executable file running
   23494 in the process the debugger is attaching to.  In such a case, @value{GDBN}
   23495 uses the value of @code{exec-file-mismatch} to handle a possible mismatch
   23496 between the executable file name running in the process and the name of the
   23497 current exec-file loaded by @value{GDBN} (@pxref{set exec-file-mismatch}).
   23498 
   23499 @end table
   23500 
   23501 @anchor{Host and target files}
   23502 @subsection Host and Target Files
   23503 @cindex remote debugging, symbol files
   23504 @cindex symbol files, remote debugging
   23505 
   23506 @value{GDBN}, running on the host, needs access to symbol and debugging
   23507 information for your program running on the target.  This requires 
   23508 access to an unstripped copy of your program, and possibly any associated
   23509 symbol files.  Note that this section applies equally to both @code{target
   23510 remote} mode and @code{target extended-remote} mode.
   23511 
   23512 Some remote targets (@pxref{qXfer executable filename read}, and
   23513 @pxref{Host I/O Packets}) allow @value{GDBN} to access program files over
   23514 the same connection used to communicate with @value{GDBN}.  With such a
   23515 target, if the remote program is unstripped, the only command you need is
   23516 @code{target remote} (or @code{target extended-remote}).
   23517 
   23518 If the remote program is stripped, or the target does not support remote
   23519 program file access, start up @value{GDBN} using the name of the local
   23520 unstripped copy of your program as the first argument, or use the
   23521 @code{file} command.  Use @code{set sysroot} to specify the location (on
   23522 the host) of target libraries (unless your @value{GDBN} was compiled with
   23523 the correct sysroot using @code{--with-sysroot}).  Alternatively, you
   23524 may use @code{set solib-search-path} to specify how @value{GDBN} locates
   23525 target libraries.
   23526 
   23527 The symbol file and target libraries must exactly match the executable
   23528 and libraries on the target, with one exception: the files on the host
   23529 system should not be stripped, even if the files on the target system
   23530 are.  Mismatched or missing files will lead to confusing results
   23531 during debugging.  On @sc{gnu}/Linux targets, mismatched or missing
   23532 files may also prevent @code{gdbserver} from debugging multi-threaded
   23533 programs.
   23534 
   23535 @subsection Remote Connection Commands
   23536 @cindex remote connection commands
   23537 @value{GDBN} can communicate with the target over a serial line, a
   23538 local Unix domain socket, or
   23539 over an @acronym{IP} network using @acronym{TCP} or @acronym{UDP}.  In
   23540 each case, @value{GDBN} uses the same protocol for debugging your
   23541 program; only the medium carrying the debugging packets varies.  The
   23542 @code{target remote} and @code{target extended-remote} commands
   23543 establish a connection to the target.  Both commands accept the same
   23544 arguments, which indicate the medium to use:
   23545 
   23546 @table @code
   23547 
   23548 @item target remote @var{serial-device}
   23549 @itemx target extended-remote @var{serial-device}
   23550 @cindex serial line, @code{target remote}
   23551 Use @var{serial-device} to communicate with the target.  For example,
   23552 to use a serial line connected to the device named @file{/dev/ttyb}:
   23553 
   23554 @smallexample
   23555 target remote /dev/ttyb
   23556 @end smallexample
   23557 
   23558 If you're using a serial line, you may want to give @value{GDBN} the
   23559 @samp{--baud} option, or use the @code{set serial baud} command
   23560 (@pxref{Remote Configuration, set serial baud}) before the
   23561 @code{target} command.
   23562 
   23563 @item target remote @var{local-socket}
   23564 @itemx target extended-remote @var{local-socket}
   23565 @cindex local socket, @code{target remote}
   23566 @cindex Unix domain socket
   23567 Use @var{local-socket} to communicate with the target.  For example,
   23568 to use a local Unix domain socket bound to the file system entry @file{/tmp/gdb-socket0}:
   23569 
   23570 @smallexample
   23571 target remote /tmp/gdb-socket0
   23572 @end smallexample
   23573 
   23574 Note that this command has the same form as the command to connect
   23575 to a serial line.  @value{GDBN} will automatically determine which
   23576 kind of file you have specified and will make the appropriate kind
   23577 of connection.
   23578 This feature is not available if the host system does not support
   23579 Unix domain sockets.
   23580 
   23581 @item target remote @code{@var{host}:@var{port}}
   23582 @itemx target remote @code{[@var{host}]:@var{port}}
   23583 @itemx target remote @code{tcp:@var{host}:@var{port}}
   23584 @itemx target remote @code{tcp:[@var{host}]:@var{port}}
   23585 @itemx target remote @code{tcp4:@var{host}:@var{port}}
   23586 @itemx target remote @code{tcp6:@var{host}:@var{port}}
   23587 @itemx target remote @code{tcp6:[@var{host}]:@var{port}}
   23588 @itemx target extended-remote @code{@var{host}:@var{port}}
   23589 @itemx target extended-remote @code{[@var{host}]:@var{port}}
   23590 @itemx target extended-remote @code{tcp:@var{host}:@var{port}}
   23591 @itemx target extended-remote @code{tcp:[@var{host}]:@var{port}}
   23592 @itemx target extended-remote @code{tcp4:@var{host}:@var{port}}
   23593 @itemx target extended-remote @code{tcp6:@var{host}:@var{port}}
   23594 @itemx target extended-remote @code{tcp6:[@var{host}]:@var{port}}
   23595 @cindex @acronym{TCP} port, @code{target remote}
   23596 Debug using a @acronym{TCP} connection to @var{port} on @var{host}.
   23597 The @var{host} may be either a host name, a numeric @acronym{IPv4}
   23598 address, or a numeric @acronym{IPv6} address (with or without the
   23599 square brackets to separate the address from the port); @var{port}
   23600 must be a decimal number.  The @var{host} could be the target machine
   23601 itself, if it is directly connected to the net, or it might be a
   23602 terminal server which in turn has a serial line to the target.
   23603 
   23604 For example, to connect to port 2828 on a terminal server named
   23605 @code{manyfarms}:
   23606 
   23607 @smallexample
   23608 target remote manyfarms:2828
   23609 @end smallexample
   23610 
   23611 To connect to port 2828 on a terminal server whose address is
   23612 @code{2001:0db8:85a3:0000:0000:8a2e:0370:7334}, you can either use the
   23613 square bracket syntax:
   23614 
   23615 @smallexample
   23616 target remote [2001:0db8:85a3:0000:0000:8a2e:0370:7334]:2828
   23617 @end smallexample
   23618 
   23619 @noindent
   23620 or explicitly specify the @acronym{IPv6} protocol:
   23621 
   23622 @smallexample
   23623 target remote tcp6:2001:0db8:85a3:0000:0000:8a2e:0370:7334:2828
   23624 @end smallexample
   23625 
   23626 This last example may be confusing to the reader, because there is no
   23627 visible separation between the hostname and the port number.
   23628 Therefore, we recommend the user to provide @acronym{IPv6} addresses
   23629 using square brackets for clarity.  However, it is important to
   23630 mention that for @value{GDBN} there is no ambiguity: the number after
   23631 the last colon is considered to be the port number.
   23632 
   23633 If your remote target is actually running on the same machine as your
   23634 debugger session (e.g.@: a simulator for your target running on the
   23635 same host), you can omit the hostname.  For example, to connect to
   23636 port 1234 on your local machine:
   23637 
   23638 @smallexample
   23639 target remote :1234
   23640 @end smallexample
   23641 @noindent
   23642 
   23643 Note that the colon is still required here.
   23644 
   23645 @item target remote @code{udp:@var{host}:@var{port}}
   23646 @itemx target remote @code{udp:[@var{host}]:@var{port}}
   23647 @itemx target remote @code{udp4:@var{host}:@var{port}}
   23648 @itemx target remote @code{udp6:[@var{host}]:@var{port}}
   23649 @itemx target extended-remote @code{udp:@var{host}:@var{port}}
   23650 @itemx target extended-remote @code{udp:@var{host}:@var{port}}
   23651 @itemx target extended-remote @code{udp:[@var{host}]:@var{port}}
   23652 @itemx target extended-remote @code{udp4:@var{host}:@var{port}}
   23653 @itemx target extended-remote @code{udp6:@var{host}:@var{port}}
   23654 @itemx target extended-remote @code{udp6:[@var{host}]:@var{port}}
   23655 @cindex @acronym{UDP} port, @code{target remote}
   23656 Debug using @acronym{UDP} packets to @var{port} on @var{host}.  For example, to
   23657 connect to @acronym{UDP} port 2828 on a terminal server named @code{manyfarms}:
   23658 
   23659 @smallexample
   23660 target remote udp:manyfarms:2828
   23661 @end smallexample
   23662 
   23663 When using a @acronym{UDP} connection for remote debugging, you should
   23664 keep in mind that the `U' stands for ``Unreliable''.  @acronym{UDP}
   23665 can silently drop packets on busy or unreliable networks, which will
   23666 cause havoc with your debugging session.
   23667 
   23668 @item target remote | @var{command}
   23669 @itemx target extended-remote | @var{command}
   23670 @cindex pipe, @code{target remote} to
   23671 Run @var{command} in the background and communicate with it using a
   23672 pipe.  The @var{command} is a shell command, to be parsed and expanded
   23673 by the system's command shell, @code{/bin/sh}; it should expect remote
   23674 protocol packets on its standard input, and send replies on its
   23675 standard output.  You could use this to run a stand-alone simulator
   23676 that speaks the remote debugging protocol, to make net connections
   23677 using programs like @code{ssh}, or for other similar tricks.
   23678 
   23679 If @var{command} closes its standard output (perhaps by exiting),
   23680 @value{GDBN} will try to send it a @code{SIGTERM} signal.  (If the
   23681 program has already exited, this will have no effect.)
   23682 
   23683 @end table
   23684 
   23685 @cindex interrupting remote programs
   23686 @cindex remote programs, interrupting
   23687 Whenever @value{GDBN} is waiting for the remote program, if you type the
   23688 interrupt character (often @kbd{Ctrl-c}), @value{GDBN} attempts to stop the
   23689 program.  This may or may not succeed, depending in part on the hardware
   23690 and the serial drivers the remote system uses.  If you type the
   23691 interrupt character once again, @value{GDBN} displays this prompt:
   23692 
   23693 @smallexample
   23694 Interrupted while waiting for the program.
   23695 Give up (and stop debugging it)?  (y or n)
   23696 @end smallexample
   23697 
   23698 In @code{target remote} mode, if you type @kbd{y}, @value{GDBN} abandons
   23699 the remote debugging session.  (If you decide you want to try again later,
   23700 you can use @kbd{target remote} again to connect once more.)  If you type
   23701 @kbd{n}, @value{GDBN} goes back to waiting.
   23702 
   23703 In @code{target extended-remote} mode, typing @kbd{n} will leave
   23704 @value{GDBN} connected to the target.
   23705 
   23706 @table @code
   23707 @kindex detach (remote)
   23708 @item detach
   23709 When you have finished debugging the remote program, you can use the
   23710 @code{detach} command to release it from @value{GDBN} control.
   23711 Detaching from the target normally resumes its execution, but the results
   23712 will depend on your particular remote stub.  After the @code{detach}
   23713 command in @code{target remote} mode, @value{GDBN} is free to connect to
   23714 another target.  In @code{target extended-remote} mode, @value{GDBN} is
   23715 still connected to the target.
   23716 
   23717 @kindex disconnect
   23718 @item disconnect
   23719 The @code{disconnect} command closes the connection to the target, and
   23720 the target is generally not resumed.  It will wait for @value{GDBN}
   23721 (this instance or another one) to connect and continue debugging.  After
   23722 the @code{disconnect} command, @value{GDBN} is again free to connect to
   23723 another target.
   23724 
   23725 @cindex send command to remote monitor
   23726 @cindex extend @value{GDBN} for remote targets
   23727 @cindex add new commands for external monitor
   23728 @kindex monitor
   23729 @item monitor @var{cmd}
   23730 This command allows you to send arbitrary commands directly to the
   23731 remote monitor.  Since @value{GDBN} doesn't care about the commands it
   23732 sends like this, this command is the way to extend @value{GDBN}---you
   23733 can add new commands that only the external monitor will understand
   23734 and implement.
   23735 @end table
   23736 
   23737 @node File Transfer
   23738 @section Sending files to a remote system
   23739 @cindex remote target, file transfer
   23740 @cindex file transfer
   23741 @cindex sending files to remote systems
   23742 
   23743 Some remote targets offer the ability to transfer files over the same
   23744 connection used to communicate with @value{GDBN}.  This is convenient
   23745 for targets accessible through other means, e.g.@: @sc{gnu}/Linux systems
   23746 running @code{gdbserver} over a network interface.  For other targets,
   23747 e.g.@: embedded devices with only a single serial port, this may be
   23748 the only way to upload or download files.
   23749 
   23750 Not all remote targets support these commands.
   23751 
   23752 @table @code
   23753 @kindex remote put
   23754 @item remote put @var{hostfile} @var{targetfile}
   23755 Copy file @var{hostfile} from the host system (the machine running
   23756 @value{GDBN}) to @var{targetfile} on the target system.
   23757 
   23758 @kindex remote get
   23759 @item remote get @var{targetfile} @var{hostfile}
   23760 Copy file @var{targetfile} from the target system to @var{hostfile}
   23761 on the host system.
   23762 
   23763 @kindex remote delete
   23764 @item remote delete @var{targetfile}
   23765 Delete @var{targetfile} from the target system.
   23766 
   23767 @end table
   23768 
   23769 @node Server
   23770 @section Using the @code{gdbserver} Program
   23771 
   23772 @kindex gdbserver
   23773 @cindex remote connection without stubs
   23774 @code{gdbserver} is a control program for Unix-like systems, which
   23775 allows you to connect your program with a remote @value{GDBN} via
   23776 @code{target remote} or @code{target extended-remote}---but without
   23777 linking in the usual debugging stub.
   23778 
   23779 @code{gdbserver} is not a complete replacement for the debugging stubs,
   23780 because it requires essentially the same operating-system facilities
   23781 that @value{GDBN} itself does.  In fact, a system that can run
   23782 @code{gdbserver} to connect to a remote @value{GDBN} could also run
   23783 @value{GDBN} locally!  @code{gdbserver} is sometimes useful nevertheless,
   23784 because it is a much smaller program than @value{GDBN} itself.  It is
   23785 also easier to port than all of @value{GDBN}, so you may be able to get
   23786 started more quickly on a new system by using @code{gdbserver}.
   23787 Finally, if you develop code for real-time systems, you may find that
   23788 the tradeoffs involved in real-time operation make it more convenient to
   23789 do as much development work as possible on another system, for example
   23790 by cross-compiling.  You can use @code{gdbserver} to make a similar
   23791 choice for debugging.
   23792 
   23793 @value{GDBN} and @code{gdbserver} communicate via either a serial line
   23794 or a TCP connection, using the standard @value{GDBN} remote serial
   23795 protocol.
   23796 
   23797 @quotation
   23798 @emph{Warning:} @code{gdbserver} does not have any built-in security.
   23799 Do not run @code{gdbserver} connected to any public network; a
   23800 @value{GDBN} connection to @code{gdbserver} provides access to the
   23801 target system with the same privileges as the user running
   23802 @code{gdbserver}.
   23803 @end quotation
   23804 
   23805 @anchor{Running gdbserver}
   23806 @subsection Running @code{gdbserver}
   23807 @cindex arguments, to @code{gdbserver}
   23808 @cindex @code{gdbserver}, command-line arguments
   23809 
   23810 Run @code{gdbserver} on the target system.  You need a copy of the
   23811 program you want to debug, including any libraries it requires.
   23812 @code{gdbserver} does not need your program's symbol table, so you can
   23813 strip the program if necessary to save space.  @value{GDBN} on the host
   23814 system does all the symbol handling.
   23815 
   23816 To use the server, you must tell it how to communicate with @value{GDBN};
   23817 the name of your program; and the arguments for your program.  The usual
   23818 syntax is:
   23819 
   23820 @smallexample
   23821 target> gdbserver @var{comm} @var{program} [ @var{args} @dots{} ]
   23822 @end smallexample
   23823 
   23824 @var{comm} is either a device name (to use a serial line), or a TCP
   23825 hostname and portnumber, or @code{-} or @code{stdio} to use
   23826 stdin/stdout of @code{gdbserver}.
   23827 For example, to debug Emacs with the argument
   23828 @samp{foo.txt} and communicate with @value{GDBN} over the serial port
   23829 @file{/dev/com1}:
   23830 
   23831 @smallexample
   23832 target> gdbserver /dev/com1 emacs foo.txt
   23833 @end smallexample
   23834 
   23835 @code{gdbserver} waits passively for the host @value{GDBN} to communicate
   23836 with it.
   23837 
   23838 To use a TCP connection instead of a serial line:
   23839 
   23840 @smallexample
   23841 target> gdbserver host:2345 emacs foo.txt
   23842 @end smallexample
   23843 
   23844 The only difference from the previous example is the first argument,
   23845 specifying that you are communicating with the host @value{GDBN} via
   23846 TCP.  The @samp{host:2345} argument means that @code{gdbserver} is to
   23847 expect a TCP connection from machine @samp{host} to local TCP port 2345.
   23848 (Currently, the @samp{host} part is ignored.)  You can choose any number
   23849 you want for the port number as long as it does not conflict with any
   23850 TCP ports already in use on the target system (for example, @code{23} is
   23851 reserved for @code{telnet}).@footnote{If you choose a port number that
   23852 conflicts with another service, @code{gdbserver} prints an error message
   23853 and exits.}  You must use the same port number with the host @value{GDBN}
   23854 @code{target remote} command.
   23855 
   23856 The @code{stdio} connection is useful when starting @code{gdbserver}
   23857 with ssh:
   23858 
   23859 @smallexample
   23860 (@value{GDBP}) target remote | ssh -T hostname gdbserver - hello
   23861 @end smallexample
   23862 
   23863 The @samp{-T} option to ssh is provided because we don't need a remote pty,
   23864 and we don't want escape-character handling.  Ssh does this by default when
   23865 a command is provided, the flag is provided to make it explicit.
   23866 You could elide it if you want to.
   23867 
   23868 Programs started with stdio-connected gdbserver have @file{/dev/null} for
   23869 @code{stdin}, and @code{stdout},@code{stderr} are sent back to gdb for
   23870 display through a pipe connected to gdbserver.
   23871 Both @code{stdout} and @code{stderr} use the same pipe.
   23872 
   23873 @anchor{Attaching to a program}
   23874 @subsubsection Attaching to a Running Program
   23875 @cindex attach to a program, @code{gdbserver}
   23876 @cindex @option{--attach}, @code{gdbserver} option
   23877 
   23878 On some targets, @code{gdbserver} can also attach to running programs.
   23879 This is accomplished via the @code{--attach} argument.  The syntax is:
   23880 
   23881 @smallexample
   23882 target> gdbserver --attach @var{comm} @var{pid}
   23883 @end smallexample
   23884 
   23885 @var{pid} is the process ID of a currently running process.  It isn't
   23886 necessary to point @code{gdbserver} at a binary for the running process.
   23887 
   23888 In @code{target extended-remote} mode, you can also attach using the
   23889 @value{GDBN} attach command
   23890 (@pxref{Attaching in Types of Remote Connections}).
   23891 
   23892 @pindex pidof
   23893 You can debug processes by name instead of process ID if your target has the
   23894 @code{pidof} utility:
   23895 
   23896 @smallexample
   23897 target> gdbserver --attach @var{comm} `pidof @var{program}`
   23898 @end smallexample
   23899 
   23900 In case more than one copy of @var{program} is running, or @var{program}
   23901 has multiple threads, most versions of @code{pidof} support the
   23902 @code{-s} option to only return the first process ID.
   23903 
   23904 @subsubsection TCP port allocation lifecycle of @code{gdbserver}
   23905 
   23906 This section applies only when @code{gdbserver} is run to listen on a TCP
   23907 port.
   23908 
   23909 @code{gdbserver} normally terminates after all of its debugged processes have
   23910 terminated in @kbd{target remote} mode.  On the other hand, for @kbd{target
   23911 extended-remote}, @code{gdbserver} stays running even with no processes left.
   23912 @value{GDBN} normally terminates the spawned debugged process on its exit,
   23913 which normally also terminates @code{gdbserver} in the @kbd{target remote}
   23914 mode.  Therefore, when the connection drops unexpectedly, and @value{GDBN}
   23915 cannot ask @code{gdbserver} to kill its debugged processes, @code{gdbserver}
   23916 stays running even in the @kbd{target remote} mode.
   23917 
   23918 When @code{gdbserver} stays running, @value{GDBN} can connect to it again later.
   23919 Such reconnecting is useful for features like @ref{disconnected tracing}.  For
   23920 completeness, at most one @value{GDBN} can be connected at a time.
   23921 
   23922 @cindex @option{--once}, @code{gdbserver} option
   23923 By default, @code{gdbserver} keeps the listening TCP port open, so that
   23924 subsequent connections are possible.  However, if you start @code{gdbserver}
   23925 with the @option{--once} option, it will stop listening for any further
   23926 connection attempts after connecting to the first @value{GDBN} session.  This
   23927 means no further connections to @code{gdbserver} will be possible after the
   23928 first one.  It also means @code{gdbserver} will terminate after the first
   23929 connection with remote @value{GDBN} has closed, even for unexpectedly closed
   23930 connections and even in the @kbd{target extended-remote} mode.  The
   23931 @option{--once} option allows reusing the same port number for connecting to
   23932 multiple instances of @code{gdbserver} running on the same host, since each
   23933 instance closes its port after the first connection.
   23934 
   23935 @anchor{Other Command-Line Arguments for gdbserver}
   23936 @subsubsection Other Command-Line Arguments for @code{gdbserver}
   23937 
   23938 You can use the @option{--multi} option to start @code{gdbserver} without
   23939 specifying a program to debug or a process to attach to.  Then you can
   23940 attach in @code{target extended-remote} mode and run or attach to a
   23941 program.  For more information,
   23942 @pxref{--multi Option in Types of Remote Connnections}.
   23943 
   23944 @cindex @option{--debug}, @code{gdbserver} option
   23945 The @option{--debug[=option1,option2,@dots{}]} option tells
   23946 @code{gdbserver} to display extra diagnostic information about the
   23947 debugging process.  The options (@var{option1}, @var{option2}, etc)
   23948 control for which areas of @code{gdbserver} additional information
   23949 will be displayed, possible values are:
   23950 
   23951 @table @code
   23952 @item all
   23953 This enables all available diagnostic output.
   23954 @item threads
   23955 This enables diagnostic output related to threading.  Currently other
   23956 general diagnostic output is included in this category, but this could
   23957 change in future releases of @code{gdbserver}.
   23958 @item event-loop
   23959 This enables event-loop specific diagnostic output.
   23960 @item remote
   23961 This enables diagnostic output related to the transfer of remote
   23962 protocol packets too and from the debugger.
   23963 @end table
   23964 
   23965 @noindent
   23966 If no options are passed to @option{--debug} then this is treated as
   23967 equivalent to @option{--debug=threads}.  This could change in future
   23968 releases of @code{gdbserver}.  The options passed to @option{--debug}
   23969 are processed left to right, and individual options can be prefixed
   23970 with the @kbd{-} (minus) character to disable diagnostic output from
   23971 this area, so it is possible to use:
   23972 
   23973 @smallexample
   23974   target> gdbserver --debug=all,-event-loop
   23975 @end smallexample
   23976 
   23977 @noindent
   23978 In order to enable all diagnostic output except that for the
   23979 event-loop.
   23980 
   23981 @cindex @option{--debug-file}, @code{gdbserver} option
   23982 @cindex @code{gdbserver}, send all debug output to a single file
   23983 The @option{--debug-file=@var{filename}} option tells @code{gdbserver} to
   23984 write any debug output to the given @var{filename}.  These options are intended
   23985 for @code{gdbserver} development and for bug reports to the developers.
   23986 
   23987 @cindex @option{--debug-format}, @code{gdbserver} option
   23988 The @option{--debug-format=option1[,option2,...]} option tells
   23989 @code{gdbserver} to include additional information in each output.
   23990 Possible options are:
   23991 
   23992 @table @code
   23993 @item none
   23994 Turn off all extra information in debugging output.
   23995 @item all
   23996 Turn on all extra information in debugging output.
   23997 @item timestamps
   23998 Include a timestamp in each line of debugging output.
   23999 @end table
   24000 
   24001 Options are processed in order.  Thus, for example, if @option{none}
   24002 appears last then no additional information is added to debugging output.
   24003 
   24004 @cindex @option{--wrapper}, @code{gdbserver} option
   24005 The @option{--wrapper} option specifies a wrapper to launch programs
   24006 for debugging.  The option should be followed by the name of the
   24007 wrapper, then any command-line arguments to pass to the wrapper, then
   24008 @kbd{--} indicating the end of the wrapper arguments.
   24009 
   24010 @code{gdbserver} runs the specified wrapper program with a combined
   24011 command line including the wrapper arguments, then the name of the
   24012 program to debug, then any arguments to the program.  The wrapper
   24013 runs until it executes your program, and then @value{GDBN} gains control.
   24014 
   24015 You can use any program that eventually calls @code{execve} with
   24016 its arguments as a wrapper.  Several standard Unix utilities do
   24017 this, e.g.@: @code{env} and @code{nohup}.  Any Unix shell script ending
   24018 with @code{exec "$@@"} will also work.
   24019 
   24020 For example, you can use @code{env} to pass an environment variable to
   24021 the debugged program, without setting the variable in @code{gdbserver}'s
   24022 environment:
   24023 
   24024 @smallexample
   24025 $ gdbserver --wrapper env LD_PRELOAD=libtest.so -- :2222 ./testprog
   24026 @end smallexample
   24027 
   24028 @cindex @option{--selftest}
   24029 The @option{--selftest} option runs the self tests in @code{gdbserver}:
   24030 
   24031 @smallexample
   24032 $ gdbserver --selftest
   24033 Ran 2 unit tests, 0 failed
   24034 @end smallexample
   24035 
   24036 These tests are disabled in release.
   24037 @subsection Connecting to @code{gdbserver}
   24038 
   24039 The basic procedure for connecting to the remote target is:
   24040 @itemize
   24041 
   24042 @item
   24043 Run @value{GDBN} on the host system.
   24044 
   24045 @item
   24046 Make sure you have the necessary symbol files
   24047 (@pxref{Host and target files}).
   24048 Load symbols for your application using the @code{file} command before you
   24049 connect.  Use @code{set sysroot} to locate target libraries (unless your
   24050 @value{GDBN} was compiled with the correct sysroot using
   24051 @code{--with-sysroot}).
   24052 
   24053 @item
   24054 Connect to your target (@pxref{Connecting,,Connecting to a Remote Target}).
   24055 For TCP connections, you must start up @code{gdbserver} prior to using
   24056 the @code{target} command.  Otherwise you may get an error whose
   24057 text depends on the host system, but which usually looks something like
   24058 @samp{Connection refused}.  Don't use the @code{load}
   24059 command in @value{GDBN} when using @code{target remote} mode, since the
   24060 program is already on the target.
   24061 
   24062 @end itemize
   24063 
   24064 @anchor{Monitor Commands for gdbserver}
   24065 @subsection Monitor Commands for @code{gdbserver}
   24066 @cindex monitor commands, for @code{gdbserver}
   24067 
   24068 During a @value{GDBN} session using @code{gdbserver}, you can use the
   24069 @code{monitor} command to send special requests to @code{gdbserver}.
   24070 Here are the available commands.
   24071 
   24072 @table @code
   24073 @item monitor help
   24074 List the available monitor commands.
   24075 
   24076 @item monitor set debug off
   24077 Disable all internal logging from gdbserver.
   24078 
   24079 @item monitor set debug on
   24080 Enable some general logging from within gdbserver.  Currently this is
   24081 equivalent to @kbd{monitor set debug threads on}, but this might
   24082 change in future releases of gdbserver.
   24083 
   24084 @item monitor set debug threads off
   24085 @itemx monitor set debug threads on
   24086 Disable or enable specific logging messages associated with thread
   24087 handling in gdbserver.  Currently this category also includes
   24088 additional output not specifically related to thread handling, this
   24089 could change in future releases of gdbserver.
   24090 
   24091 @item monitor set debug remote off
   24092 @itemx monitor set debug remote on
   24093 Disable or enable specific logging messages associated with the remote
   24094 protocol (@pxref{Remote Protocol}).
   24095 
   24096 @item monitor set debug event-loop off
   24097 @itemx monitor set debug event-loop on
   24098 Disable or enable specific logging messages associated with
   24099 gdbserver's event-loop.
   24100 
   24101 @item monitor set debug-file filename
   24102 @itemx monitor set debug-file
   24103 Send any debug output to the given file, or to stderr.
   24104 
   24105 @item monitor set debug-format option1@r{[},option2,...@r{]}
   24106 Specify additional text to add to debugging messages.
   24107 Possible options are:
   24108 
   24109 @table @code
   24110 @item none
   24111 Turn off all extra information in debugging output.
   24112 @item all
   24113 Turn on all extra information in debugging output.
   24114 @item timestamps
   24115 Include a timestamp in each line of debugging output.
   24116 @end table
   24117 
   24118 Options are processed in order.  Thus, for example, if @option{none}
   24119 appears last then no additional information is added to debugging output.
   24120 
   24121 @item monitor set libthread-db-search-path [PATH]
   24122 @cindex gdbserver, search path for @code{libthread_db}
   24123 When this command is issued, @var{path} is a colon-separated list of
   24124 directories to search for @code{libthread_db} (@pxref{Threads,,set
   24125 libthread-db-search-path}).  If you omit @var{path},
   24126 @samp{libthread-db-search-path} will be reset to its default value.
   24127 
   24128 The special entry @samp{$pdir} for @samp{libthread-db-search-path} is
   24129 not supported in @code{gdbserver}.
   24130 
   24131 @item monitor exit
   24132 Tell gdbserver to exit immediately.  This command should be followed by
   24133 @code{disconnect} to close the debugging session.  @code{gdbserver} will
   24134 detach from any attached processes and kill any processes it created.
   24135 Use @code{monitor exit} to terminate @code{gdbserver} at the end
   24136 of a multi-process mode debug session.
   24137 
   24138 @end table
   24139 
   24140 @subsection Tracepoints support in @code{gdbserver}
   24141 @cindex tracepoints support in @code{gdbserver}
   24142 
   24143 On some targets, @code{gdbserver} supports tracepoints, fast
   24144 tracepoints and static tracepoints.
   24145 
   24146 For fast or static tracepoints to work, a special library called the
   24147 @dfn{in-process agent} (IPA), must be loaded in the inferior process.
   24148 This library is built and distributed as an integral part of
   24149 @code{gdbserver}.  In addition, support for static tracepoints
   24150 requires building the in-process agent library with static tracepoints
   24151 support.  At present, the UST (LTTng Userspace Tracer,
   24152 @url{http://lttng.org/ust}) tracing engine is supported.  This support
   24153 is automatically available if UST development headers are found in the
   24154 standard include path when @code{gdbserver} is built, or if
   24155 @code{gdbserver} was explicitly configured using @option{--with-ust}
   24156 to point at such headers.  You can explicitly disable the support
   24157 using @option{--with-ust=no}.
   24158 
   24159 There are several ways to load the in-process agent in your program:
   24160 
   24161 @table @code
   24162 @item Specifying it as dependency at link time
   24163 
   24164 You can link your program dynamically with the in-process agent
   24165 library.  On most systems, this is accomplished by adding
   24166 @code{-linproctrace} to the link command.
   24167 
   24168 @item Using the system's preloading mechanisms
   24169 
   24170 You can force loading the in-process agent at startup time by using
   24171 your system's support for preloading shared libraries.  Many Unixes
   24172 support the concept of preloading user defined libraries.  In most
   24173 cases, you do that by specifying @code{LD_PRELOAD=libinproctrace.so}
   24174 in the environment.  See also the description of @code{gdbserver}'s
   24175 @option{--wrapper} command line option.
   24176 
   24177 @item Using @value{GDBN} to force loading the agent at run time
   24178 
   24179 On some systems, you can force the inferior to load a shared library,
   24180 by calling a dynamic loader function in the inferior that takes care
   24181 of dynamically looking up and loading a shared library.  On most Unix
   24182 systems, the function is @code{dlopen}.  You'll use the @code{call}
   24183 command for that.  For example:
   24184 
   24185 @smallexample
   24186 (@value{GDBP}) call dlopen ("libinproctrace.so", ...)
   24187 @end smallexample
   24188 
   24189 Note that on most Unix systems, for the @code{dlopen} function to be
   24190 available, the program needs to be linked with @code{-ldl}.
   24191 @end table
   24192 
   24193 On systems that have a userspace dynamic loader, like most Unix
   24194 systems, when you connect to @code{gdbserver} using @code{target
   24195 remote}, you'll find that the program is stopped at the dynamic
   24196 loader's entry point, and no shared library has been loaded in the
   24197 program's address space yet, including the in-process agent.  In that
   24198 case, before being able to use any of the fast or static tracepoints
   24199 features, you need to let the loader run and load the shared
   24200 libraries.  The simplest way to do that is to run the program to the
   24201 main procedure.  E.g., if debugging a C or C@t{++} program, start
   24202 @code{gdbserver} like so:
   24203 
   24204 @smallexample
   24205 $ gdbserver :9999 myprogram
   24206 @end smallexample
   24207 
   24208 Start GDB and connect to @code{gdbserver} like so, and run to main:
   24209 
   24210 @smallexample
   24211 $ gdb myprogram
   24212 (@value{GDBP}) target remote myhost:9999
   24213 0x00007f215893ba60 in ?? () from /lib64/ld-linux-x86-64.so.2
   24214 (@value{GDBP}) b main
   24215 (@value{GDBP}) continue
   24216 @end smallexample
   24217 
   24218 The in-process tracing agent library should now be loaded into the
   24219 process; you can confirm it with the @code{info sharedlibrary}
   24220 command, which will list @file{libinproctrace.so} as loaded in the
   24221 process.  You are now ready to install fast tracepoints, list static
   24222 tracepoint markers, probe static tracepoints markers, and start
   24223 tracing.
   24224 
   24225 @node Remote Configuration
   24226 @section Remote Configuration
   24227 
   24228 @kindex set remote
   24229 @kindex show remote
   24230 This section documents the configuration options available when
   24231 debugging remote programs.  For the options related to the File I/O
   24232 extensions of the remote protocol, see @ref{system,
   24233 system-call-allowed}.
   24234 
   24235 @table @code
   24236 @item set remoteaddresssize @var{bits}
   24237 @cindex address size for remote targets
   24238 @cindex bits in remote address
   24239 Set the maximum size of address in a memory packet to the specified
   24240 number of bits.  @value{GDBN} will mask off the address bits above
   24241 that number, when it passes addresses to the remote target.  The
   24242 default value is the number of bits in the target's address.
   24243 
   24244 @item show remoteaddresssize
   24245 Show the current value of remote address size in bits.
   24246 
   24247 @item set serial baud @var{n}
   24248 @cindex baud rate for remote targets
   24249 Set the baud rate for the remote serial I/O to @var{n} baud.  The
   24250 value is used to set the speed of the serial port used for debugging
   24251 remote targets.
   24252 
   24253 @item show serial baud
   24254 Show the current speed of the remote connection.
   24255 
   24256 @item set serial parity @var{parity}
   24257 Set the parity for the remote serial I/O.  Supported values of @var{parity} are:
   24258 @code{even}, @code{none}, and @code{odd}.  The default is @code{none}.
   24259 
   24260 @item show serial parity
   24261 Show the current parity of the serial port.
   24262 
   24263 @item set remotebreak
   24264 @cindex interrupt remote programs
   24265 @cindex BREAK signal instead of Ctrl-C
   24266 @anchor{set remotebreak}
   24267 If set to on, @value{GDBN} sends a @code{BREAK} signal to the remote
   24268 when you type @kbd{Ctrl-c} to interrupt the program running
   24269 on the remote.  If set to off, @value{GDBN} sends the @samp{Ctrl-C}
   24270 character instead.  The default is off, since most remote systems
   24271 expect to see @samp{Ctrl-C} as the interrupt signal.
   24272 
   24273 @item show remotebreak
   24274 Show whether @value{GDBN} sends @code{BREAK} or @samp{Ctrl-C} to
   24275 interrupt the remote program.
   24276 
   24277 @item set remoteflow on
   24278 @itemx set remoteflow off
   24279 @kindex set remoteflow
   24280 Enable or disable hardware flow control (@code{RTS}/@code{CTS})
   24281 on the serial port used to communicate to the remote target.
   24282 
   24283 @item show remoteflow
   24284 @kindex show remoteflow
   24285 Show the current setting of hardware flow control.
   24286 
   24287 @item set remotelogbase @var{base}
   24288 Set the base (a.k.a.@: radix) of logging serial protocol
   24289 communications to @var{base}.  Supported values of @var{base} are:
   24290 @code{ascii}, @code{octal}, and @code{hex}.  The default is
   24291 @code{ascii}.
   24292 
   24293 @item show remotelogbase
   24294 Show the current setting of the radix for logging remote serial
   24295 protocol.
   24296 
   24297 @item set remotelogfile @var{file}
   24298 @cindex record serial communications on file
   24299 Record remote serial communications on the named @var{file}.  The
   24300 default is not to record at all.
   24301 
   24302 @item show remotelogfile
   24303 Show the current setting  of the file name on which to record the
   24304 serial communications.
   24305 
   24306 @item set remotetimeout @var{num}
   24307 @cindex timeout for serial communications
   24308 @cindex remote timeout
   24309 Set the timeout limit to wait for the remote target to respond to
   24310 @var{num} seconds.  The default is 2 seconds.
   24311 
   24312 @item show remotetimeout
   24313 Show the current number of seconds to wait for the remote target
   24314 responses.
   24315 
   24316 @cindex limit hardware breakpoints and watchpoints
   24317 @cindex remote target, limit break- and watchpoints
   24318 @anchor{set remote hardware-watchpoint-limit}
   24319 @anchor{set remote hardware-breakpoint-limit}
   24320 @item set remote hardware-watchpoint-limit @var{limit}
   24321 @itemx set remote hardware-breakpoint-limit @var{limit}
   24322 Restrict @value{GDBN} to using @var{limit} remote hardware watchpoints
   24323 or breakpoints.  The @var{limit} can be set to 0 to disable hardware
   24324 watchpoints or breakpoints, and @code{unlimited} for unlimited
   24325 watchpoints or breakpoints.
   24326 
   24327 @item show remote hardware-watchpoint-limit
   24328 @itemx show remote hardware-breakpoint-limit
   24329 Show the current limit for the number of hardware watchpoints or
   24330 breakpoints that @value{GDBN} can use.
   24331 
   24332 @cindex limit hardware watchpoints length
   24333 @cindex remote target, limit watchpoints length
   24334 @anchor{set remote hardware-watchpoint-length-limit}
   24335 @item set remote hardware-watchpoint-length-limit @var{limit}
   24336 Restrict @value{GDBN} to using @var{limit} bytes for the maximum
   24337 length of a remote hardware watchpoint.  A @var{limit} of 0 disables
   24338 hardware watchpoints and @code{unlimited} allows watchpoints of any
   24339 length.
   24340 
   24341 @item show remote hardware-watchpoint-length-limit
   24342 Show the current limit (in bytes) of the maximum length of
   24343 a remote hardware watchpoint.
   24344 
   24345 @item set remote exec-file @var{filename}
   24346 @itemx show remote exec-file
   24347 @anchor{set remote exec-file}
   24348 @cindex executable file, for remote target
   24349 Select the file used for @code{run} with @code{target
   24350 extended-remote}.  This should be set to a filename valid on the
   24351 target system.  If it is not set, the target will use a default
   24352 filename (e.g.@: the last program run).
   24353 
   24354 @item set remote interrupt-sequence
   24355 @cindex interrupt remote programs
   24356 @cindex select Ctrl-C, BREAK or BREAK-g
   24357 Allow the user to select one of @samp{Ctrl-C}, a @code{BREAK} or
   24358 @samp{BREAK-g} as the
   24359 sequence to the remote target in order to interrupt the execution.
   24360 @samp{Ctrl-C} is a default.  Some system prefers @code{BREAK} which
   24361 is high level of serial line for some certain time.
   24362 Linux kernel prefers @samp{BREAK-g}, a.k.a Magic SysRq g.
   24363 It is @code{BREAK} signal followed by character @code{g}.
   24364 
   24365 @item show remote interrupt-sequence
   24366 Show which of @samp{Ctrl-C}, @code{BREAK} or @code{BREAK-g}
   24367 is sent by @value{GDBN} to interrupt the remote program.
   24368 @code{BREAK-g} is BREAK signal followed by @code{g} and
   24369 also known as Magic SysRq g.
   24370 
   24371 @item set remote interrupt-on-connect
   24372 @cindex send interrupt-sequence on start
   24373 Specify whether interrupt-sequence is sent to remote target when
   24374 @value{GDBN} connects to it.  This is mostly needed when you debug
   24375 Linux kernel.  Linux kernel expects @code{BREAK} followed by @code{g}
   24376 which is known as Magic SysRq g in order to connect @value{GDBN}.
   24377 
   24378 @item show remote interrupt-on-connect
   24379 Show whether interrupt-sequence is sent
   24380 to remote target when @value{GDBN} connects to it.
   24381 
   24382 @kindex set tcp
   24383 @kindex show tcp
   24384 @item set tcp auto-retry on
   24385 @cindex auto-retry, for remote TCP target
   24386 Enable auto-retry for remote TCP connections.  This is useful if the remote
   24387 debugging agent is launched in parallel with @value{GDBN}; there is a race
   24388 condition because the agent may not become ready to accept the connection
   24389 before @value{GDBN} attempts to connect.  When auto-retry is
   24390 enabled, if the initial attempt to connect fails, @value{GDBN} reattempts
   24391 to establish the connection using the timeout specified by 
   24392 @code{set tcp connect-timeout}.
   24393 
   24394 @item set tcp auto-retry off
   24395 Do not auto-retry failed TCP connections.
   24396 
   24397 @item show tcp auto-retry
   24398 Show the current auto-retry setting.
   24399 
   24400 @item set tcp connect-timeout @var{seconds}
   24401 @itemx set tcp connect-timeout unlimited
   24402 @cindex connection timeout, for remote TCP target
   24403 @cindex timeout, for remote target connection
   24404 Set the timeout for establishing a TCP connection to the remote target to
   24405 @var{seconds}.  The timeout affects both polling to retry failed connections 
   24406 (enabled by @code{set tcp auto-retry on}) and waiting for connections
   24407 that are merely slow to complete, and represents an approximate cumulative
   24408 value.  If @var{seconds} is @code{unlimited}, there is no timeout and
   24409 @value{GDBN} will keep attempting to establish a connection forever,
   24410 unless interrupted with @kbd{Ctrl-c}.  The default is 15 seconds.
   24411 
   24412 @item show tcp connect-timeout
   24413 Show the current connection timeout setting.
   24414 @end table
   24415 
   24416 @cindex remote packets, enabling and disabling
   24417 The @value{GDBN} remote protocol autodetects the packets supported by
   24418 your debugging stub.  If you need to override the autodetection, you
   24419 can use these commands to enable or disable individual packets.  Each
   24420 packet can be set to @samp{on} (the remote target supports this
   24421 packet), @samp{off} (the remote target does not support this packet),
   24422 or @samp{auto} (detect remote target support for this packet).  They
   24423 all default to @samp{auto}.  For more information about each packet,
   24424 see @ref{Remote Protocol}.
   24425 
   24426 During normal use, you should not have to use any of these commands.
   24427 If you do, that may be a bug in your remote debugging stub, or a bug
   24428 in @value{GDBN}.  You may want to report the problem to the
   24429 @value{GDBN} developers.
   24430 
   24431 For each packet @var{name}, the command to enable or disable the
   24432 packet is @code{set remote @var{name}-packet}.  If you configure a packet, the
   24433 configuration will apply for all future remote targets if no target is selected.
   24434 In case there is a target selected, only the configuration of the current target
   24435 is changed.  All other existing remote targets' features are not affected.
   24436 The command to print the current configuration of a packet is
   24437 @code{show remote @var{name}-packet}.  It displays the current remote target's
   24438 configuration.  If no remote target is selected, the default configuration for
   24439 future connections is shown.  The available settings are:
   24440 
   24441 @multitable @columnfractions 0.28 0.32 0.25
   24442 @item Command Name
   24443 @tab Remote Packet
   24444 @tab Related Features
   24445 
   24446 @item @code{fetch-register}
   24447 @tab @code{p}
   24448 @tab @code{info registers}
   24449 
   24450 @item @code{set-register}
   24451 @tab @code{P}
   24452 @tab @code{set}
   24453 
   24454 @item @code{binary-download}
   24455 @tab @code{X}
   24456 @tab @code{load}, @code{set}
   24457 
   24458 @item @code{read-aux-vector}
   24459 @tab @code{qXfer:auxv:read}
   24460 @tab @code{info auxv}
   24461 
   24462 @item @code{symbol-lookup}
   24463 @tab @code{qSymbol}
   24464 @tab Detecting multiple threads
   24465 
   24466 @item @code{attach}
   24467 @tab @code{vAttach}
   24468 @tab @code{attach}
   24469 
   24470 @item @code{verbose-resume}
   24471 @tab @code{vCont}
   24472 @tab Stepping or resuming multiple threads
   24473 
   24474 @item @code{run}
   24475 @tab @code{vRun}
   24476 @tab @code{run}
   24477 
   24478 @item @code{software-breakpoint}
   24479 @tab @code{Z0}
   24480 @tab @code{break}
   24481 
   24482 @item @code{hardware-breakpoint}
   24483 @tab @code{Z1}
   24484 @tab @code{hbreak}
   24485 
   24486 @item @code{write-watchpoint}
   24487 @tab @code{Z2}
   24488 @tab @code{watch}
   24489 
   24490 @item @code{read-watchpoint}
   24491 @tab @code{Z3}
   24492 @tab @code{rwatch}
   24493 
   24494 @item @code{access-watchpoint}
   24495 @tab @code{Z4}
   24496 @tab @code{awatch}
   24497 
   24498 @item @code{pid-to-exec-file}
   24499 @tab @code{qXfer:exec-file:read}
   24500 @tab @code{attach}, @code{run}
   24501 
   24502 @item @code{target-features}
   24503 @tab @code{qXfer:features:read}
   24504 @tab @code{set architecture}
   24505 
   24506 @item @code{library-info}
   24507 @tab @code{qXfer:libraries:read}
   24508 @tab @code{info sharedlibrary}
   24509 
   24510 @item @code{memory-map}
   24511 @tab @code{qXfer:memory-map:read}
   24512 @tab @code{info mem}
   24513 
   24514 @item @code{read-sdata-object}
   24515 @tab @code{qXfer:sdata:read}
   24516 @tab @code{print $_sdata}
   24517 
   24518 @item @code{read-siginfo-object}
   24519 @tab @code{qXfer:siginfo:read}
   24520 @tab @code{print $_siginfo}
   24521 
   24522 @item @code{write-siginfo-object}
   24523 @tab @code{qXfer:siginfo:write}
   24524 @tab @code{set $_siginfo}
   24525 
   24526 @item @code{threads}
   24527 @tab @code{qXfer:threads:read}
   24528 @tab @code{info threads}
   24529 
   24530 @item @code{get-thread-local-@*storage-address}
   24531 @tab @code{qGetTLSAddr}
   24532 @tab Displaying @code{__thread} variables
   24533 
   24534 @item @code{get-thread-information-block-address}
   24535 @tab @code{qGetTIBAddr}
   24536 @tab Display MS-Windows Thread Information Block.
   24537 
   24538 @item @code{search-memory}
   24539 @tab @code{qSearch:memory}
   24540 @tab @code{find}
   24541 
   24542 @item @code{supported-packets}
   24543 @tab @code{qSupported}
   24544 @tab Remote communications parameters
   24545 
   24546 @item @code{catch-syscalls}
   24547 @tab @code{QCatchSyscalls}
   24548 @tab @code{catch syscall}
   24549 
   24550 @item @code{pass-signals}
   24551 @tab @code{QPassSignals}
   24552 @tab @code{handle @var{signal}}
   24553 
   24554 @item @code{program-signals}
   24555 @tab @code{QProgramSignals}
   24556 @tab @code{handle @var{signal}}
   24557 
   24558 @item @code{hostio-close-packet}
   24559 @tab @code{vFile:close}
   24560 @tab @code{remote get}, @code{remote put}
   24561 
   24562 @item @code{hostio-open-packet}
   24563 @tab @code{vFile:open}
   24564 @tab @code{remote get}, @code{remote put}
   24565 
   24566 @item @code{hostio-pread-packet}
   24567 @tab @code{vFile:pread}
   24568 @tab @code{remote get}, @code{remote put}
   24569 
   24570 @item @code{hostio-pwrite-packet}
   24571 @tab @code{vFile:pwrite}
   24572 @tab @code{remote get}, @code{remote put}
   24573 
   24574 @item @code{hostio-unlink-packet}
   24575 @tab @code{vFile:unlink}
   24576 @tab @code{remote delete}
   24577 
   24578 @item @code{hostio-readlink-packet}
   24579 @tab @code{vFile:readlink}
   24580 @tab Host I/O
   24581 
   24582 @item @code{hostio-fstat-packet}
   24583 @tab @code{vFile:fstat}
   24584 @tab Host I/O
   24585 
   24586 @item @code{hostio-stat-packet}
   24587 @tab @code{vFile:stat}
   24588 @tab Host I/O
   24589 
   24590 @item @code{hostio-setfs-packet}
   24591 @tab @code{vFile:setfs}
   24592 @tab Host I/O
   24593 
   24594 @item @code{noack-packet}
   24595 @tab @code{QStartNoAckMode}
   24596 @tab Packet acknowledgment
   24597 
   24598 @item @code{osdata}
   24599 @tab @code{qXfer:osdata:read}
   24600 @tab @code{info os}
   24601 
   24602 @item @code{query-attached}
   24603 @tab @code{qAttached}
   24604 @tab Querying remote process attach state.
   24605 
   24606 @item @code{trace-buffer-size}
   24607 @tab @code{QTBuffer:size}
   24608 @tab @code{set trace-buffer-size}
   24609 
   24610 @item @code{trace-status}
   24611 @tab @code{qTStatus}
   24612 @tab @code{tstatus}
   24613 
   24614 @item @code{traceframe-info}
   24615 @tab @code{qXfer:traceframe-info:read}
   24616 @tab Traceframe info
   24617 
   24618 @item @code{install-in-trace}
   24619 @tab @code{InstallInTrace}
   24620 @tab Install tracepoint in tracing
   24621 
   24622 @item @code{disable-randomization}
   24623 @tab @code{QDisableRandomization}
   24624 @tab @code{set disable-randomization}
   24625 
   24626 @item @code{startup-with-shell}
   24627 @tab @code{QStartupWithShell}
   24628 @tab @code{set startup-with-shell}
   24629 
   24630 @item @code{environment-hex-encoded}
   24631 @tab @code{QEnvironmentHexEncoded}
   24632 @tab @code{set environment}
   24633 
   24634 @item @code{environment-unset}
   24635 @tab @code{QEnvironmentUnset}
   24636 @tab @code{unset environment}
   24637 
   24638 @item @code{environment-reset}
   24639 @tab @code{QEnvironmentReset}
   24640 @tab @code{Reset the inferior environment (i.e., unset user-set variables)}
   24641 
   24642 @item @code{set-working-dir}
   24643 @tab @code{QSetWorkingDir}
   24644 @tab @code{set cwd}
   24645 
   24646 @item @code{conditional-breakpoints-packet}
   24647 @tab @code{Z0 and Z1}
   24648 @tab @code{Support for target-side breakpoint condition evaluation}
   24649 
   24650 @item @code{multiprocess-extensions}
   24651 @tab @code{multiprocess extensions}
   24652 @tab Debug multiple processes and remote process PID awareness
   24653 
   24654 @item @code{swbreak-feature}
   24655 @tab @code{swbreak stop reason}
   24656 @tab @code{break}
   24657 
   24658 @item @code{hwbreak-feature}
   24659 @tab @code{hwbreak stop reason}
   24660 @tab @code{hbreak}
   24661 
   24662 @item @code{fork-event-feature}
   24663 @tab @code{fork stop reason}
   24664 @tab @code{fork}
   24665 
   24666 @item @code{vfork-event-feature}
   24667 @tab @code{vfork stop reason}
   24668 @tab @code{vfork}
   24669 
   24670 @item @code{exec-event-feature}
   24671 @tab @code{exec stop reason}
   24672 @tab @code{exec}
   24673 
   24674 @item @code{thread-events}
   24675 @tab @code{QThreadEvents}
   24676 @tab Tracking thread lifetime.
   24677 
   24678 @item @code{thread-options}
   24679 @tab @code{QThreadOptions}
   24680 @tab Set thread event reporting options.
   24681 
   24682 @item @code{no-resumed-stop-reply}
   24683 @tab @code{no resumed thread left stop reply}
   24684 @tab Tracking thread lifetime.
   24685 
   24686 @end multitable
   24687 
   24688 @cindex packet size, remote, configuring
   24689 The number of bytes per memory-read or memory-write packet for a remote target
   24690 can be configured using the commands
   24691 @w{@code{set remote memory-read-packet-size}} and
   24692 @w{@code{set remote memory-write-packet-size}}.  If set to @samp{0} (zero) the
   24693 default packet size will be used.  The actual limit is further reduced depending
   24694 on the target.  Specify @samp{fixed} to disable the target-dependent restriction
   24695 and @samp{limit} to enable it.  Similar to the enabling and disabling of remote
   24696 packets, the command applies to the currently selected target (if available).
   24697 If no remote target is selected, it applies to all future remote connections.
   24698 The configuration of the selected target can be displayed using the commands
   24699 @w{@code{show remote memory-read-packet-size}} and
   24700 @w{@code{show remote memory-write-packet-size}}.  If no remote target is
   24701 selected, the default configuration for future connections is shown.
   24702 
   24703 @node Remote Stub
   24704 @section Implementing a Remote Stub
   24705 
   24706 @cindex debugging stub, example
   24707 @cindex remote stub, example
   24708 @cindex stub example, remote debugging
   24709 The stub files provided with @value{GDBN} implement the target side of the
   24710 communication protocol, and the @value{GDBN} side is implemented in the
   24711 @value{GDBN} source file @file{remote.c}.  Normally, you can simply allow
   24712 these subroutines to communicate, and ignore the details.  (If you're
   24713 implementing your own stub file, you can still ignore the details: start
   24714 with one of the existing stub files.  @file{sparc-stub.c} is the best
   24715 organized, and therefore the easiest to read.)
   24716 
   24717 @cindex remote serial debugging, overview
   24718 To debug a program running on another machine (the debugging
   24719 @dfn{target} machine), you must first arrange for all the usual
   24720 prerequisites for the program to run by itself.  For example, for a C
   24721 program, you need:
   24722 
   24723 @enumerate
   24724 @item
   24725 A startup routine to set up the C runtime environment; these usually
   24726 have a name like @file{crt0}.  The startup routine may be supplied by
   24727 your hardware supplier, or you may have to write your own.
   24728 
   24729 @item
   24730 A C subroutine library to support your program's
   24731 subroutine calls, notably managing input and output.
   24732 
   24733 @item
   24734 A way of getting your program to the other machine---for example, a
   24735 download program.  These are often supplied by the hardware
   24736 manufacturer, but you may have to write your own from hardware
   24737 documentation.
   24738 @end enumerate
   24739 
   24740 The next step is to arrange for your program to use a serial port to
   24741 communicate with the machine where @value{GDBN} is running (the @dfn{host}
   24742 machine).  In general terms, the scheme looks like this:
   24743 
   24744 @table @emph
   24745 @item On the host,
   24746 @value{GDBN} already understands how to use this protocol; when everything
   24747 else is set up, you can simply use the @samp{target remote} command
   24748 (@pxref{Targets,,Specifying a Debugging Target}).
   24749 
   24750 @item On the target,
   24751 you must link with your program a few special-purpose subroutines that
   24752 implement the @value{GDBN} remote serial protocol.  The file containing these
   24753 subroutines is called  a @dfn{debugging stub}.
   24754 
   24755 On certain remote targets, you can use an auxiliary program
   24756 @code{gdbserver} instead of linking a stub into your program.
   24757 @xref{Server,,Using the @code{gdbserver} Program}, for details.
   24758 @end table
   24759 
   24760 The debugging stub is specific to the architecture of the remote
   24761 machine; for example, use @file{sparc-stub.c} to debug programs on
   24762 @sc{sparc} boards.
   24763 
   24764 @cindex remote serial stub list
   24765 These working remote stubs are distributed with @value{GDBN}:
   24766 
   24767 @table @code
   24768 
   24769 @item i386-stub.c
   24770 @cindex @file{i386-stub.c}
   24771 @cindex Intel
   24772 @cindex i386
   24773 For Intel 386 and compatible architectures.
   24774 
   24775 @item m68k-stub.c
   24776 @cindex @file{m68k-stub.c}
   24777 @cindex Motorola 680x0
   24778 @cindex m680x0
   24779 For Motorola 680x0 architectures.
   24780 
   24781 @item sh-stub.c
   24782 @cindex @file{sh-stub.c}
   24783 @cindex Renesas
   24784 @cindex SH
   24785 For Renesas SH architectures.
   24786 
   24787 @item sparc-stub.c
   24788 @cindex @file{sparc-stub.c}
   24789 @cindex Sparc
   24790 For @sc{sparc} architectures.
   24791 
   24792 @item sparcl-stub.c
   24793 @cindex @file{sparcl-stub.c}
   24794 @cindex Fujitsu
   24795 @cindex SparcLite
   24796 For Fujitsu @sc{sparclite} architectures.
   24797 
   24798 @end table
   24799 
   24800 The @file{README} file in the @value{GDBN} distribution may list other
   24801 recently added stubs.
   24802 
   24803 @menu
   24804 * Stub Contents::       What the stub can do for you
   24805 * Bootstrapping::       What you must do for the stub
   24806 * Debug Session::       Putting it all together
   24807 @end menu
   24808 
   24809 @node Stub Contents
   24810 @subsection What the Stub Can Do for You
   24811 
   24812 @cindex remote serial stub
   24813 The debugging stub for your architecture supplies these three
   24814 subroutines:
   24815 
   24816 @table @code
   24817 @findex set_debug_traps
   24818 @item set_debug_traps
   24819 @cindex remote serial stub, initialization
   24820 This routine arranges for @code{handle_exception} to run when your
   24821 program stops.  You must call this subroutine explicitly in your
   24822 program's startup code.
   24823 
   24824 @findex handle_exception
   24825 @item handle_exception
   24826 @cindex remote serial stub, main routine
   24827 This is the central workhorse, but your program never calls it
   24828 explicitly---the setup code arranges for @code{handle_exception} to
   24829 run when a trap is triggered.
   24830 
   24831 @code{handle_exception} takes control when your program stops during
   24832 execution (for example, on a breakpoint), and mediates communications
   24833 with @value{GDBN} on the host machine.  This is where the communications
   24834 protocol is implemented; @code{handle_exception} acts as the @value{GDBN}
   24835 representative on the target machine.  It begins by sending summary
   24836 information on the state of your program, then continues to execute,
   24837 retrieving and transmitting any information @value{GDBN} needs, until you
   24838 execute a @value{GDBN} command that makes your program resume; at that point,
   24839 @code{handle_exception} returns control to your own code on the target
   24840 machine.
   24841 
   24842 @item breakpoint
   24843 @cindex @code{breakpoint} subroutine, remote
   24844 Use this auxiliary subroutine to make your program contain a
   24845 breakpoint.  Depending on the particular situation, this may be the only
   24846 way for @value{GDBN} to get control.  For instance, if your target
   24847 machine has some sort of interrupt button, you won't need to call this;
   24848 pressing the interrupt button transfers control to
   24849 @code{handle_exception}---in effect, to @value{GDBN}.  On some machines,
   24850 simply receiving characters on the serial port may also trigger a trap;
   24851 again, in that situation, you don't need to call @code{breakpoint} from
   24852 your own program---simply running @samp{target remote} from the host
   24853 @value{GDBN} session gets control.
   24854 
   24855 Call @code{breakpoint} if none of these is true, or if you simply want
   24856 to make certain your program stops at a predetermined point for the
   24857 start of your debugging session.
   24858 @end table
   24859 
   24860 @node Bootstrapping
   24861 @subsection What You Must Do for the Stub
   24862 
   24863 @cindex remote stub, support routines
   24864 The debugging stubs that come with @value{GDBN} are set up for a particular
   24865 chip architecture, but they have no information about the rest of your
   24866 debugging target machine.
   24867 
   24868 First of all you need to tell the stub how to communicate with the
   24869 serial port.
   24870 
   24871 @table @code
   24872 @findex getDebugChar
   24873 @item int getDebugChar()
   24874 Write this subroutine to read a single character from the serial port.
   24875 It may be identical to @code{getchar} for your target system; a
   24876 different name is used to allow you to distinguish the two if you wish.
   24877 
   24878 @findex putDebugChar
   24879 @item void putDebugChar(int)
   24880 Write this subroutine to write a single character to the serial port.
   24881 It may be identical to @code{putchar} for your target system; a
   24882 different name is used to allow you to distinguish the two if you wish.
   24883 @end table
   24884 
   24885 @cindex control C, and remote debugging
   24886 @cindex interrupting remote targets
   24887 If you want @value{GDBN} to be able to stop your program while it is
   24888 running, you need to use an interrupt-driven serial driver, and arrange
   24889 for it to stop when it receives a @code{^C} (@samp{\003}, the control-C
   24890 character).  That is the character which @value{GDBN} uses to tell the
   24891 remote system to stop.
   24892 
   24893 Getting the debugging target to return the proper status to @value{GDBN}
   24894 probably requires changes to the standard stub; one quick and dirty way
   24895 is to just execute a breakpoint instruction (the ``dirty'' part is that
   24896 @value{GDBN} reports a @code{SIGTRAP} instead of a @code{SIGINT}).
   24897 
   24898 Other routines you need to supply are:
   24899 
   24900 @table @code
   24901 @findex exceptionHandler
   24902 @item void exceptionHandler (int @var{exception_number}, void *@var{exception_address})
   24903 Write this function to install @var{exception_address} in the exception
   24904 handling tables.  You need to do this because the stub does not have any
   24905 way of knowing what the exception handling tables on your target system
   24906 are like (for example, the processor's table might be in @sc{rom},
   24907 containing entries which point to a table in @sc{ram}).
   24908 The @var{exception_number} specifies the exception which should be changed;
   24909 its meaning is architecture-dependent (for example, different numbers
   24910 might represent divide by zero, misaligned access, etc).  When this
   24911 exception occurs, control should be transferred directly to
   24912 @var{exception_address}, and the processor state (stack, registers,
   24913 and so on) should be just as it is when a processor exception occurs.  So if
   24914 you want to use a jump instruction to reach @var{exception_address}, it
   24915 should be a simple jump, not a jump to subroutine.
   24916 
   24917 For the 386, @var{exception_address} should be installed as an interrupt
   24918 gate so that interrupts are masked while the handler runs.  The gate
   24919 should be at privilege level 0 (the most privileged level).  The
   24920 @sc{sparc} and 68k stubs are able to mask interrupts themselves without
   24921 help from @code{exceptionHandler}.
   24922 
   24923 @findex flush_i_cache
   24924 @item void flush_i_cache()
   24925 On @sc{sparc} and @sc{sparclite} only, write this subroutine to flush the
   24926 instruction cache, if any, on your target machine.  If there is no
   24927 instruction cache, this subroutine may be a no-op.
   24928 
   24929 On target machines that have instruction caches, @value{GDBN} requires this
   24930 function to make certain that the state of your program is stable.
   24931 @end table
   24932 
   24933 @noindent
   24934 You must also make sure this library routine is available:
   24935 
   24936 @table @code
   24937 @findex memset
   24938 @item void *memset(void *, int, int)
   24939 This is the standard library function @code{memset} that sets an area of
   24940 memory to a known value.  If you have one of the free versions of
   24941 @code{libc.a}, @code{memset} can be found there; otherwise, you must
   24942 either obtain it from your hardware manufacturer, or write your own.
   24943 @end table
   24944 
   24945 If you do not use the GNU C compiler, you may need other standard
   24946 library subroutines as well; this varies from one stub to another,
   24947 but in general the stubs are likely to use any of the common library
   24948 subroutines which @code{@value{NGCC}} generates as inline code.
   24949 
   24950 
   24951 @node Debug Session
   24952 @subsection Putting it All Together
   24953 
   24954 @cindex remote serial debugging summary
   24955 In summary, when your program is ready to debug, you must follow these
   24956 steps.
   24957 
   24958 @enumerate
   24959 @item
   24960 Make sure you have defined the supporting low-level routines
   24961 (@pxref{Bootstrapping,,What You Must Do for the Stub}):
   24962 @display
   24963 @code{getDebugChar}, @code{putDebugChar},
   24964 @code{flush_i_cache}, @code{memset}, @code{exceptionHandler}.
   24965 @end display
   24966 
   24967 @item
   24968 Insert these lines in your program's startup code, before the main
   24969 procedure is called:
   24970 
   24971 @smallexample
   24972 set_debug_traps();
   24973 breakpoint();
   24974 @end smallexample
   24975 
   24976 On some machines, when a breakpoint trap is raised, the hardware
   24977 automatically makes the PC point to the instruction after the
   24978 breakpoint.  If your machine doesn't do that, you may need to adjust
   24979 @code{handle_exception} to arrange for it to return to the instruction
   24980 after the breakpoint on this first invocation, so that your program
   24981 doesn't keep hitting the initial breakpoint instead of making
   24982 progress.
   24983 
   24984 @item
   24985 For the 680x0 stub only, you need to provide a variable called
   24986 @code{exceptionHook}.  Normally you just use:
   24987 
   24988 @smallexample
   24989 void (*exceptionHook)() = 0;
   24990 @end smallexample
   24991 
   24992 @noindent
   24993 but if before calling @code{set_debug_traps}, you set it to point to a
   24994 function in your program, that function is called when
   24995 @code{@value{GDBN}} continues after stopping on a trap (for example, bus
   24996 error).  The function indicated by @code{exceptionHook} is called with
   24997 one parameter: an @code{int} which is the exception number.
   24998 
   24999 @item
   25000 Compile and link together: your program, the @value{GDBN} debugging stub for
   25001 your target architecture, and the supporting subroutines.
   25002 
   25003 @item
   25004 Make sure you have a serial connection between your target machine and
   25005 the @value{GDBN} host, and identify the serial port on the host.
   25006 
   25007 @item
   25008 @c The "remote" target now provides a `load' command, so we should
   25009 @c document that.  FIXME.
   25010 Download your program to your target machine (or get it there by
   25011 whatever means the manufacturer provides), and start it.
   25012 
   25013 @item
   25014 Start @value{GDBN} on the host, and connect to the target
   25015 (@pxref{Connecting,,Connecting to a Remote Target}).
   25016 
   25017 @end enumerate
   25018 
   25019 @node Configurations
   25020 @chapter Configuration-Specific Information
   25021 
   25022 While nearly all @value{GDBN} commands are available for all native and
   25023 cross versions of the debugger, there are some exceptions.  This chapter
   25024 describes things that are only available in certain configurations.
   25025 
   25026 There are three major categories of configurations: native
   25027 configurations, where the host and target are the same, embedded
   25028 operating system configurations, which are usually the same for several
   25029 different processor architectures, and bare embedded processors, which
   25030 are quite different from each other.
   25031 
   25032 @menu
   25033 * Native::
   25034 * Embedded OS::
   25035 * Embedded Processors::
   25036 * Architectures::
   25037 @end menu
   25038 
   25039 @node Native
   25040 @section Native
   25041 
   25042 This section describes details specific to particular native
   25043 configurations.
   25044 
   25045 @menu
   25046 * BSD libkvm Interface::        Debugging BSD kernel memory images
   25047 * Process Information::         Process information
   25048 * DJGPP Native::                Features specific to the DJGPP port
   25049 * Cygwin Native::               Features specific to the Cygwin port
   25050 * Hurd Native::                 Features specific to @sc{gnu} Hurd
   25051 * Darwin::                      Features specific to Darwin
   25052 * FreeBSD::                     Features specific to FreeBSD
   25053 @end menu
   25054 
   25055 @node BSD libkvm Interface
   25056 @subsection BSD libkvm Interface
   25057 
   25058 @cindex libkvm
   25059 @cindex kernel memory image
   25060 @cindex kernel crash dump
   25061 
   25062 BSD-derived systems (FreeBSD/NetBSD/OpenBSD) have a kernel memory
   25063 interface that provides a uniform interface for accessing kernel virtual
   25064 memory images, including live systems and crash dumps.  @value{GDBN}
   25065 uses this interface to allow you to debug live kernels and kernel crash
   25066 dumps on many native BSD configurations.  This is implemented as a
   25067 special @code{kvm} debugging target.  For debugging a live system, load
   25068 the currently running kernel into @value{GDBN} and connect to the
   25069 @code{kvm} target:
   25070 
   25071 @smallexample
   25072 (@value{GDBP}) @b{target kvm}
   25073 @end smallexample
   25074 
   25075 For debugging crash dumps, provide the file name of the crash dump as an
   25076 argument:
   25077 
   25078 @smallexample
   25079 (@value{GDBP}) @b{target kvm /var/crash/bsd.0}
   25080 @end smallexample
   25081 
   25082 Once connected to the @code{kvm} target, the following commands are
   25083 available:
   25084 
   25085 @table @code
   25086 @kindex kvm
   25087 @item kvm pcb
   25088 Set current context from the @dfn{Process Control Block} (PCB) address.
   25089 
   25090 @item kvm proc
   25091 Set current context from proc address.  This command isn't available on
   25092 modern FreeBSD systems.
   25093 @end table
   25094 
   25095 @node Process Information
   25096 @subsection Process Information
   25097 @cindex /proc
   25098 @cindex examine process image
   25099 @cindex process info via @file{/proc}
   25100 
   25101 Some operating systems provide interfaces to fetch additional
   25102 information about running processes beyond memory and per-thread
   25103 register state.  If @value{GDBN} is configured for an operating system
   25104 with a supported interface, the command @code{info proc} is available
   25105 to report information about the process running your program, or about
   25106 any process running on your system.
   25107 
   25108 One supported interface is a facility called @samp{/proc} that can be
   25109 used to examine the image of a running process using file-system
   25110 subroutines.  This facility is supported on @sc{gnu}/Linux and Solaris
   25111 systems.
   25112 
   25113 On FreeBSD and NetBSD systems, system control nodes are used to query
   25114 process information.
   25115 
   25116 In addition, some systems may provide additional process information
   25117 in core files.  Note that a core file may include a subset of the
   25118 information available from a live process.  Process information is
   25119 currently available from cores created on @sc{gnu}/Linux and FreeBSD
   25120 systems.
   25121 
   25122 @table @code
   25123 @kindex info proc
   25124 @cindex process ID
   25125 @item info proc
   25126 @itemx info proc @var{process-id}
   25127 Summarize available information about a process.  If a
   25128 process ID is specified by @var{process-id}, display information about
   25129 that process; otherwise display information about the program being
   25130 debugged.  The summary includes the debugged process ID, the command
   25131 line used to invoke it, its current working directory, and its
   25132 executable file's absolute file name.
   25133 
   25134 On some systems, @var{process-id} can be of the form
   25135 @samp{[@var{pid}]/@var{tid}} which specifies a certain thread ID
   25136 within a process.  If the optional @var{pid} part is missing, it means
   25137 a thread from the process being debugged (the leading @samp{/} still
   25138 needs to be present, or else @value{GDBN} will interpret the number as
   25139 a process ID rather than a thread ID).
   25140 
   25141 @item info proc cmdline
   25142 @cindex info proc cmdline
   25143 Show the original command line of the process.  This command is
   25144 supported on @sc{gnu}/Linux, FreeBSD and NetBSD.
   25145 
   25146 @item info proc cwd
   25147 @cindex info proc cwd
   25148 Show the current working directory of the process.  This command is
   25149 supported on @sc{gnu}/Linux, FreeBSD and NetBSD.
   25150 
   25151 @item info proc exe
   25152 @cindex info proc exe
   25153 Show the name of executable of the process.  This command is supported
   25154 on @sc{gnu}/Linux, FreeBSD and NetBSD.
   25155 
   25156 @item info proc files
   25157 @cindex info proc files
   25158 Show the file descriptors open by the process.  For each open file
   25159 descriptor, @value{GDBN} shows its number, type (file, directory,
   25160 character device, socket), file pointer offset, and the name of the
   25161 resource open on the descriptor.  The resource name can be a file name
   25162 (for files, directories, and devices) or a protocol followed by socket
   25163 address (for network connections).  This command is supported on
   25164 FreeBSD.
   25165 
   25166 This example shows the open file descriptors for a process using a
   25167 tty for standard input and output as well as two network sockets:
   25168 
   25169 @smallexample
   25170 (@value{GDBP}) info proc files 22136
   25171 process 22136
   25172 Open files:
   25173 
   25174       FD   Type     Offset   Flags   Name
   25175     text   file          - r-------- /usr/bin/ssh
   25176     ctty    chr          - rw------- /dev/pts/20
   25177      cwd    dir          - r-------- /usr/home/john
   25178     root    dir          - r-------- /
   25179        0    chr  0x32933a4 rw------- /dev/pts/20
   25180        1    chr  0x32933a4 rw------- /dev/pts/20
   25181        2    chr  0x32933a4 rw------- /dev/pts/20
   25182        3 socket        0x0 rw----n-- tcp4 10.0.1.2:53014 -> 10.0.1.10:22
   25183        4 socket        0x0 rw------- unix stream:/tmp/ssh-FIt89oAzOn5f/agent.2456
   25184 @end smallexample
   25185 
   25186 @item info proc mappings
   25187 @cindex memory address space mappings
   25188 Report the memory address space ranges accessible in a process.  On
   25189 Solaris, FreeBSD and NetBSD systems, each memory range includes information
   25190 on whether the process has read, write, or execute access rights to each
   25191 range.  On @sc{gnu}/Linux, FreeBSD and NetBSD systems, each memory range
   25192 includes the object file which is mapped to that range.
   25193 
   25194 @item info proc stat
   25195 @itemx info proc status
   25196 @cindex process detailed status information
   25197 Show additional process-related information, including the user ID and
   25198 group ID; virtual memory usage; the signals that are pending, blocked,
   25199 and ignored; its TTY; its consumption of system and user time; its
   25200 stack size; its @samp{nice} value; etc.  These commands are supported
   25201 on @sc{gnu}/Linux, FreeBSD and NetBSD.
   25202 
   25203 For @sc{gnu}/Linux systems, see the @samp{proc} man page for more
   25204 information (type @kbd{man 5 proc} from your shell prompt).
   25205 
   25206 For FreeBSD and NetBSD systems, @code{info proc stat} is an alias for
   25207 @code{info proc status}.
   25208 
   25209 @item info proc all
   25210 Show all the information about the process described under all of the
   25211 above @code{info proc} subcommands.
   25212 
   25213 @ignore
   25214 @comment These sub-options of 'info proc' were not included when
   25215 @comment procfs.c was re-written.  Keep their descriptions around
   25216 @comment against the day when someone finds the time to put them back in.
   25217 @kindex info proc times
   25218 @item info proc times
   25219 Starting time, user CPU time, and system CPU time for your program and
   25220 its children.
   25221 
   25222 @kindex info proc id
   25223 @item info proc id
   25224 Report on the process IDs related to your program: its own process ID,
   25225 the ID of its parent, the process group ID, and the session ID.
   25226 @end ignore
   25227 
   25228 @item set procfs-trace
   25229 @kindex set procfs-trace
   25230 @cindex @code{procfs} API calls
   25231 This command enables and disables tracing of @code{procfs} API calls.
   25232 
   25233 @item show procfs-trace
   25234 @kindex show procfs-trace
   25235 Show the current state of @code{procfs} API call tracing.
   25236 
   25237 @item set procfs-file @var{file}
   25238 @kindex set procfs-file
   25239 Tell @value{GDBN} to write @code{procfs} API trace to the named
   25240 @var{file}.  @value{GDBN} appends the trace info to the previous
   25241 contents of the file.  The default is to display the trace on the
   25242 standard output.
   25243 
   25244 @item show procfs-file
   25245 @kindex show procfs-file
   25246 Show the file to which @code{procfs} API trace is written.
   25247 
   25248 @item proc-trace-entry
   25249 @itemx proc-trace-exit
   25250 @itemx proc-untrace-entry
   25251 @itemx proc-untrace-exit
   25252 @kindex proc-trace-entry
   25253 @kindex proc-trace-exit
   25254 @kindex proc-untrace-entry
   25255 @kindex proc-untrace-exit
   25256 These commands enable and disable tracing of entries into and exits
   25257 from the @code{syscall} interface.
   25258 
   25259 @end table
   25260 
   25261 @node DJGPP Native
   25262 @subsection Features for Debugging @sc{djgpp} Programs
   25263 @cindex @sc{djgpp} debugging
   25264 @cindex native @sc{djgpp} debugging
   25265 @cindex MS-DOS-specific commands
   25266 
   25267 @cindex DPMI
   25268 @sc{djgpp} is a port of the @sc{gnu} development tools to MS-DOS and
   25269 MS-Windows.  @sc{djgpp} programs are 32-bit protected-mode programs
   25270 that use the @dfn{DPMI} (DOS Protected-Mode Interface) API to run on
   25271 top of real-mode DOS systems and their emulations.
   25272 
   25273 @value{GDBN} supports native debugging of @sc{djgpp} programs, and
   25274 defines a few commands specific to the @sc{djgpp} port.  This
   25275 subsection describes those commands.
   25276 
   25277 @table @code
   25278 @kindex info dos
   25279 @item info dos
   25280 This is a prefix of @sc{djgpp}-specific commands which print
   25281 information about the target system and important OS structures.
   25282 
   25283 @kindex sysinfo
   25284 @cindex MS-DOS system info
   25285 @cindex free memory information (MS-DOS)
   25286 @item info dos sysinfo
   25287 This command displays assorted information about the underlying
   25288 platform: the CPU type and features, the OS version and flavor, the
   25289 DPMI version, and the available conventional and DPMI memory.
   25290 
   25291 @cindex GDT
   25292 @cindex LDT
   25293 @cindex IDT
   25294 @cindex segment descriptor tables
   25295 @cindex descriptor tables display
   25296 @item info dos gdt
   25297 @itemx info dos ldt
   25298 @itemx info dos idt
   25299 These 3 commands display entries from, respectively, Global, Local,
   25300 and Interrupt Descriptor Tables (GDT, LDT, and IDT).  The descriptor
   25301 tables are data structures which store a descriptor for each segment
   25302 that is currently in use.  The segment's selector is an index into a
   25303 descriptor table; the table entry for that index holds the
   25304 descriptor's base address and limit, and its attributes and access
   25305 rights.
   25306 
   25307 A typical @sc{djgpp} program uses 3 segments: a code segment, a data
   25308 segment (used for both data and the stack), and a DOS segment (which
   25309 allows access to DOS/BIOS data structures and absolute addresses in
   25310 conventional memory).  However, the DPMI host will usually define
   25311 additional segments in order to support the DPMI environment.
   25312 
   25313 @cindex garbled pointers
   25314 These commands allow to display entries from the descriptor tables.
   25315 Without an argument, all entries from the specified table are
   25316 displayed.  An argument, which should be an integer expression, means
   25317 display a single entry whose index is given by the argument.  For
   25318 example, here's a convenient way to display information about the
   25319 debugged program's data segment:
   25320 
   25321 @smallexample
   25322 @exdent @code{(@value{GDBP}) info dos ldt $ds}
   25323 @exdent @code{0x13f: base=0x11970000 limit=0x0009ffff 32-Bit Data (Read/Write, Exp-up)}
   25324 @end smallexample
   25325 
   25326 @noindent
   25327 This comes in handy when you want to see whether a pointer is outside
   25328 the data segment's limit (i.e.@: @dfn{garbled}).
   25329 
   25330 @cindex page tables display (MS-DOS)
   25331 @item info dos pde
   25332 @itemx info dos pte
   25333 These two commands display entries from, respectively, the Page
   25334 Directory and the Page Tables.  Page Directories and Page Tables are
   25335 data structures which control how virtual memory addresses are mapped
   25336 into physical addresses.  A Page Table includes an entry for every
   25337 page of memory that is mapped into the program's address space; there
   25338 may be several Page Tables, each one holding up to 4096 entries.  A
   25339 Page Directory has up to 4096 entries, one each for every Page Table
   25340 that is currently in use.
   25341 
   25342 Without an argument, @kbd{info dos pde} displays the entire Page
   25343 Directory, and @kbd{info dos pte} displays all the entries in all of
   25344 the Page Tables.  An argument, an integer expression, given to the
   25345 @kbd{info dos pde} command means display only that entry from the Page
   25346 Directory table.  An argument given to the @kbd{info dos pte} command
   25347 means display entries from a single Page Table, the one pointed to by
   25348 the specified entry in the Page Directory.
   25349 
   25350 @cindex direct memory access (DMA) on MS-DOS
   25351 These commands are useful when your program uses @dfn{DMA} (Direct
   25352 Memory Access), which needs physical addresses to program the DMA
   25353 controller.
   25354 
   25355 These commands are supported only with some DPMI servers.
   25356 
   25357 @cindex physical address from linear address
   25358 @item info dos address-pte @var{addr}
   25359 This command displays the Page Table entry for a specified linear
   25360 address.  The argument @var{addr} is a linear address which should
   25361 already have the appropriate segment's base address added to it,
   25362 because this command accepts addresses which may belong to @emph{any}
   25363 segment.  For example, here's how to display the Page Table entry for
   25364 the page where a variable @code{i} is stored:
   25365 
   25366 @smallexample
   25367 @exdent @code{(@value{GDBP}) info dos address-pte __djgpp_base_address + (char *)&i}
   25368 @exdent @code{Page Table entry for address 0x11a00d30:}
   25369 @exdent @code{Base=0x02698000 Dirty Acc. Not-Cached Write-Back Usr Read-Write +0xd30}
   25370 @end smallexample
   25371 
   25372 @noindent
   25373 This says that @code{i} is stored at offset @code{0xd30} from the page
   25374 whose physical base address is @code{0x02698000}, and shows all the
   25375 attributes of that page.
   25376 
   25377 Note that you must cast the addresses of variables to a @code{char *},
   25378 since otherwise the value of @code{__djgpp_base_address}, the base
   25379 address of all variables and functions in a @sc{djgpp} program, will
   25380 be added using the rules of C pointer arithmetic: if @code{i} is
   25381 declared an @code{int}, @value{GDBN} will add 4 times the value of
   25382 @code{__djgpp_base_address} to the address of @code{i}.
   25383 
   25384 Here's another example, it displays the Page Table entry for the
   25385 transfer buffer:
   25386 
   25387 @smallexample
   25388 @exdent @code{(@value{GDBP}) info dos address-pte *((unsigned *)&_go32_info_block + 3)}
   25389 @exdent @code{Page Table entry for address 0x29110:}
   25390 @exdent @code{Base=0x00029000 Dirty Acc. Not-Cached Write-Back Usr Read-Write +0x110}
   25391 @end smallexample
   25392 
   25393 @noindent
   25394 (The @code{+ 3} offset is because the transfer buffer's address is the
   25395 3rd member of the @code{_go32_info_block} structure.)  The output
   25396 clearly shows that this DPMI server maps the addresses in conventional
   25397 memory 1:1, i.e.@: the physical (@code{0x00029000} + @code{0x110}) and
   25398 linear (@code{0x29110}) addresses are identical.
   25399 
   25400 This command is supported only with some DPMI servers.
   25401 @end table
   25402 
   25403 @cindex DOS serial data link, remote debugging
   25404 In addition to native debugging, the DJGPP port supports remote
   25405 debugging via a serial data link.  The following commands are specific
   25406 to remote serial debugging in the DJGPP port of @value{GDBN}.
   25407 
   25408 @table @code
   25409 @kindex set com1base
   25410 @kindex set com1irq
   25411 @kindex set com2base
   25412 @kindex set com2irq
   25413 @kindex set com3base
   25414 @kindex set com3irq
   25415 @kindex set com4base
   25416 @kindex set com4irq
   25417 @item set com1base @var{addr}
   25418 This command sets the base I/O port address of the @file{COM1} serial
   25419 port.
   25420 
   25421 @item set com1irq @var{irq}
   25422 This command sets the @dfn{Interrupt Request} (@code{IRQ}) line to use
   25423 for the @file{COM1} serial port.
   25424 
   25425 There are similar commands @samp{set com2base}, @samp{set com3irq},
   25426 etc.@: for setting the port address and the @code{IRQ} lines for the
   25427 other 3 COM ports.
   25428 
   25429 @kindex show com1base
   25430 @kindex show com1irq
   25431 @kindex show com2base
   25432 @kindex show com2irq
   25433 @kindex show com3base
   25434 @kindex show com3irq
   25435 @kindex show com4base
   25436 @kindex show com4irq
   25437 The related commands @samp{show com1base}, @samp{show com1irq} etc.@:
   25438 display the current settings of the base address and the @code{IRQ}
   25439 lines used by the COM ports.
   25440 
   25441 @item info serial
   25442 @kindex info serial
   25443 @cindex DOS serial port status
   25444 This command prints the status of the 4 DOS serial ports.  For each
   25445 port, it prints whether it's active or not, its I/O base address and
   25446 IRQ number, whether it uses a 16550-style FIFO, its baudrate, and the
   25447 counts of various errors encountered so far.
   25448 @end table
   25449 
   25450 
   25451 @node Cygwin Native
   25452 @subsection Features for Debugging MS Windows PE Executables
   25453 @cindex MS Windows debugging
   25454 @cindex native Cygwin debugging
   25455 @cindex Cygwin-specific commands
   25456 
   25457 @value{GDBN} supports native debugging of MS Windows programs, including
   25458 DLLs with and without symbolic debugging information.
   25459 
   25460 @cindex Ctrl-BREAK, MS-Windows
   25461 @cindex interrupt debuggee on MS-Windows
   25462 MS-Windows programs that call @code{SetConsoleMode} to switch off the
   25463 special meaning of the @samp{Ctrl-C} keystroke cannot be interrupted
   25464 by typing @kbd{C-c}.  For this reason, @value{GDBN} on MS-Windows
   25465 supports @kbd{C-@key{BREAK}} as an alternative interrupt key
   25466 sequence, which can be used to interrupt the debuggee even if it
   25467 ignores @kbd{C-c}.
   25468 
   25469 There are various additional Cygwin-specific commands, described in
   25470 this section.  Working with DLLs that have no debugging symbols is
   25471 described in @ref{Non-debug DLL Symbols}.
   25472 
   25473 @table @code
   25474 @kindex info w32
   25475 @item info w32
   25476 This is a prefix of MS Windows-specific commands which print
   25477 information about the target system and important OS structures.
   25478 
   25479 @item info w32 selector
   25480 This command displays information returned by
   25481 the Win32 API @code{GetThreadSelectorEntry} function.
   25482 It takes an optional argument that is evaluated to
   25483 a long value to give the information about this given selector.
   25484 Without argument, this command displays information
   25485 about the six segment registers.
   25486 
   25487 @item info w32 thread-information-block
   25488 This command displays thread specific information stored in the
   25489 Thread Information Block (readable on the X86 CPU family using @code{$fs}
   25490 selector for 32-bit programs and @code{$gs} for 64-bit programs).
   25491 
   25492 @kindex signal-event
   25493 @item signal-event @var{id}
   25494 This command signals an event with user-provided @var{id}.  Used to resume
   25495 crashing process when attached to it using MS-Windows JIT debugging (AeDebug).
   25496 
   25497 To use it, create or edit the following keys in
   25498 @code{HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug} and/or
   25499 @code{HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug}
   25500 (for x86_64 versions):
   25501 
   25502 @itemize @minus
   25503 @item
   25504 @code{Debugger} (REG_SZ) --- a command to launch the debugger.
   25505 Suggested command is: @code{@var{fully-qualified-path-to-gdb.exe} -ex
   25506 "attach %ld" -ex "signal-event %ld" -ex "continue"}.
   25507 
   25508 The first @code{%ld} will be replaced by the process ID of the
   25509 crashing process, the second @code{%ld} will be replaced by the ID of
   25510 the event that blocks the crashing process, waiting for @value{GDBN}
   25511 to attach.
   25512 
   25513 @item
   25514 @code{Auto} (REG_SZ) --- either @code{1} or @code{0}.  @code{1} will
   25515 make the system run debugger specified by the Debugger key
   25516 automatically, @code{0} will cause a dialog box with ``OK'' and
   25517 ``Cancel'' buttons to appear, which allows the user to either
   25518 terminate the crashing process (OK) or debug it (Cancel).
   25519 @end itemize
   25520 
   25521 @kindex set cygwin-exceptions
   25522 @cindex debugging the Cygwin DLL
   25523 @cindex Cygwin DLL, debugging
   25524 @item set cygwin-exceptions @var{mode}
   25525 If @var{mode} is @code{on}, @value{GDBN} will break on exceptions that
   25526 happen inside the Cygwin DLL.  If @var{mode} is @code{off},
   25527 @value{GDBN} will delay recognition of exceptions, and may ignore some
   25528 exceptions which seem to be caused by internal Cygwin DLL
   25529 ``bookkeeping''.  This option is meant primarily for debugging the
   25530 Cygwin DLL itself; the default value is @code{off} to avoid annoying
   25531 @value{GDBN} users with false @code{SIGSEGV} signals.
   25532 
   25533 @kindex show cygwin-exceptions
   25534 @item show cygwin-exceptions
   25535 Displays whether @value{GDBN} will break on exceptions that happen
   25536 inside the Cygwin DLL itself.
   25537 
   25538 @kindex set new-console
   25539 @item set new-console @var{mode}
   25540 If @var{mode} is @code{on} the debuggee will
   25541 be started in a new console on next start.
   25542 If @var{mode} is @code{off}, the debuggee will
   25543 be started in the same console as the debugger.
   25544 
   25545 @kindex show new-console
   25546 @item show new-console
   25547 Displays whether a new console is used
   25548 when the debuggee is started.
   25549 
   25550 @kindex set new-group
   25551 @item set new-group @var{mode}
   25552 This boolean value controls whether the debuggee should
   25553 start a new group or stay in the same group as the debugger.
   25554 This affects the way the Windows OS handles
   25555 @samp{Ctrl-C}.
   25556 
   25557 @kindex show new-group
   25558 @item show new-group
   25559 Displays current value of new-group boolean.
   25560 
   25561 @kindex set debugevents
   25562 @item set debugevents
   25563 This boolean value adds debug output concerning kernel events related
   25564 to the debuggee seen by the debugger.  This includes events that
   25565 signal thread and process creation and exit, DLL loading and
   25566 unloading, console interrupts, and debugging messages produced by the
   25567 Windows @code{OutputDebugString} API call.
   25568 
   25569 @kindex set debugexec
   25570 @item set debugexec
   25571 This boolean value adds debug output concerning execute events
   25572 (such as resume thread) seen by the debugger.
   25573 
   25574 @kindex set debugexceptions
   25575 @item set debugexceptions
   25576 This boolean value adds debug output concerning exceptions in the
   25577 debuggee seen by the debugger.
   25578 
   25579 @kindex set debugmemory
   25580 @item set debugmemory
   25581 This boolean value adds debug output concerning debuggee memory reads
   25582 and writes by the debugger.
   25583 
   25584 @kindex set shell
   25585 @item set shell
   25586 This boolean values specifies whether the debuggee is called
   25587 via a shell or directly (default value is on).
   25588 
   25589 @kindex show shell
   25590 @item show shell
   25591 Displays if the debuggee will be started with a shell.
   25592 
   25593 @end table
   25594 
   25595 @menu
   25596 * Non-debug DLL Symbols::  Support for DLLs without debugging symbols
   25597 @end menu
   25598 
   25599 @node Non-debug DLL Symbols
   25600 @subsubsection Support for DLLs without Debugging Symbols
   25601 @cindex DLLs with no debugging symbols
   25602 @cindex Minimal symbols and DLLs
   25603 
   25604 Very often on windows, some of the DLLs that your program relies on do
   25605 not include symbolic debugging information (for example,
   25606 @file{kernel32.dll}).  When @value{GDBN} doesn't recognize any debugging
   25607 symbols in a DLL, it relies on the minimal amount of symbolic
   25608 information contained in the DLL's export table.  This section
   25609 describes working with such symbols, known internally to @value{GDBN} as
   25610 ``minimal symbols''.
   25611 
   25612 Note that before the debugged program has started execution, no DLLs
   25613 will have been loaded.  The easiest way around this problem is simply to
   25614 start the program --- either by setting a breakpoint or letting the
   25615 program run once to completion.
   25616 
   25617 @subsubsection DLL Name Prefixes
   25618 
   25619 In keeping with the naming conventions used by the Microsoft debugging
   25620 tools, DLL export symbols are made available with a prefix based on the
   25621 DLL name, for instance @code{KERNEL32!CreateFileA}.  The plain name is
   25622 also entered into the symbol table, so @code{CreateFileA} is often
   25623 sufficient.  In some cases there will be name clashes within a program
   25624 (particularly if the executable itself includes full debugging symbols)
   25625 necessitating the use of the fully qualified name when referring to the
   25626 contents of the DLL.  Use single-quotes around the name to avoid the
   25627 exclamation mark (``!'')  being interpreted as a language operator.
   25628 
   25629 Note that the internal name of the DLL may be all upper-case, even
   25630 though the file name of the DLL is lower-case, or vice-versa.  Since
   25631 symbols within @value{GDBN} are @emph{case-sensitive} this may cause
   25632 some confusion. If in doubt, try the @code{info functions} and
   25633 @code{info variables} commands or even @code{maint print msymbols}
   25634 (@pxref{Symbols}). Here's an example:
   25635 
   25636 @smallexample
   25637 (@value{GDBP}) info function CreateFileA
   25638 All functions matching regular expression "CreateFileA":
   25639 
   25640 Non-debugging symbols:
   25641 0x77e885f4  CreateFileA
   25642 0x77e885f4  KERNEL32!CreateFileA
   25643 @end smallexample
   25644 
   25645 @smallexample
   25646 (@value{GDBP}) info function !
   25647 All functions matching regular expression "!":
   25648 
   25649 Non-debugging symbols:
   25650 0x6100114c  cygwin1!__assert
   25651 0x61004034  cygwin1!_dll_crt0@@0
   25652 0x61004240  cygwin1!dll_crt0(per_process *)
   25653 [etc...]
   25654 @end smallexample
   25655 
   25656 @subsubsection Working with Minimal Symbols
   25657 
   25658 Symbols extracted from a DLL's export table do not contain very much
   25659 type information. All that @value{GDBN} can do is guess whether a symbol
   25660 refers to a function or variable depending on the linker section that
   25661 contains the symbol. Also note that the actual contents of the memory
   25662 contained in a DLL are not available unless the program is running. This
   25663 means that you cannot examine the contents of a variable or disassemble
   25664 a function within a DLL without a running program.
   25665 
   25666 Variables are generally treated as pointers and dereferenced
   25667 automatically. For this reason, it is often necessary to prefix a
   25668 variable name with the address-of operator (``&'') and provide explicit
   25669 type information in the command. Here's an example of the type of
   25670 problem:
   25671 
   25672 @smallexample
   25673 (@value{GDBP}) print 'cygwin1!__argv'
   25674 'cygwin1!__argv' has unknown type; cast it to its declared type
   25675 @end smallexample
   25676 
   25677 @smallexample
   25678 (@value{GDBP}) x 'cygwin1!__argv'
   25679 'cygwin1!__argv' has unknown type; cast it to its declared type
   25680 @end smallexample
   25681 
   25682 And two possible solutions:
   25683 
   25684 @smallexample
   25685 (@value{GDBP}) print ((char **)'cygwin1!__argv')[0]
   25686 $2 = 0x22fd98 "/cygdrive/c/mydirectory/myprogram"
   25687 @end smallexample
   25688 
   25689 @smallexample
   25690 (@value{GDBP}) x/2x &'cygwin1!__argv'
   25691 0x610c0aa8 <cygwin1!__argv>:    0x10021608      0x00000000
   25692 (@value{GDBP}) x/x 0x10021608
   25693 0x10021608:     0x0022fd98
   25694 (@value{GDBP}) x/s 0x0022fd98
   25695 0x22fd98:        "/cygdrive/c/mydirectory/myprogram"
   25696 @end smallexample
   25697 
   25698 Setting a break point within a DLL is possible even before the program
   25699 starts execution. However, under these circumstances, @value{GDBN} can't
   25700 examine the initial instructions of the function in order to skip the
   25701 function's frame set-up code. You can work around this by using ``*&''
   25702 to set the breakpoint at a raw memory address:
   25703 
   25704 @smallexample
   25705 (@value{GDBP}) break *&'python22!PyOS_Readline'
   25706 Breakpoint 1 at 0x1e04eff0
   25707 @end smallexample
   25708 
   25709 The author of these extensions is not entirely convinced that setting a
   25710 break point within a shared DLL like @file{kernel32.dll} is completely
   25711 safe.
   25712 
   25713 @node Hurd Native
   25714 @subsection Commands Specific to @sc{gnu} Hurd Systems
   25715 @cindex @sc{gnu} Hurd debugging
   25716 
   25717 This subsection describes @value{GDBN} commands specific to the
   25718 @sc{gnu} Hurd native debugging.
   25719 
   25720 @table @code
   25721 @item set signals
   25722 @itemx set sigs
   25723 @kindex set signals@r{, Hurd command}
   25724 @kindex set sigs@r{, Hurd command}
   25725 This command toggles the state of inferior signal interception by
   25726 @value{GDBN}.  Mach exceptions, such as breakpoint traps, are not
   25727 affected by this command.  @code{sigs} is a shorthand alias for
   25728 @code{signals}.
   25729 
   25730 @item show signals
   25731 @itemx show sigs
   25732 @kindex show signals@r{, Hurd command}
   25733 @kindex show sigs@r{, Hurd command}
   25734 Show the current state of intercepting inferior's signals.
   25735 
   25736 @item set signal-thread
   25737 @itemx set sigthread
   25738 @kindex set signal-thread
   25739 @kindex set sigthread
   25740 This command tells @value{GDBN} which thread is the @code{libc} signal
   25741 thread.  That thread is run when a signal is delivered to a running
   25742 process.  @code{set sigthread} is the shorthand alias of @code{set
   25743 signal-thread}.
   25744 
   25745 @item show signal-thread
   25746 @itemx show sigthread
   25747 @kindex show signal-thread
   25748 @kindex show sigthread
   25749 These two commands show which thread will run when the inferior is
   25750 delivered a signal.
   25751 
   25752 @item set stopped
   25753 @kindex set stopped@r{, Hurd command}
   25754 This commands tells @value{GDBN} that the inferior process is stopped,
   25755 as with the @code{SIGSTOP} signal.  The stopped process can be
   25756 continued by delivering a signal to it.
   25757 
   25758 @item show stopped
   25759 @kindex show stopped@r{, Hurd command}
   25760 This command shows whether @value{GDBN} thinks the debuggee is
   25761 stopped.
   25762 
   25763 @item set exceptions
   25764 @kindex set exceptions@r{, Hurd command}
   25765 Use this command to turn off trapping of exceptions in the inferior.
   25766 When exception trapping is off, neither breakpoints nor
   25767 single-stepping will work.  To restore the default, set exception
   25768 trapping on.
   25769 
   25770 @item show exceptions
   25771 @kindex show exceptions@r{, Hurd command}
   25772 Show the current state of trapping exceptions in the inferior.
   25773 
   25774 @item set task pause
   25775 @kindex set task@r{, Hurd commands}
   25776 @cindex task attributes (@sc{gnu} Hurd)
   25777 @cindex pause current task (@sc{gnu} Hurd)
   25778 This command toggles task suspension when @value{GDBN} has control.
   25779 Setting it to on takes effect immediately, and the task is suspended
   25780 whenever @value{GDBN} gets control.  Setting it to off will take
   25781 effect the next time the inferior is continued.  If this option is set
   25782 to off, you can use @code{set thread default pause on} or @code{set
   25783 thread pause on} (see below) to pause individual threads.
   25784 
   25785 @item show task pause
   25786 @kindex show task@r{, Hurd commands}
   25787 Show the current state of task suspension.
   25788 
   25789 @item set task detach-suspend-count
   25790 @cindex task suspend count
   25791 @cindex detach from task, @sc{gnu} Hurd
   25792 This command sets the suspend count the task will be left with when
   25793 @value{GDBN} detaches from it.
   25794 
   25795 @item show task detach-suspend-count
   25796 Show the suspend count the task will be left with when detaching.
   25797 
   25798 @item set task exception-port
   25799 @itemx set task excp
   25800 @cindex task exception port, @sc{gnu} Hurd
   25801 This command sets the task exception port to which @value{GDBN} will
   25802 forward exceptions.  The argument should be the value of the @dfn{send
   25803 rights} of the task.  @code{set task excp} is a shorthand alias.
   25804 
   25805 @item set noninvasive
   25806 @cindex noninvasive task options
   25807 This command switches @value{GDBN} to a mode that is the least
   25808 invasive as far as interfering with the inferior is concerned.  This
   25809 is the same as using @code{set task pause}, @code{set exceptions}, and
   25810 @code{set signals} to values opposite to the defaults.
   25811 
   25812 @item info send-rights
   25813 @itemx info receive-rights
   25814 @itemx info port-rights
   25815 @itemx info port-sets
   25816 @itemx info dead-names
   25817 @itemx info ports
   25818 @itemx info psets
   25819 @cindex send rights, @sc{gnu} Hurd
   25820 @cindex receive rights, @sc{gnu} Hurd
   25821 @cindex port rights, @sc{gnu} Hurd
   25822 @cindex port sets, @sc{gnu} Hurd
   25823 @cindex dead names, @sc{gnu} Hurd
   25824 These commands display information about, respectively, send rights,
   25825 receive rights, port rights, port sets, and dead names of a task.
   25826 There are also shorthand aliases: @code{info ports} for @code{info
   25827 port-rights} and @code{info psets} for @code{info port-sets}.
   25828 
   25829 @item set thread pause
   25830 @kindex set thread@r{, Hurd command}
   25831 @cindex thread properties, @sc{gnu} Hurd
   25832 @cindex pause current thread (@sc{gnu} Hurd)
   25833 This command toggles current thread suspension when @value{GDBN} has
   25834 control.  Setting it to on takes effect immediately, and the current
   25835 thread is suspended whenever @value{GDBN} gets control.  Setting it to
   25836 off will take effect the next time the inferior is continued.
   25837 Normally, this command has no effect, since when @value{GDBN} has
   25838 control, the whole task is suspended.  However, if you used @code{set
   25839 task pause off} (see above), this command comes in handy to suspend
   25840 only the current thread.
   25841 
   25842 @item show thread pause
   25843 @kindex show thread@r{, Hurd command}
   25844 This command shows the state of current thread suspension.
   25845 
   25846 @item set thread run
   25847 This command sets whether the current thread is allowed to run.
   25848 
   25849 @item show thread run
   25850 Show whether the current thread is allowed to run.
   25851 
   25852 @item set thread detach-suspend-count
   25853 @cindex thread suspend count, @sc{gnu} Hurd
   25854 @cindex detach from thread, @sc{gnu} Hurd
   25855 This command sets the suspend count @value{GDBN} will leave on a
   25856 thread when detaching.  This number is relative to the suspend count
   25857 found by @value{GDBN} when it notices the thread; use @code{set thread
   25858 takeover-suspend-count} to force it to an absolute value.
   25859 
   25860 @item show thread detach-suspend-count
   25861 Show the suspend count @value{GDBN} will leave on the thread when
   25862 detaching.
   25863 
   25864 @item set thread exception-port
   25865 @itemx set thread excp
   25866 Set the thread exception port to which to forward exceptions.  This
   25867 overrides the port set by @code{set task exception-port} (see above).
   25868 @code{set thread excp} is the shorthand alias.
   25869 
   25870 @item set thread takeover-suspend-count
   25871 Normally, @value{GDBN}'s thread suspend counts are relative to the
   25872 value @value{GDBN} finds when it notices each thread.  This command
   25873 changes the suspend counts to be absolute instead.
   25874 
   25875 @item set thread default
   25876 @itemx show thread default
   25877 @cindex thread default settings, @sc{gnu} Hurd
   25878 Each of the above @code{set thread} commands has a @code{set thread
   25879 default} counterpart (e.g., @code{set thread default pause}, @code{set
   25880 thread default exception-port}, etc.).  The @code{thread default}
   25881 variety of commands sets the default thread properties for all
   25882 threads; you can then change the properties of individual threads with
   25883 the non-default commands.
   25884 @end table
   25885 
   25886 @node Darwin
   25887 @subsection Darwin
   25888 @cindex Darwin
   25889 
   25890 @value{GDBN} provides the following commands specific to the Darwin target:
   25891 
   25892 @table @code
   25893 @item set debug darwin @var{num}
   25894 @kindex set debug darwin
   25895 When set to a non zero value, enables debugging messages specific to
   25896 the Darwin support.  Higher values produce more verbose output.
   25897 
   25898 @item show debug darwin
   25899 @kindex show debug darwin
   25900 Show the current state of Darwin messages.
   25901 
   25902 @item set debug mach-o @var{num}
   25903 @kindex set debug mach-o
   25904 When set to a non zero value, enables debugging messages while
   25905 @value{GDBN} is reading Darwin object files.  (@dfn{Mach-O} is the
   25906 file format used on Darwin for object and executable files.)  Higher
   25907 values produce more verbose output.  This is a command to diagnose
   25908 problems internal to @value{GDBN} and should not be needed in normal
   25909 usage.
   25910 
   25911 @item show debug mach-o
   25912 @kindex show debug mach-o
   25913 Show the current state of Mach-O file messages.
   25914 
   25915 @item set mach-exceptions on
   25916 @itemx set mach-exceptions off
   25917 @kindex set mach-exceptions
   25918 On Darwin, faults are first reported as a Mach exception and are then
   25919 mapped to a Posix signal.  Use this command to turn on trapping of
   25920 Mach exceptions in the inferior.  This might be sometimes useful to
   25921 better understand the cause of a fault.  The default is off.
   25922 
   25923 @item show mach-exceptions
   25924 @kindex show mach-exceptions
   25925 Show the current state of exceptions trapping.
   25926 @end table
   25927 
   25928 @node FreeBSD
   25929 @subsection FreeBSD
   25930 @cindex FreeBSD
   25931 
   25932 When the ABI of a system call is changed in the FreeBSD kernel, this
   25933 is implemented by leaving a compatibility system call using the old
   25934 ABI at the existing number and allocating a new system call number for
   25935 the version using the new ABI.  As a convenience, when a system call
   25936 is caught by name (@pxref{catch syscall}), compatibility system calls
   25937 are also caught.
   25938 
   25939 For example, FreeBSD 12 introduced a new variant of the @code{kevent}
   25940 system call and catching the @code{kevent} system call by name catches
   25941 both variants:
   25942 
   25943 @smallexample
   25944 (@value{GDBP}) catch syscall kevent
   25945 Catchpoint 1 (syscalls 'freebsd11_kevent' [363] 'kevent' [560])
   25946 (@value{GDBP})
   25947 @end smallexample
   25948 
   25949 
   25950 @node Embedded OS
   25951 @section Embedded Operating Systems
   25952 
   25953 This section describes configurations involving the debugging of
   25954 embedded operating systems that are available for several different
   25955 architectures.
   25956 
   25957 @value{GDBN} includes the ability to debug programs running on
   25958 various real-time operating systems.
   25959 
   25960 @node Embedded Processors
   25961 @section Embedded Processors
   25962 
   25963 This section goes into details specific to particular embedded
   25964 configurations.
   25965 
   25966 @cindex send command to simulator
   25967 Whenever a specific embedded processor has a simulator, @value{GDBN}
   25968 allows to send an arbitrary command to the simulator.
   25969 
   25970 @table @code
   25971 @item sim @var{command}
   25972 @kindex sim@r{, a command}
   25973 Send an arbitrary @var{command} string to the simulator.  Consult the
   25974 documentation for the specific simulator in use for information about
   25975 acceptable commands.
   25976 @end table
   25977 
   25978 
   25979 @menu
   25980 * ARC::                         Synopsys ARC
   25981 * ARM::                         ARM
   25982 * BPF::                         eBPF
   25983 * M68K::                        Motorola M68K
   25984 * MicroBlaze::                  Xilinx MicroBlaze
   25985 * MIPS Embedded::               MIPS Embedded
   25986 * OpenRISC 1000::               OpenRISC 1000 (or1k)
   25987 * PowerPC Embedded::            PowerPC Embedded
   25988 * AVR::                         Atmel AVR
   25989 * CRIS::                        CRIS
   25990 * Super-H::                     Renesas Super-H
   25991 @end menu
   25992 
   25993 @node ARC
   25994 @subsection Synopsys ARC
   25995 @cindex Synopsys ARC
   25996 @cindex ARC specific commands
   25997 @cindex ARC600
   25998 @cindex ARC700
   25999 @cindex ARC EM
   26000 @cindex ARC HS
   26001 
   26002 @value{GDBN} provides the following ARC-specific commands:
   26003 
   26004 @table @code
   26005 @item set debug arc
   26006 @kindex set debug arc
   26007 Control the level of ARC specific debug messages.  Use 0 for no messages (the
   26008 default), 1 for debug messages, and 2 for even more debug messages.
   26009 
   26010 @item show debug arc
   26011 @kindex show debug arc
   26012 Show the level of ARC specific debugging in operation.
   26013 
   26014 @item maint print arc arc-instruction @var{address}
   26015 @kindex maint print arc arc-instruction
   26016 Print internal disassembler information about instruction at a given address.
   26017 
   26018 @end table
   26019 
   26020 @node ARM
   26021 @subsection ARM
   26022 
   26023 @value{GDBN} provides the following ARM-specific commands:
   26024 
   26025 @table @code
   26026 @item set arm disassembler
   26027 @kindex set arm
   26028 This commands selects from a list of disassembly styles.  The
   26029 @code{"std"} style is the standard style.
   26030 
   26031 @item show arm disassembler
   26032 @kindex show arm
   26033 Show the current disassembly style.
   26034 
   26035 @item set arm apcs32
   26036 @cindex ARM 32-bit mode
   26037 This command toggles ARM operation mode between 32-bit and 26-bit.
   26038 
   26039 @item show arm apcs32
   26040 Display the current usage of the ARM 32-bit mode.
   26041 
   26042 @item set arm fpu @var{fputype}
   26043 This command sets the ARM floating-point unit (FPU) type.  The
   26044 argument @var{fputype} can be one of these:
   26045 
   26046 @table @code
   26047 @item auto
   26048 Determine the FPU type by querying the OS ABI.
   26049 @item softfpa
   26050 Software FPU, with mixed-endian doubles on little-endian ARM
   26051 processors.
   26052 @item fpa
   26053 GCC-compiled FPA co-processor.
   26054 @item softvfp
   26055 Software FPU with pure-endian doubles.
   26056 @item vfp
   26057 VFP co-processor.
   26058 @end table
   26059 
   26060 @item show arm fpu
   26061 Show the current type of the FPU.
   26062 
   26063 @item set arm abi
   26064 This command forces @value{GDBN} to use the specified ABI.
   26065 
   26066 @item show arm abi
   26067 Show the currently used ABI.
   26068 
   26069 @item set arm fallback-mode (arm|thumb|auto)
   26070 @value{GDBN} uses the symbol table, when available, to determine
   26071 whether instructions are ARM or Thumb.  This command controls
   26072 @value{GDBN}'s default behavior when the symbol table is not
   26073 available.  The default is @samp{auto}, which causes @value{GDBN} to
   26074 use the current execution mode (from the @code{T} bit in the @code{CPSR}
   26075 register).
   26076 
   26077 @item show arm fallback-mode
   26078 Show the current fallback instruction mode.
   26079 
   26080 @item set arm force-mode (arm|thumb|auto)
   26081 This command overrides use of the symbol table to determine whether
   26082 instructions are ARM or Thumb.  The default is @samp{auto}, which
   26083 causes @value{GDBN} to use the symbol table and then the setting
   26084 of @samp{set arm fallback-mode}.
   26085 
   26086 @item show arm force-mode
   26087 Show the current forced instruction mode.
   26088 
   26089 @item set arm unwind-secure-frames
   26090 This command enables unwinding from Non-secure to Secure mode on
   26091 Cortex-M with Security extension.
   26092 This can trigger security exceptions when unwinding the exception
   26093 stack.
   26094 It is enabled by default.
   26095 
   26096 @item show arm unwind-secure-frames
   26097 Show whether unwinding from Non-secure to Secure mode is enabled.
   26098 
   26099 @item set debug arm
   26100 Toggle whether to display ARM-specific debugging messages from the ARM
   26101 target support subsystem.
   26102 
   26103 @item show debug arm
   26104 Show whether ARM-specific debugging messages are enabled.
   26105 @end table
   26106 
   26107 @table @code
   26108 @item target sim @r{[}@var{simargs}@r{]} @dots{} 
   26109 The @value{GDBN} ARM simulator accepts the following optional arguments.
   26110 
   26111 @table @code
   26112 @item --swi-support=@var{type}
   26113 Tell the simulator which SWI interfaces to support.  The argument
   26114 @var{type} may be a comma separated list of the following values.
   26115 The default value is @code{all}.
   26116 
   26117 @table @code
   26118 @item none
   26119 @item demon
   26120 @item angel
   26121 @item redboot
   26122 @item all
   26123 @end table
   26124 @end table
   26125 @end table
   26126 
   26127 @node BPF
   26128 @subsection BPF
   26129 
   26130 @table @code
   26131 @item target sim @r{[}@var{simargs}@r{]} @dots{}
   26132 The @value{GDBN} BPF simulator accepts the following optional arguments.
   26133 
   26134 @table @code
   26135 @item --skb-data-offset=@var{offset}
   26136 Tell the simulator the offset, measured in bytes, of the
   26137 @code{skb_data} field in the kernel @code{struct sk_buff} structure.
   26138 This offset is used by some BPF specific-purpose load/store
   26139 instructions.  Defaults to 0.
   26140 @end table
   26141 @end table
   26142 
   26143 @node M68K
   26144 @subsection M68k
   26145 
   26146 The Motorola m68k configuration includes ColdFire support.
   26147 
   26148 @node MicroBlaze
   26149 @subsection MicroBlaze
   26150 @cindex Xilinx MicroBlaze
   26151 @cindex XMD, Xilinx Microprocessor Debugger
   26152 
   26153 The MicroBlaze is a soft-core processor supported on various Xilinx
   26154 FPGAs, such as Spartan or Virtex series.  Boards with these processors
   26155 usually have JTAG ports which connect to a host system running the Xilinx
   26156 Embedded Development Kit (EDK) or Software Development Kit (SDK).
   26157 This host system is used to download the configuration bitstream to
   26158 the target FPGA.  The Xilinx Microprocessor Debugger (XMD) program
   26159 communicates with the target board using the JTAG interface and
   26160 presents a @code{gdbserver} interface to the board.  By default
   26161 @code{xmd} uses port @code{1234}.  (While it is possible to change 
   26162 this default port, it requires the use of undocumented @code{xmd} 
   26163 commands.  Contact Xilinx support if you need to do this.)
   26164 
   26165 Use these GDB commands to connect to the MicroBlaze target processor.
   26166 
   26167 @table @code
   26168 @item target remote :1234
   26169 Use this command to connect to the target if you are running @value{GDBN}
   26170 on the same system as @code{xmd}.
   26171 
   26172 @item target remote @var{xmd-host}:1234
   26173 Use this command to connect to the target if it is connected to @code{xmd}
   26174 running on a different system named @var{xmd-host}.
   26175 
   26176 @item load
   26177 Use this command to download a program to the MicroBlaze target.
   26178 
   26179 @item set debug microblaze @var{n}
   26180 Enable MicroBlaze-specific debugging messages if non-zero.
   26181 
   26182 @item show debug microblaze @var{n}
   26183 Show MicroBlaze-specific debugging level.
   26184 @end table
   26185 
   26186 @node MIPS Embedded
   26187 @subsection @acronym{MIPS} Embedded
   26188 
   26189 @noindent
   26190 @value{GDBN} supports these special commands for @acronym{MIPS} targets:
   26191 
   26192 @table @code
   26193 @item set mipsfpu double
   26194 @itemx set mipsfpu single
   26195 @itemx set mipsfpu none
   26196 @itemx set mipsfpu auto
   26197 @itemx show mipsfpu
   26198 @kindex set mipsfpu
   26199 @kindex show mipsfpu
   26200 @cindex @acronym{MIPS} remote floating point
   26201 @cindex floating point, @acronym{MIPS} remote
   26202 If your target board does not support the @acronym{MIPS} floating point
   26203 coprocessor, you should use the command @samp{set mipsfpu none} (if you
   26204 need this, you may wish to put the command in your @value{GDBN} init
   26205 file).  This tells @value{GDBN} how to find the return value of
   26206 functions which return floating point values.  It also allows
   26207 @value{GDBN} to avoid saving the floating point registers when calling
   26208 functions on the board.  If you are using a floating point coprocessor
   26209 with only single precision floating point support, as on the @sc{r4650}
   26210 processor, use the command @samp{set mipsfpu single}.  The default
   26211 double precision floating point coprocessor may be selected using
   26212 @samp{set mipsfpu double}.
   26213 
   26214 In previous versions the only choices were double precision or no
   26215 floating point, so @samp{set mipsfpu on} will select double precision
   26216 and @samp{set mipsfpu off} will select no floating point.
   26217 
   26218 As usual, you can inquire about the @code{mipsfpu} variable with
   26219 @samp{show mipsfpu}.
   26220 @end table
   26221 
   26222 @node OpenRISC 1000
   26223 @subsection OpenRISC 1000
   26224 @cindex OpenRISC 1000
   26225 
   26226 @noindent
   26227 The OpenRISC 1000 provides a free RISC instruction set architecture.  It is
   26228 mainly provided as a soft-core which can run on Xilinx, Altera and other
   26229 FPGA's.
   26230 
   26231 @value{GDBN} for OpenRISC supports the below commands when connecting to
   26232 a target:
   26233 
   26234 @table @code
   26235 
   26236 @kindex target sim
   26237 @item target sim
   26238 
   26239 Runs the builtin CPU simulator which can run very basic
   26240 programs but does not support most hardware functions like MMU.
   26241 For more complex use cases the user is advised to run an external
   26242 target, and connect using @samp{target remote}.
   26243 
   26244 Example: @code{target sim}
   26245 
   26246 @item set debug or1k
   26247 Toggle whether to display OpenRISC-specific debugging messages from the
   26248 OpenRISC target support subsystem.
   26249 
   26250 @item show debug or1k
   26251 Show whether OpenRISC-specific debugging messages are enabled.
   26252 @end table
   26253 
   26254 @node PowerPC Embedded
   26255 @subsection PowerPC Embedded
   26256 
   26257 @cindex DVC register
   26258 @value{GDBN} supports using the DVC (Data Value Compare) register to
   26259 implement in hardware simple hardware watchpoint conditions of the form:
   26260 
   26261 @smallexample
   26262 (@value{GDBP}) watch @var{address|variable} \
   26263   if  @var{address|variable} == @var{constant expression}
   26264 @end smallexample
   26265 
   26266 The DVC register will be automatically used when @value{GDBN} detects
   26267 such pattern in a condition expression, and the created watchpoint uses one
   26268 debug register (either the @code{exact-watchpoints} option is on and the
   26269 variable is scalar, or the variable has a length of one byte).  This feature
   26270 is available in native @value{GDBN} running on a Linux kernel version 2.6.34
   26271 or newer.
   26272 
   26273 When running on PowerPC embedded processors, @value{GDBN} automatically uses
   26274 ranged hardware watchpoints, unless the @code{exact-watchpoints} option is on,
   26275 in which case watchpoints using only one debug register are created when
   26276 watching variables of scalar types.
   26277 
   26278 You can create an artificial array to watch an arbitrary memory
   26279 region using one of the following commands (@pxref{Expressions}):
   26280 
   26281 @smallexample
   26282 (@value{GDBP}) watch *((char *) @var{address})@@@var{length}
   26283 (@value{GDBP}) watch @{char[@var{length}]@} @var{address}
   26284 @end smallexample
   26285 
   26286 PowerPC embedded processors support masked watchpoints.  See the discussion
   26287 about the @code{mask} argument in @ref{Set Watchpoints}.
   26288 
   26289 @cindex ranged breakpoint
   26290 PowerPC embedded processors support hardware accelerated
   26291 @dfn{ranged breakpoints}.  A ranged breakpoint stops execution of
   26292 the inferior whenever it executes an instruction at any address within
   26293 the range it was set at.  To set a ranged breakpoint in @value{GDBN},
   26294 use the @code{break-range} command.
   26295 
   26296 @value{GDBN} provides the following PowerPC-specific commands:
   26297 
   26298 @table @code
   26299 @kindex break-range
   26300 @item break-range @var{start-locspec}, @var{end-locspec}
   26301 Set a breakpoint for an address range given by @var{start-locspec} and
   26302 @var{end-locspec}, which are location specs.  @xref{Location
   26303 Specifications}, for a list of all the possible forms of location
   26304 specs.  @value{GDBN} resolves both @var{start-locspec} and
   26305 @var{end-locspec}, and uses the addresses of the resolved code
   26306 locations as start and end addresses of the range to break at.  The
   26307 breakpoint will stop execution of the inferior whenever it executes an
   26308 instruction at any address between the start and end addresses,
   26309 inclusive.  If either @var{start-locspec} or @var{end-locspec} resolve
   26310 to multiple code locations in the program, then the command aborts
   26311 with an error without creating a breakpoint.
   26312 
   26313 @kindex set powerpc
   26314 @item set powerpc soft-float
   26315 @itemx show powerpc soft-float
   26316 Force @value{GDBN} to use (or not use) a software floating point calling
   26317 convention.  By default, @value{GDBN} selects the calling convention based
   26318 on the selected architecture and the provided executable file.
   26319 
   26320 @item set powerpc vector-abi
   26321 @itemx show powerpc vector-abi
   26322 Force @value{GDBN} to use the specified calling convention for vector
   26323 arguments and return values.  The valid options are @samp{auto};
   26324 @samp{generic}, to avoid vector registers even if they are present;
   26325 @samp{altivec}, to use AltiVec registers; and @samp{spe} to use SPE
   26326 registers.  By default, @value{GDBN} selects the calling convention
   26327 based on the selected architecture and the provided executable file.
   26328 
   26329 @item set powerpc exact-watchpoints
   26330 @itemx show powerpc exact-watchpoints
   26331 Allow @value{GDBN} to use only one debug register when watching a variable
   26332 of scalar type, thus assuming that the variable is accessed through the
   26333 address of its first byte.
   26334 
   26335 @end table
   26336 
   26337 @node AVR
   26338 @subsection Atmel AVR
   26339 @cindex AVR
   26340 
   26341 When configured for debugging the Atmel AVR, @value{GDBN} supports the
   26342 following AVR-specific commands:
   26343 
   26344 @table @code
   26345 @item info io_registers
   26346 @kindex info io_registers@r{, AVR}
   26347 @cindex I/O registers (Atmel AVR)
   26348 This command displays information about the AVR I/O registers.  For
   26349 each register, @value{GDBN} prints its number and value.
   26350 @end table
   26351 
   26352 @node CRIS
   26353 @subsection CRIS
   26354 @cindex CRIS
   26355 
   26356 When configured for debugging CRIS, @value{GDBN} provides the
   26357 following CRIS-specific commands:
   26358 
   26359 @table @code
   26360 @item set cris-version @var{ver}
   26361 @cindex CRIS version
   26362 Set the current CRIS version to @var{ver}, either @samp{10} or @samp{32}.
   26363 The CRIS version affects register names and sizes.  This command is useful in
   26364 case autodetection of the CRIS version fails.
   26365 
   26366 @item show cris-version
   26367 Show the current CRIS version.
   26368 
   26369 @item set cris-dwarf2-cfi
   26370 @cindex DWARF-2 CFI and CRIS
   26371 Set the usage of DWARF-2 CFI for CRIS debugging.  The default is @samp{on}.
   26372 Change to @samp{off} when using @code{gcc-cris} whose version is below 
   26373 @code{R59}.
   26374 
   26375 @item show cris-dwarf2-cfi
   26376 Show the current state of using DWARF-2 CFI.
   26377 
   26378 @item set cris-mode @var{mode}
   26379 @cindex CRIS mode
   26380 Set the current CRIS mode to @var{mode}.  It should only be changed when
   26381 debugging in guru mode, in which case it should be set to 
   26382 @samp{guru} (the default is @samp{normal}).
   26383 
   26384 @item show cris-mode
   26385 Show the current CRIS mode.
   26386 @end table
   26387 
   26388 @node Super-H
   26389 @subsection Renesas Super-H
   26390 @cindex Super-H
   26391 
   26392 For the Renesas Super-H processor, @value{GDBN} provides these
   26393 commands:
   26394 
   26395 @table @code
   26396 @item set sh calling-convention @var{convention}
   26397 @kindex set sh calling-convention
   26398 Set the calling-convention used when calling functions from @value{GDBN}.
   26399 Allowed values are @samp{gcc}, which is the default setting, and @samp{renesas}.
   26400 With the @samp{gcc} setting, functions are called using the @value{NGCC} calling
   26401 convention.  If the DWARF-2 information of the called function specifies
   26402 that the function follows the Renesas calling convention, the function
   26403 is called using the Renesas calling convention.  If the calling convention
   26404 is set to @samp{renesas}, the Renesas calling convention is always used,
   26405 regardless of the DWARF-2 information.  This can be used to override the
   26406 default of @samp{gcc} if debug information is missing, or the compiler
   26407 does not emit the DWARF-2 calling convention entry for a function.
   26408 
   26409 @item show sh calling-convention
   26410 @kindex show sh calling-convention
   26411 Show the current calling convention setting.
   26412 
   26413 @end table
   26414 
   26415 
   26416 @node Architectures
   26417 @section Architectures
   26418 
   26419 This section describes characteristics of architectures that affect
   26420 all uses of @value{GDBN} with the architecture, both native and cross.
   26421 
   26422 @menu
   26423 * AArch64::
   26424 * x86::
   26425 * Alpha::
   26426 * MIPS::
   26427 * HPPA::               HP PA architecture
   26428 * PowerPC::
   26429 * Sparc64::
   26430 * S12Z::
   26431 * AMD GPU::            @acronym{AMD GPU} architectures
   26432 @end menu
   26433 
   26434 @node AArch64
   26435 @subsection AArch64
   26436 @cindex AArch64 support
   26437 
   26438 When @value{GDBN} is debugging the AArch64 architecture, it provides the
   26439 following special commands:
   26440 
   26441 @table @code
   26442 @item set debug aarch64
   26443 @kindex set debug aarch64
   26444 This command determines whether AArch64 architecture-specific debugging
   26445 messages are to be displayed.
   26446 
   26447 @item show debug aarch64
   26448 Show whether AArch64 debugging messages are displayed.
   26449 
   26450 @end table
   26451 
   26452 @subsubsection AArch64 SVE.
   26453 @cindex AArch64 SVE.
   26454 
   26455 When @value{GDBN} is debugging the AArch64 architecture, if the Scalable Vector
   26456 Extension (SVE) is present, then @value{GDBN} will provide the vector registers
   26457 @code{$z0} through @code{$z31}, vector predicate registers @code{$p0} through
   26458 @code{$p15}, and the @code{$ffr} register.  In addition, the pseudo register
   26459 @code{$vg} will be provided.  This is the vector granule for the current thread
   26460 and represents the number of 64-bit chunks in an SVE @code{z} register.
   26461 
   26462 If the vector length changes, then the @code{$vg} register will be updated,
   26463 but the lengths of the @code{z} and @code{p} registers will not change.  This
   26464 is a known limitation of @value{GDBN} and does not affect the execution of the
   26465 target process.
   26466 
   26467 For SVE, the following definitions are used throughout @value{GDBN}'s source
   26468 code and in this document:
   26469 
   26470 @itemize
   26471 
   26472 @item
   26473 @var{vl}: The vector length, in bytes.  It defines the size of each @code{Z}
   26474 register.
   26475 @anchor{vl}
   26476 @cindex vl
   26477 
   26478 @item
   26479 @var{vq}: The number of 128 bit units in @var{vl}.  This is mostly used
   26480 internally by @value{GDBN} and the Linux Kernel.
   26481 @anchor{vq}
   26482 @cindex vq
   26483 
   26484 @item
   26485 @var{vg}: The number of 64 bit units in @var{vl}.  This is mostly used
   26486 internally by @value{GDBN} and the Linux Kernel.
   26487 @anchor{vg}
   26488 @cindex vg
   26489 
   26490 @end itemize
   26491 
   26492 @subsubsection AArch64 SME.
   26493 @anchor{AArch64 SME}
   26494 @cindex SME
   26495 @cindex AArch64 SME
   26496 @cindex Scalable Matrix Extension
   26497 
   26498 The Scalable Matrix Extension (@url{https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/scalable-matrix-extension-armv9-a-architecture, @acronym{SME}})
   26499 is an AArch64 architecture extension that expands on the concept of the
   26500 Scalable Vector Extension (@url{https://developer.arm.com/documentation/101726/4-0/Learn-about-the-Scalable-Vector-Extension--SVE-/What-is-the-Scalable-Vector-Extension-, @acronym{SVE}})
   26501 by providing a 2-dimensional register @code{ZA}, which is a square
   26502 matrix of variable size, just like SVE provides a group of vector registers of
   26503 variable size.
   26504 
   26505 Similarly to SVE, where the size of each @code{Z} register is directly related
   26506 to the vector length (@var{vl} for short), the @acronym{SME} @code{ZA} matrix
   26507 register's size is directly related to the streaming vector length
   26508 (@var{svl} for short).  @xref{vl}.  @xref{svl}.
   26509 
   26510 The @code{ZA} register state can be either active or inactive, if it is not in
   26511 use.
   26512 
   26513 @acronym{SME} also introduces a new execution mode called streaming
   26514 @acronym{SVE} mode (streaming mode for short).  When streaming mode is
   26515 enabled, the program supports execution of @acronym{SVE2} instructions and the
   26516 @acronym{SVE} registers will have vector length @var{svl}.  When streaming
   26517 mode is disabled, the SVE registers have vector length @var{vl}.
   26518 
   26519 For more information about @acronym{SME} and @acronym{SVE}, please refer to
   26520 official @url{https://developer.arm.com/documentation/ddi0487/latest,
   26521 architecture documentation}.
   26522 
   26523 The following definitions are used throughout @value{GDBN}'s source code and
   26524 in this document:
   26525 
   26526 @itemize
   26527 
   26528 @item
   26529 @var{svl}: The streaming vector length, in bytes.  It defines the size of each
   26530 dimension of the 2-dimensional square @code{ZA} matrix.  The total size of
   26531 @code{ZA} is therefore @var{svl} by @var{svl}.
   26532 
   26533 When streaming mode is enabled, it defines the size of the @acronym{SVE}
   26534 registers as well.
   26535 @anchor{svl}
   26536 @cindex svl
   26537 
   26538 @item
   26539 @var{svq}: The number of 128 bit units in @var{svl}, also known as streaming
   26540 vector granule.  This is mostly used internally by @value{GDBN} and the Linux
   26541 Kernel.
   26542 @anchor{svq}
   26543 @cindex svq
   26544 
   26545 @item
   26546 @var{svg}: The number of 64 bit units in @var{svl}.  This is mostly used
   26547 internally by @value{GDBN} and the Linux Kernel.
   26548 @anchor{svg}
   26549 @cindex svg
   26550 
   26551 @end itemize
   26552 
   26553 When @value{GDBN} is debugging the AArch64 architecture, if the Scalable Matrix
   26554 Extension (@acronym{SME}) is present, then @value{GDBN} will make the @code{ZA}
   26555 register available.  @value{GDBN} will also make the @code{SVG} register and
   26556 @code{SVCR} pseudo-register available.
   26557 
   26558 The @code{ZA} register is a 2-dimensional square @var{svl} by @var{svl}
   26559 matrix of bytes.  To simplify the representation and access to the @code{ZA}
   26560 register in @value{GDBN}, it is defined as a vector of
   26561 @var{svl}x@var{svl} bytes.
   26562 
   26563 If the user wants to index the @code{ZA} register as a matrix, it is possible
   26564 to reference @code{ZA} as @code{ZA[@var{i}][@var{j}]}, where @var{i} is the
   26565 row number and @var{j} is the column number.
   26566 
   26567 The @code{SVG} register always contains the streaming vector granule
   26568 (@var{svg}) for the current thread.  From the value of register @code{SVG} we
   26569 can easily derive the @var{svl} value.
   26570 
   26571 @anchor{aarch64 sme svcr}
   26572 The @code{SVCR} pseudo-register (streaming vector control register) is a status
   26573 register that holds two state bits: @sc{sm} in bit 0 and @sc{za} in bit 1.
   26574 
   26575 If the @sc{sm} bit is 1, it means the current thread is in streaming
   26576 mode, and the @acronym{SVE} registers will use @var{svl} for their sizes.  If
   26577 the @sc{sm} bit is 0, the current thread is not in streaming mode, and the
   26578 @acronym{SVE} registers will use @var{vl} for their sizes.  @xref{vl}.
   26579 
   26580 If the @sc{za} bit is 1, it means the @code{ZA} register is being used and
   26581 has meaningful contents.  If the @sc{za} bit is 0, the @code{ZA} register is
   26582 unavailable and its contents are undefined.
   26583 
   26584 For convenience and simplicity, if the @sc{za} bit is 0, the @code{ZA}
   26585 register and all of its pseudo-registers will read as zero.
   26586 
   26587 If @var{svl} changes during the execution of a program, then the @code{ZA}
   26588 register size and the bits in the @code{SVCR} pseudo-register will be updated
   26589 to reflect it.
   26590 
   26591 It is possible for users to change @var{svl} during the execution of a
   26592 program by modifying the @code{SVG} register value.
   26593 
   26594 Whenever the @code{SVG} register is modified with a new value, the
   26595 following will be observed:
   26596 
   26597 @itemize
   26598 
   26599 @item The @sc{za} and @sc{sm} bits will be cleared in the @code{SVCR}
   26600 pseudo-register.
   26601 
   26602 @item The @code{ZA} register will have a new size and its state will be
   26603 cleared, forcing its contents and the contents of all of its pseudo-registers
   26604 back to zero.
   26605 
   26606 @item If the @sc{sm} bit was 1, the @acronym{SVE} registers will be reset to
   26607 having their sizes based on @var{vl} as opposed to @var{svl}.  If the
   26608 @sc{sm} bit was 0 prior to modifying the @code{SVG} register, there will be no
   26609 observable effect on the @acronym{SVE} registers.
   26610 
   26611 @end itemize
   26612 
   26613 The possible values for the @code{SVG} register are 2, 4, 8, 16, 32.  These
   26614 numbers correspond to streaming vector length (@var{svl}) values of 16
   26615 bytes, 32 bytes, 64 bytes, 128 bytes and 256 bytes respectively.
   26616 
   26617 The minimum size of the @code{ZA} register is 16 x 16 (256) bytes, and the
   26618 maximum size is 256 x 256 (65536) bytes.  In streaming mode, with bit @sc{sm}
   26619 set, the size of the @code{ZA} register is the size of all the SVE @code{Z}
   26620 registers combined.
   26621 
   26622 The @code{ZA} register can also be accessed using tiles and tile slices.
   26623 
   26624 Tile pseudo-registers are square, 2-dimensional sub-arrays of elements within
   26625 the @code{ZA} register.
   26626 
   26627 The tile pseudo-registers have the following naming pattern:
   26628 @code{ZA<@var{tile number}><@var{qualifier}>}.
   26629 
   26630 There is a total of 31 @code{ZA} tile pseudo-registers.  They are
   26631 @code{ZA0B}, @code{ZA0H} through @code{ZA1H}, @code{ZA0S} through @code{ZA3S},
   26632 @code{ZA0D} through @code{ZA7D} and @code{ZA0Q} through @code{ZA15Q}.
   26633 
   26634 Tile slice pseudo-registers are vectors of horizontally or vertically
   26635 contiguous elements within the @code{ZA} register.
   26636 
   26637 The tile slice pseudo-registers have the following naming pattern:
   26638 @code{ZA<@var{tile number}><@var{direction}><@var{qualifier}>
   26639 <@var{slice number}>}.
   26640 
   26641 There are up to 16 tiles (0 ~ 15), the direction can be either @code{v}
   26642 (vertical) or @code{h} (horizontal), the qualifiers can be @code{b} (byte),
   26643 @code{h} (halfword), @code{s} (word), @code{d} (doubleword) and @code{q}
   26644 (quadword) and there are up to 256 slices (0 ~ 255) depending on the value
   26645 of @var{svl}.  The number of slices is the same as the value of @var{svl}.
   26646 
   26647 The number of available tile slice pseudo-registers can be large.  For a
   26648 minimum @var{svl} of 16 bytes, there are 5 (number of qualifiers) x
   26649 2 (number of directions) x 16 (@var{svl}) pseudo-registers.  For the
   26650 maximum @var{svl} of 256 bytes, there are 5 x 2 x 256 pseudo-registers.
   26651 
   26652 When listing all the available registers, users will see the
   26653 currently-available @code{ZA} pseudo-registers.  Pseudo-registers that don't
   26654 exist for a given @var{svl} value will not be displayed.
   26655 
   26656 For more information on @acronym{SME} and its terminology, please refer to the
   26657 @url{https://developer.arm.com/documentation/ddi0616/aa/,
   26658 Arm Architecture Reference Manual Supplement}, The Scalable Matrix Extension
   26659 (@acronym{SME}), for Armv9-A.
   26660 
   26661 Some features are still under development and rely on
   26662 @url{https://github.com/ARM-software/acle/releases/latest, ACLE} and
   26663 @url{https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst, ABI}
   26664 definitions, so there are known limitations to the current @acronym{SME}
   26665 support in @value{GDBN}.
   26666 
   26667 One such example is calling functions in the program being debugged by
   26668 @value{GDBN}.  Such calls are not @acronym{SME}-aware and thus don't take into
   26669 account the @code{SVCR} pseudo-register bits nor the @code{ZA} register
   26670 contents.  @xref{Calling}.
   26671 
   26672 The @url{https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#the-za-lazy-saving-scheme,
   26673 lazy saving scheme} involving the @code{TPIDR2} register is not yet supported
   26674 by @value{GDBN}, though the @code{TPIDR2} register is known and supported
   26675 by @value{GDBN}.
   26676 
   26677 Lastly, an important limitation for @command{gdbserver} is its inability to
   26678 communicate @var{svl} changes to @value{GDBN}.  This means @command{gdbserver},
   26679 even though it is capable of adjusting its internal caches to reflect a change
   26680 in the value of @var{svl} mid-execution, will operate with a potentially
   26681 different @var{svl} value compared to @value{GDBN}.  This can lead to
   26682 @value{GDBN} showing incorrect values for the @code{ZA} register and
   26683 incorrect values for SVE registers (when in streaming mode).
   26684 
   26685 This is the same limitation we have for the @acronym{SVE} registers, and there
   26686 are plans to address this limitation going forward.
   26687 
   26688 @subsubsection AArch64 SME2.
   26689 @anchor{AArch64 SME2}
   26690 @cindex SME2
   26691 @cindex AArch64 SME2
   26692 @cindex Scalable Matrix Extension 2
   26693 
   26694 The Scalable Matrix Extension 2 is an AArch64 architecture extension that
   26695 further expands the @acronym{SME} extension with the following:
   26696 
   26697 @itemize
   26698 
   26699 @item The ability to address the @code{ZA} array through groups of
   26700 one-dimensional @code{ZA} array vectors, as opposed to @code{ZA} tiles
   26701 with 2 dimensions.
   26702 
   26703 @item Instructions to operate on groups of @acronym{SVE} @code{Z} registers and
   26704 @code{ZA} array vectors.
   26705 
   26706 @item A new 512 bit @code{ZT0} lookup table register, for data decompression.
   26707 
   26708 @end itemize
   26709 
   26710 When @value{GDBN} is debugging the AArch64 architecture, if the Scalable Matrix
   26711 Extension 2 (@acronym{SME2}) is present, then @value{GDBN} will make the
   26712 @code{ZT0} register available.
   26713 
   26714 The @code{ZT0} register is only considered active when the @code{ZA} register
   26715 state is active, therefore when the @sc{za} bit of the @code{SVCR} is 1.
   26716 
   26717 When the @sc{za} bit of @code{SVCR} is 0, that means the @code{ZA} register
   26718 state is not active, which means the @code{ZT0} register state is also not
   26719 active.
   26720 
   26721 When @code{ZT0} is not active, it is comprised of zeroes, just like @code{ZA}.
   26722 
   26723 Similarly to the @code{ZA} register, if the @code{ZT0} state is not active and
   26724 the user attempts to modify its value such that any of its bytes is non-zero,
   26725 then @value{GDBN} will initialize the @code{ZA} register state as well, which
   26726 means the @code{SVCR} @sc{za} bit gets set to 1.
   26727 
   26728 For more information about @acronym{SME2}, please refer to the
   26729 official @url{https://developer.arm.com/documentation/ddi0487/latest,
   26730 architecture documentation}.
   26731 
   26732 @subsubsection AArch64 Pointer Authentication.
   26733 @cindex AArch64 Pointer Authentication.
   26734 @anchor{AArch64 PAC}
   26735 
   26736 When @value{GDBN} is debugging the AArch64 architecture, and the program is
   26737 using the v8.3-A feature Pointer Authentication (PAC), then whenever the link
   26738 register @code{$lr} is pointing to an PAC function its value will be masked.
   26739 When GDB prints a backtrace, any addresses that required unmasking will be
   26740 postfixed with the marker [PAC].  When using the MI, this is printed as part
   26741 of the @code{addr_flags} field.
   26742 
   26743 @subsubsection AArch64 Memory Tagging Extension.
   26744 @cindex AArch64 Memory Tagging Extension.
   26745 
   26746 When @value{GDBN} is debugging the AArch64 architecture, the program is
   26747 using the v8.5-A feature Memory Tagging Extension (MTE) and there is support
   26748 in the kernel for MTE, @value{GDBN} will make memory tagging functionality
   26749 available for inspection and editing of logical and allocation tags.
   26750 @xref{Memory Tagging}.
   26751 
   26752 To aid debugging, @value{GDBN} will output additional information when SIGSEGV
   26753 signals are generated as a result of memory tag failures.
   26754 
   26755 If the tag violation is synchronous, the following will be shown:
   26756 
   26757 @smallexample
   26758 Program received signal SIGSEGV, Segmentation fault
   26759 Memory tag violation while accessing address 0x0500fffff7ff8000
   26760 Allocation tag 0x1
   26761 Logical tag 0x5.
   26762 @end smallexample
   26763 
   26764 If the tag violation is asynchronous, the fault address is not available.
   26765 In this case @value{GDBN} will show the following:
   26766 
   26767 @smallexample
   26768 Program received signal SIGSEGV, Segmentation fault
   26769 Memory tag violation
   26770 Fault address unavailable.
   26771 @end smallexample
   26772 
   26773 A special register, @code{tag_ctl}, is made available through the
   26774 @code{org.gnu.gdb.aarch64.mte} feature.  This register exposes some
   26775 options that can be controlled at runtime and emulates the @code{prctl}
   26776 option @code{PR_SET_TAGGED_ADDR_CTRL}.  For further information, see the
   26777 documentation in the Linux kernel.
   26778 
   26779 @value{GDBN} supports dumping memory tag data to core files through the
   26780 @command{gcore} command and reading memory tag data from core files generated
   26781 by the @command{gcore} command or the Linux kernel.
   26782 
   26783 When a process uses memory-mapped pages protected by memory tags (for
   26784 example, AArch64 MTE), this additional information will be recorded in
   26785 the core file in the event of a crash or if @value{GDBN} generates a core file
   26786 from the current process state.
   26787 
   26788 The memory tag data will be used so developers can display the memory
   26789 tags from a particular memory region (using the @samp{m} modifier to the
   26790 @command{x} command, using the @command{print} command or using the various
   26791 @command{memory-tag} subcommands.
   26792 
   26793 In the case of a crash, @value{GDBN} will attempt to retrieve the memory tag
   26794 information automatically from the core file, and will show one of the above
   26795 messages depending on whether the synchronous or asynchronous mode is selected.
   26796 @xref{Memory Tagging}. @xref{Memory}.
   26797 
   26798 @node x86
   26799 @subsection x86
   26800 
   26801 @table @code
   26802 @item set struct-convention @var{mode}
   26803 @kindex set struct-convention
   26804 @cindex struct return convention
   26805 @cindex struct/union returned in registers
   26806 Set the convention used by the inferior to return @code{struct}s and
   26807 @code{union}s from functions to @var{mode}.  Possible values of
   26808 @var{mode} are @code{"pcc"}, @code{"reg"}, and @code{"default"} (the
   26809 default).  @code{"default"} or @code{"pcc"} means that @code{struct}s
   26810 are returned on the stack, while @code{"reg"} means that a
   26811 @code{struct} or a @code{union} whose size is 1, 2, 4, or 8 bytes will
   26812 be returned in a register.
   26813 
   26814 @item show struct-convention
   26815 @kindex show struct-convention
   26816 Show the current setting of the convention to return @code{struct}s
   26817 from functions.
   26818 @end table
   26819 
   26820 @subsubsection x87 registers
   26821 
   26822 @value{GDBN} provides access to the x87 state through the following registers:
   26823 
   26824 @itemize
   26825 
   26826 @item @code{$st0} to @code{st7}: @code{ST(0)} to @code{ST(7)} floating-point
   26827 registers
   26828 @item @code{$fctrl}: control word register (@code{FCW})
   26829 @item @code{$fstat}: status word register (@code{FSW})
   26830 @item @code{$ftag}: tag word (@code{FTW})
   26831 @item @code{$fiseg}: last instruction pointer segment
   26832 @item @code{$fioff}: last instruction pointer
   26833 @item @code{$foseg}: last data pointer segment
   26834 @item @code{$fooff}: last data pointer
   26835 @item @code{$fop}: last opcode
   26836 
   26837 @end itemize
   26838 
   26839 @node Alpha
   26840 @subsection Alpha
   26841 
   26842 See the following section.
   26843 
   26844 @node MIPS
   26845 @subsection @acronym{MIPS}
   26846 
   26847 @cindex stack on Alpha
   26848 @cindex stack on @acronym{MIPS}
   26849 @cindex Alpha stack
   26850 @cindex @acronym{MIPS} stack
   26851 Alpha- and @acronym{MIPS}-based computers use an unusual stack frame, which
   26852 sometimes requires @value{GDBN} to search backward in the object code to
   26853 find the beginning of a function.
   26854 
   26855 @cindex response time, @acronym{MIPS} debugging
   26856 To improve response time (especially for embedded applications, where
   26857 @value{GDBN} may be restricted to a slow serial line for this search)
   26858 you may want to limit the size of this search, using one of these
   26859 commands:
   26860 
   26861 @table @code
   26862 @cindex @code{heuristic-fence-post} (Alpha, @acronym{MIPS})
   26863 @item set heuristic-fence-post @var{limit}
   26864 Restrict @value{GDBN} to examining at most @var{limit} bytes in its
   26865 search for the beginning of a function.  A value of @var{0} (the
   26866 default) means there is no limit.  However, except for @var{0}, the
   26867 larger the limit the more bytes @code{heuristic-fence-post} must search
   26868 and therefore the longer it takes to run.  You should only need to use
   26869 this command when debugging a stripped executable.
   26870 
   26871 @item show heuristic-fence-post
   26872 Display the current limit.
   26873 @end table
   26874 
   26875 @noindent
   26876 These commands are available @emph{only} when @value{GDBN} is configured
   26877 for debugging programs on Alpha or @acronym{MIPS} processors.
   26878 
   26879 Several @acronym{MIPS}-specific commands are available when debugging @acronym{MIPS}
   26880 programs:
   26881 
   26882 @table @code
   26883 @item set mips abi @var{arg}
   26884 @kindex set mips abi
   26885 @cindex set ABI for @acronym{MIPS}
   26886 Tell @value{GDBN} which @acronym{MIPS} ABI is used by the inferior.  Possible
   26887 values of @var{arg} are:
   26888 
   26889 @table @samp
   26890 @item auto
   26891 The default ABI associated with the current binary (this is the
   26892 default).
   26893 @item o32
   26894 @item o64
   26895 @item n32
   26896 @item n64
   26897 @item eabi32
   26898 @item eabi64
   26899 @end table
   26900 
   26901 @item show mips abi
   26902 @kindex show mips abi
   26903 Show the @acronym{MIPS} ABI used by @value{GDBN} to debug the inferior.
   26904 
   26905 @item set mips compression @var{arg}
   26906 @kindex set mips compression
   26907 @cindex code compression, @acronym{MIPS}
   26908 Tell @value{GDBN} which @acronym{MIPS} compressed
   26909 @acronym{ISA, Instruction Set Architecture} encoding is used by the
   26910 inferior.  @value{GDBN} uses this for code disassembly and other
   26911 internal interpretation purposes.  This setting is only referred to
   26912 when no executable has been associated with the debugging session or
   26913 the executable does not provide information about the encoding it uses.
   26914 Otherwise this setting is automatically updated from information
   26915 provided by the executable.
   26916 
   26917 Possible values of @var{arg} are @samp{mips16} and @samp{micromips}.
   26918 The default compressed @acronym{ISA} encoding is @samp{mips16}, as
   26919 executables containing @acronym{MIPS16} code frequently are not
   26920 identified as such.
   26921 
   26922 This setting is ``sticky''; that is, it retains its value across
   26923 debugging sessions until reset either explicitly with this command or
   26924 implicitly from an executable.
   26925 
   26926 The compiler and/or assembler typically add symbol table annotations to
   26927 identify functions compiled for the @acronym{MIPS16} or
   26928 @acronym{microMIPS} @acronym{ISA}s.  If these function-scope annotations
   26929 are present, @value{GDBN} uses them in preference to the global
   26930 compressed @acronym{ISA} encoding setting.
   26931 
   26932 @item show mips compression
   26933 @kindex show mips compression
   26934 Show the @acronym{MIPS} compressed @acronym{ISA} encoding used by
   26935 @value{GDBN} to debug the inferior.
   26936 
   26937 @item set mipsfpu
   26938 @itemx show mipsfpu
   26939 @xref{MIPS Embedded, set mipsfpu}.
   26940 
   26941 @item set mips mask-address @var{arg}
   26942 @kindex set mips mask-address
   26943 @cindex @acronym{MIPS} addresses, masking
   26944 This command determines whether the most-significant 32 bits of 64-bit
   26945 @acronym{MIPS} addresses are masked off.  The argument @var{arg} can be
   26946 @samp{on}, @samp{off}, or @samp{auto}.  The latter is the default
   26947 setting, which lets @value{GDBN} determine the correct value.
   26948 
   26949 @item show mips mask-address
   26950 @kindex show mips mask-address
   26951 Show whether the upper 32 bits of @acronym{MIPS} addresses are masked off or
   26952 not.
   26953 
   26954 @item set remote-mips64-transfers-32bit-regs
   26955 @kindex set remote-mips64-transfers-32bit-regs
   26956 This command controls compatibility with 64-bit @acronym{MIPS} targets that
   26957 transfer data in 32-bit quantities.  If you have an old @acronym{MIPS} 64 target
   26958 that transfers 32 bits for some registers, like @sc{sr} and @sc{fsr},
   26959 and 64 bits for other registers, set this option to @samp{on}.
   26960 
   26961 @item show remote-mips64-transfers-32bit-regs
   26962 @kindex show remote-mips64-transfers-32bit-regs
   26963 Show the current setting of compatibility with older @acronym{MIPS} 64 targets.
   26964 
   26965 @item set debug mips
   26966 @kindex set debug mips
   26967 This command turns on and off debugging messages for the @acronym{MIPS}-specific
   26968 target code in @value{GDBN}.
   26969 
   26970 @item show debug mips
   26971 @kindex show debug mips
   26972 Show the current setting of @acronym{MIPS} debugging messages.
   26973 @end table
   26974 
   26975 
   26976 @node HPPA
   26977 @subsection HPPA
   26978 @cindex HPPA support
   26979 
   26980 When @value{GDBN} is debugging the HP PA architecture, it provides the
   26981 following special commands:
   26982 
   26983 @table @code
   26984 @item set debug hppa
   26985 @kindex set debug hppa
   26986 This command determines whether HPPA architecture-specific debugging
   26987 messages are to be displayed.
   26988 
   26989 @item show debug hppa
   26990 Show whether HPPA debugging messages are displayed.
   26991 
   26992 @item maint print unwind @var{address}
   26993 @kindex maint print unwind@r{, HPPA}
   26994 This command displays the contents of the unwind table entry at the
   26995 given @var{address}.
   26996 
   26997 @end table
   26998 
   26999 
   27000 @node PowerPC
   27001 @subsection PowerPC
   27002 @cindex PowerPC architecture
   27003 
   27004 When @value{GDBN} is debugging the PowerPC architecture, it provides a set of 
   27005 pseudo-registers to enable inspection of 128-bit wide Decimal Floating Point
   27006 numbers stored in the floating point registers. These values must be stored
   27007 in two consecutive registers, always starting at an even register like
   27008 @code{f0} or @code{f2}.
   27009 
   27010 The pseudo-registers go from @code{$dl0} through @code{$dl15}, and are formed
   27011 by joining the even/odd register pairs @code{f0} and @code{f1} for @code{$dl0},
   27012 @code{f2} and @code{f3} for @code{$dl1} and so on.
   27013 
   27014 For POWER7 processors, @value{GDBN} provides a set of pseudo-registers, the 64-bit
   27015 wide Extended Floating Point Registers (@samp{f32} through @samp{f63}).
   27016 
   27017 @node Sparc64
   27018 @subsection Sparc64
   27019 @cindex Sparc64 support
   27020 @cindex Application Data Integrity
   27021 @subsubsection ADI Support
   27022 
   27023 The M7 processor supports an Application Data Integrity (ADI) feature that 
   27024 detects invalid data accesses.  When software allocates memory and enables 
   27025 ADI on the allocated memory, it chooses a 4-bit version number, sets the 
   27026 version in the upper 4 bits of the 64-bit pointer to that data, and stores 
   27027 the 4-bit version in every cacheline of that data.  Hardware saves the latter 
   27028 in spare bits in the cache and memory hierarchy.  On each load and store, 
   27029 the processor compares the upper 4 VA (virtual address) bits to the 
   27030 cacheline's version.  If there is a mismatch, the processor generates a 
   27031 version mismatch trap which can be either precise or disrupting.  The trap 
   27032 is an error condition which the kernel delivers to the process as a SIGSEGV 
   27033 signal.
   27034 
   27035 Note that only 64-bit applications can use ADI and need to be built with
   27036 ADI-enabled.
   27037 
   27038 Values of the ADI version tags, which are in granularity of a 
   27039 cacheline (64 bytes), can be viewed or modified. 
   27040 
   27041 
   27042 @table @code
   27043 @kindex adi examine
   27044 @item adi (examine | x) [ / @var{n} ] @var{addr}
   27045 
   27046 The @code{adi examine} command displays the value of one ADI version tag per 
   27047 cacheline. 
   27048 
   27049 @var{n} is a decimal integer specifying the number in bytes; the default 
   27050 is 1.  It specifies how much ADI version information, at the ratio of 1:ADI 
   27051 block size, to display. 
   27052 
   27053 @var{addr} is the address in user address space where you want @value{GDBN} 
   27054 to begin displaying the ADI version tags. 
   27055 
   27056 Below is an example of displaying ADI versions of variable "shmaddr".
   27057 
   27058 @smallexample
   27059 (@value{GDBP}) adi x/100 shmaddr
   27060    0xfff800010002c000:     0 0
   27061 @end smallexample
   27062 
   27063 @kindex adi assign
   27064 @item adi (assign | a) [ / @var{n} ] @var{addr} = @var{tag}
   27065 
   27066 The @code{adi assign} command is used to assign new ADI version tag 
   27067 to an address. 
   27068 
   27069 @var{n} is a decimal integer specifying the number in bytes; 
   27070 the default is 1.  It specifies how much ADI version information, at the 
   27071 ratio of 1:ADI block size, to modify. 
   27072 
   27073 @var{addr} is the address in user address space where you want @value{GDBN} 
   27074 to begin modifying the ADI version tags. 
   27075 
   27076 @var{tag} is the new ADI version tag.
   27077 
   27078 For example, do the following to modify then verify ADI versions of 
   27079 variable "shmaddr":
   27080 
   27081 @smallexample
   27082 (@value{GDBP}) adi a/100 shmaddr = 7
   27083 (@value{GDBP}) adi x/100 shmaddr
   27084    0xfff800010002c000:     7 7
   27085 @end smallexample
   27086 
   27087 @end table
   27088 
   27089 @node S12Z
   27090 @subsection S12Z
   27091 @cindex S12Z support
   27092 
   27093 When @value{GDBN} is debugging the S12Z architecture,
   27094 it provides the following special command:
   27095 
   27096 @table @code
   27097 @item maint info bdccsr
   27098 @kindex maint info bdccsr@r{, S12Z}
   27099 This command displays the current value of the microprocessor's
   27100 BDCCSR register.
   27101 @end table
   27102 
   27103 @node AMD GPU
   27104 @subsection @acronym{AMD GPU}
   27105 @cindex @acronym{AMD GPU} support
   27106 
   27107 @value{GDBN} supports debugging programs offloaded to @acronym{AMD GPU} devices
   27108 using the @url{https://docs.amd.com/, @acronym{AMD ROCm}} platform.
   27109 @value{GDBN} presents host threads alongside GPU wavefronts, allowing debugging
   27110 both the host and device parts of the program simultaneously.
   27111 
   27112 @subsubsection @acronym{AMD GPU} Architectures
   27113 
   27114 The list of @acronym{AMD GPU} architectures supported by @value{GDBN} depends
   27115 on the version of the AMD Debugger API library used.  See its
   27116 @uref{https://docs.amd.com/bundle/ROCDebugger_User_and_API, documentation} for
   27117 more details.
   27118 
   27119 @subsubsection @acronym{AMD GPU} Device Driver and @acronym{AMD ROCm} Runtime
   27120 
   27121 @value{GDBN} requires a compatible @acronym{AMD GPU} device driver to
   27122 be installed.  A warning message is displayed if either the device
   27123 driver version or the version of the debug support it implements is
   27124 unsupported.  @value{GDBN} will continue to function except no
   27125 @acronym{AMD GPU} debugging will be possible.
   27126 
   27127 @value{GDBN} requires each agent to have compatible firmware installed
   27128 by the device driver.  A warning message is displayed if unsupported
   27129 firmware is detected.  @value{GDBN} will continue to function except
   27130 no @acronym{AMD GPU} debugging will be possible on the agent.
   27131 
   27132 @value{GDBN} requires a compatible @acronym{AMD ROCm} runtime to be
   27133 loaded in order to detect @acronym{AMD GPU} code objects and
   27134 wavefronts.  A warning message is displayed if an unsupported
   27135 @acronym{AMD ROCm} runtime is detected, or there is an error or
   27136 restriction that prevents debugging.  @value{GDBN} will continue to
   27137 function except no @acronym{AMD GPU} debugging will be possible.
   27138 
   27139 @subsubsection @acronym{AMD GPU} Wavefronts
   27140 @cindex wavefronts
   27141 
   27142 An @acronym{AMD GPU} wavefront is represented in @value{GDBN} as a
   27143 thread.
   27144 
   27145 Note that some @acronym{AMD GPU} architectures may have restrictions
   27146 on providing information about @acronym{AMD GPU} wavefronts created
   27147 when @value{GDBN} is not attached (@pxref{AMD GPU Attaching
   27148 Restrictions, , @acronym{AMD GPU} Attaching Restrictions}).
   27149 
   27150 When scheduler-locking is in effect (@pxref{set scheduler-locking}),
   27151 new wavefronts created by the resumed thread (either CPU thread or GPU
   27152 wavefront) are held in the halt state.
   27153 
   27154 @subsubsection @acronym{AMD GPU} Code Objects
   27155 
   27156 The @samp{info sharedlibrary} command will show the @acronym{AMD GPU}
   27157 code objects as file or memory URIs, together with the host's shared
   27158 libraries.  For example:
   27159 
   27160 @smallexample
   27161 (@value{GDBP}) info sharedlibrary
   27162 From    To      Syms Read   Shared Object Library
   27163 0x1111  0x2222  Yes (*)     /lib64/ld-linux-x86-64.so.2
   27164 ...
   27165 0x3333  0x4444  Yes (*)     /opt/rocm-4.5.0/.../libamd_comgr.so
   27166 0x5555  0x6666  Yes (*)     /lib/x86_64-linux-gnu/libtinfo.so.5
   27167 0x7777  0x8888  Yes         file:///tmp/a.out#offset=6477&size=10832
   27168 0x9999  0xaaaa  Yes (*)     memory://95557/mem#offset=0x1234&size=100
   27169 (*): Shared library is missing debugging information.
   27170 (@value{GDBP})
   27171 @end smallexample
   27172 
   27173 For a @samp{file} URI, the path portion is the file on disk containing
   27174 the code object.  The @var{offset} parameter is a 0-based offset in
   27175 this file, to the start of the code object.  If omitted, it defaults to
   27176 0.  The @var{size} parameter is the size of the code object in bytes.
   27177 If omitted, it defaults to the size of the file.
   27178 
   27179 For a @samp{memory} URI, the path portion is the process id of the
   27180 process owning the memory containing the code object.  The @var{offset}
   27181 parameter is the memory address where the code object is found, and
   27182 the @var{size} parameter is its size in bytes.
   27183 
   27184 @acronym{AMD GPU} code objects are loaded into each @acronym{AMD GPU}
   27185 device separately.  The @samp{info sharedlibrary} command may
   27186 therefore show the same code object loaded multiple times.  As a
   27187 consequence, setting a breakpoint in @acronym{AMD GPU} code will
   27188 result in multiple breakpoint locations if there are multiple
   27189 @acronym{AMD GPU} devices.
   27190 
   27191 @subsubsection @acronym{AMD GPU} Entity Target Identifiers and Convenience Variables
   27192 
   27193 The @acronym{AMD GPU} entities have the following target identifier formats:
   27194 
   27195 @table @asis
   27196 
   27197 @item Thread Target ID
   27198 The @acronym{AMD GPU} thread target identifier (@var{systag}) string has the
   27199 following format:
   27200 
   27201 @smallexample
   27202 AMDGPU Wave @var{agent-id}:@var{queue-id}:@var{dispatch-id}:@var{wave-id} (@var{work-group-x},@var{work-group-y},@var{work-group-z})/@var{work-group-thread-index}
   27203 @end smallexample
   27204 
   27205 @end table
   27206 
   27207 @anchor{AMD GPU Signals}
   27208 @subsubsection @acronym{AMD GPU} Signals
   27209 
   27210 For @acronym{AMD GPU} wavefronts, @value{GDBN} maps target conditions to stop
   27211 signals in the following way:
   27212 
   27213 @table @code
   27214 
   27215 @item SIGILL
   27216 Execution of an illegal instruction.
   27217 
   27218 @item SIGTRAP
   27219 Execution of a @code{S_TRAP} instruction other than:
   27220 
   27221 @itemize @bullet{}
   27222 
   27223 @item
   27224 @code{S_TRAP 1} which is used by @value{GDBN} to insert breakpoints.
   27225 
   27226 @item
   27227 @code{S_TRAP 2} which raises @code{SIGABRT}.
   27228 
   27229 @end itemize
   27230 
   27231 @item SIGABRT
   27232 Execution of a @code{S_TRAP 2} instruction.
   27233 
   27234 @item SIGFPE
   27235 Execution of a floating point or integer instruction detects a
   27236 condition that is enabled to raise a signal.  The conditions include:
   27237 
   27238 @itemize @bullet{}
   27239 
   27240 @item
   27241 Floating point operation is invalid.
   27242 
   27243 @item
   27244 Floating point operation had subnormal input that was rounded to zero.
   27245 
   27246 @item
   27247 Floating point operation performed a division by zero.
   27248 
   27249 @item
   27250 Floating point operation produced an overflow result.  The result was
   27251 rounded to infinity.
   27252 
   27253 @item
   27254 Floating point operation produced an underflow result.  A subnormal
   27255 result was rounded to zero.
   27256 
   27257 @item
   27258 Floating point operation produced an inexact result.
   27259 
   27260 @item
   27261 Integer operation performed a division by zero.
   27262 
   27263 @end itemize
   27264 
   27265 By default, these conditions are not enabled to raise signals.  The
   27266 @samp{set $mode} command can be used to change the @acronym{AMD GPU}
   27267 wavefront's register that has bits controlling which conditions are
   27268 enabled to raise signals.  The @samp{print $trapsts} command can be
   27269 used to inspect which conditions have been detected even if they are
   27270 not enabled to raise a signal.
   27271 
   27272 @item SIGBUS
   27273 Execution of an instruction that accessed global memory using an
   27274 address that is outside the virtual address range.
   27275 
   27276 @item SIGSEGV
   27277 Execution of an instruction that accessed a global memory page that is
   27278 either not mapped or accessed with incompatible permissions.
   27279 
   27280 @end table
   27281 
   27282 If a single instruction raises more than one signal, they will be
   27283 reported one at a time each time the wavefront is continued.
   27284 
   27285 @subsubsection @acronym{AMD GPU} Memory Violation Reporting
   27286 
   27287 A wavefront can report memory violation events.  However, the program
   27288 location at which they are reported may be after the machine instruction
   27289 that caused them.  This can result in the reported source statement
   27290 being incorrect.  The following commands can be used to control this
   27291 behavior:
   27292 
   27293 @table @code
   27294 
   27295 @kindex set amdgpu precise-memory
   27296 @cindex AMD GPU precise memory event reporting
   27297 @item set amdgpu precise-memory @var{mode}
   27298 Controls how @acronym{AMD GPU} devices detect memory violations, where
   27299 @var{mode} can be:
   27300 
   27301 @table @code
   27302 
   27303 @item off
   27304 The program location may not be immediately after the instruction that
   27305 caused the memory violation.  This is the default.
   27306 
   27307 @item on
   27308 Requests that the program location will be immediately after the
   27309 instruction that caused a memory violation.  Enabling this mode may make
   27310 the @acronym{AMD GPU} device execution significantly slower as it has to
   27311 wait for each memory operation to complete before executing the next
   27312 instruction.
   27313 
   27314 @end table
   27315 
   27316 The @code{amdgpu precise-memory} parameter is per-inferior.  When an
   27317 inferior forks or execs, or the user uses the @code{clone-inferior} command,
   27318 and an inferior is created as a result, the newly created inferior inherits
   27319 the parameter value of the original inferior.
   27320 
   27321 @kindex show amdgpu precise-memory
   27322 @cindex AMD GPU precise memory event reporting
   27323 @item show amdgpu precise-memory
   27324 Displays the currently requested AMD GPU precise memory setting.
   27325 
   27326 @end table
   27327 
   27328 @subsubsection @acronym{AMD GPU} Logging
   27329 
   27330 The @samp{set debug amd-dbgapi} command can be used
   27331 to enable diagnostic messages in the @samp{amd-dbgapi} target.  The
   27332 @samp{show debug amd-dbgapi} command displays the current setting.
   27333 @xref{set debug amd-dbgapi}.
   27334 
   27335 The @samp{set debug amd-dbgapi-lib log-level @var{level}} command can be used
   27336 to enable diagnostic messages from the @samp{amd-dbgapi} library (which
   27337 @value{GDBN} uses under the hood).  The @samp{show debug amd-dbgapi-lib
   27338 log-level} command displays the current @samp{amd-dbgapi} library log level.
   27339 @xref{set debug amd-dbgapi-lib}.
   27340 
   27341 @subsubsection @acronym{AMD GPU} Restrictions
   27342 
   27343 @enumerate
   27344 
   27345 @item
   27346 When in non-stop mode, wavefronts may not hit breakpoints inserted
   27347 while not stopped, nor see memory updates made while not stopped,
   27348 until the wavefront is next stopped.  Memory updated by non-stopped
   27349 wavefronts may not be visible until the wavefront is next stopped.
   27350 
   27351 @item The HIP runtime performs deferred code object loading by default.
   27352 @acronym{AMD GPU} code objects are not loaded until the first kernel is
   27353 launched.  Before then, all breakpoints have to be set as pending breakpoints.
   27354 
   27355 If source line positions are used that only correspond to source lines in
   27356 unloaded code objects, then @value{GDBN} may not set pending breakpoints, and
   27357 instead set breakpoints on the next following source line that maps to host
   27358 code.  This can result in unexpected breakpoint hits being reported.  When the
   27359 code object containing the source lines is loaded, the incorrect breakpoints
   27360 will be removed and replaced by the correct ones.  This problem can be avoided
   27361 by only setting breakpoints in unloaded code objects using symbol or function
   27362 names.
   27363 
   27364 Setting the @code{HIP_ENABLE_DEFERRED_LOADING} environment variable to @code{0}
   27365 can be used to disable deferred code object loading by the HIP runtime.  This
   27366 ensures all code objects will be loaded when the inferior reaches the beginning
   27367 of the @code{main} function.
   27368 
   27369 @item
   27370 If no CPU thread is running, then @samp{Ctrl-C} is not able to stop
   27371 @acronym{AMD GPU} threads.  This can happen for example if you enable
   27372 @code{scheduler-locking} after the whole program stopped, and then resume an
   27373 @acronym{AMD GPU} thread.  The only way to unblock the situation is to kill the
   27374 @value{GDBN} process.
   27375 
   27376 @anchor{AMD GPU Attaching Restrictions}
   27377 @item
   27378 
   27379 By default, for some architectures, the @acronym{AMD GPU} device driver causes
   27380 all @acronym{AMD GPU} wavefronts created when @value{GDBN} is not attached to
   27381 be unable to report the dispatch associated with the wavefront, or the
   27382 wavefront's work-group position.  The @samp{info threads} command will display
   27383 this missing information with a @samp{?}.
   27384 
   27385 This does not affect wavefronts created while @value{GDBN} is attached which
   27386 are always capable of reporting this information.
   27387 
   27388 If the @env{HSA_ENABLE_DEBUG} environment variable is set to @samp{1} when the
   27389 @acronym{AMD ROCm} runtime is initialized, then this information will be
   27390 available for all architectures even for wavefronts created when @value{GDBN}
   27391 was not attached.
   27392 
   27393 @end enumerate
   27394 
   27395 @node Controlling GDB
   27396 @chapter Controlling @value{GDBN}
   27397 
   27398 You can alter the way @value{GDBN} interacts with you by using the
   27399 @code{set} command.  For commands controlling how @value{GDBN} displays
   27400 data, see @ref{Print Settings, ,Print Settings}.  Other settings are
   27401 described here.
   27402 
   27403 @menu
   27404 * Prompt::                      Prompt
   27405 * Editing::                     Command editing
   27406 * Command History::             Command history
   27407 * Screen Size::                 Screen size
   27408 * Output Styling::              Output styling
   27409 * Numbers::                     Numbers
   27410 * ABI::                         Configuring the current ABI
   27411 * Auto-loading::                Automatically loading associated files
   27412 * Messages/Warnings::           Optional warnings and messages
   27413 * Debugging Output::            Optional messages about internal happenings
   27414 * Other Misc Settings::         Other Miscellaneous Settings
   27415 @end menu
   27416 
   27417 @node Prompt
   27418 @section Prompt
   27419 
   27420 @cindex prompt
   27421 
   27422 @value{GDBN} indicates its readiness to read a command by printing a string
   27423 called the @dfn{prompt}.  This string is normally @samp{(@value{GDBP})}.  You
   27424 can change the prompt string with the @code{set prompt} command.  For
   27425 instance, when debugging @value{GDBN} with @value{GDBN}, it is useful to change
   27426 the prompt in one of the @value{GDBN} sessions so that you can always tell
   27427 which one you are talking to.
   27428 
   27429 @emph{Note:}  @code{set prompt} does not add a space for you after the
   27430 prompt you set.  This allows you to set a prompt which ends in a space
   27431 or a prompt that does not.
   27432 
   27433 @table @code
   27434 @kindex set prompt
   27435 @item set prompt @var{newprompt}
   27436 Directs @value{GDBN} to use @var{newprompt} as its prompt string henceforth.
   27437 
   27438 @kindex show prompt
   27439 @item show prompt
   27440 Prints a line of the form: @samp{Gdb's prompt is: @var{your-prompt}}
   27441 @end table
   27442 
   27443 Versions of @value{GDBN} that ship with Python scripting enabled have
   27444 prompt extensions.  The commands for interacting with these extensions
   27445 are:
   27446 
   27447 @table @code
   27448 @kindex set extended-prompt
   27449 @item set extended-prompt @var{prompt}
   27450 Set an extended prompt that allows for substitutions.
   27451 @xref{gdb.prompt}, for a list of escape sequences that can be used for
   27452 substitution.  Any escape sequences specified as part of the prompt
   27453 string are replaced with the corresponding strings each time the prompt
   27454 is displayed.
   27455 
   27456 For example:
   27457 
   27458 @smallexample
   27459 set extended-prompt Current working directory: \w (@value{GDBP})
   27460 @end smallexample
   27461 
   27462 Note that when an extended-prompt is set, it takes control of the
   27463 @var{prompt_hook} hook.  @xref{prompt_hook}, for further information.
   27464 
   27465 @kindex show extended-prompt
   27466 @item show extended-prompt
   27467 Prints the extended prompt.  Any escape sequences specified as part of
   27468 the prompt string with @code{set extended-prompt}, are replaced with the
   27469 corresponding strings each time the prompt is displayed.
   27470 @end table
   27471 
   27472 @node Editing
   27473 @section Command Editing
   27474 @cindex readline
   27475 @cindex command line editing
   27476 
   27477 @value{GDBN} reads its input commands via the @dfn{Readline} interface.  This
   27478 @sc{gnu} library provides consistent behavior for programs which provide a
   27479 command line interface to the user.  Advantages are @sc{gnu} Emacs-style
   27480 or @dfn{vi}-style inline editing of commands, @code{csh}-like history
   27481 substitution, and a storage and recall of command history across
   27482 debugging sessions.
   27483 
   27484 You may control the behavior of command line editing in @value{GDBN} with the
   27485 command @code{set}.
   27486 
   27487 @table @code
   27488 @kindex set editing
   27489 @cindex editing
   27490 @item set editing
   27491 @itemx set editing on
   27492 Enable command line editing (enabled by default).
   27493 
   27494 @item set editing off
   27495 Disable command line editing.
   27496 
   27497 @kindex show editing
   27498 @item show editing
   27499 Show whether command line editing is enabled.
   27500 @end table
   27501 
   27502 @ifset SYSTEM_READLINE
   27503 @xref{Command Line Editing, , , rluserman, GNU Readline Library},
   27504 @end ifset
   27505 @ifclear SYSTEM_READLINE
   27506 @xref{Command Line Editing},
   27507 @end ifclear
   27508 for more details about the Readline
   27509 interface.  Users unfamiliar with @sc{gnu} Emacs or @code{vi} are
   27510 encouraged to read that chapter.
   27511 
   27512 @cindex Readline application name
   27513 @value{GDBN} sets the Readline application name to @samp{gdb}.  This
   27514 is useful for conditions in @file{.inputrc}.
   27515 
   27516 @cindex operate-and-get-next
   27517 @value{GDBN} defines a bindable Readline command,
   27518 @code{operate-and-get-next}.  This is bound to @kbd{C-o} by default.
   27519 This command accepts the current line for execution and fetches the
   27520 next line relative to the current line from the history for editing.
   27521 Any argument is ignored.
   27522 
   27523 It is possible to discover which version of Readline @value{GDBN} is
   27524 using with the @kbd{show configuration} command (@pxref{show
   27525 configuration}).
   27526 
   27527 @node Command History
   27528 @section Command History
   27529 @cindex command history
   27530 
   27531 @value{GDBN} can keep track of the commands you type during your
   27532 debugging sessions, so that you can be certain of precisely what
   27533 happened.  Use these commands to manage the @value{GDBN} command
   27534 history facility.
   27535 
   27536 @value{GDBN} uses the @sc{gnu} History library, a part of the Readline
   27537 package, to provide the history facility.
   27538 @ifset SYSTEM_READLINE
   27539 @xref{Using History Interactively, , , history, GNU History Library},
   27540 @end ifset
   27541 @ifclear SYSTEM_READLINE
   27542 @xref{Using History Interactively},
   27543 @end ifclear
   27544 for the detailed description of the History library.
   27545 
   27546 To issue a command to @value{GDBN} without affecting certain aspects of
   27547 the state which is seen by users, prefix it with @samp{server }
   27548 (@pxref{Server Prefix}).  This
   27549 means that this command will not affect the command history, nor will it
   27550 affect @value{GDBN}'s notion of which command to repeat if @key{RET} is
   27551 pressed on a line by itself.
   27552 
   27553 @cindex @code{server}, command prefix
   27554 The server prefix does not affect the recording of values into the value
   27555 history; to print a value without recording it into the value history,
   27556 use the @code{output} command instead of the @code{print} command.
   27557 
   27558 Here is the description of @value{GDBN} commands related to command
   27559 history.
   27560 
   27561 @table @code
   27562 @cindex history substitution
   27563 @cindex history file
   27564 @kindex set history filename
   27565 @cindex @env{GDBHISTFILE}, environment variable
   27566 @item set history filename @r{[}@var{fname}@r{]}
   27567 Set the name of the @value{GDBN} command history file to @var{fname}.
   27568 This is the file where @value{GDBN} reads an initial command history
   27569 list, and where it writes the command history from this session when it
   27570 exits.  You can access this list through history expansion or through
   27571 the history command editing characters listed below.  This file defaults
   27572 to the value of the environment variable @env{GDBHISTFILE}, or to
   27573 @file{./.gdb_history} (@file{./_gdb_history} on MS-DOS) if this variable
   27574 is not set.
   27575 
   27576 The @env{GDBHISTFILE} environment variable is read after processing
   27577 any @value{GDBN} initialization files (@pxref{Startup}) and after
   27578 processing any commands passed using command line options (for
   27579 example, @code{-ex}).
   27580 
   27581 If the @var{fname} argument is not given, or if the @env{GDBHISTFILE}
   27582 is the empty string then @value{GDBN} will neither try to load an
   27583 existing history file, nor will it try to save the history on exit.
   27584 
   27585 @cindex save command history
   27586 @kindex set history save
   27587 @item set history save
   27588 @itemx set history save on
   27589 Record command history in a file, whose name may be specified with the
   27590 @code{set history filename} command.  By default, this option is
   27591 disabled.  The command history will be recorded when @value{GDBN}
   27592 exits.  If @code{set history filename} is set to the empty string then
   27593 history saving is disabled, even when @code{set history save} is
   27594 @code{on}.
   27595 
   27596 @item set history save off
   27597 Don't record the command history into the file specified by @code{set
   27598 history filename} when @value{GDBN} exits.
   27599 
   27600 @cindex history size
   27601 @kindex set history size
   27602 @cindex @env{GDBHISTSIZE}, environment variable
   27603 @item set history size @var{size}
   27604 @itemx set history size unlimited
   27605 Set the number of commands which @value{GDBN} keeps in its history list.
   27606 This defaults to the value of the environment variable @env{GDBHISTSIZE}, or
   27607 to 256 if this variable is not set.  Non-numeric values of @env{GDBHISTSIZE}
   27608 are ignored.  If @var{size} is @code{unlimited} or if @env{GDBHISTSIZE} is
   27609 either a negative number or the empty string, then the number of commands
   27610 @value{GDBN} keeps in the history list is unlimited.
   27611 
   27612 The @env{GDBHISTSIZE} environment variable is read after processing
   27613 any @value{GDBN} initialization files (@pxref{Startup}) and after
   27614 processing any commands passed using command line options (for
   27615 example, @code{-ex}).
   27616 
   27617 @cindex remove duplicate history
   27618 @kindex set history remove-duplicates
   27619 @item set history remove-duplicates @var{count}
   27620 @itemx set history remove-duplicates unlimited
   27621 Control the removal of duplicate history entries in the command history list.
   27622 If @var{count} is non-zero, @value{GDBN} will look back at the last @var{count}
   27623 history entries and remove the first entry that is a duplicate of the current
   27624 entry being added to the command history list.  If @var{count} is
   27625 @code{unlimited} then this lookbehind is unbounded.  If @var{count} is 0, then
   27626 removal of duplicate history entries is disabled.
   27627 
   27628 Only history entries added during the current session are considered for
   27629 removal.  This option is set to 0 by default.
   27630 
   27631 @end table
   27632 
   27633 History expansion assigns special meaning to the character @kbd{!}.
   27634 @ifset SYSTEM_READLINE
   27635 @xref{Event Designators, , , history, GNU History Library},
   27636 @end ifset
   27637 @ifclear SYSTEM_READLINE
   27638 @xref{Event Designators},
   27639 @end ifclear
   27640 for more details.
   27641 
   27642 @cindex history expansion, turn on/off
   27643 Since @kbd{!} is also the logical not operator in C, history expansion
   27644 is off by default. If you decide to enable history expansion with the
   27645 @code{set history expansion on} command, you may sometimes need to
   27646 follow @kbd{!} (when it is used as logical not, in an expression) with
   27647 a space or a tab to prevent it from being expanded.  The readline
   27648 history facilities do not attempt substitution on the strings
   27649 @kbd{!=} and @kbd{!(}, even when history expansion is enabled.
   27650 
   27651 The commands to control history expansion are:
   27652 
   27653 @table @code
   27654 @item set history expansion on
   27655 @itemx set history expansion
   27656 @kindex set history expansion
   27657 Enable history expansion.  History expansion is off by default.
   27658 
   27659 @item set history expansion off
   27660 Disable history expansion.
   27661 
   27662 @c @group
   27663 @kindex show history
   27664 @item show history
   27665 @itemx show history filename
   27666 @itemx show history save
   27667 @itemx show history size
   27668 @itemx show history expansion
   27669 These commands display the state of the @value{GDBN} history parameters.
   27670 @code{show history} by itself displays all four states.
   27671 @c @end group
   27672 @end table
   27673 
   27674 @table @code
   27675 @kindex show commands
   27676 @cindex show last commands
   27677 @cindex display command history
   27678 @item show commands
   27679 Display the last ten commands in the command history.
   27680 
   27681 @item show commands @var{n}
   27682 Print ten commands centered on command number @var{n}.
   27683 
   27684 @item show commands +
   27685 Print ten commands just after the commands last printed.
   27686 @end table
   27687 
   27688 @node Screen Size
   27689 @section Screen Size
   27690 @cindex size of screen
   27691 @cindex screen size
   27692 @cindex pagination
   27693 @cindex page size
   27694 @cindex pauses in output
   27695 
   27696 Certain commands to @value{GDBN} may produce large amounts of
   27697 information output to the screen.  To help you read all of it,
   27698 @value{GDBN} pauses and asks you for input at the end of each page of
   27699 output.  Type @key{RET} when you want to see one more page of output,
   27700 @kbd{q} to discard the remaining output, or @kbd{c} to continue
   27701 without paging for the rest of the current command.  Also, the screen
   27702 width setting determines when to wrap lines of output.  Depending on
   27703 what is being printed, @value{GDBN} tries to break the line at a
   27704 readable place, rather than simply letting it overflow onto the
   27705 following line.
   27706 
   27707 Normally @value{GDBN} knows the size of the screen from the terminal
   27708 driver software.  For example, on Unix @value{GDBN} uses the termcap data base
   27709 together with the value of the @env{TERM} environment variable and the
   27710 @code{stty rows} and @code{stty cols} settings.  If this is not correct,
   27711 you can override it with the @code{set height} and @code{set
   27712 width} commands:
   27713 
   27714 @table @code
   27715 @kindex set height
   27716 @kindex set width
   27717 @kindex show width
   27718 @kindex show height
   27719 @item set height @var{lpp}
   27720 @itemx set height unlimited
   27721 @itemx show height
   27722 @itemx set width @var{cpl}
   27723 @itemx set width unlimited
   27724 @itemx show width
   27725 These @code{set} commands specify a screen height of @var{lpp} lines and
   27726 a screen width of @var{cpl} characters.  The associated @code{show}
   27727 commands display the current settings.
   27728 
   27729 If you specify a height of either @code{unlimited} or zero lines,
   27730 @value{GDBN} does not pause during output no matter how long the
   27731 output is.  This is useful if output is to a file or to an editor
   27732 buffer.
   27733 
   27734 Likewise, you can specify @samp{set width unlimited} or @samp{set
   27735 width 0} to prevent @value{GDBN} from wrapping its output.
   27736 
   27737 @item set pagination on
   27738 @itemx set pagination off
   27739 @kindex set pagination
   27740 Turn the output pagination on or off; the default is on.  Turning
   27741 pagination off is the alternative to @code{set height unlimited}.  Note that
   27742 running @value{GDBN} with the @option{--batch} option (@pxref{Mode
   27743 Options, -batch}) also automatically disables pagination.
   27744 
   27745 @item show pagination
   27746 @kindex show pagination
   27747 Show the current pagination mode.
   27748 @end table
   27749 
   27750 @node Output Styling
   27751 @section Output Styling
   27752 @cindex styling
   27753 @cindex colors
   27754 
   27755 @kindex set style
   27756 @kindex show style
   27757 @value{GDBN} can style its output on a capable terminal.  This is
   27758 enabled by default on most systems, but disabled by default when in
   27759 batch mode (@pxref{Mode Options}).  Various style settings are available;
   27760 and styles can also be disabled entirely.
   27761 
   27762 @table @code
   27763 @item set style enabled @samp{on|off}
   27764 Enable or disable all styling.  The default is host-dependent, with
   27765 most hosts defaulting to @samp{on}.
   27766 
   27767 If the @env{NO_COLOR} environment variable is set to a non-empty
   27768 value, then @value{GDBN} will change this to @samp{off} at startup.
   27769 
   27770 @item show style enabled
   27771 Show the current state of styling.
   27772 
   27773 @item set style sources @samp{on|off}
   27774 Enable or disable source code styling.  This affects whether source
   27775 code, such as the output of the @code{list} command, is styled.  The
   27776 default is @samp{on}.  Note that source styling only works if styling
   27777 in general is enabled, and if a source highlighting library is
   27778 available to @value{GDBN}.
   27779 
   27780 There are two ways that highlighting can be done.  First, if
   27781 @value{GDBN} was linked with the GNU Source Highlight library, then it
   27782 is used.  Otherwise, if @value{GDBN} was configured with Python
   27783 scripting support, and if the Python Pygments package is available,
   27784 then it will be used.
   27785 
   27786 @item show style sources
   27787 Show the current state of source code styling.
   27788 
   27789 @item set style tui-current-position @samp{on|off}
   27790 Enable or disable styling of the source and assembly code highlighted
   27791 by the TUI's current position indicator.  The default is @samp{off}.
   27792 @xref{TUI, ,@value{GDBN} Text User Interface}.
   27793 
   27794 @item show style tui-current-position
   27795 Show whether the source and assembly code highlighted by the TUI's
   27796 current position indicator is styled.
   27797 
   27798 @anchor{style_disassembler_enabled}
   27799 @item set style disassembler enabled @samp{on|off}
   27800 Enable or disable disassembler styling.  This affects whether
   27801 disassembler output, such as the output of the @code{disassemble}
   27802 command, is styled.  Disassembler styling only works if styling in
   27803 general is enabled (with @code{set style enabled on}), and if a source
   27804 highlighting library is available to @value{GDBN}.
   27805 
   27806 The two source highlighting libraries that @value{GDBN} could use to
   27807 style disassembler output are; @value{GDBN}'s builtin disassembler, or
   27808 the Python Pygments package.
   27809 
   27810 @value{GDBN}'s first choice will be to use the builtin disassembler
   27811 for styling, this usually provides better results, being able to style
   27812 different types of instruction operands differently.  However, the
   27813 builtin disassembler is not able to style all architectures.
   27814 
   27815 For architectures that the builtin disassembler is unable to style,
   27816 @value{GDBN} will fall back to use the Python Pygments package where
   27817 possible.  In order to use the Python Pygments package, @value{GDBN}
   27818 must be built with Python support, and the Pygments package must be
   27819 installed.
   27820 
   27821 If neither of these options are available then @value{GDBN} will
   27822 produce unstyled disassembler output, even when this setting is
   27823 @samp{on}.
   27824 
   27825 To discover if the current architecture supports styling using the
   27826 builtin disassembler library see @ref{maint_libopcodes_styling,,@kbd{maint
   27827 show libopcodes-styling enabled}}.
   27828 
   27829 @item show style disassembler enabled
   27830 Show the current state of disassembler styling.
   27831 
   27832 @end table
   27833 
   27834 Subcommands of @code{set style} control specific forms of styling.
   27835 These subcommands all follow the same pattern: each style-able object
   27836 can be styled with a foreground color, a background color, and an
   27837 intensity.
   27838 
   27839 For example, the style of file names can be controlled using the
   27840 @code{set style filename} group of commands:
   27841 
   27842 @table @code
   27843 @item set style filename background @var{color}
   27844 Set the background to @var{color}.  Valid colors are @samp{none}
   27845 (meaning the terminal's default color), @samp{black}, @samp{red},
   27846 @samp{green}, @samp{yellow}, @samp{blue}, @samp{magenta}, @samp{cyan},
   27847 and@samp{white}.
   27848 
   27849 @item set style filename foreground @var{color}
   27850 Set the foreground to @var{color}.  Valid colors are @samp{none}
   27851 (meaning the terminal's default color), @samp{black}, @samp{red},
   27852 @samp{green}, @samp{yellow}, @samp{blue}, @samp{magenta}, @samp{cyan},
   27853 and@samp{white}.
   27854 
   27855 @item set style filename intensity @var{value}
   27856 Set the intensity to @var{value}.  Valid intensities are @samp{normal}
   27857 (the default), @samp{bold}, and @samp{dim}.
   27858 @end table
   27859 
   27860 The @code{show style} command and its subcommands are styling
   27861 a style name in their output using its own style.
   27862 So, use @command{show style} to see the complete list of styles,
   27863 their characteristics and the visual aspect of each style.
   27864 
   27865 The style-able objects are:
   27866 @table @code
   27867 @item command
   27868 Control the styling of any @value{GDBN} commands that are displayed by
   27869 @value{GDBN}.  By default, this style's intensity is bold.
   27870 
   27871 @item filename
   27872 Control the styling of file names and URLs.  By default, this style's
   27873 foreground color is green.
   27874 
   27875 @item function
   27876 Control the styling of function names.  These are managed with the
   27877 @code{set style function} family of commands.  By default, this
   27878 style's foreground color is yellow.
   27879 
   27880 This style is also used for symbol names in styled disassembler output
   27881 if @value{GDBN} is using its builtin disassembler library for styling
   27882 (@pxref{style_disassembler_enabled,,@kbd{set style disassembler
   27883 enabled}}).
   27884 
   27885 @item line-number
   27886 Control the styling of line numbers.  By default, this style's
   27887 intensity is dim.
   27888 
   27889 @item variable
   27890 Control the styling of variable names.  These are managed with the
   27891 @code{set style variable} family of commands.  By default, this style's
   27892 foreground color is cyan.
   27893 
   27894 @item address
   27895 Control the styling of addresses.  These are managed with the
   27896 @code{set style address} family of commands.  By default, this style's
   27897 foreground color is blue.
   27898 
   27899 This style is also used for addresses in styled disassembler output
   27900 if @value{GDBN} is using its builtin disassembler library for styling
   27901 (@pxref{style_disassembler_enabled,,@kbd{set style disassembler
   27902 enabled}}).
   27903 
   27904 @item version
   27905 Control the styling of @value{GDBN}'s version number text.  By
   27906 default, this style's foreground color is magenta and it has bold
   27907 intensity.  The version number is displayed in two places, the output
   27908 of @command{show version}, and when @value{GDBN} starts up.
   27909 
   27910 In order to control how @value{GDBN} styles the version number at
   27911 startup, add the @code{set style version} family of commands to the
   27912 early initialization command file (@pxref{Initialization
   27913 Files}).
   27914 
   27915 @item title
   27916 Control the styling of titles.  These are managed with the
   27917 @code{set style title} family of commands.  By default, this style's
   27918 intensity is bold.  The title style is used when displaying the header
   27919 line of a list, for example the first line of the output of
   27920 @code{info breakpoints} (@pxref{Set Breaks}).
   27921 
   27922 @item highlight
   27923 Control the styling of highlightings.  These are managed with the
   27924 @code{set style highlight} family of commands.  By default, this style's
   27925 foreground color is red.  Commands are using the highlight style to draw
   27926 the user attention to some specific parts of their output.  For example,
   27927 the command @command{apropos -v REGEXP} uses the highlight style to
   27928 mark the documentation parts matching @var{regexp}.
   27929 
   27930 @item metadata
   27931 Control the styling of data annotations added by @value{GDBN} to data
   27932 it displays.  By default, this style's intensity is dim.  Metadata
   27933 annotations include the @samp{repeats @var{n} times} annotation for
   27934 suppressed display of repeated array elements (@pxref{Print Settings}),
   27935 @samp{<unavailable>} and @w{@samp{<error @var{descr}>}} annotations
   27936 for errors and @samp{<optimized-out>} annotations for optimized-out
   27937 values in displaying stack frame information in backtraces
   27938 (@pxref{Backtrace}), etc.
   27939 
   27940 @item tui-border
   27941 Control the styling of the TUI border.  Note that, unlike other
   27942 styling options, only the color of the border can be controlled via
   27943 @code{set style}.  This was done for compatibility reasons, as TUI
   27944 controls to set the border's intensity predated the addition of
   27945 general styling to @value{GDBN}.  @xref{TUI Configuration}.
   27946 
   27947 @item tui-active-border
   27948 Control the styling of the active TUI border; that is, the TUI window
   27949 that has the focus.
   27950 
   27951 @item disassembler comment
   27952 Control the styling of comments in the disassembler output.  These are
   27953 managed with the @code{set style disassembler comment} family of
   27954 commands.  This style is only used when @value{GDBN} is styling using
   27955 its builtin disassembler library
   27956 (@pxref{style_disassembler_enabled,,@kbd{set style disassembler
   27957 enabled}}).  By default, this style's intensity is dim, and its
   27958 foreground color is white.
   27959 
   27960 @item disassembler immediate
   27961 Control the styling of numeric operands in the disassembler output.
   27962 These are managed with the @code{set style disassembler immediate}
   27963 family of commands.  This style is not used for instruction operands
   27964 that represent addresses, in that case the @samp{disassembler address}
   27965 style is used.  This style is only used when @value{GDBN} is styling
   27966 using its builtin disassembler library.  By default, this style's
   27967 foreground color is blue.
   27968 
   27969 @item disassembler address
   27970 Control the styling of address operands in the disassembler output.
   27971 This is an alias for the @samp{address} style.
   27972 
   27973 @item disassembler symbol
   27974 Control the styling of symbol names in the disassembler output.  This
   27975 is an alias for the @samp{function} style.
   27976 
   27977 @item disassembler mnemonic
   27978 Control the styling of instruction mnemonics in the disassembler
   27979 output.  These are managed with the @code{set style disassembler
   27980 mnemonic} family of commands.  This style is also used for assembler
   27981 directives, e.g.@: @code{.byte}, @code{.word}, etc.  This style is
   27982 only used when @value{GDBN} is styling using its builtin disassembler
   27983 library.  By default, this style's foreground color is green.
   27984 
   27985 @item disassembler register
   27986 Control the styling of register operands in the disassembler output.
   27987 These are managed with the @code{set style disassembler register}
   27988 family of commands.  This style is only used when @value{GDBN} is
   27989 styling using its builtin disassembler library.  By default, this style's
   27990 foreground color is red.
   27991 
   27992 @end table
   27993 
   27994 @node Numbers
   27995 @section Numbers
   27996 @cindex number representation
   27997 @cindex entering numbers
   27998 
   27999 You can always enter numbers in octal, decimal, or hexadecimal in
   28000 @value{GDBN} by the usual conventions: octal numbers begin with
   28001 @samp{0}, decimal numbers end with @samp{.}, and hexadecimal numbers
   28002 begin with @samp{0x}.  Numbers that neither begin with @samp{0} or
   28003 @samp{0x}, nor end with a @samp{.} are, by default, entered in base
   28004 10; likewise, the default display for numbers---when no particular
   28005 format is specified---is base 10.  You can change the default base for
   28006 both input and output with the commands described below.
   28007 
   28008 @table @code
   28009 @kindex set input-radix
   28010 @item set input-radix @var{base}
   28011 Set the default base for numeric input.  Supported choices
   28012 for @var{base} are decimal 8, 10, or 16.  The base must itself be
   28013 specified either unambiguously or using the current input radix; for
   28014 example, any of
   28015 
   28016 @smallexample
   28017 set input-radix 012
   28018 set input-radix 10.
   28019 set input-radix 0xa
   28020 @end smallexample
   28021 
   28022 @noindent
   28023 sets the input base to decimal.  On the other hand, @samp{set input-radix 10}
   28024 leaves the input radix unchanged, no matter what it was, since
   28025 @samp{10}, being without any leading or trailing signs of its base, is
   28026 interpreted in the current radix.  Thus, if the current radix is 16,
   28027 @samp{10} is interpreted in hex, i.e.@: as 16 decimal, which doesn't
   28028 change the radix.
   28029 
   28030 @kindex set output-radix
   28031 @item set output-radix @var{base}
   28032 Set the default base for numeric display.  Supported choices
   28033 for @var{base} are decimal 8, 10, or 16.  The base must itself be
   28034 specified either unambiguously or using the current input radix.
   28035 
   28036 @kindex show input-radix
   28037 @item show input-radix
   28038 Display the current default base for numeric input.
   28039 
   28040 @kindex show output-radix
   28041 @item show output-radix
   28042 Display the current default base for numeric display.
   28043 
   28044 @item set radix @r{[}@var{base}@r{]}
   28045 @itemx show radix
   28046 @kindex set radix
   28047 @kindex show radix
   28048 These commands set and show the default base for both input and output
   28049 of numbers.  @code{set radix} sets the radix of input and output to
   28050 the same base; without an argument, it resets the radix back to its
   28051 default value of 10.
   28052 
   28053 @end table
   28054 
   28055 @node ABI
   28056 @section Configuring the Current ABI
   28057 
   28058 @value{GDBN} can determine the @dfn{ABI} (Application Binary Interface) of your
   28059 application automatically.  However, sometimes you need to override its
   28060 conclusions.  Use these commands to manage @value{GDBN}'s view of the
   28061 current ABI.
   28062 
   28063 @cindex OS ABI
   28064 @kindex set osabi
   28065 @kindex show osabi
   28066 @cindex Newlib OS ABI and its influence on the longjmp handling
   28067 
   28068 One @value{GDBN} configuration can debug binaries for multiple operating
   28069 system targets, either via remote debugging or native emulation.
   28070 @value{GDBN} will autodetect the @dfn{OS ABI} (Operating System ABI) in use,
   28071 but you can override its conclusion using the @code{set osabi} command.
   28072 One example where this is useful is in debugging of binaries which use
   28073 an alternate C library (e.g.@: @sc{uClibc} for @sc{gnu}/Linux) which does
   28074 not have the same identifying marks that the standard C library for your
   28075 platform provides.
   28076 
   28077 When @value{GDBN} is debugging the AArch64 architecture, it provides a
   28078 ``Newlib'' OS ABI.  This is useful for handling @code{setjmp} and
   28079 @code{longjmp} when debugging binaries that use the @sc{newlib} C library.
   28080 The ``Newlib'' OS ABI can be selected by @code{set osabi Newlib}.
   28081 
   28082 @table @code
   28083 @item show osabi
   28084 Show the OS ABI currently in use.
   28085 
   28086 @item set osabi
   28087 With no argument, show the list of registered available OS ABI's.
   28088 
   28089 @item set osabi @var{abi}
   28090 Set the current OS ABI to @var{abi}.
   28091 @end table
   28092 
   28093 @cindex float promotion
   28094 
   28095 Generally, the way that an argument of type @code{float} is passed to a
   28096 function depends on whether the function is prototyped.  For a prototyped
   28097 (i.e.@: ANSI/ISO style) function, @code{float} arguments are passed unchanged,
   28098 according to the architecture's convention for @code{float}.  For unprototyped
   28099 (i.e.@: K&R style) functions, @code{float} arguments are first promoted to type
   28100 @code{double} and then passed.
   28101 
   28102 Unfortunately, some forms of debug information do not reliably indicate whether
   28103 a function is prototyped.  If @value{GDBN} calls a function that is not marked
   28104 as prototyped, it consults @kbd{set coerce-float-to-double}.
   28105 
   28106 @table @code
   28107 @kindex set coerce-float-to-double
   28108 @item set coerce-float-to-double
   28109 @itemx set coerce-float-to-double on
   28110 Arguments of type @code{float} will be promoted to @code{double} when passed
   28111 to an unprototyped function.  This is the default setting.
   28112 
   28113 @item set coerce-float-to-double off
   28114 Arguments of type @code{float} will be passed directly to unprototyped
   28115 functions.
   28116 
   28117 @kindex show coerce-float-to-double
   28118 @item show coerce-float-to-double
   28119 Show the current setting of promoting @code{float} to @code{double}.
   28120 @end table
   28121 
   28122 @kindex set cp-abi
   28123 @kindex show cp-abi
   28124 @value{GDBN} needs to know the ABI used for your program's C@t{++}
   28125 objects.  The correct C@t{++} ABI depends on which C@t{++} compiler was
   28126 used to build your application.  @value{GDBN} only fully supports
   28127 programs with a single C@t{++} ABI; if your program contains code using
   28128 multiple C@t{++} ABI's or if @value{GDBN} can not identify your
   28129 program's ABI correctly, you can tell @value{GDBN} which ABI to use.
   28130 Currently supported ABI's include ``gnu-v2'', for @code{g++} versions
   28131 before 3.0, ``gnu-v3'', for @code{g++} versions 3.0 and later, and
   28132 ``hpaCC'' for the HP ANSI C@t{++} compiler.  Other C@t{++} compilers may
   28133 use the ``gnu-v2'' or ``gnu-v3'' ABI's as well.  The default setting is
   28134 ``auto''.
   28135 
   28136 @table @code
   28137 @item show cp-abi
   28138 Show the C@t{++} ABI currently in use.
   28139 
   28140 @item set cp-abi
   28141 With no argument, show the list of supported C@t{++} ABI's.
   28142 
   28143 @item set cp-abi @var{abi}
   28144 @itemx set cp-abi auto
   28145 Set the current C@t{++} ABI to @var{abi}, or return to automatic detection.
   28146 @end table
   28147 
   28148 @node Auto-loading
   28149 @section Automatically loading associated files
   28150 @cindex auto-loading
   28151 
   28152 @value{GDBN} sometimes reads files with commands and settings automatically,
   28153 without being explicitly told so by the user.  We call this feature
   28154 @dfn{auto-loading}.  While auto-loading is useful for automatically adapting
   28155 @value{GDBN} to the needs of your project, it can sometimes produce unexpected
   28156 results or introduce security risks (e.g., if the file comes from untrusted
   28157 sources).
   28158 
   28159 There are various kinds of files @value{GDBN} can automatically load.
   28160 In addition to these files, @value{GDBN} supports auto-loading code written
   28161 in various extension languages.  @xref{Auto-loading extensions}.
   28162 
   28163 Note that loading of these associated files (including the local @file{.gdbinit}
   28164 file) requires accordingly configured @code{auto-load safe-path}
   28165 (@pxref{Auto-loading safe path}).
   28166 
   28167 For these reasons, @value{GDBN} includes commands and options to let you
   28168 control when to auto-load files and which files should be auto-loaded.
   28169 
   28170 @table @code
   28171 @anchor{set auto-load off}
   28172 @kindex set auto-load off
   28173 @item set auto-load off
   28174 Globally disable loading of all auto-loaded files.
   28175 You may want to use this command with the @samp{-iex} option
   28176 (@pxref{Option -init-eval-command}) such as:
   28177 @smallexample
   28178 $ @kbd{gdb -iex "set auto-load off" untrusted-executable corefile}
   28179 @end smallexample
   28180 
   28181 Be aware that system init file (@pxref{System-wide configuration})
   28182 and init files from your home directory (@pxref{Home Directory Init File})
   28183 still get read (as they come from generally trusted directories).
   28184 To prevent @value{GDBN} from auto-loading even those init files, use the
   28185 @option{-nx} option (@pxref{Mode Options}), in addition to
   28186 @code{set auto-load no}.
   28187 
   28188 @anchor{show auto-load}
   28189 @kindex show auto-load
   28190 @item show auto-load
   28191 Show whether auto-loading of each specific @samp{auto-load} file(s) is enabled
   28192 or disabled.
   28193 
   28194 @smallexample
   28195 (@value{GDBP}) show auto-load
   28196 gdb-scripts:  Auto-loading of canned sequences of commands scripts is on.
   28197 libthread-db:  Auto-loading of inferior specific libthread_db is on.
   28198 local-gdbinit:  Auto-loading of .gdbinit script from current directory
   28199                 is on.
   28200 python-scripts:  Auto-loading of Python scripts is on.
   28201 safe-path:  List of directories from which it is safe to auto-load files
   28202             is $debugdir:$datadir/auto-load.
   28203 scripts-directory:  List of directories from which to load auto-loaded scripts
   28204                     is $debugdir:$datadir/auto-load.
   28205 @end smallexample
   28206 
   28207 @anchor{info auto-load}
   28208 @kindex info auto-load
   28209 @item info auto-load
   28210 Print whether each specific @samp{auto-load} file(s) have been auto-loaded or
   28211 not.
   28212 
   28213 @smallexample
   28214 (@value{GDBP}) info auto-load
   28215 gdb-scripts:
   28216 Loaded  Script
   28217 Yes     /home/user/gdb/gdb-gdb.gdb
   28218 libthread-db:  No auto-loaded libthread-db.
   28219 local-gdbinit:  Local .gdbinit file "/home/user/gdb/.gdbinit" has been
   28220                 loaded.
   28221 python-scripts:
   28222 Loaded  Script
   28223 Yes     /home/user/gdb/gdb-gdb.py
   28224 @end smallexample
   28225 @end table
   28226 
   28227 These are @value{GDBN} control commands for the auto-loading:
   28228 
   28229 @multitable @columnfractions .5 .5
   28230 @item @xref{set auto-load off}.
   28231 @tab Disable auto-loading globally.
   28232 @item @xref{show auto-load}.
   28233 @tab Show setting of all kinds of files.
   28234 @item @xref{info auto-load}.
   28235 @tab Show state of all kinds of files.
   28236 @item @xref{set auto-load gdb-scripts}.
   28237 @tab Control for @value{GDBN} command scripts.
   28238 @item @xref{show auto-load gdb-scripts}.
   28239 @tab Show setting of @value{GDBN} command scripts.
   28240 @item @xref{info auto-load gdb-scripts}.
   28241 @tab Show state of @value{GDBN} command scripts.
   28242 @item @xref{set auto-load python-scripts}.
   28243 @tab Control for @value{GDBN} Python scripts.
   28244 @item @xref{show auto-load python-scripts}.
   28245 @tab Show setting of @value{GDBN} Python scripts.
   28246 @item @xref{info auto-load python-scripts}.
   28247 @tab Show state of @value{GDBN} Python scripts.
   28248 @item @xref{set auto-load guile-scripts}.
   28249 @tab Control for @value{GDBN} Guile scripts.
   28250 @item @xref{show auto-load guile-scripts}.
   28251 @tab Show setting of @value{GDBN} Guile scripts.
   28252 @item @xref{info auto-load guile-scripts}.
   28253 @tab Show state of @value{GDBN} Guile scripts.
   28254 @item @xref{set auto-load scripts-directory}.
   28255 @tab Control for @value{GDBN} auto-loaded scripts location.
   28256 @item @xref{show auto-load scripts-directory}.
   28257 @tab Show @value{GDBN} auto-loaded scripts location.
   28258 @item @xref{add-auto-load-scripts-directory}.
   28259 @tab Add directory for auto-loaded scripts location list.
   28260 @item @xref{set auto-load local-gdbinit}.
   28261 @tab Control for init file in the current directory.
   28262 @item @xref{show auto-load local-gdbinit}.
   28263 @tab Show setting of init file in the current directory.
   28264 @item @xref{info auto-load local-gdbinit}.
   28265 @tab Show state of init file in the current directory.
   28266 @item @xref{set auto-load libthread-db}.
   28267 @tab Control for thread debugging library.
   28268 @item @xref{show auto-load libthread-db}.
   28269 @tab Show setting of thread debugging library.
   28270 @item @xref{info auto-load libthread-db}.
   28271 @tab Show state of thread debugging library.
   28272 @item @xref{set auto-load safe-path}.
   28273 @tab Control directories trusted for automatic loading.
   28274 @item @xref{show auto-load safe-path}.
   28275 @tab Show directories trusted for automatic loading.
   28276 @item @xref{add-auto-load-safe-path}.
   28277 @tab Add directory trusted for automatic loading.
   28278 @end multitable
   28279 
   28280 @menu
   28281 * Init File in the Current Directory:: @samp{set/show/info auto-load local-gdbinit}
   28282 * libthread_db.so.1 file::             @samp{set/show/info auto-load libthread-db}
   28283 
   28284 * Auto-loading safe path::             @samp{set/show/info auto-load safe-path}
   28285 * Auto-loading verbose mode::          @samp{set/show debug auto-load}
   28286 @end menu
   28287 
   28288 @node Init File in the Current Directory
   28289 @subsection Automatically loading init file in the current directory
   28290 @cindex auto-loading init file in the current directory
   28291 
   28292 By default, @value{GDBN} reads and executes the canned sequences of commands
   28293 from init file (if any) in the current working directory,
   28294 see @ref{Init File in the Current Directory during Startup}.
   28295 
   28296 Note that loading of this local @file{.gdbinit} file also requires accordingly
   28297 configured @code{auto-load safe-path} (@pxref{Auto-loading safe path}).
   28298 
   28299 @table @code
   28300 @anchor{set auto-load local-gdbinit}
   28301 @kindex set auto-load local-gdbinit
   28302 @item set auto-load local-gdbinit [on|off]
   28303 Enable or disable the auto-loading of canned sequences of commands
   28304 (@pxref{Sequences}) found in init file in the current directory.
   28305 
   28306 @anchor{show auto-load local-gdbinit}
   28307 @kindex show auto-load local-gdbinit
   28308 @item show auto-load local-gdbinit
   28309 Show whether auto-loading of canned sequences of commands from init file in the
   28310 current directory is enabled or disabled.
   28311 
   28312 @anchor{info auto-load local-gdbinit}
   28313 @kindex info auto-load local-gdbinit
   28314 @item info auto-load local-gdbinit
   28315 Print whether canned sequences of commands from init file in the
   28316 current directory have been auto-loaded.
   28317 @end table
   28318 
   28319 @node libthread_db.so.1 file
   28320 @subsection Automatically loading thread debugging library
   28321 @cindex auto-loading libthread_db.so.1
   28322 
   28323 This feature is currently present only on @sc{gnu}/Linux native hosts.
   28324 
   28325 @value{GDBN} reads in some cases thread debugging library from places specific
   28326 to the inferior (@pxref{set libthread-db-search-path}).
   28327 
   28328 The special @samp{libthread-db-search-path} entry @samp{$sdir} is processed
   28329 without checking this @samp{set auto-load libthread-db} switch as system
   28330 libraries have to be trusted in general.  In all other cases of
   28331 @samp{libthread-db-search-path} entries @value{GDBN} checks first if @samp{set
   28332 auto-load libthread-db} is enabled before trying to open such thread debugging
   28333 library.
   28334 
   28335 Note that loading of this debugging library also requires accordingly configured
   28336 @code{auto-load safe-path} (@pxref{Auto-loading safe path}).
   28337 
   28338 @table @code
   28339 @anchor{set auto-load libthread-db}
   28340 @kindex set auto-load libthread-db
   28341 @item set auto-load libthread-db [on|off]
   28342 Enable or disable the auto-loading of inferior specific thread debugging library.
   28343 
   28344 @anchor{show auto-load libthread-db}
   28345 @kindex show auto-load libthread-db
   28346 @item show auto-load libthread-db
   28347 Show whether auto-loading of inferior specific thread debugging library is
   28348 enabled or disabled.
   28349 
   28350 @anchor{info auto-load libthread-db}
   28351 @kindex info auto-load libthread-db
   28352 @item info auto-load libthread-db
   28353 Print the list of all loaded inferior specific thread debugging libraries and
   28354 for each such library print list of inferior @var{pid}s using it.
   28355 @end table
   28356 
   28357 @node Auto-loading safe path
   28358 @subsection Security restriction for auto-loading
   28359 @cindex auto-loading safe-path
   28360 
   28361 As the files of inferior can come from untrusted source (such as submitted by
   28362 an application user) @value{GDBN} does not always load any files automatically.
   28363 @value{GDBN} provides the @samp{set auto-load safe-path} setting to list
   28364 directories trusted for loading files not explicitly requested by user.
   28365 Each directory can also be a shell wildcard pattern.
   28366 
   28367 If the path is not set properly you will see a warning and the file will not
   28368 get loaded:
   28369 
   28370 @smallexample
   28371 $ ./gdb -q ./gdb
   28372 Reading symbols from /home/user/gdb/gdb...
   28373 warning: File "/home/user/gdb/gdb-gdb.gdb" auto-loading has been
   28374          declined by your `auto-load safe-path' set
   28375          to "$debugdir:$datadir/auto-load".
   28376 warning: File "/home/user/gdb/gdb-gdb.py" auto-loading has been
   28377          declined by your `auto-load safe-path' set
   28378          to "$debugdir:$datadir/auto-load".
   28379 @end smallexample
   28380 
   28381 @noindent
   28382 To instruct @value{GDBN} to go ahead and use the init files anyway,
   28383 invoke @value{GDBN} like this:
   28384 
   28385 @smallexample
   28386 $ gdb -q -iex "set auto-load safe-path /home/user/gdb" ./gdb
   28387 @end smallexample
   28388 
   28389 The list of trusted directories is controlled by the following commands:
   28390 
   28391 @table @code
   28392 @anchor{set auto-load safe-path}
   28393 @kindex set auto-load safe-path
   28394 @item set auto-load safe-path @r{[}@var{directories}@r{]}
   28395 Set the list of directories (and their subdirectories) trusted for automatic
   28396 loading and execution of scripts.  You can also enter a specific trusted file.
   28397 Each directory can also be a shell wildcard pattern; wildcards do not match
   28398 directory separator - see @code{FNM_PATHNAME} for system function @code{fnmatch}
   28399 (@pxref{Wildcard Matching, fnmatch, , libc, GNU C Library Reference Manual}).
   28400 If you omit @var{directories}, @samp{auto-load safe-path} will be reset to
   28401 its default value as specified during @value{GDBN} compilation.
   28402 
   28403 The list of directories uses path separator (@samp{:} on GNU and Unix
   28404 systems, @samp{;} on MS-Windows and MS-DOS) to separate directories, similarly
   28405 to the @env{PATH} environment variable.
   28406 
   28407 @anchor{show auto-load safe-path}
   28408 @kindex show auto-load safe-path
   28409 @item show auto-load safe-path
   28410 Show the list of directories trusted for automatic loading and execution of
   28411 scripts.
   28412 
   28413 @anchor{add-auto-load-safe-path}
   28414 @kindex add-auto-load-safe-path
   28415 @item add-auto-load-safe-path
   28416 Add an entry (or list of entries) to the list of directories trusted for
   28417 automatic loading and execution of scripts.  Multiple entries may be delimited
   28418 by the host platform path separator in use.
   28419 @end table
   28420 
   28421 This variable defaults to what @code{--with-auto-load-dir} has been configured
   28422 to (@pxref{with-auto-load-dir}).  @file{$debugdir} and @file{$datadir}
   28423 substitution applies the same as for @ref{set auto-load scripts-directory}.
   28424 The default @code{set auto-load safe-path} value can be also overridden by
   28425 @value{GDBN} configuration option @option{--with-auto-load-safe-path}.
   28426 
   28427 Setting this variable to @file{/} disables this security protection,
   28428 corresponding @value{GDBN} configuration option is
   28429 @option{--without-auto-load-safe-path}.
   28430 This variable is supposed to be set to the system directories writable by the
   28431 system superuser only.  Users can add their source directories in init files in
   28432 their home directories (@pxref{Home Directory Init File}).  See also deprecated
   28433 init file in the current directory
   28434 (@pxref{Init File in the Current Directory during Startup}).
   28435 
   28436 To force @value{GDBN} to load the files it declined to load in the previous
   28437 example, you could use one of the following ways:
   28438 
   28439 @table @asis
   28440 @item @file{~/.gdbinit}: @samp{add-auto-load-safe-path ~/src/gdb}
   28441 Specify this trusted directory (or a file) as additional component of the list.
   28442 You have to specify also any existing directories displayed by
   28443 by @samp{show auto-load safe-path} (such as @samp{/usr:/bin} in this example).
   28444 
   28445 @item @kbd{gdb -iex "set auto-load safe-path /usr:/bin:~/src/gdb" @dots{}}
   28446 Specify this directory as in the previous case but just for a single
   28447 @value{GDBN} session.
   28448 
   28449 @item @kbd{gdb -iex "set auto-load safe-path /" @dots{}}
   28450 Disable auto-loading safety for a single @value{GDBN} session.
   28451 This assumes all the files you debug during this @value{GDBN} session will come
   28452 from trusted sources.
   28453 
   28454 @item @kbd{./configure --without-auto-load-safe-path}
   28455 During compilation of @value{GDBN} you may disable any auto-loading safety.
   28456 This assumes all the files you will ever debug with this @value{GDBN} come from
   28457 trusted sources.
   28458 @end table
   28459 
   28460 On the other hand you can also explicitly forbid automatic files loading which
   28461 also suppresses any such warning messages:
   28462 
   28463 @table @asis
   28464 @item @kbd{gdb -iex "set auto-load no" @dots{}}
   28465 You can use @value{GDBN} command-line option for a single @value{GDBN} session.
   28466 
   28467 @item @file{~/.gdbinit}: @samp{set auto-load no}
   28468 Disable auto-loading globally for the user
   28469 (@pxref{Home Directory Init File}).  While it is improbable, you could also
   28470 use system init file instead (@pxref{System-wide configuration}).
   28471 @end table
   28472 
   28473 This setting applies to the file names as entered by user.  If no entry matches
   28474 @value{GDBN} tries as a last resort to also resolve all the file names into
   28475 their canonical form (typically resolving symbolic links) and compare the
   28476 entries again.  @value{GDBN} already canonicalizes most of the filenames on its
   28477 own before starting the comparison so a canonical form of directories is
   28478 recommended to be entered.
   28479 
   28480 @node Auto-loading verbose mode
   28481 @subsection Displaying files tried for auto-load
   28482 @cindex auto-loading verbose mode
   28483 
   28484 For better visibility of all the file locations where you can place scripts to
   28485 be auto-loaded with inferior --- or to protect yourself against accidental
   28486 execution of untrusted scripts --- @value{GDBN} provides a feature for printing
   28487 all the files attempted to be loaded.  Both existing and non-existing files may
   28488 be printed.
   28489 
   28490 For example the list of directories from which it is safe to auto-load files
   28491 (@pxref{Auto-loading safe path}) applies also to canonicalized filenames which
   28492 may not be too obvious while setting it up.
   28493 
   28494 @smallexample
   28495 (@value{GDBP}) set debug auto-load on
   28496 (@value{GDBP}) file ~/src/t/true
   28497 auto-load: Loading canned sequences of commands script "/tmp/true-gdb.gdb"
   28498            for objfile "/tmp/true".
   28499 auto-load: Updating directories of "/usr:/opt".
   28500 auto-load: Using directory "/usr".
   28501 auto-load: Using directory "/opt".
   28502 warning: File "/tmp/true-gdb.gdb" auto-loading has been declined
   28503          by your `auto-load safe-path' set to "/usr:/opt".
   28504 @end smallexample
   28505 
   28506 @table @code
   28507 @anchor{set debug auto-load}
   28508 @kindex set debug auto-load
   28509 @item set debug auto-load [on|off]
   28510 Set whether to print the filenames attempted to be auto-loaded.
   28511 
   28512 @anchor{show debug auto-load}
   28513 @kindex show debug auto-load
   28514 @item show debug auto-load
   28515 Show whether printing of the filenames attempted to be auto-loaded is turned
   28516 on or off.
   28517 @end table
   28518 
   28519 @node Messages/Warnings
   28520 @section Optional Warnings and Messages
   28521 
   28522 @cindex verbose operation
   28523 @cindex optional warnings
   28524 By default, @value{GDBN} is silent about its inner workings.  If you are
   28525 running on a slow machine, you may want to use the @code{set verbose}
   28526 command.  This makes @value{GDBN} tell you when it does a lengthy
   28527 internal operation, so you will not think it has crashed.
   28528 
   28529 Currently, the messages controlled by @code{set verbose} are those
   28530 which announce that the symbol table for a source file is being read;
   28531 see @code{symbol-file} in @ref{Files, ,Commands to Specify Files}.
   28532 
   28533 @table @code
   28534 @kindex set verbose
   28535 @item set verbose on
   28536 Enables @value{GDBN} output of certain informational messages.
   28537 
   28538 @item set verbose off
   28539 Disables @value{GDBN} output of certain informational messages.
   28540 
   28541 @kindex show verbose
   28542 @item show verbose
   28543 Displays whether @code{set verbose} is on or off.
   28544 @end table
   28545 
   28546 By default, if @value{GDBN} encounters bugs in the symbol table of an
   28547 object file, it is silent; but if you are debugging a compiler, you may
   28548 find this information useful (@pxref{Symbol Errors, ,Errors Reading
   28549 Symbol Files}).
   28550 
   28551 @table @code
   28552 
   28553 @kindex set complaints
   28554 @item set complaints @var{limit}
   28555 Permits @value{GDBN} to output @var{limit} complaints about each type of
   28556 unusual symbols before becoming silent about the problem.  Set
   28557 @var{limit} to zero to suppress all complaints; set it to a large number
   28558 to prevent complaints from being suppressed.
   28559 
   28560 @kindex show complaints
   28561 @item show complaints
   28562 Displays how many symbol complaints @value{GDBN} is permitted to produce.
   28563 
   28564 @end table
   28565 
   28566 @anchor{confirmation requests}
   28567 By default, @value{GDBN} is cautious, and asks what sometimes seems to be a
   28568 lot of stupid questions to confirm certain commands.  For example, if
   28569 you try to run a program which is already running:
   28570 
   28571 @smallexample
   28572 (@value{GDBP}) run
   28573 The program being debugged has been started already.
   28574 Start it from the beginning? (y or n)
   28575 @end smallexample
   28576 
   28577 If you are willing to unflinchingly face the consequences of your own
   28578 commands, you can disable this ``feature'':
   28579 
   28580 @table @code
   28581 
   28582 @kindex set confirm
   28583 @cindex flinching
   28584 @cindex confirmation
   28585 @cindex stupid questions
   28586 @item set confirm off
   28587 Disables confirmation requests.  Note that running @value{GDBN} with
   28588 the @option{--batch} option (@pxref{Mode Options, -batch}) also
   28589 automatically disables confirmation requests.
   28590 
   28591 @item set confirm on
   28592 Enables confirmation requests (the default).
   28593 
   28594 @kindex show confirm
   28595 @item show confirm
   28596 Displays state of confirmation requests.
   28597 
   28598 @end table
   28599 
   28600 @cindex command tracing
   28601 If you need to debug user-defined commands or sourced files you may find it
   28602 useful to enable @dfn{command tracing}.  In this mode each command will be
   28603 printed as it is executed, prefixed with one or more @samp{+} symbols, the
   28604 quantity denoting the call depth of each command.
   28605 
   28606 @table @code
   28607 @kindex set trace-commands
   28608 @cindex command scripts, debugging
   28609 @item set trace-commands on
   28610 Enable command tracing.
   28611 @item set trace-commands off
   28612 Disable command tracing.
   28613 @item show trace-commands
   28614 Display the current state of command tracing.
   28615 @end table
   28616 
   28617 @node Debugging Output
   28618 @section Optional Messages about Internal Happenings
   28619 @cindex optional debugging messages
   28620 
   28621 @value{GDBN} has commands that enable optional debugging messages from
   28622 various @value{GDBN} subsystems; normally these commands are of
   28623 interest to @value{GDBN} maintainers, or when reporting a bug.  This
   28624 section documents those commands.
   28625 
   28626 @table @code
   28627 @kindex set exec-done-display
   28628 @item set exec-done-display
   28629 Turns on or off the notification of asynchronous commands'
   28630 completion.  When on, @value{GDBN} will print a message when an
   28631 asynchronous command finishes its execution.  The default is off.
   28632 @kindex show exec-done-display
   28633 @item show exec-done-display
   28634 Displays the current setting of asynchronous command completion
   28635 notification.
   28636 
   28637 @kindex set debug
   28638 @cindex ARM AArch64
   28639 @item set debug aarch64
   28640 Turns on or off display of debugging messages related to ARM AArch64.
   28641 The default is off.
   28642 @kindex show debug
   28643 @item show debug aarch64
   28644 Displays the current state of displaying debugging messages related to
   28645 ARM AArch64.
   28646 
   28647 @cindex gdbarch debugging info
   28648 @cindex architecture debugging info
   28649 @item set debug arch
   28650 Turns on or off display of gdbarch debugging info.  The default is off
   28651 @item show debug arch
   28652 Displays the current state of displaying gdbarch debugging info.
   28653 
   28654 @item set debug aix-thread
   28655 @cindex AIX threads
   28656 Display debugging messages about inner workings of the AIX thread
   28657 module.
   28658 @item show debug aix-thread
   28659 Show the current state of AIX thread debugging info display.
   28660 
   28661 @cindex AMD GPU debugging info
   28662 @anchor{set debug amd-dbgapi-lib}
   28663 @item set debug amd-dbgapi-lib
   28664 @itemx show debug amd-dbgapi-lib
   28665 
   28666 The @code{set debug amd-dbgapi-lib log-level @var{level}} command can be used
   28667 to enable diagnostic messages from the @samp{amd-dbgapi} library, where
   28668 @var{level} can be:
   28669 
   28670 @table @code
   28671 
   28672 @item off
   28673 no logging is enabled
   28674 
   28675 @item error
   28676 fatal errors are reported
   28677 
   28678 @item warning
   28679 fatal errors and warnings are reported
   28680 
   28681 @item info
   28682 fatal errors, warnings, and info messages are reported
   28683 
   28684 @item verbose
   28685 all messages are reported
   28686 
   28687 @end table
   28688 
   28689 The @code{show debug amd-dbgapi-lib log-level} command displays the current
   28690 @acronym{amd-dbgapi} library log level.
   28691 
   28692 @anchor{set debug amd-dbgapi}
   28693 @item set debug amd-dbgapi
   28694 @itemx show debug amd-dbgapi
   28695 
   28696 The @samp{set debug amd-dbgapi} command can be used
   28697 to enable diagnostic messages in the @samp{amd-dbgapi} target.  The
   28698 @samp{show debug amd-dbgapi} command displays the current setting.
   28699 @xref{set debug amd-dbgapi}.
   28700 
   28701 @item set debug check-physname
   28702 @cindex physname
   28703 Check the results of the ``physname'' computation.  When reading DWARF
   28704 debugging information for C@t{++}, @value{GDBN} attempts to compute
   28705 each entity's name.  @value{GDBN} can do this computation in two
   28706 different ways, depending on exactly what information is present.
   28707 When enabled, this setting causes @value{GDBN} to compute the names
   28708 both ways and display any discrepancies.
   28709 @item show debug check-physname
   28710 Show the current state of ``physname'' checking.
   28711 
   28712 @item set debug coff-pe-read
   28713 @cindex COFF/PE exported symbols
   28714 Control display of debugging messages related to reading of COFF/PE
   28715 exported symbols.  The default is off.
   28716 @item show debug coff-pe-read
   28717 Displays the current state of displaying debugging messages related to
   28718 reading of COFF/PE exported symbols.
   28719 
   28720 @item set debug dwarf-die
   28721 @cindex DWARF DIEs
   28722 Dump DWARF DIEs after they are read in.
   28723 The value is the number of nesting levels to print.
   28724 A value of zero turns off the display.
   28725 @item show debug dwarf-die
   28726 Show the current state of DWARF DIE debugging.
   28727 
   28728 @item set debug dwarf-line
   28729 @cindex DWARF Line Tables
   28730 Turns on or off display of debugging messages related to reading
   28731 DWARF line tables.  The default is 0 (off).
   28732 A value of 1 provides basic information.
   28733 A value greater than 1 provides more verbose information.
   28734 @item show debug dwarf-line
   28735 Show the current state of DWARF line table debugging.
   28736 
   28737 @item set debug dwarf-read
   28738 @cindex DWARF Reading
   28739 Turns on or off display of debugging messages related to reading
   28740 DWARF debug info.  The default is 0 (off).
   28741 A value of 1 provides basic information.
   28742 A value greater than 1 provides more verbose information.
   28743 @item show debug dwarf-read
   28744 Show the current state of DWARF reader debugging.
   28745 
   28746 @item set debug displaced
   28747 @cindex displaced stepping debugging info
   28748 Turns on or off display of @value{GDBN} debugging info for the
   28749 displaced stepping support.  The default is off.
   28750 @item show debug displaced
   28751 Displays the current state of displaying @value{GDBN} debugging info
   28752 related to displaced stepping.
   28753 
   28754 @item set debug event
   28755 @cindex event debugging info
   28756 Turns on or off display of @value{GDBN} event debugging info.  The
   28757 default is off.
   28758 @item show debug event
   28759 Displays the current state of displaying @value{GDBN} event debugging
   28760 info.
   28761 
   28762 @item set debug event-loop
   28763 @cindex event-loop debugging
   28764 Controls output of debugging info about the event loop.  The possible
   28765 values are @samp{off}, @samp{all} (shows all debugging info) and
   28766 @samp{all-except-ui} (shows all debugging info except those about
   28767 UI-related events).
   28768 @item show debug event-loop
   28769 Shows the current state of displaying debugging info about the event
   28770 loop.
   28771 
   28772 @item set debug expression
   28773 @cindex expression debugging info
   28774 Turns on or off display of debugging info about @value{GDBN}
   28775 expression parsing.  The default is off.
   28776 @item show debug expression
   28777 Displays the current state of displaying debugging info about
   28778 @value{GDBN} expression parsing.
   28779 
   28780 @item set debug fbsd-lwp
   28781 @cindex FreeBSD LWP debug messages
   28782 Turns on or off debugging messages from the FreeBSD LWP debug support.
   28783 @item show debug fbsd-lwp
   28784 Show the current state of FreeBSD LWP debugging messages.
   28785 
   28786 @item set debug fbsd-nat
   28787 @cindex FreeBSD native target debug messages
   28788 Turns on or off debugging messages from the FreeBSD native target.
   28789 @item show debug fbsd-nat
   28790 Show the current state of FreeBSD native target debugging messages.
   28791 
   28792 @item set debug fortran-array-slicing
   28793 @cindex fortran array slicing debugging info
   28794 Turns on or off display of @value{GDBN} Fortran array slicing
   28795 debugging info.  The default is off.
   28796 
   28797 @item show debug fortran-array-slicing
   28798 Displays the current state of displaying @value{GDBN} Fortran array
   28799 slicing debugging info.
   28800 
   28801 @item set debug frame
   28802 @cindex frame debugging info
   28803 Turns on or off display of @value{GDBN} frame debugging info.  The
   28804 default is off.
   28805 @item show debug frame
   28806 Displays the current state of displaying @value{GDBN} frame debugging
   28807 info.
   28808 
   28809 @item set debug gnu-nat
   28810 @cindex @sc{gnu}/Hurd debug messages
   28811 Turn on or off debugging messages from the @sc{gnu}/Hurd debug support.
   28812 @item show debug gnu-nat
   28813 Show the current state of @sc{gnu}/Hurd debugging messages.
   28814 
   28815 @item set debug infrun
   28816 @cindex inferior debugging info
   28817 Turns on or off display of @value{GDBN} debugging info for running the inferior.
   28818 The default is off.  @file{infrun.c} contains GDB's runtime state machine used 
   28819 for implementing operations such as single-stepping the inferior.
   28820 @item show debug infrun
   28821 Displays the current state of @value{GDBN} inferior debugging.
   28822 
   28823 @item set debug infcall
   28824 @cindex inferior function call debugging info
   28825 Turns on or off display of debugging info related to inferior function
   28826 calls made by @value{GDBN}.
   28827 @item show debug infcall
   28828 Displays the current state of @value{GDBN} inferior function call debugging.
   28829 
   28830 @item set debug jit
   28831 @cindex just-in-time compilation, debugging messages
   28832 Turn on or off debugging messages from JIT debug support.
   28833 @item show debug jit
   28834 Displays the current state of @value{GDBN} JIT debugging.
   28835 
   28836 @item set debug linux-nat @r{[}on@r{|}off@r{]}
   28837 @cindex @sc{gnu}/Linux native target debug messages
   28838 @cindex Linux native targets
   28839 Turn on or off debugging messages from the Linux native target debug support.
   28840 @item show debug linux-nat
   28841 Show the current state of Linux native target debugging messages.
   28842 
   28843 @item set debug linux-namespaces
   28844 @cindex @sc{gnu}/Linux namespaces debug messages
   28845 Turn on or off debugging messages from the Linux namespaces debug support.
   28846 @item show debug linux-namespaces
   28847 Show the current state of Linux namespaces debugging messages.
   28848 
   28849 @item set debug mach-o
   28850 @cindex Mach-O symbols processing
   28851 Control display of debugging messages related to Mach-O symbols
   28852 processing.  The default is off.
   28853 @item show debug mach-o
   28854 Displays the current state of displaying debugging messages related to
   28855 reading of COFF/PE exported symbols.
   28856 
   28857 @item set debug notification
   28858 @cindex remote async notification debugging info
   28859 Turn on or off debugging messages about remote async notification.
   28860 The default is off.
   28861 @item show debug notification
   28862 Displays the current state of remote async notification debugging messages.
   28863 
   28864 @item set debug observer
   28865 @cindex observer debugging info
   28866 Turns on or off display of @value{GDBN} observer debugging.  This
   28867 includes info such as the notification of observable events.
   28868 @item show debug observer
   28869 Displays the current state of observer debugging.
   28870 
   28871 @item set debug overload
   28872 @cindex C@t{++} overload debugging info
   28873 Turns on or off display of @value{GDBN} C@t{++} overload debugging
   28874 info. This includes info such as ranking of functions, etc.  The default
   28875 is off.
   28876 @item show debug overload
   28877 Displays the current state of displaying @value{GDBN} C@t{++} overload
   28878 debugging info.
   28879 
   28880 @cindex expression parser, debugging info
   28881 @cindex debug expression parser
   28882 @item set debug parser
   28883 Turns on or off the display of expression parser debugging output.
   28884 Internally, this sets the @code{yydebug} variable in the expression
   28885 parser.  @xref{Tracing, , Tracing Your Parser, bison, Bison}, for
   28886 details.  The default is off.
   28887 @item show debug parser
   28888 Show the current state of expression parser debugging.
   28889 
   28890 @cindex packets, reporting on stdout
   28891 @cindex serial connections, debugging
   28892 @cindex debug remote protocol
   28893 @cindex remote protocol debugging
   28894 @cindex display remote packets
   28895 @item set debug remote
   28896 Turns on or off display of reports on all packets sent back and forth across
   28897 the serial line to the remote machine.  The info is printed on the
   28898 @value{GDBN} standard output stream. The default is off.
   28899 @item show debug remote
   28900 Displays the state of display of remote packets.
   28901 
   28902 @item set debug remote-packet-max-chars
   28903 Sets the maximum number of characters to display for each remote packet when
   28904 @code{set debug remote} is on.  This is useful to prevent @value{GDBN} from
   28905 displaying lengthy remote packets and polluting the console.
   28906 
   28907 The default value is @code{512}, which means @value{GDBN} will truncate each
   28908 remote packet after 512 bytes.
   28909 
   28910 Setting this option to @code{unlimited} will disable truncation and will output
   28911 the full length of the remote packets.
   28912 @item show debug remote-packet-max-chars
   28913 Displays the number of bytes to output for remote packet debugging.
   28914 
   28915 @item set debug separate-debug-file
   28916 Turns on or off display of debug output about separate debug file search.
   28917 @item show debug separate-debug-file
   28918 Displays the state of separate debug file search debug output.
   28919 
   28920 @item set debug serial
   28921 Turns on or off display of @value{GDBN} serial debugging info. The
   28922 default is off.
   28923 @item show debug serial
   28924 Displays the current state of displaying @value{GDBN} serial debugging
   28925 info.
   28926 
   28927 @item set debug solib
   28928 Turns on or off display of debugging messages related to shared libraries.
   28929 The default is off.
   28930 @item show debug solib
   28931 Show the current state of solib debugging messages.
   28932 
   28933 @item set debug symbol-lookup
   28934 @cindex symbol lookup
   28935 Turns on or off display of debugging messages related to symbol lookup.
   28936 The default is 0 (off).
   28937 A value of 1 provides basic information.
   28938 A value greater than 1 provides more verbose information.
   28939 @item show debug symbol-lookup
   28940 Show the current state of symbol lookup debugging messages.
   28941 
   28942 @item set debug symfile
   28943 @cindex symbol file functions
   28944 Turns on or off display of debugging messages related to symbol file functions.
   28945 The default is off.  @xref{Files}.
   28946 @item show debug symfile
   28947 Show the current state of symbol file debugging messages.
   28948 
   28949 @item set debug symtab-create
   28950 @cindex symbol table creation
   28951 Turns on or off display of debugging messages related to symbol table creation.
   28952 The default is 0 (off).
   28953 A value of 1 provides basic information.
   28954 A value greater than 1 provides more verbose information.
   28955 @item show debug symtab-create
   28956 Show the current state of symbol table creation debugging.
   28957 
   28958 @item set debug target
   28959 @cindex target debugging info
   28960 Turns on or off display of @value{GDBN} target debugging info. This info
   28961 includes what is going on at the target level of GDB, as it happens. The
   28962 default is 0.  Set it to 1 to track events, and to 2 to also track the
   28963 value of large memory transfers.
   28964 @item show debug target
   28965 Displays the current state of displaying @value{GDBN} target debugging
   28966 info.
   28967 
   28968 @item set debug timestamp
   28969 @cindex timestamping debugging info
   28970 Turns on or off display of timestamps with @value{GDBN} debugging info.
   28971 When enabled, seconds and microseconds are displayed before each debugging
   28972 message.
   28973 @item show debug timestamp
   28974 Displays the current state of displaying timestamps with @value{GDBN}
   28975 debugging info.
   28976 
   28977 @item set debug varobj
   28978 @cindex variable object debugging info
   28979 Turns on or off display of @value{GDBN} variable object debugging
   28980 info. The default is off.
   28981 @item show debug varobj
   28982 Displays the current state of displaying @value{GDBN} variable object
   28983 debugging info.
   28984 
   28985 @item set debug xml
   28986 @cindex XML parser debugging
   28987 Turn on or off debugging messages for built-in XML parsers.
   28988 @item show debug xml
   28989 Displays the current state of XML debugging messages.
   28990 
   28991 @item set debug breakpoints
   28992 @cindex breakpoint debugging info
   28993 Turns on or off display of @value{GDBN} debugging info for breakpoint insertion
   28994 and removal.  The default is off.
   28995 @item show debug breakpoints
   28996 Displays the current state of displaying @value{GDBN} debugging info for
   28997 breakpoint insertion and removal.
   28998 @end table
   28999 
   29000 @node Other Misc Settings
   29001 @section Other Miscellaneous Settings
   29002 @cindex miscellaneous settings
   29003 
   29004 @table @code
   29005 @kindex set interactive-mode
   29006 @item set interactive-mode
   29007 If @code{on}, forces @value{GDBN} to assume that GDB was started
   29008 in a terminal.  In practice, this means that @value{GDBN} should wait
   29009 for the user to answer queries generated by commands entered at
   29010 the command prompt.  If @code{off}, forces @value{GDBN} to operate
   29011 in the opposite mode, and it uses the default answers to all queries.
   29012 If @code{auto} (the default), @value{GDBN} tries to determine whether
   29013 its standard input is a terminal, and works in interactive-mode if it
   29014 is, non-interactively otherwise.
   29015 
   29016 In the vast majority of cases, the debugger should be able to guess
   29017 correctly which mode should be used.  But this setting can be useful
   29018 in certain specific cases, such as running a MinGW @value{GDBN}
   29019 inside a cygwin window.
   29020 
   29021 @kindex show interactive-mode
   29022 @item show interactive-mode
   29023 Displays whether the debugger is operating in interactive mode or not.
   29024 @end table
   29025 
   29026 @table @code
   29027 @kindex set suppress-cli-notifications
   29028 @item set suppress-cli-notifications
   29029 If @code{on}, command-line-interface (CLI) notifications that are
   29030 printed by @value{GDBN} are suppressed.  If @code{off}, the
   29031 notifications are printed as usual.  The default value is @code{off}.
   29032 CLI notifications occur when you change the selected context or when
   29033 the program being debugged stops, as detailed below.
   29034 
   29035 @table @emph
   29036 @item User-selected context changes:
   29037 When you change the selected context (i.e.@: the current inferior,
   29038 thread and/or the frame), @value{GDBN} prints information about the
   29039 new context.  For example, the default behavior is below:
   29040 
   29041 @smallexample
   29042 (gdb) inferior 1
   29043 [Switching to inferior 1 [process 634] (/tmp/test)]
   29044 [Switching to thread 1 (process 634)]
   29045 #0  main () at test.c:3
   29046 3         return 0;
   29047 (gdb)
   29048 @end smallexample
   29049 
   29050 When the notifications are suppressed, the new context is not printed:
   29051 
   29052 @smallexample
   29053 (gdb) set suppress-cli-notifications on
   29054 (gdb) inferior 1
   29055 (gdb)
   29056 @end smallexample
   29057 
   29058 @item The program being debugged stops:
   29059 When the program you are debugging stops (e.g.@: because of hitting a
   29060 breakpoint, completing source-stepping, an interrupt, etc.),
   29061 @value{GDBN} prints information about the stop event.  For example,
   29062 below is a breakpoint hit:
   29063 
   29064 @smallexample
   29065 (gdb) break test.c:3
   29066 Breakpoint 2 at 0x555555555155: file test.c, line 3.
   29067 (gdb) continue
   29068 Continuing.
   29069 
   29070 Breakpoint 2, main () at test.c:3
   29071 3         return 0;
   29072 (gdb)
   29073 @end smallexample
   29074 
   29075 When the notifications are suppressed, the output becomes:
   29076 
   29077 @smallexample
   29078 (gdb) break test.c:3
   29079 Breakpoint 2 at 0x555555555155: file test.c, line 3.
   29080 (gdb) set suppress-cli-notifications on
   29081 (gdb) continue
   29082 Continuing.
   29083 (gdb)
   29084 @end smallexample
   29085 
   29086 Suppressing CLI notifications may be useful in scripts to obtain a
   29087 reduced output from a list of commands.
   29088 @end table
   29089 
   29090 @kindex show suppress-cli-notifications
   29091 @item show suppress-cli-notifications
   29092 Displays whether printing CLI notifications is suppressed or not.
   29093 @end table
   29094 
   29095 @node Extending GDB
   29096 @chapter Extending @value{GDBN}
   29097 @cindex extending GDB
   29098 
   29099 @value{GDBN} provides several mechanisms for extension.
   29100 @value{GDBN} also provides the ability to automatically load
   29101 extensions when it reads a file for debugging.  This allows the
   29102 user to automatically customize @value{GDBN} for the program
   29103 being debugged.
   29104 
   29105 To facilitate the use of extension languages, @value{GDBN} is capable
   29106 of evaluating the contents of a file.  When doing so, @value{GDBN}
   29107 can recognize which extension language is being used by looking at
   29108 the filename extension.  Files with an unrecognized filename extension
   29109 are always treated as a @value{GDBN} Command Files.
   29110 @xref{Command Files,, Command files}.
   29111 
   29112 You can control how @value{GDBN} evaluates these files with the following
   29113 setting:
   29114 
   29115 @table @code
   29116 @kindex set script-extension
   29117 @kindex show script-extension
   29118 @item set script-extension off
   29119 All scripts are always evaluated as @value{GDBN} Command Files.
   29120 
   29121 @item set script-extension soft
   29122 The debugger determines the scripting language based on filename
   29123 extension.  If this scripting language is supported, @value{GDBN}
   29124 evaluates the script using that language.  Otherwise, it evaluates
   29125 the file as a @value{GDBN} Command File.
   29126 
   29127 @item set script-extension strict
   29128 The debugger determines the scripting language based on filename
   29129 extension, and evaluates the script using that language.  If the
   29130 language is not supported, then the evaluation fails.
   29131 
   29132 @item show script-extension
   29133 Display the current value of the @code{script-extension} option.
   29134 
   29135 @end table
   29136 
   29137 @ifset SYSTEM_GDBINIT_DIR
   29138 This setting is not used for files in the system-wide gdbinit directory.
   29139 Files in that directory must have an extension matching their language,
   29140 or have a @file{.gdb} extension to be interpreted as regular @value{GDBN}
   29141 commands.  @xref{Startup}.
   29142 @end ifset
   29143 
   29144 @menu
   29145 * Sequences::                Canned Sequences of @value{GDBN} Commands
   29146 * Aliases::                  Command Aliases
   29147 * Python::                   Extending @value{GDBN} using Python
   29148 * Guile::                    Extending @value{GDBN} using Guile
   29149 * Auto-loading extensions::  Automatically loading extensions
   29150 * Multiple Extension Languages:: Working with multiple extension languages
   29151 @end menu
   29152 
   29153 @node Sequences
   29154 @section Canned Sequences of Commands
   29155 
   29156 Aside from breakpoint commands (@pxref{Break Commands, ,Breakpoint
   29157 Command Lists}), @value{GDBN} provides two ways to store sequences of
   29158 commands for execution as a unit: user-defined commands and command
   29159 files.
   29160 
   29161 @menu
   29162 * Define::             How to define your own commands
   29163 * Hooks::              Hooks for user-defined commands
   29164 * Command Files::      How to write scripts of commands to be stored in a file
   29165 * Output::             Commands for controlled output
   29166 * Auto-loading sequences::  Controlling auto-loaded command files
   29167 @end menu
   29168 
   29169 @node Define
   29170 @subsection User-defined Commands
   29171 
   29172 @cindex user-defined command
   29173 @cindex arguments, to user-defined commands
   29174 A @dfn{user-defined command} is a sequence of @value{GDBN} commands to
   29175 which you assign a new name as a command.  This is done with the
   29176 @code{define} command.
   29177 
   29178 User commands may accept an unlimited number of arguments separated by
   29179 whitespace.  Arguments are accessed within the user command via
   29180 @code{$arg0@dots{}$argN}.  The arguments are text substitutions, so
   29181 they may reference variables, use complex expressions, or even perform
   29182 inferior functions calls.  Note, however, that this textual
   29183 substitution means that working with certain arguments is difficult.
   29184 For example, there is no way for the user to pass an argument
   29185 containing a space; and while stringifying an argument can be done
   29186 using an expression like @code{"$arg1"}, this will fail if the
   29187 argument contains a quote.  For more complicated and robust commands,
   29188 we recommend writing them in Python; see @ref{CLI Commands In Python}.
   29189 
   29190 A trivial example:
   29191 
   29192 @smallexample
   29193 define adder
   29194   print $arg0 + $arg1 + $arg2
   29195 end
   29196 @end smallexample
   29197 
   29198 @noindent
   29199 To execute the command use:
   29200 
   29201 @smallexample
   29202 adder 1 2 3
   29203 @end smallexample
   29204 
   29205 @noindent
   29206 This defines the command @code{adder}, which prints the sum of
   29207 its three arguments.
   29208 
   29209 @cindex argument count in user-defined commands
   29210 @cindex how many arguments (user-defined commands)
   29211 In addition, @code{$argc} may be used to find out how many arguments have
   29212 been passed.
   29213 
   29214 @smallexample
   29215 define adder
   29216   if $argc == 2
   29217     print $arg0 + $arg1
   29218   end
   29219   if $argc == 3
   29220     print $arg0 + $arg1 + $arg2
   29221   end
   29222 end
   29223 @end smallexample
   29224 
   29225 Combining with the @code{eval} command (@pxref{eval}) makes it easier
   29226 to process a variable number of arguments:
   29227 
   29228 @smallexample
   29229 define adder
   29230   set $i = 0
   29231   set $sum = 0
   29232   while $i < $argc
   29233     eval "set $sum = $sum + $arg%d", $i
   29234     set $i = $i + 1
   29235   end
   29236   print $sum
   29237 end
   29238 @end smallexample
   29239 
   29240 @table @code
   29241 
   29242 @kindex define
   29243 @item define @var{commandname}
   29244 Define a command named @var{commandname}.  If there is already a command
   29245 by that name, you are asked to confirm that you want to redefine it.
   29246 The argument @var{commandname} may be a bare command name consisting of letters,
   29247 numbers, dashes, dots, and underscores.  It may also start with any
   29248 predefined or user-defined prefix command.
   29249 For example, @samp{define target my-target} creates
   29250 a user-defined @samp{target my-target} command.
   29251 
   29252 The definition of the command is made up of other @value{GDBN} command lines,
   29253 which are given following the @code{define} command.  The end of these
   29254 commands is marked by a line containing @code{end}.
   29255 
   29256 @kindex document
   29257 @kindex end@r{ (user-defined commands)}
   29258 @item document @var{commandname}
   29259 Document the user-defined command @var{commandname}, so that it can be
   29260 accessed by @code{help}.  The command @var{commandname} must already be
   29261 defined.  This command reads lines of documentation just as @code{define}
   29262 reads the lines of the command definition, ending with @code{end}.
   29263 After the @code{document} command is finished, @code{help} on command
   29264 @var{commandname} displays the documentation you have written.
   29265 
   29266 You may use the @code{document} command again to change the
   29267 documentation of a command.  Redefining the command with @code{define}
   29268 does not change the documentation.
   29269 
   29270 It is also possible to document user-defined aliases.  The alias documentation
   29271 will then be used by the @code{help} and @code{apropos} commands
   29272 instead of the documentation of the aliased command.
   29273 Documenting a user-defined alias is particularly useful when defining
   29274 an alias as a set of nested @code{with} commands
   29275 (@pxref{Command aliases default args}).
   29276 
   29277 @kindex define-prefix
   29278 @item define-prefix @var{commandname}
   29279 Define or mark the command @var{commandname} as a user-defined prefix
   29280 command.  Once marked, @var{commandname} can be used as prefix command
   29281 by the  @code{define} command.
   29282 Note that @code{define-prefix} can be used with a not yet defined
   29283 @var{commandname}.  In such a case, @var{commandname} is defined as
   29284 an empty user-defined command.
   29285 In case you redefine a command that was marked as a user-defined
   29286 prefix command, the subcommands of the redefined command are kept
   29287 (and @value{GDBN} indicates so to the user).
   29288 
   29289 Example:
   29290 @example
   29291 (@value{GDBP}) define-prefix abc
   29292 (@value{GDBP}) define-prefix abc def
   29293 (@value{GDBP}) define abc def
   29294 Type commands for definition of "abc def".
   29295 End with a line saying just "end".
   29296 >echo command initial def\n
   29297 >end
   29298 (@value{GDBP}) define abc def ghi
   29299 Type commands for definition of "abc def ghi".
   29300 End with a line saying just "end".
   29301 >echo command ghi\n
   29302 >end
   29303 (@value{GDBP}) define abc def
   29304 Keeping subcommands of prefix command "def".
   29305 Redefine command "def"? (y or n) y
   29306 Type commands for definition of "abc def".
   29307 End with a line saying just "end".
   29308 >echo command def\n
   29309 >end
   29310 (@value{GDBP}) abc def ghi
   29311 command ghi
   29312 (@value{GDBP}) abc def
   29313 command def
   29314 (@value{GDBP})
   29315 @end example
   29316 
   29317 @kindex dont-repeat
   29318 @cindex don't repeat command
   29319 @item dont-repeat
   29320 Used inside a user-defined command, this tells @value{GDBN} that this
   29321 command should not be repeated when the user hits @key{RET}
   29322 (@pxref{Command Syntax, repeat last command}).
   29323 
   29324 @kindex help user-defined
   29325 @item help user-defined
   29326 List all user-defined commands and all python commands defined in class
   29327 COMMAND_USER.  The first line of the documentation or docstring is
   29328 included (if any).
   29329 
   29330 @kindex show user
   29331 @item show user
   29332 @itemx show user @var{commandname}
   29333 Display the @value{GDBN} commands used to define @var{commandname} (but
   29334 not its documentation).  If no @var{commandname} is given, display the
   29335 definitions for all user-defined commands.
   29336 This does not work for user-defined python commands.
   29337 
   29338 @cindex infinite recursion in user-defined commands
   29339 @kindex show max-user-call-depth
   29340 @kindex set max-user-call-depth
   29341 @item show max-user-call-depth
   29342 @itemx set max-user-call-depth
   29343 The value of @code{max-user-call-depth} controls how many recursion
   29344 levels are allowed in user-defined commands before @value{GDBN} suspects an
   29345 infinite recursion and aborts the command.
   29346 This does not apply to user-defined python commands.
   29347 @end table
   29348 
   29349 In addition to the above commands, user-defined commands frequently
   29350 use control flow commands, described in @ref{Command Files}.
   29351 
   29352 When user-defined commands are executed, the
   29353 commands of the definition are not printed.  An error in any command
   29354 stops execution of the user-defined command.
   29355 
   29356 If used interactively, commands that would ask for confirmation proceed
   29357 without asking when used inside a user-defined command.  Many @value{GDBN}
   29358 commands that normally print messages to say what they are doing omit the
   29359 messages when used in a user-defined command.
   29360 
   29361 @node Hooks
   29362 @subsection User-defined Command Hooks
   29363 @cindex command hooks
   29364 @cindex hooks, for commands
   29365 @cindex hooks, pre-command
   29366 
   29367 @kindex hook
   29368 You may define @dfn{hooks}, which are a special kind of user-defined
   29369 command.  Whenever you run the command @samp{foo}, if the user-defined
   29370 command @samp{hook-foo} exists, it is executed (with no arguments)
   29371 before that command.
   29372 
   29373 @cindex hooks, post-command
   29374 @kindex hookpost
   29375 A hook may also be defined which is run after the command you executed.
   29376 Whenever you run the command @samp{foo}, if the user-defined command
   29377 @samp{hookpost-foo} exists, it is executed (with no arguments) after
   29378 that command.  Post-execution hooks may exist simultaneously with
   29379 pre-execution hooks, for the same command.
   29380 
   29381 It is valid for a hook to call the command which it hooks.  If this
   29382 occurs, the hook is not re-executed, thereby avoiding infinite recursion.
   29383 
   29384 @c It would be nice if hookpost could be passed a parameter indicating
   29385 @c if the command it hooks executed properly or not.  FIXME!
   29386 
   29387 @kindex stop@r{, a pseudo-command}
   29388 In addition, a pseudo-command, @samp{stop} exists.  Defining
   29389 (@samp{hook-stop}) makes the associated commands execute every time
   29390 execution stops in your program: before breakpoint commands are run,
   29391 displays are printed, or the stack frame is printed.
   29392 
   29393 For example, to ignore @code{SIGALRM} signals while
   29394 single-stepping, but treat them normally during normal execution,
   29395 you could define:
   29396 
   29397 @smallexample
   29398 define hook-stop
   29399 handle SIGALRM nopass
   29400 end
   29401 
   29402 define hook-run
   29403 handle SIGALRM pass
   29404 end
   29405 
   29406 define hook-continue
   29407 handle SIGALRM pass
   29408 end
   29409 @end smallexample
   29410 
   29411 As a further example, to hook at the beginning and end of the @code{echo}
   29412 command, and to add extra text to the beginning and end of the message,
   29413 you could define:
   29414 
   29415 @smallexample
   29416 define hook-echo
   29417 echo <<<---
   29418 end
   29419 
   29420 define hookpost-echo
   29421 echo --->>>\n
   29422 end
   29423 
   29424 (@value{GDBP}) echo Hello World
   29425 <<<---Hello World--->>>
   29426 (@value{GDBP})
   29427 
   29428 @end smallexample
   29429 
   29430 You can define a hook for any single-word command in @value{GDBN}, but
   29431 not for command aliases; you should define a hook for the basic command
   29432 name, e.g.@:  @code{backtrace} rather than @code{bt}.
   29433 @c FIXME!  So how does Joe User discover whether a command is an alias
   29434 @c or not?
   29435 You can hook a multi-word command by adding @code{hook-} or
   29436 @code{hookpost-} to the last word of the command, e.g.@:
   29437 @samp{define target hook-remote} to add a hook to @samp{target remote}.
   29438 
   29439 If an error occurs during the execution of your hook, execution of
   29440 @value{GDBN} commands stops and @value{GDBN} issues a prompt
   29441 (before the command that you actually typed had a chance to run).
   29442 
   29443 If you try to define a hook which does not match any known command, you
   29444 get a warning from the @code{define} command.
   29445 
   29446 @node Command Files
   29447 @subsection Command Files
   29448 
   29449 @cindex command files
   29450 @cindex scripting commands
   29451 A command file for @value{GDBN} is a text file made of lines that are
   29452 @value{GDBN} commands.  Comments (lines starting with @kbd{#}) may
   29453 also be included.  An empty line in a command file does nothing; it
   29454 does not mean to repeat the last command, as it would from the
   29455 terminal.
   29456 
   29457 You can request the execution of a command file with the @code{source}
   29458 command.  Note that the @code{source} command is also used to evaluate
   29459 scripts that are not Command Files.  The exact behavior can be configured
   29460 using the @code{script-extension} setting.
   29461 @xref{Extending GDB,, Extending GDB}.
   29462 
   29463 @table @code
   29464 @kindex source
   29465 @cindex execute commands from a file
   29466 @item source [-s] [-v] @var{filename}
   29467 Execute the command file @var{filename}.
   29468 @end table
   29469 
   29470 The lines in a command file are generally executed sequentially,
   29471 unless the order of execution is changed by one of the
   29472 @emph{flow-control commands} described below.  The commands are not
   29473 printed as they are executed.  An error in any command terminates
   29474 execution of the command file and control is returned to the console.
   29475 
   29476 @value{GDBN} first searches for @var{filename} in the current directory.
   29477 If the file is not found there, and @var{filename} does not specify a
   29478 directory, then @value{GDBN} also looks for the file on the source search path
   29479 (specified with the @samp{directory} command);
   29480 except that @file{$cdir} is not searched because the compilation directory
   29481 is not relevant to scripts.
   29482 
   29483 If @code{-s} is specified, then @value{GDBN} searches for @var{filename}
   29484 on the search path even if @var{filename} specifies a directory.
   29485 The search is done by appending @var{filename} to each element of the
   29486 search path.  So, for example, if @var{filename} is @file{mylib/myscript}
   29487 and the search path contains @file{/home/user} then @value{GDBN} will
   29488 look for the script @file{/home/user/mylib/myscript}.
   29489 The search is also done if @var{filename} is an absolute path.
   29490 For example, if @var{filename} is @file{/tmp/myscript} and
   29491 the search path contains @file{/home/user} then @value{GDBN} will
   29492 look for the script @file{/home/user/tmp/myscript}.
   29493 For DOS-like systems, if @var{filename} contains a drive specification,
   29494 it is stripped before concatenation.  For example, if @var{filename} is
   29495 @file{d:myscript} and the search path contains @file{c:/tmp} then @value{GDBN}
   29496 will look for the script @file{c:/tmp/myscript}.
   29497 
   29498 If @code{-v}, for verbose mode, is given then @value{GDBN} displays
   29499 each command as it is executed.  The option must be given before
   29500 @var{filename}, and is interpreted as part of the filename anywhere else.
   29501 
   29502 Commands that would ask for confirmation if used interactively proceed
   29503 without asking when used in a command file.  Many @value{GDBN} commands that
   29504 normally print messages to say what they are doing omit the messages
   29505 when called from command files.
   29506 
   29507 @value{GDBN} also accepts command input from standard input.  In this
   29508 mode, normal output goes to standard output and error output goes to
   29509 standard error.  Errors in a command file supplied on standard input do
   29510 not terminate execution of the command file---execution continues with
   29511 the next command.
   29512 
   29513 @smallexample
   29514 gdb < cmds > log 2>&1
   29515 @end smallexample
   29516 
   29517 (The syntax above will vary depending on the shell used.) This example
   29518 will execute commands from the file @file{cmds}. All output and errors
   29519 would be directed to @file{log}.
   29520 
   29521 Since commands stored on command files tend to be more general than
   29522 commands typed interactively, they frequently need to deal with
   29523 complicated situations, such as different or unexpected values of
   29524 variables and symbols, changes in how the program being debugged is
   29525 built, etc.  @value{GDBN} provides a set of flow-control commands to
   29526 deal with these complexities.  Using these commands, you can write
   29527 complex scripts that loop over data structures, execute commands
   29528 conditionally, etc.
   29529 
   29530 @table @code
   29531 @kindex if
   29532 @kindex else
   29533 @item if
   29534 @itemx else
   29535 This command allows to include in your script conditionally executed
   29536 commands. The @code{if} command takes a single argument, which is an
   29537 expression to evaluate.  It is followed by a series of commands that
   29538 are executed only if the expression is true (its value is nonzero).
   29539 There can then optionally be an @code{else} line, followed by a series
   29540 of commands that are only executed if the expression was false.  The
   29541 end of the list is marked by a line containing @code{end}.
   29542 
   29543 @kindex while
   29544 @item while
   29545 This command allows to write loops.  Its syntax is similar to
   29546 @code{if}: the command takes a single argument, which is an expression
   29547 to evaluate, and must be followed by the commands to execute, one per
   29548 line, terminated by an @code{end}.  These commands are called the
   29549 @dfn{body} of the loop.  The commands in the body of @code{while} are
   29550 executed repeatedly as long as the expression evaluates to true.
   29551 
   29552 @kindex loop_break
   29553 @item loop_break
   29554 This command exits the @code{while} loop in whose body it is included.
   29555 Execution of the script continues after that @code{while}s @code{end}
   29556 line.
   29557 
   29558 @kindex loop_continue
   29559 @item loop_continue
   29560 This command skips the execution of the rest of the body of commands
   29561 in the @code{while} loop in whose body it is included.  Execution
   29562 branches to the beginning of the @code{while} loop, where it evaluates
   29563 the controlling expression.
   29564 
   29565 @kindex end@r{ (if/else/while commands)}
   29566 @item end
   29567 Terminate the block of commands that are the body of @code{if},
   29568 @code{else}, or @code{while} flow-control commands.
   29569 @end table
   29570 
   29571 
   29572 @node Output
   29573 @subsection Commands for Controlled Output
   29574 
   29575 During the execution of a command file or a user-defined command, normal
   29576 @value{GDBN} output is suppressed; the only output that appears is what is
   29577 explicitly printed by the commands in the definition.  This section
   29578 describes three commands useful for generating exactly the output you
   29579 want.
   29580 
   29581 @table @code
   29582 @kindex echo
   29583 @item echo @var{text}
   29584 @c I do not consider backslash-space a standard C escape sequence
   29585 @c because it is not in ANSI.
   29586 Print @var{text}.  Nonprinting characters can be included in
   29587 @var{text} using C escape sequences, such as @samp{\n} to print a
   29588 newline.  @strong{No newline is printed unless you specify one.}
   29589 In addition to the standard C escape sequences, a backslash followed
   29590 by a space stands for a space.  This is useful for displaying a
   29591 string with spaces at the beginning or the end, since leading and
   29592 trailing spaces are otherwise trimmed from all arguments.
   29593 To print @samp{@w{ }and foo =@w{ }}, use the command
   29594 @samp{echo \@w{ }and foo = \@w{ }}.
   29595 
   29596 A backslash at the end of @var{text} can be used, as in C, to continue
   29597 the command onto subsequent lines.  For example,
   29598 
   29599 @smallexample
   29600 echo This is some text\n\
   29601 which is continued\n\
   29602 onto several lines.\n
   29603 @end smallexample
   29604 
   29605 produces the same output as
   29606 
   29607 @smallexample
   29608 echo This is some text\n
   29609 echo which is continued\n
   29610 echo onto several lines.\n
   29611 @end smallexample
   29612 
   29613 @kindex output
   29614 @item output @var{expression}
   29615 Print the value of @var{expression} and nothing but that value: no
   29616 newlines, no @samp{$@var{nn} = }.  The value is not entered in the
   29617 value history either.  @xref{Expressions, ,Expressions}, for more information
   29618 on expressions.
   29619 
   29620 @item output/@var{fmt} @var{expression}
   29621 Print the value of @var{expression} in format @var{fmt}.  You can use
   29622 the same formats as for @code{print}.  @xref{Output Formats,,Output
   29623 Formats}, for more information.
   29624 
   29625 @kindex printf
   29626 @item printf @var{template}, @var{expressions}@dots{}
   29627 Print the values of one or more @var{expressions} under the control of
   29628 the string @var{template}.  To print several values, make
   29629 @var{expressions} be a comma-separated list of individual expressions,
   29630 which may be either numbers or pointers.  Their values are printed as
   29631 specified by @var{template}, exactly as a C program would do by
   29632 executing the code below:
   29633 
   29634 @smallexample
   29635 printf (@var{template}, @var{expressions}@dots{});
   29636 @end smallexample
   29637 
   29638 As in @code{C} @code{printf}, ordinary characters in @var{template}
   29639 are printed verbatim, while @dfn{conversion specification} introduced
   29640 by the @samp{%} character cause subsequent @var{expressions} to be
   29641 evaluated, their values converted and formatted according to type and
   29642 style information encoded in the conversion specifications, and then
   29643 printed.
   29644 
   29645 For example, you can print two values in hex like this:
   29646 
   29647 @smallexample
   29648 printf "foo, bar-foo = 0x%x, 0x%x\n", foo, bar-foo
   29649 @end smallexample
   29650 
   29651 @code{printf} supports all the standard @code{C} conversion
   29652 specifications, including the flags and modifiers between the @samp{%}
   29653 character and the conversion letter, with the following exceptions:
   29654 
   29655 @itemize @bullet
   29656 @item
   29657 The argument-ordering modifiers, such as @samp{2$}, are not supported.
   29658 
   29659 @item
   29660 The modifier @samp{*} is not supported for specifying precision or
   29661 width.
   29662 
   29663 @item
   29664 The @samp{'} flag (for separation of digits into groups according to
   29665 @code{LC_NUMERIC'}) is not supported.
   29666 
   29667 @item
   29668 The type modifiers @samp{hh}, @samp{j}, @samp{t}, and @samp{z} are not
   29669 supported.
   29670 
   29671 @item
   29672 The conversion letter @samp{n} (as in @samp{%n}) is not supported.
   29673 
   29674 @item
   29675 The conversion letters @samp{a} and @samp{A} are not supported.
   29676 @end itemize
   29677 
   29678 @noindent
   29679 Note that the @samp{ll} type modifier is supported only if the
   29680 underlying @code{C} implementation used to build @value{GDBN} supports
   29681 the @code{long long int} type, and the @samp{L} type modifier is
   29682 supported only if @code{long double} type is available.
   29683 
   29684 As in @code{C}, @code{printf} supports simple backslash-escape
   29685 sequences, such as @code{\n}, @samp{\t}, @samp{\\}, @samp{\"},
   29686 @samp{\a}, and @samp{\f}, that consist of backslash followed by a
   29687 single character.  Octal and hexadecimal escape sequences are not
   29688 supported.
   29689 
   29690 Additionally, @code{printf} supports conversion specifications for DFP
   29691 (@dfn{Decimal Floating Point}) types using the following length modifiers
   29692 together with a floating point specifier.
   29693 letters:
   29694 
   29695 @itemize @bullet
   29696 @item
   29697 @samp{H} for printing @code{Decimal32} types.
   29698 
   29699 @item
   29700 @samp{D} for printing @code{Decimal64} types.
   29701 
   29702 @item
   29703 @samp{DD} for printing @code{Decimal128} types.
   29704 @end itemize
   29705 
   29706 If the underlying @code{C} implementation used to build @value{GDBN} has
   29707 support for the three length modifiers for DFP types, other modifiers
   29708 such as width and precision will also be available for @value{GDBN} to use.
   29709 
   29710 In case there is no such @code{C} support, no additional modifiers will be
   29711 available and the value will be printed in the standard way.
   29712 
   29713 Here's an example of printing DFP types using the above conversion letters:
   29714 @smallexample
   29715 printf "D32: %Hf - D64: %Df - D128: %DDf\n",1.2345df,1.2E10dd,1.2E1dl
   29716 @end smallexample
   29717 
   29718 @anchor{%V Format Specifier}
   29719 Additionally, @code{printf} supports a special @samp{%V} output format.
   29720 This format prints the string representation of an expression just as
   29721 @value{GDBN} would produce with the standard @kbd{print} command
   29722 (@pxref{Data, ,Examining Data}):
   29723 
   29724 @smallexample
   29725 (@value{GDBP}) print array
   29726 $1 = @{0, 1, 2, 3, 4, 5@}
   29727 (@value{GDBP}) printf "Array is: %V\n", array
   29728 Array is: @{0, 1, 2, 3, 4, 5@}
   29729 @end smallexample
   29730 
   29731 It is possible to include print options with the @samp{%V} format by
   29732 placing them in @samp{[...]} immediately after the @samp{%V}, like
   29733 this:
   29734 
   29735 @smallexample
   29736 (@value{GDBP}) printf "Array is: %V[-array-indexes on]\n", array
   29737 Array is: @{[0] = 0, [1] = 1, [2] = 2, [3] = 3, [4] = 4, [5] = 5@}
   29738 @end smallexample
   29739 
   29740 If you need to print a literal @samp{[} directly after a @samp{%V}, then
   29741 just include an empty print options list:
   29742 
   29743 @smallexample
   29744 (@value{GDBP}) printf "Array is: %V[][Hello]\n", array
   29745 Array is: @{0, 1, 2, 3, 4, 5@}[Hello]
   29746 @end smallexample
   29747 
   29748 @anchor{eval}
   29749 @kindex eval
   29750 @item eval @var{template}, @var{expressions}@dots{}
   29751 Convert the values of one or more @var{expressions} under the control of
   29752 the string @var{template} to a command line, and call it.
   29753 
   29754 @end table
   29755 
   29756 @node Auto-loading sequences
   29757 @subsection Controlling auto-loading native @value{GDBN} scripts
   29758 @cindex native script auto-loading
   29759 
   29760 When a new object file is read (for example, due to the @code{file}
   29761 command, or because the inferior has loaded a shared library),
   29762 @value{GDBN} will look for the command file @file{@var{objfile}-gdb.gdb}.
   29763 @xref{Auto-loading extensions}.
   29764 
   29765 Auto-loading can be enabled or disabled,
   29766 and the list of auto-loaded scripts can be printed.
   29767 
   29768 @table @code
   29769 @anchor{set auto-load gdb-scripts}
   29770 @kindex set auto-load gdb-scripts
   29771 @item set auto-load gdb-scripts [on|off]
   29772 Enable or disable the auto-loading of canned sequences of commands scripts.
   29773 
   29774 @anchor{show auto-load gdb-scripts}
   29775 @kindex show auto-load gdb-scripts
   29776 @item show auto-load gdb-scripts
   29777 Show whether auto-loading of canned sequences of commands scripts is enabled or
   29778 disabled.
   29779 
   29780 @anchor{info auto-load gdb-scripts}
   29781 @kindex info auto-load gdb-scripts
   29782 @cindex print list of auto-loaded canned sequences of commands scripts
   29783 @item info auto-load gdb-scripts [@var{regexp}]
   29784 Print the list of all canned sequences of commands scripts that @value{GDBN}
   29785 auto-loaded.
   29786 @end table
   29787 
   29788 If @var{regexp} is supplied only canned sequences of commands scripts with
   29789 matching names are printed.
   29790 
   29791 @node Aliases
   29792 @section Command Aliases
   29793 @cindex aliases for commands
   29794 
   29795 Aliases allow you to define alternate spellings for existing commands.
   29796 For example, if a new @value{GDBN} command defined in Python
   29797 (@pxref{Python}) has a long name, it is handy to have an abbreviated
   29798 version of it that involves less typing.
   29799 
   29800 @value{GDBN} itself uses aliases.  For example @samp{s} is an alias
   29801 of the @samp{step} command even though it is otherwise an ambiguous
   29802 abbreviation of other commands like @samp{set} and @samp{show}.
   29803 
   29804 Aliases are also used to provide shortened or more common versions
   29805 of multi-word commands.  For example, @value{GDBN} provides the
   29806 @samp{tty} alias of the @samp{set inferior-tty} command.
   29807 
   29808 You can define a new alias with the @samp{alias} command.
   29809 
   29810 @table @code
   29811 
   29812 @kindex alias
   29813 @item alias [-a] [--] @var{alias} = @var{command} [@var{default-args}]
   29814 
   29815 @end table
   29816 
   29817 @var{alias} specifies the name of the new alias.  Each word of
   29818 @var{alias} must consist of letters, numbers, dashes and underscores.
   29819 
   29820 @var{command} specifies the name of an existing command
   29821 that is being aliased.
   29822 
   29823 @var{command} can also be the name of an existing alias.  In this
   29824 case, @var{command} cannot be an alias that has default arguments.
   29825 
   29826 The @samp{-a} option specifies that the new alias is an abbreviation
   29827 of the command.  Abbreviations are not used in command completion.
   29828 
   29829 The @samp{--} option specifies the end of options,
   29830 and is useful when @var{alias} begins with a dash.
   29831 
   29832 You can specify @var{default-args} for your alias.  These
   29833 @var{default-args} will be automatically added before the alias
   29834 arguments typed explicitly on the command line.
   29835 
   29836 For example, the below defines an alias @code{btfullall} that shows all local
   29837 variables and all frame arguments:
   29838 @smallexample
   29839 (@value{GDBP}) alias btfullall = backtrace -full -frame-arguments all
   29840 @end smallexample
   29841 
   29842 For more information about @var{default-args}, see @ref{Command
   29843 aliases default args, ,Default Arguments}.
   29844 
   29845 Here is a simple example showing how to make an abbreviation of a
   29846 command so that there is less to type.  Suppose you were tired of
   29847 typing @samp{disas}, the current shortest unambiguous abbreviation of
   29848 the @samp{disassemble} command and you wanted an even shorter version
   29849 named @samp{di}.  The following will accomplish this.
   29850 
   29851 @smallexample
   29852 (@value{GDBP}) alias -a di = disas
   29853 @end smallexample
   29854 
   29855 Note that aliases are different from user-defined commands.  With a
   29856 user-defined command, you also need to write documentation for it with
   29857 the @samp{document} command.  An alias automatically picks up the
   29858 documentation of the existing command.
   29859 
   29860 Here is an example where we make @samp{elms} an abbreviation of
   29861 @samp{elements} in the @samp{set print elements} command.
   29862 This is to show that you can make an abbreviation of any part
   29863 of a command.
   29864 
   29865 @smallexample
   29866 (@value{GDBP}) alias -a set print elms = set print elements
   29867 (@value{GDBP}) alias -a show print elms = show print elements
   29868 (@value{GDBP}) set p elms 200
   29869 (@value{GDBP}) show p elms
   29870 Limit on string chars or array elements to print is 200.
   29871 @end smallexample
   29872 
   29873 Note that if you are defining an alias of a @samp{set} command,
   29874 and you want to have an alias for the corresponding @samp{show}
   29875 command, then you need to define the latter separately.
   29876 
   29877 Unambiguously abbreviated commands are allowed in @var{command} and
   29878 @var{alias}, just as they are normally.
   29879 
   29880 @smallexample
   29881 (@value{GDBP}) alias -a set pr elms = set p ele
   29882 @end smallexample
   29883 
   29884 Finally, here is an example showing the creation of a one word
   29885 alias for a more complex command.
   29886 This creates alias @samp{spe} of the command @samp{set print elements}.
   29887 
   29888 @smallexample
   29889 (@value{GDBP}) alias spe = set print elements
   29890 (@value{GDBP}) spe 20
   29891 @end smallexample
   29892 
   29893 @menu
   29894 * Command aliases default args::        Default arguments for aliases
   29895 @end menu
   29896 
   29897 @node Command aliases default args
   29898 @subsection Default Arguments
   29899 @cindex aliases for commands, default arguments
   29900 
   29901 You can tell @value{GDBN} to always prepend some default arguments to
   29902 the list of arguments provided explicitly by the user when using a
   29903 user-defined alias.
   29904 
   29905 If you repeatedly use the same arguments or options for a command, you
   29906 can define an alias for this command and tell @value{GDBN} to
   29907 automatically prepend these arguments or options to the list of
   29908 arguments you type explicitly when using the alias@footnote{@value{GDBN}
   29909 could easily accept default arguments for pre-defined commands and aliases,
   29910 but it was deemed this would be confusing, and so is not allowed.}.
   29911 
   29912 For example, if you often use the command @code{thread apply all}
   29913 specifying to work on the threads in ascending order and to continue in case it
   29914 encounters an error, you can tell @value{GDBN} to automatically preprend
   29915 the @code{-ascending} and @code{-c} options by using:
   29916 
   29917 @smallexample
   29918 (@value{GDBP}) alias thread apply asc-all = thread apply all -ascending -c
   29919 @end smallexample
   29920 
   29921 Once you have defined this alias with its default args, any time you type
   29922 the @code{thread apply asc-all} followed by @code{some arguments},
   29923 @value{GDBN} will execute  @code{thread apply all -ascending -c some arguments}.
   29924 
   29925 To have even less to type, you can also define a one word alias:
   29926 @smallexample
   29927 (@value{GDBP}) alias t_a_c = thread apply all -ascending -c
   29928 @end smallexample
   29929 
   29930 As usual, unambiguous abbreviations can be used for @var{alias}
   29931 and @var{default-args}.
   29932 
   29933 The different aliases of a command do not share their default args.
   29934 For example, you define a new alias @code{bt_ALL} showing all possible
   29935 information and another alias @code{bt_SMALL} showing very limited information
   29936 using:
   29937 @smallexample
   29938 (@value{GDBP}) alias bt_ALL = backtrace -entry-values both -frame-arg all \
   29939    -past-main -past-entry -full
   29940 (@value{GDBP}) alias bt_SMALL = backtrace -entry-values no -frame-arg none \
   29941    -past-main off -past-entry off
   29942 @end smallexample
   29943 
   29944 (For more on using the @code{alias} command, see @ref{Aliases}.)
   29945 
   29946 Default args are not limited to the arguments and options of @var{command},
   29947 but can specify nested commands if @var{command} accepts such a nested command
   29948 as argument.
   29949 For example, the below defines @code{faalocalsoftype} that lists the
   29950 frames having locals of a certain type, together with the matching
   29951 local vars:
   29952 @smallexample
   29953 (@value{GDBP}) alias faalocalsoftype = frame apply all info locals -q -t
   29954 (@value{GDBP}) faalocalsoftype int
   29955 #1  0x55554f5e in sleeper_or_burner (v=0xdf50) at sleepers.c:86
   29956 i = 0
   29957 ret = 21845
   29958 @end smallexample
   29959 
   29960 This is also very useful to define an alias for a set of nested @code{with}
   29961 commands to have a particular combination of temporary settings.  For example,
   29962 the below defines the alias @code{pp10} that pretty prints an expression
   29963 argument, with a maximum of 10 elements if the expression is a string or
   29964 an array:
   29965 @smallexample
   29966 (@value{GDBP}) alias pp10 = with print pretty -- with print elements 10 -- print
   29967 @end smallexample
   29968 This defines the alias  @code{pp10} as being a sequence of 3 commands.
   29969 The first part @code{with print pretty --} temporarily activates the setting
   29970 @code{set print pretty}, then launches the command that follows the separator
   29971 @code{--}.
   29972 The command following the first part is also a @code{with} command that
   29973 temporarily changes the setting @code{set print elements} to 10, then
   29974 launches the command that follows the second separator @code{--}.
   29975 The third part @code{print} is the command the @code{pp10} alias will launch,
   29976 using the temporary values of the settings and the arguments explicitly given
   29977 by the user.
   29978 For more information about the @code{with} command usage,
   29979 see @ref{Command Settings}.
   29980 
   29981 By default, asking the help for an alias shows the documentation of
   29982 the aliased command.  When the alias is a set of nested commands, @code{help}
   29983 of an alias shows the documentation of the first command.  This help
   29984 is not particularly useful for an alias such as @code{pp10}.
   29985 For such an alias, it is useful to give a specific documentation
   29986 using the @code{document} command (@pxref{Define, document}).
   29987 
   29988 
   29989 @c Python docs live in a separate file.
   29990 @include python.texi
   29991 
   29992 @c Guile docs live in a separate file.
   29993 @include guile.texi
   29994 
   29995 @node Auto-loading extensions
   29996 @section Auto-loading extensions
   29997 @cindex auto-loading extensions
   29998 
   29999 @value{GDBN} provides two mechanisms for automatically loading
   30000 extensions when a new object file is read (for example, due to the
   30001 @code{file} command, or because the inferior has loaded a shared
   30002 library): @file{@var{objfile}-gdb.@var{ext}} (@pxref{objfile-gdbdotext
   30003 file,,The @file{@var{objfile}-gdb.@var{ext}} file}) and the
   30004 @code{.debug_gdb_scripts} section of modern file formats like ELF
   30005 (@pxref{dotdebug_gdb_scripts section,,The @code{.debug_gdb_scripts}
   30006 section}).  For a discussion of the differences between these two
   30007 approaches see @ref{Which flavor to choose?}.
   30008 
   30009 The auto-loading feature is useful for supplying application-specific
   30010 debugging commands and features.
   30011 
   30012 Auto-loading can be enabled or disabled,
   30013 and the list of auto-loaded scripts can be printed.
   30014 See the @samp{auto-loading} section of each extension language
   30015 for more information.
   30016 For @value{GDBN} command files see @ref{Auto-loading sequences}.
   30017 For Python files see @ref{Python Auto-loading}.
   30018 
   30019 Note that loading of this script file also requires accordingly configured
   30020 @code{auto-load safe-path} (@pxref{Auto-loading safe path}).
   30021 
   30022 @menu
   30023 * objfile-gdbdotext file::              The @file{@var{objfile}-gdb.@var{ext}} file
   30024 * dotdebug_gdb_scripts section::        The @code{.debug_gdb_scripts} section
   30025 * Which flavor to choose?::             Choosing between these approaches
   30026 @end menu
   30027 
   30028 @node objfile-gdbdotext file
   30029 @subsection The @file{@var{objfile}-gdb.@var{ext}} file
   30030 @cindex @file{@var{objfile}-gdb.gdb}
   30031 @cindex @file{@var{objfile}-gdb.py}
   30032 @cindex @file{@var{objfile}-gdb.scm}
   30033 
   30034 When a new object file is read, @value{GDBN} looks for a file named
   30035 @file{@var{objfile}-gdb.@var{ext}} (we call it @var{script-name} below),
   30036 where @var{objfile} is the object file's name and
   30037 where @var{ext} is the file extension for the extension language:
   30038 
   30039 @table @code
   30040 @item @file{@var{objfile}-gdb.gdb}
   30041 GDB's own command language
   30042 @item @file{@var{objfile}-gdb.py}
   30043 Python
   30044 @item @file{@var{objfile}-gdb.scm}
   30045 Guile
   30046 @end table
   30047 
   30048 @var{script-name} is formed by ensuring that the file name of @var{objfile}
   30049 is absolute, following all symlinks, and resolving @code{.} and @code{..}
   30050 components, and appending the @file{-gdb.@var{ext}} suffix.
   30051 If this file exists and is readable, @value{GDBN} will evaluate it as a
   30052 script in the specified extension language.
   30053 
   30054 If this file does not exist, then @value{GDBN} will look for
   30055 @var{script-name} file in all of the directories as specified below.
   30056 (On MS-Windows/MS-DOS, the drive letter of the executable's leading
   30057 directories is converted to a one-letter subdirectory, i.e.@:
   30058 @file{d:/usr/bin/} is converted to @file{/d/usr/bin/}, because Windows
   30059 filesystems disallow colons in file names.)
   30060 
   30061 Note that loading of these files requires an accordingly configured
   30062 @code{auto-load safe-path} (@pxref{Auto-loading safe path}).
   30063 
   30064 For object files using @file{.exe} suffix @value{GDBN} tries to load first the
   30065 scripts normally according to its @file{.exe} filename.  But if no scripts are
   30066 found @value{GDBN} also tries script filenames matching the object file without
   30067 its @file{.exe} suffix.  This @file{.exe} stripping is case insensitive and it
   30068 is attempted on any platform.  This makes the script filenames compatible
   30069 between Unix and MS-Windows hosts.
   30070 
   30071 @table @code
   30072 @anchor{set auto-load scripts-directory}
   30073 @kindex set auto-load scripts-directory
   30074 @item set auto-load scripts-directory @r{[}@var{directories}@r{]}
   30075 Control @value{GDBN} auto-loaded scripts location.  Multiple directory entries
   30076 may be delimited by the host platform path separator in use
   30077 (@samp{:} on Unix, @samp{;} on MS-Windows and MS-DOS).
   30078 
   30079 Each entry here needs to be covered also by the security setting
   30080 @code{set auto-load safe-path} (@pxref{set auto-load safe-path}).
   30081 
   30082 @anchor{with-auto-load-dir}
   30083 This variable defaults to @file{$debugdir:$datadir/auto-load}.  The default
   30084 @code{set auto-load safe-path} value can be also overridden by @value{GDBN}
   30085 configuration option @option{--with-auto-load-dir}.
   30086 
   30087 Any reference to @file{$debugdir} will get replaced by
   30088 @var{debug-file-directory} value (@pxref{Separate Debug Files}) and any
   30089 reference to @file{$datadir} will get replaced by @var{data-directory} which is
   30090 determined at @value{GDBN} startup (@pxref{Data Files}).  @file{$debugdir} and
   30091 @file{$datadir} must be placed as a directory component --- either alone or
   30092 delimited by @file{/} or @file{\} directory separators, depending on the host
   30093 platform.
   30094 
   30095 The list of directories uses path separator (@samp{:} on GNU and Unix
   30096 systems, @samp{;} on MS-Windows and MS-DOS) to separate directories, similarly
   30097 to the @env{PATH} environment variable.
   30098 
   30099 @anchor{show auto-load scripts-directory}
   30100 @kindex show auto-load scripts-directory
   30101 @item show auto-load scripts-directory
   30102 Show @value{GDBN} auto-loaded scripts location.
   30103 
   30104 @anchor{add-auto-load-scripts-directory}
   30105 @kindex add-auto-load-scripts-directory
   30106 @item add-auto-load-scripts-directory @r{[}@var{directories}@dots{}@r{]}
   30107 Add an entry (or list of entries) to the list of auto-loaded scripts locations.
   30108 Multiple entries may be delimited by the host platform path separator in use.
   30109 @end table
   30110 
   30111 @value{GDBN} does not track which files it has already auto-loaded this way.
   30112 @value{GDBN} will load the associated script every time the corresponding
   30113 @var{objfile} is opened.
   30114 So your @file{-gdb.@var{ext}} file should be careful to avoid errors if it
   30115 is evaluated more than once.
   30116 
   30117 @node dotdebug_gdb_scripts section
   30118 @subsection The @code{.debug_gdb_scripts} section
   30119 @cindex @code{.debug_gdb_scripts} section
   30120 
   30121 For systems using file formats like ELF and COFF,
   30122 when @value{GDBN} loads a new object file
   30123 it will look for a special section named @code{.debug_gdb_scripts}.
   30124 If this section exists, its contents is a list of null-terminated entries
   30125 specifying scripts to load.  Each entry begins with a non-null prefix byte that
   30126 specifies the kind of entry, typically the extension language and whether the
   30127 script is in a file or inlined in @code{.debug_gdb_scripts}.
   30128 
   30129 The following entries are supported:
   30130 
   30131 @table @code
   30132 @item SECTION_SCRIPT_ID_PYTHON_FILE = 1
   30133 @item SECTION_SCRIPT_ID_SCHEME_FILE = 3
   30134 @item SECTION_SCRIPT_ID_PYTHON_TEXT = 4
   30135 @item SECTION_SCRIPT_ID_SCHEME_TEXT = 6
   30136 @end table
   30137 
   30138 @subsubsection Script File Entries
   30139 
   30140 If the entry specifies a file, @value{GDBN} will look for the file first
   30141 in the current directory and then along the source search path
   30142 (@pxref{Source Path, ,Specifying Source Directories}),
   30143 except that @file{$cdir} is not searched, since the compilation
   30144 directory is not relevant to scripts.
   30145 
   30146 File entries can be placed in section @code{.debug_gdb_scripts} with,
   30147 for example, this GCC macro for Python scripts.
   30148 
   30149 @example
   30150 /* Note: The "MS" section flags are to remove duplicates.  */
   30151 #define DEFINE_GDB_PY_SCRIPT(script_name) \
   30152   asm("\
   30153 .pushsection \".debug_gdb_scripts\", \"MS\",@@progbits,1\n\
   30154 .byte 1 /* Python */\n\
   30155 .asciz \"" script_name "\"\n\
   30156 .popsection \n\
   30157 ");
   30158 @end example
   30159 
   30160 @noindent
   30161 For Guile scripts, replace @code{.byte 1} with @code{.byte 3}.
   30162 Then one can reference the macro in a header or source file like this:
   30163 
   30164 @example
   30165 DEFINE_GDB_PY_SCRIPT ("my-app-scripts.py")
   30166 @end example
   30167 
   30168 The script name may include directories if desired.
   30169 
   30170 Note that loading of this script file also requires accordingly configured
   30171 @code{auto-load safe-path} (@pxref{Auto-loading safe path}).
   30172 
   30173 If the macro invocation is put in a header, any application or library
   30174 using this header will get a reference to the specified script,
   30175 and with the use of @code{"MS"} attributes on the section, the linker
   30176 will remove duplicates.
   30177 
   30178 @subsubsection Script Text Entries
   30179 
   30180 Script text entries allow to put the executable script in the entry
   30181 itself instead of loading it from a file.
   30182 The first line of the entry, everything after the prefix byte and up to
   30183 the first newline (@code{0xa}) character, is the script name, and must not
   30184 contain any kind of space character, e.g., spaces or tabs.
   30185 The rest of the entry, up to the trailing null byte, is the script to
   30186 execute in the specified language.  The name needs to be unique among
   30187 all script names, as @value{GDBN} executes each script only once based
   30188 on its name.
   30189 
   30190 Here is an example from file @file{py-section-script.c} in the @value{GDBN}
   30191 testsuite.
   30192 
   30193 @example
   30194 #include "symcat.h"
   30195 #include "gdb/section-scripts.h"
   30196 asm(
   30197 ".pushsection \".debug_gdb_scripts\", \"MS\",@@progbits,1\n"
   30198 ".byte " XSTRING (SECTION_SCRIPT_ID_PYTHON_TEXT) "\n"
   30199 ".ascii \"gdb.inlined-script\\n\"\n"
   30200 ".ascii \"class test_cmd (gdb.Command):\\n\"\n"
   30201 ".ascii \"  def __init__ (self):\\n\"\n"
   30202 ".ascii \"    super (test_cmd, self).__init__ ("
   30203     "\\\"test-cmd\\\", gdb.COMMAND_OBSCURE)\\n\"\n"
   30204 ".ascii \"  def invoke (self, arg, from_tty):\\n\"\n"
   30205 ".ascii \"    print (\\\"test-cmd output, arg = %s\\\" % arg)\\n\"\n"
   30206 ".ascii \"test_cmd ()\\n\"\n"
   30207 ".byte 0\n"
   30208 ".popsection\n"
   30209 );
   30210 @end example
   30211 
   30212 Loading of inlined scripts requires a properly configured
   30213 @code{auto-load safe-path} (@pxref{Auto-loading safe path}).
   30214 The path to specify in @code{auto-load safe-path} is the path of the file
   30215 containing the @code{.debug_gdb_scripts} section.
   30216 
   30217 @node Which flavor to choose?
   30218 @subsection Which flavor to choose?
   30219 
   30220 Given the multiple ways of auto-loading extensions, it might not always
   30221 be clear which one to choose.  This section provides some guidance.
   30222 
   30223 @noindent
   30224 Benefits of the @file{-gdb.@var{ext}} way:
   30225 
   30226 @itemize @bullet
   30227 @item
   30228 Can be used with file formats that don't support multiple sections.
   30229 
   30230 @item
   30231 Ease of finding scripts for public libraries.
   30232 
   30233 Scripts specified in the @code{.debug_gdb_scripts} section are searched for
   30234 in the source search path.
   30235 For publicly installed libraries, e.g., @file{libstdc++}, there typically
   30236 isn't a source directory in which to find the script.
   30237 
   30238 @item
   30239 Doesn't require source code additions.
   30240 @end itemize
   30241 
   30242 @noindent
   30243 Benefits of the @code{.debug_gdb_scripts} way:
   30244 
   30245 @itemize @bullet
   30246 @item
   30247 Works with static linking.
   30248 
   30249 Scripts for libraries done the @file{-gdb.@var{ext}} way require an objfile to
   30250 trigger their loading.  When an application is statically linked the only
   30251 objfile available is the executable, and it is cumbersome to attach all the
   30252 scripts from all the input libraries to the executable's
   30253 @file{-gdb.@var{ext}} script.
   30254 
   30255 @item
   30256 Works with classes that are entirely inlined.
   30257 
   30258 Some classes can be entirely inlined, and thus there may not be an associated
   30259 shared library to attach a @file{-gdb.@var{ext}} script to.
   30260 
   30261 @item
   30262 Scripts needn't be copied out of the source tree.
   30263 
   30264 In some circumstances, apps can be built out of large collections of internal
   30265 libraries, and the build infrastructure necessary to install the
   30266 @file{-gdb.@var{ext}} scripts in a place where @value{GDBN} can find them is
   30267 cumbersome.  It may be easier to specify the scripts in the
   30268 @code{.debug_gdb_scripts} section as relative paths, and add a path to the
   30269 top of the source tree to the source search path.
   30270 @end itemize
   30271 
   30272 @node Multiple Extension Languages
   30273 @section Multiple Extension Languages
   30274 
   30275 The Guile and Python extension languages do not share any state,
   30276 and generally do not interfere with each other.
   30277 There are some things to be aware of, however.
   30278 
   30279 @subsection Python comes first
   30280 
   30281 Python was @value{GDBN}'s first extension language, and to avoid breaking
   30282 existing behavior Python comes first.  This is generally solved by the
   30283 ``first one wins'' principle.  @value{GDBN} maintains a list of enabled
   30284 extension languages, and when it makes a call to an extension language,
   30285 (say to pretty-print a value), it tries each in turn until an extension
   30286 language indicates it has performed the request (e.g., has returned the
   30287 pretty-printed form of a value).
   30288 This extends to errors while performing such requests: If an error happens
   30289 while, for example, trying to pretty-print an object then the error is
   30290 reported and any following extension languages are not tried.
   30291 
   30292 @node Interpreters
   30293 @chapter Command Interpreters
   30294 @cindex command interpreters
   30295 
   30296 @value{GDBN} supports multiple command interpreters, and some command
   30297 infrastructure to allow users or user interface writers to switch
   30298 between interpreters or run commands in other interpreters.
   30299 
   30300 @value{GDBN} currently supports two command interpreters, the console
   30301 interpreter (sometimes called the command-line interpreter or @sc{cli})
   30302 and the machine interface interpreter (or @sc{gdb/mi}).  This manual
   30303 describes both of these interfaces in great detail.
   30304 
   30305 By default, @value{GDBN} will start with the console interpreter.
   30306 However, the user may choose to start @value{GDBN} with another
   30307 interpreter by specifying the @option{-i} or @option{--interpreter}
   30308 startup options.  Defined interpreters include:
   30309 
   30310 @table @code
   30311 @item console
   30312 @cindex console interpreter
   30313 The traditional console or command-line interpreter.  This is the most often
   30314 used interpreter with @value{GDBN}. With no interpreter specified at runtime,
   30315 @value{GDBN} will use this interpreter.
   30316 
   30317 @item dap
   30318 @cindex DAP
   30319 @cindex Debugger Adapter Protocol
   30320 When @value{GDBN} has been built with Python support, it also supports
   30321 the Debugger Adapter Protocol.  This protocol can be used by a
   30322 debugger GUI or an IDE to communicate with @value{GDBN}.  This
   30323 protocol is documented at
   30324 @url{https://microsoft.github.io/debug-adapter-protocol/}.
   30325 @xref{Debugger Adapter Protocol}, for information about @value{GDBN}
   30326 extensions to the protocol.
   30327 
   30328 @item mi
   30329 @cindex mi interpreter
   30330 The newest @sc{gdb/mi} interface (currently @code{mi3}).  Used primarily
   30331 by programs wishing to use @value{GDBN} as a backend for a debugger GUI
   30332 or an IDE.  For more information, see @ref{GDB/MI, ,The @sc{gdb/mi}
   30333 Interface}.
   30334 
   30335 @item mi3
   30336 @cindex mi3 interpreter
   30337 The @sc{gdb/mi} interface introduced in @value{GDBN} 9.1.
   30338 
   30339 @item mi2
   30340 @cindex mi2 interpreter
   30341 The @sc{gdb/mi} interface introduced in @value{GDBN} 6.0.
   30342 
   30343 @end table
   30344 
   30345 @cindex invoke another interpreter
   30346 
   30347 @kindex interpreter-exec
   30348 You may execute commands in any interpreter from the current
   30349 interpreter using the appropriate command.  If you are running the
   30350 console interpreter, simply use the @code{interpreter-exec} command:
   30351 
   30352 @smallexample
   30353 interpreter-exec mi "-data-list-register-names"
   30354 @end smallexample
   30355 
   30356 @sc{gdb/mi} has a similar command, although it is only available in versions of
   30357 @value{GDBN} which support @sc{gdb/mi} version 2 (or greater).
   30358 
   30359 Note that @code{interpreter-exec} only changes the interpreter for the
   30360 duration of the specified command.  It does not change the interpreter
   30361 permanently.
   30362 
   30363 @cindex start a new independent interpreter
   30364 
   30365 Although you may only choose a single interpreter at startup, it is
   30366 possible to run an independent interpreter on a specified input/output
   30367 device (usually a tty).
   30368 
   30369 For example, consider a debugger GUI or IDE that wants to provide a
   30370 @value{GDBN} console view.  It may do so by embedding a terminal
   30371 emulator widget in its GUI, starting @value{GDBN} in the traditional
   30372 command-line mode with stdin/stdout/stderr redirected to that
   30373 terminal, and then creating an MI interpreter running on a specified
   30374 input/output device.  The console interpreter created by @value{GDBN}
   30375 at startup handles commands the user types in the terminal widget,
   30376 while the GUI controls and synchronizes state with @value{GDBN} using
   30377 the separate MI interpreter.
   30378 
   30379 To start a new secondary @dfn{user interface} running MI, use the
   30380 @code{new-ui} command:
   30381 
   30382 @kindex new-ui
   30383 @cindex new user interface
   30384 @smallexample
   30385 new-ui @var{interpreter} @var{tty}
   30386 @end smallexample
   30387 
   30388 The @var{interpreter} parameter specifies the interpreter to run.
   30389 This accepts the same values as the @code{interpreter-exec} command.
   30390 For example, @samp{console}, @samp{mi}, @samp{mi2}, etc.  The
   30391 @var{tty} parameter specifies the name of the bidirectional file the
   30392 interpreter uses for input/output, usually the name of a
   30393 pseudoterminal slave on Unix systems.  For example:
   30394 
   30395 @smallexample
   30396 (@value{GDBP}) new-ui mi /dev/pts/9
   30397 @end smallexample
   30398 
   30399 @noindent
   30400 runs an MI interpreter on @file{/dev/pts/9}.
   30401 
   30402 @node TUI
   30403 @chapter @value{GDBN} Text User Interface
   30404 @cindex TUI
   30405 @cindex Text User Interface
   30406 
   30407 The @value{GDBN} Text User Interface (TUI) is a terminal
   30408 interface which uses the @code{curses} library to show the source
   30409 file, the assembly output, the program registers and @value{GDBN}
   30410 commands in separate text windows.  The TUI mode is supported only
   30411 on platforms where a suitable version of the @code{curses} library
   30412 is available.
   30413 
   30414 The TUI mode is enabled by default when you invoke @value{GDBN} as
   30415 @samp{@value{GDBP} -tui}.
   30416 You can also switch in and out of TUI mode while @value{GDBN} runs by
   30417 using various TUI commands and key bindings, such as @command{tui
   30418 enable} or @kbd{C-x C-a}.  @xref{TUI Commands, ,TUI Commands}, and
   30419 @ref{TUI Keys, ,TUI Key Bindings}.
   30420 
   30421 @menu
   30422 * TUI Overview::                TUI overview
   30423 * TUI Keys::                    TUI key bindings
   30424 * TUI Single Key Mode::         TUI single key mode
   30425 * TUI Mouse Support::           TUI mouse support
   30426 * TUI Commands::                TUI-specific commands
   30427 * TUI Configuration::           TUI configuration variables
   30428 @end menu
   30429 
   30430 @node TUI Overview
   30431 @section TUI Overview
   30432 
   30433 In TUI mode, @value{GDBN} can display several text windows:
   30434 
   30435 @table @emph
   30436 @item command
   30437 This window is the @value{GDBN} command window with the @value{GDBN}
   30438 prompt and the @value{GDBN} output.  The @value{GDBN} input is still
   30439 managed using readline.
   30440 
   30441 @item source
   30442 The source window shows the source file of the program.  The current
   30443 line and active breakpoints are displayed in this window.
   30444 
   30445 @item assembly
   30446 The assembly window shows the disassembly output of the program.
   30447 
   30448 @item register
   30449 This window shows the processor registers.  Registers are highlighted
   30450 when their values change.
   30451 @end table
   30452 
   30453 The source and assembly windows show the current program position by
   30454 highlighting the current line and marking it with a @samp{>} marker.
   30455 By default, source and assembly code styling is disabled for the
   30456 highlighted text, but you can enable it with the @code{set style
   30457 tui-current-position on} command.  @xref{Output Styling}.
   30458 
   30459 Breakpoints are indicated with two markers.  The first marker
   30460 indicates the breakpoint type:
   30461 
   30462 @table @code
   30463 @item B
   30464 Breakpoint which was hit at least once.
   30465 
   30466 @item b
   30467 Breakpoint which was never hit.
   30468 
   30469 @item H
   30470 Hardware breakpoint which was hit at least once.
   30471 
   30472 @item h
   30473 Hardware breakpoint which was never hit.
   30474 @end table
   30475 
   30476 The second marker indicates whether the breakpoint is enabled or not:
   30477 
   30478 @table @code
   30479 @item +
   30480 Breakpoint is enabled.
   30481 
   30482 @item -
   30483 Breakpoint is disabled.
   30484 @end table
   30485 
   30486 The source, assembly and register windows are updated when the current
   30487 thread changes, when the frame changes, or when the program counter
   30488 changes.
   30489 
   30490 These windows are not all visible at the same time.  The command
   30491 window is always visible.  The others can be arranged in several
   30492 layouts:
   30493 
   30494 @itemize @bullet
   30495 @item
   30496 source only,
   30497 
   30498 @item
   30499 assembly only,
   30500 
   30501 @item
   30502 source and assembly,
   30503 
   30504 @item
   30505 source and registers, or
   30506 
   30507 @item
   30508 assembly and registers.
   30509 @end itemize
   30510 
   30511 These are the standard layouts, but other layouts can be defined.
   30512 
   30513 A status line above the command window shows the following information:
   30514 
   30515 @table @emph
   30516 @item target
   30517 Indicates the current @value{GDBN} target.
   30518 (@pxref{Targets, ,Specifying a Debugging Target}).
   30519 
   30520 @item process
   30521 Gives the current process or thread number.
   30522 When no process is being debugged, this field is set to @code{No process}.
   30523 
   30524 @item focus
   30525 Shows the name of the TUI window that has the focus.
   30526 
   30527 @item function
   30528 Gives the current function name for the selected frame.
   30529 The name is demangled if demangling is turned on (@pxref{Print Settings}).
   30530 When there is no symbol corresponding to the current program counter,
   30531 the string @code{??} is displayed.
   30532 
   30533 @item line
   30534 Indicates the current line number for the selected frame.
   30535 When the current line number is not known, the string @code{??} is displayed.
   30536 
   30537 @item pc
   30538 Indicates the current program counter address.
   30539 @end table
   30540 
   30541 @node TUI Keys
   30542 @section TUI Key Bindings
   30543 @cindex TUI key bindings
   30544 
   30545 The TUI installs several key bindings in the readline keymaps
   30546 @ifset SYSTEM_READLINE
   30547 (@pxref{Command Line Editing, , , rluserman, GNU Readline Library}).
   30548 @end ifset
   30549 @ifclear SYSTEM_READLINE
   30550 (@pxref{Command Line Editing}).
   30551 @end ifclear
   30552 The following key bindings are installed for both TUI mode and the
   30553 @value{GDBN} standard mode.
   30554 
   30555 @table @kbd
   30556 @kindex C-x C-a
   30557 @item C-x C-a
   30558 @kindex C-x a
   30559 @itemx C-x a
   30560 @kindex C-x A
   30561 @itemx C-x A
   30562 Enter or leave the TUI mode.  When leaving the TUI mode,
   30563 the curses window management stops and @value{GDBN} operates using
   30564 its standard mode, writing on the terminal directly.  When reentering
   30565 the TUI mode, control is given back to the curses windows.
   30566 The screen is then refreshed.
   30567 
   30568 This key binding uses the bindable Readline function
   30569 @code{tui-switch-mode}.
   30570 
   30571 @kindex C-x 1
   30572 @item C-x 1
   30573 Use a TUI layout with only one window.  The layout will
   30574 either be @samp{source} or @samp{assembly}.  When the TUI mode
   30575 is not active, it will switch to the TUI mode.
   30576 
   30577 Think of this key binding as the Emacs @kbd{C-x 1} binding.
   30578 
   30579 This key binding uses the bindable Readline function
   30580 @code{tui-delete-other-windows}.
   30581 
   30582 @kindex C-x 2
   30583 @item C-x 2
   30584 Use a TUI layout with at least two windows.  When the current
   30585 layout already has two windows, the next layout with two windows is used.
   30586 When a new layout is chosen, one window will always be common to the
   30587 previous layout and the new one.
   30588 
   30589 Think of it as the Emacs @kbd{C-x 2} binding.
   30590 
   30591 This key binding uses the bindable Readline function
   30592 @code{tui-change-windows}.
   30593 
   30594 @kindex C-x o
   30595 @item C-x o
   30596 Change the active window.  The TUI associates several key bindings
   30597 (like scrolling and arrow keys) with the active window.  This command
   30598 gives the focus to the next TUI window.
   30599 
   30600 Think of it as the Emacs @kbd{C-x o} binding.
   30601 
   30602 This key binding uses the bindable Readline function
   30603 @code{tui-other-window}.
   30604 
   30605 @kindex C-x s
   30606 @item C-x s
   30607 Switch in and out of the TUI SingleKey mode that binds single
   30608 keys to @value{GDBN} commands (@pxref{TUI Single Key Mode}).
   30609 
   30610 This key binding uses the bindable Readline function
   30611 @code{next-keymap}.
   30612 @end table
   30613 
   30614 The following key bindings only work in the TUI mode:
   30615 
   30616 @table @asis
   30617 @kindex PgUp
   30618 @item @key{PgUp}
   30619 Scroll the active window one page up.
   30620 
   30621 @kindex PgDn
   30622 @item @key{PgDn}
   30623 Scroll the active window one page down.
   30624 
   30625 @kindex Up
   30626 @item @key{Up}
   30627 Scroll the active window one line up.
   30628 
   30629 @kindex Down
   30630 @item @key{Down}
   30631 Scroll the active window one line down.
   30632 
   30633 @kindex Left
   30634 @item @key{Left}
   30635 Scroll the active window one column left.
   30636 
   30637 @kindex Right
   30638 @item @key{Right}
   30639 Scroll the active window one column right.
   30640 
   30641 @kindex C-L
   30642 @item @kbd{C-L}
   30643 Refresh the screen.
   30644 @end table
   30645 
   30646 Because the arrow keys scroll the active window in the TUI mode, they
   30647 are not available for their normal use by readline unless the command
   30648 window has the focus.  When another window is active, you must use
   30649 other readline key bindings such as @kbd{C-p}, @kbd{C-n}, @kbd{C-b}
   30650 and @kbd{C-f} to control the command window.
   30651 
   30652 @node TUI Single Key Mode
   30653 @section TUI Single Key Mode
   30654 @cindex TUI single key mode
   30655 
   30656 The TUI also provides a @dfn{SingleKey} mode, which binds several
   30657 frequently used @value{GDBN} commands to single keys.  Type @kbd{C-x s} to
   30658 switch into this mode, where the following key bindings are used:
   30659 
   30660 @table @kbd
   30661 @kindex c @r{(SingleKey TUI key)}
   30662 @item c
   30663 continue
   30664 
   30665 @kindex C @r{(SingleKey TUI key)}
   30666 @item C
   30667 reverse-continue
   30668 
   30669 @kindex d @r{(SingleKey TUI key)}
   30670 @item d
   30671 down
   30672 
   30673 @kindex f @r{(SingleKey TUI key)}
   30674 @item f
   30675 finish
   30676 
   30677 @kindex F @r{(SingleKey TUI key)}
   30678 @item F
   30679 reverse-finish
   30680 
   30681 @kindex n @r{(SingleKey TUI key)}
   30682 @item n
   30683 next
   30684 
   30685 @kindex N @r{(SingleKey TUI key)}
   30686 @item N
   30687 reverse-next
   30688 
   30689 @kindex o @r{(SingleKey TUI key)}
   30690 @item o
   30691 nexti.  The shortcut letter @samp{o} stands for ``step Over''.
   30692 
   30693 @kindex O @r{(SingleKey TUI key)}
   30694 @item O
   30695 reverse-nexti
   30696 
   30697 @kindex q @r{(SingleKey TUI key)}
   30698 @item q
   30699 exit the SingleKey mode.
   30700 
   30701 @kindex r @r{(SingleKey TUI key)}
   30702 @item r
   30703 run
   30704 
   30705 @kindex s @r{(SingleKey TUI key)}
   30706 @item s
   30707 step
   30708 
   30709 @kindex S @r{(SingleKey TUI key)}
   30710 @item S
   30711 reverse-step
   30712 
   30713 @kindex i @r{(SingleKey TUI key)}
   30714 @item i
   30715 stepi.  The shortcut letter @samp{i} stands for ``step Into''.
   30716 
   30717 @kindex I @r{(SingleKey TUI key)}
   30718 @item I
   30719 reverse-stepi
   30720 
   30721 @kindex u @r{(SingleKey TUI key)}
   30722 @item u
   30723 up
   30724 
   30725 @kindex v @r{(SingleKey TUI key)}
   30726 @item v
   30727 info locals
   30728 
   30729 @kindex w @r{(SingleKey TUI key)}
   30730 @item w
   30731 where
   30732 @end table
   30733 
   30734 Other keys temporarily switch to the @value{GDBN} command prompt.
   30735 The key that was pressed is inserted in the editing buffer so that
   30736 it is possible to type most @value{GDBN} commands without interaction
   30737 with the TUI SingleKey mode.  Once the command is entered the TUI
   30738 SingleKey mode is restored.  The only way to permanently leave
   30739 this mode is by typing @kbd{q} or @kbd{C-x s}.
   30740 
   30741 @cindex SingleKey keymap name
   30742 If @value{GDBN} was built with Readline 8.0 or later, the TUI
   30743 SingleKey keymap will be named @samp{SingleKey}.  This can be used in
   30744 @file{.inputrc} to add additional bindings to this keymap.
   30745 
   30746 @node TUI Mouse Support
   30747 @section TUI Mouse Support
   30748 @cindex TUI mouse support
   30749 
   30750 If the curses library supports the mouse, the TUI supports mouse
   30751 actions.
   30752 
   30753 The mouse wheel scrolls the appropriate window under the mouse cursor.
   30754 
   30755 The TUI itself does not directly support copying/pasting with the
   30756 mouse.  However, on Unix terminals, you can typically press and hold
   30757 the @key{SHIFT} key on your keyboard to temporarily bypass
   30758 @value{GDBN}'s TUI and access the terminal's native mouse copy/paste
   30759 functionality (commonly, click-drag-release or double-click to select
   30760 text, middle-click to paste).  This copy/paste works with the
   30761 terminal's selection buffer, as opposed to the TUI's buffer.  Alternatively, to
   30762 disable mouse support in the TUI entirely and give the terminal control over
   30763 mouse clicks, turn off the @code{tui mouse-events} setting
   30764 (@pxref{tui-mouse-events,,set tui mouse-events}).
   30765 
   30766 Python extensions can react to mouse clicks
   30767 (@pxref{python-window-click,,Window.click}).
   30768 
   30769 @node TUI Commands
   30770 @section TUI-specific Commands
   30771 @cindex TUI commands
   30772 
   30773 The TUI has specific commands to control the text windows.
   30774 These commands are always available, even when @value{GDBN} is not in
   30775 the TUI mode.  When @value{GDBN} is in the standard mode, most
   30776 of these commands will automatically switch to the TUI mode.
   30777 
   30778 Note that if @value{GDBN}'s @code{stdout} is not connected to a
   30779 terminal, or @value{GDBN} has been started with the machine interface
   30780 interpreter (@pxref{GDB/MI, ,The @sc{gdb/mi} Interface}), most of
   30781 these commands will fail with an error, because it would not be
   30782 possible or desirable to enable curses window management.
   30783 
   30784 @table @code
   30785 @item tui enable
   30786 @kindex tui enable
   30787 Activate TUI mode.  The last active TUI window layout will be used if
   30788 TUI mode has previously been used in the current debugging session,
   30789 otherwise a default layout is used.
   30790 
   30791 @item tui disable
   30792 @kindex tui disable
   30793 Disable TUI mode, returning to the console interpreter.
   30794 
   30795 @anchor{info_win_command}
   30796 @item info win
   30797 @kindex info win
   30798 List the names and sizes of all currently displayed windows.
   30799 
   30800 @item tui new-layout @var{name} @var{window} @var{weight} @r{[}@var{window} @var{weight}@dots{}@r{]}
   30801 @kindex tui new-layout
   30802 Create a new TUI layout.  The new layout will be named @var{name}, and
   30803 can be accessed using the @code{layout} command (see below).
   30804 
   30805 Each @var{window} parameter is either the name of a window to display,
   30806 or a window description.  The windows will be displayed from top to
   30807 bottom in the order listed.
   30808 
   30809 The names of the windows are the same as the ones given to the
   30810 @code{focus} command (see below); additionally, the @code{status}
   30811 window can be specified.  Note that, because it is of fixed height,
   30812 the weight assigned to the status window is of no importance.  It is
   30813 conventional to use @samp{0} here.
   30814 
   30815 A window description looks a bit like an invocation of @code{tui
   30816 new-layout}, and is of the form
   30817 @{@r{[}@code{-horizontal}@r{]}@var{window} @var{weight} @r{[}@var{window} @var{weight}@dots{}@r{]}@}.
   30818 
   30819 This specifies a sub-layout.  If @code{-horizontal} is given, the
   30820 windows in this description will be arranged side-by-side, rather than
   30821 top-to-bottom.
   30822 
   30823 Each @var{weight} is an integer.  It is the weight of this window
   30824 relative to all the other windows in the layout.  These numbers are
   30825 used to calculate how much of the screen is given to each window.
   30826 
   30827 For example:
   30828 
   30829 @example
   30830 (gdb) tui new-layout example src 1 regs 1 status 0 cmd 1
   30831 @end example
   30832 
   30833 Here, the new layout is called @samp{example}.  It shows the source
   30834 and register windows, followed by the status window, and then finally
   30835 the command window.  The non-status windows all have the same weight,
   30836 so the terminal will be split into three roughly equal sections.
   30837 
   30838 Here is a more complex example, showing a horizontal layout:
   30839 
   30840 @example
   30841 (gdb) tui new-layout example @{-horizontal src 1 asm 1@} 2 status 0 cmd 1
   30842 @end example
   30843 
   30844 This will result in side-by-side source and assembly windows; with the
   30845 status and command window being beneath these, filling the entire
   30846 width of the terminal.  Because they have weight 2, the source and
   30847 assembly windows will be twice the height of the command window.
   30848 
   30849 @kindex tui layout
   30850 @kindex layout
   30851 @item tui layout @var{name}
   30852 @itemx layout @var{name}
   30853 Changes which TUI windows are displayed.  The @var{name} parameter
   30854 controls which layout is shown.  It can be either one of the built-in
   30855 layout names, or the name of a layout defined by the user using
   30856 @code{tui new-layout}.
   30857 
   30858 The built-in layouts are as follows:
   30859 
   30860 @table @code
   30861 @item next
   30862 Display the next layout.
   30863 
   30864 @item prev
   30865 Display the previous layout.
   30866 
   30867 @item src
   30868 Display the source and command windows.
   30869 
   30870 @item asm
   30871 Display the assembly and command windows.
   30872 
   30873 @item split
   30874 Display the source, assembly, and command windows.
   30875 
   30876 @item regs
   30877 When in @code{src} layout display the register, source, and command
   30878 windows.  When in @code{asm} or @code{split} layout display the
   30879 register, assembler, and command windows.
   30880 @end table
   30881 
   30882 @kindex focus
   30883 @item tui focus @var{name}
   30884 @itemx focus @var{name}
   30885 Changes which TUI window is currently active for scrolling.  The
   30886 @var{name} parameter can be any of the following:
   30887 
   30888 @table @code
   30889 @item next
   30890 Make the next window active for scrolling.
   30891 
   30892 @item prev
   30893 Make the previous window active for scrolling.
   30894 
   30895 @item src
   30896 Make the source window active for scrolling.
   30897 
   30898 @item asm
   30899 Make the assembly window active for scrolling.
   30900 
   30901 @item regs
   30902 Make the register window active for scrolling.
   30903 
   30904 @item cmd
   30905 Make the command window active for scrolling.
   30906 @end table
   30907 
   30908 @kindex tui refresh
   30909 @kindex refresh
   30910 @item tui refresh
   30911 @itemx refresh
   30912 Refresh the screen.  This is similar to typing @kbd{C-L}.
   30913 
   30914 @item tui reg @var{group}
   30915 @kindex tui reg
   30916 Changes the register group displayed in the tui register window to
   30917 @var{group}.  If the register window is not currently displayed this
   30918 command will cause the register window to be displayed.  The list of
   30919 register groups, as well as their order is target specific. The
   30920 following groups are available on most targets:
   30921 @table @code
   30922 @item next
   30923 Repeatedly selecting this group will cause the display to cycle
   30924 through all of the available register groups.
   30925 
   30926 @item prev
   30927 Repeatedly selecting this group will cause the display to cycle
   30928 through all of the available register groups in the reverse order to
   30929 @var{next}.
   30930 
   30931 @item general
   30932 Display the general registers.
   30933 @item float
   30934 Display the floating point registers.
   30935 @item system
   30936 Display the system registers.
   30937 @item vector
   30938 Display the vector registers.
   30939 @item all
   30940 Display all registers.
   30941 @end table
   30942 
   30943 @item update
   30944 @kindex update
   30945 Update the source window and the current execution point.
   30946 
   30947 @kindex tui window height
   30948 @kindex winheight
   30949 @item tui window height @var{name} +@var{count}
   30950 @itemx tui window height @var{name} -@var{count}
   30951 @itemx winheight @var{name} +@var{count}
   30952 @itemx winheight @var{name} -@var{count}
   30953 Change the height of the window @var{name} by @var{count} lines.
   30954 Positive counts increase the height, while negative counts decrease
   30955 it.  The @var{name} parameter can be the name of any currently visible
   30956 window.  The names of the currently visible windows can be discovered
   30957 using @kbd{info win} (@pxref{info_win_command,,info win}).
   30958 
   30959 The set of currently visible windows must always fill the terminal,
   30960 and so, it is only possible to resize on window if there are other
   30961 visible windows that can either give or receive the extra terminal
   30962 space.
   30963 
   30964 @kindex tui window width
   30965 @kindex winwidth
   30966 @item tui window width @var{name} +@var{count}
   30967 @itemx tui window width @var{name} -@var{count}
   30968 @itemx winwidth @var{name} +@var{count}
   30969 @itemx winwidth @var{name} -@var{count}
   30970 Change the width of the window @var{name} by @var{count} columns.
   30971 Positive counts increase the width, while negative counts decrease it.
   30972 The @var{name} parameter can be the name of any currently visible
   30973 window.  The names of the currently visible windows can be discovered
   30974 using @code{info win} (@pxref{info_win_command,,info win}).
   30975 
   30976 The set of currently visible windows must always fill the terminal,
   30977 and so, it is only possible to resize on window if there are other
   30978 visible windows that can either give or receive the extra terminal
   30979 space.
   30980 @end table
   30981 
   30982 @node TUI Configuration
   30983 @section TUI Configuration Variables
   30984 @cindex TUI configuration variables
   30985 
   30986 Several configuration variables control the appearance of TUI windows.
   30987 
   30988 @table @code
   30989 @item set tui border-kind @var{kind}
   30990 @kindex set tui border-kind
   30991 Select the border appearance for the source, assembly and register windows.
   30992 The possible values are the following:
   30993 @table @code
   30994 @item space
   30995 Use a space character to draw the border.
   30996 
   30997 @item ascii
   30998 Use @sc{ascii} characters @samp{+}, @samp{-} and @samp{|} to draw the border.
   30999 
   31000 @item acs
   31001 Use the Alternate Character Set to draw the border.  The border is
   31002 drawn using character line graphics if the terminal supports them.
   31003 @end table
   31004 
   31005 @item set tui border-mode @var{mode}
   31006 @kindex set tui border-mode
   31007 @itemx set tui active-border-mode @var{mode}
   31008 @kindex set tui active-border-mode
   31009 Select the display attributes for the borders of the inactive windows
   31010 or the active window.  The @var{mode} can be one of the following:
   31011 @table @code
   31012 @item normal
   31013 Use normal attributes to display the border.
   31014 
   31015 @item standout
   31016 Use standout mode.
   31017 
   31018 @item reverse
   31019 Use reverse video mode.
   31020 
   31021 @item half
   31022 Use half bright mode.
   31023 
   31024 @item half-standout
   31025 Use half bright and standout mode.
   31026 
   31027 @item bold
   31028 Use extra bright or bold mode.
   31029 
   31030 @item bold-standout
   31031 Use extra bright or bold and standout mode.
   31032 @end table
   31033 
   31034 @item set tui tab-width @var{nchars}
   31035 @kindex set tui tab-width
   31036 @kindex tabset
   31037 Set the width of tab stops to be @var{nchars} characters.  This
   31038 setting affects the display of TAB characters in the source and
   31039 assembly windows.
   31040 
   31041 @item set tui compact-source @r{[}on@r{|}off@r{]}
   31042 @kindex set tui compact-source
   31043 Set whether the TUI source window is displayed in ``compact'' form.
   31044 The default display uses more space for line numbers; the compact
   31045 display uses only as much space as is needed for the line numbers in
   31046 the current file.
   31047 
   31048 @anchor{tui-mouse-events}
   31049 @item set tui mouse-events @r{[}on@r{|}off@r{]}
   31050 @kindex set tui mouse-events
   31051 When on (default), mouse clicks control the TUI (@pxref{TUI Mouse Support}).
   31052 When off, mouse clicks are handled by the terminal, enabling terminal-native
   31053 text selection.
   31054 
   31055 @kindex set debug tui
   31056 @item set debug tui @r{[}on|off@r{]}
   31057 Turn on or off display of @value{GDBN} internal debug messages relating
   31058 to the TUI.
   31059 
   31060 @kindex show debug tui
   31061 @item show debug tui
   31062 Show the current status of displaying @value{GDBN} internal debug
   31063 messages relating to the TUI.
   31064 
   31065 @end table
   31066 
   31067 Note that the colors of the TUI borders can be controlled using the
   31068 appropriate @code{set style} commands.  @xref{Output Styling}.
   31069 
   31070 @node Emacs
   31071 @chapter Using @value{GDBN} under @sc{gnu} Emacs
   31072 
   31073 @cindex Emacs
   31074 @cindex @sc{gnu} Emacs
   31075 A special interface allows you to use @sc{gnu} Emacs to view (and
   31076 edit) the source files for the program you are debugging with
   31077 @value{GDBN}.
   31078 
   31079 To use this interface, use the command @kbd{M-x gdb} in Emacs.  Give the
   31080 executable file you want to debug as an argument.  This command starts
   31081 @value{GDBN} as a subprocess of Emacs, with input and output through a newly
   31082 created Emacs buffer.
   31083 @c (Do not use the @code{-tui} option to run @value{GDBN} from Emacs.)
   31084 
   31085 Running @value{GDBN} under Emacs can be just like running @value{GDBN} normally except for two
   31086 things:
   31087 
   31088 @itemize @bullet
   31089 @item
   31090 All ``terminal'' input and output goes through an Emacs buffer, called
   31091 the GUD buffer.
   31092 
   31093 This applies both to @value{GDBN} commands and their output, and to the input
   31094 and output done by the program you are debugging.
   31095 
   31096 This is useful because it means that you can copy the text of previous
   31097 commands and input them again; you can even use parts of the output
   31098 in this way.
   31099 
   31100 All the facilities of Emacs' Shell mode are available for interacting
   31101 with your program.  In particular, you can send signals the usual
   31102 way---for example, @kbd{C-c C-c} for an interrupt, @kbd{C-c C-z} for a
   31103 stop.
   31104 
   31105 @item
   31106 @value{GDBN} displays source code through Emacs.
   31107 
   31108 Each time @value{GDBN} displays a stack frame, Emacs automatically finds the
   31109 source file for that frame and puts an arrow (@samp{=>}) at the
   31110 left margin of the current line.  Emacs uses a separate buffer for
   31111 source display, and splits the screen to show both your @value{GDBN} session
   31112 and the source.
   31113 
   31114 Explicit @value{GDBN} @code{list} or search commands still produce output as
   31115 usual, but you probably have no reason to use them from Emacs.
   31116 @end itemize
   31117 
   31118 We call this @dfn{text command mode}.  Emacs 22.1, and later, also uses
   31119 a graphical mode, enabled by default, which provides further buffers
   31120 that can control the execution and describe the state of your program.
   31121 @xref{GDB Graphical Interface,,, Emacs, The @sc{gnu} Emacs Manual}.
   31122 
   31123 If you specify an absolute file name when prompted for the @kbd{M-x
   31124 gdb} argument, then Emacs sets your current working directory to where
   31125 your program resides.  If you only specify the file name, then Emacs
   31126 sets your current working directory to the directory associated
   31127 with the previous buffer.  In this case, @value{GDBN} may find your
   31128 program by searching your environment's @env{PATH} variable, but on
   31129 some operating systems it might not find the source.  So, although the
   31130 @value{GDBN} input and output session proceeds normally, the auxiliary
   31131 buffer does not display the current source and line of execution.
   31132 
   31133 The initial working directory of @value{GDBN} is printed on the top
   31134 line of the GUD buffer and this serves as a default for the commands
   31135 that specify files for @value{GDBN} to operate on.  @xref{Files,
   31136 ,Commands to Specify Files}.
   31137 
   31138 By default, @kbd{M-x gdb} calls the program called @file{gdb}.  If you
   31139 need to call @value{GDBN} by a different name (for example, if you
   31140 keep several configurations around, with different names) you can
   31141 customize the Emacs variable @code{gud-gdb-command-name} to run the
   31142 one you want.
   31143 
   31144 In the GUD buffer, you can use these special Emacs commands in
   31145 addition to the standard Shell mode commands:
   31146 
   31147 @table @kbd
   31148 @item C-h m
   31149 Describe the features of Emacs' GUD Mode.
   31150 
   31151 @item C-c C-s
   31152 Execute to another source line, like the @value{GDBN} @code{step} command; also
   31153 update the display window to show the current file and location.
   31154 
   31155 @item C-c C-n
   31156 Execute to next source line in this function, skipping all function
   31157 calls, like the @value{GDBN} @code{next} command.  Then update the display window
   31158 to show the current file and location.
   31159 
   31160 @item C-c C-i
   31161 Execute one instruction, like the @value{GDBN} @code{stepi} command; update
   31162 display window accordingly.
   31163 
   31164 @item C-c C-f
   31165 Execute until exit from the selected stack frame, like the @value{GDBN}
   31166 @code{finish} command.
   31167 
   31168 @item C-c C-r
   31169 Continue execution of your program, like the @value{GDBN} @code{continue}
   31170 command.
   31171 
   31172 @item C-c <
   31173 Go up the number of frames indicated by the numeric argument
   31174 (@pxref{Arguments, , Numeric Arguments, Emacs, The @sc{gnu} Emacs Manual}),
   31175 like the @value{GDBN} @code{up} command.
   31176 
   31177 @item C-c >
   31178 Go down the number of frames indicated by the numeric argument, like the
   31179 @value{GDBN} @code{down} command.
   31180 @end table
   31181 
   31182 In any source file, the Emacs command @kbd{C-x @key{SPC}} (@code{gud-break})
   31183 tells @value{GDBN} to set a breakpoint on the source line point is on.
   31184 
   31185 In text command mode, if you type @kbd{M-x speedbar}, Emacs displays a
   31186 separate frame which shows a backtrace when the GUD buffer is current.
   31187 Move point to any frame in the stack and type @key{RET} to make it
   31188 become the current frame and display the associated source in the
   31189 source buffer.  Alternatively, click @kbd{Mouse-2} to make the
   31190 selected frame become the current one.  In graphical mode, the
   31191 speedbar displays watch expressions.
   31192 
   31193 If you accidentally delete the source-display buffer, an easy way to get
   31194 it back is to type the command @code{f} in the @value{GDBN} buffer, to
   31195 request a frame display; when you run under Emacs, this recreates
   31196 the source buffer if necessary to show you the context of the current
   31197 frame.
   31198 
   31199 The source files displayed in Emacs are in ordinary Emacs buffers
   31200 which are visiting the source files in the usual way.  You can edit
   31201 the files with these buffers if you wish; but keep in mind that @value{GDBN}
   31202 communicates with Emacs in terms of line numbers.  If you add or
   31203 delete lines from the text, the line numbers that @value{GDBN} knows cease
   31204 to correspond properly with the code.
   31205 
   31206 A more detailed description of Emacs' interaction with @value{GDBN} is
   31207 given in the Emacs manual (@pxref{Debuggers,,, Emacs, The @sc{gnu}
   31208 Emacs Manual}).
   31209 
   31210 @node GDB/MI
   31211 @chapter The @sc{gdb/mi} Interface
   31212 
   31213 @unnumberedsec Function and Purpose
   31214 
   31215 @cindex @sc{gdb/mi}, its purpose
   31216 @sc{gdb/mi} is a line based machine oriented text interface to
   31217 @value{GDBN} and is activated by specifying using the
   31218 @option{--interpreter} command line option (@pxref{Mode Options}).  It
   31219 is specifically intended to support the development of systems which
   31220 use the debugger as just one small component of a larger system.
   31221 
   31222 This chapter is a specification of the @sc{gdb/mi} interface.  It is written
   31223 in the form of a reference manual.
   31224 
   31225 Note that @sc{gdb/mi} is still under construction, so some of the
   31226 features described below are incomplete and subject to change
   31227 (@pxref{GDB/MI Development and Front Ends, , @sc{gdb/mi} Development and Front Ends}).  
   31228 
   31229 @unnumberedsec Notation and Terminology
   31230 
   31231 @cindex notational conventions, for @sc{gdb/mi}
   31232 This chapter uses the following notation:
   31233 
   31234 @itemize @bullet
   31235 @item
   31236 @code{|} separates two alternatives.
   31237 
   31238 @item
   31239 @code{[ @var{something} ]} indicates that @var{something} is optional:
   31240 it may or may not be given.
   31241 
   31242 @item
   31243 @code{( @var{group} )*} means that @var{group} inside the parentheses
   31244 may repeat zero or more times.
   31245 
   31246 @item
   31247 @code{( @var{group} )+} means that @var{group} inside the parentheses
   31248 may repeat one or more times.
   31249 
   31250 @item
   31251 @code{( @var{group} )} means that @var{group} inside the parentheses
   31252 occurs exactly once.
   31253 
   31254 @item
   31255 @code{"@var{string}"} means a literal @var{string}.
   31256 @end itemize
   31257 
   31258 @ignore
   31259 @heading Dependencies
   31260 @end ignore
   31261 
   31262 @menu
   31263 * GDB/MI General Design::
   31264 * GDB/MI Command Syntax::
   31265 * GDB/MI Compatibility with CLI::
   31266 * GDB/MI Development and Front Ends::
   31267 * GDB/MI Output Records::
   31268 * GDB/MI Simple Examples::
   31269 * GDB/MI Command Description Format::
   31270 * GDB/MI Breakpoint Commands::
   31271 * GDB/MI Catchpoint Commands::
   31272 * GDB/MI Program Context::
   31273 * GDB/MI Thread Commands::
   31274 * GDB/MI Ada Tasking Commands::
   31275 * GDB/MI Program Execution::
   31276 * GDB/MI Stack Manipulation::
   31277 * GDB/MI Variable Objects::
   31278 * GDB/MI Data Manipulation::
   31279 * GDB/MI Tracepoint Commands::
   31280 * GDB/MI Symbol Query::
   31281 * GDB/MI File Commands::
   31282 @ignore
   31283 * GDB/MI Kod Commands::
   31284 * GDB/MI Memory Overlay Commands::
   31285 * GDB/MI Signal Handling Commands::
   31286 @end ignore
   31287 * GDB/MI Target Manipulation::
   31288 * GDB/MI File Transfer Commands::
   31289 * GDB/MI Ada Exceptions Commands::
   31290 * GDB/MI Support Commands::
   31291 * GDB/MI Miscellaneous Commands::
   31292 @end menu
   31293 
   31294 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   31295 @node GDB/MI General Design
   31296 @section @sc{gdb/mi} General Design
   31297 @cindex GDB/MI General Design
   31298 
   31299 Interaction of a @sc{gdb/mi} frontend with @value{GDBN} involves three
   31300 parts---commands sent to @value{GDBN}, responses to those commands
   31301 and notifications.  Each command results in exactly one response,
   31302 indicating either successful completion of the command, or an error.
   31303 For the commands that do not resume the target, the response contains the
   31304 requested information.  For the commands that resume the target, the
   31305 response only indicates whether the target was successfully resumed.
   31306 Notifications is the mechanism for reporting changes in the state of the
   31307 target, or in @value{GDBN} state, that cannot conveniently be associated with
   31308 a command and reported as part of that command response.
   31309 
   31310 The important examples of notifications are:
   31311 @itemize @bullet
   31312 
   31313 @item 
   31314 Exec notifications.  These are used to report changes in
   31315 target state---when a target is resumed, or stopped.  It would not
   31316 be feasible to include this information in response of resuming
   31317 commands, because one resume commands can result in multiple events in
   31318 different threads.  Also, quite some time may pass before any event
   31319 happens in the target, while a frontend needs to know whether the resuming
   31320 command itself was successfully executed.
   31321 
   31322 @item 
   31323 Console output, and status notifications.  Console output
   31324 notifications are used to report output of CLI commands, as well as
   31325 diagnostics for other commands.  Status notifications are used to
   31326 report the progress of a long-running operation.  Naturally, including
   31327 this information in command response would mean no output is produced
   31328 until the command is finished, which is undesirable.
   31329 
   31330 @item
   31331 General notifications.  Commands may have various side effects on
   31332 the @value{GDBN} or target state beyond their official purpose.  For example,
   31333 a command may change the selected thread.  Although such changes can
   31334 be included in command response, using notification allows for more
   31335 orthogonal frontend design.
   31336 
   31337 @end itemize
   31338 
   31339 There's no guarantee that whenever an MI command reports an error,
   31340 @value{GDBN} or the target are in any specific state, and especially,
   31341 the state is not reverted to the state before the MI command was
   31342 processed.  Therefore, whenever an MI command results in an error, 
   31343 we recommend that the frontend refreshes all the information shown in 
   31344 the user interface.
   31345 
   31346 
   31347 @menu
   31348 * Context management::
   31349 * Asynchronous and non-stop modes::
   31350 * Thread groups::
   31351 @end menu
   31352 
   31353 @node Context management
   31354 @subsection Context management
   31355 
   31356 @subsubsection Threads and Frames
   31357 
   31358 In most cases when @value{GDBN} accesses the target, this access is
   31359 done in context of a specific thread and frame (@pxref{Frames}).
   31360 Often, even when accessing global data, the target requires that a thread
   31361 be specified.  The CLI interface maintains the selected thread and frame,
   31362 and supplies them to target on each command.  This is convenient,
   31363 because a command line user would not want to specify that information
   31364 explicitly on each command, and because user interacts with
   31365 @value{GDBN} via a single terminal, so no confusion is possible as 
   31366 to what thread and frame are the current ones.
   31367 
   31368 In the case of MI, the concept of selected thread and frame is less
   31369 useful.  First, a frontend can easily remember this information
   31370 itself.  Second, a graphical frontend can have more than one window,
   31371 each one used for debugging a different thread, and the frontend might
   31372 want to access additional threads for internal purposes.  This
   31373 increases the risk that by relying on implicitly selected thread, the
   31374 frontend may be operating on a wrong one.  Therefore, each MI command
   31375 should explicitly specify which thread and frame to operate on.  To
   31376 make it possible, each MI command accepts the @samp{--thread} and
   31377 @samp{--frame} options, the value to each is @value{GDBN} global
   31378 identifier for thread and frame to operate on.
   31379 
   31380 Usually, each top-level window in a frontend allows the user to select
   31381 a thread and a frame, and remembers the user selection for further
   31382 operations.  However, in some cases @value{GDBN} may suggest that the
   31383 current thread or frame be changed.  For example, when stopping on a
   31384 breakpoint it is reasonable to switch to the thread where breakpoint is
   31385 hit.  For another example, if the user issues the CLI @samp{thread} or
   31386 @samp{frame} commands via the frontend, it is desirable to change the
   31387 frontend's selection to the one specified by user.  @value{GDBN}
   31388 communicates the suggestion to change current thread and frame using the
   31389 @samp{=thread-selected} notification.
   31390 
   31391 Note that historically, MI shares the selected thread with CLI, so 
   31392 frontends used the @code{-thread-select} to execute commands in the
   31393 right context.  However, getting this to work right is cumbersome.  The
   31394 simplest way is for frontend to emit @code{-thread-select} command
   31395 before every command.  This doubles the number of commands that need
   31396 to be sent.  The alternative approach is to suppress @code{-thread-select}
   31397 if the selected thread in @value{GDBN} is supposed to be identical to the
   31398 thread the frontend wants to operate on.  However, getting this
   31399 optimization right can be tricky.  In particular, if the frontend
   31400 sends several commands to @value{GDBN}, and one of the commands changes the
   31401 selected thread, then the behavior of subsequent commands will
   31402 change.  So, a frontend should either wait for response from such
   31403 problematic commands, or explicitly add @code{-thread-select} for
   31404 all subsequent commands.  No frontend is known to do this exactly
   31405 right, so it is suggested to just always pass the @samp{--thread} and
   31406 @samp{--frame} options.
   31407 
   31408 @subsubsection Language
   31409 
   31410 The execution of several commands depends on which language is selected.
   31411 By default, the current language (@pxref{show language}) is used.
   31412 But for commands known to be language-sensitive, it is recommended
   31413 to use the @samp{--language} option.  This option takes one argument,
   31414 which is the name of the language to use while executing the command.
   31415 For instance:
   31416 
   31417 @smallexample
   31418 -data-evaluate-expression --language c "sizeof (void*)"
   31419 ^done,value="4"
   31420 (gdb) 
   31421 @end smallexample
   31422 
   31423 The valid language names are the same names accepted by the
   31424 @samp{set language} command (@pxref{Manually}), excluding @samp{auto},
   31425 @samp{local} or @samp{unknown}.
   31426 
   31427 @node Asynchronous and non-stop modes
   31428 @subsection Asynchronous command execution and non-stop mode
   31429 
   31430 On some targets, @value{GDBN} is capable of processing MI commands
   31431 even while the target is running.  This is called @dfn{asynchronous
   31432 command execution} (@pxref{Background Execution}).  The frontend may
   31433 specify a preference for asynchronous execution using the
   31434 @code{-gdb-set mi-async 1} command, which should be emitted before
   31435 either running the executable or attaching to the target.  After the
   31436 frontend has started the executable or attached to the target, it can
   31437 find if asynchronous execution is enabled using the
   31438 @code{-list-target-features} command.
   31439 
   31440 @table @code
   31441 @cindex foreground execution
   31442 @cindex background execution
   31443 @cindex asynchronous execution
   31444 @cindex execution, foreground, background and asynchronous
   31445 @kindex set mi-async
   31446 @item -gdb-set mi-async @r{[}on@r{|}off@r{]}
   31447 Set whether MI is in asynchronous mode.
   31448 
   31449 When @code{off}, which is the default, MI execution commands (e.g.,
   31450 @code{-exec-continue}) are foreground commands, and @value{GDBN} waits
   31451 for the program to stop before processing further commands.
   31452 
   31453 When @code{on}, MI execution commands are background execution
   31454 commands (e.g., @code{-exec-continue} becomes the equivalent of the
   31455 @code{c&} CLI command), and so @value{GDBN} is capable of processing
   31456 MI commands even while the target is running.
   31457 
   31458 @kindex show mi-async
   31459 @item -gdb-show mi-async
   31460 Show whether MI asynchronous mode is enabled.
   31461 @end table
   31462 
   31463 Note: In @value{GDBN} version 7.7 and earlier, this option was called
   31464 @code{target-async} instead of @code{mi-async}, and it had the effect
   31465 of both putting MI in asynchronous mode and making CLI background
   31466 commands possible.  CLI background commands are now always possible
   31467 ``out of the box'' if the target supports them.  The old spelling is
   31468 kept as a deprecated alias for backwards compatibility.
   31469 
   31470 Even if @value{GDBN} can accept a command while target is running,
   31471 many commands that access the target do not work when the target is
   31472 running.  Therefore, asynchronous command execution is most useful
   31473 when combined with non-stop mode (@pxref{Non-Stop Mode}).  Then,
   31474 it is possible to examine the state of one thread, while other threads
   31475 are running.
   31476 
   31477 When a given thread is running, MI commands that try to access the
   31478 target in the context of that thread may not work, or may work only on
   31479 some targets.  In particular, commands that try to operate on thread's
   31480 stack will not work, on any target.  Commands that read memory, or
   31481 modify breakpoints, may work or not work, depending on the target.  Note
   31482 that even commands that operate on global state, such as @code{print},
   31483 @code{set}, and breakpoint commands, still access the target in the
   31484 context of a specific thread,  so frontend should try to find a
   31485 stopped thread and perform the operation on that thread (using the
   31486 @samp{--thread} option).
   31487 
   31488 Which commands will work in the context of a running thread is
   31489 highly target dependent.  However, the two commands
   31490 @code{-exec-interrupt}, to stop a thread, and @code{-thread-info},
   31491 to find the state of a thread, will always work.
   31492 
   31493 @node Thread groups
   31494 @subsection Thread groups
   31495 @value{GDBN} may be used to debug several processes at the same time.
   31496 On some platforms, @value{GDBN} may support debugging of several
   31497 hardware systems, each one having several cores with several different
   31498 processes running on each core.  This section describes the MI
   31499 mechanism to support such debugging scenarios.
   31500 
   31501 The key observation is that regardless of the structure of the 
   31502 target, MI can have a global list of threads, because most commands that 
   31503 accept the @samp{--thread} option do not need to know what process that
   31504 thread belongs to.  Therefore, it is not necessary to introduce
   31505 neither additional @samp{--process} option, nor an notion of the
   31506 current process in the MI interface.  The only strictly new feature
   31507 that is required is the ability to find how the threads are grouped
   31508 into processes.
   31509 
   31510 To allow the user to discover such grouping, and to support arbitrary
   31511 hierarchy of machines/cores/processes, MI introduces the concept of a
   31512 @dfn{thread group}.  Thread group is a collection of threads and other
   31513 thread groups.  A thread group always has a string identifier, a type,
   31514 and may have additional attributes specific to the type.  A new
   31515 command, @code{-list-thread-groups}, returns the list of top-level
   31516 thread groups, which correspond to processes that @value{GDBN} is
   31517 debugging at the moment.  By passing an identifier of a thread group
   31518 to the @code{-list-thread-groups} command, it is possible to obtain
   31519 the members of specific thread group.
   31520 
   31521 To allow the user to easily discover processes, and other objects, he
   31522 wishes to debug, a concept of @dfn{available thread group} is
   31523 introduced.  Available thread group is an thread group that
   31524 @value{GDBN} is not debugging, but that can be attached to, using the
   31525 @code{-target-attach} command.  The list of available top-level thread
   31526 groups can be obtained using @samp{-list-thread-groups --available}.
   31527 In general, the content of a thread group may be only retrieved only
   31528 after attaching to that thread group.
   31529 
   31530 Thread groups are related to inferiors (@pxref{Inferiors Connections and
   31531 Programs}).  Each inferior corresponds to a thread group of a special
   31532 type @samp{process}, and some additional operations are permitted on
   31533 such thread groups.
   31534 
   31535 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   31536 @node GDB/MI Command Syntax
   31537 @section @sc{gdb/mi} Command Syntax
   31538 
   31539 @menu
   31540 * GDB/MI Input Syntax::
   31541 * GDB/MI Output Syntax::
   31542 @end menu
   31543 
   31544 @node GDB/MI Input Syntax
   31545 @subsection @sc{gdb/mi} Input Syntax
   31546 
   31547 @cindex input syntax for @sc{gdb/mi}
   31548 @cindex @sc{gdb/mi}, input syntax
   31549 @table @code
   31550 @item @var{command} @expansion{}
   31551 @code{@var{cli-command} | @var{mi-command}}
   31552 
   31553 @item @var{cli-command} @expansion{}
   31554 @code{[ @var{token} ] @var{cli-command} @var{nl}}, where
   31555 @var{cli-command} is any existing @value{GDBN} CLI command.
   31556 
   31557 @item @var{mi-command} @expansion{}
   31558 @code{[ @var{token} ] "-" @var{operation} ( " " @var{option} )*
   31559 @code{[} " --" @code{]} ( " " @var{parameter} )* @var{nl}}
   31560 
   31561 @item @var{token} @expansion{}
   31562 "any sequence of digits"
   31563 
   31564 @item @var{option} @expansion{}
   31565 @code{"-" @var{parameter} [ " " @var{parameter} ]}
   31566 
   31567 @item @var{parameter} @expansion{}
   31568 @code{@var{non-blank-sequence} | @var{c-string}}
   31569 
   31570 @item @var{operation} @expansion{}
   31571 @emph{any of the operations described in this chapter}
   31572 
   31573 @item @var{non-blank-sequence} @expansion{}
   31574 @emph{anything, provided it doesn't contain special characters such as
   31575 "-", @var{nl}, """ and of course " "}
   31576 
   31577 @item @var{c-string} @expansion{}
   31578 @code{""" @var{seven-bit-iso-c-string-content} """}
   31579 
   31580 @item @var{nl} @expansion{}
   31581 @code{CR | CR-LF}
   31582 @end table
   31583 
   31584 @noindent
   31585 Notes:
   31586 
   31587 @itemize @bullet
   31588 @item
   31589 The CLI commands are still handled by the @sc{mi} interpreter; their
   31590 output is described below.
   31591 
   31592 @item
   31593 The @code{@var{token}}, when present, is passed back when the command
   31594 finishes.
   31595 
   31596 @item
   31597 Some @sc{mi} commands accept optional arguments as part of the parameter
   31598 list.  Each option is identified by a leading @samp{-} (dash) and may be
   31599 followed by an optional argument parameter.  Options occur first in the
   31600 parameter list and can be delimited from normal parameters using
   31601 @samp{--} (this is useful when some parameters begin with a dash).
   31602 @end itemize
   31603 
   31604 Pragmatics:
   31605 
   31606 @itemize @bullet
   31607 @item
   31608 We want easy access to the existing CLI syntax (for debugging).
   31609 
   31610 @item
   31611 We want it to be easy to spot a @sc{mi} operation.
   31612 @end itemize
   31613 
   31614 @node GDB/MI Output Syntax
   31615 @subsection @sc{gdb/mi} Output Syntax
   31616 
   31617 @cindex output syntax of @sc{gdb/mi}
   31618 @cindex @sc{gdb/mi}, output syntax
   31619 The output from @sc{gdb/mi} consists of zero or more out-of-band records
   31620 followed, optionally, by a single result record.  This result record
   31621 is for the most recent command.  The sequence of output records is
   31622 terminated by @samp{(gdb)}.
   31623 
   31624 If an input command was prefixed with a @code{@var{token}} then the
   31625 corresponding output for that command will also be prefixed by that same
   31626 @var{token}.
   31627 
   31628 @table @code
   31629 @item @var{output} @expansion{}
   31630 @code{( @var{out-of-band-record} )* [ @var{result-record} ] "(gdb)" @var{nl}}
   31631 
   31632 @item @var{result-record} @expansion{}
   31633 @code{ [ @var{token} ] "^" @var{result-class} ( "," @var{result} )* @var{nl}}
   31634 
   31635 @item @var{out-of-band-record} @expansion{}
   31636 @code{@var{async-record} | @var{stream-record}}
   31637 
   31638 @item @var{async-record} @expansion{}
   31639 @code{@var{exec-async-output} | @var{status-async-output} | @var{notify-async-output}}
   31640 
   31641 @item @var{exec-async-output} @expansion{}
   31642 @code{[ @var{token} ] "*" @var{async-output nl}}
   31643 
   31644 @item @var{status-async-output} @expansion{}
   31645 @code{[ @var{token} ] "+" @var{async-output nl}}
   31646 
   31647 @item @var{notify-async-output} @expansion{}
   31648 @code{[ @var{token} ] "=" @var{async-output nl}}
   31649 
   31650 @item @var{async-output} @expansion{}
   31651 @code{@var{async-class} ( "," @var{result} )*}
   31652 
   31653 @item @var{result-class} @expansion{}
   31654 @code{"done" | "running" | "connected" | "error" | "exit"}
   31655 
   31656 @item @var{async-class} @expansion{}
   31657 @code{"stopped" | @var{others}} (where @var{others} will be added
   31658 depending on the needs---this is still in development).
   31659 
   31660 @item @var{result} @expansion{}
   31661 @code{ @var{variable} "=" @var{value}}
   31662 
   31663 @item @var{variable} @expansion{}
   31664 @code{ @var{string} }
   31665 
   31666 @item @var{value} @expansion{}
   31667 @code{ @var{const} | @var{tuple} | @var{list} }
   31668 
   31669 @item @var{const} @expansion{}
   31670 @code{@var{c-string}}
   31671 
   31672 @item @var{tuple} @expansion{}
   31673 @code{ "@{@}" | "@{" @var{result} ( "," @var{result} )* "@}" }
   31674 
   31675 @item @var{list} @expansion{}
   31676 @code{ "[]" | "[" @var{value} ( "," @var{value} )* "]" | "["
   31677 @var{result} ( "," @var{result} )* "]" }
   31678 
   31679 @item @var{stream-record} @expansion{}
   31680 @code{@var{console-stream-output} | @var{target-stream-output} | @var{log-stream-output}}
   31681 
   31682 @item @var{console-stream-output} @expansion{}
   31683 @code{"~" @var{c-string nl}}
   31684 
   31685 @item @var{target-stream-output} @expansion{}
   31686 @code{"@@" @var{c-string nl}}
   31687 
   31688 @item @var{log-stream-output} @expansion{}
   31689 @code{"&" @var{c-string nl}}
   31690 
   31691 @item @var{nl} @expansion{}
   31692 @code{CR | CR-LF}
   31693 
   31694 @item @var{token} @expansion{}
   31695 @emph{any sequence of digits}.
   31696 @end table
   31697 
   31698 @noindent
   31699 Notes:
   31700 
   31701 @itemize @bullet
   31702 @item
   31703 All output sequences end in a single line containing a period.
   31704 
   31705 @item
   31706 The @code{@var{token}} is from the corresponding request.  Note that
   31707 for all async output, while the token is allowed by the grammar and
   31708 may be output by future versions of @value{GDBN} for select async
   31709 output messages, it is generally omitted.  Frontends should treat
   31710 all async output as reporting general changes in the state of the
   31711 target and there should be no need to associate async output to any
   31712 prior command.
   31713 
   31714 @item
   31715 @cindex status output in @sc{gdb/mi}
   31716 @var{status-async-output} contains on-going status information about the
   31717 progress of a slow operation.  It can be discarded.  All status output is
   31718 prefixed by @samp{+}.
   31719 
   31720 @item
   31721 @cindex async output in @sc{gdb/mi}
   31722 @var{exec-async-output} contains asynchronous state change on the target
   31723 (stopped, started, disappeared).  All async output is prefixed by
   31724 @samp{*}.
   31725 
   31726 @item
   31727 @cindex notify output in @sc{gdb/mi}
   31728 @var{notify-async-output} contains supplementary information that the
   31729 client should handle (e.g., a new breakpoint information).  All notify
   31730 output is prefixed by @samp{=}.
   31731 
   31732 @item
   31733 @cindex console output in @sc{gdb/mi}
   31734 @var{console-stream-output} is output that should be displayed as is in the
   31735 console.  It is the textual response to a CLI command.  All the console
   31736 output is prefixed by @samp{~}.
   31737 
   31738 @item
   31739 @cindex target output in @sc{gdb/mi}
   31740 @var{target-stream-output} is the output produced by the target program.
   31741 All the target output is prefixed by @samp{@@}.
   31742 
   31743 @item
   31744 @cindex log output in @sc{gdb/mi}
   31745 @var{log-stream-output} is output text coming from @value{GDBN}'s internals, for
   31746 instance messages that should be displayed as part of an error log.  All
   31747 the log output is prefixed by @samp{&}.
   31748 
   31749 @item
   31750 @cindex list output in @sc{gdb/mi}
   31751 New @sc{gdb/mi} commands should only output @var{lists} containing
   31752 @var{values}.
   31753 
   31754 
   31755 @end itemize
   31756 
   31757 @xref{GDB/MI Stream Records, , @sc{gdb/mi} Stream Records}, for more
   31758 details about the various output records.
   31759 
   31760 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   31761 @node GDB/MI Compatibility with CLI
   31762 @section @sc{gdb/mi} Compatibility with CLI
   31763 
   31764 @cindex compatibility, @sc{gdb/mi} and CLI
   31765 @cindex @sc{gdb/mi}, compatibility with CLI
   31766 
   31767 For the developers convenience CLI commands can be entered directly,
   31768 but there may be some unexpected behavior.  For example, commands
   31769 that query the user will behave as if the user replied yes, breakpoint
   31770 command lists are not executed and some CLI commands, such as
   31771 @code{if}, @code{when} and @code{define}, prompt for further input with
   31772 @samp{>}, which is not valid MI output.
   31773 
   31774 This feature may be removed at some stage in the future and it is
   31775 recommended that front ends use the @code{-interpreter-exec} command
   31776 (@pxref{-interpreter-exec}).
   31777 
   31778 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   31779 @node GDB/MI Development and Front Ends
   31780 @section @sc{gdb/mi} Development and Front Ends
   31781 @cindex @sc{gdb/mi} development
   31782 
   31783 The application which takes the MI output and presents the state of the
   31784 program being debugged to the user is called a @dfn{front end}.
   31785 
   31786 Since @sc{gdb/mi} is used by a variety of front ends to @value{GDBN}, changes
   31787 to the MI interface may break existing usage.  This section describes how the
   31788 protocol changes and how to request previous version of the protocol when it
   31789 does.
   31790 
   31791 Some changes in MI need not break a carefully designed front end, and
   31792 for these the MI version will remain unchanged.  The following is a
   31793 list of changes that may occur within one level, so front ends should
   31794 parse MI output in a way that can handle them:
   31795 
   31796 @itemize @bullet
   31797 @item
   31798 New MI commands may be added.
   31799 
   31800 @item
   31801 New fields may be added to the output of any MI command.
   31802 
   31803 @item
   31804 The range of values for fields with specified values, e.g.,
   31805 @code{in_scope} (@pxref{-var-update}) may be extended.
   31806 
   31807 @c The format of field's content e.g type prefix, may change so parse it
   31808 @c   at your own risk.  Yes, in general?
   31809 
   31810 @c The order of fields may change?  Shouldn't really matter but it might
   31811 @c resolve inconsistencies.
   31812 @end itemize
   31813 
   31814 If the changes are likely to break front ends, the MI version level
   31815 will be increased by one.  The new versions of the MI protocol are not compatible
   31816 with the old versions.  Old versions of MI remain available, allowing front ends
   31817 to keep using them until they are modified to use the latest MI version.
   31818 
   31819 Since @code{--interpreter=mi} always points to the latest MI version, it is
   31820 recommended that front ends request a specific version of MI when launching
   31821 @value{GDBN} (e.g.@: @code{--interpreter=mi2}) to make sure they get an
   31822 interpreter with the MI version they expect.
   31823 
   31824 The following table gives a summary of the released versions of the MI
   31825 interface: the version number, the version of GDB in which it first appeared
   31826 and the breaking changes compared to the previous version.
   31827 
   31828 @multitable @columnfractions .1 .1 .8
   31829 @headitem MI version @tab GDB version @tab Breaking changes
   31830 
   31831 @item
   31832 @center 1
   31833 @tab
   31834 @center 5.1
   31835 @tab
   31836 None
   31837 
   31838 @item
   31839 @center 2
   31840 @tab
   31841 @center 6.0
   31842 @tab
   31843 
   31844 @itemize
   31845 @item
   31846 The @code{-environment-pwd}, @code{-environment-directory} and
   31847 @code{-environment-path} commands now returns values using the MI output
   31848 syntax, rather than CLI output syntax.
   31849 
   31850 @item
   31851 @code{-var-list-children}'s @code{children} result field is now a list, rather
   31852 than a tuple.
   31853 
   31854 @item
   31855 @code{-var-update}'s @code{changelist} result field is now a list, rather than
   31856 a tuple.
   31857 @end itemize
   31858 
   31859 @item
   31860 @center 3
   31861 @tab
   31862 @center 9.1
   31863 @tab
   31864 
   31865 @itemize
   31866 @item
   31867 The output of information about multi-location breakpoints has changed in the
   31868 responses to the @code{-break-insert} and @code{-break-info} commands, as well
   31869 as in the @code{=breakpoint-created} and @code{=breakpoint-modified} events.
   31870 The multiple locations are now placed in a @code{locations} field, whose value
   31871 is a list.
   31872 @end itemize
   31873 
   31874 @item
   31875 @center 4
   31876 @tab
   31877 @center 13.1
   31878 @tab
   31879 
   31880 @itemize
   31881 @item
   31882 The syntax of the "script" field in breakpoint output has changed in the
   31883 responses to the @code{-break-insert} and @code{-break-info} commands, as
   31884 well as the @code{=breakpoint-created} and @code{=breakpoint-modified}
   31885 events.  The previous output was syntactically invalid.  The new output is
   31886 a list.
   31887 @end itemize
   31888 
   31889 @end multitable
   31890 
   31891 If your front end cannot yet migrate to a more recent version of the
   31892 MI protocol, you can nevertheless selectively enable specific features
   31893 available in those recent MI versions, using the following commands:
   31894 
   31895 @table @code
   31896 
   31897 @item -fix-multi-location-breakpoint-output
   31898 Use the output for multi-location breakpoints which was introduced by
   31899 MI 3, even when using MI versions below 3.  This command has no
   31900 effect when using MI version 3 or later.
   31901 
   31902 @item -fix-breakpoint-script-output
   31903 Use the output for the breakpoint "script" field which was introduced by
   31904 MI 4, even when using MI versions below 4.  This command has no effect when
   31905 using MI version 4 or later.
   31906 
   31907 @end table
   31908 
   31909 The best way to avoid unexpected changes in MI that might break your front
   31910 end is to make your project known to @value{GDBN} developers and
   31911 follow development on @email{gdb@@sourceware.org} and
   31912 @email{gdb-patches@@sourceware.org}.
   31913 @cindex mailing lists
   31914 
   31915 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   31916 @node GDB/MI Output Records
   31917 @section @sc{gdb/mi} Output Records
   31918 
   31919 @menu
   31920 * GDB/MI Result Records::
   31921 * GDB/MI Stream Records::
   31922 * GDB/MI Async Records::
   31923 * GDB/MI Breakpoint Information::
   31924 * GDB/MI Frame Information::
   31925 * GDB/MI Thread Information::
   31926 * GDB/MI Ada Exception Information::
   31927 @end menu
   31928 
   31929 @node GDB/MI Result Records
   31930 @subsection @sc{gdb/mi} Result Records
   31931 
   31932 @cindex result records in @sc{gdb/mi}
   31933 @cindex @sc{gdb/mi}, result records
   31934 In addition to a number of out-of-band notifications, the response to a
   31935 @sc{gdb/mi} command includes one of the following result indications:
   31936 
   31937 @table @code
   31938 @findex ^done
   31939 @item "^done" [ "," @var{results} ]
   31940 The synchronous operation was successful, @code{@var{results}} are the return
   31941 values.
   31942 
   31943 @findex ^running
   31944 @item "^running"
   31945 This result record is equivalent to @samp{^done}.  Historically, it
   31946 was output instead of @samp{^done} if the command has resumed the
   31947 target.  This behavior is maintained for backward compatibility, but
   31948 all frontends should treat @samp{^done} and @samp{^running}
   31949 identically and rely on the @samp{*running} output record to determine
   31950 which threads are resumed.
   31951 
   31952 @findex ^connected
   31953 @item "^connected"
   31954 @value{GDBN} has connected to a remote target.
   31955 
   31956 @findex ^error
   31957 @item "^error" "," "msg=" @var{c-string} [ "," "code=" @var{c-string} ]
   31958 The operation failed.  The @code{msg=@var{c-string}} variable contains
   31959 the corresponding error message.
   31960 
   31961 If present, the @code{code=@var{c-string}} variable provides an error
   31962 code on which consumers can rely on to detect the corresponding
   31963 error condition.  At present, only one error code is defined:
   31964 
   31965 @table @samp
   31966 @item "undefined-command"
   31967 Indicates that the command causing the error does not exist.
   31968 @end table
   31969 
   31970 @findex ^exit
   31971 @item "^exit"
   31972 @value{GDBN} has terminated.
   31973 
   31974 @end table
   31975 
   31976 @node GDB/MI Stream Records
   31977 @subsection @sc{gdb/mi} Stream Records
   31978 
   31979 @cindex @sc{gdb/mi}, stream records
   31980 @cindex stream records in @sc{gdb/mi}
   31981 @value{GDBN} internally maintains a number of output streams: the console, the
   31982 target, and the log.  The output intended for each of these streams is
   31983 funneled through the @sc{gdb/mi} interface using @dfn{stream records}.
   31984 
   31985 Each stream record begins with a unique @dfn{prefix character} which
   31986 identifies its stream (@pxref{GDB/MI Output Syntax, , @sc{gdb/mi} Output
   31987 Syntax}).  In addition to the prefix, each stream record contains a
   31988 @code{@var{string-output}}.  This is either raw text (with an implicit new
   31989 line) or a quoted C string (which does not contain an implicit newline).
   31990 
   31991 @table @code
   31992 @item "~" @var{string-output}
   31993 The console output stream contains text that should be displayed in the
   31994 CLI console window.  It contains the textual responses to CLI commands.
   31995 
   31996 @item "@@" @var{string-output}
   31997 The target output stream contains any textual output from the running
   31998 target.  This is only present when GDB's event loop is truly
   31999 asynchronous, which is currently only the case for remote targets.
   32000 
   32001 @item "&" @var{string-output}
   32002 The log stream contains debugging messages being produced by @value{GDBN}'s
   32003 internals.
   32004 @end table
   32005 
   32006 @node GDB/MI Async Records
   32007 @subsection @sc{gdb/mi} Async Records
   32008 
   32009 @cindex async records in @sc{gdb/mi}
   32010 @cindex @sc{gdb/mi}, async records
   32011 @dfn{Async} records are used to notify the @sc{gdb/mi} client of
   32012 additional changes that have occurred.  Those changes can either be a
   32013 consequence of @sc{gdb/mi} commands (e.g., a breakpoint modified) or a result of
   32014 target activity (e.g., target stopped).
   32015 
   32016 The following is the list of possible async records:
   32017 
   32018 @table @code
   32019 
   32020 @item *running,thread-id="@var{thread}"
   32021 The target is now running.  The @var{thread} field can be the global
   32022 thread ID of the thread that is now running, and it can be
   32023 @samp{all} if all threads are running.  The frontend should assume
   32024 that no interaction with a running thread is possible after this
   32025 notification is produced.  The frontend should not assume that this
   32026 notification is output only once for any command.  @value{GDBN} may
   32027 emit this notification several times, either for different threads,
   32028 because it cannot resume all threads together, or even for a single
   32029 thread, if the thread must be stepped though some code before letting
   32030 it run freely.
   32031 
   32032 @item *stopped,reason="@var{reason}",thread-id="@var{id}",stopped-threads="@var{stopped}",core="@var{core}"
   32033 The target has stopped.  The @var{reason} field can have one of the
   32034 following values:
   32035 
   32036 @table @code
   32037 @item breakpoint-hit
   32038 A breakpoint was reached.
   32039 @item watchpoint-trigger
   32040 A watchpoint was triggered.
   32041 @item read-watchpoint-trigger
   32042 A read watchpoint was triggered.
   32043 @item access-watchpoint-trigger 
   32044 An access watchpoint was triggered.
   32045 @item function-finished
   32046 An -exec-finish or similar CLI command was accomplished.
   32047 @item location-reached
   32048 An -exec-until or similar CLI command was accomplished.
   32049 @item watchpoint-scope
   32050 A watchpoint has gone out of scope.
   32051 @item end-stepping-range
   32052 An -exec-next, -exec-next-instruction, -exec-step, -exec-step-instruction or 
   32053 similar CLI command was accomplished.
   32054 @item exited-signalled 
   32055 The inferior exited because of a signal.
   32056 @item exited 
   32057 The inferior exited.
   32058 @item exited-normally 
   32059 The inferior exited normally.
   32060 @item signal-received 
   32061 A signal was received by the inferior.
   32062 @item solib-event
   32063 The inferior has stopped due to a library being loaded or unloaded.
   32064 This can happen when @code{stop-on-solib-events} (@pxref{Files}) is
   32065 set or when a @code{catch load} or @code{catch unload} catchpoint is
   32066 in use (@pxref{Set Catchpoints}).
   32067 @item fork
   32068 The inferior has forked.  This is reported when @code{catch fork}
   32069 (@pxref{Set Catchpoints}) has been used.
   32070 @item vfork
   32071 The inferior has vforked.  This is reported in when @code{catch vfork}
   32072 (@pxref{Set Catchpoints}) has been used.
   32073 @item syscall-entry
   32074 The inferior entered a system call.  This is reported when @code{catch
   32075 syscall} (@pxref{Set Catchpoints}) has been used.
   32076 @item syscall-return
   32077 The inferior returned from a system call.  This is reported when
   32078 @code{catch syscall} (@pxref{Set Catchpoints}) has been used.
   32079 @item exec
   32080 The inferior called @code{exec}.  This is reported when @code{catch exec}
   32081 (@pxref{Set Catchpoints}) has been used.
   32082 @item no-history
   32083 There isn't enough history recorded to continue reverse execution.
   32084 @end table
   32085 
   32086 The @var{id} field identifies the global thread ID of the thread
   32087 that directly caused the stop -- for example by hitting a breakpoint.
   32088 Depending on whether all-stop
   32089 mode is in effect (@pxref{All-Stop Mode}), @value{GDBN} may either
   32090 stop all threads, or only the thread that directly triggered the stop.
   32091 If all threads are stopped, the @var{stopped} field will have the
   32092 value of @code{"all"}.  Otherwise, the value of the @var{stopped}
   32093 field will be a list of thread identifiers.  Presently, this list will
   32094 always include a single thread, but frontend should be prepared to see
   32095 several threads in the list.  The @var{core} field reports the
   32096 processor core on which the stop event has happened.  This field may be absent
   32097 if such information is not available.
   32098 
   32099 @item =thread-group-added,id="@var{id}"
   32100 @itemx =thread-group-removed,id="@var{id}"
   32101 A thread group was either added or removed.  The @var{id} field
   32102 contains the @value{GDBN} identifier of the thread group.  When a thread
   32103 group is added, it generally might not be associated with a running
   32104 process.  When a thread group is removed, its id becomes invalid and
   32105 cannot be used in any way.
   32106 
   32107 @item =thread-group-started,id="@var{id}",pid="@var{pid}"
   32108 A thread group became associated with a running program,
   32109 either because the program was just started or the thread group
   32110 was attached to a program.  The @var{id} field contains the
   32111 @value{GDBN} identifier of the thread group.  The @var{pid} field
   32112 contains process identifier, specific to the operating system.
   32113 
   32114 @item =thread-group-exited,id="@var{id}"[,exit-code="@var{code}"]
   32115 A thread group is no longer associated with a running program,
   32116 either because the program has exited, or because it was detached
   32117 from.  The @var{id} field contains the @value{GDBN} identifier of the
   32118 thread group.  The @var{code} field is the exit code of the inferior; it exists
   32119 only when the inferior exited with some code.
   32120 
   32121 @item =thread-created,id="@var{id}",group-id="@var{gid}"
   32122 @itemx =thread-exited,id="@var{id}",group-id="@var{gid}"
   32123 A thread either was created, or has exited.  The @var{id} field
   32124 contains the global @value{GDBN} identifier of the thread.  The @var{gid}
   32125 field identifies the thread group this thread belongs to.
   32126 
   32127 @item =thread-selected,id="@var{id}"[,frame="@var{frame}"]
   32128 Informs that the selected thread or frame were changed.  This notification
   32129 is not emitted as result of the @code{-thread-select} or
   32130 @code{-stack-select-frame} commands, but is emitted whenever an MI command
   32131 that is not documented to change the selected thread and frame actually
   32132 changes them.  In particular, invoking, directly or indirectly
   32133 (via user-defined command), the CLI @code{thread} or @code{frame} commands,
   32134 will generate this notification.  Changing the thread or frame from another
   32135 user interface (see @ref{Interpreters}) will also generate this notification.
   32136 
   32137 The @var{frame} field is only present if the newly selected thread is
   32138 stopped.  See @ref{GDB/MI Frame Information} for the format of its value.
   32139 
   32140 We suggest that in response to this notification, front ends
   32141 highlight the selected thread and cause subsequent commands to apply to
   32142 that thread.
   32143 
   32144 @item =library-loaded,...
   32145 Reports that a new library file was loaded by the program.  This
   32146 notification has 5 fields---@var{id}, @var{target-name},
   32147 @var{host-name}, @var{symbols-loaded} and @var{ranges}.  The @var{id} field is an
   32148 opaque identifier of the library.  For remote debugging case,
   32149 @var{target-name} and @var{host-name} fields give the name of the
   32150 library file on the target, and on the host respectively.  For native
   32151 debugging, both those fields have the same value.  The
   32152 @var{symbols-loaded} field is emitted only for backward compatibility
   32153 and should not be relied on to convey any useful information.  The
   32154 @var{thread-group} field, if present, specifies the id of the thread
   32155 group in whose context the library was loaded.  If the field is
   32156 absent, it means the library was loaded in the context of all present
   32157 thread groups.  The @var{ranges} field specifies the ranges of addresses belonging
   32158 to this library.
   32159 
   32160 @item =library-unloaded,...
   32161 Reports that a library was unloaded by the program.  This notification
   32162 has 3 fields---@var{id}, @var{target-name} and @var{host-name} with
   32163 the same meaning as for the @code{=library-loaded} notification.
   32164 The @var{thread-group} field, if present, specifies the id of the
   32165 thread group in whose context the library was unloaded.  If the field is
   32166 absent, it means the library was unloaded in the context of all present
   32167 thread groups.
   32168 
   32169 @item =traceframe-changed,num=@var{tfnum},tracepoint=@var{tpnum}
   32170 @itemx =traceframe-changed,end
   32171 Reports that the trace frame was changed and its new number is
   32172 @var{tfnum}.  The number of the tracepoint associated with this trace
   32173 frame is @var{tpnum}.
   32174 
   32175 @item =tsv-created,name=@var{name},initial=@var{initial}
   32176 Reports that the new trace state variable @var{name} is created with
   32177 initial value @var{initial}.
   32178 
   32179 @item =tsv-deleted,name=@var{name}
   32180 @itemx =tsv-deleted
   32181 Reports that the trace state variable @var{name} is deleted or all
   32182 trace state variables are deleted.
   32183 
   32184 @item =tsv-modified,name=@var{name},initial=@var{initial}[,current=@var{current}]
   32185 Reports that the trace state variable @var{name} is modified with
   32186 the initial value @var{initial}. The current value @var{current} of
   32187 trace state variable is optional and is reported if the current
   32188 value of trace state variable is known.
   32189 
   32190 @item =breakpoint-created,bkpt=@{...@}
   32191 @itemx =breakpoint-modified,bkpt=@{...@}
   32192 @itemx =breakpoint-deleted,id=@var{number}
   32193 Reports that a breakpoint was created, modified, or deleted,
   32194 respectively.  Only user-visible breakpoints are reported to the MI
   32195 user.
   32196 
   32197 The @var{bkpt} argument is of the same form as returned by the various
   32198 breakpoint commands; @xref{GDB/MI Breakpoint Commands}.  The
   32199 @var{number} is the ordinal number of the breakpoint.
   32200 
   32201 Note that if a breakpoint is emitted in the result record of a
   32202 command, then it will not also be emitted in an async record.
   32203 
   32204 @item =record-started,thread-group="@var{id}",method="@var{method}"[,format="@var{format}"]
   32205 @itemx =record-stopped,thread-group="@var{id}"
   32206 Execution log recording was either started or stopped on an
   32207 inferior.  The @var{id} is the @value{GDBN} identifier of the thread
   32208 group corresponding to the affected inferior.
   32209 
   32210 The @var{method} field indicates the method used to record execution.  If the
   32211 method in use supports multiple recording formats, @var{format} will be present
   32212 and contain the currently used format.  @xref{Process Record and Replay},
   32213 for existing method and format values.
   32214 
   32215 @item =cmd-param-changed,param=@var{param},value=@var{value}
   32216 Reports that a parameter of the command @code{set @var{param}} is
   32217 changed to @var{value}.  In the multi-word @code{set} command,
   32218 the @var{param} is the whole parameter list to @code{set} command.
   32219 For example, In command @code{set check type on}, @var{param}
   32220 is @code{check type} and @var{value} is @code{on}.
   32221 
   32222 @item =memory-changed,thread-group=@var{id},addr=@var{addr},len=@var{len}[,type="code"]
   32223 Reports that bytes from @var{addr} to @var{data} + @var{len} were
   32224 written in an inferior.  The @var{id} is the identifier of the
   32225 thread group corresponding to the affected inferior.  The optional
   32226 @code{type="code"} part is reported if the memory written to holds
   32227 executable code.
   32228 @end table
   32229 
   32230 @node GDB/MI Breakpoint Information
   32231 @subsection @sc{gdb/mi} Breakpoint Information
   32232 
   32233 When @value{GDBN} reports information about a breakpoint, a
   32234 tracepoint, a watchpoint, or a catchpoint, it uses a tuple with the
   32235 following fields:
   32236 
   32237 @table @code
   32238 @item number
   32239 The breakpoint number.
   32240 
   32241 @item type
   32242 The type of the breakpoint.  For ordinary breakpoints this will be
   32243 @samp{breakpoint}, but many values are possible.
   32244 
   32245 @item catch-type
   32246 If the type of the breakpoint is @samp{catchpoint}, then this
   32247 indicates the exact type of catchpoint.
   32248 
   32249 @item disp
   32250 This is the breakpoint disposition---either @samp{del}, meaning that
   32251 the breakpoint will be deleted at the next stop, or @samp{keep},
   32252 meaning that the breakpoint will not be deleted.
   32253 
   32254 @item enabled
   32255 This indicates whether the breakpoint is enabled, in which case the
   32256 value is @samp{y}, or disabled, in which case the value is @samp{n}.
   32257 Note that this is not the same as the field @code{enable}.
   32258 
   32259 @item addr
   32260 The address of the breakpoint.  This may be a hexadecimal number,
   32261 giving the address; or the string @samp{<PENDING>}, for a pending
   32262 breakpoint; or the string @samp{<MULTIPLE>}, for a breakpoint with
   32263 multiple locations.  This field will not be present if no address can
   32264 be determined.  For example, a watchpoint does not have an address.
   32265 
   32266 @item addr_flags
   32267 Optional field containing any flags related to the address.  These flags are
   32268 architecture-dependent; see @ref{Architectures} for their meaning for a
   32269 particular CPU.
   32270 
   32271 @item func
   32272 If known, the function in which the breakpoint appears.
   32273 If not known, this field is not present.
   32274 
   32275 @item filename
   32276 The name of the source file which contains this function, if known.
   32277 If not known, this field is not present.
   32278 
   32279 @item fullname
   32280 The full file name of the source file which contains this function, if
   32281 known.  If not known, this field is not present.
   32282 
   32283 @item line
   32284 The line number at which this breakpoint appears, if known.
   32285 If not known, this field is not present.
   32286 
   32287 @item at
   32288 If the source file is not known, this field may be provided.  If
   32289 provided, this holds the address of the breakpoint, possibly followed
   32290 by a symbol name.
   32291 
   32292 @item pending
   32293 If this breakpoint is pending, this field is present and holds the
   32294 text used to set the breakpoint, as entered by the user.
   32295 
   32296 @item evaluated-by
   32297 Where this breakpoint's condition is evaluated, either @samp{host} or
   32298 @samp{target}.
   32299 
   32300 @item thread
   32301 If this is a thread-specific breakpoint, then this identifies the
   32302 thread in which the breakpoint can trigger.
   32303 
   32304 @item inferior
   32305 If this is an inferior-specific breakpoint, this this identifies the
   32306 inferior in which the breakpoint can trigger.
   32307 
   32308 @item task
   32309 If this breakpoint is restricted to a particular Ada task, then this
   32310 field will hold the task identifier.
   32311 
   32312 @item cond
   32313 If the breakpoint is conditional, this is the condition expression.
   32314 
   32315 @item ignore
   32316 The ignore count of the breakpoint.
   32317 
   32318 @item enable
   32319 The enable count of the breakpoint.
   32320 
   32321 @item traceframe-usage
   32322 FIXME.
   32323 
   32324 @item static-tracepoint-marker-string-id
   32325 For a static tracepoint, the name of the static tracepoint marker.
   32326 
   32327 @item mask
   32328 For a masked watchpoint, this is the mask.
   32329 
   32330 @item pass
   32331 A tracepoint's pass count.
   32332 
   32333 @item original-location
   32334 The location of the breakpoint as originally specified by the user.
   32335 This field is optional.
   32336 
   32337 @item times
   32338 The number of times the breakpoint has been hit.
   32339 
   32340 @item installed
   32341 This field is only given for tracepoints.  This is either @samp{y},
   32342 meaning that the tracepoint is installed, or @samp{n}, meaning that it
   32343 is not.
   32344 
   32345 @item what
   32346 Some extra data, the exact contents of which are type-dependent.
   32347 
   32348 @item locations
   32349 This field is present if the breakpoint has multiple locations.  It is also
   32350 exceptionally present if the breakpoint is enabled and has a single, disabled
   32351 location.
   32352 
   32353 The value is a list of locations.  The format of a location is described below.
   32354 
   32355 @end table
   32356 
   32357 A location in a multi-location breakpoint is represented as a tuple with the
   32358 following fields:
   32359 
   32360 @table @code
   32361 
   32362 @item number
   32363 The location number as a dotted pair, like @samp{1.2}.  The first digit is the
   32364 number of the parent breakpoint.  The second digit is the number of the
   32365 location within that breakpoint.
   32366 
   32367 @item enabled
   32368 There are three possible values, with the following meanings:
   32369 @table @code
   32370 @item y
   32371 The location is enabled.
   32372 @item n
   32373 The location is disabled by the user.
   32374 @item N
   32375 The location is disabled because the breakpoint condition is invalid
   32376 at this location.
   32377 @end table
   32378 
   32379 @item addr
   32380 The address of this location as an hexadecimal number.
   32381 
   32382 @item addr_flags
   32383 Optional field containing any flags related to the address.  These flags are
   32384 architecture-dependent; see @ref{Architectures} for their meaning for a
   32385 particular CPU.
   32386 
   32387 @item func
   32388 If known, the function in which the location appears.
   32389 If not known, this field is not present.
   32390 
   32391 @item file
   32392 The name of the source file which contains this location, if known.
   32393 If not known, this field is not present.
   32394 
   32395 @item fullname
   32396 The full file name of the source file which contains this location, if
   32397 known.  If not known, this field is not present.
   32398 
   32399 @item line
   32400 The line number at which this location appears, if known.
   32401 If not known, this field is not present.
   32402 
   32403 @item thread-groups
   32404 The thread groups this location is in.
   32405 
   32406 @end table
   32407 
   32408 For example, here is what the output of @code{-break-insert}
   32409 (@pxref{GDB/MI Breakpoint Commands}) might be:
   32410 
   32411 @smallexample
   32412 -> -break-insert main
   32413 <- ^done,bkpt=@{number="1",type="breakpoint",disp="keep",
   32414     enabled="y",addr="0x08048564",func="main",file="myprog.c",
   32415     fullname="/home/nickrob/myprog.c",line="68",thread-groups=["i1"],
   32416     times="0"@}
   32417 <- (gdb)
   32418 @end smallexample
   32419 
   32420 @node GDB/MI Frame Information
   32421 @subsection @sc{gdb/mi} Frame Information
   32422 
   32423 Response from many MI commands includes an information about stack
   32424 frame.  This information is a tuple that may have the following
   32425 fields:
   32426 
   32427 @table @code
   32428 @item level
   32429 The level of the stack frame.  The innermost frame has the level of
   32430 zero.  This field is always present.
   32431 
   32432 @item func
   32433 The name of the function corresponding to the frame.  This field may
   32434 be absent if @value{GDBN} is unable to determine the function name.
   32435 
   32436 @item addr
   32437 The code address for the frame.  This field is always present.
   32438 
   32439 @item addr_flags
   32440 Optional field containing any flags related to the address.  These flags are
   32441 architecture-dependent; see @ref{Architectures} for their meaning for a
   32442 particular CPU.
   32443 
   32444 @item file
   32445 The name of the source files that correspond to the frame's code
   32446 address.  This field may be absent.
   32447 
   32448 @item line
   32449 The source line corresponding to the frames' code address.  This field
   32450 may be absent.
   32451 
   32452 @item from
   32453 The name of the binary file (either executable or shared library) the
   32454 corresponds to the frame's code address.  This field may be absent.
   32455 
   32456 @end table
   32457 
   32458 @node GDB/MI Thread Information
   32459 @subsection @sc{gdb/mi} Thread Information
   32460 
   32461 Whenever @value{GDBN} has to report an information about a thread, it
   32462 uses a tuple with the following fields.  The fields are always present unless
   32463 stated otherwise.
   32464 
   32465 @table @code
   32466 @item id
   32467 The global numeric id assigned to the thread by @value{GDBN}.
   32468 
   32469 @item target-id
   32470 The target-specific string identifying the thread.
   32471 
   32472 @item details
   32473 Additional information about the thread provided by the target.
   32474 It is supposed to be human-readable and not interpreted by the
   32475 frontend.  This field is optional.
   32476 
   32477 @item name
   32478 The name of the thread.  If the user specified a name using the
   32479 @code{thread name} command, then this name is given.  Otherwise, if
   32480 @value{GDBN} can extract the thread name from the target, then that
   32481 name is given.  If @value{GDBN} cannot find the thread name, then this
   32482 field is omitted.
   32483 
   32484 @item state
   32485 The execution state of the thread, either @samp{stopped} or @samp{running},
   32486 depending on whether the thread is presently running.
   32487 
   32488 @item frame
   32489 The stack frame currently executing in the thread.  This field is only present
   32490 if the thread is stopped.  Its format is documented in
   32491 @ref{GDB/MI Frame Information}.
   32492 
   32493 @item core
   32494 The value of this field is an integer number of the processor core the
   32495 thread was last seen on.  This field is optional.
   32496 @end table
   32497 
   32498 @node GDB/MI Ada Exception Information
   32499 @subsection @sc{gdb/mi} Ada Exception Information
   32500 
   32501 Whenever a @code{*stopped} record is emitted because the program
   32502 stopped after hitting an exception catchpoint (@pxref{Set Catchpoints}),
   32503 @value{GDBN} provides the name of the exception that was raised via
   32504 the @code{exception-name} field.  Also, for exceptions that were raised
   32505 with an exception message, @value{GDBN} provides that message via
   32506 the @code{exception-message} field.
   32507 
   32508 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   32509 @node GDB/MI Simple Examples
   32510 @section Simple Examples of @sc{gdb/mi} Interaction
   32511 @cindex @sc{gdb/mi}, simple examples
   32512 
   32513 This subsection presents several simple examples of interaction using
   32514 the @sc{gdb/mi} interface.  In these examples, @samp{->} means that the
   32515 following line is passed to @sc{gdb/mi} as input, while @samp{<-} means
   32516 the output received from @sc{gdb/mi}.
   32517 
   32518 Note the line breaks shown in the examples are here only for
   32519 readability, they don't appear in the real output.
   32520 
   32521 @subheading Setting a Breakpoint
   32522 
   32523 Setting a breakpoint generates synchronous output which contains detailed
   32524 information of the breakpoint.
   32525 
   32526 @smallexample
   32527 -> -break-insert main
   32528 <- ^done,bkpt=@{number="1",type="breakpoint",disp="keep",
   32529     enabled="y",addr="0x08048564",func="main",file="myprog.c",
   32530     fullname="/home/nickrob/myprog.c",line="68",thread-groups=["i1"],
   32531     times="0"@}
   32532 <- (gdb)
   32533 @end smallexample
   32534 
   32535 @subheading Program Execution
   32536 
   32537 Program execution generates asynchronous records and MI gives the
   32538 reason that execution stopped.
   32539 
   32540 @smallexample
   32541 -> -exec-run
   32542 <- ^running
   32543 <- (gdb)
   32544 <- *stopped,reason="breakpoint-hit",disp="keep",bkptno="1",thread-id="0",
   32545    frame=@{addr="0x08048564",func="main",
   32546    args=[@{name="argc",value="1"@},@{name="argv",value="0xbfc4d4d4"@}],
   32547    file="myprog.c",fullname="/home/nickrob/myprog.c",line="68",
   32548    arch="i386:x86_64"@}
   32549 <- (gdb)
   32550 -> -exec-continue
   32551 <- ^running
   32552 <- (gdb)
   32553 <- *stopped,reason="exited-normally"
   32554 <- (gdb)
   32555 @end smallexample
   32556 
   32557 @subheading Quitting @value{GDBN}
   32558 
   32559 Quitting @value{GDBN} just prints the result class @samp{^exit}.
   32560 
   32561 @smallexample
   32562 -> (gdb)
   32563 <- -gdb-exit
   32564 <- ^exit
   32565 @end smallexample
   32566 
   32567 Please note that @samp{^exit} is printed immediately, but it might
   32568 take some time for @value{GDBN} to actually exit.  During that time, @value{GDBN}
   32569 performs necessary cleanups, including killing programs being debugged
   32570 or disconnecting from debug hardware, so the frontend should wait till
   32571 @value{GDBN} exits and should only forcibly kill @value{GDBN} if it
   32572 fails to exit in reasonable time.
   32573 
   32574 @subheading A Bad Command
   32575 
   32576 Here's what happens if you pass a non-existent command:
   32577 
   32578 @smallexample
   32579 -> -rubbish
   32580 <- ^error,msg="Undefined MI command: rubbish"
   32581 <- (gdb)
   32582 @end smallexample
   32583 
   32584 
   32585 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   32586 @node GDB/MI Command Description Format
   32587 @section @sc{gdb/mi} Command Description Format
   32588 
   32589 The remaining sections describe blocks of commands.  Each block of
   32590 commands is laid out in a fashion similar to this section.
   32591 
   32592 @subheading Motivation
   32593 
   32594 The motivation for this collection of commands.
   32595 
   32596 @subheading Introduction
   32597 
   32598 A brief introduction to this collection of commands as a whole.
   32599 
   32600 @subheading Commands
   32601 
   32602 For each command in the block, the following is described:
   32603 
   32604 @subsubheading Synopsis
   32605 
   32606 @smallexample
   32607  -command @var{args}@dots{}
   32608 @end smallexample
   32609 
   32610 @subsubheading Result
   32611 
   32612 @subsubheading @value{GDBN} Command
   32613 
   32614 The corresponding @value{GDBN} CLI command(s), if any.
   32615 
   32616 @subsubheading Example
   32617 
   32618 Example(s) formatted for readability.  Some of the described commands  have
   32619 not been implemented yet and these are labeled N.A.@: (not available).
   32620 
   32621 
   32622 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   32623 @node GDB/MI Breakpoint Commands
   32624 @section @sc{gdb/mi} Breakpoint Commands
   32625 
   32626 @cindex breakpoint commands for @sc{gdb/mi}
   32627 @cindex @sc{gdb/mi}, breakpoint commands
   32628 This section documents @sc{gdb/mi} commands for manipulating
   32629 breakpoints.
   32630 
   32631 @findex -break-after
   32632 @subheading The @code{-break-after} Command
   32633 
   32634 @subsubheading Synopsis
   32635 
   32636 @smallexample
   32637  -break-after @var{number} @var{count}
   32638 @end smallexample
   32639 
   32640 The breakpoint number @var{number} is not in effect until it has been
   32641 hit @var{count} times.  To see how this is reflected in the output of
   32642 the @samp{-break-list} command, see the description of the
   32643 @samp{-break-list} command below.
   32644 
   32645 @subsubheading @value{GDBN} Command
   32646 
   32647 The corresponding @value{GDBN} command is @samp{ignore}.
   32648 
   32649 @subsubheading Example
   32650 
   32651 @smallexample
   32652 (gdb)
   32653 -break-insert main
   32654 ^done,bkpt=@{number="1",type="breakpoint",disp="keep",
   32655 enabled="y",addr="0x000100d0",func="main",file="hello.c",
   32656 fullname="/home/foo/hello.c",line="5",thread-groups=["i1"],
   32657 times="0"@}
   32658 (gdb)
   32659 -break-after 1 3
   32660 ~
   32661 ^done
   32662 (gdb)
   32663 -break-list
   32664 ^done,BreakpointTable=@{nr_rows="1",nr_cols="6",
   32665 hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
   32666 @{width="14",alignment="-1",col_name="type",colhdr="Type"@},
   32667 @{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
   32668 @{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
   32669 @{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
   32670 @{width="40",alignment="2",col_name="what",colhdr="What"@}],
   32671 body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y",
   32672 addr="0x000100d0",func="main",file="hello.c",fullname="/home/foo/hello.c",
   32673 line="5",thread-groups=["i1"],times="0",ignore="3"@}]@}
   32674 (gdb)
   32675 @end smallexample
   32676 
   32677 @ignore
   32678 @findex -break-catch
   32679 @subheading The @code{-break-catch} Command
   32680 @end ignore
   32681 
   32682 @findex -break-commands
   32683 @subheading The @code{-break-commands} Command
   32684 
   32685 @subsubheading Synopsis
   32686 
   32687 @smallexample
   32688  -break-commands @var{number} [ @var{command1} ... @var{commandN} ]
   32689 @end smallexample
   32690 
   32691 Specifies the CLI commands that should be executed when breakpoint
   32692 @var{number} is hit.  The parameters @var{command1} to @var{commandN}
   32693 are the commands.  If no command is specified, any previously-set
   32694 commands are cleared.  @xref{Break Commands}.  Typical use of this
   32695 functionality is tracing a program, that is, printing of values of
   32696 some variables whenever breakpoint is hit and then continuing.
   32697 
   32698 @subsubheading @value{GDBN} Command
   32699 
   32700 The corresponding @value{GDBN} command is @samp{commands}.
   32701 
   32702 @subsubheading Example
   32703 
   32704 @smallexample
   32705 (gdb)
   32706 -break-insert main
   32707 ^done,bkpt=@{number="1",type="breakpoint",disp="keep",
   32708 enabled="y",addr="0x000100d0",func="main",file="hello.c",
   32709 fullname="/home/foo/hello.c",line="5",thread-groups=["i1"],
   32710 times="0"@}
   32711 (gdb)
   32712 -break-commands 1 "print v" "continue"
   32713 ^done
   32714 (gdb)
   32715 @end smallexample
   32716 
   32717 @findex -break-condition
   32718 @subheading The @code{-break-condition} Command
   32719 
   32720 @subsubheading Synopsis
   32721 
   32722 @smallexample
   32723  -break-condition [ --force ] @var{number} [ @var{expr} ]
   32724 @end smallexample
   32725 
   32726 Breakpoint @var{number} will stop the program only if the condition in
   32727 @var{expr} is true.  The condition becomes part of the
   32728 @samp{-break-list} output (see the description of the @samp{-break-list}
   32729 command below).  If the @samp{--force} flag is passed, the condition
   32730 is forcibly defined even when it is invalid for all locations of
   32731 breakpoint @var{number}.  If the @var{expr} argument is omitted,
   32732 breakpoint @var{number} becomes unconditional.
   32733 
   32734 @subsubheading @value{GDBN} Command
   32735 
   32736 The corresponding @value{GDBN} command is @samp{condition}.
   32737 
   32738 @subsubheading Example
   32739 
   32740 @smallexample
   32741 (gdb)
   32742 -break-condition 1 1
   32743 ^done
   32744 (gdb)
   32745 -break-list
   32746 ^done,BreakpointTable=@{nr_rows="1",nr_cols="6",
   32747 hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
   32748 @{width="14",alignment="-1",col_name="type",colhdr="Type"@},
   32749 @{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
   32750 @{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
   32751 @{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
   32752 @{width="40",alignment="2",col_name="what",colhdr="What"@}],
   32753 body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y",
   32754 addr="0x000100d0",func="main",file="hello.c",fullname="/home/foo/hello.c",
   32755 line="5",cond="1",thread-groups=["i1"],times="0",ignore="3"@}]@}
   32756 (gdb)
   32757 @end smallexample
   32758 
   32759 @findex -break-delete
   32760 @subheading The @code{-break-delete} Command
   32761 
   32762 @subsubheading Synopsis
   32763 
   32764 @smallexample
   32765  -break-delete ( @var{breakpoint} )+
   32766 @end smallexample
   32767 
   32768 Delete the breakpoint(s) whose number(s) are specified in the argument
   32769 list.  This is obviously reflected in the breakpoint list.
   32770 
   32771 @subsubheading @value{GDBN} Command
   32772 
   32773 The corresponding @value{GDBN} command is @samp{delete}.
   32774 
   32775 @subsubheading Example
   32776 
   32777 @smallexample
   32778 (gdb)
   32779 -break-delete 1
   32780 ^done
   32781 (gdb)
   32782 -break-list
   32783 ^done,BreakpointTable=@{nr_rows="0",nr_cols="6",
   32784 hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
   32785 @{width="14",alignment="-1",col_name="type",colhdr="Type"@},
   32786 @{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
   32787 @{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
   32788 @{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
   32789 @{width="40",alignment="2",col_name="what",colhdr="What"@}],
   32790 body=[]@}
   32791 (gdb)
   32792 @end smallexample
   32793 
   32794 @findex -break-disable
   32795 @subheading The @code{-break-disable} Command
   32796 
   32797 @subsubheading Synopsis
   32798 
   32799 @smallexample
   32800  -break-disable ( @var{breakpoint} )+
   32801 @end smallexample
   32802 
   32803 Disable the named @var{breakpoint}(s).  The field @samp{enabled} in the
   32804 break list is now set to @samp{n} for the named @var{breakpoint}(s).
   32805 
   32806 @subsubheading @value{GDBN} Command
   32807 
   32808 The corresponding @value{GDBN} command is @samp{disable}.
   32809 
   32810 @subsubheading Example
   32811 
   32812 @smallexample
   32813 (gdb)
   32814 -break-disable 2
   32815 ^done
   32816 (gdb)
   32817 -break-list
   32818 ^done,BreakpointTable=@{nr_rows="1",nr_cols="6",
   32819 hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
   32820 @{width="14",alignment="-1",col_name="type",colhdr="Type"@},
   32821 @{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
   32822 @{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
   32823 @{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
   32824 @{width="40",alignment="2",col_name="what",colhdr="What"@}],
   32825 body=[bkpt=@{number="2",type="breakpoint",disp="keep",enabled="n",
   32826 addr="0x000100d0",func="main",file="hello.c",fullname="/home/foo/hello.c",
   32827 line="5",thread-groups=["i1"],times="0"@}]@}
   32828 (gdb)
   32829 @end smallexample
   32830 
   32831 @findex -break-enable
   32832 @subheading The @code{-break-enable} Command
   32833 
   32834 @subsubheading Synopsis
   32835 
   32836 @smallexample
   32837  -break-enable ( @var{breakpoint} )+
   32838 @end smallexample
   32839 
   32840 Enable (previously disabled) @var{breakpoint}(s).
   32841 
   32842 @subsubheading @value{GDBN} Command
   32843 
   32844 The corresponding @value{GDBN} command is @samp{enable}.
   32845 
   32846 @subsubheading Example
   32847 
   32848 @smallexample
   32849 (gdb)
   32850 -break-enable 2
   32851 ^done
   32852 (gdb)
   32853 -break-list
   32854 ^done,BreakpointTable=@{nr_rows="1",nr_cols="6",
   32855 hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
   32856 @{width="14",alignment="-1",col_name="type",colhdr="Type"@},
   32857 @{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
   32858 @{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
   32859 @{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
   32860 @{width="40",alignment="2",col_name="what",colhdr="What"@}],
   32861 body=[bkpt=@{number="2",type="breakpoint",disp="keep",enabled="y",
   32862 addr="0x000100d0",func="main",file="hello.c",fullname="/home/foo/hello.c",
   32863 line="5",thread-groups=["i1"],times="0"@}]@}
   32864 (gdb)
   32865 @end smallexample
   32866 
   32867 @findex -break-info
   32868 @subheading The @code{-break-info} Command
   32869 
   32870 @subsubheading Synopsis
   32871 
   32872 @smallexample
   32873  -break-info @var{breakpoint}
   32874 @end smallexample
   32875 
   32876 @c REDUNDANT???
   32877 Get information about a single breakpoint.
   32878 
   32879 The result is a table of breakpoints.  @xref{GDB/MI Breakpoint
   32880 Information}, for details on the format of each breakpoint in the
   32881 table.
   32882 
   32883 @subsubheading @value{GDBN} Command
   32884 
   32885 The corresponding @value{GDBN} command is @samp{info break @var{breakpoint}}.
   32886 
   32887 @subsubheading Example
   32888 N.A.
   32889 
   32890 @findex -break-insert
   32891 @anchor{-break-insert}
   32892 @subheading The @code{-break-insert} Command
   32893 
   32894 @subsubheading Synopsis
   32895 
   32896 @smallexample
   32897  -break-insert [ -t ] [ -h ] [ -f ] [ -d ] [ -a ] [ --qualified ]
   32898     [ -c @var{condition} ] [ --force-condition ] [ -i @var{ignore-count} ]
   32899     [ -p @var{thread-id} ] [ -g @var{thread-group-id} ] [ @var{locspec} ]
   32900 @end smallexample
   32901 
   32902 @noindent
   32903 If specified, @var{locspec}, can be one of:
   32904 
   32905 @table @var
   32906 @item linespec location
   32907 A linespec location.  @xref{Linespec Locations}.
   32908 
   32909 @item explicit location
   32910 An explicit location.  @sc{gdb/mi} explicit locations are
   32911 analogous to the CLI's explicit locations using the option names
   32912 listed below.  @xref{Explicit Locations}.
   32913 
   32914 @table @samp
   32915 @item --source @var{filename}
   32916 The source file name of the location.  This option requires the use
   32917 of either @samp{--function} or @samp{--line}.
   32918 
   32919 @item --function @var{function}
   32920 The name of a function or method.
   32921 
   32922 @item --label @var{label}
   32923 The name of a label.
   32924 
   32925 @item --line @var{lineoffset}
   32926 An absolute or relative line offset from the start of the location.
   32927 @end table
   32928 
   32929 @item address location
   32930 An address location, *@var{address}.  @xref{Address Locations}.
   32931 @end table
   32932 
   32933 @noindent
   32934 The possible optional parameters of this command are:
   32935 
   32936 @table @samp
   32937 @item -t
   32938 Insert a temporary breakpoint.
   32939 @item -h
   32940 Insert a hardware breakpoint.
   32941 @item -f
   32942 If @var{locspec} cannot be resolved (for example if it
   32943 refers to unknown files or functions), create a pending
   32944 breakpoint.  Without this flag, @value{GDBN} will report
   32945 an error, and won't create a breakpoint, if @var{locspec}
   32946 cannot be parsed.
   32947 @item -d
   32948 Create a disabled breakpoint.
   32949 @item -a
   32950 Create a tracepoint.  @xref{Tracepoints}.  When this parameter
   32951 is used together with @samp{-h}, a fast tracepoint is created.
   32952 @item -c @var{condition}
   32953 Make the breakpoint conditional on @var{condition}.
   32954 @item --force-condition
   32955 Forcibly define the breakpoint even if the condition is invalid at
   32956 all of the breakpoint locations.
   32957 @item -i @var{ignore-count}
   32958 Initialize the @var{ignore-count}.
   32959 @item -p @var{thread-id}
   32960 Restrict the breakpoint to the thread with the specified global
   32961 @var{thread-id}.  @var{thread-id} must be a valid thread-id at the
   32962 time the breakpoint is requested.  Breakpoints created with a
   32963 @var{thread-id} will automatically be deleted when the corresponding
   32964 thread exits.
   32965 @item -g @var{thread-group-id}
   32966 Restrict the breakpoint to the thread group with the specified
   32967 @var{thread-group-id}.
   32968 @item --qualified
   32969 This option makes @value{GDBN} interpret a function name specified as
   32970 a complete fully-qualified name.
   32971 @end table
   32972 
   32973 @subsubheading Result
   32974 
   32975 @xref{GDB/MI Breakpoint Information}, for details on the format of the
   32976 resulting breakpoint.
   32977 
   32978 Note: this format is open to change.
   32979 @c An out-of-band breakpoint instead of part of the result?
   32980 
   32981 @subsubheading @value{GDBN} Command
   32982 
   32983 The corresponding @value{GDBN} commands are @samp{break}, @samp{tbreak},
   32984 @samp{hbreak}, and @samp{thbreak}. @c and @samp{rbreak}.
   32985 
   32986 @subsubheading Example
   32987 
   32988 @smallexample
   32989 (gdb)
   32990 -break-insert main
   32991 ^done,bkpt=@{number="1",addr="0x0001072c",file="recursive2.c",
   32992 fullname="/home/foo/recursive2.c,line="4",thread-groups=["i1"],
   32993 times="0"@}
   32994 (gdb)
   32995 -break-insert -t foo
   32996 ^done,bkpt=@{number="2",addr="0x00010774",file="recursive2.c",
   32997 fullname="/home/foo/recursive2.c,line="11",thread-groups=["i1"],
   32998 times="0"@}
   32999 (gdb)
   33000 -break-list
   33001 ^done,BreakpointTable=@{nr_rows="2",nr_cols="6",
   33002 hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
   33003 @{width="14",alignment="-1",col_name="type",colhdr="Type"@},
   33004 @{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
   33005 @{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
   33006 @{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
   33007 @{width="40",alignment="2",col_name="what",colhdr="What"@}],
   33008 body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y",
   33009 addr="0x0001072c", func="main",file="recursive2.c",
   33010 fullname="/home/foo/recursive2.c,"line="4",thread-groups=["i1"],
   33011 times="0"@},
   33012 bkpt=@{number="2",type="breakpoint",disp="del",enabled="y",
   33013 addr="0x00010774",func="foo",file="recursive2.c",
   33014 fullname="/home/foo/recursive2.c",line="11",thread-groups=["i1"],
   33015 times="0"@}]@}
   33016 (gdb)
   33017 @end smallexample
   33018 
   33019 @findex -dprintf-insert
   33020 @subheading The @code{-dprintf-insert} Command
   33021 
   33022 @subsubheading Synopsis
   33023 
   33024 @smallexample
   33025  -dprintf-insert [ -t ] [ -f ] [ -d ] [ --qualified ]
   33026     [ -c @var{condition} ] [--force-condition] [ -i @var{ignore-count} ]
   33027     [ -p @var{thread-id} ] [ @var{locspec} ] @var{format}
   33028     [ @var{argument}@dots{} ]
   33029 @end smallexample
   33030 
   33031 @noindent
   33032 Insert a new dynamic print breakpoint at the given location.
   33033 @xref{Dynamic Printf}.  @var{format} is the format to use, and any
   33034 remaining arguments are passed as expressions to substitute.
   33035 
   33036 @noindent
   33037 If supplied, @var{locspec} and @code{--qualified} may be specified
   33038 the same way as for the @code{-break-insert} command.
   33039 @xref{-break-insert}.
   33040 
   33041 The possible optional parameters of this command are:
   33042 
   33043 @table @samp
   33044 @item -t
   33045 Insert a temporary breakpoint.
   33046 @item -f
   33047 If @var{locspec} cannot be parsed (for example, if it
   33048 refers to unknown files or functions), create a pending
   33049 breakpoint.  Without this flag, @value{GDBN} will report
   33050 an error, and won't create a breakpoint, if @var{locspec}
   33051 cannot be parsed.
   33052 @item -d
   33053 Create a disabled breakpoint.
   33054 @item -c @var{condition}
   33055 Make the breakpoint conditional on @var{condition}.
   33056 @item --force-condition
   33057 Forcibly define the breakpoint even if the condition is invalid at
   33058 all of the breakpoint locations.
   33059 @item -i @var{ignore-count}
   33060 Set the ignore count of the breakpoint (@pxref{Conditions, ignore count})
   33061 to @var{ignore-count}.
   33062 @item -p @var{thread-id}
   33063 Restrict the breakpoint to the thread with the specified global
   33064 @var{thread-id}.
   33065 @end table
   33066 
   33067 @subsubheading Result
   33068 
   33069 @xref{GDB/MI Breakpoint Information}, for details on the format of the
   33070 resulting breakpoint.
   33071 
   33072 @c An out-of-band breakpoint instead of part of the result?
   33073 
   33074 @subsubheading @value{GDBN} Command
   33075 
   33076 The corresponding @value{GDBN} command is @samp{dprintf}.
   33077 
   33078 @subsubheading Example
   33079 
   33080 @smallexample
   33081 (gdb)
   33082 4-dprintf-insert foo "At foo entry\n"
   33083 4^done,bkpt=@{number="1",type="dprintf",disp="keep",enabled="y",
   33084 addr="0x000000000040061b",func="foo",file="mi-dprintf.c",
   33085 fullname="mi-dprintf.c",line="25",thread-groups=["i1"],
   33086 times="0",script=["printf \"At foo entry\\n\"","continue"],
   33087 original-location="foo"@}
   33088 (gdb)
   33089 5-dprintf-insert 26 "arg=%d, g=%d\n" arg g
   33090 5^done,bkpt=@{number="2",type="dprintf",disp="keep",enabled="y",
   33091 addr="0x000000000040062a",func="foo",file="mi-dprintf.c",
   33092 fullname="mi-dprintf.c",line="26",thread-groups=["i1"],
   33093 times="0",script=["printf \"arg=%d, g=%d\\n\", arg, g","continue"],
   33094 original-location="mi-dprintf.c:26"@}
   33095 (gdb)
   33096 @end smallexample
   33097 
   33098 @findex -break-list
   33099 @subheading The @code{-break-list} Command
   33100 
   33101 @subsubheading Synopsis
   33102 
   33103 @smallexample
   33104  -break-list
   33105 @end smallexample
   33106 
   33107 Displays the list of inserted breakpoints, showing the following fields:
   33108 
   33109 @table @samp
   33110 @item Number
   33111 number of the breakpoint
   33112 @item Type
   33113 type of the breakpoint: @samp{breakpoint} or @samp{watchpoint}
   33114 @item Disposition
   33115 should the breakpoint be deleted or disabled when it is hit: @samp{keep}
   33116 or @samp{nokeep}
   33117 @item Enabled
   33118 is the breakpoint enabled or no: @samp{y} or @samp{n}
   33119 @item Address
   33120 memory location at which the breakpoint is set
   33121 @item What
   33122 logical location of the breakpoint, expressed by function name, file
   33123 name, line number
   33124 @item Thread-groups
   33125 list of thread groups to which this breakpoint applies
   33126 @item Times
   33127 number of times the breakpoint has been hit
   33128 @end table
   33129 
   33130 If there are no breakpoints, watchpoints, tracepoints, or catchpoints,
   33131 the @code{BreakpointTable} @code{body} field is an empty list.
   33132 
   33133 @subsubheading @value{GDBN} Command
   33134 
   33135 The corresponding @value{GDBN} command is @samp{info break}.
   33136 
   33137 @subsubheading Example
   33138 
   33139 @smallexample
   33140 (gdb)
   33141 -break-list
   33142 ^done,BreakpointTable=@{nr_rows="2",nr_cols="6",
   33143 hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
   33144 @{width="14",alignment="-1",col_name="type",colhdr="Type"@},
   33145 @{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
   33146 @{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
   33147 @{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
   33148 @{width="40",alignment="2",col_name="what",colhdr="What"@}],
   33149 body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y",
   33150 addr="0x000100d0",func="main",file="hello.c",line="5",thread-groups=["i1"],
   33151 times="0"@},
   33152 bkpt=@{number="2",type="breakpoint",disp="keep",enabled="y",
   33153 addr="0x00010114",func="foo",file="hello.c",fullname="/home/foo/hello.c",
   33154 line="13",thread-groups=["i1"],times="0"@}]@}
   33155 (gdb)
   33156 @end smallexample
   33157 
   33158 Here's an example of the result when there are no breakpoints:
   33159 
   33160 @smallexample
   33161 (gdb)
   33162 -break-list
   33163 ^done,BreakpointTable=@{nr_rows="0",nr_cols="6",
   33164 hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
   33165 @{width="14",alignment="-1",col_name="type",colhdr="Type"@},
   33166 @{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
   33167 @{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
   33168 @{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
   33169 @{width="40",alignment="2",col_name="what",colhdr="What"@}],
   33170 body=[]@}
   33171 (gdb)
   33172 @end smallexample
   33173 
   33174 @findex -break-passcount
   33175 @subheading The @code{-break-passcount} Command
   33176 
   33177 @subsubheading Synopsis
   33178 
   33179 @smallexample
   33180  -break-passcount @var{tracepoint-number} @var{passcount}
   33181 @end smallexample
   33182 
   33183 Set the passcount for tracepoint @var{tracepoint-number} to
   33184 @var{passcount}.  If the breakpoint referred to by @var{tracepoint-number}
   33185 is not a tracepoint, error is emitted.  This corresponds to CLI
   33186 command @samp{passcount}.
   33187 
   33188 @findex -break-watch
   33189 @subheading The @code{-break-watch} Command
   33190 
   33191 @subsubheading Synopsis
   33192 
   33193 @smallexample
   33194  -break-watch [ -a | -r ]
   33195 @end smallexample
   33196 
   33197 Create a watchpoint.  With the @samp{-a} option it will create an
   33198 @dfn{access} watchpoint, i.e., a watchpoint that triggers either on a
   33199 read from or on a write to the memory location.  With the @samp{-r}
   33200 option, the watchpoint created is a @dfn{read} watchpoint, i.e., it will
   33201 trigger only when the memory location is accessed for reading.  Without
   33202 either of the options, the watchpoint created is a regular watchpoint,
   33203 i.e., it will trigger when the memory location is accessed for writing.
   33204 @xref{Set Watchpoints, , Setting Watchpoints}.
   33205 
   33206 Note that @samp{-break-list} will report a single list of watchpoints and
   33207 breakpoints inserted.
   33208 
   33209 @subsubheading @value{GDBN} Command
   33210 
   33211 The corresponding @value{GDBN} commands are @samp{watch}, @samp{awatch}, and
   33212 @samp{rwatch}.
   33213 
   33214 @subsubheading Example
   33215 
   33216 Setting a watchpoint on a variable in the @code{main} function:
   33217 
   33218 @smallexample
   33219 (gdb)
   33220 -break-watch x
   33221 ^done,wpt=@{number="2",exp="x"@}
   33222 (gdb)
   33223 -exec-continue
   33224 ^running
   33225 (gdb)
   33226 *stopped,reason="watchpoint-trigger",wpt=@{number="2",exp="x"@},
   33227 value=@{old="-268439212",new="55"@},
   33228 frame=@{func="main",args=[],file="recursive2.c",
   33229 fullname="/home/foo/bar/recursive2.c",line="5",arch="i386:x86_64"@}
   33230 (gdb)
   33231 @end smallexample
   33232 
   33233 Setting a watchpoint on a variable local to a function.  @value{GDBN} will stop
   33234 the program execution twice: first for the variable changing value, then
   33235 for the watchpoint going out of scope.
   33236 
   33237 @smallexample
   33238 (gdb)
   33239 -break-watch C
   33240 ^done,wpt=@{number="5",exp="C"@}
   33241 (gdb)
   33242 -exec-continue
   33243 ^running
   33244 (gdb)
   33245 *stopped,reason="watchpoint-trigger",
   33246 wpt=@{number="5",exp="C"@},value=@{old="-276895068",new="3"@},
   33247 frame=@{func="callee4",args=[],
   33248 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
   33249 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="13",
   33250 arch="i386:x86_64"@}
   33251 (gdb)
   33252 -exec-continue
   33253 ^running
   33254 (gdb)
   33255 *stopped,reason="watchpoint-scope",wpnum="5",
   33256 frame=@{func="callee3",args=[@{name="strarg",
   33257 value="0x11940 \"A string argument.\""@}],
   33258 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
   33259 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="18",
   33260 arch="i386:x86_64"@}
   33261 (gdb)
   33262 @end smallexample
   33263 
   33264 Listing breakpoints and watchpoints, at different points in the program
   33265 execution.  Note that once the watchpoint goes out of scope, it is
   33266 deleted.
   33267 
   33268 @smallexample
   33269 (gdb)
   33270 -break-watch C
   33271 ^done,wpt=@{number="2",exp="C"@}
   33272 (gdb)
   33273 -break-list
   33274 ^done,BreakpointTable=@{nr_rows="2",nr_cols="6",
   33275 hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
   33276 @{width="14",alignment="-1",col_name="type",colhdr="Type"@},
   33277 @{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
   33278 @{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
   33279 @{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
   33280 @{width="40",alignment="2",col_name="what",colhdr="What"@}],
   33281 body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y",
   33282 addr="0x00010734",func="callee4",
   33283 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
   33284 fullname="/home/foo/devo/gdb/testsuite/gdb.mi/basics.c"line="8",thread-groups=["i1"],
   33285 times="1"@},
   33286 bkpt=@{number="2",type="watchpoint",disp="keep",
   33287 enabled="y",addr="",what="C",thread-groups=["i1"],times="0"@}]@}
   33288 (gdb)
   33289 -exec-continue
   33290 ^running
   33291 (gdb)
   33292 *stopped,reason="watchpoint-trigger",wpt=@{number="2",exp="C"@},
   33293 value=@{old="-276895068",new="3"@},
   33294 frame=@{func="callee4",args=[],
   33295 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
   33296 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="13",
   33297 arch="i386:x86_64"@}
   33298 (gdb)
   33299 -break-list
   33300 ^done,BreakpointTable=@{nr_rows="2",nr_cols="6",
   33301 hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
   33302 @{width="14",alignment="-1",col_name="type",colhdr="Type"@},
   33303 @{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
   33304 @{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
   33305 @{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
   33306 @{width="40",alignment="2",col_name="what",colhdr="What"@}],
   33307 body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y",
   33308 addr="0x00010734",func="callee4",
   33309 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
   33310 fullname="/home/foo/devo/gdb/testsuite/gdb.mi/basics.c",line="8",thread-groups=["i1"],
   33311 times="1"@},
   33312 bkpt=@{number="2",type="watchpoint",disp="keep",
   33313 enabled="y",addr="",what="C",thread-groups=["i1"],times="-5"@}]@}
   33314 (gdb)
   33315 -exec-continue
   33316 ^running
   33317 ^done,reason="watchpoint-scope",wpnum="2",
   33318 frame=@{func="callee3",args=[@{name="strarg",
   33319 value="0x11940 \"A string argument.\""@}],
   33320 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
   33321 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="18",
   33322 arch="i386:x86_64"@}
   33323 (gdb)
   33324 -break-list
   33325 ^done,BreakpointTable=@{nr_rows="1",nr_cols="6",
   33326 hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
   33327 @{width="14",alignment="-1",col_name="type",colhdr="Type"@},
   33328 @{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
   33329 @{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
   33330 @{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
   33331 @{width="40",alignment="2",col_name="what",colhdr="What"@}],
   33332 body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y",
   33333 addr="0x00010734",func="callee4",
   33334 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
   33335 fullname="/home/foo/devo/gdb/testsuite/gdb.mi/basics.c",line="8",
   33336 thread-groups=["i1"],times="1"@}]@}
   33337 (gdb)
   33338 @end smallexample
   33339 
   33340 
   33341 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   33342 @node GDB/MI Catchpoint Commands
   33343 @section @sc{gdb/mi} Catchpoint Commands
   33344 
   33345 This section documents @sc{gdb/mi} commands for manipulating
   33346 catchpoints.
   33347 
   33348 @menu
   33349 * Shared Library GDB/MI Catchpoint Commands::
   33350 * Ada Exception GDB/MI Catchpoint Commands::
   33351 * C++ Exception GDB/MI Catchpoint Commands::
   33352 @end menu
   33353 
   33354 @node Shared Library GDB/MI Catchpoint Commands
   33355 @subsection Shared Library @sc{gdb/mi} Catchpoints
   33356 
   33357 @findex -catch-load
   33358 @subheading The @code{-catch-load} Command
   33359 
   33360 @subsubheading Synopsis
   33361 
   33362 @smallexample
   33363  -catch-load [ -t ] [ -d ] @var{regexp}
   33364 @end smallexample
   33365 
   33366 Add a catchpoint for library load events.  If the @samp{-t} option is used,
   33367 the catchpoint is a temporary one (@pxref{Set Breaks, ,Setting
   33368 Breakpoints}).  If the @samp{-d} option is used, the catchpoint is created
   33369 in a disabled state.  The @samp{regexp} argument is a regular
   33370 expression used to match the name of the loaded library.
   33371 
   33372 
   33373 @subsubheading @value{GDBN} Command
   33374 
   33375 The corresponding @value{GDBN} command is @samp{catch load}.
   33376 
   33377 @subsubheading Example
   33378 
   33379 @smallexample
   33380 -catch-load -t foo.so
   33381 ^done,bkpt=@{number="1",type="catchpoint",disp="del",enabled="y",
   33382 what="load of library matching foo.so",catch-type="load",times="0"@}
   33383 (gdb)
   33384 @end smallexample
   33385 
   33386 
   33387 @findex -catch-unload
   33388 @subheading The @code{-catch-unload} Command
   33389 
   33390 @subsubheading Synopsis
   33391 
   33392 @smallexample
   33393  -catch-unload [ -t ] [ -d ] @var{regexp}
   33394 @end smallexample
   33395 
   33396 Add a catchpoint for library unload events.  If the @samp{-t} option is
   33397 used, the catchpoint is a temporary one (@pxref{Set Breaks, ,Setting
   33398 Breakpoints}).  If the @samp{-d} option is used, the catchpoint is
   33399 created in a disabled state.  The @samp{regexp} argument is a regular
   33400 expression used to match the name of the unloaded library.
   33401 
   33402 @subsubheading @value{GDBN} Command
   33403 
   33404 The corresponding @value{GDBN} command is @samp{catch unload}.
   33405 
   33406 @subsubheading Example
   33407 
   33408 @smallexample
   33409 -catch-unload -d bar.so
   33410 ^done,bkpt=@{number="2",type="catchpoint",disp="keep",enabled="n",
   33411 what="load of library matching bar.so",catch-type="unload",times="0"@}
   33412 (gdb)
   33413 @end smallexample
   33414 
   33415 @node Ada Exception GDB/MI Catchpoint Commands
   33416 @subsection Ada Exception @sc{gdb/mi} Catchpoints
   33417 
   33418 The following @sc{gdb/mi} commands can be used to create catchpoints
   33419 that stop the execution when Ada exceptions are being raised.
   33420 
   33421 @findex -catch-assert
   33422 @subheading The @code{-catch-assert} Command
   33423 
   33424 @subsubheading Synopsis
   33425 
   33426 @smallexample
   33427  -catch-assert [ -c @var{condition}] [ -d ] [ -t ]
   33428 @end smallexample
   33429 
   33430 Add a catchpoint for failed Ada assertions.
   33431 
   33432 The possible optional parameters for this command are:
   33433 
   33434 @table @samp
   33435 @item -c @var{condition}
   33436 Make the catchpoint conditional on @var{condition}.
   33437 @item -d
   33438 Create a disabled catchpoint.
   33439 @item -t
   33440 Create a temporary catchpoint.
   33441 @end table
   33442 
   33443 @subsubheading @value{GDBN} Command
   33444 
   33445 The corresponding @value{GDBN} command is @samp{catch assert}.
   33446 
   33447 @subsubheading Example
   33448 
   33449 @smallexample
   33450 -catch-assert
   33451 ^done,bkptno="5",bkpt=@{number="5",type="breakpoint",disp="keep",
   33452 enabled="y",addr="0x0000000000404888",what="failed Ada assertions",
   33453 thread-groups=["i1"],times="0",
   33454 original-location="__gnat_debug_raise_assert_failure"@}
   33455 (gdb)
   33456 @end smallexample
   33457 
   33458 @findex -catch-exception
   33459 @subheading The @code{-catch-exception} Command
   33460 
   33461 @subsubheading Synopsis
   33462 
   33463 @smallexample
   33464  -catch-exception [ -c @var{condition}] [ -d ] [ -e @var{exception-name} ]
   33465     [ -t ] [ -u ]
   33466 @end smallexample
   33467 
   33468 Add a catchpoint stopping when Ada exceptions are raised.
   33469 By default, the command stops the program when any Ada exception
   33470 gets raised.  But it is also possible, by using some of the
   33471 optional parameters described below, to create more selective
   33472 catchpoints.
   33473 
   33474 The possible optional parameters for this command are:
   33475 
   33476 @table @samp
   33477 @item -c @var{condition}
   33478 Make the catchpoint conditional on @var{condition}.
   33479 @item -d
   33480 Create a disabled catchpoint.
   33481 @item -e @var{exception-name}
   33482 Only stop when @var{exception-name} is raised.  This option cannot
   33483 be used combined with @samp{-u}.
   33484 @item -t
   33485 Create a temporary catchpoint.
   33486 @item -u
   33487 Stop only when an unhandled exception gets raised.  This option
   33488 cannot be used combined with @samp{-e}.
   33489 @end table
   33490 
   33491 @subsubheading @value{GDBN} Command
   33492 
   33493 The corresponding @value{GDBN} commands are @samp{catch exception}
   33494 and @samp{catch exception unhandled}.
   33495 
   33496 @subsubheading Example
   33497 
   33498 @smallexample
   33499 -catch-exception -e Program_Error
   33500 ^done,bkptno="4",bkpt=@{number="4",type="breakpoint",disp="keep",
   33501 enabled="y",addr="0x0000000000404874",
   33502 what="`Program_Error' Ada exception", thread-groups=["i1"],
   33503 times="0",original-location="__gnat_debug_raise_exception"@}
   33504 (gdb)
   33505 @end smallexample
   33506 
   33507 @findex -catch-handlers
   33508 @subheading The @code{-catch-handlers} Command
   33509 
   33510 @subsubheading Synopsis
   33511 
   33512 @smallexample
   33513  -catch-handlers [ -c @var{condition}] [ -d ] [ -e @var{exception-name} ]
   33514     [ -t ]
   33515 @end smallexample
   33516 
   33517 Add a catchpoint stopping when Ada exceptions are handled.
   33518 By default, the command stops the program when any Ada exception
   33519 gets handled.  But it is also possible, by using some of the
   33520 optional parameters described below, to create more selective
   33521 catchpoints.
   33522 
   33523 The possible optional parameters for this command are:
   33524 
   33525 @table @samp
   33526 @item -c @var{condition}
   33527 Make the catchpoint conditional on @var{condition}.
   33528 @item -d
   33529 Create a disabled catchpoint.
   33530 @item -e @var{exception-name}
   33531 Only stop when @var{exception-name} is handled.
   33532 @item -t
   33533 Create a temporary catchpoint.
   33534 @end table
   33535 
   33536 @subsubheading @value{GDBN} Command
   33537 
   33538 The corresponding @value{GDBN} command is @samp{catch handlers}.
   33539 
   33540 @subsubheading Example
   33541 
   33542 @smallexample
   33543 -catch-handlers -e Constraint_Error
   33544 ^done,bkptno="4",bkpt=@{number="4",type="breakpoint",disp="keep",
   33545 enabled="y",addr="0x0000000000402f68",
   33546 what="`Constraint_Error' Ada exception handlers",thread-groups=["i1"],
   33547 times="0",original-location="__gnat_begin_handler"@}
   33548 (gdb)
   33549 @end smallexample
   33550 
   33551 @node C++ Exception GDB/MI Catchpoint Commands
   33552 @subsection C@t{++} Exception @sc{gdb/mi} Catchpoints
   33553 
   33554 The following @sc{gdb/mi} commands can be used to create catchpoints
   33555 that stop the execution when C@t{++} exceptions are being throw, rethrown,
   33556 or caught.
   33557 
   33558 @findex -catch-throw
   33559 @subheading The @code{-catch-throw} Command
   33560 
   33561 @subsubheading Synopsis
   33562 
   33563 @smallexample
   33564  -catch-throw [ -t ] [ -r @var{regexp}]
   33565 @end smallexample
   33566 
   33567 Stop when the debuggee throws a C@t{++} exception.  If @var{regexp} is
   33568 given, then only exceptions whose type matches the regular expression
   33569 will be caught.
   33570 
   33571 If @samp{-t} is given, then the catchpoint is enabled only for one
   33572 stop, the catchpoint is automatically deleted after stopping once for
   33573 the event.
   33574 
   33575 @subsubheading @value{GDBN} Command
   33576 
   33577 The corresponding @value{GDBN} commands are @samp{catch throw}
   33578 and @samp{tcatch throw} (@pxref{Set Catchpoints}).
   33579 
   33580 @subsubheading Example
   33581 
   33582 @smallexample
   33583 -catch-throw -r exception_type
   33584 ^done,bkpt=@{number="1",type="catchpoint",disp="keep",enabled="y",
   33585   what="exception throw",catch-type="throw",
   33586   thread-groups=["i1"],
   33587   regexp="exception_type",times="0"@}
   33588 (gdb)
   33589 -exec-run
   33590 ^running
   33591 (gdb)
   33592 ~"\n"
   33593 ~"Catchpoint 1 (exception thrown), 0x00007ffff7ae00ed
   33594   in __cxa_throw () from /lib64/libstdc++.so.6\n"
   33595 *stopped,bkptno="1",reason="breakpoint-hit",disp="keep",
   33596   frame=@{addr="0x00007ffff7ae00ed",func="__cxa_throw",
   33597   args=[],from="/lib64/libstdc++.so.6",arch="i386:x86-64"@},
   33598   thread-id="1",stopped-threads="all",core="6"
   33599 (gdb)
   33600 @end smallexample
   33601 
   33602 @findex -catch-rethrow
   33603 @subheading The @code{-catch-rethrow} Command
   33604 
   33605 @subsubheading Synopsis
   33606 
   33607 @smallexample
   33608  -catch-rethrow [ -t ] [ -r @var{regexp}]
   33609 @end smallexample
   33610 
   33611 Stop when a C@t{++} exception is re-thrown.  If @var{regexp} is given,
   33612 then only exceptions whose type matches the regular expression will be
   33613 caught.
   33614 
   33615 If @samp{-t} is given, then the catchpoint is enabled only for one
   33616 stop, the catchpoint is automatically deleted after the first event is
   33617 caught.
   33618 
   33619 @subsubheading @value{GDBN} Command
   33620 
   33621 The corresponding @value{GDBN} commands are @samp{catch rethrow}
   33622 and @samp{tcatch rethrow} (@pxref{Set Catchpoints}).
   33623 
   33624 @subsubheading Example
   33625 
   33626 @smallexample
   33627 -catch-rethrow -r exception_type
   33628 ^done,bkpt=@{number="1",type="catchpoint",disp="keep",enabled="y",
   33629   what="exception rethrow",catch-type="rethrow",
   33630   thread-groups=["i1"],
   33631   regexp="exception_type",times="0"@}
   33632 (gdb)
   33633 -exec-run
   33634 ^running
   33635 (gdb)
   33636 ~"\n"
   33637 ~"Catchpoint 1 (exception rethrown), 0x00007ffff7ae00ed
   33638   in __cxa_rethrow () from /lib64/libstdc++.so.6\n"
   33639 *stopped,bkptno="1",reason="breakpoint-hit",disp="keep",
   33640   frame=@{addr="0x00007ffff7ae00ed",func="__cxa_rethrow",
   33641   args=[],from="/lib64/libstdc++.so.6",arch="i386:x86-64"@},
   33642   thread-id="1",stopped-threads="all",core="6"
   33643 (gdb)
   33644 @end smallexample
   33645 
   33646 @findex -catch-catch
   33647 @subheading The @code{-catch-catch} Command
   33648 
   33649 @subsubheading Synopsis
   33650 
   33651 @smallexample
   33652  -catch-catch [ -t ] [ -r @var{regexp}]
   33653 @end smallexample
   33654 
   33655 Stop when the debuggee catches a C@t{++} exception.  If @var{regexp}
   33656 is given, then only exceptions whose type matches the regular
   33657 expression will be caught.
   33658 
   33659 If @samp{-t} is given, then the catchpoint is enabled only for one
   33660 stop, the catchpoint is automatically deleted after the first event is
   33661 caught.
   33662 
   33663 @subsubheading @value{GDBN} Command
   33664 
   33665 The corresponding @value{GDBN} commands are @samp{catch catch}
   33666 and @samp{tcatch catch} (@pxref{Set Catchpoints}).
   33667 
   33668 @subsubheading Example
   33669 
   33670 @smallexample
   33671 -catch-catch -r exception_type
   33672 ^done,bkpt=@{number="1",type="catchpoint",disp="keep",enabled="y",
   33673   what="exception catch",catch-type="catch",
   33674   thread-groups=["i1"],
   33675   regexp="exception_type",times="0"@}
   33676 (gdb)
   33677 -exec-run
   33678 ^running
   33679 (gdb)
   33680 ~"\n"
   33681 ~"Catchpoint 1 (exception caught), 0x00007ffff7ae00ed
   33682   in __cxa_begin_catch () from /lib64/libstdc++.so.6\n"
   33683 *stopped,bkptno="1",reason="breakpoint-hit",disp="keep",
   33684   frame=@{addr="0x00007ffff7ae00ed",func="__cxa_begin_catch",
   33685   args=[],from="/lib64/libstdc++.so.6",arch="i386:x86-64"@},
   33686   thread-id="1",stopped-threads="all",core="6"
   33687 (gdb)
   33688 @end smallexample
   33689 
   33690 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   33691 @node GDB/MI Program Context
   33692 @section @sc{gdb/mi}  Program Context
   33693 
   33694 @findex -exec-arguments
   33695 @subheading The @code{-exec-arguments} Command
   33696 
   33697 
   33698 @subsubheading Synopsis
   33699 
   33700 @smallexample
   33701  -exec-arguments @var{args}
   33702 @end smallexample
   33703 
   33704 Set the inferior program arguments, to be used in the next
   33705 @samp{-exec-run}.
   33706 
   33707 @subsubheading @value{GDBN} Command
   33708 
   33709 The corresponding @value{GDBN} command is @samp{set args}.
   33710 
   33711 @subsubheading Example
   33712 
   33713 @smallexample
   33714 (gdb)
   33715 -exec-arguments -v word
   33716 ^done
   33717 (gdb)
   33718 @end smallexample
   33719 
   33720 
   33721 @ignore
   33722 @findex -exec-show-arguments
   33723 @subheading The @code{-exec-show-arguments} Command
   33724 
   33725 @subsubheading Synopsis
   33726 
   33727 @smallexample
   33728  -exec-show-arguments
   33729 @end smallexample
   33730 
   33731 Print the arguments of the program.
   33732 
   33733 @subsubheading @value{GDBN} Command
   33734 
   33735 The corresponding @value{GDBN} command is @samp{show args}.
   33736 
   33737 @subsubheading Example
   33738 N.A.
   33739 @end ignore
   33740 
   33741 
   33742 @findex -environment-cd
   33743 @subheading The @code{-environment-cd} Command
   33744 
   33745 @subsubheading Synopsis
   33746 
   33747 @smallexample
   33748  -environment-cd @var{pathdir}
   33749 @end smallexample
   33750 
   33751 Set @value{GDBN}'s working directory.
   33752 
   33753 @subsubheading @value{GDBN} Command
   33754 
   33755 The corresponding @value{GDBN} command is @samp{cd}.
   33756 
   33757 @subsubheading Example
   33758 
   33759 @smallexample
   33760 (gdb)
   33761 -environment-cd /kwikemart/marge/ezannoni/flathead-dev/devo/gdb
   33762 ^done
   33763 (gdb)
   33764 @end smallexample
   33765 
   33766 
   33767 @findex -environment-directory
   33768 @subheading The @code{-environment-directory} Command
   33769 
   33770 @subsubheading Synopsis
   33771 
   33772 @smallexample
   33773  -environment-directory [ -r ] [ @var{pathdir} ]+
   33774 @end smallexample
   33775 
   33776 Add directories @var{pathdir} to beginning of search path for source files.
   33777 If the @samp{-r} option is used, the search path is reset to the default
   33778 search path.  If directories @var{pathdir} are supplied in addition to the
   33779 @samp{-r} option, the search path is first reset and then addition
   33780 occurs as normal.
   33781 Multiple directories may be specified, separated by blanks.  Specifying
   33782 multiple directories in a single command
   33783 results in the directories added to the beginning of the
   33784 search path in the same order they were presented in the command.
   33785 If blanks are needed as
   33786 part of a directory name, double-quotes should be used around
   33787 the name.  In the command output, the path will show up separated
   33788 by the system directory-separator character.  The directory-separator
   33789 character must not be used
   33790 in any directory name.
   33791 If no directories are specified, the current search path is displayed.
   33792 
   33793 @subsubheading @value{GDBN} Command
   33794 
   33795 The corresponding @value{GDBN} command is @samp{dir}.
   33796 
   33797 @subsubheading Example
   33798 
   33799 @smallexample
   33800 (gdb)
   33801 -environment-directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb
   33802 ^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
   33803 (gdb)
   33804 -environment-directory ""
   33805 ^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
   33806 (gdb)
   33807 -environment-directory -r /home/jjohnstn/src/gdb /usr/src
   33808 ^done,source-path="/home/jjohnstn/src/gdb:/usr/src:$cdir:$cwd"
   33809 (gdb)
   33810 -environment-directory -r
   33811 ^done,source-path="$cdir:$cwd"
   33812 (gdb)
   33813 @end smallexample
   33814 
   33815 
   33816 @findex -environment-path
   33817 @subheading The @code{-environment-path} Command
   33818 
   33819 @subsubheading Synopsis
   33820 
   33821 @smallexample
   33822  -environment-path [ -r ] [ @var{pathdir} ]+
   33823 @end smallexample
   33824 
   33825 Add directories @var{pathdir} to beginning of search path for object files.
   33826 If the @samp{-r} option is used, the search path is reset to the original
   33827 search path that existed at gdb start-up.  If directories @var{pathdir} are
   33828 supplied in addition to the
   33829 @samp{-r} option, the search path is first reset and then addition
   33830 occurs as normal.
   33831 Multiple directories may be specified, separated by blanks.  Specifying
   33832 multiple directories in a single command
   33833 results in the directories added to the beginning of the
   33834 search path in the same order they were presented in the command.
   33835 If blanks are needed as
   33836 part of a directory name, double-quotes should be used around
   33837 the name.  In the command output, the path will show up separated
   33838 by the system directory-separator character.  The directory-separator
   33839 character must not be used
   33840 in any directory name.
   33841 If no directories are specified, the current path is displayed.
   33842 
   33843 
   33844 @subsubheading @value{GDBN} Command
   33845 
   33846 The corresponding @value{GDBN} command is @samp{path}.
   33847 
   33848 @subsubheading Example
   33849 
   33850 @smallexample
   33851 (gdb)
   33852 -environment-path
   33853 ^done,path="/usr/bin"
   33854 (gdb)
   33855 -environment-path /kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb /bin
   33856 ^done,path="/kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb:/bin:/usr/bin"
   33857 (gdb)
   33858 -environment-path -r /usr/local/bin
   33859 ^done,path="/usr/local/bin:/usr/bin"
   33860 (gdb)
   33861 @end smallexample
   33862 
   33863 
   33864 @findex -environment-pwd
   33865 @subheading The @code{-environment-pwd} Command
   33866 
   33867 @subsubheading Synopsis
   33868 
   33869 @smallexample
   33870  -environment-pwd
   33871 @end smallexample
   33872 
   33873 Show the current working directory.
   33874 
   33875 @subsubheading @value{GDBN} Command
   33876 
   33877 The corresponding @value{GDBN} command is @samp{pwd}.
   33878 
   33879 @subsubheading Example
   33880 
   33881 @smallexample
   33882 (gdb)
   33883 -environment-pwd
   33884 ^done,cwd="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb"
   33885 (gdb)
   33886 @end smallexample
   33887 
   33888 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   33889 @node GDB/MI Thread Commands
   33890 @section @sc{gdb/mi} Thread Commands
   33891 
   33892 
   33893 @findex -thread-info
   33894 @subheading The @code{-thread-info} Command
   33895 
   33896 @subsubheading Synopsis
   33897 
   33898 @smallexample
   33899  -thread-info [ @var{thread-id} ]
   33900 @end smallexample
   33901 
   33902 Reports information about either a specific thread, if the
   33903 @var{thread-id} parameter is present, or about all threads.
   33904 @var{thread-id} is the thread's global thread ID.  When printing
   33905 information about all threads, also reports the global ID of the
   33906 current thread.
   33907 
   33908 @subsubheading @value{GDBN} Command
   33909 
   33910 The @samp{info thread} command prints the same information
   33911 about all threads.
   33912 
   33913 @subsubheading Result
   33914 
   33915 The result contains the following attributes:
   33916 
   33917 @table @samp
   33918 @item threads
   33919 A list of threads.  The format of the elements of the list is described in
   33920 @ref{GDB/MI Thread Information}.
   33921 
   33922 @item current-thread-id
   33923 The global id of the currently selected thread.  This field is omitted if there
   33924 is no selected thread (for example, when the selected inferior is not running,
   33925 and therefore has no threads) or if a @var{thread-id} argument was passed to
   33926 the command.
   33927 
   33928 @end table
   33929 
   33930 @subsubheading Example
   33931 
   33932 @smallexample
   33933 -thread-info
   33934 ^done,threads=[
   33935 @{id="2",target-id="Thread 0xb7e14b90 (LWP 21257)",
   33936    frame=@{level="0",addr="0xffffe410",func="__kernel_vsyscall",
   33937            args=[]@},state="running"@},
   33938 @{id="1",target-id="Thread 0xb7e156b0 (LWP 21254)",
   33939    frame=@{level="0",addr="0x0804891f",func="foo",
   33940            args=[@{name="i",value="10"@}],
   33941            file="/tmp/a.c",fullname="/tmp/a.c",line="158",arch="i386:x86_64"@},
   33942            state="running"@}],
   33943 current-thread-id="1"
   33944 (gdb)
   33945 @end smallexample
   33946 
   33947 @findex -thread-list-ids
   33948 @subheading The @code{-thread-list-ids} Command
   33949 
   33950 @subsubheading Synopsis
   33951 
   33952 @smallexample
   33953  -thread-list-ids
   33954 @end smallexample
   33955 
   33956 Produces a list of the currently known global @value{GDBN} thread ids.
   33957 At the end of the list it also prints the total number of such
   33958 threads.
   33959 
   33960 This command is retained for historical reasons, the
   33961 @code{-thread-info} command should be used instead.
   33962 
   33963 @subsubheading @value{GDBN} Command
   33964 
   33965 Part of @samp{info threads} supplies the same information.
   33966 
   33967 @subsubheading Example
   33968 
   33969 @smallexample
   33970 (gdb)
   33971 -thread-list-ids
   33972 ^done,thread-ids=@{thread-id="3",thread-id="2",thread-id="1"@},
   33973 current-thread-id="1",number-of-threads="3"
   33974 (gdb)
   33975 @end smallexample
   33976 
   33977 
   33978 @findex -thread-select
   33979 @subheading The @code{-thread-select} Command
   33980 
   33981 @subsubheading Synopsis
   33982 
   33983 @smallexample
   33984  -thread-select @var{thread-id}
   33985 @end smallexample
   33986 
   33987 Make thread with global thread number @var{thread-id} the current
   33988 thread.  It prints the number of the new current thread, and the
   33989 topmost frame for that thread.
   33990 
   33991 This command is deprecated in favor of explicitly using the
   33992 @samp{--thread} option to each command.
   33993 
   33994 @subsubheading @value{GDBN} Command
   33995 
   33996 The corresponding @value{GDBN} command is @samp{thread}.
   33997 
   33998 @subsubheading Example
   33999 
   34000 @smallexample
   34001 (gdb)
   34002 -exec-next
   34003 ^running
   34004 (gdb)
   34005 *stopped,reason="end-stepping-range",thread-id="2",line="187",
   34006 file="../../../devo/gdb/testsuite/gdb.threads/linux-dp.c"
   34007 (gdb)
   34008 -thread-list-ids
   34009 ^done,
   34010 thread-ids=@{thread-id="3",thread-id="2",thread-id="1"@},
   34011 number-of-threads="3"
   34012 (gdb)
   34013 -thread-select 3
   34014 ^done,new-thread-id="3",
   34015 frame=@{level="0",func="vprintf",
   34016 args=[@{name="format",value="0x8048e9c \"%*s%c %d %c\\n\""@},
   34017 @{name="arg",value="0x2"@}],file="vprintf.c",line="31",arch="i386:x86_64"@}
   34018 (gdb)
   34019 @end smallexample
   34020 
   34021 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   34022 @node GDB/MI Ada Tasking Commands
   34023 @section @sc{gdb/mi} Ada Tasking Commands
   34024 
   34025 @findex -ada-task-info
   34026 @subheading The @code{-ada-task-info} Command
   34027 
   34028 @subsubheading Synopsis
   34029 
   34030 @smallexample
   34031  -ada-task-info [ @var{task-id} ]
   34032 @end smallexample
   34033 
   34034 Reports information about either a specific Ada task, if the
   34035 @var{task-id} parameter is present, or about all Ada tasks.
   34036 
   34037 @subsubheading @value{GDBN} Command
   34038 
   34039 The @samp{info tasks} command prints the same information
   34040 about all Ada tasks (@pxref{Ada Tasks}).
   34041 
   34042 @subsubheading Result
   34043 
   34044 The result is a table of Ada tasks.  The following columns are
   34045 defined for each Ada task:
   34046 
   34047 @table @samp
   34048 @item current
   34049 This field exists only for the current thread.  It has the value @samp{*}.
   34050 
   34051 @item id
   34052 The identifier that @value{GDBN} uses to refer to the Ada task.
   34053 
   34054 @item task-id
   34055 The identifier that the target uses to refer to the Ada task.
   34056 
   34057 @item thread-id
   34058 The global thread identifier of the thread corresponding to the Ada
   34059 task.
   34060 
   34061 This field should always exist, as Ada tasks are always implemented
   34062 on top of a thread.  But if @value{GDBN} cannot find this corresponding
   34063 thread for any reason, the field is omitted.
   34064 
   34065 @item parent-id
   34066 This field exists only when the task was created by another task.
   34067 In this case, it provides the ID of the parent task.
   34068 
   34069 @item priority
   34070 The base priority of the task.
   34071 
   34072 @item state
   34073 The current state of the task.  For a detailed description of the
   34074 possible states, see @ref{Ada Tasks}.
   34075 
   34076 @item name
   34077 The name of the task.
   34078 
   34079 @end table
   34080 
   34081 @subsubheading Example
   34082 
   34083 @smallexample
   34084 -ada-task-info
   34085 ^done,tasks=@{nr_rows="3",nr_cols="8",
   34086 hdr=[@{width="1",alignment="-1",col_name="current",colhdr=""@},
   34087 @{width="3",alignment="1",col_name="id",colhdr="ID"@},
   34088 @{width="9",alignment="1",col_name="task-id",colhdr="TID"@},
   34089 @{width="4",alignment="1",col_name="thread-id",colhdr=""@},
   34090 @{width="4",alignment="1",col_name="parent-id",colhdr="P-ID"@},
   34091 @{width="3",alignment="1",col_name="priority",colhdr="Pri"@},
   34092 @{width="22",alignment="-1",col_name="state",colhdr="State"@},
   34093 @{width="1",alignment="2",col_name="name",colhdr="Name"@}],
   34094 body=[@{current="*",id="1",task-id="   644010",thread-id="1",priority="48",
   34095 state="Child Termination Wait",name="main_task"@}]@}
   34096 (gdb)
   34097 @end smallexample
   34098 
   34099 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   34100 @node GDB/MI Program Execution
   34101 @section @sc{gdb/mi} Program Execution
   34102 
   34103 These are the asynchronous commands which generate the out-of-band
   34104 record @samp{*stopped}.  Currently @value{GDBN} only really executes
   34105 asynchronously with remote targets and this interaction is mimicked in
   34106 other cases.
   34107 
   34108 @findex -exec-continue
   34109 @subheading The @code{-exec-continue} Command
   34110 
   34111 @subsubheading Synopsis
   34112 
   34113 @smallexample
   34114  -exec-continue [--reverse] [--all|--thread-group N]
   34115 @end smallexample
   34116 
   34117 Resumes the execution of the inferior program, which will continue
   34118 to execute until it reaches a debugger stop event.  If the 
   34119 @samp{--reverse} option is specified, execution resumes in reverse until 
   34120 it reaches a stop event.  Stop events may include
   34121 @itemize @bullet
   34122 @item
   34123 breakpoints, watchpoints, tracepoints, or catchpoints
   34124 @item
   34125 signals or exceptions
   34126 @item
   34127 the end of the process (or its beginning under @samp{--reverse})
   34128 @item
   34129 the end or beginning of a replay log if one is being used.
   34130 @end itemize
   34131 In all-stop mode (@pxref{All-Stop
   34132 Mode}), may resume only one thread, or all threads, depending on the
   34133 value of the @samp{scheduler-locking} variable.  If @samp{--all} is
   34134 specified, all threads (in all inferiors) will be resumed.  The @samp{--all} option is
   34135 ignored in all-stop mode.  If the @samp{--thread-group} options is
   34136 specified, then all threads in that thread group are resumed.
   34137 
   34138 @subsubheading @value{GDBN} Command
   34139 
   34140 The corresponding @value{GDBN} corresponding is @samp{continue}.
   34141 
   34142 @subsubheading Example
   34143 
   34144 @smallexample
   34145 -exec-continue
   34146 ^running
   34147 (gdb)
   34148 @@Hello world
   34149 *stopped,reason="breakpoint-hit",disp="keep",bkptno="2",frame=@{
   34150 func="foo",args=[],file="hello.c",fullname="/home/foo/bar/hello.c",
   34151 line="13",arch="i386:x86_64"@}
   34152 (gdb)
   34153 @end smallexample
   34154 
   34155 For a @samp{breakpoint-hit} stopped reason, when the breakpoint
   34156 encountered has multiple locations, the field @samp{bkptno} is
   34157 followed by the field @samp{locno}.
   34158 
   34159 @smallexample
   34160 -exec-continue
   34161 ^running
   34162 (gdb)
   34163 @@Hello world
   34164 *stopped,reason="breakpoint-hit",disp="keep",bkptno="2",locno="3",frame=@{
   34165 func="foo",args=[],file="hello.c",fullname="/home/foo/bar/hello.c",
   34166 line="13",arch="i386:x86_64"@}
   34167 (gdb)
   34168 @end smallexample
   34169 
   34170 @findex -exec-finish
   34171 @subheading The @code{-exec-finish} Command
   34172 
   34173 @subsubheading Synopsis
   34174 
   34175 @smallexample
   34176  -exec-finish [--reverse]
   34177 @end smallexample
   34178 
   34179 Resumes the execution of the inferior program until the current
   34180 function is exited.  Displays the results returned by the function.
   34181 If the @samp{--reverse} option is specified, resumes the reverse
   34182 execution of the inferior program until the point where current
   34183 function was called.
   34184 
   34185 @subsubheading @value{GDBN} Command
   34186 
   34187 The corresponding @value{GDBN} command is @samp{finish}.
   34188 
   34189 @subsubheading Example
   34190 
   34191 Function returning @code{void}.
   34192 
   34193 @smallexample
   34194 -exec-finish
   34195 ^running
   34196 (gdb)
   34197 @@hello from foo
   34198 *stopped,reason="function-finished",frame=@{func="main",args=[],
   34199 file="hello.c",fullname="/home/foo/bar/hello.c",line="7",arch="i386:x86_64"@}
   34200 (gdb)
   34201 @end smallexample
   34202 
   34203 Function returning other than @code{void}.  The name of the internal
   34204 @value{GDBN} variable storing the result is printed, together with the
   34205 value itself.
   34206 
   34207 @smallexample
   34208 -exec-finish
   34209 ^running
   34210 (gdb)
   34211 *stopped,reason="function-finished",frame=@{addr="0x000107b0",func="foo",
   34212 args=[@{name="a",value="1"],@{name="b",value="9"@}@},
   34213 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14",
   34214 arch="i386:x86_64"@},
   34215 gdb-result-var="$1",return-value="0"
   34216 (gdb)
   34217 @end smallexample
   34218 
   34219 
   34220 @findex -exec-interrupt
   34221 @subheading The @code{-exec-interrupt} Command
   34222 
   34223 @subsubheading Synopsis
   34224 
   34225 @smallexample
   34226  -exec-interrupt [--all|--thread-group N]
   34227 @end smallexample
   34228 
   34229 Interrupts the background execution of the target.  Note how the token
   34230 associated with the stop message is the one for the execution command
   34231 that has been interrupted.  The token for the interrupt itself only
   34232 appears in the @samp{^done} output.  If the user is trying to
   34233 interrupt a non-running program, an error message will be printed.
   34234 
   34235 Note that when asynchronous execution is enabled, this command is
   34236 asynchronous just like other execution commands.  That is, first the
   34237 @samp{^done} response will be printed, and the target stop will be
   34238 reported after that using the @samp{*stopped} notification.
   34239 
   34240 In non-stop mode, only the context thread is interrupted by default.
   34241 All threads (in all inferiors) will be interrupted if the
   34242 @samp{--all}  option is specified.  If the @samp{--thread-group}
   34243 option is specified, all threads in that group will be interrupted.
   34244 
   34245 @subsubheading @value{GDBN} Command
   34246 
   34247 The corresponding @value{GDBN} command is @samp{interrupt}.
   34248 
   34249 @subsubheading Example
   34250 
   34251 @smallexample
   34252 (gdb)
   34253 111-exec-continue
   34254 111^running
   34255 
   34256 (gdb)
   34257 222-exec-interrupt
   34258 222^done
   34259 (gdb)
   34260 111*stopped,signal-name="SIGINT",signal-meaning="Interrupt",
   34261 frame=@{addr="0x00010140",func="foo",args=[],file="try.c",
   34262 fullname="/home/foo/bar/try.c",line="13",arch="i386:x86_64"@}
   34263 (gdb)
   34264 
   34265 (gdb)
   34266 -exec-interrupt
   34267 ^error,msg="mi_cmd_exec_interrupt: Inferior not executing."
   34268 (gdb)
   34269 @end smallexample
   34270 
   34271 @findex -exec-jump
   34272 @subheading The @code{-exec-jump} Command
   34273 
   34274 @subsubheading Synopsis
   34275 
   34276 @smallexample
   34277  -exec-jump @var{locspec}
   34278 @end smallexample
   34279 
   34280 Resumes execution of the inferior program at the address to
   34281 which @var{locspec} resolves.  @xref{Location Specifications},
   34282 for a description of the different forms of @var{locspec}.
   34283 
   34284 @subsubheading @value{GDBN} Command
   34285 
   34286 The corresponding @value{GDBN} command is @samp{jump}.
   34287 
   34288 @subsubheading Example
   34289 
   34290 @smallexample
   34291 -exec-jump foo.c:10
   34292 *running,thread-id="all"
   34293 ^running
   34294 @end smallexample
   34295 
   34296 
   34297 @findex -exec-next
   34298 @subheading The @code{-exec-next} Command
   34299 
   34300 @subsubheading Synopsis
   34301 
   34302 @smallexample
   34303  -exec-next [--reverse]
   34304 @end smallexample
   34305 
   34306 Resumes execution of the inferior program, stopping when the beginning
   34307 of the next source line is reached.
   34308 
   34309 If the @samp{--reverse} option is specified, resumes reverse execution
   34310 of the inferior program, stopping at the beginning of the previous
   34311 source line.  If you issue this command on the first line of a
   34312 function, it will take you back to the caller of that function, to the
   34313 source line where the function was called.
   34314 
   34315 
   34316 @subsubheading @value{GDBN} Command
   34317 
   34318 The corresponding @value{GDBN} command is @samp{next}.
   34319 
   34320 @subsubheading Example
   34321 
   34322 @smallexample
   34323 -exec-next
   34324 ^running
   34325 (gdb)
   34326 *stopped,reason="end-stepping-range",line="8",file="hello.c"
   34327 (gdb)
   34328 @end smallexample
   34329 
   34330 
   34331 @findex -exec-next-instruction
   34332 @subheading The @code{-exec-next-instruction} Command
   34333 
   34334 @subsubheading Synopsis
   34335 
   34336 @smallexample
   34337  -exec-next-instruction [--reverse]
   34338 @end smallexample
   34339 
   34340 Executes one machine instruction.  If the instruction is a function
   34341 call, continues until the function returns.  If the program stops at an
   34342 instruction in the middle of a source line, the address will be
   34343 printed as well.
   34344 
   34345 If the @samp{--reverse} option is specified, resumes reverse execution
   34346 of the inferior program, stopping at the previous instruction.  If the
   34347 previously executed instruction was a return from another function,
   34348 it will continue to execute in reverse until the call to that function
   34349 (from the current stack frame) is reached.
   34350 
   34351 @subsubheading @value{GDBN} Command
   34352 
   34353 The corresponding @value{GDBN} command is @samp{nexti}.
   34354 
   34355 @subsubheading Example
   34356 
   34357 @smallexample
   34358 (gdb)
   34359 -exec-next-instruction
   34360 ^running
   34361 
   34362 (gdb)
   34363 *stopped,reason="end-stepping-range",
   34364 addr="0x000100d4",line="5",file="hello.c"
   34365 (gdb)
   34366 @end smallexample
   34367 
   34368 
   34369 @findex -exec-return
   34370 @subheading The @code{-exec-return} Command
   34371 
   34372 @subsubheading Synopsis
   34373 
   34374 @smallexample
   34375  -exec-return
   34376 @end smallexample
   34377 
   34378 Makes current function return immediately.  Doesn't execute the inferior.
   34379 Displays the new current frame.
   34380 
   34381 @subsubheading @value{GDBN} Command
   34382 
   34383 The corresponding @value{GDBN} command is @samp{return}.
   34384 
   34385 @subsubheading Example
   34386 
   34387 @smallexample
   34388 (gdb)
   34389 200-break-insert callee4
   34390 200^done,bkpt=@{number="1",addr="0x00010734",
   34391 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="8"@}
   34392 (gdb)
   34393 000-exec-run
   34394 000^running
   34395 (gdb)
   34396 000*stopped,reason="breakpoint-hit",disp="keep",bkptno="1",
   34397 frame=@{func="callee4",args=[],
   34398 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
   34399 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="8",
   34400 arch="i386:x86_64"@}
   34401 (gdb)
   34402 205-break-delete
   34403 205^done
   34404 (gdb)
   34405 111-exec-return
   34406 111^done,frame=@{level="0",func="callee3",
   34407 args=[@{name="strarg",
   34408 value="0x11940 \"A string argument.\""@}],
   34409 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
   34410 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="18",
   34411 arch="i386:x86_64"@}
   34412 (gdb)
   34413 @end smallexample
   34414 
   34415 
   34416 @findex -exec-run
   34417 @subheading The @code{-exec-run} Command
   34418 
   34419 @subsubheading Synopsis
   34420 
   34421 @smallexample
   34422  -exec-run [ --all | --thread-group N ] [ --start ]
   34423 @end smallexample
   34424 
   34425 Starts execution of the inferior from the beginning.  The inferior
   34426 executes until either a breakpoint is encountered or the program
   34427 exits.  In the latter case the output will include an exit code, if
   34428 the program has exited exceptionally.
   34429 
   34430 When neither the @samp{--all} nor the @samp{--thread-group} option
   34431 is specified, the current inferior is started.  If the
   34432 @samp{--thread-group} option is specified, it should refer to a thread
   34433 group of type @samp{process}, and that thread group will be started.
   34434 If the @samp{--all} option is specified, then all inferiors will be started.
   34435 
   34436 Using the @samp{--start} option instructs the debugger to stop
   34437 the execution at the start of the inferior's main subprogram,
   34438 following the same behavior as the @code{start} command
   34439 (@pxref{Starting}).
   34440 
   34441 @subsubheading @value{GDBN} Command
   34442 
   34443 The corresponding @value{GDBN} command is @samp{run}.
   34444 
   34445 @subsubheading Examples
   34446 
   34447 @smallexample
   34448 (gdb)
   34449 -break-insert main
   34450 ^done,bkpt=@{number="1",addr="0x0001072c",file="recursive2.c",line="4"@}
   34451 (gdb)
   34452 -exec-run
   34453 ^running
   34454 (gdb)
   34455 *stopped,reason="breakpoint-hit",disp="keep",bkptno="1",
   34456 frame=@{func="main",args=[],file="recursive2.c",
   34457 fullname="/home/foo/bar/recursive2.c",line="4",arch="i386:x86_64"@}
   34458 (gdb)
   34459 @end smallexample
   34460 
   34461 @noindent
   34462 Program exited normally:
   34463 
   34464 @smallexample
   34465 (gdb)
   34466 -exec-run
   34467 ^running
   34468 (gdb)
   34469 x = 55
   34470 *stopped,reason="exited-normally"
   34471 (gdb)
   34472 @end smallexample
   34473 
   34474 @noindent
   34475 Program exited exceptionally:
   34476 
   34477 @smallexample
   34478 (gdb)
   34479 -exec-run
   34480 ^running
   34481 (gdb)
   34482 x = 55
   34483 *stopped,reason="exited",exit-code="01"
   34484 (gdb)
   34485 @end smallexample
   34486 
   34487 Another way the program can terminate is if it receives a signal such as
   34488 @code{SIGINT}.  In this case, @sc{gdb/mi} displays this:
   34489 
   34490 @smallexample
   34491 (gdb)
   34492 *stopped,reason="exited-signalled",signal-name="SIGINT",
   34493 signal-meaning="Interrupt"
   34494 @end smallexample
   34495 
   34496 
   34497 @c @subheading -exec-signal
   34498 
   34499 
   34500 @findex -exec-step
   34501 @subheading The @code{-exec-step} Command
   34502 
   34503 @subsubheading Synopsis
   34504 
   34505 @smallexample
   34506  -exec-step [--reverse]
   34507 @end smallexample
   34508 
   34509 Resumes execution of the inferior program, stopping when the beginning
   34510 of the next source line is reached, if the next source line is not a
   34511 function call.  If it is, stop at the first instruction of the called
   34512 function.  If the @samp{--reverse} option is specified, resumes reverse
   34513 execution of the inferior program, stopping at the beginning of the
   34514 previously executed source line.
   34515 
   34516 @subsubheading @value{GDBN} Command
   34517 
   34518 The corresponding @value{GDBN} command is @samp{step}.
   34519 
   34520 @subsubheading Example
   34521 
   34522 Stepping into a function:
   34523 
   34524 @smallexample
   34525 -exec-step
   34526 ^running
   34527 (gdb)
   34528 *stopped,reason="end-stepping-range",
   34529 frame=@{func="foo",args=[@{name="a",value="10"@},
   34530 @{name="b",value="0"@}],file="recursive2.c",
   34531 fullname="/home/foo/bar/recursive2.c",line="11",arch="i386:x86_64"@}
   34532 (gdb)
   34533 @end smallexample
   34534 
   34535 Regular stepping:
   34536 
   34537 @smallexample
   34538 -exec-step
   34539 ^running
   34540 (gdb)
   34541 *stopped,reason="end-stepping-range",line="14",file="recursive2.c"
   34542 (gdb)
   34543 @end smallexample
   34544 
   34545 
   34546 @findex -exec-step-instruction
   34547 @subheading The @code{-exec-step-instruction} Command
   34548 
   34549 @subsubheading Synopsis
   34550 
   34551 @smallexample
   34552  -exec-step-instruction [--reverse]
   34553 @end smallexample
   34554 
   34555 Resumes the inferior which executes one machine instruction.  If the
   34556 @samp{--reverse} option is specified, resumes reverse execution of the
   34557 inferior program, stopping at the previously executed instruction.
   34558 The output, once @value{GDBN} has stopped, will vary depending on
   34559 whether we have stopped in the middle of a source line or not.  In the
   34560 former case, the address at which the program stopped will be printed
   34561 as well.
   34562 
   34563 @subsubheading @value{GDBN} Command
   34564 
   34565 The corresponding @value{GDBN} command is @samp{stepi}.
   34566 
   34567 @subsubheading Example
   34568 
   34569 @smallexample
   34570 (gdb)
   34571 -exec-step-instruction
   34572 ^running
   34573 
   34574 (gdb)
   34575 *stopped,reason="end-stepping-range",
   34576 frame=@{func="foo",args=[],file="try.c",
   34577 fullname="/home/foo/bar/try.c",line="10",arch="i386:x86_64"@}
   34578 (gdb)
   34579 -exec-step-instruction
   34580 ^running
   34581 
   34582 (gdb)
   34583 *stopped,reason="end-stepping-range",
   34584 frame=@{addr="0x000100f4",func="foo",args=[],file="try.c",
   34585 fullname="/home/foo/bar/try.c",line="10",arch="i386:x86_64"@}
   34586 (gdb)
   34587 @end smallexample
   34588 
   34589 
   34590 @findex -exec-until
   34591 @subheading The @code{-exec-until} Command
   34592 
   34593 @subsubheading Synopsis
   34594 
   34595 @smallexample
   34596  -exec-until [ @var{locspec} ]
   34597 @end smallexample
   34598 
   34599 Executes the inferior until it reaches the address to which
   34600 @var{locspec} resolves.  If there is no argument, the inferior
   34601 executes until it reaches a source line greater than the current one.
   34602 The reason for stopping in this case will be @samp{location-reached}.
   34603 
   34604 @subsubheading @value{GDBN} Command
   34605 
   34606 The corresponding @value{GDBN} command is @samp{until}.
   34607 
   34608 @subsubheading Example
   34609 
   34610 @smallexample
   34611 (gdb)
   34612 -exec-until recursive2.c:6
   34613 ^running
   34614 (gdb)
   34615 x = 55
   34616 *stopped,reason="location-reached",frame=@{func="main",args=[],
   34617 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="6",
   34618 arch="i386:x86_64"@}
   34619 (gdb)
   34620 @end smallexample
   34621 
   34622 @ignore
   34623 @subheading -file-clear
   34624 Is this going away????
   34625 @end ignore
   34626 
   34627 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   34628 @node GDB/MI Stack Manipulation
   34629 @section @sc{gdb/mi} Stack Manipulation Commands
   34630 
   34631 @findex -enable-frame-filters
   34632 @subheading The @code{-enable-frame-filters} Command
   34633 
   34634 @smallexample
   34635 -enable-frame-filters
   34636 @end smallexample
   34637 
   34638 @value{GDBN} allows Python-based frame filters to affect the output of
   34639 the MI commands relating to stack traces.  As there is no way to
   34640 implement this in a fully backward-compatible way, a front end must
   34641 request that this functionality be enabled.
   34642 
   34643 Once enabled, this feature cannot be disabled.
   34644 
   34645 Note that if Python support has not been compiled into @value{GDBN},
   34646 this command will still succeed (and do nothing).
   34647 
   34648 @findex -stack-info-frame
   34649 @subheading The @code{-stack-info-frame} Command
   34650 
   34651 @subsubheading Synopsis
   34652 
   34653 @smallexample
   34654  -stack-info-frame
   34655 @end smallexample
   34656 
   34657 Get info on the selected frame.
   34658 
   34659 @subsubheading @value{GDBN} Command
   34660 
   34661 The corresponding @value{GDBN} command is @samp{info frame} or @samp{frame}
   34662 (without arguments).
   34663 
   34664 @subsubheading Example
   34665 
   34666 @smallexample
   34667 (gdb)
   34668 -stack-info-frame
   34669 ^done,frame=@{level="1",addr="0x0001076c",func="callee3",
   34670 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
   34671 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="17",
   34672 arch="i386:x86_64"@}
   34673 (gdb)
   34674 @end smallexample
   34675 
   34676 @findex -stack-info-depth
   34677 @subheading The @code{-stack-info-depth} Command
   34678 
   34679 @subsubheading Synopsis
   34680 
   34681 @smallexample
   34682  -stack-info-depth [ @var{max-depth} ]
   34683 @end smallexample
   34684 
   34685 Return the depth of the stack.  If the integer argument @var{max-depth}
   34686 is specified, do not count beyond @var{max-depth} frames.
   34687 
   34688 @subsubheading @value{GDBN} Command
   34689 
   34690 There's no equivalent @value{GDBN} command.
   34691 
   34692 @subsubheading Example
   34693 
   34694 For a stack with frame levels 0 through 11:
   34695 
   34696 @smallexample
   34697 (gdb)
   34698 -stack-info-depth
   34699 ^done,depth="12"
   34700 (gdb)
   34701 -stack-info-depth 4
   34702 ^done,depth="4"
   34703 (gdb)
   34704 -stack-info-depth 12
   34705 ^done,depth="12"
   34706 (gdb)
   34707 -stack-info-depth 11
   34708 ^done,depth="11"
   34709 (gdb)
   34710 -stack-info-depth 13
   34711 ^done,depth="12"
   34712 (gdb)
   34713 @end smallexample
   34714 
   34715 @anchor{-stack-list-arguments}
   34716 @findex -stack-list-arguments
   34717 @subheading The @code{-stack-list-arguments} Command
   34718 
   34719 @subsubheading Synopsis
   34720 
   34721 @smallexample
   34722  -stack-list-arguments [ --no-frame-filters ] [ --skip-unavailable ] @var{print-values}
   34723     [ @var{low-frame} @var{high-frame} ]
   34724 @end smallexample
   34725 
   34726 Display a list of the arguments for the frames between @var{low-frame}
   34727 and @var{high-frame} (inclusive).  If @var{low-frame} and
   34728 @var{high-frame} are not provided, list the arguments for the whole
   34729 call stack.  If the two arguments are equal, show the single frame
   34730 at the corresponding level.  It is an error if @var{low-frame} is
   34731 larger than the actual number of frames.  On the other hand,
   34732 @var{high-frame} may be larger than the actual number of frames, in
   34733 which case only existing frames will be returned.
   34734 
   34735 If @var{print-values} is 0 or @code{--no-values}, print only the names of
   34736 the variables; if it is 1 or @code{--all-values}, print also their
   34737 values; and if it is 2 or @code{--simple-values}, print the name,
   34738 type and value for simple data types, and the name and type for arrays,
   34739 structures and unions.  If the option @code{--no-frame-filters} is
   34740 supplied, then Python frame filters will not be executed.
   34741 
   34742 If the @code{--skip-unavailable} option is specified, arguments that
   34743 are not available are not listed.  Partially available arguments
   34744 are still displayed, however.
   34745 
   34746 Use of this command to obtain arguments in a single frame is
   34747 deprecated in favor of the @samp{-stack-list-variables} command.
   34748 
   34749 @subsubheading @value{GDBN} Command
   34750 
   34751 @value{GDBN} does not have an equivalent command.  @code{gdbtk} has a
   34752 @samp{gdb_get_args} command which partially overlaps with the
   34753 functionality of @samp{-stack-list-arguments}.
   34754 
   34755 @subsubheading Example
   34756 
   34757 @smallexample
   34758 (gdb)
   34759 -stack-list-frames
   34760 ^done,
   34761 stack=[
   34762 frame=@{level="0",addr="0x00010734",func="callee4",
   34763 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
   34764 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="8",
   34765 arch="i386:x86_64"@},
   34766 frame=@{level="1",addr="0x0001076c",func="callee3",
   34767 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
   34768 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="17",
   34769 arch="i386:x86_64"@},
   34770 frame=@{level="2",addr="0x0001078c",func="callee2",
   34771 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
   34772 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="22",
   34773 arch="i386:x86_64"@},
   34774 frame=@{level="3",addr="0x000107b4",func="callee1",
   34775 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
   34776 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="27",
   34777 arch="i386:x86_64"@},
   34778 frame=@{level="4",addr="0x000107e0",func="main",
   34779 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
   34780 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="32",
   34781 arch="i386:x86_64"@}]
   34782 (gdb)
   34783 -stack-list-arguments 0
   34784 ^done,
   34785 stack-args=[
   34786 frame=@{level="0",args=[]@},
   34787 frame=@{level="1",args=[name="strarg"]@},
   34788 frame=@{level="2",args=[name="intarg",name="strarg"]@},
   34789 frame=@{level="3",args=[name="intarg",name="strarg",name="fltarg"]@},
   34790 frame=@{level="4",args=[]@}]
   34791 (gdb)
   34792 -stack-list-arguments 1
   34793 ^done,
   34794 stack-args=[
   34795 frame=@{level="0",args=[]@},
   34796 frame=@{level="1",
   34797  args=[@{name="strarg",value="0x11940 \"A string argument.\""@}]@},
   34798 frame=@{level="2",args=[
   34799 @{name="intarg",value="2"@},
   34800 @{name="strarg",value="0x11940 \"A string argument.\""@}]@},
   34801 @{frame=@{level="3",args=[
   34802 @{name="intarg",value="2"@},
   34803 @{name="strarg",value="0x11940 \"A string argument.\""@},
   34804 @{name="fltarg",value="3.5"@}]@},
   34805 frame=@{level="4",args=[]@}]
   34806 (gdb)
   34807 -stack-list-arguments 0 2 2
   34808 ^done,stack-args=[frame=@{level="2",args=[name="intarg",name="strarg"]@}]
   34809 (gdb)
   34810 -stack-list-arguments 1 2 2
   34811 ^done,stack-args=[frame=@{level="2",
   34812 args=[@{name="intarg",value="2"@},
   34813 @{name="strarg",value="0x11940 \"A string argument.\""@}]@}]
   34814 (gdb)
   34815 @end smallexample
   34816 
   34817 @c @subheading -stack-list-exception-handlers
   34818 
   34819 
   34820 @anchor{-stack-list-frames}
   34821 @findex -stack-list-frames
   34822 @subheading The @code{-stack-list-frames} Command
   34823 
   34824 @subsubheading Synopsis
   34825 
   34826 @smallexample
   34827  -stack-list-frames [ --no-frame-filters @var{low-frame} @var{high-frame} ]
   34828 @end smallexample
   34829 
   34830 List the frames currently on the stack.  For each frame it displays the
   34831 following info:
   34832 
   34833 @table @samp
   34834 @item @var{level}
   34835 The frame number, 0 being the topmost frame, i.e., the innermost function.
   34836 @item @var{addr}
   34837 The @code{$pc} value for that frame.
   34838 @item @var{func}
   34839 Function name.
   34840 @item @var{file}
   34841 File name of the source file where the function lives.
   34842 @item @var{fullname}
   34843 The full file name of the source file where the function lives.
   34844 @item @var{line}
   34845 Line number corresponding to the @code{$pc}.
   34846 @item @var{from}
   34847 The shared library where this function is defined.  This is only given
   34848 if the frame's function is not known.
   34849 @item @var{arch}
   34850 Frame's architecture.
   34851 @end table
   34852 
   34853 If invoked without arguments, this command prints a backtrace for the
   34854 whole stack.  If given two integer arguments, it shows the frames whose
   34855 levels are between the two arguments (inclusive).  If the two arguments
   34856 are equal, it shows the single frame at the corresponding level.  It is
   34857 an error if @var{low-frame} is larger than the actual number of
   34858 frames.  On the other hand, @var{high-frame} may be larger than the
   34859 actual number of frames, in which case only existing frames will be
   34860 returned.  If the option @code{--no-frame-filters} is supplied, then
   34861 Python frame filters will not be executed.
   34862 
   34863 @subsubheading @value{GDBN} Command
   34864 
   34865 The corresponding @value{GDBN} commands are @samp{backtrace} and @samp{where}.
   34866 
   34867 @subsubheading Example
   34868 
   34869 Full stack backtrace:
   34870 
   34871 @smallexample
   34872 (gdb)
   34873 -stack-list-frames
   34874 ^done,stack=
   34875 [frame=@{level="0",addr="0x0001076c",func="foo",
   34876   file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="11",
   34877   arch="i386:x86_64"@},
   34878 frame=@{level="1",addr="0x000107a4",func="foo",
   34879   file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14",
   34880   arch="i386:x86_64"@},
   34881 frame=@{level="2",addr="0x000107a4",func="foo",
   34882   file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14",
   34883   arch="i386:x86_64"@},
   34884 frame=@{level="3",addr="0x000107a4",func="foo",
   34885   file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14",
   34886   arch="i386:x86_64"@},
   34887 frame=@{level="4",addr="0x000107a4",func="foo",
   34888   file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14",
   34889   arch="i386:x86_64"@},
   34890 frame=@{level="5",addr="0x000107a4",func="foo",
   34891   file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14",
   34892   arch="i386:x86_64"@},
   34893 frame=@{level="6",addr="0x000107a4",func="foo",
   34894   file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14",
   34895   arch="i386:x86_64"@},
   34896 frame=@{level="7",addr="0x000107a4",func="foo",
   34897   file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14",
   34898   arch="i386:x86_64"@},
   34899 frame=@{level="8",addr="0x000107a4",func="foo",
   34900   file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14",
   34901   arch="i386:x86_64"@},
   34902 frame=@{level="9",addr="0x000107a4",func="foo",
   34903   file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14",
   34904   arch="i386:x86_64"@},
   34905 frame=@{level="10",addr="0x000107a4",func="foo",
   34906   file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14",
   34907   arch="i386:x86_64"@},
   34908 frame=@{level="11",addr="0x00010738",func="main",
   34909   file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="4",
   34910   arch="i386:x86_64"@}]
   34911 (gdb)
   34912 @end smallexample
   34913 
   34914 Show frames between @var{low_frame} and @var{high_frame}:
   34915 
   34916 @smallexample
   34917 (gdb)
   34918 -stack-list-frames 3 5
   34919 ^done,stack=
   34920 [frame=@{level="3",addr="0x000107a4",func="foo",
   34921   file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14",
   34922   arch="i386:x86_64"@},
   34923 frame=@{level="4",addr="0x000107a4",func="foo",
   34924   file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14",
   34925   arch="i386:x86_64"@},
   34926 frame=@{level="5",addr="0x000107a4",func="foo",
   34927   file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14",
   34928   arch="i386:x86_64"@}]
   34929 (gdb)
   34930 @end smallexample
   34931 
   34932 Show a single frame:
   34933 
   34934 @smallexample
   34935 (gdb)
   34936 -stack-list-frames 3 3
   34937 ^done,stack=
   34938 [frame=@{level="3",addr="0x000107a4",func="foo",
   34939   file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14",
   34940   arch="i386:x86_64"@}]
   34941 (gdb)
   34942 @end smallexample
   34943 
   34944 
   34945 @findex -stack-list-locals
   34946 @anchor{-stack-list-locals}
   34947 @subheading The @code{-stack-list-locals} Command
   34948 
   34949 @subsubheading Synopsis
   34950 
   34951 @smallexample
   34952  -stack-list-locals [ --no-frame-filters ] [ --skip-unavailable ] @var{print-values}
   34953 @end smallexample
   34954 
   34955 Display the local variable names for the selected frame.  If
   34956 @var{print-values} is 0 or @code{--no-values}, print only the names of
   34957 the variables; if it is 1 or @code{--all-values}, print also their
   34958 values; and if it is 2 or @code{--simple-values}, print the name,
   34959 type and value for simple data types, and the name and type for arrays,
   34960 structures and unions.  In this last case, a frontend can immediately
   34961 display the value of simple data types and create variable objects for
   34962 other data types when the user wishes to explore their values in
   34963 more detail.  If the option @code{--no-frame-filters} is supplied, then
   34964 Python frame filters will not be executed.
   34965 
   34966 If the @code{--skip-unavailable} option is specified, local variables
   34967 that are not available are not listed.  Partially available local
   34968 variables are still displayed, however.
   34969 
   34970 This command is deprecated in favor of the
   34971 @samp{-stack-list-variables} command.
   34972 
   34973 @subsubheading @value{GDBN} Command
   34974 
   34975 @samp{info locals} in @value{GDBN}, @samp{gdb_get_locals} in @code{gdbtk}.
   34976 
   34977 @subsubheading Example
   34978 
   34979 @smallexample
   34980 (gdb)
   34981 -stack-list-locals 0
   34982 ^done,locals=[name="A",name="B",name="C"]
   34983 (gdb)
   34984 -stack-list-locals --all-values
   34985 ^done,locals=[@{name="A",value="1"@},@{name="B",value="2"@},
   34986   @{name="C",value="@{1, 2, 3@}"@}]
   34987 -stack-list-locals --simple-values
   34988 ^done,locals=[@{name="A",type="int",value="1"@},
   34989   @{name="B",type="int",value="2"@},@{name="C",type="int [3]"@}]
   34990 (gdb)
   34991 @end smallexample
   34992 
   34993 @anchor{-stack-list-variables}
   34994 @findex -stack-list-variables
   34995 @subheading The @code{-stack-list-variables} Command
   34996 
   34997 @subsubheading Synopsis
   34998 
   34999 @smallexample
   35000  -stack-list-variables [ --no-frame-filters ] [ --skip-unavailable ] @var{print-values}
   35001 @end smallexample
   35002 
   35003 Display the names of local variables and function arguments for the selected frame.  If
   35004 @var{print-values} is 0 or @code{--no-values}, print only the names of
   35005 the variables; if it is 1 or @code{--all-values}, print also their
   35006 values; and if it is 2 or @code{--simple-values}, print the name,
   35007 type and value for simple data types, and the name and type for arrays,
   35008 structures and unions.  If the option @code{--no-frame-filters} is
   35009 supplied, then Python frame filters will not be executed.
   35010 
   35011 If the @code{--skip-unavailable} option is specified, local variables
   35012 and arguments that are not available are not listed.  Partially
   35013 available arguments and local variables are still displayed, however.
   35014 
   35015 @subsubheading Example
   35016 
   35017 @smallexample
   35018 (gdb)
   35019 -stack-list-variables --thread 1 --frame 0 --all-values
   35020 ^done,variables=[@{name="x",value="11"@},@{name="s",value="@{a = 1, b = 2@}"@}]
   35021 (gdb)
   35022 @end smallexample
   35023 
   35024 
   35025 @findex -stack-select-frame
   35026 @subheading The @code{-stack-select-frame} Command
   35027 
   35028 @subsubheading Synopsis
   35029 
   35030 @smallexample
   35031  -stack-select-frame @var{framenum}
   35032 @end smallexample
   35033 
   35034 Change the selected frame.  Select a different frame @var{framenum} on
   35035 the stack.
   35036 
   35037 This command in deprecated in favor of passing the @samp{--frame}
   35038 option to every command.
   35039 
   35040 @subsubheading @value{GDBN} Command
   35041 
   35042 The corresponding @value{GDBN} commands are @samp{frame}, @samp{up},
   35043 @samp{down}, @samp{select-frame}, @samp{up-silent}, and @samp{down-silent}.
   35044 
   35045 @subsubheading Example
   35046 
   35047 @smallexample
   35048 (gdb)
   35049 -stack-select-frame 2
   35050 ^done
   35051 (gdb)
   35052 @end smallexample
   35053 
   35054 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   35055 @node GDB/MI Variable Objects
   35056 @section @sc{gdb/mi} Variable Objects
   35057 
   35058 @ignore
   35059 
   35060 @subheading Motivation for Variable Objects in @sc{gdb/mi}
   35061 
   35062 For the implementation of a variable debugger window (locals, watched
   35063 expressions, etc.), we are proposing the adaptation of the existing code
   35064 used by @code{Insight}.
   35065 
   35066 The two main reasons for that are:
   35067 
   35068 @enumerate 1
   35069 @item
   35070 It has been proven in practice (it is already on its second generation).
   35071 
   35072 @item
   35073 It will shorten development time (needless to say how important it is
   35074 now).
   35075 @end enumerate
   35076 
   35077 The original interface was designed to be used by Tcl code, so it was
   35078 slightly changed so it could be used through @sc{gdb/mi}.  This section
   35079 describes the @sc{gdb/mi} operations that will be available and gives some
   35080 hints about their use.
   35081 
   35082 @emph{Note}: In addition to the set of operations described here, we
   35083 expect the @sc{gui} implementation of a variable window to require, at
   35084 least, the following operations:
   35085 
   35086 @itemize @bullet
   35087 @item @code{-gdb-show} @code{output-radix}
   35088 @item @code{-stack-list-arguments}
   35089 @item @code{-stack-list-locals}
   35090 @item @code{-stack-select-frame}
   35091 @end itemize
   35092 
   35093 @end ignore
   35094 
   35095 @subheading Introduction to Variable Objects
   35096 
   35097 @cindex variable objects in @sc{gdb/mi}
   35098 
   35099 Variable objects are "object-oriented" MI interface for examining and
   35100 changing values of expressions.  Unlike some other MI interfaces that
   35101 work with expressions, variable objects are specifically designed for
   35102 simple and efficient presentation in the frontend.  A variable object
   35103 is identified by string name.  When a variable object is created, the
   35104 frontend specifies the expression for that variable object.  The
   35105 expression can be a simple variable, or it can be an arbitrary complex
   35106 expression, and can even involve CPU registers.  After creating a
   35107 variable object, the frontend can invoke other variable object
   35108 operations---for example to obtain or change the value of a variable
   35109 object, or to change display format.
   35110 
   35111 Variable objects have hierarchical tree structure.  Any variable object
   35112 that corresponds to a composite type, such as structure in C, has
   35113 a number of child variable objects, for example corresponding to each
   35114 element of a structure.  A child variable object can itself have 
   35115 children, recursively.  Recursion ends when we reach 
   35116 leaf variable objects, which always have built-in types.  Child variable
   35117 objects are created only by explicit request, so if a frontend 
   35118 is not interested in the children of a particular variable object, no
   35119 child will be created.
   35120 
   35121 For a leaf variable object it is possible to obtain its value as a
   35122 string, or set the value from a string.  String value can be also
   35123 obtained for a non-leaf variable object, but it's generally a string
   35124 that only indicates the type of the object, and does not list its
   35125 contents.  Assignment to a non-leaf variable object is not allowed.
   35126  
   35127 A frontend does not need to read the values of all variable objects each time
   35128 the program stops.  Instead, MI provides an update command that lists all
   35129 variable objects whose values has changed since the last update
   35130 operation.  This considerably reduces the amount of data that must
   35131 be transferred to the frontend.  As noted above, children variable
   35132 objects are created on demand, and only leaf variable objects have a
   35133 real value.  As result, gdb will read target memory only for leaf
   35134 variables that frontend has created.
   35135 
   35136 The automatic update is not always desirable.  For example, a frontend
   35137 might want to keep a value of some expression for future reference,
   35138 and never update it.  For another example,  fetching memory is
   35139 relatively slow for embedded targets, so a frontend might want
   35140 to disable automatic update for the variables that are either not
   35141 visible on the screen, or ``closed''.  This is possible using so
   35142 called ``frozen variable objects''.  Such variable objects are never
   35143 implicitly updated.  
   35144 
   35145 Variable objects can be either @dfn{fixed} or @dfn{floating}.  For the
   35146 fixed variable object, the expression is parsed when the variable
   35147 object is created, including associating identifiers to specific
   35148 variables.  The meaning of expression never changes.  For a floating
   35149 variable object the values of variables whose names appear in the
   35150 expressions are re-evaluated every time in the context of the current
   35151 frame.  Consider this example:
   35152 
   35153 @smallexample
   35154 void do_work(...)
   35155 @{
   35156         struct work_state state;
   35157 
   35158         if (...)
   35159            do_work(...);
   35160 @}
   35161 @end smallexample
   35162 
   35163 If a fixed variable object for the @code{state} variable is created in
   35164 this function, and we enter the recursive call, the variable
   35165 object will report the value of @code{state} in the top-level
   35166 @code{do_work} invocation.  On the other hand, a floating variable
   35167 object will report the value of @code{state} in the current frame.
   35168 
   35169 If an expression specified when creating a fixed variable object
   35170 refers to a local variable, the variable object becomes bound to the
   35171 thread and frame in which the variable object is created.  When such
   35172 variable object is updated, @value{GDBN} makes sure that the
   35173 thread/frame combination the variable object is bound to still exists,
   35174 and re-evaluates the variable object in context of that thread/frame.
   35175 
   35176 The following is the complete set of @sc{gdb/mi} operations defined to
   35177 access this functionality:
   35178 
   35179 @multitable @columnfractions .4 .6
   35180 @item @strong{Operation}
   35181 @tab @strong{Description}
   35182 
   35183 @item @code{-enable-pretty-printing}
   35184 @tab enable Python-based pretty-printing
   35185 @item @code{-var-create}
   35186 @tab create a variable object
   35187 @item @code{-var-delete}
   35188 @tab delete the variable object and/or its children
   35189 @item @code{-var-set-format}
   35190 @tab set the display format of this variable
   35191 @item @code{-var-show-format}
   35192 @tab show the display format of this variable
   35193 @item @code{-var-info-num-children}
   35194 @tab tells how many children this object has
   35195 @item @code{-var-list-children}
   35196 @tab return a list of the object's children
   35197 @item @code{-var-info-type}
   35198 @tab show the type of this variable object
   35199 @item @code{-var-info-expression}
   35200 @tab print parent-relative expression that this variable object represents
   35201 @item @code{-var-info-path-expression}
   35202 @tab print full expression that this variable object represents
   35203 @item @code{-var-show-attributes}
   35204 @tab is this variable editable? does it exist here?
   35205 @item @code{-var-evaluate-expression}
   35206 @tab get the value of this variable
   35207 @item @code{-var-assign}
   35208 @tab set the value of this variable
   35209 @item @code{-var-update}
   35210 @tab update the variable and its children
   35211 @item @code{-var-set-frozen}
   35212 @tab set frozenness attribute
   35213 @item @code{-var-set-update-range}
   35214 @tab set range of children to display on update
   35215 @end multitable
   35216 
   35217 In the next subsection we describe each operation in detail and suggest
   35218 how it can be used.
   35219 
   35220 @subheading Description And Use of Operations on Variable Objects
   35221 
   35222 @findex -enable-pretty-printing
   35223 @subheading The @code{-enable-pretty-printing} Command
   35224 
   35225 @smallexample
   35226 -enable-pretty-printing
   35227 @end smallexample
   35228 
   35229 @value{GDBN} allows Python-based visualizers to affect the output of the
   35230 MI variable object commands.  However, because there was no way to
   35231 implement this in a fully backward-compatible way, a front end must
   35232 request that this functionality be enabled.
   35233 
   35234 Once enabled, this feature cannot be disabled.
   35235 
   35236 Note that if Python support has not been compiled into @value{GDBN},
   35237 this command will still succeed (and do nothing).
   35238 
   35239 @findex -var-create
   35240 @subheading The @code{-var-create} Command
   35241 
   35242 @subsubheading Synopsis
   35243 
   35244 @smallexample
   35245  -var-create @{@var{name} | "-"@}
   35246     @{@var{frame-addr} | "*" | "@@"@} @var{expression}
   35247 @end smallexample
   35248 
   35249 This operation creates a variable object, which allows the monitoring of
   35250 a variable, the result of an expression, a memory cell or a CPU
   35251 register.
   35252 
   35253 The @var{name} parameter is the string by which the object can be
   35254 referenced.  It must be unique.  If @samp{-} is specified, the varobj
   35255 system will generate a string ``varNNNNNN'' automatically.  It will be
   35256 unique provided that one does not specify @var{name} of that format.
   35257 The command fails if a duplicate name is found.
   35258 
   35259 The frame under which the expression should be evaluated can be
   35260 specified by @var{frame-addr}.  A @samp{*} indicates that the current
   35261 frame should be used.  A @samp{@@} indicates that a floating variable
   35262 object must be created.
   35263 
   35264 @var{expression} is any expression valid on the current language set (must not
   35265 begin with a @samp{*}), or one of the following:
   35266 
   35267 @itemize @bullet
   35268 @item
   35269 @samp{*@var{addr}}, where @var{addr} is the address of a memory cell
   35270 
   35271 @item
   35272 @samp{*@var{addr}-@var{addr}} --- a memory address range (TBD)
   35273 
   35274 @item
   35275 @samp{$@var{regname}} --- a CPU register name
   35276 @end itemize
   35277 
   35278 @cindex dynamic varobj
   35279 A varobj's contents may be provided by a Python-based pretty-printer.  In this
   35280 case the varobj is known as a @dfn{dynamic varobj}.  Dynamic varobjs
   35281 have slightly different semantics in some cases.  If the
   35282 @code{-enable-pretty-printing} command is not sent, then @value{GDBN}
   35283 will never create a dynamic varobj.  This ensures backward
   35284 compatibility for existing clients.
   35285 
   35286 @subsubheading Result
   35287 
   35288 This operation returns attributes of the newly-created varobj.  These
   35289 are:
   35290 
   35291 @table @samp
   35292 @item name
   35293 The name of the varobj.
   35294 
   35295 @item numchild
   35296 The number of children of the varobj.  This number is not necessarily
   35297 reliable for a dynamic varobj.  Instead, you must examine the
   35298 @samp{has_more} attribute.
   35299 
   35300 @item value
   35301 The varobj's scalar value.  For a varobj whose type is some sort of
   35302 aggregate (e.g., a @code{struct}), this value will not be interesting.
   35303 For a dynamic varobj, this value comes directly from the Python
   35304 pretty-printer object's @code{to_string} method.
   35305 
   35306 @item type
   35307 The varobj's type.  This is a string representation of the type, as
   35308 would be printed by the @value{GDBN} CLI.  If @samp{print object}
   35309 (@pxref{Print Settings, set print object}) is set to @code{on}, the
   35310 @emph{actual} (derived) type of the object is shown rather than the
   35311 @emph{declared} one.
   35312 
   35313 @item thread-id
   35314 If a variable object is bound to a specific thread, then this is the
   35315 thread's global identifier.
   35316 
   35317 @item has_more
   35318 For a dynamic varobj, this indicates whether there appear to be any
   35319 children available.  For a non-dynamic varobj, this will be 0.
   35320 
   35321 @item dynamic
   35322 This attribute will be present and have the value @samp{1} if the
   35323 varobj is a dynamic varobj.  If the varobj is not a dynamic varobj,
   35324 then this attribute will not be present.
   35325 
   35326 @item displayhint
   35327 A dynamic varobj can supply a display hint to the front end.  The
   35328 value comes directly from the Python pretty-printer object's
   35329 @code{display_hint} method.  @xref{Pretty Printing API}.
   35330 @end table
   35331 
   35332 Typical output will look like this:
   35333 
   35334 @smallexample
   35335  name="@var{name}",numchild="@var{N}",type="@var{type}",thread-id="@var{M}",
   35336   has_more="@var{has_more}"
   35337 @end smallexample
   35338 
   35339 
   35340 @findex -var-delete
   35341 @subheading The @code{-var-delete} Command
   35342 
   35343 @subsubheading Synopsis
   35344 
   35345 @smallexample
   35346  -var-delete [ -c ] @var{name}
   35347 @end smallexample
   35348 
   35349 Deletes a previously created variable object and all of its children.
   35350 With the @samp{-c} option, just deletes the children.
   35351 
   35352 Returns an error if the object @var{name} is not found.
   35353 
   35354 
   35355 @findex -var-set-format
   35356 @subheading The @code{-var-set-format} Command
   35357 
   35358 @subsubheading Synopsis
   35359 
   35360 @smallexample
   35361  -var-set-format @var{name} @var{format-spec}
   35362 @end smallexample
   35363 
   35364 Sets the output format for the value of the object @var{name} to be
   35365 @var{format-spec}.
   35366 
   35367 @anchor{-var-set-format}
   35368 The syntax for the @var{format-spec} is as follows:
   35369 
   35370 @smallexample
   35371  @var{format-spec} @expansion{}
   35372  @{binary | decimal | hexadecimal | octal | natural | zero-hexadecimal@}
   35373 @end smallexample
   35374 
   35375 The natural format is the default format chosen automatically
   35376 based on the variable type (like decimal for an @code{int}, hex
   35377 for pointers, etc.).
   35378 
   35379 The zero-hexadecimal format has a representation similar to hexadecimal
   35380 but with padding zeroes to the left of the value.  For example, a 32-bit
   35381 hexadecimal value of 0x1234 would be represented as 0x00001234 in the
   35382 zero-hexadecimal format.
   35383 
   35384 For a variable with children, the format is set only on the 
   35385 variable itself, and the children are not affected.  
   35386 
   35387 @findex -var-show-format
   35388 @subheading The @code{-var-show-format} Command
   35389 
   35390 @subsubheading Synopsis
   35391 
   35392 @smallexample
   35393  -var-show-format @var{name}
   35394 @end smallexample
   35395 
   35396 Returns the format used to display the value of the object @var{name}.
   35397 
   35398 @smallexample
   35399  @var{format} @expansion{}
   35400  @var{format-spec}
   35401 @end smallexample
   35402 
   35403 
   35404 @findex -var-info-num-children
   35405 @subheading The @code{-var-info-num-children} Command
   35406 
   35407 @subsubheading Synopsis
   35408 
   35409 @smallexample
   35410  -var-info-num-children @var{name}
   35411 @end smallexample
   35412 
   35413 Returns the number of children of a variable object @var{name}:
   35414 
   35415 @smallexample
   35416  numchild=@var{n}
   35417 @end smallexample
   35418 
   35419 Note that this number is not completely reliable for a dynamic varobj.
   35420 It will return the current number of children, but more children may
   35421 be available.
   35422 
   35423 
   35424 @findex -var-list-children
   35425 @subheading The @code{-var-list-children} Command
   35426 
   35427 @subsubheading Synopsis
   35428 
   35429 @smallexample
   35430  -var-list-children [@var{print-values}] @var{name} [@var{from} @var{to}]
   35431 @end smallexample
   35432 @anchor{-var-list-children}
   35433 
   35434 Return a list of the children of the specified variable object and
   35435 create variable objects for them, if they do not already exist.  With
   35436 a single argument or if @var{print-values} has a value of 0 or
   35437 @code{--no-values}, print only the names of the variables; if
   35438 @var{print-values} is 1 or @code{--all-values}, also print their
   35439 values; and if it is 2 or @code{--simple-values} print the name and
   35440 value for simple data types and just the name for arrays, structures
   35441 and unions.
   35442 
   35443 @var{from} and @var{to}, if specified, indicate the range of children
   35444 to report.  If @var{from} or @var{to} is less than zero, the range is
   35445 reset and all children will be reported.  Otherwise, children starting
   35446 at @var{from} (zero-based) and up to and excluding @var{to} will be
   35447 reported.
   35448 
   35449 If a child range is requested, it will only affect the current call to
   35450 @code{-var-list-children}, but not future calls to @code{-var-update}.
   35451 For this, you must instead use @code{-var-set-update-range}.  The
   35452 intent of this approach is to enable a front end to implement any
   35453 update approach it likes; for example, scrolling a view may cause the
   35454 front end to request more children with @code{-var-list-children}, and
   35455 then the front end could call @code{-var-set-update-range} with a
   35456 different range to ensure that future updates are restricted to just
   35457 the visible items.
   35458 
   35459 For each child the following results are returned:
   35460 
   35461 @table @var
   35462 
   35463 @item name
   35464 Name of the variable object created for this child.
   35465 
   35466 @item exp
   35467 The expression to be shown to the user by the front end to designate this child.
   35468 For example this may be the name of a structure member.
   35469 
   35470 For a dynamic varobj, this value cannot be used to form an
   35471 expression.  There is no way to do this at all with a dynamic varobj.
   35472 
   35473 For C/C@t{++} structures there are several pseudo children returned to
   35474 designate access qualifiers.  For these pseudo children @var{exp} is
   35475 @samp{public}, @samp{private}, or @samp{protected}.  In this case the
   35476 type and value are not present.
   35477 
   35478 A dynamic varobj will not report the access qualifying
   35479 pseudo-children, regardless of the language.  This information is not
   35480 available at all with a dynamic varobj.
   35481 
   35482 @item numchild
   35483 Number of children this child has.  For a dynamic varobj, this will be
   35484 0.
   35485 
   35486 @item type
   35487 The type of the child.  If @samp{print object}
   35488 (@pxref{Print Settings, set print object}) is set to @code{on}, the
   35489 @emph{actual} (derived) type of the object is shown rather than the
   35490 @emph{declared} one.
   35491 
   35492 @item value
   35493 If values were requested, this is the value.
   35494 
   35495 @item thread-id
   35496 If this variable object is associated with a thread, this is the
   35497 thread's global thread id.  Otherwise this result is not present.
   35498 
   35499 @item frozen
   35500 If the variable object is frozen, this variable will be present with a value of 1.
   35501 
   35502 @item displayhint
   35503 A dynamic varobj can supply a display hint to the front end.  The
   35504 value comes directly from the Python pretty-printer object's
   35505 @code{display_hint} method.  @xref{Pretty Printing API}.
   35506 
   35507 @item dynamic
   35508 This attribute will be present and have the value @samp{1} if the
   35509 varobj is a dynamic varobj.  If the varobj is not a dynamic varobj,
   35510 then this attribute will not be present.
   35511 
   35512 @end table
   35513 
   35514 The result may have its own attributes:
   35515 
   35516 @table @samp
   35517 @item displayhint
   35518 A dynamic varobj can supply a display hint to the front end.  The
   35519 value comes directly from the Python pretty-printer object's
   35520 @code{display_hint} method.  @xref{Pretty Printing API}.
   35521 
   35522 @item has_more
   35523 This is an integer attribute which is nonzero if there are children
   35524 remaining after the end of the selected range.
   35525 @end table
   35526 
   35527 @subsubheading Example
   35528 
   35529 @smallexample
   35530 (gdb)
   35531  -var-list-children n
   35532  ^done,numchild=@var{n},children=[child=@{name=@var{name},exp=@var{exp},
   35533  numchild=@var{n},type=@var{type}@},@r{(repeats N times)}]
   35534 (gdb)
   35535  -var-list-children --all-values n
   35536  ^done,numchild=@var{n},children=[child=@{name=@var{name},exp=@var{exp},
   35537  numchild=@var{n},value=@var{value},type=@var{type}@},@r{(repeats N times)}]
   35538 @end smallexample
   35539 
   35540 
   35541 @findex -var-info-type
   35542 @subheading The @code{-var-info-type} Command
   35543 
   35544 @subsubheading Synopsis
   35545 
   35546 @smallexample
   35547  -var-info-type @var{name}
   35548 @end smallexample
   35549 
   35550 Returns the type of the specified variable @var{name}.  The type is
   35551 returned as a string in the same format as it is output by the
   35552 @value{GDBN} CLI:
   35553 
   35554 @smallexample
   35555  type=@var{typename}
   35556 @end smallexample
   35557 
   35558 
   35559 @findex -var-info-expression
   35560 @subheading The @code{-var-info-expression} Command
   35561 
   35562 @subsubheading Synopsis
   35563 
   35564 @smallexample
   35565  -var-info-expression @var{name}
   35566 @end smallexample
   35567 
   35568 Returns a string that is suitable for presenting this
   35569 variable object in user interface.  The string is generally
   35570 not valid expression in the current language, and cannot be evaluated.
   35571 
   35572 For example, if @code{a} is an array, and variable object
   35573 @code{A} was created for @code{a}, then we'll get this output:
   35574 
   35575 @smallexample
   35576 (gdb) -var-info-expression A.1
   35577 ^done,lang="C",exp="1"
   35578 @end smallexample
   35579 
   35580 @noindent
   35581 Here, the value of @code{lang} is the language name, which can be
   35582 found in @ref{Supported Languages}.
   35583 
   35584 Note that the output of the @code{-var-list-children} command also
   35585 includes those expressions, so the @code{-var-info-expression} command
   35586 is of limited use.
   35587 
   35588 @findex -var-info-path-expression
   35589 @subheading The @code{-var-info-path-expression} Command
   35590 
   35591 @subsubheading Synopsis
   35592 
   35593 @smallexample
   35594  -var-info-path-expression @var{name}
   35595 @end smallexample
   35596 
   35597 Returns an expression that can be evaluated in the current
   35598 context and will yield the same value that a variable object has.
   35599 Compare this with the @code{-var-info-expression} command, which
   35600 result can be used only for UI presentation.  Typical use of
   35601 the @code{-var-info-path-expression} command is creating a 
   35602 watchpoint from a variable object.
   35603 
   35604 This command is currently not valid for children of a dynamic varobj,
   35605 and will give an error when invoked on one.
   35606 
   35607 For example, suppose @code{C} is a C@t{++} class, derived from class
   35608 @code{Base}, and that the @code{Base} class has a member called
   35609 @code{m_size}.  Assume a variable @code{c} is has the type of
   35610 @code{C} and a variable object @code{C} was created for variable
   35611 @code{c}.  Then, we'll get this output:
   35612 @smallexample
   35613 (gdb) -var-info-path-expression C.Base.public.m_size
   35614 ^done,path_expr=((Base)c).m_size)
   35615 @end smallexample
   35616 
   35617 @findex -var-show-attributes
   35618 @subheading The @code{-var-show-attributes} Command
   35619 
   35620 @subsubheading Synopsis
   35621 
   35622 @smallexample
   35623  -var-show-attributes @var{name}
   35624 @end smallexample
   35625 
   35626 List attributes of the specified variable object @var{name}:
   35627 
   35628 @smallexample
   35629  status=@var{attr} [ ( ,@var{attr} )* ]
   35630 @end smallexample
   35631 
   35632 @noindent
   35633 where @var{attr} is @code{@{ @{ editable | noneditable @} | TBD @}}.
   35634 
   35635 @findex -var-evaluate-expression
   35636 @subheading The @code{-var-evaluate-expression} Command
   35637 
   35638 @subsubheading Synopsis
   35639 
   35640 @smallexample
   35641  -var-evaluate-expression [-f @var{format-spec}] @var{name}
   35642 @end smallexample
   35643 
   35644 Evaluates the expression that is represented by the specified variable
   35645 object and returns its value as a string.  The format of the string
   35646 can be specified with the @samp{-f} option.  The possible values of 
   35647 this option are the same as for @code{-var-set-format} 
   35648 (@pxref{-var-set-format}).  If the @samp{-f} option is not specified,
   35649 the current display format will be used.  The current display format 
   35650 can be changed using the @code{-var-set-format} command.
   35651 
   35652 @smallexample
   35653  value=@var{value}
   35654 @end smallexample
   35655 
   35656 Note that one must invoke @code{-var-list-children} for a variable
   35657 before the value of a child variable can be evaluated.
   35658 
   35659 @findex -var-assign
   35660 @subheading The @code{-var-assign} Command
   35661 
   35662 @subsubheading Synopsis
   35663 
   35664 @smallexample
   35665  -var-assign @var{name} @var{expression}
   35666 @end smallexample
   35667 
   35668 Assigns the value of @var{expression} to the variable object specified
   35669 by @var{name}.  The object must be @samp{editable}.  If the variable's
   35670 value is altered by the assign, the variable will show up in any
   35671 subsequent @code{-var-update} list.
   35672 
   35673 @subsubheading Example
   35674 
   35675 @smallexample
   35676 (gdb)
   35677 -var-assign var1 3
   35678 ^done,value="3"
   35679 (gdb)
   35680 -var-update *
   35681 ^done,changelist=[@{name="var1",in_scope="true",type_changed="false"@}]
   35682 (gdb)
   35683 @end smallexample
   35684 
   35685 @findex -var-update
   35686 @subheading The @code{-var-update} Command
   35687 
   35688 @subsubheading Synopsis
   35689 
   35690 @smallexample
   35691  -var-update [@var{print-values}] @{@var{name} | "*"@}
   35692 @end smallexample
   35693 
   35694 Reevaluate the expressions corresponding to the variable object
   35695 @var{name} and all its direct and indirect children, and return the
   35696 list of variable objects whose values have changed; @var{name} must
   35697 be a root variable object.  Here, ``changed'' means that the result of
   35698 @code{-var-evaluate-expression} before and after the
   35699 @code{-var-update} is different.  If @samp{*} is used as the variable
   35700 object names, all existing variable objects are updated, except
   35701 for frozen ones (@pxref{-var-set-frozen}).  The option
   35702 @var{print-values} determines whether both names and values, or just
   35703 names are printed.  The possible values of this option are the same
   35704 as for @code{-var-list-children} (@pxref{-var-list-children}).  It is
   35705 recommended to use the @samp{--all-values} option, to reduce the
   35706 number of MI commands needed on each program stop.
   35707 
   35708 With the @samp{*} parameter, if a variable object is bound to a
   35709 currently running thread, it will not be updated, without any
   35710 diagnostic.
   35711 
   35712 If @code{-var-set-update-range} was previously used on a varobj, then
   35713 only the selected range of children will be reported.
   35714 
   35715 @code{-var-update} reports all the changed varobjs in a tuple named
   35716 @samp{changelist}.
   35717 
   35718 Each item in the change list is itself a tuple holding:
   35719 
   35720 @table @samp
   35721 @item name
   35722 The name of the varobj.
   35723 
   35724 @item value
   35725 If values were requested for this update, then this field will be
   35726 present and will hold the value of the varobj.
   35727 
   35728 @item in_scope
   35729 @anchor{-var-update}
   35730 This field is a string which may take one of three values:
   35731 
   35732 @table @code
   35733 @item "true"
   35734 The variable object's current value is valid.
   35735 
   35736 @item "false"
   35737 The variable object does not currently hold a valid value but it may
   35738 hold one in the future if its associated expression comes back into
   35739 scope.
   35740 
   35741 @item "invalid"
   35742 The variable object no longer holds a valid value.
   35743 This can occur when the executable file being debugged has changed,
   35744 either through recompilation or by using the @value{GDBN} @code{file}
   35745 command.  The front end should normally choose to delete these variable
   35746 objects.
   35747 @end table
   35748 
   35749 In the future new values may be added to this list so the front should
   35750 be prepared for this possibility.  @xref{GDB/MI Development and Front Ends, ,@sc{gdb/mi} Development and Front Ends}.
   35751 
   35752 @item type_changed
   35753 This is only present if the varobj is still valid.  If the type
   35754 changed, then this will be the string @samp{true}; otherwise it will
   35755 be @samp{false}.
   35756 
   35757 When a varobj's type changes, its children are also likely to have
   35758 become incorrect.  Therefore, the varobj's children are automatically
   35759 deleted when this attribute is @samp{true}.  Also, the varobj's update
   35760 range, when set using the @code{-var-set-update-range} command, is
   35761 unset.
   35762 
   35763 @item new_type
   35764 If the varobj's type changed, then this field will be present and will
   35765 hold the new type.
   35766 
   35767 @item new_num_children
   35768 For a dynamic varobj, if the number of children changed, or if the
   35769 type changed, this will be the new number of children.
   35770 
   35771 The @samp{numchild} field in other varobj responses is generally not
   35772 valid for a dynamic varobj -- it will show the number of children that
   35773 @value{GDBN} knows about, but because dynamic varobjs lazily
   35774 instantiate their children, this will not reflect the number of
   35775 children which may be available.
   35776 
   35777 The @samp{new_num_children} attribute only reports changes to the
   35778 number of children known by @value{GDBN}.  This is the only way to
   35779 detect whether an update has removed children (which necessarily can
   35780 only happen at the end of the update range).
   35781 
   35782 @item displayhint
   35783 The display hint, if any.
   35784 
   35785 @item has_more
   35786 This is an integer value, which will be 1 if there are more children
   35787 available outside the varobj's update range.
   35788 
   35789 @item dynamic
   35790 This attribute will be present and have the value @samp{1} if the
   35791 varobj is a dynamic varobj.  If the varobj is not a dynamic varobj,
   35792 then this attribute will not be present.
   35793 
   35794 @item new_children
   35795 If new children were added to a dynamic varobj within the selected
   35796 update range (as set by @code{-var-set-update-range}), then they will
   35797 be listed in this attribute.
   35798 @end table
   35799 
   35800 @subsubheading Example
   35801 
   35802 @smallexample
   35803 (gdb)
   35804 -var-assign var1 3
   35805 ^done,value="3"
   35806 (gdb)
   35807 -var-update --all-values var1
   35808 ^done,changelist=[@{name="var1",value="3",in_scope="true",
   35809 type_changed="false"@}]
   35810 (gdb)
   35811 @end smallexample
   35812 
   35813 @findex -var-set-frozen
   35814 @anchor{-var-set-frozen}
   35815 @subheading The @code{-var-set-frozen} Command
   35816 
   35817 @subsubheading Synopsis
   35818 
   35819 @smallexample
   35820  -var-set-frozen @var{name} @var{flag}
   35821 @end smallexample
   35822 
   35823 Set the frozenness flag on the variable object @var{name}.  The
   35824 @var{flag} parameter should be either @samp{1} to make the variable
   35825 frozen or @samp{0} to make it unfrozen.  If a variable object is
   35826 frozen, then neither itself, nor any of its children, are 
   35827 implicitly updated by @code{-var-update} of 
   35828 a parent variable or by @code{-var-update *}.  Only
   35829 @code{-var-update} of the variable itself will update its value and
   35830 values of its children.  After a variable object is unfrozen, it is
   35831 implicitly updated by all subsequent @code{-var-update} operations.  
   35832 Unfreezing a variable does not update it, only subsequent
   35833 @code{-var-update} does.
   35834 
   35835 @subsubheading Example
   35836 
   35837 @smallexample
   35838 (gdb)
   35839 -var-set-frozen V 1
   35840 ^done
   35841 (gdb)
   35842 @end smallexample
   35843 
   35844 @findex -var-set-update-range
   35845 @anchor{-var-set-update-range}
   35846 @subheading The @code{-var-set-update-range} command
   35847 
   35848 @subsubheading Synopsis
   35849 
   35850 @smallexample
   35851  -var-set-update-range @var{name} @var{from} @var{to}
   35852 @end smallexample
   35853 
   35854 Set the range of children to be returned by future invocations of
   35855 @code{-var-update}.
   35856 
   35857 @var{from} and @var{to} indicate the range of children to report.  If
   35858 @var{from} or @var{to} is less than zero, the range is reset and all
   35859 children will be reported.  Otherwise, children starting at @var{from}
   35860 (zero-based) and up to and excluding @var{to} will be reported.
   35861 
   35862 @subsubheading Example
   35863 
   35864 @smallexample
   35865 (gdb)
   35866 -var-set-update-range V 1 2
   35867 ^done
   35868 @end smallexample
   35869 
   35870 @findex -var-set-visualizer
   35871 @anchor{-var-set-visualizer}
   35872 @subheading The @code{-var-set-visualizer} command
   35873 
   35874 @subsubheading Synopsis
   35875 
   35876 @smallexample
   35877  -var-set-visualizer @var{name} @var{visualizer}
   35878 @end smallexample
   35879 
   35880 Set a visualizer for the variable object @var{name}.
   35881 
   35882 @var{visualizer} is the visualizer to use.  The special value
   35883 @samp{None} means to disable any visualizer in use.
   35884 
   35885 If not @samp{None}, @var{visualizer} must be a Python expression.
   35886 This expression must evaluate to a callable object which accepts a
   35887 single argument.  @value{GDBN} will call this object with the value of
   35888 the varobj @var{name} as an argument (this is done so that the same
   35889 Python pretty-printing code can be used for both the CLI and MI).
   35890 When called, this object must return an object which conforms to the
   35891 pretty-printing interface (@pxref{Pretty Printing API}).
   35892 
   35893 The pre-defined function @code{gdb.default_visualizer} may be used to
   35894 select a visualizer by following the built-in process
   35895 (@pxref{Selecting Pretty-Printers}).  This is done automatically when
   35896 a varobj is created, and so ordinarily is not needed.
   35897 
   35898 This feature is only available if Python support is enabled.  The MI
   35899 command @code{-list-features} (@pxref{GDB/MI Support Commands})
   35900 can be used to check this.
   35901 
   35902 @subsubheading Example
   35903 
   35904 Resetting the visualizer:
   35905 
   35906 @smallexample
   35907 (gdb)
   35908 -var-set-visualizer V None
   35909 ^done
   35910 @end smallexample
   35911 
   35912 Reselecting the default (type-based) visualizer:
   35913 
   35914 @smallexample
   35915 (gdb)
   35916 -var-set-visualizer V gdb.default_visualizer
   35917 ^done
   35918 @end smallexample
   35919 
   35920 Suppose @code{SomeClass} is a visualizer class.  A lambda expression
   35921 can be used to instantiate this class for a varobj:
   35922 
   35923 @smallexample
   35924 (gdb)
   35925 -var-set-visualizer V "lambda val: SomeClass()"
   35926 ^done
   35927 @end smallexample
   35928 
   35929 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   35930 @node GDB/MI Data Manipulation
   35931 @section @sc{gdb/mi} Data Manipulation
   35932 
   35933 @cindex data manipulation, in @sc{gdb/mi}
   35934 @cindex @sc{gdb/mi}, data manipulation
   35935 This section describes the @sc{gdb/mi} commands that manipulate data:
   35936 examine memory and registers, evaluate expressions, etc.
   35937 
   35938 For details about what an addressable memory unit is,
   35939 @pxref{addressable memory unit}.
   35940 
   35941 @c REMOVED FROM THE INTERFACE.
   35942 @c @subheading -data-assign
   35943 @c Change the value of a program variable. Plenty of side effects.
   35944 @c @subsubheading GDB Command
   35945 @c set variable
   35946 @c @subsubheading Example
   35947 @c N.A.
   35948 
   35949 @findex -data-disassemble
   35950 @subheading The @code{-data-disassemble} Command
   35951 
   35952 @subsubheading Synopsis
   35953 
   35954 @smallexample
   35955  -data-disassemble
   35956   ( -s @var{start-addr} -e @var{end-addr}
   35957   | -a @var{addr}
   35958   | -f @var{filename} -l @var{linenum} [ -n @var{lines} ] )
   35959   [ --opcodes @var{opcodes-mode} ]
   35960   [ --source ]
   35961   [ -- @var{mode} ]
   35962 @end smallexample
   35963 
   35964 @noindent
   35965 Where:
   35966 
   35967 @table @samp
   35968 @item @var{start-addr}
   35969 is the beginning address (or @code{$pc})
   35970 @item @var{end-addr}
   35971 is the end address
   35972 @item @var{addr}
   35973 is an address anywhere within (or the name of) the function to
   35974 disassemble.  If an address is specified, the whole function
   35975 surrounding that address will be disassembled.  If a name is
   35976 specified, the whole function with that name will be disassembled.
   35977 @item @var{filename}
   35978 is the name of the file to disassemble
   35979 @item @var{linenum}
   35980 is the line number to disassemble around
   35981 @item @var{lines}
   35982 is the number of disassembly lines to be produced.  If it is -1,
   35983 the whole function will be disassembled, in case no @var{end-addr} is
   35984 specified.  If @var{end-addr} is specified as a non-zero value, and
   35985 @var{lines} is lower than the number of disassembly lines between
   35986 @var{start-addr} and @var{end-addr}, only @var{lines} lines are
   35987 displayed; if @var{lines} is higher than the number of lines between
   35988 @var{start-addr} and @var{end-addr}, only the lines up to @var{end-addr}
   35989 are displayed.
   35990 @item @var{opcodes-mode}
   35991 can only be used with @var{mode} 0, and should be one of the following:
   35992 @table @samp
   35993 @item none
   35994 no opcode information will be included in the result.
   35995 
   35996 @item bytes
   35997 opcodes will be included in the result, the opcodes will be formatted
   35998 as for @kbd{disassemble /b}.
   35999 
   36000 @item display
   36001 opcodes will be included in the result, the opcodes will be formatted
   36002 as for @kbd{disassemble /r}.
   36003 @end table
   36004 @item @var{mode}
   36005 the use of @var{mode} is deprecated in favour of using the
   36006 @code{--opcodes} and @code{--source} options.  When no @var{mode} is
   36007 given, @var{mode} 0 will be assumed.  However, the @var{mode} is still
   36008 available for backward compatibility.  The @var{mode} should be one of:
   36009 @table @samp
   36010 @item 0
   36011 @emph{disassembly only}, this is the default mode if no mode is
   36012 specified.
   36013 
   36014 @item 1
   36015 @emph{mixed source and disassembly (deprecated)}, it is not possible
   36016 to recreate this mode using @code{--opcodes} and @code{--source}
   36017 options.
   36018 
   36019 @item 2
   36020 @emph{disassembly with raw opcodes}, this mode is equivalent to using
   36021 @var{mode} 0 and passing @code{--opcodes bytes} to the command.
   36022 
   36023 @item 3
   36024 @emph{mixed source and disassembly with raw opcodes (deprecated)}, it
   36025 is not possible to recreate this mode using @code{--opcodes} and
   36026 @code{--source} options.
   36027 
   36028 @item 4
   36029 @emph{mixed source and disassembly}, this mode is equivalent to using
   36030 @var{mode} 0 and passing @code{--source} to the command.
   36031 
   36032 @item 5
   36033 @emph{mixed source and disassembly with raw opcodes}, this mode is
   36034 equivalent to using @var{mode} 0 and passing @code{--opcodes bytes}
   36035 and @code{--source} to the command.
   36036 @end table
   36037 Modes 1 and 3 are deprecated.  The output is ``source centric''
   36038 which hasn't proved useful in practice.
   36039 @xref{Machine Code}, for a discussion of the difference between
   36040 @code{/m} and @code{/s} output of the @code{disassemble} command.
   36041 @end table
   36042 
   36043 The @code{--source} can only be used with @var{mode} 0.  Passing this
   36044 option will include the source code in the disassembly result as if
   36045 @var{mode} 4 or 5 had been used.
   36046 
   36047 @subsubheading Result
   36048 
   36049 The result of the @code{-data-disassemble} command will be a list named
   36050 @samp{asm_insns}, the contents of this list depend on the options used
   36051 with the @code{-data-disassemble} command.
   36052 
   36053 For modes 0 and 2, and when the @code{--source} option is not used, the
   36054 @samp{asm_insns} list contains tuples with the following fields:
   36055 
   36056 @table @code
   36057 @item address
   36058 The address at which this instruction was disassembled.
   36059 
   36060 @item func-name
   36061 The name of the function this instruction is within.
   36062 
   36063 @item offset
   36064 The decimal offset in bytes from the start of @samp{func-name}.
   36065 
   36066 @item inst
   36067 The text disassembly for this @samp{address}.
   36068 
   36069 @item opcodes
   36070 This field is only present for modes 2, 3 and 5, or when the
   36071 @code{--opcodes} option @samp{bytes} or @samp{display} is used.  This
   36072 contains the raw opcode bytes for the @samp{inst} field.
   36073 
   36074 When the @samp{--opcodes} option is not passed to
   36075 @code{-data-disassemble}, or the @samp{bytes} value is passed to
   36076 @samp{--opcodes}, then the bytes are formatted as a series of single
   36077 bytes, in hex, in ascending address order, with a single space between
   36078 each byte.  This format is equivalent to the @samp{/b} option being
   36079 used with the @kbd{disassemble} command
   36080 (@pxref{disassemble,,@kbd{disassemble}}).
   36081 
   36082 When @samp{--opcodes} is passed the value @samp{display} then the bytes
   36083 are formatted in the natural instruction display order.  This means
   36084 multiple bytes can be grouped together, and the bytes might be
   36085 byte-swapped.  This format is equivalent to the @samp{/r} option being
   36086 used with the @kbd{disassemble} command.
   36087 @end table
   36088 
   36089 For modes 1, 3, 4 and 5, or when the @code{--source} option is used, the
   36090 @samp{asm_insns} list contains tuples named @samp{src_and_asm_line},
   36091 each of which has the following fields:
   36092 
   36093 @table @code
   36094 @item line
   36095 The line number within @samp{file}.
   36096 
   36097 @item file
   36098 The file name from the compilation unit.  This might be an absolute
   36099 file name or a relative file name depending on the compile command
   36100 used.
   36101 
   36102 @item fullname
   36103 Absolute file name of @samp{file}.  It is converted to a canonical form
   36104 using the source file search path
   36105 (@pxref{Source Path, ,Specifying Source Directories})
   36106 and after resolving all the symbolic links.
   36107 
   36108 If the source file is not found this field will contain the path as
   36109 present in the debug information.
   36110 
   36111 @item line_asm_insn
   36112 This is a list of tuples containing the disassembly for @samp{line} in
   36113 @samp{file}.  The fields of each tuple are the same as for
   36114 @code{-data-disassemble} in @var{mode} 0 and 2, so @samp{address},
   36115 @samp{func-name}, @samp{offset}, @samp{inst}, and optionally
   36116 @samp{opcodes}.
   36117 
   36118 @end table
   36119 
   36120 Note that whatever included in the @samp{inst} field, is not
   36121 manipulated directly by @sc{gdb/mi}, i.e., it is not possible to
   36122 adjust its format.
   36123 
   36124 @subsubheading @value{GDBN} Command
   36125 
   36126 The corresponding @value{GDBN} command is @samp{disassemble}.
   36127 
   36128 @subsubheading Example
   36129 
   36130 Disassemble from the current value of @code{$pc} to @code{$pc + 20}:
   36131 
   36132 @smallexample
   36133 (gdb)
   36134 -data-disassemble -s $pc -e "$pc + 20" -- 0
   36135 ^done,
   36136 asm_insns=[
   36137 @{address="0x000107c0",func-name="main",offset="4",
   36138 inst="mov  2, %o0"@},
   36139 @{address="0x000107c4",func-name="main",offset="8",
   36140 inst="sethi  %hi(0x11800), %o2"@},
   36141 @{address="0x000107c8",func-name="main",offset="12",
   36142 inst="or  %o2, 0x140, %o1\t! 0x11940 <_lib_version+8>"@},
   36143 @{address="0x000107cc",func-name="main",offset="16",
   36144 inst="sethi  %hi(0x11800), %o2"@},
   36145 @{address="0x000107d0",func-name="main",offset="20",
   36146 inst="or  %o2, 0x168, %o4\t! 0x11968 <_lib_version+48>"@}]
   36147 (gdb)
   36148 @end smallexample
   36149 
   36150 Disassemble the whole @code{main} function.  Line 32 is part of
   36151 @code{main}.
   36152 
   36153 @smallexample
   36154 -data-disassemble -f basics.c -l 32 -- 0
   36155 ^done,asm_insns=[
   36156 @{address="0x000107bc",func-name="main",offset="0",
   36157 inst="save  %sp, -112, %sp"@},
   36158 @{address="0x000107c0",func-name="main",offset="4",
   36159 inst="mov   2, %o0"@},
   36160 @{address="0x000107c4",func-name="main",offset="8",
   36161 inst="sethi %hi(0x11800), %o2"@},
   36162 [@dots{}]
   36163 @{address="0x0001081c",func-name="main",offset="96",inst="ret "@},
   36164 @{address="0x00010820",func-name="main",offset="100",inst="restore "@}]
   36165 (gdb)
   36166 @end smallexample
   36167 
   36168 Disassemble 3 instructions from the start of @code{main}:
   36169 
   36170 @smallexample
   36171 (gdb)
   36172 -data-disassemble -f basics.c -l 32 -n 3 -- 0
   36173 ^done,asm_insns=[
   36174 @{address="0x000107bc",func-name="main",offset="0",
   36175 inst="save  %sp, -112, %sp"@},
   36176 @{address="0x000107c0",func-name="main",offset="4",
   36177 inst="mov  2, %o0"@},
   36178 @{address="0x000107c4",func-name="main",offset="8",
   36179 inst="sethi  %hi(0x11800), %o2"@}]
   36180 (gdb)
   36181 @end smallexample
   36182 
   36183 Disassemble 3 instructions from the start of @code{main} in mixed mode:
   36184 
   36185 @smallexample
   36186 (gdb)
   36187 -data-disassemble -f basics.c -l 32 -n 3 -- 1
   36188 ^done,asm_insns=[
   36189 src_and_asm_line=@{line="31",
   36190 file="../../../src/gdb/testsuite/gdb.mi/basics.c",
   36191 fullname="/absolute/path/to/src/gdb/testsuite/gdb.mi/basics.c",
   36192 line_asm_insn=[@{address="0x000107bc",
   36193 func-name="main",offset="0",inst="save  %sp, -112, %sp"@}]@},
   36194 src_and_asm_line=@{line="32",
   36195 file="../../../src/gdb/testsuite/gdb.mi/basics.c",
   36196 fullname="/absolute/path/to/src/gdb/testsuite/gdb.mi/basics.c",
   36197 line_asm_insn=[@{address="0x000107c0",
   36198 func-name="main",offset="4",inst="mov  2, %o0"@},
   36199 @{address="0x000107c4",func-name="main",offset="8",
   36200 inst="sethi  %hi(0x11800), %o2"@}]@}]
   36201 (gdb)
   36202 @end smallexample
   36203 
   36204 
   36205 @findex -data-evaluate-expression
   36206 @subheading The @code{-data-evaluate-expression} Command
   36207 
   36208 @subsubheading Synopsis
   36209 
   36210 @smallexample
   36211  -data-evaluate-expression @var{expr}
   36212 @end smallexample
   36213 
   36214 Evaluate @var{expr} as an expression.  The expression could contain an
   36215 inferior function call.  The function call will execute synchronously.
   36216 If the expression contains spaces, it must be enclosed in double quotes.
   36217 
   36218 @subsubheading @value{GDBN} Command
   36219 
   36220 The corresponding @value{GDBN} commands are @samp{print}, @samp{output}, and
   36221 @samp{call}.  In @code{gdbtk} only, there's a corresponding
   36222 @samp{gdb_eval} command.
   36223 
   36224 @subsubheading Example
   36225 
   36226 In the following example, the numbers that precede the commands are the
   36227 @dfn{tokens} described in @ref{GDB/MI Command Syntax, ,@sc{gdb/mi}
   36228 Command Syntax}.  Notice how @sc{gdb/mi} returns the same tokens in its
   36229 output.
   36230 
   36231 @smallexample
   36232 211-data-evaluate-expression A
   36233 211^done,value="1"
   36234 (gdb)
   36235 311-data-evaluate-expression &A
   36236 311^done,value="0xefffeb7c"
   36237 (gdb)
   36238 411-data-evaluate-expression A+3
   36239 411^done,value="4"
   36240 (gdb)
   36241 511-data-evaluate-expression "A + 3"
   36242 511^done,value="4"
   36243 (gdb)
   36244 @end smallexample
   36245 
   36246 
   36247 @findex -data-list-changed-registers
   36248 @subheading The @code{-data-list-changed-registers} Command
   36249 
   36250 @subsubheading Synopsis
   36251 
   36252 @smallexample
   36253  -data-list-changed-registers
   36254 @end smallexample
   36255 
   36256 Display a list of the registers that have changed.
   36257 
   36258 @subsubheading @value{GDBN} Command
   36259 
   36260 @value{GDBN} doesn't have a direct analog for this command; @code{gdbtk}
   36261 has the corresponding command @samp{gdb_changed_register_list}.
   36262 
   36263 @subsubheading Example
   36264 
   36265 On a PPC MBX board:
   36266 
   36267 @smallexample
   36268 (gdb)
   36269 -exec-continue
   36270 ^running
   36271 
   36272 (gdb)
   36273 *stopped,reason="breakpoint-hit",disp="keep",bkptno="1",frame=@{
   36274 func="main",args=[],file="try.c",fullname="/home/foo/bar/try.c",
   36275 line="5",arch="powerpc"@}
   36276 (gdb)
   36277 -data-list-changed-registers
   36278 ^done,changed-registers=["0","1","2","4","5","6","7","8","9",
   36279 "10","11","13","14","15","16","17","18","19","20","21","22","23",
   36280 "24","25","26","27","28","30","31","64","65","66","67","69"]
   36281 (gdb)
   36282 @end smallexample
   36283 
   36284 
   36285 @findex -data-list-register-names
   36286 @subheading The @code{-data-list-register-names} Command
   36287 
   36288 @subsubheading Synopsis
   36289 
   36290 @smallexample
   36291  -data-list-register-names [ ( @var{regno} )+ ]
   36292 @end smallexample
   36293 
   36294 Show a list of register names for the current target.  If no arguments
   36295 are given, it shows a list of the names of all the registers.  If
   36296 integer numbers are given as arguments, it will print a list of the
   36297 names of the registers corresponding to the arguments.  To ensure
   36298 consistency between a register name and its number, the output list may
   36299 include empty register names.
   36300 
   36301 @subsubheading @value{GDBN} Command
   36302 
   36303 @value{GDBN} does not have a command which corresponds to
   36304 @samp{-data-list-register-names}.  In @code{gdbtk} there is a
   36305 corresponding command @samp{gdb_regnames}.
   36306 
   36307 @subsubheading Example
   36308 
   36309 For the PPC MBX board:
   36310 @smallexample
   36311 (gdb)
   36312 -data-list-register-names
   36313 ^done,register-names=["r0","r1","r2","r3","r4","r5","r6","r7",
   36314 "r8","r9","r10","r11","r12","r13","r14","r15","r16","r17","r18",
   36315 "r19","r20","r21","r22","r23","r24","r25","r26","r27","r28","r29",
   36316 "r30","r31","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9",
   36317 "f10","f11","f12","f13","f14","f15","f16","f17","f18","f19","f20",
   36318 "f21","f22","f23","f24","f25","f26","f27","f28","f29","f30","f31",
   36319 "", "pc","ps","cr","lr","ctr","xer"]
   36320 (gdb)
   36321 -data-list-register-names 1 2 3
   36322 ^done,register-names=["r1","r2","r3"]
   36323 (gdb)
   36324 @end smallexample
   36325 
   36326 @findex -data-list-register-values
   36327 @subheading The @code{-data-list-register-values} Command
   36328 
   36329 @subsubheading Synopsis
   36330 
   36331 @smallexample
   36332  -data-list-register-values
   36333     [ @code{--skip-unavailable} ] @var{fmt} [ ( @var{regno} )*]
   36334 @end smallexample
   36335 
   36336 Display the registers' contents.  The format according to which the
   36337 registers' contents are to be returned is given by @var{fmt}, followed
   36338 by an optional list of numbers specifying the registers to display.  A
   36339 missing list of numbers indicates that the contents of all the
   36340 registers must be returned.  The @code{--skip-unavailable} option
   36341 indicates that only the available registers are to be returned.
   36342 
   36343 Allowed formats for @var{fmt} are:
   36344 
   36345 @table @code
   36346 @item x
   36347 Hexadecimal
   36348 @item o
   36349 Octal
   36350 @item t
   36351 Binary
   36352 @item d
   36353 Decimal
   36354 @item r
   36355 Raw
   36356 @item N
   36357 Natural
   36358 @end table
   36359 
   36360 @subsubheading @value{GDBN} Command
   36361 
   36362 The corresponding @value{GDBN} commands are @samp{info reg}, @samp{info
   36363 all-reg}, and (in @code{gdbtk}) @samp{gdb_fetch_registers}.
   36364 
   36365 @subsubheading Example
   36366 
   36367 For a PPC MBX board (note: line breaks are for readability only, they
   36368 don't appear in the actual output):
   36369 
   36370 @smallexample
   36371 (gdb)
   36372 -data-list-register-values r 64 65
   36373 ^done,register-values=[@{number="64",value="0xfe00a300"@},
   36374 @{number="65",value="0x00029002"@}]
   36375 (gdb)
   36376 -data-list-register-values x
   36377 ^done,register-values=[@{number="0",value="0xfe0043c8"@},
   36378 @{number="1",value="0x3fff88"@},@{number="2",value="0xfffffffe"@},
   36379 @{number="3",value="0x0"@},@{number="4",value="0xa"@},
   36380 @{number="5",value="0x3fff68"@},@{number="6",value="0x3fff58"@},
   36381 @{number="7",value="0xfe011e98"@},@{number="8",value="0x2"@},
   36382 @{number="9",value="0xfa202820"@},@{number="10",value="0xfa202808"@},
   36383 @{number="11",value="0x1"@},@{number="12",value="0x0"@},
   36384 @{number="13",value="0x4544"@},@{number="14",value="0xffdfffff"@},
   36385 @{number="15",value="0xffffffff"@},@{number="16",value="0xfffffeff"@},
   36386 @{number="17",value="0xefffffed"@},@{number="18",value="0xfffffffe"@},
   36387 @{number="19",value="0xffffffff"@},@{number="20",value="0xffffffff"@},
   36388 @{number="21",value="0xffffffff"@},@{number="22",value="0xfffffff7"@},
   36389 @{number="23",value="0xffffffff"@},@{number="24",value="0xffffffff"@},
   36390 @{number="25",value="0xffffffff"@},@{number="26",value="0xfffffffb"@},
   36391 @{number="27",value="0xffffffff"@},@{number="28",value="0xf7bfffff"@},
   36392 @{number="29",value="0x0"@},@{number="30",value="0xfe010000"@},
   36393 @{number="31",value="0x0"@},@{number="32",value="0x0"@},
   36394 @{number="33",value="0x0"@},@{number="34",value="0x0"@},
   36395 @{number="35",value="0x0"@},@{number="36",value="0x0"@},
   36396 @{number="37",value="0x0"@},@{number="38",value="0x0"@},
   36397 @{number="39",value="0x0"@},@{number="40",value="0x0"@},
   36398 @{number="41",value="0x0"@},@{number="42",value="0x0"@},
   36399 @{number="43",value="0x0"@},@{number="44",value="0x0"@},
   36400 @{number="45",value="0x0"@},@{number="46",value="0x0"@},
   36401 @{number="47",value="0x0"@},@{number="48",value="0x0"@},
   36402 @{number="49",value="0x0"@},@{number="50",value="0x0"@},
   36403 @{number="51",value="0x0"@},@{number="52",value="0x0"@},
   36404 @{number="53",value="0x0"@},@{number="54",value="0x0"@},
   36405 @{number="55",value="0x0"@},@{number="56",value="0x0"@},
   36406 @{number="57",value="0x0"@},@{number="58",value="0x0"@},
   36407 @{number="59",value="0x0"@},@{number="60",value="0x0"@},
   36408 @{number="61",value="0x0"@},@{number="62",value="0x0"@},
   36409 @{number="63",value="0x0"@},@{number="64",value="0xfe00a300"@},
   36410 @{number="65",value="0x29002"@},@{number="66",value="0x202f04b5"@},
   36411 @{number="67",value="0xfe0043b0"@},@{number="68",value="0xfe00b3e4"@},
   36412 @{number="69",value="0x20002b03"@}]
   36413 (gdb)
   36414 @end smallexample
   36415 
   36416 
   36417 @findex -data-read-memory
   36418 @subheading The @code{-data-read-memory} Command
   36419 
   36420 This command is deprecated, use @code{-data-read-memory-bytes} instead.
   36421 
   36422 @subsubheading Synopsis
   36423 
   36424 @smallexample
   36425  -data-read-memory [ -o @var{byte-offset} ]
   36426    @var{address} @var{word-format} @var{word-size}
   36427    @var{nr-rows} @var{nr-cols} [ @var{aschar} ]
   36428 @end smallexample
   36429 
   36430 @noindent
   36431 where:
   36432 
   36433 @table @samp
   36434 @item @var{address}
   36435 An expression specifying the address of the first memory word to be
   36436 read.  Complex expressions containing embedded white space should be
   36437 quoted using the C convention.
   36438 
   36439 @item @var{word-format}
   36440 The format to be used to print the memory words.  The notation is the
   36441 same as for @value{GDBN}'s @code{print} command (@pxref{Output Formats,
   36442 ,Output Formats}).
   36443 
   36444 @item @var{word-size}
   36445 The size of each memory word in bytes.
   36446 
   36447 @item @var{nr-rows}
   36448 The number of rows in the output table.
   36449 
   36450 @item @var{nr-cols}
   36451 The number of columns in the output table.
   36452 
   36453 @item @var{aschar}
   36454 If present, indicates that each row should include an @sc{ascii} dump.  The
   36455 value of @var{aschar} is used as a padding character when a byte is not a
   36456 member of the printable @sc{ascii} character set (printable @sc{ascii}
   36457 characters are those whose code is between 32 and 126, inclusively).
   36458 
   36459 @item @var{byte-offset}
   36460 An offset to add to the @var{address} before fetching memory.
   36461 @end table
   36462 
   36463 This command displays memory contents as a table of @var{nr-rows} by
   36464 @var{nr-cols} words, each word being @var{word-size} bytes.  In total,
   36465 @code{@var{nr-rows} * @var{nr-cols} * @var{word-size}} bytes are read
   36466 (returned as @samp{total-bytes}).  Should less than the requested number
   36467 of bytes be returned by the target, the missing words are identified
   36468 using @samp{N/A}.  The number of bytes read from the target is returned
   36469 in @samp{nr-bytes} and the starting address used to read memory in
   36470 @samp{addr}.
   36471 
   36472 The address of the next/previous row or page is available in
   36473 @samp{next-row} and @samp{prev-row}, @samp{next-page} and
   36474 @samp{prev-page}.
   36475 
   36476 @subsubheading @value{GDBN} Command
   36477 
   36478 The corresponding @value{GDBN} command is @samp{x}.  @code{gdbtk} has
   36479 @samp{gdb_get_mem} memory read command.
   36480 
   36481 @subsubheading Example
   36482 
   36483 Read six bytes of memory starting at @code{bytes+6} but then offset by
   36484 @code{-6} bytes.  Format as three rows of two columns.  One byte per
   36485 word.  Display each word in hex.
   36486 
   36487 @smallexample
   36488 (gdb)
   36489 9-data-read-memory -o -6 -- bytes+6 x 1 3 2
   36490 9^done,addr="0x00001390",nr-bytes="6",total-bytes="6",
   36491 next-row="0x00001396",prev-row="0x0000138e",next-page="0x00001396",
   36492 prev-page="0x0000138a",memory=[
   36493 @{addr="0x00001390",data=["0x00","0x01"]@},
   36494 @{addr="0x00001392",data=["0x02","0x03"]@},
   36495 @{addr="0x00001394",data=["0x04","0x05"]@}]
   36496 (gdb)
   36497 @end smallexample
   36498 
   36499 Read two bytes of memory starting at address @code{shorts + 64} and
   36500 display as a single word formatted in decimal.
   36501 
   36502 @smallexample
   36503 (gdb)
   36504 5-data-read-memory shorts+64 d 2 1 1
   36505 5^done,addr="0x00001510",nr-bytes="2",total-bytes="2",
   36506 next-row="0x00001512",prev-row="0x0000150e",
   36507 next-page="0x00001512",prev-page="0x0000150e",memory=[
   36508 @{addr="0x00001510",data=["128"]@}]
   36509 (gdb)
   36510 @end smallexample
   36511 
   36512 Read thirty two bytes of memory starting at @code{bytes+16} and format
   36513 as eight rows of four columns.  Include a string encoding with @samp{x}
   36514 used as the non-printable character.
   36515 
   36516 @smallexample
   36517 (gdb)
   36518 4-data-read-memory bytes+16 x 1 8 4 x
   36519 4^done,addr="0x000013a0",nr-bytes="32",total-bytes="32",
   36520 next-row="0x000013c0",prev-row="0x0000139c",
   36521 next-page="0x000013c0",prev-page="0x00001380",memory=[
   36522 @{addr="0x000013a0",data=["0x10","0x11","0x12","0x13"],ascii="xxxx"@},
   36523 @{addr="0x000013a4",data=["0x14","0x15","0x16","0x17"],ascii="xxxx"@},
   36524 @{addr="0x000013a8",data=["0x18","0x19","0x1a","0x1b"],ascii="xxxx"@},
   36525 @{addr="0x000013ac",data=["0x1c","0x1d","0x1e","0x1f"],ascii="xxxx"@},
   36526 @{addr="0x000013b0",data=["0x20","0x21","0x22","0x23"],ascii=" !\"#"@},
   36527 @{addr="0x000013b4",data=["0x24","0x25","0x26","0x27"],ascii="$%&'"@},
   36528 @{addr="0x000013b8",data=["0x28","0x29","0x2a","0x2b"],ascii="()*+"@},
   36529 @{addr="0x000013bc",data=["0x2c","0x2d","0x2e","0x2f"],ascii=",-./"@}]
   36530 (gdb)
   36531 @end smallexample
   36532 
   36533 @findex -data-read-memory-bytes
   36534 @subheading The @code{-data-read-memory-bytes} Command
   36535 
   36536 @subsubheading Synopsis
   36537 
   36538 @smallexample
   36539  -data-read-memory-bytes [ -o @var{offset} ]
   36540    @var{address} @var{count}
   36541 @end smallexample
   36542 
   36543 @noindent
   36544 where:
   36545 
   36546 @table @samp
   36547 @item @var{address}
   36548 An expression specifying the address of the first addressable memory unit
   36549 to be read.  Complex expressions containing embedded white space should be
   36550 quoted using the C convention.
   36551 
   36552 @item @var{count}
   36553 The number of addressable memory units to read.  This should be an integer
   36554 literal.
   36555 
   36556 @item @var{offset}
   36557 The offset relative to @var{address} at which to start reading.  This
   36558 should be an integer literal.  This option is provided so that a frontend
   36559 is not required to first evaluate address and then perform address
   36560 arithmetic itself.
   36561 
   36562 @end table
   36563 
   36564 This command attempts to read all accessible memory regions in the
   36565 specified range.  First, all regions marked as unreadable in the memory
   36566 map (if one is defined) will be skipped.  @xref{Memory Region
   36567 Attributes}.  Second, @value{GDBN} will attempt to read the remaining
   36568 regions.  For each one, if reading full region results in an errors,
   36569 @value{GDBN} will try to read a subset of the region.
   36570 
   36571 In general, every single memory unit in the region may be readable or not,
   36572 and the only way to read every readable unit is to try a read at
   36573 every address, which is not practical.   Therefore, @value{GDBN} will
   36574 attempt to read all accessible memory units at either beginning or the end
   36575 of the region, using a binary division scheme.  This heuristic works
   36576 well for reading across a memory map boundary.  Note that if a region
   36577 has a readable range that is neither at the beginning or the end,
   36578 @value{GDBN} will not read it.
   36579 
   36580 The result record (@pxref{GDB/MI Result Records}) that is output of
   36581 the command includes a field named @samp{memory} whose content is a
   36582 list of tuples.  Each tuple represent a successfully read memory block
   36583 and has the following fields:
   36584 
   36585 @table @code
   36586 @item begin
   36587 The start address of the memory block, as hexadecimal literal.
   36588 
   36589 @item end
   36590 The end address of the memory block, as hexadecimal literal.
   36591 
   36592 @item offset
   36593 The offset of the memory block, as hexadecimal literal, relative to
   36594 the start address passed to @code{-data-read-memory-bytes}.
   36595 
   36596 @item contents
   36597 The contents of the memory block, in hex.
   36598 
   36599 @end table
   36600 
   36601 
   36602 
   36603 @subsubheading @value{GDBN} Command
   36604 
   36605 The corresponding @value{GDBN} command is @samp{x}.
   36606 
   36607 @subsubheading Example
   36608 
   36609 @smallexample
   36610 (gdb)
   36611 -data-read-memory-bytes &a 10
   36612 ^done,memory=[@{begin="0xbffff154",offset="0x00000000",
   36613               end="0xbffff15e",
   36614               contents="01000000020000000300"@}]
   36615 (gdb)
   36616 @end smallexample
   36617 
   36618 
   36619 @findex -data-write-memory-bytes
   36620 @subheading The @code{-data-write-memory-bytes} Command
   36621 
   36622 @subsubheading Synopsis
   36623 
   36624 @smallexample
   36625  -data-write-memory-bytes @var{address} @var{contents}
   36626  -data-write-memory-bytes @var{address} @var{contents} @r{[}@var{count}@r{]}
   36627 @end smallexample
   36628 
   36629 @noindent
   36630 where:
   36631 
   36632 @table @samp
   36633 @item @var{address}
   36634 An expression specifying the address of the first addressable memory unit
   36635 to be written.  Complex expressions containing embedded white space should
   36636 be quoted using the C convention.
   36637 
   36638 @item @var{contents}
   36639 The hex-encoded data to write.  It is an error if @var{contents} does
   36640 not represent an integral number of addressable memory units.
   36641 
   36642 @item @var{count}
   36643 Optional argument indicating the number of addressable memory units to be
   36644 written.  If @var{count} is greater than @var{contents}' length,
   36645 @value{GDBN} will repeatedly write @var{contents} until it fills
   36646 @var{count} memory units.
   36647 
   36648 @end table
   36649 
   36650 @subsubheading @value{GDBN} Command
   36651 
   36652 There's no corresponding @value{GDBN} command.
   36653 
   36654 @subsubheading Example
   36655 
   36656 @smallexample
   36657 (gdb)
   36658 -data-write-memory-bytes &a "aabbccdd"
   36659 ^done
   36660 (gdb)
   36661 @end smallexample
   36662 
   36663 @smallexample
   36664 (gdb)
   36665 -data-write-memory-bytes &a "aabbccdd" 16e
   36666 ^done
   36667 (gdb)
   36668 @end smallexample
   36669 
   36670 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   36671 @node GDB/MI Tracepoint Commands
   36672 @section @sc{gdb/mi} Tracepoint Commands
   36673 
   36674 The commands defined in this section implement MI support for
   36675 tracepoints.  For detailed introduction, see @ref{Tracepoints}.
   36676 
   36677 @findex -trace-find
   36678 @subheading The @code{-trace-find} Command
   36679 
   36680 @subsubheading Synopsis
   36681 
   36682 @smallexample
   36683  -trace-find @var{mode} [@var{parameters}@dots{}]
   36684 @end smallexample
   36685 
   36686 Find a trace frame using criteria defined by @var{mode} and
   36687 @var{parameters}.  The following table lists permissible
   36688 modes and their parameters.  For details of operation, see @ref{tfind}.
   36689 
   36690 @table @samp
   36691 
   36692 @item none
   36693 No parameters are required.  Stops examining trace frames.
   36694 
   36695 @item frame-number
   36696 An integer is required as parameter.  Selects tracepoint frame with
   36697 that index.
   36698 
   36699 @item tracepoint-number
   36700 An integer is required as parameter.  Finds next
   36701 trace frame that corresponds to tracepoint with the specified number.
   36702 
   36703 @item pc
   36704 An address is required as parameter.  Finds
   36705 next trace frame that corresponds to any tracepoint at the specified
   36706 address.
   36707 
   36708 @item pc-inside-range
   36709 Two addresses are required as parameters.  Finds next trace
   36710 frame that corresponds to a tracepoint at an address inside the
   36711 specified range.  Both bounds are considered to be inside the range.
   36712 
   36713 @item pc-outside-range
   36714 Two addresses are required as parameters.  Finds
   36715 next trace frame that corresponds to a tracepoint at an address outside
   36716 the specified range.  Both bounds are considered to be inside the range.
   36717 
   36718 @item line
   36719 Location specification is required as parameter.  @xref{Location Specifications}.
   36720 Finds next trace frame that corresponds to a tracepoint at
   36721 the specified location.
   36722 
   36723 @end table
   36724 
   36725 If @samp{none} was passed as @var{mode}, the response does not
   36726 have fields.  Otherwise, the response may have the following fields:
   36727 
   36728 @table @samp
   36729 @item found
   36730 This field has either @samp{0} or @samp{1} as the value, depending
   36731 on whether a matching tracepoint was found.
   36732 
   36733 @item traceframe
   36734 The index of the found traceframe.  This field is present iff
   36735 the @samp{found} field has value of @samp{1}.
   36736 
   36737 @item tracepoint
   36738 The index of the found tracepoint.  This field is present iff
   36739 the @samp{found} field has value of @samp{1}.
   36740 
   36741 @item frame
   36742 The information about the frame corresponding to the found trace
   36743 frame.  This field is present only if a trace frame was found.
   36744 @xref{GDB/MI Frame Information}, for description of this field.
   36745 
   36746 @end table
   36747 
   36748 @subsubheading @value{GDBN} Command
   36749 
   36750 The corresponding @value{GDBN} command is @samp{tfind}.
   36751 
   36752 @findex -trace-define-variable
   36753 @subheading The @code{-trace-define-variable} Command
   36754 
   36755 @subsubheading Synopsis
   36756 
   36757 @smallexample
   36758  -trace-define-variable @var{name} [ @var{value} ]
   36759 @end smallexample
   36760 
   36761 Create trace variable @var{name} if it does not exist.  If
   36762 @var{value} is specified, sets the initial value of the specified
   36763 trace variable to that value.  Note that the @var{name} should start
   36764 with the @samp{$} character.
   36765 
   36766 @subsubheading @value{GDBN} Command
   36767 
   36768 The corresponding @value{GDBN} command is @samp{tvariable}.
   36769 
   36770 @findex -trace-frame-collected
   36771 @subheading The @code{-trace-frame-collected} Command
   36772 
   36773 @subsubheading Synopsis
   36774 
   36775 @smallexample
   36776  -trace-frame-collected
   36777     [--var-print-values @var{var_pval}]
   36778     [--comp-print-values @var{comp_pval}]
   36779     [--registers-format @var{regformat}]
   36780     [--memory-contents]
   36781 @end smallexample
   36782 
   36783 This command returns the set of collected objects, register names,
   36784 trace state variable names, memory ranges and computed expressions
   36785 that have been collected at a particular trace frame.  The optional
   36786 parameters to the command affect the output format in different ways.
   36787 See the output description table below for more details.
   36788 
   36789 The reported names can be used in the normal manner to create
   36790 varobjs and inspect the objects themselves.  The items returned by
   36791 this command are categorized so that it is clear which is a variable,
   36792 which is a register, which is a trace state variable, which is a
   36793 memory range and which is a computed expression.
   36794 
   36795 For instance, if the actions were
   36796 @smallexample
   36797 collect myVar, myArray[myIndex], myObj.field, myPtr->field, myCount + 2
   36798 collect *(int*)0xaf02bef0@@40
   36799 @end smallexample
   36800 
   36801 @noindent
   36802 the object collected in its entirety would be @code{myVar}.  The
   36803 object @code{myArray} would be partially collected, because only the
   36804 element at index @code{myIndex} would be collected.  The remaining
   36805 objects would be computed expressions.
   36806 
   36807 An example output would be:
   36808 
   36809 @smallexample
   36810 (gdb)
   36811 -trace-frame-collected
   36812 ^done,
   36813   explicit-variables=[@{name="myVar",value="1"@}],
   36814   computed-expressions=[@{name="myArray[myIndex]",value="0"@},
   36815                         @{name="myObj.field",value="0"@},
   36816                         @{name="myPtr->field",value="1"@},
   36817                         @{name="myCount + 2",value="3"@},
   36818                         @{name="$tvar1 + 1",value="43970027"@}],
   36819   registers=[@{number="0",value="0x7fe2c6e79ec8"@},
   36820              @{number="1",value="0x0"@},
   36821              @{number="2",value="0x4"@},
   36822              ...
   36823              @{number="125",value="0x0"@}],
   36824   tvars=[@{name="$tvar1",current="43970026"@}],
   36825   memory=[@{address="0x0000000000602264",length="4"@},
   36826           @{address="0x0000000000615bc0",length="4"@}]
   36827 (gdb)
   36828 @end smallexample
   36829 
   36830 Where:
   36831 
   36832 @table @code
   36833 @item explicit-variables
   36834 The set of objects that have been collected in their entirety (as
   36835 opposed to collecting just a few elements of an array or a few struct
   36836 members).  For each object, its name and value are printed.
   36837 The @code{--var-print-values} option affects how or whether the value
   36838 field is output.  If @var{var_pval} is 0, then print only the names;
   36839 if it is 1, print also their values; and if it is 2, print the name,
   36840 type and value for simple data types, and the name and type for
   36841 arrays, structures and unions.
   36842 
   36843 @item computed-expressions
   36844 The set of computed expressions that have been collected at the
   36845 current trace frame.  The @code{--comp-print-values} option affects
   36846 this set like the @code{--var-print-values} option affects the
   36847 @code{explicit-variables} set.  See above.
   36848 
   36849 @item registers
   36850 The registers that have been collected at the current trace frame.
   36851 For each register collected, the name and current value are returned.
   36852 The value is formatted according to the @code{--registers-format}
   36853 option.  See the @command{-data-list-register-values} command for a
   36854 list of the allowed formats.  The default is @samp{x}.
   36855 
   36856 @item tvars
   36857 The trace state variables that have been collected at the current
   36858 trace frame.  For each trace state variable collected, the name and
   36859 current value are returned.
   36860 
   36861 @item memory
   36862 The set of memory ranges that have been collected at the current trace
   36863 frame.  Its content is a list of tuples.  Each tuple represents a
   36864 collected memory range and has the following fields:
   36865 
   36866 @table @code
   36867 @item address
   36868 The start address of the memory range, as hexadecimal literal.
   36869 
   36870 @item length
   36871 The length of the memory range, as decimal literal.
   36872 
   36873 @item contents
   36874 The contents of the memory block, in hex.  This field is only present
   36875 if the @code{--memory-contents} option is specified.
   36876 
   36877 @end table
   36878 
   36879 @end table
   36880 
   36881 @subsubheading @value{GDBN} Command
   36882 
   36883 There is no corresponding @value{GDBN} command.
   36884 
   36885 @subsubheading Example
   36886 
   36887 @findex -trace-list-variables
   36888 @subheading The @code{-trace-list-variables} Command
   36889 
   36890 @subsubheading Synopsis
   36891 
   36892 @smallexample
   36893  -trace-list-variables
   36894 @end smallexample
   36895 
   36896 Return a table of all defined trace variables.  Each element of the
   36897 table has the following fields:
   36898 
   36899 @table @samp
   36900 @item name
   36901 The name of the trace variable.  This field is always present.
   36902 
   36903 @item initial
   36904 The initial value.  This is a 64-bit signed integer.  This
   36905 field is always present.
   36906 
   36907 @item current
   36908 The value the trace variable has at the moment.  This is a 64-bit
   36909 signed integer.  This field is absent iff current value is
   36910 not defined, for example if the trace was never run, or is
   36911 presently running.
   36912 
   36913 @end table
   36914 
   36915 @subsubheading @value{GDBN} Command
   36916 
   36917 The corresponding @value{GDBN} command is @samp{tvariables}.
   36918 
   36919 @subsubheading Example
   36920 
   36921 @smallexample
   36922 (gdb)
   36923 -trace-list-variables
   36924 ^done,trace-variables=@{nr_rows="1",nr_cols="3",
   36925 hdr=[@{width="15",alignment="-1",col_name="name",colhdr="Name"@},
   36926      @{width="11",alignment="-1",col_name="initial",colhdr="Initial"@},
   36927      @{width="11",alignment="-1",col_name="current",colhdr="Current"@}],
   36928 body=[variable=@{name="$trace_timestamp",initial="0"@}
   36929       variable=@{name="$foo",initial="10",current="15"@}]@}
   36930 (gdb)
   36931 @end smallexample
   36932 
   36933 @findex -trace-save
   36934 @subheading The @code{-trace-save} Command
   36935 
   36936 @subsubheading Synopsis
   36937 
   36938 @smallexample
   36939  -trace-save [ -r ] [ -ctf ] @var{filename}
   36940 @end smallexample
   36941 
   36942 Saves the collected trace data to @var{filename}.  Without the
   36943 @samp{-r} option, the data is downloaded from the target and saved
   36944 in a local file.  With the @samp{-r} option the target is asked
   36945 to perform the save.
   36946 
   36947 By default, this command will save the trace in the tfile format.  You can
   36948 supply the optional @samp{-ctf} argument to save it the CTF format. See
   36949 @ref{Trace Files} for more information about CTF.
   36950 
   36951 @subsubheading @value{GDBN} Command
   36952 
   36953 The corresponding @value{GDBN} command is @samp{tsave}.
   36954 
   36955 
   36956 @findex -trace-start
   36957 @subheading The @code{-trace-start} Command
   36958 
   36959 @subsubheading Synopsis
   36960 
   36961 @smallexample
   36962  -trace-start
   36963 @end smallexample
   36964 
   36965 Starts a tracing experiment.  The result of this command does not
   36966 have any fields.
   36967 
   36968 @subsubheading @value{GDBN} Command
   36969 
   36970 The corresponding @value{GDBN} command is @samp{tstart}.
   36971 
   36972 @findex -trace-status
   36973 @subheading The @code{-trace-status} Command
   36974 
   36975 @subsubheading Synopsis
   36976 
   36977 @smallexample
   36978  -trace-status
   36979 @end smallexample
   36980 
   36981 Obtains the status of a tracing experiment.  The result may include
   36982 the following fields:
   36983 
   36984 @table @samp
   36985 
   36986 @item supported
   36987 May have a value of either @samp{0}, when no tracing operations are
   36988 supported, @samp{1}, when all tracing operations are supported, or
   36989 @samp{file} when examining trace file.  In the latter case, examining
   36990 of trace frame is possible but new tracing experiment cannot be
   36991 started.  This field is always present.
   36992 
   36993 @item running
   36994 May have a value of either @samp{0} or @samp{1} depending on whether
   36995 tracing experiment is in progress on target.  This field is present
   36996 if @samp{supported} field is not @samp{0}.
   36997 
   36998 @item stop-reason
   36999 Report the reason why the tracing was stopped last time.  This field
   37000 may be absent iff tracing was never stopped on target yet.  The
   37001 value of @samp{request} means the tracing was stopped as result of
   37002 the @code{-trace-stop} command.  The value of @samp{overflow} means
   37003 the tracing buffer is full.  The value of @samp{disconnection} means
   37004 tracing was automatically stopped when @value{GDBN} has disconnected.
   37005 The value of @samp{passcount} means tracing was stopped when a
   37006 tracepoint was passed a maximal number of times for that tracepoint.
   37007 This field is present if @samp{supported} field is not @samp{0}.
   37008 
   37009 @item stopping-tracepoint
   37010 The number of tracepoint whose passcount as exceeded.  This field is
   37011 present iff the @samp{stop-reason} field has the value of
   37012 @samp{passcount}.
   37013 
   37014 @item frames
   37015 @itemx frames-created
   37016 The @samp{frames} field is a count of the total number of trace frames
   37017 in the trace buffer, while @samp{frames-created} is the total created
   37018 during the run, including ones that were discarded, such as when a
   37019 circular trace buffer filled up.  Both fields are optional.
   37020 
   37021 @item buffer-size
   37022 @itemx buffer-free
   37023 These fields tell the current size of the tracing buffer and the
   37024 remaining space.  These fields are optional.
   37025 
   37026 @item circular
   37027 The value of the circular trace buffer flag.  @code{1} means that the
   37028 trace buffer is circular and old trace frames will be discarded if
   37029 necessary to make room, @code{0} means that the trace buffer is linear
   37030 and may fill up.
   37031 
   37032 @item disconnected
   37033 The value of the disconnected tracing flag.  @code{1} means that
   37034 tracing will continue after @value{GDBN} disconnects, @code{0} means
   37035 that the trace run will stop.
   37036 
   37037 @item trace-file
   37038 The filename of the trace file being examined.  This field is
   37039 optional, and only present when examining a trace file.
   37040 
   37041 @end table
   37042 
   37043 @subsubheading @value{GDBN} Command
   37044 
   37045 The corresponding @value{GDBN} command is @samp{tstatus}.
   37046 
   37047 @findex -trace-stop
   37048 @subheading The @code{-trace-stop} Command
   37049 
   37050 @subsubheading Synopsis
   37051 
   37052 @smallexample
   37053  -trace-stop
   37054 @end smallexample
   37055 
   37056 Stops a tracing experiment.  The result of this command has the same
   37057 fields as @code{-trace-status}, except that the @samp{supported} and
   37058 @samp{running} fields are not output.
   37059 
   37060 @subsubheading @value{GDBN} Command
   37061 
   37062 The corresponding @value{GDBN} command is @samp{tstop}.
   37063 
   37064 
   37065 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   37066 @node GDB/MI Symbol Query
   37067 @section @sc{gdb/mi} Symbol Query Commands
   37068 
   37069 
   37070 @ignore
   37071 @findex -symbol-info-address
   37072 @subheading The @code{-symbol-info-address} Command
   37073 
   37074 @subsubheading Synopsis
   37075 
   37076 @smallexample
   37077  -symbol-info-address @var{symbol}
   37078 @end smallexample
   37079 
   37080 Describe where @var{symbol} is stored.
   37081 
   37082 @subsubheading @value{GDBN} Command
   37083 
   37084 The corresponding @value{GDBN} command is @samp{info address}.
   37085 
   37086 @subsubheading Example
   37087 N.A.
   37088 
   37089 
   37090 @findex -symbol-info-file
   37091 @subheading The @code{-symbol-info-file} Command
   37092 
   37093 @subsubheading Synopsis
   37094 
   37095 @smallexample
   37096  -symbol-info-file
   37097 @end smallexample
   37098 
   37099 Show the file for the symbol.
   37100 
   37101 @subsubheading @value{GDBN} Command
   37102 
   37103 There's no equivalent @value{GDBN} command.  @code{gdbtk} has
   37104 @samp{gdb_find_file}.
   37105 
   37106 @subsubheading Example
   37107 N.A.
   37108 @end ignore
   37109 
   37110 @findex -symbol-info-functions
   37111 @anchor{-symbol-info-functions}
   37112 @subheading The @code{-symbol-info-functions} Command
   37113 
   37114 @subsubheading Synopsis
   37115 
   37116 @smallexample
   37117  -symbol-info-functions [--include-nondebug]
   37118                         [--type @var{type_regexp}]
   37119                         [--name @var{name_regexp}]
   37120                         [--max-results @var{limit}]
   37121 @end smallexample
   37122 
   37123 @noindent
   37124 Return a list containing the names and types for all global functions
   37125 taken from the debug information.  The functions are grouped by source
   37126 file, and shown with the line number on which each function is
   37127 defined.
   37128 
   37129 The @code{--include-nondebug} option causes the output to include
   37130 code symbols from the symbol table.
   37131 
   37132 The options @code{--type} and @code{--name} allow the symbols returned
   37133 to be filtered based on either the name of the function, or the type
   37134 signature of the function.
   37135 
   37136 The option @code{--max-results} restricts the command to return no
   37137 more than @var{limit} results.  If exactly @var{limit} results are
   37138 returned then there might be additional results available if a higher
   37139 limit is used.
   37140 
   37141 @subsubheading @value{GDBN} Command
   37142 
   37143 The corresponding @value{GDBN} command is @samp{info functions}.
   37144 
   37145 @subsubheading Example
   37146 @smallexample
   37147 @group
   37148 (gdb)
   37149 -symbol-info-functions
   37150 ^done,symbols=
   37151   @{debug=
   37152     [@{filename="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
   37153       fullname="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
   37154       symbols=[@{line="36", name="f4", type="void (int *)",
   37155                 description="void f4(int *);"@},
   37156                @{line="42", name="main", type="int ()",
   37157                 description="int main();"@},
   37158                @{line="30", name="f1", type="my_int_t (int, int)",
   37159                 description="static my_int_t f1(int, int);"@}]@},
   37160      @{filename="/project/gdb/testsuite/gdb.mi/mi-sym-info-2.c",
   37161       fullname="/project/gdb/testsuite/gdb.mi/mi-sym-info-2.c",
   37162       symbols=[@{line="33", name="f2", type="float (another_float_t)",
   37163                 description="float f2(another_float_t);"@},
   37164                @{line="39", name="f3", type="int (another_int_t)",
   37165                 description="int f3(another_int_t);"@},
   37166                @{line="27", name="f1", type="another_float_t (int)",
   37167                 description="static another_float_t f1(int);"@}]@}]@}
   37168 @end group
   37169 @group
   37170 (gdb)
   37171 -symbol-info-functions --name f1
   37172 ^done,symbols=
   37173   @{debug=
   37174     [@{filename="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
   37175       fullname="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
   37176       symbols=[@{line="30", name="f1", type="my_int_t (int, int)",
   37177                 description="static my_int_t f1(int, int);"@}]@},
   37178      @{filename="/project/gdb/testsuite/gdb.mi/mi-sym-info-2.c",
   37179       fullname="/project/gdb/testsuite/gdb.mi/mi-sym-info-2.c",
   37180       symbols=[@{line="27", name="f1", type="another_float_t (int)",
   37181                 description="static another_float_t f1(int);"@}]@}]@}
   37182 @end group
   37183 @group
   37184 (gdb)
   37185 -symbol-info-functions --type void
   37186 ^done,symbols=
   37187   @{debug=
   37188     [@{filename="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
   37189       fullname="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
   37190       symbols=[@{line="36", name="f4", type="void (int *)",
   37191                 description="void f4(int *);"@}]@}]@}
   37192 @end group
   37193 @group
   37194 (gdb)
   37195 -symbol-info-functions --include-nondebug
   37196 ^done,symbols=
   37197   @{debug=
   37198     [@{filename="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
   37199       fullname="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
   37200       symbols=[@{line="36", name="f4", type="void (int *)",
   37201                 description="void f4(int *);"@},
   37202                @{line="42", name="main", type="int ()",
   37203                 description="int main();"@},
   37204                @{line="30", name="f1", type="my_int_t (int, int)",
   37205                 description="static my_int_t f1(int, int);"@}]@},
   37206      @{filename="/project/gdb/testsuite/gdb.mi/mi-sym-info-2.c",
   37207       fullname="/project/gdb/testsuite/gdb.mi/mi-sym-info-2.c",
   37208       symbols=[@{line="33", name="f2", type="float (another_float_t)",
   37209                 description="float f2(another_float_t);"@},
   37210                @{line="39", name="f3", type="int (another_int_t)",
   37211                 description="int f3(another_int_t);"@},
   37212                @{line="27", name="f1", type="another_float_t (int)",
   37213                 description="static another_float_t f1(int);"@}]@}],
   37214    nondebug=
   37215     [@{address="0x0000000000400398",name="_init"@},
   37216      @{address="0x00000000004003b0",name="_start"@},
   37217       ...
   37218     ]@}
   37219 @end group
   37220 @end smallexample
   37221 
   37222 @findex -symbol-info-module-functions
   37223 @anchor{-symbol-info-module-functions}
   37224 @subheading The @code{-symbol-info-module-functions} Command
   37225 
   37226 @subsubheading Synopsis
   37227 
   37228 @smallexample
   37229  -symbol-info-module-functions [--module @var{module_regexp}]
   37230                                [--name @var{name_regexp}]
   37231                                [--type @var{type_regexp}]
   37232 @end smallexample
   37233 
   37234 @noindent
   37235 Return a list containing the names of all known functions within all
   37236 know Fortran modules.  The functions are grouped by source file and
   37237 containing module, and shown with the line number on which each
   37238 function is defined.
   37239 
   37240 The option @code{--module} only returns results for modules matching
   37241 @var{module_regexp}.  The option @code{--name} only returns functions
   37242 whose name matches @var{name_regexp}, and @code{--type} only returns
   37243 functions whose type matches @var{type_regexp}.
   37244 
   37245 @subsubheading @value{GDBN} Command
   37246 
   37247 The corresponding @value{GDBN} command is @samp{info module functions}.
   37248 
   37249 @subsubheading Example
   37250 
   37251 @smallexample
   37252 @group
   37253 (gdb)
   37254 -symbol-info-module-functions
   37255 ^done,symbols=
   37256   [@{module="mod1",
   37257     files=[@{filename="/project/gdb/testsuite/gdb.mi/mi-fortran-modules-2.f90",
   37258             fullname="/project/gdb/testsuite/gdb.mi/mi-fortran-modules-2.f90",
   37259             symbols=[@{line="21",name="mod1::check_all",type="void (void)",
   37260                       description="void mod1::check_all(void);"@}]@}]@},
   37261     @{module="mod2",
   37262      files=[@{filename="/project/gdb/testsuite/gdb.mi/mi-fortran-modules-2.f90",
   37263              fullname="/project/gdb/testsuite/gdb.mi/mi-fortran-modules-2.f90",
   37264              symbols=[@{line="30",name="mod2::check_var_i",type="void (void)",
   37265                        description="void mod2::check_var_i(void);"@}]@}]@},
   37266     @{module="mod3",
   37267      files=[@{filename="/project/gdb/testsuite/gdb.mi/mi-fortran-modules.f90",
   37268              fullname="/project/gdb/testsuite/gdb.mi/mi-fortran-modules.f90",
   37269              symbols=[@{line="21",name="mod3::check_all",type="void (void)",
   37270                        description="void mod3::check_all(void);"@},
   37271                       @{line="27",name="mod3::check_mod2",type="void (void)",
   37272                        description="void mod3::check_mod2(void);"@}]@}]@},
   37273     @{module="modmany",
   37274      files=[@{filename="/project/gdb/testsuite/gdb.mi/mi-fortran-modules.f90",
   37275              fullname="/project/gdb/testsuite/gdb.mi/mi-fortran-modules.f90",
   37276              symbols=[@{line="35",name="modmany::check_some",type="void (void)",
   37277                        description="void modmany::check_some(void);"@}]@}]@},
   37278     @{module="moduse",
   37279      files=[@{filename="/project/gdb/testsuite/gdb.mi/mi-fortran-modules.f90",
   37280              fullname="/project/gdb/testsuite/gdb.mi/mi-fortran-modules.f90",
   37281              symbols=[@{line="44",name="moduse::check_all",type="void (void)",
   37282                        description="void moduse::check_all(void);"@},
   37283                       @{line="49",name="moduse::check_var_x",type="void (void)",
   37284                        description="void moduse::check_var_x(void);"@}]@}]@}]
   37285 @end group
   37286 @end smallexample
   37287 
   37288 @findex -symbol-info-module-variables
   37289 @anchor{-symbol-info-module-variables}
   37290 @subheading The @code{-symbol-info-module-variables} Command
   37291 
   37292 @subsubheading Synopsis
   37293 
   37294 @smallexample
   37295  -symbol-info-module-variables [--module @var{module_regexp}]
   37296                                [--name @var{name_regexp}]
   37297                                [--type @var{type_regexp}]
   37298 @end smallexample
   37299 
   37300 @noindent
   37301 Return a list containing the names of all known variables within all
   37302 know Fortran modules.  The variables are grouped by source file and
   37303 containing module, and shown with the line number on which each
   37304 variable is defined.
   37305 
   37306 The option @code{--module} only returns results for modules matching
   37307 @var{module_regexp}.  The option @code{--name} only returns variables
   37308 whose name matches @var{name_regexp}, and @code{--type} only returns
   37309 variables whose type matches @var{type_regexp}.
   37310 
   37311 @subsubheading @value{GDBN} Command
   37312 
   37313 The corresponding @value{GDBN} command is @samp{info module variables}.
   37314 
   37315 @subsubheading Example
   37316 
   37317 @smallexample
   37318 @group
   37319 (gdb)
   37320 -symbol-info-module-variables
   37321 ^done,symbols=
   37322   [@{module="mod1",
   37323     files=[@{filename="/project/gdb/testsuite/gdb.mi/mi-fortran-modules-2.f90",
   37324             fullname="/project/gdb/testsuite/gdb.mi/mi-fortran-modules-2.f90",
   37325             symbols=[@{line="18",name="mod1::var_const",type="integer(kind=4)",
   37326                       description="integer(kind=4) mod1::var_const;"@},
   37327                      @{line="17",name="mod1::var_i",type="integer(kind=4)",
   37328                       description="integer(kind=4) mod1::var_i;"@}]@}]@},
   37329    @{module="mod2",
   37330     files=[@{filename="/project/gdb/testsuite/gdb.mi/mi-fortran-modules-2.f90",
   37331             fullname="/project/gdb/testsuite/gdb.mi/mi-fortran-modules-2.f90",
   37332             symbols=[@{line="28",name="mod2::var_i",type="integer(kind=4)",
   37333                       description="integer(kind=4) mod2::var_i;"@}]@}]@},
   37334    @{module="mod3",
   37335     files=[@{filename="/project/gdb/testsuite/gdb.mi/mi-fortran-modules.f90",
   37336             fullname="/project/gdb/testsuite/gdb.mi/mi-fortran-modules.f90",
   37337             symbols=[@{line="18",name="mod3::mod1",type="integer(kind=4)",
   37338                       description="integer(kind=4) mod3::mod1;"@},
   37339                      @{line="17",name="mod3::mod2",type="integer(kind=4)",
   37340                       description="integer(kind=4) mod3::mod2;"@},
   37341                      @{line="19",name="mod3::var_i",type="integer(kind=4)",
   37342                       description="integer(kind=4) mod3::var_i;"@}]@}]@},
   37343    @{module="modmany",
   37344     files=[@{filename="/project/gdb/testsuite/gdb.mi/mi-fortran-modules.f90",
   37345             fullname="/project/gdb/testsuite/gdb.mi/mi-fortran-modules.f90",
   37346             symbols=[@{line="33",name="modmany::var_a",type="integer(kind=4)",
   37347                       description="integer(kind=4) modmany::var_a;"@},
   37348                      @{line="33",name="modmany::var_b",type="integer(kind=4)",
   37349                       description="integer(kind=4) modmany::var_b;"@},
   37350                      @{line="33",name="modmany::var_c",type="integer(kind=4)",
   37351                       description="integer(kind=4) modmany::var_c;"@},
   37352                      @{line="33",name="modmany::var_i",type="integer(kind=4)",
   37353                       description="integer(kind=4) modmany::var_i;"@}]@}]@},
   37354    @{module="moduse",
   37355     files=[@{filename="/project/gdb/testsuite/gdb.mi/mi-fortran-modules.f90",
   37356             fullname="/project/gdb/testsuite/gdb.mi/mi-fortran-modules.f90",
   37357             symbols=[@{line="42",name="moduse::var_x",type="integer(kind=4)",
   37358                       description="integer(kind=4) moduse::var_x;"@},
   37359                      @{line="42",name="moduse::var_y",type="integer(kind=4)",
   37360                       description="integer(kind=4) moduse::var_y;"@}]@}]@}]
   37361 @end group
   37362 @end smallexample
   37363 
   37364 @findex -symbol-info-modules
   37365 @anchor{-symbol-info-modules}
   37366 @subheading The @code{-symbol-info-modules} Command
   37367 
   37368 @subsubheading Synopsis
   37369 
   37370 @smallexample
   37371  -symbol-info-modules [--name @var{name_regexp}]
   37372                       [--max-results @var{limit}]
   37373 
   37374 @end smallexample
   37375 
   37376 @noindent
   37377 Return a list containing the names of all known Fortran modules.  The
   37378 modules are grouped by source file, and shown with the line number on
   37379 which each modules is defined.
   37380 
   37381 The option @code{--name} allows the modules returned to be filtered
   37382 based the name of the module.
   37383 
   37384 The option @code{--max-results} restricts the command to return no
   37385 more than @var{limit} results.  If exactly @var{limit} results are
   37386 returned then there might be additional results available if a higher
   37387 limit is used.
   37388 
   37389 @subsubheading @value{GDBN} Command
   37390 
   37391 The corresponding @value{GDBN} command is @samp{info modules}.
   37392 
   37393 @subsubheading Example
   37394 @smallexample
   37395 @group
   37396 (gdb)
   37397 -symbol-info-modules
   37398 ^done,symbols=
   37399   @{debug=
   37400     [@{filename="/project/gdb/testsuite/gdb.mi/mi-fortran-modules-2.f90",
   37401       fullname="/project/gdb/testsuite/gdb.mi/mi-fortran-modules-2.f90",
   37402       symbols=[@{line="16",name="mod1"@},
   37403                @{line="22",name="mod2"@}]@},
   37404      @{filename="/project/gdb/testsuite/gdb.mi/mi-fortran-modules.f90",
   37405       fullname="/project/gdb/testsuite/gdb.mi/mi-fortran-modules.f90",
   37406       symbols=[@{line="16",name="mod3"@},
   37407                @{line="22",name="modmany"@},
   37408                @{line="26",name="moduse"@}]@}]@}
   37409 @end group
   37410 @group
   37411 (gdb)
   37412 -symbol-info-modules --name mod[123]
   37413 ^done,symbols=
   37414   @{debug=
   37415     [@{filename="/project/gdb/testsuite/gdb.mi/mi-fortran-modules-2.f90",
   37416       fullname="/project/gdb/testsuite/gdb.mi/mi-fortran-modules-2.f90",
   37417       symbols=[@{line="16",name="mod1"@},
   37418                @{line="22",name="mod2"@}]@},
   37419      @{filename="/project/gdb/testsuite/gdb.mi/mi-fortran-modules.f90",
   37420       fullname="/project/gdb/testsuite/gdb.mi/mi-fortran-modules.f90",
   37421       symbols=[@{line="16",name="mod3"@}]@}]@}
   37422 @end group
   37423 @end smallexample
   37424 
   37425 @findex -symbol-info-types
   37426 @anchor{-symbol-info-types}
   37427 @subheading The @code{-symbol-info-types} Command
   37428 
   37429 @subsubheading Synopsis
   37430 
   37431 @smallexample
   37432  -symbol-info-types [--name @var{name_regexp}]
   37433                     [--max-results @var{limit}]
   37434 
   37435 @end smallexample
   37436 
   37437 @noindent
   37438 Return a list of all defined types.  The types are grouped by source
   37439 file, and shown with the line number on which each user defined type
   37440 is defined.  Some base types are not defined in the source code but
   37441 are added to the debug information by the compiler, for example
   37442 @code{int}, @code{float}, etc.; these types do not have an associated
   37443 line number.
   37444 
   37445 The option @code{--name} allows the list of types returned to be
   37446 filtered by name.
   37447 
   37448 The option @code{--max-results} restricts the command to return no
   37449 more than @var{limit} results.  If exactly @var{limit} results are
   37450 returned then there might be additional results available if a higher
   37451 limit is used.
   37452 
   37453 @subsubheading @value{GDBN} Command
   37454 
   37455 The corresponding @value{GDBN} command is @samp{info types}.
   37456 
   37457 @subsubheading Example
   37458 @smallexample
   37459 @group
   37460 (gdb)
   37461 -symbol-info-types
   37462 ^done,symbols=
   37463   @{debug=
   37464      [@{filename="gdb.mi/mi-sym-info-1.c",
   37465        fullname="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
   37466        symbols=[@{name="float"@},
   37467                 @{name="int"@},
   37468                 @{line="27",name="typedef int my_int_t;"@}]@},
   37469       @{filename="gdb.mi/mi-sym-info-2.c",
   37470        fullname="/project/gdb.mi/mi-sym-info-2.c",
   37471        symbols=[@{line="24",name="typedef float another_float_t;"@},
   37472                 @{line="23",name="typedef int another_int_t;"@},
   37473                 @{name="float"@},
   37474                 @{name="int"@}]@}]@}
   37475 @end group
   37476 @group
   37477 (gdb)
   37478 -symbol-info-types --name _int_
   37479 ^done,symbols=
   37480   @{debug=
   37481      [@{filename="gdb.mi/mi-sym-info-1.c",
   37482        fullname="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
   37483        symbols=[@{line="27",name="typedef int my_int_t;"@}]@},
   37484       @{filename="gdb.mi/mi-sym-info-2.c",
   37485        fullname="/project/gdb.mi/mi-sym-info-2.c",
   37486        symbols=[@{line="23",name="typedef int another_int_t;"@}]@}]@}
   37487 @end group
   37488 @end smallexample
   37489 
   37490 @findex -symbol-info-variables
   37491 @anchor{-symbol-info-variables}
   37492 @subheading The @code{-symbol-info-variables} Command
   37493 
   37494 @subsubheading Synopsis
   37495 
   37496 @smallexample
   37497  -symbol-info-variables [--include-nondebug]
   37498                         [--type @var{type_regexp}]
   37499                         [--name @var{name_regexp}]
   37500                         [--max-results @var{limit}]
   37501 
   37502 @end smallexample
   37503 
   37504 @noindent
   37505 Return a list containing the names and types for all global variables
   37506 taken from the debug information.  The variables are grouped by source
   37507 file, and shown with the line number on which each variable is
   37508 defined.
   37509 
   37510 The @code{--include-nondebug} option causes the output to include
   37511 data symbols from the symbol table.
   37512 
   37513 The options @code{--type} and @code{--name} allow the symbols returned
   37514 to be filtered based on either the name of the variable, or the type
   37515 of the variable.
   37516 
   37517 The option @code{--max-results} restricts the command to return no
   37518 more than @var{limit} results.  If exactly @var{limit} results are
   37519 returned then there might be additional results available if a higher
   37520 limit is used.
   37521 
   37522 @subsubheading @value{GDBN} Command
   37523 
   37524 The corresponding @value{GDBN} command is @samp{info variables}.
   37525 
   37526 @subsubheading Example
   37527 @smallexample
   37528 @group
   37529 (gdb)
   37530 -symbol-info-variables
   37531 ^done,symbols=
   37532   @{debug=
   37533     [@{filename="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
   37534       fullname="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
   37535       symbols=[@{line="25",name="global_f1",type="float",
   37536                 description="static float global_f1;"@},
   37537                @{line="24",name="global_i1",type="int",
   37538                 description="static int global_i1;"@}]@},
   37539      @{filename="/project/gdb/testsuite/gdb.mi/mi-sym-info-2.c",
   37540       fullname="/project/gdb/testsuite/gdb.mi/mi-sym-info-2.c",
   37541       symbols=[@{line="21",name="global_f2",type="int",
   37542                 description="int global_f2;"@},
   37543                @{line="20",name="global_i2",type="int",
   37544                 description="int global_i2;"@},
   37545                @{line="19",name="global_f1",type="float",
   37546                 description="static float global_f1;"@},
   37547                @{line="18",name="global_i1",type="int",
   37548                 description="static int global_i1;"@}]@}]@}
   37549 @end group
   37550 @group
   37551 (gdb)
   37552 -symbol-info-variables --name f1
   37553 ^done,symbols=
   37554   @{debug=
   37555     [@{filename="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
   37556       fullname="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
   37557       symbols=[@{line="25",name="global_f1",type="float",
   37558                 description="static float global_f1;"@}]@},
   37559      @{filename="/project/gdb/testsuite/gdb.mi/mi-sym-info-2.c",
   37560       fullname="/project/gdb/testsuite/gdb.mi/mi-sym-info-2.c",
   37561       symbols=[@{line="19",name="global_f1",type="float",
   37562                 description="static float global_f1;"@}]@}]@}
   37563 @end group
   37564 @group
   37565 (gdb)
   37566 -symbol-info-variables --type float
   37567 ^done,symbols=
   37568   @{debug=
   37569     [@{filename="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
   37570       fullname="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
   37571       symbols=[@{line="25",name="global_f1",type="float",
   37572                 description="static float global_f1;"@}]@},
   37573      @{filename="/project/gdb/testsuite/gdb.mi/mi-sym-info-2.c",
   37574       fullname="/project/gdb/testsuite/gdb.mi/mi-sym-info-2.c",
   37575       symbols=[@{line="19",name="global_f1",type="float",
   37576                 description="static float global_f1;"@}]@}]@}
   37577 @end group
   37578 @group
   37579 (gdb)
   37580 -symbol-info-variables --include-nondebug
   37581 ^done,symbols=
   37582   @{debug=
   37583     [@{filename="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
   37584       fullname="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
   37585       symbols=[@{line="25",name="global_f1",type="float",
   37586                 description="static float global_f1;"@},
   37587                @{line="24",name="global_i1",type="int",
   37588                 description="static int global_i1;"@}]@},
   37589      @{filename="/project/gdb/testsuite/gdb.mi/mi-sym-info-2.c",
   37590       fullname="/project/gdb/testsuite/gdb.mi/mi-sym-info-2.c",
   37591       symbols=[@{line="21",name="global_f2",type="int",
   37592                 description="int global_f2;"@},
   37593                @{line="20",name="global_i2",type="int",
   37594                 description="int global_i2;"@},
   37595                @{line="19",name="global_f1",type="float",
   37596                 description="static float global_f1;"@},
   37597                @{line="18",name="global_i1",type="int",
   37598                 description="static int global_i1;"@}]@}],
   37599    nondebug=
   37600     [@{address="0x00000000004005d0",name="_IO_stdin_used"@},
   37601      @{address="0x00000000004005d8",name="__dso_handle"@}
   37602       ...
   37603     ]@}
   37604 @end group
   37605 @end smallexample
   37606 
   37607 @ignore
   37608 @findex -symbol-info-line
   37609 @subheading The @code{-symbol-info-line} Command
   37610 
   37611 @subsubheading Synopsis
   37612 
   37613 @smallexample
   37614  -symbol-info-line
   37615 @end smallexample
   37616 
   37617 Show the core addresses of the code for a source line.
   37618 
   37619 @subsubheading @value{GDBN} Command
   37620 
   37621 The corresponding @value{GDBN} command is @samp{info line}.
   37622 @code{gdbtk} has the @samp{gdb_get_line} and @samp{gdb_get_file} commands.
   37623 
   37624 @subsubheading Example
   37625 N.A.
   37626 
   37627 
   37628 @findex -symbol-info-symbol
   37629 @subheading The @code{-symbol-info-symbol} Command
   37630 
   37631 @subsubheading Synopsis
   37632 
   37633 @smallexample
   37634  -symbol-info-symbol @var{addr}
   37635 @end smallexample
   37636 
   37637 Describe what symbol is at location @var{addr}.
   37638 
   37639 @subsubheading @value{GDBN} Command
   37640 
   37641 The corresponding @value{GDBN} command is @samp{info symbol}.
   37642 
   37643 @subsubheading Example
   37644 N.A.
   37645 
   37646 
   37647 @findex -symbol-list-functions
   37648 @subheading The @code{-symbol-list-functions} Command
   37649 
   37650 @subsubheading Synopsis
   37651 
   37652 @smallexample
   37653  -symbol-list-functions
   37654 @end smallexample
   37655 
   37656 List the functions in the executable.
   37657 
   37658 @subsubheading @value{GDBN} Command
   37659 
   37660 @samp{info functions} in @value{GDBN}, @samp{gdb_listfunc} and
   37661 @samp{gdb_search} in @code{gdbtk}.
   37662 
   37663 @subsubheading Example
   37664 N.A.
   37665 @end ignore
   37666 
   37667 
   37668 @findex -symbol-list-lines
   37669 @subheading The @code{-symbol-list-lines} Command
   37670 
   37671 @subsubheading Synopsis
   37672 
   37673 @smallexample
   37674  -symbol-list-lines @var{filename}
   37675 @end smallexample
   37676 
   37677 Print the list of lines that contain code and their associated program
   37678 addresses for the given source filename.  The entries are sorted in
   37679 ascending PC order.
   37680 
   37681 @subsubheading @value{GDBN} Command
   37682 
   37683 There is no corresponding @value{GDBN} command.
   37684 
   37685 @subsubheading Example
   37686 @smallexample
   37687 (gdb)
   37688 -symbol-list-lines basics.c
   37689 ^done,lines=[@{pc="0x08048554",line="7"@},@{pc="0x0804855a",line="8"@}]
   37690 (gdb)
   37691 @end smallexample
   37692 
   37693 
   37694 @ignore
   37695 @findex -symbol-list-types
   37696 @subheading The @code{-symbol-list-types} Command
   37697 
   37698 @subsubheading Synopsis
   37699 
   37700 @smallexample
   37701  -symbol-list-types
   37702 @end smallexample
   37703 
   37704 List all the type names.
   37705 
   37706 @subsubheading @value{GDBN} Command
   37707 
   37708 The corresponding commands are @samp{info types} in @value{GDBN},
   37709 @samp{gdb_search} in @code{gdbtk}.
   37710 
   37711 @subsubheading Example
   37712 N.A.
   37713 
   37714 
   37715 @findex -symbol-list-variables
   37716 @subheading The @code{-symbol-list-variables} Command
   37717 
   37718 @subsubheading Synopsis
   37719 
   37720 @smallexample
   37721  -symbol-list-variables
   37722 @end smallexample
   37723 
   37724 List all the global and static variable names.
   37725 
   37726 @subsubheading @value{GDBN} Command
   37727 
   37728 @samp{info variables} in @value{GDBN}, @samp{gdb_search} in @code{gdbtk}.
   37729 
   37730 @subsubheading Example
   37731 N.A.
   37732 
   37733 
   37734 @findex -symbol-locate
   37735 @subheading The @code{-symbol-locate} Command
   37736 
   37737 @subsubheading Synopsis
   37738 
   37739 @smallexample
   37740  -symbol-locate
   37741 @end smallexample
   37742 
   37743 @subsubheading @value{GDBN} Command
   37744 
   37745 @samp{gdb_loc} in @code{gdbtk}.
   37746 
   37747 @subsubheading Example
   37748 N.A.
   37749 
   37750 
   37751 @findex -symbol-type
   37752 @subheading The @code{-symbol-type} Command
   37753 
   37754 @subsubheading Synopsis
   37755 
   37756 @smallexample
   37757  -symbol-type @var{variable}
   37758 @end smallexample
   37759 
   37760 Show type of @var{variable}.
   37761 
   37762 @subsubheading @value{GDBN} Command
   37763 
   37764 The corresponding @value{GDBN} command is @samp{ptype}, @code{gdbtk} has
   37765 @samp{gdb_obj_variable}.
   37766 
   37767 @subsubheading Example
   37768 N.A.
   37769 @end ignore
   37770 
   37771 
   37772 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   37773 @node GDB/MI File Commands
   37774 @section @sc{gdb/mi} File Commands
   37775 
   37776 This section describes the GDB/MI commands to specify executable file names
   37777 and to read in and obtain symbol table information.
   37778 
   37779 @findex -file-exec-and-symbols
   37780 @subheading The @code{-file-exec-and-symbols} Command
   37781 
   37782 @subsubheading Synopsis
   37783 
   37784 @smallexample
   37785  -file-exec-and-symbols @var{file}
   37786 @end smallexample
   37787 
   37788 Specify the executable file to be debugged.  This file is the one from
   37789 which the symbol table is also read.  If no file is specified, the
   37790 command clears the executable and symbol information.  If breakpoints
   37791 are set when using this command with no arguments, @value{GDBN} will produce
   37792 error messages.  Otherwise, no output is produced, except a completion
   37793 notification.
   37794 
   37795 @subsubheading @value{GDBN} Command
   37796 
   37797 The corresponding @value{GDBN} command is @samp{file}.
   37798 
   37799 @subsubheading Example
   37800 
   37801 @smallexample
   37802 (gdb)
   37803 -file-exec-and-symbols /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx
   37804 ^done
   37805 (gdb)
   37806 @end smallexample
   37807 
   37808 
   37809 @findex -file-exec-file
   37810 @subheading The @code{-file-exec-file} Command
   37811 
   37812 @subsubheading Synopsis
   37813 
   37814 @smallexample
   37815  -file-exec-file @var{file}
   37816 @end smallexample
   37817 
   37818 Specify the executable file to be debugged.  Unlike
   37819 @samp{-file-exec-and-symbols}, the symbol table is @emph{not} read
   37820 from this file.  If used without argument, @value{GDBN} clears the information
   37821 about the executable file.  No output is produced, except a completion
   37822 notification.
   37823 
   37824 @subsubheading @value{GDBN} Command
   37825 
   37826 The corresponding @value{GDBN} command is @samp{exec-file}.
   37827 
   37828 @subsubheading Example
   37829 
   37830 @smallexample
   37831 (gdb)
   37832 -file-exec-file /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx
   37833 ^done
   37834 (gdb)
   37835 @end smallexample
   37836 
   37837 
   37838 @ignore
   37839 @findex -file-list-exec-sections
   37840 @subheading The @code{-file-list-exec-sections} Command
   37841 
   37842 @subsubheading Synopsis
   37843 
   37844 @smallexample
   37845  -file-list-exec-sections
   37846 @end smallexample
   37847 
   37848 List the sections of the current executable file.
   37849 
   37850 @subsubheading @value{GDBN} Command
   37851 
   37852 The @value{GDBN} command @samp{info file} shows, among the rest, the same
   37853 information as this command.  @code{gdbtk} has a corresponding command
   37854 @samp{gdb_load_info}.
   37855 
   37856 @subsubheading Example
   37857 N.A.
   37858 @end ignore
   37859 
   37860 
   37861 @findex -file-list-exec-source-file
   37862 @subheading The @code{-file-list-exec-source-file} Command
   37863 
   37864 @subsubheading Synopsis
   37865 
   37866 @smallexample
   37867  -file-list-exec-source-file
   37868 @end smallexample
   37869 
   37870 List the line number, the current source file, and the absolute path
   37871 to the current source file for the current executable.  The macro
   37872 information field has a value of @samp{1} or @samp{0} depending on
   37873 whether or not the file includes preprocessor macro information.
   37874 
   37875 @subsubheading @value{GDBN} Command
   37876 
   37877 The @value{GDBN} equivalent is @samp{info source}
   37878 
   37879 @subsubheading Example
   37880 
   37881 @smallexample
   37882 (gdb)
   37883 123-file-list-exec-source-file
   37884 123^done,line="1",file="foo.c",fullname="/home/bar/foo.c,macro-info="1"
   37885 (gdb)
   37886 @end smallexample
   37887 
   37888 
   37889 @findex -file-list-exec-source-files
   37890 @subheading The @code{-file-list-exec-source-files} Command
   37891 @kindex info sources
   37892 
   37893 @subsubheading Synopsis
   37894 
   37895 @smallexample
   37896  -file-list-exec-source-files @r{[} @var{--group-by-objfile} @r{]}
   37897                               @r{[} @var{--dirname} @r{|} @var{--basename} @r{]}
   37898                               @r{[} -- @r{]}
   37899                               @r{[} @var{regexp} @r{]}
   37900 @end smallexample
   37901 
   37902 This command returns information about the source files @value{GDBN}
   37903 knows about, it will output both the filename and fullname (absolute
   37904 file name) of a source file, though the fullname can be elided if this
   37905 information is not known to @value{GDBN}.
   37906 
   37907 With no arguments this command returns a list of source files.  Each
   37908 source file is represented by a tuple with the fields; @var{file},
   37909 @var{fullname}, and @var{debug-fully-read}.  The @var{file} is the
   37910 display name for the file, while @var{fullname} is the absolute name
   37911 of the file.  The @var{fullname} field can be elided if the absolute
   37912 name of the source file can't be computed.  The field
   37913 @var{debug-fully-read} will be a string, either @code{true} or
   37914 @code{false}.  When @code{true}, this indicates the full debug
   37915 information for the compilation unit describing this file has been
   37916 read in.  When @code{false}, the full debug information has not yet
   37917 been read in.  While reading in the full debug information it is
   37918 possible that @value{GDBN} could become aware of additional source
   37919 files.
   37920 
   37921 The optional @var{regexp} can be used to filter the list of source
   37922 files returned.  The @var{regexp} will be matched against the full
   37923 source file name.  The matching is case-sensitive, except on operating
   37924 systems that have case-insensitive filesystem (e.g.,
   37925 MS-Windows).  @samp{--} can be used before @var{regexp} to prevent
   37926 @value{GDBN} interpreting @var{regexp} as a command option (e.g.@: if
   37927 @var{regexp} starts with @samp{-}).
   37928 
   37929 If @code{--dirname} is provided, then @var{regexp} is matched only
   37930 against the directory name of each source file.  If @code{--basename}
   37931 is provided, then @var{regexp} is matched against the basename of each
   37932 source file.  Only one of @code{--dirname} or @code{--basename} may be
   37933 given, and if either is given then @var{regexp} is required.
   37934 
   37935 If @code{--group-by-objfile} is used then the format of the results is
   37936 changed.  The results will now be a list of tuples, with each tuple
   37937 representing an object file (executable or shared library) loaded into
   37938 @value{GDBN}.  The fields of these tuples are; @var{filename},
   37939 @var{debug-info}, and @var{sources}.  The @var{filename} is the
   37940 absolute name of the object file, @var{debug-info} is a string with
   37941 one of the following values:
   37942 
   37943 @table @code
   37944 @item none
   37945 This object file has no debug information.
   37946 @item partially-read
   37947 This object file has debug information, but it is not fully read in
   37948 yet.  When it is read in later, GDB might become aware of additional
   37949 source files.
   37950 @item fully-read
   37951 This object file has debug information, and this information is fully
   37952 read into GDB.  The list of source files is complete.
   37953 @end table
   37954 
   37955 The @var{sources} is a list or tuples, with each tuple describing a
   37956 single source file with the same fields as described previously.  The
   37957 @var{sources} list can be empty for object files that have no debug
   37958 information.
   37959 
   37960 @subsubheading @value{GDBN} Command
   37961 
   37962 The @value{GDBN} equivalent is @samp{info sources}.
   37963 @code{gdbtk} has an analogous command @samp{gdb_listfiles}.
   37964 
   37965 @subsubheading Example
   37966 @smallexample
   37967 (@value{GDBP})
   37968 -file-list-exec-source-files
   37969 ^done,files=[@{file="foo.c",fullname="/home/foo.c",debug-fully-read="true"@},
   37970              @{file="/home/bar.c",fullname="/home/bar.c",debug-fully-read="true"@},
   37971              @{file="gdb_could_not_find_fullpath.c",debug-fully-read="true"@}]
   37972 (@value{GDBP})
   37973 -file-list-exec-source-files
   37974 ^done,files=[@{file="test.c",
   37975               fullname="/tmp/info-sources/test.c",
   37976               debug-fully-read="true"@},
   37977              @{file="/usr/include/stdc-predef.h",
   37978               fullname="/usr/include/stdc-predef.h",
   37979               debug-fully-read="true"@},
   37980              @{file="header.h",
   37981               fullname="/tmp/info-sources/header.h",
   37982               debug-fully-read="true"@},
   37983              @{file="helper.c",
   37984               fullname="/tmp/info-sources/helper.c",
   37985               debug-fully-read="true"@}]
   37986 (@value{GDBP})
   37987 -file-list-exec-source-files -- \\.c
   37988 ^done,files=[@{file="test.c",
   37989               fullname="/tmp/info-sources/test.c",
   37990               debug-fully-read="true"@},
   37991              @{file="helper.c",
   37992               fullname="/tmp/info-sources/helper.c",
   37993               debug-fully-read="true"@}]
   37994 (@value{GDBP})
   37995 -file-list-exec-source-files --group-by-objfile
   37996 ^done,files=[@{filename="/tmp/info-sources/test.x",
   37997               debug-info="fully-read",
   37998               sources=[@{file="test.c",
   37999                         fullname="/tmp/info-sources/test.c",
   38000                         debug-fully-read="true"@},
   38001                        @{file="/usr/include/stdc-predef.h",
   38002                         fullname="/usr/include/stdc-predef.h",
   38003                         debug-fully-read="true"@},
   38004                        @{file="header.h",
   38005                         fullname="/tmp/info-sources/header.h",
   38006                         debug-fully-read="true"@}]@},
   38007              @{filename="/lib64/ld-linux-x86-64.so.2",
   38008               debug-info="none",
   38009               sources=[]@},
   38010              @{filename="system-supplied DSO at 0x7ffff7fcf000",
   38011               debug-info="none",
   38012               sources=[]@},
   38013              @{filename="/tmp/info-sources/libhelper.so",
   38014               debug-info="fully-read",
   38015               sources=[@{file="helper.c",
   38016                         fullname="/tmp/info-sources/helper.c",
   38017                         debug-fully-read="true"@},
   38018                        @{file="/usr/include/stdc-predef.h",
   38019                         fullname="/usr/include/stdc-predef.h",
   38020                         debug-fully-read="true"@},
   38021                        @{file="header.h",
   38022                         fullname="/tmp/info-sources/header.h",
   38023                         debug-fully-read="true"@}]@},
   38024              @{filename="/lib64/libc.so.6",
   38025               debug-info="none",
   38026               sources=[]@}]
   38027 @end smallexample
   38028 
   38029 @findex -file-list-shared-libraries
   38030 @subheading The @code{-file-list-shared-libraries} Command
   38031 
   38032 @subsubheading Synopsis
   38033 
   38034 @smallexample
   38035  -file-list-shared-libraries [ @var{regexp} ]
   38036 @end smallexample
   38037 
   38038 List the shared libraries in the program.
   38039 With a regular expression @var{regexp}, only those libraries whose
   38040 names match @var{regexp} are listed.
   38041 
   38042 @subsubheading @value{GDBN} Command
   38043 
   38044 The corresponding @value{GDBN} command is @samp{info shared}.  The fields
   38045 have a similar meaning to the @code{=library-loaded} notification.
   38046 The @code{ranges} field specifies the multiple segments belonging to this
   38047 library.  Each range has the following fields:
   38048 
   38049 @table @samp
   38050 @item from
   38051 The address defining the inclusive lower bound of the segment.
   38052 @item to
   38053 The address defining the exclusive upper bound of the segment.
   38054 @end table
   38055 
   38056 @subsubheading Example
   38057 @smallexample
   38058 (gdb)
   38059 -file-list-exec-source-files
   38060 ^done,shared-libraries=[
   38061 @{id="/lib/libfoo.so",target-name="/lib/libfoo.so",host-name="/lib/libfoo.so",symbols-loaded="1",thread-group="i1",ranges=[@{from="0x72815989",to="0x728162c0"@}]@},
   38062 @{id="/lib/libbar.so",target-name="/lib/libbar.so",host-name="/lib/libbar.so",symbols-loaded="1",thread-group="i1",ranges=[@{from="0x76ee48c0",to="0x76ee9160"@}]@}]
   38063 (gdb)
   38064 @end smallexample
   38065 
   38066 
   38067 @ignore
   38068 @findex -file-list-symbol-files
   38069 @subheading The @code{-file-list-symbol-files} Command
   38070 
   38071 @subsubheading Synopsis
   38072 
   38073 @smallexample
   38074  -file-list-symbol-files
   38075 @end smallexample
   38076 
   38077 List symbol files.
   38078 
   38079 @subsubheading @value{GDBN} Command
   38080 
   38081 The corresponding @value{GDBN} command is @samp{info file} (part of it).
   38082 
   38083 @subsubheading Example
   38084 N.A.
   38085 @end ignore
   38086 
   38087 
   38088 @findex -file-symbol-file
   38089 @subheading The @code{-file-symbol-file} Command
   38090 
   38091 @subsubheading Synopsis
   38092 
   38093 @smallexample
   38094  -file-symbol-file @var{file}
   38095 @end smallexample
   38096 
   38097 Read symbol table info from the specified @var{file} argument.  When
   38098 used without arguments, clears @value{GDBN}'s symbol table info.  No output is
   38099 produced, except for a completion notification.
   38100 
   38101 @subsubheading @value{GDBN} Command
   38102 
   38103 The corresponding @value{GDBN} command is @samp{symbol-file}.
   38104 
   38105 @subsubheading Example
   38106 
   38107 @smallexample
   38108 (gdb)
   38109 -file-symbol-file /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx
   38110 ^done
   38111 (gdb)
   38112 @end smallexample
   38113 
   38114 @ignore
   38115 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   38116 @node GDB/MI Memory Overlay Commands
   38117 @section @sc{gdb/mi} Memory Overlay Commands
   38118 
   38119 The memory overlay commands are not implemented.
   38120 
   38121 @c @subheading -overlay-auto
   38122 
   38123 @c @subheading -overlay-list-mapping-state
   38124 
   38125 @c @subheading -overlay-list-overlays
   38126 
   38127 @c @subheading -overlay-map
   38128 
   38129 @c @subheading -overlay-off
   38130 
   38131 @c @subheading -overlay-on
   38132 
   38133 @c @subheading -overlay-unmap
   38134 
   38135 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   38136 @node GDB/MI Signal Handling Commands
   38137 @section @sc{gdb/mi} Signal Handling Commands
   38138 
   38139 Signal handling commands are not implemented.
   38140 
   38141 @c @subheading -signal-handle
   38142 
   38143 @c @subheading -signal-list-handle-actions
   38144 
   38145 @c @subheading -signal-list-signal-types
   38146 @end ignore
   38147 
   38148 
   38149 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   38150 @node GDB/MI Target Manipulation
   38151 @section @sc{gdb/mi} Target Manipulation Commands
   38152 
   38153 
   38154 @findex -target-attach
   38155 @subheading The @code{-target-attach} Command
   38156 
   38157 @subsubheading Synopsis
   38158 
   38159 @smallexample
   38160  -target-attach @var{pid} | @var{gid} | @var{file}
   38161 @end smallexample
   38162 
   38163 Attach to a process @var{pid} or a file @var{file} outside of
   38164 @value{GDBN}, or a thread group @var{gid}.  If attaching to a thread
   38165 group, the id previously returned by 
   38166 @samp{-list-thread-groups --available} must be used.
   38167 
   38168 @subsubheading @value{GDBN} Command
   38169 
   38170 The corresponding @value{GDBN} command is @samp{attach}.
   38171 
   38172 @subsubheading Example
   38173 @smallexample
   38174 (gdb)
   38175 -target-attach 34
   38176 =thread-created,id="1"
   38177 *stopped,thread-id="1",frame=@{addr="0xb7f7e410",func="bar",args=[]@}
   38178 ^done
   38179 (gdb)
   38180 @end smallexample
   38181 
   38182 @ignore
   38183 @findex -target-compare-sections
   38184 @subheading The @code{-target-compare-sections} Command
   38185 
   38186 @subsubheading Synopsis
   38187 
   38188 @smallexample
   38189  -target-compare-sections [ @var{section} ]
   38190 @end smallexample
   38191 
   38192 Compare data of section @var{section} on target to the exec file.
   38193 Without the argument, all sections are compared.
   38194 
   38195 @subsubheading @value{GDBN} Command
   38196 
   38197 The @value{GDBN} equivalent is @samp{compare-sections}.
   38198 
   38199 @subsubheading Example
   38200 N.A.
   38201 @end ignore
   38202 
   38203 
   38204 @findex -target-detach
   38205 @subheading The @code{-target-detach} Command
   38206 
   38207 @subsubheading Synopsis
   38208 
   38209 @smallexample
   38210  -target-detach [ @var{pid} | @var{gid} ]
   38211 @end smallexample
   38212 
   38213 Detach from the remote target which normally resumes its execution.
   38214 If either @var{pid} or @var{gid} is specified, detaches from either
   38215 the specified process, or specified thread group.  There's no output.
   38216 
   38217 @subsubheading @value{GDBN} Command
   38218 
   38219 The corresponding @value{GDBN} command is @samp{detach}.
   38220 
   38221 @subsubheading Example
   38222 
   38223 @smallexample
   38224 (gdb)
   38225 -target-detach
   38226 ^done
   38227 (gdb)
   38228 @end smallexample
   38229 
   38230 
   38231 @findex -target-disconnect
   38232 @subheading The @code{-target-disconnect} Command
   38233 
   38234 @subsubheading Synopsis
   38235 
   38236 @smallexample
   38237  -target-disconnect
   38238 @end smallexample
   38239 
   38240 Disconnect from the remote target.  There's no output and the target is
   38241 generally not resumed.
   38242 
   38243 @subsubheading @value{GDBN} Command
   38244 
   38245 The corresponding @value{GDBN} command is @samp{disconnect}.
   38246 
   38247 @subsubheading Example
   38248 
   38249 @smallexample
   38250 (gdb)
   38251 -target-disconnect
   38252 ^done
   38253 (gdb)
   38254 @end smallexample
   38255 
   38256 
   38257 @findex -target-download
   38258 @subheading The @code{-target-download} Command
   38259 
   38260 @subsubheading Synopsis
   38261 
   38262 @smallexample
   38263  -target-download
   38264 @end smallexample
   38265 
   38266 Loads the executable onto the remote target.
   38267 It prints out an update message every half second, which includes the fields:
   38268 
   38269 @table @samp
   38270 @item section
   38271 The name of the section.
   38272 @item section-sent
   38273 The size of what has been sent so far for that section.
   38274 @item section-size
   38275 The size of the section.
   38276 @item total-sent
   38277 The total size of what was sent so far (the current and the previous sections).
   38278 @item total-size
   38279 The size of the overall executable to download.
   38280 @end table
   38281 
   38282 @noindent
   38283 Each message is sent as status record (@pxref{GDB/MI Output Syntax, ,
   38284 @sc{gdb/mi} Output Syntax}).
   38285 
   38286 In addition, it prints the name and size of the sections, as they are
   38287 downloaded.  These messages include the following fields:
   38288 
   38289 @table @samp
   38290 @item section
   38291 The name of the section.
   38292 @item section-size
   38293 The size of the section.
   38294 @item total-size
   38295 The size of the overall executable to download.
   38296 @end table
   38297 
   38298 @noindent
   38299 At the end, a summary is printed.
   38300 
   38301 @subsubheading @value{GDBN} Command
   38302 
   38303 The corresponding @value{GDBN} command is @samp{load}.
   38304 
   38305 @subsubheading Example
   38306 
   38307 Note: each status message appears on a single line.  Here the messages
   38308 have been broken down so that they can fit onto a page.
   38309 
   38310 @smallexample
   38311 (gdb)
   38312 -target-download
   38313 +download,@{section=".text",section-size="6668",total-size="9880"@}
   38314 +download,@{section=".text",section-sent="512",section-size="6668",
   38315 total-sent="512",total-size="9880"@}
   38316 +download,@{section=".text",section-sent="1024",section-size="6668",
   38317 total-sent="1024",total-size="9880"@}
   38318 +download,@{section=".text",section-sent="1536",section-size="6668",
   38319 total-sent="1536",total-size="9880"@}
   38320 +download,@{section=".text",section-sent="2048",section-size="6668",
   38321 total-sent="2048",total-size="9880"@}
   38322 +download,@{section=".text",section-sent="2560",section-size="6668",
   38323 total-sent="2560",total-size="9880"@}
   38324 +download,@{section=".text",section-sent="3072",section-size="6668",
   38325 total-sent="3072",total-size="9880"@}
   38326 +download,@{section=".text",section-sent="3584",section-size="6668",
   38327 total-sent="3584",total-size="9880"@}
   38328 +download,@{section=".text",section-sent="4096",section-size="6668",
   38329 total-sent="4096",total-size="9880"@}
   38330 +download,@{section=".text",section-sent="4608",section-size="6668",
   38331 total-sent="4608",total-size="9880"@}
   38332 +download,@{section=".text",section-sent="5120",section-size="6668",
   38333 total-sent="5120",total-size="9880"@}
   38334 +download,@{section=".text",section-sent="5632",section-size="6668",
   38335 total-sent="5632",total-size="9880"@}
   38336 +download,@{section=".text",section-sent="6144",section-size="6668",
   38337 total-sent="6144",total-size="9880"@}
   38338 +download,@{section=".text",section-sent="6656",section-size="6668",
   38339 total-sent="6656",total-size="9880"@}
   38340 +download,@{section=".init",section-size="28",total-size="9880"@}
   38341 +download,@{section=".fini",section-size="28",total-size="9880"@}
   38342 +download,@{section=".data",section-size="3156",total-size="9880"@}
   38343 +download,@{section=".data",section-sent="512",section-size="3156",
   38344 total-sent="7236",total-size="9880"@}
   38345 +download,@{section=".data",section-sent="1024",section-size="3156",
   38346 total-sent="7748",total-size="9880"@}
   38347 +download,@{section=".data",section-sent="1536",section-size="3156",
   38348 total-sent="8260",total-size="9880"@}
   38349 +download,@{section=".data",section-sent="2048",section-size="3156",
   38350 total-sent="8772",total-size="9880"@}
   38351 +download,@{section=".data",section-sent="2560",section-size="3156",
   38352 total-sent="9284",total-size="9880"@}
   38353 +download,@{section=".data",section-sent="3072",section-size="3156",
   38354 total-sent="9796",total-size="9880"@}
   38355 ^done,address="0x10004",load-size="9880",transfer-rate="6586",
   38356 write-rate="429"
   38357 (gdb)
   38358 @end smallexample
   38359 
   38360 
   38361 @ignore
   38362 @findex -target-exec-status
   38363 @subheading The @code{-target-exec-status} Command
   38364 
   38365 @subsubheading Synopsis
   38366 
   38367 @smallexample
   38368  -target-exec-status
   38369 @end smallexample
   38370 
   38371 Provide information on the state of the target (whether it is running or
   38372 not, for instance).
   38373 
   38374 @subsubheading @value{GDBN} Command
   38375 
   38376 There's no equivalent @value{GDBN} command.
   38377 
   38378 @subsubheading Example
   38379 N.A.
   38380 
   38381 
   38382 @findex -target-list-available-targets
   38383 @subheading The @code{-target-list-available-targets} Command
   38384 
   38385 @subsubheading Synopsis
   38386 
   38387 @smallexample
   38388  -target-list-available-targets
   38389 @end smallexample
   38390 
   38391 List the possible targets to connect to.
   38392 
   38393 @subsubheading @value{GDBN} Command
   38394 
   38395 The corresponding @value{GDBN} command is @samp{help target}.
   38396 
   38397 @subsubheading Example
   38398 N.A.
   38399 
   38400 
   38401 @findex -target-list-current-targets
   38402 @subheading The @code{-target-list-current-targets} Command
   38403 
   38404 @subsubheading Synopsis
   38405 
   38406 @smallexample
   38407  -target-list-current-targets
   38408 @end smallexample
   38409 
   38410 Describe the current target.
   38411 
   38412 @subsubheading @value{GDBN} Command
   38413 
   38414 The corresponding information is printed by @samp{info file} (among
   38415 other things).
   38416 
   38417 @subsubheading Example
   38418 N.A.
   38419 
   38420 
   38421 @findex -target-list-parameters
   38422 @subheading The @code{-target-list-parameters} Command
   38423 
   38424 @subsubheading Synopsis
   38425 
   38426 @smallexample
   38427  -target-list-parameters
   38428 @end smallexample
   38429 
   38430 @c ????
   38431 @end ignore
   38432 
   38433 @subsubheading @value{GDBN} Command
   38434 
   38435 No equivalent.
   38436 
   38437 @subsubheading Example
   38438 N.A.
   38439 
   38440 @findex -target-flash-erase
   38441 @subheading The @code{-target-flash-erase} Command
   38442 
   38443 @subsubheading Synopsis
   38444 
   38445 @smallexample
   38446  -target-flash-erase
   38447 @end smallexample
   38448 
   38449 Erases all known flash memory regions on the target.
   38450 
   38451 The corresponding @value{GDBN} command is @samp{flash-erase}.
   38452 
   38453 The output is a list of flash regions that have been erased, with starting
   38454 addresses and memory region sizes.
   38455 
   38456 @smallexample
   38457 (gdb)
   38458 -target-flash-erase
   38459 ^done,erased-regions=@{address="0x0",size="0x40000"@}
   38460 (gdb)
   38461 @end smallexample
   38462 
   38463 @findex -target-select
   38464 @subheading The @code{-target-select} Command
   38465 
   38466 @subsubheading Synopsis
   38467 
   38468 @smallexample
   38469  -target-select @var{type} @var{parameters @dots{}}
   38470 @end smallexample
   38471 
   38472 Connect @value{GDBN} to the remote target.  This command takes two args:
   38473 
   38474 @table @samp
   38475 @item @var{type}
   38476 The type of target, for instance @samp{remote}, etc.
   38477 @item @var{parameters}
   38478 Device names, host names and the like.  @xref{Target Commands, ,
   38479 Commands for Managing Targets}, for more details.
   38480 @end table
   38481 
   38482 The output is a connection notification, followed by the address at
   38483 which the target program is, in the following form:
   38484 
   38485 @smallexample
   38486 ^connected,addr="@var{address}",func="@var{function name}",
   38487   args=[@var{arg list}]
   38488 @end smallexample
   38489 
   38490 @subsubheading @value{GDBN} Command
   38491 
   38492 The corresponding @value{GDBN} command is @samp{target}.
   38493 
   38494 @subsubheading Example
   38495 
   38496 @smallexample
   38497 (gdb)
   38498 -target-select remote /dev/ttya
   38499 ^connected,addr="0xfe00a300",func="??",args=[]
   38500 (gdb)
   38501 @end smallexample
   38502 
   38503 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   38504 @node GDB/MI File Transfer Commands
   38505 @section @sc{gdb/mi} File Transfer Commands
   38506 
   38507 
   38508 @findex -target-file-put
   38509 @subheading The @code{-target-file-put} Command
   38510 
   38511 @subsubheading Synopsis
   38512 
   38513 @smallexample
   38514  -target-file-put @var{hostfile} @var{targetfile}
   38515 @end smallexample
   38516 
   38517 Copy file @var{hostfile} from the host system (the machine running
   38518 @value{GDBN}) to @var{targetfile} on the target system.
   38519 
   38520 @subsubheading @value{GDBN} Command
   38521 
   38522 The corresponding @value{GDBN} command is @samp{remote put}.
   38523 
   38524 @subsubheading Example
   38525 
   38526 @smallexample
   38527 (gdb)
   38528 -target-file-put localfile remotefile
   38529 ^done
   38530 (gdb)
   38531 @end smallexample
   38532 
   38533 
   38534 @findex -target-file-get
   38535 @subheading The @code{-target-file-get} Command
   38536 
   38537 @subsubheading Synopsis
   38538 
   38539 @smallexample
   38540  -target-file-get @var{targetfile} @var{hostfile}
   38541 @end smallexample
   38542 
   38543 Copy file @var{targetfile} from the target system to @var{hostfile}
   38544 on the host system.
   38545 
   38546 @subsubheading @value{GDBN} Command
   38547 
   38548 The corresponding @value{GDBN} command is @samp{remote get}.
   38549 
   38550 @subsubheading Example
   38551 
   38552 @smallexample
   38553 (gdb)
   38554 -target-file-get remotefile localfile
   38555 ^done
   38556 (gdb)
   38557 @end smallexample
   38558 
   38559 
   38560 @findex -target-file-delete
   38561 @subheading The @code{-target-file-delete} Command
   38562 
   38563 @subsubheading Synopsis
   38564 
   38565 @smallexample
   38566  -target-file-delete @var{targetfile}
   38567 @end smallexample
   38568 
   38569 Delete @var{targetfile} from the target system.
   38570 
   38571 @subsubheading @value{GDBN} Command
   38572 
   38573 The corresponding @value{GDBN} command is @samp{remote delete}.
   38574 
   38575 @subsubheading Example
   38576 
   38577 @smallexample
   38578 (gdb)
   38579 -target-file-delete remotefile
   38580 ^done
   38581 (gdb)
   38582 @end smallexample
   38583 
   38584 
   38585 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   38586 @node GDB/MI Ada Exceptions Commands
   38587 @section Ada Exceptions @sc{gdb/mi} Commands
   38588 
   38589 @findex -info-ada-exceptions
   38590 @subheading The @code{-info-ada-exceptions} Command
   38591 
   38592 @subsubheading Synopsis
   38593 
   38594 @smallexample
   38595  -info-ada-exceptions [ @var{regexp}]
   38596 @end smallexample
   38597 
   38598 List all Ada exceptions defined within the program being debugged.
   38599 With a regular expression @var{regexp}, only those exceptions whose
   38600 names match @var{regexp} are listed.
   38601 
   38602 @subsubheading @value{GDBN} Command
   38603 
   38604 The corresponding @value{GDBN} command is @samp{info exceptions}.
   38605 
   38606 @subsubheading Result
   38607 
   38608 The result is a table of Ada exceptions.  The following columns are
   38609 defined for each exception:
   38610 
   38611 @table @samp
   38612 @item name
   38613 The name of the exception.
   38614 
   38615 @item address
   38616 The address of the exception.
   38617 
   38618 @end table
   38619 
   38620 @subsubheading Example
   38621 
   38622 @smallexample
   38623 -info-ada-exceptions aint
   38624 ^done,ada-exceptions=@{nr_rows="2",nr_cols="2",
   38625 hdr=[@{width="1",alignment="-1",col_name="name",colhdr="Name"@},
   38626 @{width="1",alignment="-1",col_name="address",colhdr="Address"@}],
   38627 body=[@{name="constraint_error",address="0x0000000000613da0"@},
   38628 @{name="const.aint_global_e",address="0x0000000000613b00"@}]@}
   38629 @end smallexample
   38630 
   38631 @subheading Catching Ada Exceptions
   38632 
   38633 The commands describing how to ask @value{GDBN} to stop when a program
   38634 raises an exception are described at @ref{Ada Exception GDB/MI
   38635 Catchpoint Commands}.
   38636 
   38637 
   38638 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   38639 @node GDB/MI Support Commands
   38640 @section @sc{gdb/mi} Support Commands
   38641 
   38642 Since new commands and features get regularly added to @sc{gdb/mi},
   38643 some commands are available to help front-ends query the debugger
   38644 about support for these capabilities.  Similarly, it is also possible
   38645 to query @value{GDBN} about target support of certain features.
   38646 
   38647 @cindex @code{-info-gdb-mi-command}
   38648 @findex -info-gdb-mi-command
   38649 @subheading The @code{-info-gdb-mi-command} Command
   38650 
   38651 @subsubheading Synopsis
   38652 
   38653 @smallexample
   38654  -info-gdb-mi-command @var{cmd_name}
   38655 @end smallexample
   38656 
   38657 Query support for the @sc{gdb/mi} command named @var{cmd_name}.
   38658 
   38659 Note that the dash (@code{-}) starting all @sc{gdb/mi} commands
   38660 is technically not part of the command name (@pxref{GDB/MI Input
   38661 Syntax}), and thus should be omitted in @var{cmd_name}.  However,
   38662 for ease of use, this command also accepts the form with the leading
   38663 dash.
   38664 
   38665 @subsubheading @value{GDBN} Command
   38666 
   38667 There is no corresponding @value{GDBN} command.
   38668 
   38669 @subsubheading Result
   38670 
   38671 The result is a tuple.  There is currently only one field:
   38672 
   38673 @table @samp
   38674 @item exists
   38675 This field is equal to @code{"true"} if the @sc{gdb/mi} command exists,
   38676 @code{"false"} otherwise.
   38677 
   38678 @end table
   38679 
   38680 @subsubheading Example
   38681 
   38682 Here is an example where the @sc{gdb/mi} command does not exist:
   38683 
   38684 @smallexample
   38685 -info-gdb-mi-command unsupported-command
   38686 ^done,command=@{exists="false"@}
   38687 @end smallexample
   38688 
   38689 @noindent
   38690 And here is an example where the @sc{gdb/mi} command is known
   38691 to the debugger:
   38692 
   38693 @smallexample
   38694 -info-gdb-mi-command symbol-list-lines
   38695 ^done,command=@{exists="true"@}
   38696 @end smallexample
   38697 
   38698 @findex -list-features
   38699 @cindex supported @sc{gdb/mi} features, list
   38700 @subheading The @code{-list-features} Command
   38701 
   38702 Returns a list of particular features of the MI protocol that
   38703 this version of gdb implements.  A feature can be a command,
   38704 or a new field in an output of some command, or even an
   38705 important bugfix.  While a frontend can sometimes detect presence
   38706 of a feature at runtime, it is easier to perform detection at debugger
   38707 startup.
   38708 
   38709 The command returns a list of strings, with each string naming an
   38710 available feature.  Each returned string is just a name, it does not
   38711 have any internal structure.  The list of possible feature names
   38712 is given below.
   38713 
   38714 Example output:
   38715 
   38716 @smallexample
   38717 (gdb) -list-features
   38718 ^done,result=["feature1","feature2"]
   38719 @end smallexample
   38720 
   38721 The current list of features is:
   38722 
   38723 @ftable @samp
   38724 @item frozen-varobjs
   38725 Indicates support for the @code{-var-set-frozen} command, as well
   38726 as possible presence of the @code{frozen} field in the output
   38727 of @code{-varobj-create}.
   38728 @item pending-breakpoints
   38729 Indicates support for the @option{-f} option to the @code{-break-insert}
   38730 command.
   38731 @item python
   38732 Indicates Python scripting support, Python-based
   38733 pretty-printing commands, and possible presence of the
   38734 @samp{display_hint} field in the output of @code{-var-list-children}
   38735 @item thread-info
   38736 Indicates support for the @code{-thread-info} command.
   38737 @item data-read-memory-bytes
   38738 Indicates support for the @code{-data-read-memory-bytes} and the
   38739 @code{-data-write-memory-bytes} commands.
   38740 @item breakpoint-notifications
   38741 Indicates that changes to breakpoints and breakpoints created via the
   38742 CLI will be announced via async records.
   38743 @item ada-task-info
   38744 Indicates support for the @code{-ada-task-info} command.
   38745 @item language-option
   38746 Indicates that all @sc{gdb/mi} commands accept the @option{--language}
   38747 option (@pxref{Context management}).
   38748 @item info-gdb-mi-command
   38749 Indicates support for the @code{-info-gdb-mi-command} command.
   38750 @item undefined-command-error-code
   38751 Indicates support for the "undefined-command" error code in error result
   38752 records, produced when trying to execute an undefined @sc{gdb/mi} command
   38753 (@pxref{GDB/MI Result Records}).
   38754 @item exec-run-start-option
   38755 Indicates that the @code{-exec-run} command supports the @option{--start}
   38756 option (@pxref{GDB/MI Program Execution}).
   38757 @item data-disassemble-a-option
   38758 Indicates that the @code{-data-disassemble} command supports the @option{-a}
   38759 option (@pxref{GDB/MI Data Manipulation}).
   38760 @item simple-values-ref-types
   38761 Indicates that the @code{--simple-values} argument to the
   38762 @code{-stack-list-arguments}, @code{-stack-list-locals},
   38763 @code{-stack-list-variables}, and @code{-var-list-children} commands
   38764 takes reference types into account: that is, a value is considered
   38765 simple if it is neither an array, structure, or union, nor a reference
   38766 to an array, structure, or union.
   38767 @end ftable
   38768 
   38769 @findex -list-target-features
   38770 @subheading The @code{-list-target-features} Command
   38771 
   38772 Returns a list of particular features that are supported by the
   38773 target.  Those features affect the permitted MI commands, but 
   38774 unlike the features reported by the @code{-list-features} command, the
   38775 features depend on which target GDB is using at the moment.  Whenever
   38776 a target can change, due to commands such as @code{-target-select},
   38777 @code{-target-attach} or @code{-exec-run}, the list of target features
   38778 may change, and the frontend should obtain it again.
   38779 Example output:
   38780 
   38781 @smallexample
   38782 (gdb) -list-target-features
   38783 ^done,result=["async"]
   38784 @end smallexample
   38785 
   38786 The current list of features is:
   38787 
   38788 @table @samp
   38789 @item async
   38790 Indicates that the target is capable of asynchronous command
   38791 execution, which means that @value{GDBN} will accept further commands
   38792 while the target is running.
   38793 
   38794 @item reverse
   38795 Indicates that the target is capable of reverse execution.
   38796 @xref{Reverse Execution}, for more information.
   38797 
   38798 @end table
   38799 
   38800 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   38801 @node GDB/MI Miscellaneous Commands
   38802 @section Miscellaneous @sc{gdb/mi} Commands
   38803 
   38804 @c @subheading -gdb-complete
   38805 
   38806 @findex -gdb-exit
   38807 @subheading The @code{-gdb-exit} Command
   38808 
   38809 @subsubheading Synopsis
   38810 
   38811 @smallexample
   38812  -gdb-exit
   38813 @end smallexample
   38814 
   38815 Exit @value{GDBN} immediately.
   38816 
   38817 @subsubheading @value{GDBN} Command
   38818 
   38819 Approximately corresponds to @samp{quit}.
   38820 
   38821 @subsubheading Example
   38822 
   38823 @smallexample
   38824 (gdb)
   38825 -gdb-exit
   38826 ^exit
   38827 @end smallexample
   38828 
   38829 
   38830 @ignore
   38831 @findex -exec-abort
   38832 @subheading The @code{-exec-abort} Command
   38833 
   38834 @subsubheading Synopsis
   38835 
   38836 @smallexample
   38837  -exec-abort
   38838 @end smallexample
   38839 
   38840 Kill the inferior running program.
   38841 
   38842 @subsubheading @value{GDBN} Command
   38843 
   38844 The corresponding @value{GDBN} command is @samp{kill}.
   38845 
   38846 @subsubheading Example
   38847 N.A.
   38848 @end ignore
   38849 
   38850 
   38851 @findex -gdb-set
   38852 @subheading The @code{-gdb-set} Command
   38853 
   38854 @subsubheading Synopsis
   38855 
   38856 @smallexample
   38857  -gdb-set
   38858 @end smallexample
   38859 
   38860 Set an internal @value{GDBN} variable.
   38861 @c IS THIS A DOLLAR VARIABLE? OR SOMETHING LIKE ANNOTATE ?????
   38862 
   38863 @subsubheading @value{GDBN} Command
   38864 
   38865 The corresponding @value{GDBN} command is @samp{set}.
   38866 
   38867 @subsubheading Example
   38868 
   38869 @smallexample
   38870 (gdb)
   38871 -gdb-set $foo=3
   38872 ^done
   38873 (gdb)
   38874 @end smallexample
   38875 
   38876 
   38877 @findex -gdb-show
   38878 @subheading The @code{-gdb-show} Command
   38879 
   38880 @subsubheading Synopsis
   38881 
   38882 @smallexample
   38883  -gdb-show
   38884 @end smallexample
   38885 
   38886 Show the current value of a @value{GDBN} variable.
   38887 
   38888 @subsubheading @value{GDBN} Command
   38889 
   38890 The corresponding @value{GDBN} command is @samp{show}.
   38891 
   38892 @subsubheading Example
   38893 
   38894 @smallexample
   38895 (gdb)
   38896 -gdb-show annotate
   38897 ^done,value="0"
   38898 (gdb)
   38899 @end smallexample
   38900 
   38901 @c @subheading -gdb-source
   38902 
   38903 
   38904 @findex -gdb-version
   38905 @subheading The @code{-gdb-version} Command
   38906 
   38907 @subsubheading Synopsis
   38908 
   38909 @smallexample
   38910  -gdb-version
   38911 @end smallexample
   38912 
   38913 Show version information for @value{GDBN}.  Used mostly in testing.
   38914 
   38915 @subsubheading @value{GDBN} Command
   38916 
   38917 The @value{GDBN} equivalent is @samp{show version}.  @value{GDBN} by
   38918 default shows this information when you start an interactive session.
   38919 
   38920 @subsubheading Example
   38921 
   38922 @c This example modifies the actual output from GDB to avoid overfull
   38923 @c box in TeX.
   38924 @smallexample
   38925 (gdb)
   38926 -gdb-version
   38927 ~GNU gdb 5.2.1
   38928 ~Copyright 2000 Free Software Foundation, Inc.
   38929 ~GDB is free software, covered by the GNU General Public License, and
   38930 ~you are welcome to change it and/or distribute copies of it under
   38931 ~ certain conditions.
   38932 ~Type "show copying" to see the conditions.
   38933 ~There is absolutely no warranty for GDB.  Type "show warranty" for
   38934 ~ details.
   38935 ~This GDB was configured as
   38936  "--host=sparc-sun-solaris2.5.1 --target=ppc-eabi".
   38937 ^done
   38938 (gdb)
   38939 @end smallexample
   38940 
   38941 @findex -list-thread-groups
   38942 @subheading The @code{-list-thread-groups} Command
   38943 
   38944 @subsubheading Synopsis
   38945 
   38946 @smallexample
   38947 -list-thread-groups [ --available ] [ --recurse 1 ] [ @var{group} ... ]
   38948 @end smallexample
   38949 
   38950 Lists thread groups (@pxref{Thread groups}).  When a single thread
   38951 group is passed as the argument, lists the children of that group.
   38952 When several thread group are passed, lists information about those
   38953 thread groups.  Without any parameters, lists information about all
   38954 top-level thread groups.
   38955 
   38956 Normally, thread groups that are being debugged are reported.
   38957 With the @samp{--available} option, @value{GDBN} reports thread groups
   38958 available on the target.
   38959 
   38960 The output of this command may have either a @samp{threads} result or
   38961 a @samp{groups} result.  The @samp{thread} result has a list of tuples
   38962 as value, with each tuple describing a thread (@pxref{GDB/MI Thread
   38963 Information}).  The @samp{groups} result has a list of tuples as value,
   38964 each tuple describing a thread group.  If top-level groups are
   38965 requested (that is, no parameter is passed), or when several groups
   38966 are passed, the output always has a @samp{groups} result.  The format
   38967 of the @samp{group} result is described below.
   38968 
   38969 To reduce the number of roundtrips it's possible to list thread groups
   38970 together with their children, by passing the @samp{--recurse} option
   38971 and the recursion depth.  Presently, only recursion depth of 1 is
   38972 permitted.  If this option is present, then every reported thread group
   38973 will also include its children, either as @samp{group} or
   38974 @samp{threads} field.
   38975 
   38976 In general, any combination of option and parameters is permitted, with
   38977 the following caveats:
   38978 
   38979 @itemize @bullet
   38980 @item
   38981 When a single thread group is passed, the output will typically
   38982 be the @samp{threads} result.  Because threads may not contain
   38983 anything, the @samp{recurse} option will be ignored.
   38984 
   38985 @item
   38986 When the @samp{--available} option is passed, limited information may
   38987 be available.  In particular, the list of threads of a process might
   38988 be inaccessible.  Further, specifying specific thread groups might
   38989 not give any performance advantage over listing all thread groups.
   38990 The frontend should assume that @samp{-list-thread-groups --available}
   38991 is always an expensive operation and cache the results.
   38992 
   38993 @end itemize
   38994 
   38995 The @samp{groups} result is a list of tuples, where each tuple may
   38996 have the following fields:
   38997 
   38998 @table @code
   38999 @item id
   39000 Identifier of the thread group.  This field is always present.
   39001 The identifier is an opaque string; frontends should not try to
   39002 convert it to an integer, even though it might look like one.
   39003 
   39004 @item type
   39005 The type of the thread group.  At present, only @samp{process} is a
   39006 valid type.
   39007 
   39008 @item pid
   39009 The target-specific process identifier.  This field is only present
   39010 for thread groups of type @samp{process} and only if the process exists.
   39011 
   39012 @item exit-code
   39013 The exit code of this group's last exited thread, formatted in octal.
   39014 This field is only present for thread groups of type @samp{process} and
   39015 only if the process is not running.
   39016 
   39017 @item num_children
   39018 The number of children this thread group has.  This field may be
   39019 absent for an available thread group.
   39020 
   39021 @item threads
   39022 This field has a list of tuples as value, each tuple describing a
   39023 thread.  It may be present if the @samp{--recurse} option is
   39024 specified, and it's actually possible to obtain the threads.
   39025 
   39026 @item cores
   39027 This field is a list of integers, each identifying a core that one
   39028 thread of the group is running on.  This field may be absent if
   39029 such information is not available.
   39030 
   39031 @item executable
   39032 The name of the executable file that corresponds to this thread group.
   39033 The field is only present for thread groups of type @samp{process},
   39034 and only if there is a corresponding executable file.
   39035 
   39036 @end table
   39037 
   39038 @subsubheading Example
   39039 
   39040 @smallexample
   39041 (@value{GDBP})
   39042 -list-thread-groups
   39043 ^done,groups=[@{id="17",type="process",pid="yyy",num_children="2"@}]
   39044 -list-thread-groups 17
   39045 ^done,threads=[@{id="2",target-id="Thread 0xb7e14b90 (LWP 21257)",
   39046    frame=@{level="0",addr="0xffffe410",func="__kernel_vsyscall",args=[]@},state="running"@},
   39047 @{id="1",target-id="Thread 0xb7e156b0 (LWP 21254)",
   39048    frame=@{level="0",addr="0x0804891f",func="foo",args=[@{name="i",value="10"@}],
   39049            file="/tmp/a.c",fullname="/tmp/a.c",line="158",arch="i386:x86_64"@},state="running"@}]]
   39050 -list-thread-groups --available
   39051 ^done,groups=[@{id="17",type="process",pid="yyy",num_children="2",cores=[1,2]@}]
   39052 -list-thread-groups --available --recurse 1
   39053  ^done,groups=[@{id="17", types="process",pid="yyy",num_children="2",cores=[1,2],
   39054                 threads=[@{id="1",target-id="Thread 0xb7e14b90",cores=[1]@},
   39055                          @{id="2",target-id="Thread 0xb7e14b90",cores=[2]@}]@},..]
   39056 -list-thread-groups --available --recurse 1 17 18
   39057 ^done,groups=[@{id="17", types="process",pid="yyy",num_children="2",cores=[1,2],
   39058                threads=[@{id="1",target-id="Thread 0xb7e14b90",cores=[1]@},
   39059                         @{id="2",target-id="Thread 0xb7e14b90",cores=[2]@}]@},...]
   39060 @end smallexample
   39061 
   39062 @findex -info-os
   39063 @subheading The @code{-info-os} Command
   39064 
   39065 @subsubheading Synopsis
   39066 
   39067 @smallexample
   39068 -info-os [ @var{type} ]
   39069 @end smallexample
   39070 
   39071 If no argument is supplied, the command returns a table of available
   39072 operating-system-specific information types.  If one of these types is
   39073 supplied as an argument @var{type}, then the command returns a table
   39074 of data of that type.
   39075 
   39076 The types of information available depend on the target operating
   39077 system.
   39078 
   39079 @subsubheading @value{GDBN} Command
   39080 
   39081 The corresponding @value{GDBN} command is @samp{info os}.
   39082 
   39083 @subsubheading Example
   39084 
   39085 When run on a @sc{gnu}/Linux system, the output will look something
   39086 like this:
   39087 
   39088 @smallexample
   39089 (@value{GDBP})
   39090 -info-os
   39091 ^done,OSDataTable=@{nr_rows="10",nr_cols="3",
   39092 hdr=[@{width="10",alignment="-1",col_name="col0",colhdr="Type"@},
   39093      @{width="10",alignment="-1",col_name="col1",colhdr="Description"@},
   39094      @{width="10",alignment="-1",col_name="col2",colhdr="Title"@}],
   39095 body=[item=@{col0="cpus",col1="Listing of all cpus/cores on the system",
   39096             col2="CPUs"@},
   39097       item=@{col0="files",col1="Listing of all file descriptors",
   39098             col2="File descriptors"@},
   39099       item=@{col0="modules",col1="Listing of all loaded kernel modules",
   39100             col2="Kernel modules"@},
   39101       item=@{col0="msg",col1="Listing of all message queues",
   39102             col2="Message queues"@},
   39103       item=@{col0="processes",col1="Listing of all processes",
   39104             col2="Processes"@},
   39105       item=@{col0="procgroups",col1="Listing of all process groups",
   39106             col2="Process groups"@},
   39107       item=@{col0="semaphores",col1="Listing of all semaphores",
   39108             col2="Semaphores"@},
   39109       item=@{col0="shm",col1="Listing of all shared-memory regions",
   39110             col2="Shared-memory regions"@},
   39111       item=@{col0="sockets",col1="Listing of all internet-domain sockets",
   39112             col2="Sockets"@},
   39113       item=@{col0="threads",col1="Listing of all threads",
   39114             col2="Threads"@}]
   39115 (@value{GDBP})
   39116 -info-os processes
   39117 ^done,OSDataTable=@{nr_rows="190",nr_cols="4",
   39118 hdr=[@{width="10",alignment="-1",col_name="col0",colhdr="pid"@},
   39119      @{width="10",alignment="-1",col_name="col1",colhdr="user"@},
   39120      @{width="10",alignment="-1",col_name="col2",colhdr="command"@},
   39121      @{width="10",alignment="-1",col_name="col3",colhdr="cores"@}],
   39122 body=[item=@{col0="1",col1="root",col2="/sbin/init",col3="0"@},
   39123       item=@{col0="2",col1="root",col2="[kthreadd]",col3="1"@},
   39124       item=@{col0="3",col1="root",col2="[ksoftirqd/0]",col3="0"@},
   39125       ...
   39126       item=@{col0="26446",col1="stan",col2="bash",col3="0"@},
   39127       item=@{col0="28152",col1="stan",col2="bash",col3="1"@}]@}
   39128 (@value{GDBP})
   39129 @end smallexample
   39130 
   39131 (Note that the MI output here includes a @code{"Title"} column that
   39132 does not appear in command-line @code{info os}; this column is useful
   39133 for MI clients that want to enumerate the types of data, such as in a
   39134 popup menu, but is needless clutter on the command line, and
   39135 @code{info os} omits it.)
   39136 
   39137 @findex -add-inferior
   39138 @subheading The @code{-add-inferior} Command
   39139 
   39140 @subsubheading Synopsis
   39141 
   39142 @smallexample
   39143 -add-inferior [ --no-connection ]
   39144 @end smallexample
   39145 
   39146 Creates a new inferior (@pxref{Inferiors Connections and Programs}).  The created
   39147 inferior is not associated with any executable.  Such association may
   39148 be established with the @samp{-file-exec-and-symbols} command
   39149 (@pxref{GDB/MI File Commands}).
   39150 
   39151 By default, the new inferior begins connected to the same target
   39152 connection as the current inferior.  For example, if the current
   39153 inferior was connected to @code{gdbserver} with @code{target remote},
   39154 then the new inferior will be connected to the same @code{gdbserver}
   39155 instance.  The @samp{--no-connection} option starts the new inferior
   39156 with no connection yet.  You can then for example use the
   39157 @code{-target-select remote} command to connect to some other
   39158 @code{gdbserver} instance, use @code{-exec-run} to spawn a local
   39159 program, etc.
   39160 
   39161 The command response always has a field, @var{inferior}, whose value
   39162 is the identifier of the thread group corresponding to the new
   39163 inferior.
   39164 
   39165 An additional section field, @var{connection}, is optional.  This
   39166 field will only exist if the new inferior has a target connection.  If
   39167 this field exists, then its value will be a tuple containing the
   39168 following fields:
   39169 
   39170 @table @samp
   39171 @item number
   39172 The number of the connection used for the new inferior.
   39173 
   39174 @item name
   39175 The name of the connection type used for the new inferior.
   39176 @end table
   39177 
   39178 @subsubheading @value{GDBN} Command
   39179 
   39180 The corresponding @value{GDBN} command is @samp{add-inferior}
   39181 (@pxref{add_inferior_cli,,@samp{add-inferior}}).
   39182 
   39183 @subsubheading Example
   39184 
   39185 @smallexample
   39186 (@value{GDBP})
   39187 -add-inferior
   39188 ^done,inferior="i3"
   39189 @end smallexample
   39190 
   39191 @findex -remove-inferior
   39192 @subheading The @code{-remove-inferior} Command
   39193 
   39194 @subsubheading Synopsis
   39195 
   39196 @smallexample
   39197 -remove-inferior @var{inferior-id}
   39198 @end smallexample
   39199 
   39200 Removes an inferior (@pxref{Inferiors Connections and Programs}).
   39201 Only inferiors that have exited can be removed.  The @var{inferior-id}
   39202 is the inferior to be removed, and should be the same id string as
   39203 returned by the @samp{-add-inferior} command.
   39204 
   39205 When an inferior is successfully removed a
   39206 @code{=thread-group-removed} notification (@pxref{GDB/MI Async
   39207 Records}) is emitted, the @var{id} field of which contains the
   39208 @var{inferior-id} for the removed inferior.
   39209 
   39210 @subsubheading @value{GDBN} Command
   39211 
   39212 The corresponding @value{GDBN} command is @samp{remove-inferiors}
   39213 (@pxref{remove_inferiors_cli,,@samp{remove-inferiors}}).
   39214 
   39215 @subsubheading Example
   39216 
   39217 @smallexample
   39218 (@value{GDBP})
   39219 -remove-inferior i3
   39220 =thread-group-removed,id="i3"
   39221 ^done
   39222 @end smallexample
   39223 
   39224 @findex -interpreter-exec
   39225 @subheading The @code{-interpreter-exec} Command
   39226 
   39227 @subsubheading Synopsis
   39228 
   39229 @smallexample
   39230 -interpreter-exec @var{interpreter} @var{command}
   39231 @end smallexample
   39232 @anchor{-interpreter-exec} 
   39233 
   39234 Execute the specified @var{command} in the given @var{interpreter}.
   39235 
   39236 @subsubheading @value{GDBN} Command
   39237 
   39238 The corresponding @value{GDBN} command is @samp{interpreter-exec}.
   39239 
   39240 @subsubheading Example
   39241 
   39242 @smallexample
   39243 (gdb)
   39244 -interpreter-exec console "break main"
   39245 &"During symbol reading, couldn't parse type; debugger out of date?.\n"
   39246 &"During symbol reading, bad structure-type format.\n"
   39247 ~"Breakpoint 1 at 0x8074fc6: file ../../src/gdb/main.c, line 743.\n"
   39248 ^done
   39249 (gdb)
   39250 @end smallexample
   39251 
   39252 @findex -inferior-tty-set
   39253 @subheading The @code{-inferior-tty-set} Command
   39254 
   39255 @subsubheading Synopsis
   39256 
   39257 @smallexample
   39258 -inferior-tty-set /dev/pts/1
   39259 @end smallexample
   39260 
   39261 Set terminal for future runs of the program being debugged.
   39262 
   39263 @subsubheading @value{GDBN} Command
   39264 
   39265 The corresponding @value{GDBN} command is @samp{set inferior-tty} /dev/pts/1.
   39266 
   39267 @subsubheading Example
   39268 
   39269 @smallexample
   39270 (gdb)
   39271 -inferior-tty-set /dev/pts/1
   39272 ^done
   39273 (gdb)
   39274 @end smallexample
   39275 
   39276 @findex -inferior-tty-show
   39277 @subheading The @code{-inferior-tty-show} Command
   39278 
   39279 @subsubheading Synopsis
   39280 
   39281 @smallexample
   39282 -inferior-tty-show
   39283 @end smallexample
   39284 
   39285 Show terminal for future runs of program being debugged.
   39286 
   39287 @subsubheading @value{GDBN} Command
   39288 
   39289 The corresponding @value{GDBN} command is @samp{show inferior-tty}.
   39290 
   39291 @subsubheading Example
   39292 
   39293 @smallexample
   39294 (gdb)
   39295 -inferior-tty-set /dev/pts/1
   39296 ^done
   39297 (gdb)
   39298 -inferior-tty-show
   39299 ^done,inferior_tty_terminal="/dev/pts/1"
   39300 (gdb)
   39301 @end smallexample
   39302 
   39303 @findex -enable-timings
   39304 @subheading The @code{-enable-timings} Command
   39305 
   39306 @subsubheading Synopsis
   39307 
   39308 @smallexample
   39309 -enable-timings [yes | no]
   39310 @end smallexample
   39311 
   39312 Toggle the printing of the wallclock, user and system times for an MI
   39313 command as a field in its output.  This command is to help frontend
   39314 developers optimize the performance of their code.  No argument is
   39315 equivalent to @samp{yes}.
   39316 
   39317 @subsubheading @value{GDBN} Command
   39318 
   39319 No equivalent.
   39320 
   39321 @subsubheading Example
   39322 
   39323 @smallexample
   39324 (gdb)
   39325 -enable-timings
   39326 ^done
   39327 (gdb)
   39328 -break-insert main
   39329 ^done,bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y",
   39330 addr="0x080484ed",func="main",file="myprog.c",
   39331 fullname="/home/nickrob/myprog.c",line="73",thread-groups=["i1"],
   39332 times="0"@},
   39333 time=@{wallclock="0.05185",user="0.00800",system="0.00000"@}
   39334 (gdb)
   39335 -enable-timings no
   39336 ^done
   39337 (gdb)
   39338 -exec-run
   39339 ^running
   39340 (gdb)
   39341 *stopped,reason="breakpoint-hit",disp="keep",bkptno="1",thread-id="0",
   39342 frame=@{addr="0x080484ed",func="main",args=[@{name="argc",value="1"@},
   39343 @{name="argv",value="0xbfb60364"@}],file="myprog.c",
   39344 fullname="/home/nickrob/myprog.c",line="73",arch="i386:x86_64"@}
   39345 (gdb)
   39346 @end smallexample
   39347 
   39348 @findex -complete
   39349 @subheading The @code{-complete} Command
   39350 
   39351 @subsubheading Synopsis
   39352 
   39353 @smallexample
   39354 -complete @var{command}
   39355 @end smallexample
   39356 
   39357 Show a list of completions for partially typed CLI @var{command}.
   39358 
   39359 This command is intended for @sc{gdb/mi} frontends that cannot use two separate
   39360 CLI and MI channels --- for example: because of lack of PTYs like on Windows or
   39361 because @value{GDBN} is used remotely via a SSH connection.
   39362 
   39363 @subsubheading Result
   39364 
   39365 The result consists of two or three fields:
   39366 
   39367 @table @samp
   39368 @item completion
   39369 This field contains the completed @var{command}.  If @var{command}
   39370 has no known completions, this field is omitted.
   39371 
   39372 @item matches
   39373 This field contains a (possibly empty) array of matches.  It is always present.
   39374 
   39375 @item max_completions_reached
   39376 This field contains @code{1} if number of known completions is above
   39377 @code{max-completions} limit (@pxref{Completion}), otherwise it contains
   39378 @code{0}.  It is always present.
   39379 
   39380 @end table
   39381 
   39382 @subsubheading @value{GDBN} Command
   39383 
   39384 The corresponding @value{GDBN} command is @samp{complete}.
   39385 
   39386 @subsubheading Example
   39387 
   39388 @smallexample
   39389 (gdb)
   39390 -complete br
   39391 ^done,completion="break",
   39392       matches=["break","break-range"],
   39393       max_completions_reached="0"
   39394 (gdb)
   39395 -complete "b ma"
   39396 ^done,completion="b ma",
   39397       matches=["b madvise","b main"],max_completions_reached="0"
   39398 (gdb)
   39399 -complete "b push_b"
   39400 ^done,completion="b push_back(",
   39401       matches=[
   39402        "b A::push_back(void*)",
   39403        "b std::string::push_back(char)",
   39404        "b std::vector<int, std::allocator<int> >::push_back(int&&)"],
   39405       max_completions_reached="0"
   39406 (gdb)
   39407 -complete "nonexist"
   39408 ^done,matches=[],max_completions_reached="0"
   39409 (gdb)
   39410 
   39411 @end smallexample
   39412 
   39413 @node Annotations
   39414 @chapter @value{GDBN} Annotations
   39415 
   39416 This chapter describes annotations in @value{GDBN}.  Annotations were
   39417 designed to interface @value{GDBN} to graphical user interfaces or other
   39418 similar programs which want to interact with @value{GDBN} at a
   39419 relatively high level.
   39420 
   39421 The annotation mechanism has largely been superseded by @sc{gdb/mi}
   39422 (@pxref{GDB/MI}).
   39423 
   39424 @ignore
   39425 This is Edition @value{EDITION}, @value{DATE}.
   39426 @end ignore
   39427 
   39428 @menu
   39429 * Annotations Overview::  What annotations are; the general syntax.
   39430 * Server Prefix::       Issuing a command without affecting user state.
   39431 * Prompting::           Annotations marking @value{GDBN}'s need for input.
   39432 * Errors::              Annotations for error messages.
   39433 * Invalidation::        Some annotations describe things now invalid.
   39434 * Annotations for Running::
   39435                         Whether the program is running, how it stopped, etc.
   39436 * Source Annotations::  Annotations describing source code.
   39437 @end menu
   39438 
   39439 @node Annotations Overview
   39440 @section What is an Annotation?
   39441 @cindex annotations
   39442 
   39443 Annotations start with a newline character, two @samp{control-z}
   39444 characters, and the name of the annotation.  If there is no additional
   39445 information associated with this annotation, the name of the annotation
   39446 is followed immediately by a newline.  If there is additional
   39447 information, the name of the annotation is followed by a space, the
   39448 additional information, and a newline.  The additional information
   39449 cannot contain newline characters.
   39450 
   39451 Any output not beginning with a newline and two @samp{control-z}
   39452 characters denotes literal output from @value{GDBN}.  Currently there is
   39453 no need for @value{GDBN} to output a newline followed by two
   39454 @samp{control-z} characters, but if there was such a need, the
   39455 annotations could be extended with an @samp{escape} annotation which
   39456 means those three characters as output.
   39457 
   39458 The annotation @var{level}, which is specified using the
   39459 @option{--annotate} command line option (@pxref{Mode Options}), controls
   39460 how much information @value{GDBN} prints together with its prompt,
   39461 values of expressions, source lines, and other types of output.  Level 0
   39462 is for no annotations, level 1 is for use when @value{GDBN} is run as a
   39463 subprocess of @sc{gnu} Emacs, level 3 is the maximum annotation suitable
   39464 for programs that control @value{GDBN}, and level 2 annotations have
   39465 been made obsolete (@pxref{Limitations, , Limitations of the Annotation
   39466 Interface, annotate, GDB's Obsolete Annotations}).
   39467 
   39468 @table @code
   39469 @kindex set annotate
   39470 @item set annotate @var{level}
   39471 The @value{GDBN} command @code{set annotate} sets the level of
   39472 annotations to the specified @var{level}.
   39473 
   39474 @item show annotate
   39475 @kindex show annotate
   39476 Show the current annotation level.
   39477 @end table
   39478 
   39479 This chapter describes level 3 annotations.
   39480 
   39481 A simple example of starting up @value{GDBN} with annotations is:
   39482 
   39483 @smallexample
   39484 $ @kbd{gdb --annotate=3}
   39485 GNU gdb 6.0
   39486 Copyright 2003 Free Software Foundation, Inc.
   39487 GDB is free software, covered by the GNU General Public License,
   39488 and you are welcome to change it and/or distribute copies of it
   39489 under certain conditions.
   39490 Type "show copying" to see the conditions.
   39491 There is absolutely no warranty for GDB.  Type "show warranty"
   39492 for details.
   39493 This GDB was configured as "i386-pc-linux-gnu"
   39494 
   39495 ^Z^Zpre-prompt
   39496 (@value{GDBP})
   39497 ^Z^Zprompt
   39498 @kbd{quit}
   39499 
   39500 ^Z^Zpost-prompt
   39501 $
   39502 @end smallexample
   39503 
   39504 Here @samp{quit} is input to @value{GDBN}; the rest is output from
   39505 @value{GDBN}.  The three lines beginning @samp{^Z^Z} (where @samp{^Z}
   39506 denotes a @samp{control-z} character) are annotations; the rest is
   39507 output from @value{GDBN}.
   39508 
   39509 @node Server Prefix
   39510 @section The Server Prefix
   39511 @cindex server prefix
   39512 
   39513 If you prefix a command with @samp{server } then it will not affect
   39514 the command history, nor will it affect @value{GDBN}'s notion of which
   39515 command to repeat if @key{RET} is pressed on a line by itself.  This
   39516 means that commands can be run behind a user's back by a front-end in
   39517 a transparent manner.
   39518 
   39519 The @code{server } prefix does not affect the recording of values into
   39520 the value history; to print a value without recording it into the
   39521 value history, use the @code{output} command instead of the
   39522 @code{print} command.
   39523 
   39524 Using this prefix also disables confirmation requests
   39525 (@pxref{confirmation requests}).
   39526 
   39527 @node Prompting
   39528 @section Annotation for @value{GDBN} Input
   39529 
   39530 @cindex annotations for prompts
   39531 When @value{GDBN} prompts for input, it annotates this fact so it is possible
   39532 to know when to send output, when the output from a given command is
   39533 over, etc.
   39534 
   39535 Different kinds of input each have a different @dfn{input type}.  Each
   39536 input type has three annotations: a @code{pre-} annotation, which
   39537 denotes the beginning of any prompt which is being output, a plain
   39538 annotation, which denotes the end of the prompt, and then a @code{post-}
   39539 annotation which denotes the end of any echo which may (or may not) be
   39540 associated with the input.  For example, the @code{prompt} input type
   39541 features the following annotations:
   39542 
   39543 @smallexample
   39544 ^Z^Zpre-prompt
   39545 ^Z^Zprompt
   39546 ^Z^Zpost-prompt
   39547 @end smallexample
   39548 
   39549 The input types are
   39550 
   39551 @table @code
   39552 @findex pre-prompt annotation
   39553 @findex prompt annotation
   39554 @findex post-prompt annotation
   39555 @item prompt
   39556 When @value{GDBN} is prompting for a command (the main @value{GDBN} prompt).
   39557 
   39558 @findex pre-commands annotation
   39559 @findex commands annotation
   39560 @findex post-commands annotation
   39561 @item commands
   39562 When @value{GDBN} prompts for a set of commands, like in the @code{commands}
   39563 command.  The annotations are repeated for each command which is input.
   39564 
   39565 @findex pre-overload-choice annotation
   39566 @findex overload-choice annotation
   39567 @findex post-overload-choice annotation
   39568 @item overload-choice
   39569 When @value{GDBN} wants the user to select between various overloaded functions.
   39570 
   39571 @findex pre-query annotation
   39572 @findex query annotation
   39573 @findex post-query annotation
   39574 @item query
   39575 When @value{GDBN} wants the user to confirm a potentially dangerous operation.
   39576 
   39577 @findex pre-prompt-for-continue annotation
   39578 @findex prompt-for-continue annotation
   39579 @findex post-prompt-for-continue annotation
   39580 @item prompt-for-continue
   39581 When @value{GDBN} is asking the user to press return to continue.  Note: Don't
   39582 expect this to work well; instead use @code{set height 0} to disable
   39583 prompting.  This is because the counting of lines is buggy in the
   39584 presence of annotations.
   39585 @end table
   39586 
   39587 @node Errors
   39588 @section Errors
   39589 @cindex annotations for errors, warnings and interrupts
   39590 
   39591 @findex quit annotation
   39592 @smallexample
   39593 ^Z^Zquit
   39594 @end smallexample
   39595 
   39596 This annotation occurs right before @value{GDBN} responds to an interrupt.
   39597 
   39598 @findex error annotation
   39599 @smallexample
   39600 ^Z^Zerror
   39601 @end smallexample
   39602 
   39603 This annotation occurs right before @value{GDBN} responds to an error.
   39604 
   39605 Quit and error annotations indicate that any annotations which @value{GDBN} was
   39606 in the middle of may end abruptly.  For example, if a
   39607 @code{value-history-begin} annotation is followed by a @code{error}, one
   39608 cannot expect to receive the matching @code{value-history-end}.  One
   39609 cannot expect not to receive it either, however; an error annotation
   39610 does not necessarily mean that @value{GDBN} is immediately returning all the way
   39611 to the top level.
   39612 
   39613 @findex error-begin annotation
   39614 A quit or error annotation may be preceded by
   39615 
   39616 @smallexample
   39617 ^Z^Zerror-begin
   39618 @end smallexample
   39619 
   39620 Any output between that and the quit or error annotation is the error
   39621 message.
   39622 
   39623 Warning messages are not yet annotated.
   39624 @c If we want to change that, need to fix warning(), type_error(),
   39625 @c range_error(), and possibly other places.
   39626 
   39627 @node Invalidation
   39628 @section Invalidation Notices
   39629 
   39630 @cindex annotations for invalidation messages
   39631 The following annotations say that certain pieces of state may have
   39632 changed.
   39633 
   39634 @table @code
   39635 @findex frames-invalid annotation
   39636 @item ^Z^Zframes-invalid
   39637 
   39638 The frames (for example, output from the @code{backtrace} command) may
   39639 have changed.
   39640 
   39641 @findex breakpoints-invalid annotation
   39642 @item ^Z^Zbreakpoints-invalid
   39643 
   39644 The breakpoints may have changed.  For example, the user just added or
   39645 deleted a breakpoint.
   39646 @end table
   39647 
   39648 @node Annotations for Running
   39649 @section Running the Program
   39650 @cindex annotations for running programs
   39651 
   39652 @findex starting annotation
   39653 @findex stopping annotation
   39654 When the program starts executing due to a @value{GDBN} command such as
   39655 @code{step} or @code{continue},
   39656 
   39657 @smallexample
   39658 ^Z^Zstarting
   39659 @end smallexample
   39660 
   39661 is output.  When the program stops,
   39662 
   39663 @smallexample
   39664 ^Z^Zstopped
   39665 @end smallexample
   39666 
   39667 is output.  Before the @code{stopped} annotation, a variety of
   39668 annotations describe how the program stopped.
   39669 
   39670 @table @code
   39671 @findex exited annotation
   39672 @item ^Z^Zexited @var{exit-status}
   39673 The program exited, and @var{exit-status} is the exit status (zero for
   39674 successful exit, otherwise nonzero).
   39675 
   39676 @findex signalled annotation
   39677 @findex signal-name annotation
   39678 @findex signal-name-end annotation
   39679 @findex signal-string annotation
   39680 @findex signal-string-end annotation
   39681 @item ^Z^Zsignalled
   39682 The program exited with a signal.  After the @code{^Z^Zsignalled}, the
   39683 annotation continues:
   39684 
   39685 @smallexample
   39686 @var{intro-text}
   39687 ^Z^Zsignal-name
   39688 @var{name}
   39689 ^Z^Zsignal-name-end
   39690 @var{middle-text}
   39691 ^Z^Zsignal-string
   39692 @var{string}
   39693 ^Z^Zsignal-string-end
   39694 @var{end-text}
   39695 @end smallexample
   39696 
   39697 @noindent
   39698 where @var{name} is the name of the signal, such as @code{SIGILL} or
   39699 @code{SIGSEGV}, and @var{string} is the explanation of the signal, such
   39700 as @code{Illegal Instruction} or @code{Segmentation fault}.  The arguments
   39701 @var{intro-text}, @var{middle-text}, and @var{end-text} are for the
   39702 user's benefit and have no particular format.
   39703 
   39704 @findex signal annotation
   39705 @item ^Z^Zsignal
   39706 The syntax of this annotation is just like @code{signalled}, but @value{GDBN} is
   39707 just saying that the program received the signal, not that it was
   39708 terminated with it.
   39709 
   39710 @findex breakpoint annotation
   39711 @item ^Z^Zbreakpoint @var{number}
   39712 The program hit breakpoint number @var{number}.
   39713 
   39714 @findex watchpoint annotation
   39715 @item ^Z^Zwatchpoint @var{number}
   39716 The program hit watchpoint number @var{number}.
   39717 @end table
   39718 
   39719 @node Source Annotations
   39720 @section Displaying Source
   39721 @cindex annotations for source display
   39722 
   39723 @findex source annotation
   39724 The following annotation is used instead of displaying source code:
   39725 
   39726 @smallexample
   39727 ^Z^Zsource @var{filename}:@var{line}:@var{character}:@var{middle}:@var{addr}
   39728 @end smallexample
   39729 
   39730 where @var{filename} is an absolute file name indicating which source
   39731 file, @var{line} is the line number within that file (where 1 is the
   39732 first line in the file), @var{character} is the character position
   39733 within the file (where 0 is the first character in the file) (for most
   39734 debug formats this will necessarily point to the beginning of a line),
   39735 @var{middle} is @samp{middle} if @var{addr} is in the middle of the
   39736 line, or @samp{beg} if @var{addr} is at the beginning of the line, and
   39737 @var{addr} is the address in the target program associated with the
   39738 source which is being displayed.  The @var{addr} is in the form @samp{0x}
   39739 followed by one or more lowercase hex digits (note that this does not
   39740 depend on the language).
   39741 
   39742 @node Debugger Adapter Protocol
   39743 @chapter Debugger Adapter Protocol
   39744 
   39745 The Debugger Adapter Protocol is a generic API that is used by some
   39746 IDEs to communicate with debuggers.  It is documented at
   39747 @url{https://microsoft.github.io/debug-adapter-protocol/}.
   39748 
   39749 Generally, @value{GDBN} implements the Debugger Adapter Protocol as
   39750 written.  However, in some cases, extensions are either needed or even
   39751 expected.
   39752 
   39753 @value{GDBN} defines some parameters that can be passed to the
   39754 @code{launch} request:
   39755 
   39756 @table @code
   39757 @item args
   39758 If provided, this should be an array of strings.  These strings are
   39759 provided as command-line arguments to the inferior, as if by
   39760 @code{set args}.  @xref{Arguments}.
   39761 
   39762 @item cwd
   39763 If provided, this should be a string.  @value{GDBN} will change its
   39764 working directory to this directory, as if by the @code{cd} command
   39765 (@pxref{Working Directory}).  The launched program will inherit this
   39766 as its working directory.  Note that change of directory happens
   39767 before the @code{program} parameter is processed.  This will affect
   39768 the result if @code{program} is a relative filename.
   39769 
   39770 @item env
   39771 If provided, this should be an object.  Each key of the object will be
   39772 used as the name of an environment variable; each value must be a
   39773 string and will be the value of that variable.  The environment of the
   39774 inferior will be set to exactly as passed in.  @xref{Environment}.
   39775 
   39776 @item program
   39777 If provided, this is a string that specifies the program to use.  This
   39778 corresponds to the @code{file} command.  @xref{Files}.
   39779 
   39780 @item stopAtBeginningOfMainSubprogram
   39781 If provided, this must be a boolean.  When @samp{True}, @value{GDBN}
   39782 will set a temporary breakpoint at the program's main procedure, using
   39783 the same approach as the @code{start} command.  @xref{Starting}.
   39784 
   39785 @item stopOnEntry
   39786 If provided, this must be a boolean.  When @samp{True}, @value{GDBN}
   39787 will set a temporary breakpoint at the program's first instruction, using
   39788 the same approach as the @code{starti} command.  @xref{Starting}.
   39789 @end table
   39790 
   39791 @value{GDBN} defines some parameters that can be passed to the
   39792 @code{attach} request.  Either @code{pid} or @code{target} must be
   39793 specified, but if both are specified then @code{target} will be
   39794 ignored.
   39795 
   39796 @table @code
   39797 @item pid
   39798 The process ID to which @value{GDBN} should attach.  @xref{Attach}.
   39799 
   39800 @item program
   39801 If provided, this is a string that specifies the program to use.  This
   39802 corresponds to the @code{file} command.  @xref{Files}.  In some cases,
   39803 @value{GDBN} can automatically determine which program is running.
   39804 However, for many remote targets, this is not the case, and so this
   39805 should be supplied.
   39806 
   39807 @item target
   39808 The target to which @value{GDBN} should connect.  This is a string and
   39809 is passed to the @code{target remote} command.  @xref{Connecting}.
   39810 @end table
   39811 
   39812 In response to the @code{disassemble} request, DAP allows the client
   39813 to return the bytes of each instruction in an implementation-defined
   39814 format.  @value{GDBN} implements this by sending a string with the
   39815 bytes encoded in hex, like @code{"55a2b900"}.
   39816 
   39817 When the @code{repl} context is used for the @code{evaluate} request,
   39818 @value{GDBN} evaluates the provided expression as a CLI command.
   39819 
   39820 Evaluation in general can cause the inferior to continue execution.
   39821 For example, evaluating the @code{continue} command could do this, as
   39822 could evaluating an expression that involves an inferior function
   39823 call.
   39824 
   39825 @code{repl} evaluation can also cause @value{GDBN} to appear to stop
   39826 responding to requests, for example if a CLI script does a lengthy
   39827 computation.
   39828 
   39829 Evaluations like this can be interrupted using the DAP @code{cancel}
   39830 request.  (In fact, @code{cancel} should work for any request, but it
   39831 is unlikely to be useful for most of them.)
   39832 
   39833 @value{GDBN} provides a couple of logging settings that can be used in
   39834 DAP mode.  These can be set on the command line using the @code{-iex}
   39835 option (@pxref{File Options}).
   39836 
   39837 @table @code
   39838 @item set debug dap-log-file @r{[}@var{filename}@r{]}
   39839 Enable DAP logging.  Logs are written to @var{filename}.  If no
   39840 @var{filename} is given, logging is stopped.
   39841 
   39842 @item set debug dap-log-level @var{level}
   39843 Set the DAP logging level.  The default is @samp{1}, which logs the
   39844 DAP protocol, whatever debug messages the developers thought were
   39845 useful, and unexpected exceptions.  Level @samp{2} can be used to log
   39846 all exceptions, including ones that are considered to be expected.
   39847 For example, a failure to parse an expression would be considered a
   39848 normal exception and not normally be logged.
   39849 @end table
   39850 
   39851 @node JIT Interface
   39852 @chapter JIT Compilation Interface
   39853 @cindex just-in-time compilation
   39854 @cindex JIT compilation interface
   39855 
   39856 This chapter documents @value{GDBN}'s @dfn{just-in-time} (JIT) compilation
   39857 interface.  A JIT compiler is a program or library that generates native
   39858 executable code at runtime and executes it, usually in order to achieve good
   39859 performance while maintaining platform independence. 
   39860 
   39861 Programs that use JIT compilation are normally difficult to debug because
   39862 portions of their code are generated at runtime, instead of being loaded from
   39863 object files, which is where @value{GDBN} normally finds the program's symbols
   39864 and debug information.  In order to debug programs that use JIT compilation,
   39865 @value{GDBN} has an interface that allows the program to register in-memory
   39866 symbol files with @value{GDBN} at runtime.
   39867 
   39868 If you are using @value{GDBN} to debug a program that uses this interface, then
   39869 it should work transparently so long as you have not stripped the binary.  If
   39870 you are developing a JIT compiler, then the interface is documented in the rest
   39871 of this chapter.  At this time, the only known client of this interface is the
   39872 LLVM JIT.
   39873 
   39874 Broadly speaking, the JIT interface mirrors the dynamic loader interface.  The
   39875 JIT compiler communicates with @value{GDBN} by writing data into a global
   39876 variable and calling a function at a well-known symbol.  When @value{GDBN}
   39877 attaches, it reads a linked list of symbol files from the global variable to
   39878 find existing code, and puts a breakpoint in the function so that it can find
   39879 out about additional code.
   39880 
   39881 @menu
   39882 * Declarations::                Relevant C struct declarations
   39883 * Registering Code::            Steps to register code
   39884 * Unregistering Code::          Steps to unregister code
   39885 * Custom Debug Info::           Emit debug information in a custom format
   39886 @end menu
   39887 
   39888 @node Declarations
   39889 @section JIT Declarations
   39890 
   39891 These are the relevant struct declarations that a C program should include to
   39892 implement the interface:
   39893 
   39894 @smallexample
   39895 typedef enum
   39896 @{
   39897   JIT_NOACTION = 0,
   39898   JIT_REGISTER_FN,
   39899   JIT_UNREGISTER_FN
   39900 @} jit_actions_t;
   39901 
   39902 struct jit_code_entry
   39903 @{
   39904   struct jit_code_entry *next_entry;
   39905   struct jit_code_entry *prev_entry;
   39906   const char *symfile_addr;
   39907   uint64_t symfile_size;
   39908 @};
   39909 
   39910 struct jit_descriptor
   39911 @{
   39912   uint32_t version;
   39913   /* This type should be jit_actions_t, but we use uint32_t
   39914      to be explicit about the bitwidth.  */
   39915   uint32_t action_flag;
   39916   struct jit_code_entry *relevant_entry;
   39917   struct jit_code_entry *first_entry;
   39918 @};
   39919 
   39920 /* GDB puts a breakpoint in this function.  */
   39921 void __attribute__((noinline)) __jit_debug_register_code() @{ @};
   39922 
   39923 /* Make sure to specify the version statically, because the
   39924    debugger may check the version before we can set it.  */
   39925 struct jit_descriptor __jit_debug_descriptor = @{ 1, 0, 0, 0 @};
   39926 @end smallexample
   39927 
   39928 If the JIT is multi-threaded, then it is important that the JIT synchronize any
   39929 modifications to this global data properly, which can easily be done by putting
   39930 a global mutex around modifications to these structures.
   39931 
   39932 @node Registering Code
   39933 @section Registering Code
   39934 
   39935 To register code with @value{GDBN}, the JIT should follow this protocol:
   39936 
   39937 @itemize @bullet
   39938 @item
   39939 Generate an object file in memory with symbols and other desired debug
   39940 information.  The file must include the virtual addresses of the sections.
   39941 
   39942 @item
   39943 Create a code entry for the file, which gives the start and size of the symbol
   39944 file.
   39945 
   39946 @item
   39947 Add it to the linked list in the JIT descriptor.
   39948 
   39949 @item
   39950 Point the relevant_entry field of the descriptor at the entry.
   39951 
   39952 @item
   39953 Set @code{action_flag} to @code{JIT_REGISTER} and call
   39954 @code{__jit_debug_register_code}.
   39955 @end itemize
   39956 
   39957 When @value{GDBN} is attached and the breakpoint fires, @value{GDBN} uses the
   39958 @code{relevant_entry} pointer so it doesn't have to walk the list looking for
   39959 new code.  However, the linked list must still be maintained in order to allow
   39960 @value{GDBN} to attach to a running process and still find the symbol files.
   39961 
   39962 @node Unregistering Code
   39963 @section Unregistering Code
   39964 
   39965 If code is freed, then the JIT should use the following protocol:
   39966 
   39967 @itemize @bullet
   39968 @item
   39969 Remove the code entry corresponding to the code from the linked list.
   39970 
   39971 @item
   39972 Point the @code{relevant_entry} field of the descriptor at the code entry.
   39973 
   39974 @item
   39975 Set @code{action_flag} to @code{JIT_UNREGISTER} and call
   39976 @code{__jit_debug_register_code}.
   39977 @end itemize
   39978 
   39979 If the JIT frees or recompiles code without unregistering it, then @value{GDBN}
   39980 and the JIT will leak the memory used for the associated symbol files.
   39981 
   39982 @node Custom Debug Info
   39983 @section Custom Debug Info
   39984 @cindex custom JIT debug info
   39985 @cindex JIT debug info reader
   39986 
   39987 Generating debug information in platform-native file formats (like ELF
   39988 or COFF) may be an overkill for JIT compilers; especially if all the
   39989 debug info is used for is displaying a meaningful backtrace.  The
   39990 issue can be resolved by having the JIT writers decide on a debug info
   39991 format and also provide a reader that parses the debug info generated
   39992 by the JIT compiler.  This section gives a brief overview on writing
   39993 such a parser.  More specific details can be found in the source file
   39994 @file{gdb/jit-reader.in}, which is also installed as a header at
   39995 @file{@var{includedir}/gdb/jit-reader.h} for easy inclusion.
   39996 
   39997 The reader is implemented as a shared object (so this functionality is
   39998 not available on platforms which don't allow loading shared objects at
   39999 runtime).  Two @value{GDBN} commands, @code{jit-reader-load} and
   40000 @code{jit-reader-unload} are provided, to be used to load and unload
   40001 the readers from a preconfigured directory.  Once loaded, the shared
   40002 object is used the parse the debug information emitted by the JIT
   40003 compiler.
   40004 
   40005 @menu
   40006 * Using JIT Debug Info Readers::       How to use supplied readers correctly
   40007 * Writing JIT Debug Info Readers::     Creating a debug-info reader
   40008 @end menu
   40009 
   40010 @node Using JIT Debug Info Readers
   40011 @subsection Using JIT Debug Info Readers
   40012 @kindex jit-reader-load
   40013 @kindex jit-reader-unload
   40014 
   40015 Readers can be loaded and unloaded using the @code{jit-reader-load}
   40016 and @code{jit-reader-unload} commands.
   40017 
   40018 @table @code
   40019 @item jit-reader-load @var{reader}
   40020 Load the JIT reader named @var{reader}, which is a shared
   40021 object specified as either an absolute or a relative file name.  In
   40022 the latter case, @value{GDBN} will try to load the reader from a
   40023 pre-configured directory, usually @file{@var{libdir}/gdb/} on a UNIX
   40024 system (here @var{libdir} is the system library directory, often
   40025 @file{/usr/local/lib}).
   40026 
   40027 Only one reader can be active at a time; trying to load a second
   40028 reader when one is already loaded will result in @value{GDBN}
   40029 reporting an error.  A new JIT reader can be loaded by first unloading
   40030 the current one using @code{jit-reader-unload} and then invoking
   40031 @code{jit-reader-load}.
   40032 
   40033 @item show jit-reader-directory
   40034 This command will show the directory that is used by
   40035 @code{jit-reader-load} when a relative file name is specified.
   40036 
   40037 @item jit-reader-unload
   40038 Unload the currently loaded JIT reader.
   40039 
   40040 @end table
   40041 
   40042 @node Writing JIT Debug Info Readers
   40043 @subsection Writing JIT Debug Info Readers
   40044 @cindex writing JIT debug info readers
   40045 
   40046 As mentioned, a reader is essentially a shared object conforming to a
   40047 certain ABI.  This ABI is described in @file{jit-reader.h}.
   40048 
   40049 @file{jit-reader.h} defines the structures, macros and functions
   40050 required to write a reader.  It is installed (along with
   40051 @value{GDBN}), in @file{@var{includedir}/gdb} where @var{includedir} is
   40052 the system include directory.
   40053 
   40054 Readers need to be released under a GPL compatible license.  A reader
   40055 can be declared as released under such a license by placing the macro
   40056 @code{GDB_DECLARE_GPL_COMPATIBLE_READER} in a source file.
   40057 
   40058 The entry point for readers is the symbol @code{gdb_init_reader},
   40059 which is expected to be a function with the prototype
   40060 
   40061 @findex gdb_init_reader
   40062 @smallexample
   40063 extern struct gdb_reader_funcs *gdb_init_reader (void);
   40064 @end smallexample
   40065 
   40066 @cindex @code{struct gdb_reader_funcs}
   40067 
   40068 @code{struct gdb_reader_funcs} contains a set of pointers to callback
   40069 functions.  These functions are executed to read the debug info
   40070 generated by the JIT compiler (@code{read}), to unwind stack frames
   40071 (@code{unwind}) and to create canonical frame IDs
   40072 (@code{get_frame_id}).  It also has a callback that is called when the
   40073 reader is being unloaded (@code{destroy}).  The struct looks like this
   40074 
   40075 @smallexample
   40076 struct gdb_reader_funcs
   40077 @{
   40078   /* Must be set to GDB_READER_INTERFACE_VERSION.  */
   40079   int reader_version;
   40080 
   40081   /* For use by the reader.  */
   40082   void *priv_data;
   40083 
   40084   gdb_read_debug_info *read;
   40085   gdb_unwind_frame *unwind;
   40086   gdb_get_frame_id *get_frame_id;
   40087   gdb_destroy_reader *destroy;
   40088 @};
   40089 @end smallexample
   40090 
   40091 @cindex @code{struct gdb_symbol_callbacks}
   40092 @cindex @code{struct gdb_unwind_callbacks}
   40093 
   40094 The callbacks are provided with another set of callbacks by
   40095 @value{GDBN} to do their job.  For @code{read}, these callbacks are
   40096 passed in a @code{struct gdb_symbol_callbacks} and for @code{unwind}
   40097 and @code{get_frame_id}, in a @code{struct gdb_unwind_callbacks}.
   40098 @code{struct gdb_symbol_callbacks} has callbacks to create new object
   40099 files and new symbol tables inside those object files.  @code{struct
   40100 gdb_unwind_callbacks} has callbacks to read registers off the current
   40101 frame and to write out the values of the registers in the previous
   40102 frame.  Both have a callback (@code{target_read}) to read bytes off the
   40103 target's address space.
   40104 
   40105 @node In-Process Agent
   40106 @chapter In-Process Agent
   40107 @cindex debugging agent
   40108 The traditional debugging model is conceptually low-speed, but works fine,
   40109 because most bugs can be reproduced in debugging-mode execution.  However,
   40110 as multi-core or many-core processors are becoming mainstream, and
   40111 multi-threaded programs become more and more popular, there should be more
   40112 and more bugs that only manifest themselves at normal-mode execution, for
   40113 example, thread races, because debugger's interference with the program's
   40114 timing may conceal the bugs.  On the other hand, in some applications,
   40115 it is not feasible for the debugger to interrupt the program's execution
   40116 long enough for the developer to learn anything helpful about its behavior.
   40117 If the program's correctness depends on its real-time behavior, delays
   40118 introduced by a debugger might cause the program to fail, even when the
   40119 code itself is correct.  It is useful to be able to observe the program's
   40120 behavior without interrupting it.
   40121 
   40122 Therefore, traditional debugging model is too intrusive to reproduce
   40123 some bugs.  In order to reduce the interference with the program, we can
   40124 reduce the number of operations performed by debugger.  The
   40125 @dfn{In-Process Agent}, a shared library, is running within the same
   40126 process with inferior, and is able to perform some debugging operations
   40127 itself.  As a result, debugger is only involved when necessary, and
   40128 performance of debugging can be improved accordingly.  Note that
   40129 interference with program can be reduced but can't be removed completely,
   40130 because the in-process agent will still stop or slow down the program.
   40131 
   40132 The in-process agent can interpret and execute Agent Expressions
   40133 (@pxref{Agent Expressions}) during performing debugging operations.  The
   40134 agent expressions can be used for different purposes, such as collecting
   40135 data in tracepoints, and condition evaluation in breakpoints.
   40136 
   40137 @anchor{Control Agent}
   40138 You can control whether the in-process agent is used as an aid for
   40139 debugging with the following commands:
   40140 
   40141 @table @code
   40142 @kindex set agent on
   40143 @item set agent on
   40144 Causes the in-process agent to perform some operations on behalf of the
   40145 debugger.  Just which operations requested by the user will be done
   40146 by the in-process agent depends on the its capabilities.  For example,
   40147 if you request to evaluate breakpoint conditions in the in-process agent,
   40148 and the in-process agent has such capability as well, then breakpoint
   40149 conditions will be evaluated in the in-process agent.
   40150 
   40151 @kindex set agent off
   40152 @item set agent off
   40153 Disables execution of debugging operations by the in-process agent.  All
   40154 of the operations will be performed by @value{GDBN}.
   40155 
   40156 @kindex show agent
   40157 @item show agent
   40158 Display the current setting of execution of debugging operations by
   40159 the in-process agent.
   40160 @end table
   40161 
   40162 @menu
   40163 * In-Process Agent Protocol::
   40164 @end menu
   40165 
   40166 @node In-Process Agent Protocol
   40167 @section In-Process Agent Protocol
   40168 @cindex in-process agent protocol
   40169 
   40170 The in-process agent is able to communicate with both @value{GDBN} and
   40171 GDBserver (@pxref{In-Process Agent}).  This section documents the protocol
   40172 used for communications between @value{GDBN} or GDBserver and the IPA.
   40173 In general, @value{GDBN} or GDBserver sends commands
   40174 (@pxref{IPA Protocol Commands}) and data to in-process agent, and then
   40175 in-process agent replies back with the return result of the command, or
   40176 some other information.  The data sent to in-process agent is composed
   40177 of primitive data types, such as 4-byte or 8-byte type, and composite
   40178 types, which are called objects (@pxref{IPA Protocol Objects}).
   40179 
   40180 @menu
   40181 * IPA Protocol Objects::
   40182 * IPA Protocol Commands::
   40183 @end menu
   40184 
   40185 @node IPA Protocol Objects
   40186 @subsection IPA Protocol Objects
   40187 @cindex ipa protocol objects
   40188 
   40189 The commands sent to and results received from agent may contain some
   40190 complex data types called @dfn{objects}.
   40191 
   40192 The in-process agent is running on the same machine with @value{GDBN}
   40193 or GDBserver, so it doesn't have to handle as much differences between
   40194 two ends as remote protocol (@pxref{Remote Protocol}) tries to handle.
   40195 However, there are still some differences of two ends in two processes:
   40196 
   40197 @enumerate
   40198 @item
   40199 word size.  On some 64-bit machines, @value{GDBN} or GDBserver can be
   40200 compiled as a 64-bit executable, while in-process agent is a 32-bit one.
   40201 @item
   40202 ABI.  Some machines may have multiple types of ABI, @value{GDBN} or
   40203 GDBserver is compiled with one, and in-process agent is compiled with
   40204 the other one.
   40205 @end enumerate
   40206 
   40207 Here are the IPA Protocol Objects:
   40208 
   40209 @enumerate
   40210 @item
   40211 agent expression object.  It represents an agent expression
   40212 (@pxref{Agent Expressions}).
   40213 @anchor{agent expression object}
   40214 @item
   40215 tracepoint action object.  It represents a tracepoint action
   40216 (@pxref{Tracepoint Actions,,Tracepoint Action Lists}) to collect registers,
   40217 memory, static trace data and to evaluate expression.
   40218 @anchor{tracepoint action object}
   40219 @item
   40220 tracepoint object.  It represents a tracepoint (@pxref{Tracepoints}).
   40221 @anchor{tracepoint object}
   40222 
   40223 @end enumerate
   40224 
   40225 The following table describes important attributes of each IPA protocol
   40226 object:
   40227 
   40228 @multitable @columnfractions .30 .20 .50
   40229 @headitem Name @tab Size @tab Description
   40230 @item @emph{agent expression object} @tab @tab
   40231 @item length @tab 4 @tab length of bytes code
   40232 @item byte code @tab @var{length} @tab contents of byte code
   40233 @item @emph{tracepoint action for collecting memory} @tab @tab
   40234 @item 'M' @tab 1 @tab type of tracepoint action
   40235 @item addr @tab 8 @tab if @var{basereg} is @samp{-1}, @var{addr} is the
   40236 address of the lowest byte to collect, otherwise @var{addr} is the offset
   40237 of @var{basereg} for memory collecting.
   40238 @item len @tab 8 @tab length of memory for collecting
   40239 @item basereg @tab 4 @tab the register number containing the starting
   40240 memory address for collecting.
   40241 @item @emph{tracepoint action for collecting registers} @tab @tab
   40242 @item 'R' @tab 1 @tab type of tracepoint action
   40243 @item @emph{tracepoint action for collecting static trace data} @tab @tab
   40244 @item 'L' @tab 1 @tab type of tracepoint action
   40245 @item @emph{tracepoint action for expression evaluation} @tab @tab
   40246 @item 'X' @tab 1 @tab type of tracepoint action
   40247 @item agent expression @tab length of @tab @ref{agent expression object}
   40248 @item @emph{tracepoint object} @tab @tab
   40249 @item number @tab 4 @tab number of tracepoint
   40250 @item address @tab 8 @tab address of tracepoint inserted on
   40251 @item type @tab 4 @tab type of tracepoint
   40252 @item enabled @tab 1 @tab enable or disable of tracepoint
   40253 @item step_count @tab 8 @tab step
   40254 @item pass_count @tab 8 @tab pass
   40255 @item numactions @tab 4 @tab number of tracepoint actions
   40256 @item hit count @tab 8 @tab hit count
   40257 @item trace frame usage @tab 8 @tab trace frame usage
   40258 @item compiled_cond @tab 8 @tab compiled condition
   40259 @item orig_size @tab 8 @tab orig size
   40260 @item condition @tab 4 if condition is NULL otherwise length of
   40261 @ref{agent expression object}
   40262 @tab zero if condition is NULL, otherwise is
   40263 @ref{agent expression object}
   40264 @item actions @tab variable
   40265 @tab numactions number of @ref{tracepoint action object}
   40266 @end multitable
   40267 
   40268 @node IPA Protocol Commands
   40269 @subsection IPA Protocol Commands
   40270 @cindex ipa protocol commands
   40271 
   40272 The spaces in each command are delimiters to ease reading this commands
   40273 specification.  They don't exist in real commands.
   40274 
   40275 @table @samp
   40276 
   40277 @item FastTrace:@var{tracepoint_object} @var{gdb_jump_pad_head}
   40278 Installs a new fast tracepoint described by @var{tracepoint_object}
   40279 (@pxref{tracepoint object}).  The @var{gdb_jump_pad_head}, 8-byte long, is the
   40280 head of @dfn{jumppad}, which is used to jump to data collection routine
   40281 in IPA finally.
   40282 
   40283 Replies:
   40284 @table @samp
   40285 @item OK @var{target_address} @var{gdb_jump_pad_head} @var{fjump_size} @var{fjump}
   40286 @var{target_address} is address of tracepoint in the inferior.
   40287 The @var{gdb_jump_pad_head} is updated head of jumppad.  Both of
   40288 @var{target_address} and @var{gdb_jump_pad_head} are 8-byte long.
   40289 The @var{fjump} contains a sequence of instructions jump to jumppad entry.
   40290 The @var{fjump_size}, 4-byte long, is the size of @var{fjump}.
   40291 
   40292 @end table
   40293 
   40294 @item close
   40295 Closes the in-process agent.  This command is sent when @value{GDBN} or GDBserver
   40296 is about to kill inferiors.
   40297 
   40298 @item qTfSTM
   40299 @xref{qTfSTM}.
   40300 @item qTsSTM
   40301 @xref{qTsSTM}.
   40302 @item qTSTMat
   40303 @xref{qTSTMat}.
   40304 @item probe_marker_at:@var{address}
   40305 Asks in-process agent to probe the marker at @var{address}.
   40306 
   40307 Replies:
   40308 @table @samp
   40309 @end table
   40310 @item unprobe_marker_at:@var{address}
   40311 Asks in-process agent to unprobe the marker at @var{address}.
   40312 @end table
   40313 
   40314 @node GDB Bugs
   40315 @chapter Reporting Bugs in @value{GDBN}
   40316 @cindex bugs in @value{GDBN}
   40317 @cindex reporting bugs in @value{GDBN}
   40318 
   40319 Your bug reports play an essential role in making @value{GDBN} reliable.
   40320 
   40321 Reporting a bug may help you by bringing a solution to your problem, or it
   40322 may not.  But in any case the principal function of a bug report is to help
   40323 the entire community by making the next version of @value{GDBN} work better.  Bug
   40324 reports are your contribution to the maintenance of @value{GDBN}.
   40325 
   40326 In order for a bug report to serve its purpose, you must include the
   40327 information that enables us to fix the bug.
   40328 
   40329 @menu
   40330 * Bug Criteria::                Have you found a bug?
   40331 * Bug Reporting::               How to report bugs
   40332 @end menu
   40333 
   40334 @node Bug Criteria
   40335 @section Have You Found a Bug?
   40336 @cindex bug criteria
   40337 
   40338 If you are not sure whether you have found a bug, here are some guidelines:
   40339 
   40340 @itemize @bullet
   40341 @cindex fatal signal
   40342 @cindex debugger crash
   40343 @cindex crash of debugger
   40344 @item
   40345 If the debugger gets a fatal signal, for any input whatever, that is a
   40346 @value{GDBN} bug.  Reliable debuggers never crash.
   40347 
   40348 @cindex error on valid input
   40349 @item
   40350 If @value{GDBN} produces an error message for valid input, that is a
   40351 bug.  (Note that if you're cross debugging, the problem may also be
   40352 somewhere in the connection to the target.)
   40353 
   40354 @cindex invalid input
   40355 @item
   40356 If @value{GDBN} does not produce an error message for invalid input,
   40357 that is a bug.  However, you should note that your idea of
   40358 ``invalid input'' might be our idea of ``an extension'' or ``support
   40359 for traditional practice''.
   40360 
   40361 @item
   40362 If you are an experienced user of debugging tools, your suggestions
   40363 for improvement of @value{GDBN} are welcome in any case.
   40364 @end itemize
   40365 
   40366 @node Bug Reporting
   40367 @section How to Report Bugs
   40368 @cindex bug reports
   40369 @cindex @value{GDBN} bugs, reporting
   40370 
   40371 A number of companies and individuals offer support for @sc{gnu} products.
   40372 If you obtained @value{GDBN} from a support organization, we recommend you
   40373 contact that organization first.
   40374 
   40375 You can find contact information for many support companies and
   40376 individuals in the file @file{etc/SERVICE} in the @sc{gnu} Emacs
   40377 distribution.
   40378 @c should add a web page ref...
   40379 
   40380 @ifset BUGURL
   40381 @ifset BUGURL_DEFAULT
   40382 In any event, we also recommend that you submit bug reports for
   40383 @value{GDBN}.  The preferred method is to submit them directly using
   40384 @uref{http://www.gnu.org/software/gdb/bugs/, @value{GDBN}'s Bugs web
   40385 page}.  Alternatively, the @email{bug-gdb@@gnu.org, e-mail gateway} can
   40386 be used.
   40387 
   40388 @strong{Do not send bug reports to @samp{info-gdb}, or to
   40389 @samp{help-gdb}, or to any newsgroups.}  Most users of @value{GDBN} do
   40390 not want to receive bug reports.  Those that do have arranged to receive
   40391 @samp{bug-gdb}.
   40392 
   40393 The mailing list @samp{bug-gdb} has a newsgroup @samp{gnu.gdb.bug} which
   40394 serves as a repeater.  The mailing list and the newsgroup carry exactly
   40395 the same messages.  Often people think of posting bug reports to the
   40396 newsgroup instead of mailing them.  This appears to work, but it has one
   40397 problem which can be crucial: a newsgroup posting often lacks a mail
   40398 path back to the sender.  Thus, if we need to ask for more information,
   40399 we may be unable to reach you.  For this reason, it is better to send
   40400 bug reports to the mailing list.
   40401 @end ifset
   40402 @ifclear BUGURL_DEFAULT
   40403 In any event, we also recommend that you submit bug reports for
   40404 @value{GDBN} to @value{BUGURL}.
   40405 @end ifclear
   40406 @end ifset
   40407 
   40408 The fundamental principle of reporting bugs usefully is this:
   40409 @strong{report all the facts}.  If you are not sure whether to state a
   40410 fact or leave it out, state it!
   40411 
   40412 Often people omit facts because they think they know what causes the
   40413 problem and assume that some details do not matter.  Thus, you might
   40414 assume that the name of the variable you use in an example does not matter.
   40415 Well, probably it does not, but one cannot be sure.  Perhaps the bug is a
   40416 stray memory reference which happens to fetch from the location where that
   40417 name is stored in memory; perhaps, if the name were different, the contents
   40418 of that location would fool the debugger into doing the right thing despite
   40419 the bug.  Play it safe and give a specific, complete example.  That is the
   40420 easiest thing for you to do, and the most helpful.
   40421 
   40422 Keep in mind that the purpose of a bug report is to enable us to fix the
   40423 bug.  It may be that the bug has been reported previously, but neither
   40424 you nor we can know that unless your bug report is complete and
   40425 self-contained.
   40426 
   40427 Sometimes people give a few sketchy facts and ask, ``Does this ring a
   40428 bell?''  Those bug reports are useless, and we urge everyone to
   40429 @emph{refuse to respond to them} except to chide the sender to report
   40430 bugs properly.
   40431 
   40432 To enable us to fix the bug, you should include all these things:
   40433 
   40434 @itemize @bullet
   40435 @item
   40436 The version of @value{GDBN}.  @value{GDBN} announces it if you start
   40437 with no arguments; you can also print it at any time using @code{show
   40438 version}.
   40439 
   40440 Without this, we will not know whether there is any point in looking for
   40441 the bug in the current version of @value{GDBN}.
   40442 
   40443 @item
   40444 The type of machine you are using, and the operating system name and
   40445 version number.
   40446 
   40447 @item
   40448 The details of the @value{GDBN} build-time configuration.
   40449 @value{GDBN} shows these details if you invoke it with the
   40450 @option{--configuration} command-line option, or if you type
   40451 @code{show configuration} at @value{GDBN}'s prompt.
   40452 
   40453 @item
   40454 What compiler (and its version) was used to compile @value{GDBN}---e.g.@:
   40455 ``@value{GCC}--2.8.1''.
   40456 
   40457 @item
   40458 What compiler (and its version) was used to compile the program you are
   40459 debugging---e.g.@:  ``@value{GCC}--2.8.1'', or ``HP92453-01 A.10.32.03 HP
   40460 C Compiler''.  For @value{NGCC}, you can say @kbd{@value{GCC} --version}
   40461 to get this information; for other compilers, see the documentation for
   40462 those compilers.
   40463 
   40464 @item
   40465 The command arguments you gave the compiler to compile your example and
   40466 observe the bug.  For example, did you use @samp{-O}?  To guarantee
   40467 you will not omit something important, list them all.  A copy of the
   40468 Makefile (or the output from make) is sufficient.
   40469 
   40470 If we were to try to guess the arguments, we would probably guess wrong
   40471 and then we might not encounter the bug.
   40472 
   40473 @item
   40474 A complete input script, and all necessary source files, that will
   40475 reproduce the bug.
   40476 
   40477 @item
   40478 A description of what behavior you observe that you believe is
   40479 incorrect.  For example, ``It gets a fatal signal.''
   40480 
   40481 Of course, if the bug is that @value{GDBN} gets a fatal signal, then we
   40482 will certainly notice it.  But if the bug is incorrect output, we might
   40483 not notice unless it is glaringly wrong.  You might as well not give us
   40484 a chance to make a mistake.
   40485 
   40486 Even if the problem you experience is a fatal signal, you should still
   40487 say so explicitly.  Suppose something strange is going on, such as, your
   40488 copy of @value{GDBN} is out of synch, or you have encountered a bug in
   40489 the C library on your system.  (This has happened!)  Your copy might
   40490 crash and ours would not.  If you told us to expect a crash, then when
   40491 ours fails to crash, we would know that the bug was not happening for
   40492 us.  If you had not told us to expect a crash, then we would not be able
   40493 to draw any conclusion from our observations.
   40494 
   40495 @pindex script
   40496 @cindex recording a session script
   40497 To collect all this information, you can use a session recording program
   40498 such as @command{script}, which is available on many Unix systems.
   40499 Just run your @value{GDBN} session inside @command{script} and then
   40500 include the @file{typescript} file with your bug report.
   40501 
   40502 Another way to record a @value{GDBN} session is to run @value{GDBN}
   40503 inside Emacs and then save the entire buffer to a file.
   40504 
   40505 @item
   40506 If you wish to suggest changes to the @value{GDBN} source, send us context
   40507 diffs.  If you even discuss something in the @value{GDBN} source, refer to
   40508 it by context, not by line number.
   40509 
   40510 The line numbers in our development sources will not match those in your
   40511 sources.  Your line numbers would convey no useful information to us.
   40512 
   40513 @end itemize
   40514 
   40515 Here are some things that are not necessary:
   40516 
   40517 @itemize @bullet
   40518 @item
   40519 A description of the envelope of the bug.
   40520 
   40521 Often people who encounter a bug spend a lot of time investigating
   40522 which changes to the input file will make the bug go away and which
   40523 changes will not affect it.
   40524 
   40525 This is often time consuming and not very useful, because the way we
   40526 will find the bug is by running a single example under the debugger
   40527 with breakpoints, not by pure deduction from a series of examples.
   40528 We recommend that you save your time for something else.
   40529 
   40530 Of course, if you can find a simpler example to report @emph{instead}
   40531 of the original one, that is a convenience for us.  Errors in the
   40532 output will be easier to spot, running under the debugger will take
   40533 less time, and so on.
   40534 
   40535 However, simplification is not vital; if you do not want to do this,
   40536 report the bug anyway and send us the entire test case you used.
   40537 
   40538 @item
   40539 A patch for the bug.
   40540 
   40541 A patch for the bug does help us if it is a good one.  But do not omit
   40542 the necessary information, such as the test case, on the assumption that
   40543 a patch is all we need.  We might see problems with your patch and decide
   40544 to fix the problem another way, or we might not understand it at all.
   40545 
   40546 Sometimes with a program as complicated as @value{GDBN} it is very hard to
   40547 construct an example that will make the program follow a certain path
   40548 through the code.  If you do not send us the example, we will not be able
   40549 to construct one, so we will not be able to verify that the bug is fixed.
   40550 
   40551 And if we cannot understand what bug you are trying to fix, or why your
   40552 patch should be an improvement, we will not install it.  A test case will
   40553 help us to understand.
   40554 
   40555 @item
   40556 A guess about what the bug is or what it depends on.
   40557 
   40558 Such guesses are usually wrong.  Even we cannot guess right about such
   40559 things without first using the debugger to find the facts.
   40560 @end itemize
   40561 
   40562 @c The readline documentation is distributed with the readline code
   40563 @c and consists of the two following files:
   40564 @c     rluser.texi
   40565 @c     hsuser.texi
   40566 @c Use -I with makeinfo to point to the appropriate directory,
   40567 @c environment var TEXINPUTS with TeX.
   40568 @ifclear SYSTEM_READLINE
   40569 @include rluser.texi
   40570 @include hsuser.texi
   40571 @end ifclear
   40572 
   40573 @node In Memoriam
   40574 @appendix In Memoriam
   40575 
   40576 The @value{GDBN} project mourns the loss of the following long-time
   40577 contributors:
   40578 
   40579 @table @code
   40580 @item Fred Fish
   40581 Fred was a long-standing contributor to @value{GDBN} (1991-2006), and
   40582 to Free Software in general.  Outside of @value{GDBN}, he was known in
   40583 the Amiga world for his series of Fish Disks, and the GeekGadget project.
   40584 
   40585 @item Michael Snyder
   40586 Michael was one of the Global Maintainers of the @value{GDBN} project,
   40587 with contributions recorded as early as 1996, until 2011.  In addition
   40588 to his day to day participation, he was a large driving force behind
   40589 adding Reverse Debugging to @value{GDBN}.
   40590 @end table
   40591 
   40592 Beyond their technical contributions to the project, they were also
   40593 enjoyable members of the Free Software Community.  We will miss them.
   40594 
   40595 @node Formatting Documentation
   40596 @appendix Formatting Documentation
   40597 
   40598 @cindex @value{GDBN} reference card
   40599 @cindex reference card
   40600 The @value{GDBN} 4 release includes an already-formatted reference card, ready
   40601 for printing with PostScript or Ghostscript, in the @file{gdb}
   40602 subdirectory of the main source directory@footnote{In
   40603 @file{gdb-@value{GDBVN}/gdb/refcard.ps} of the version @value{GDBVN}
   40604 release.}.  If you can use PostScript or Ghostscript with your printer,
   40605 you can print the reference card immediately with @file{refcard.ps}.
   40606 
   40607 The release also includes the source for the reference card.  You
   40608 can format it, using @TeX{}, by typing:
   40609 
   40610 @smallexample
   40611 make refcard.dvi
   40612 @end smallexample
   40613 
   40614 The @value{GDBN} reference card is designed to print in @dfn{landscape}
   40615 mode on US ``letter'' size paper;
   40616 that is, on a sheet 11 inches wide by 8.5 inches
   40617 high.  You will need to specify this form of printing as an option to
   40618 your @sc{dvi} output program.
   40619 
   40620 @cindex documentation
   40621 
   40622 All the documentation for @value{GDBN} comes as part of the machine-readable
   40623 distribution.  The documentation is written in Texinfo format, which is
   40624 a documentation system that uses a single source file to produce both
   40625 on-line information and a printed manual.  You can use one of the Info
   40626 formatting commands to create the on-line version of the documentation
   40627 and @TeX{} (or @code{texi2roff}) to typeset the printed version.
   40628 
   40629 @value{GDBN} includes an already formatted copy of the on-line Info
   40630 version of this manual in the @file{gdb} subdirectory.  The main Info
   40631 file is @file{gdb-@value{GDBVN}/gdb/gdb.info}, and it refers to
   40632 subordinate files matching @samp{gdb.info*} in the same directory.  If
   40633 necessary, you can print out these files, or read them with any editor;
   40634 but they are easier to read using the @code{info} subsystem in @sc{gnu}
   40635 Emacs or the standalone @code{info} program, available as part of the
   40636 @sc{gnu} Texinfo distribution.
   40637 
   40638 If you want to format these Info files yourself, you need one of the
   40639 Info formatting programs, such as @code{texinfo-format-buffer} or
   40640 @code{makeinfo}.
   40641 
   40642 If you have @code{makeinfo} installed, and are in the top level
   40643 @value{GDBN} source directory (@file{gdb-@value{GDBVN}}, in the case of
   40644 version @value{GDBVN}), you can make the Info file by typing:
   40645 
   40646 @smallexample
   40647 cd gdb
   40648 make gdb.info
   40649 @end smallexample
   40650 
   40651 If you want to typeset and print copies of this manual, you need @TeX{},
   40652 a program to print its @sc{dvi} output files, and @file{texinfo.tex}, the
   40653 Texinfo definitions file.
   40654 
   40655 @TeX{} is a typesetting program; it does not print files directly, but
   40656 produces output files called @sc{dvi} files.  To print a typeset
   40657 document, you need a program to print @sc{dvi} files.  If your system
   40658 has @TeX{} installed, chances are it has such a program.  The precise
   40659 command to use depends on your system; @kbd{lpr -d} is common; another
   40660 (for PostScript devices) is @kbd{dvips}.  The @sc{dvi} print command may
   40661 require a file name without any extension or a @samp{.dvi} extension.
   40662 
   40663 @TeX{} also requires a macro definitions file called
   40664 @file{texinfo.tex}.  This file tells @TeX{} how to typeset a document
   40665 written in Texinfo format.  On its own, @TeX{} cannot either read or
   40666 typeset a Texinfo file.  @file{texinfo.tex} is distributed with GDB
   40667 and is located in the @file{gdb-@var{version-number}/texinfo}
   40668 directory.
   40669 
   40670 If you have @TeX{} and a @sc{dvi} printer program installed, you can
   40671 typeset and print this manual.  First switch to the @file{gdb}
   40672 subdirectory of the main source directory (for example, to
   40673 @file{gdb-@value{GDBVN}/gdb}) and type:
   40674 
   40675 @smallexample
   40676 make gdb.dvi
   40677 @end smallexample
   40678 
   40679 Then give @file{gdb.dvi} to your @sc{dvi} printing program.
   40680 
   40681 @node Installing GDB
   40682 @appendix Installing @value{GDBN}
   40683 @cindex installation
   40684 
   40685 @menu
   40686 * Requirements::                Requirements for building @value{GDBN}
   40687 * Running Configure::           Invoking the @value{GDBN} @file{configure} script
   40688 * Separate Objdir::             Compiling @value{GDBN} in another directory
   40689 * Config Names::                Specifying names for hosts and targets
   40690 * Configure Options::           Summary of options for configure
   40691 * System-wide configuration::   Having a system-wide init file
   40692 @end menu
   40693 
   40694 @node Requirements
   40695 @section Requirements for Building @value{GDBN}
   40696 @cindex building @value{GDBN}, requirements for
   40697 
   40698 Building @value{GDBN} requires various tools and packages to be available.
   40699 Other packages will be used only if they are found.
   40700 
   40701 @heading Tools/Packages Necessary for Building @value{GDBN}
   40702 @table @asis
   40703 @item C@t{++}17 compiler
   40704 @value{GDBN} is written in C@t{++}17.  It should be buildable with any
   40705 recent C@t{++}17 compiler, e.g.@: GCC.
   40706 
   40707 @item GNU make
   40708 @value{GDBN}'s build system relies on features only found in the GNU
   40709 make program.  Other variants of @code{make} will not work.
   40710 
   40711 @item Libraries
   40712 The following libraries are mandatory for building @value{GDBN}.  The
   40713 @file{configure} script searches for each of these libraries in
   40714 several standard locations; if some library is installed in an unusual
   40715 place, you can use either the @option{--with-@var{lib}}
   40716 @file{configure} option to specify its installation directory, or
   40717 the two separate options @option{---with-@var{library}-include} (to
   40718 specify the location of its header files) and
   40719 @option{--with-@var{library}-lib} (to specify the location of its
   40720 libraries).  For example, for the GMP library, the 3 options are
   40721 @option{--with-gmp}, @option{--with-gmp-include}, and
   40722 @option{--with-gmp-lib}.  @xref{Configure Options}.  We mention below
   40723 the home site of each library, so that you could download and install
   40724 them if your system doesn't already include them.
   40725 
   40726 @table @asis
   40727 @item GMP (The GNU Multiple Precision arithmetic library)
   40728 @value{GDBN} uses GMP to perform some of its extended-precision
   40729 arithmetic.  The latest version of GMP is available from
   40730 @url{https://gmplib.org/}.
   40731 
   40732 @anchor{MPFR}
   40733 @item MPFR (The GNU Multiple-precision floating-point library)
   40734 @value{GDBN} uses MPFR to emulate the target floating-point
   40735 arithmetic during expression evaluation, if the target uses different
   40736 floating-point formats than the host.  The latest version of MPFR is
   40737 available from @url{http://www.mpfr.org}.
   40738 @end table
   40739 
   40740 @end table
   40741 
   40742 @heading Tools/Packages Optional for Building @value{GDBN}
   40743 The tools/packages and libraries listed below are optional;
   40744 @value{GDBN} can be build without them, at the expense of some run-time
   40745 functionality that will be missing.  As above, we list the home sites
   40746 for each package/library, and the command-line options supported by
   40747 the @file{configure} script to specify their installation directories
   40748 if they are non-standard.  In addition, for each package you can use
   40749 the option @option{--with-@var{package}} to force @value{GDBN} to be
   40750 compiled with the named @var{package}, and
   40751 @option{--without-@var{package}} to disable building with it even if
   40752 it is available.  @xref{Configure Options}, for detailed description
   40753 of the options to @file{configure}.
   40754 
   40755 @table @asis
   40756 @item Python
   40757 @value{GDBN} can be scripted using Python language.  @xref{Python}.
   40758 The latest version is available from
   40759 @url{https://www.python.org/downloads/}.  Use the
   40760 @option{--with-python=@var{dir}} to specify the non-standard directory
   40761 where Python is installed.
   40762 
   40763 @item Guile
   40764 @value{GDBN} can also be scripted using GNU Guile.  @xref{Guile}.  The
   40765 latest version can be found on
   40766 @url{https://www.gnu.org/software/guile/download/}.  If you have more
   40767 than one version of Guile installed, use the
   40768 @option{--with-guile=@var{guile-version}} to specify the Guile version
   40769 to include in the build.
   40770 
   40771 @anchor{Expat}
   40772 @item Expat
   40773 If available, @value{GDBN} uses the Expat library for parsing XML
   40774 files.  @value{GDBN} uses XML files for the following functionalities:
   40775 
   40776 @itemize @bullet
   40777 @item
   40778 Remote protocol memory maps (@pxref{Memory Map Format})
   40779 @item
   40780 Target descriptions (@pxref{Target Descriptions})
   40781 @item
   40782 Remote shared library lists (@xref{Library List Format},
   40783 or alternatively @pxref{Library List Format for SVR4 Targets})
   40784 @item
   40785 MS-Windows shared libraries (@pxref{Shared Libraries})
   40786 @item
   40787 Traceframe info (@pxref{Traceframe Info Format})
   40788 @item
   40789 Branch trace (@pxref{Branch Trace Format},
   40790 @pxref{Branch Trace Configuration Format})
   40791 @end itemize
   40792 
   40793 The latest version of Expat is available from
   40794 @url{http://expat.sourceforge.net}.  Use the
   40795 @option{--with-libexpat-prefix} to specify non-standard installation
   40796 places for Expat.
   40797 
   40798 @item iconv
   40799 @value{GDBN}'s features related to character sets (@pxref{Character
   40800 Sets}) require a functioning @code{iconv} implementation.  If you are
   40801 on a GNU system, then this is provided by the GNU C Library.  Some
   40802 other systems also provide a working @code{iconv}.  Use the option
   40803 @option{--with-iconv-bin} to specify where to find the @command{iconv}
   40804 program.
   40805 
   40806 On systems without @code{iconv}, you can install the GNU Libiconv
   40807 library; its latest version can be found on
   40808 @url{https://ftp.gnu.org/pub/gnu/libiconv/} if your system doesn't
   40809 provide it.  Use the @option{--with-libiconv-prefix} option to
   40810 @file{configure} to specify non-standard installation place for it.
   40811 
   40812 Alternatively, @value{GDBN}'s top-level @file{configure} and
   40813 @file{Makefile} will arrange to build Libiconv if a directory named
   40814 @file{libiconv} appears in the top-most source directory.  If Libiconv
   40815 is built this way, and if the operating system does not provide a
   40816 suitable @code{iconv} implementation, then the just-built library will
   40817 automatically be used by @value{GDBN}.  One easy way to set this up is
   40818 to download GNU Libiconv, unpack it inside the top-level directory of
   40819 the @value{GDBN} source tree, and then rename the directory holding
   40820 the Libiconv source code to @samp{libiconv}.
   40821 
   40822 @cindex compressed debug sections
   40823 @item lzma
   40824 @value{GDBN} can support debugging sections that are compressed with
   40825 the LZMA library.  @xref{MiniDebugInfo}.  If this library is not
   40826 included with your operating system, you can find it in the xz package
   40827 at @url{http://tukaani.org/xz/}.  Use the
   40828 @option{--with-liblzma-prefix} option to specify its non-standard
   40829 location.
   40830 
   40831 @item zlib
   40832 @value{GDBN} will use the @samp{zlib} library, if available, to read
   40833 compressed debug sections.  Some linkers, such as GNU @command{gold},
   40834 are capable of producing binaries with compressed debug sections.  If
   40835 @value{GDBN} is compiled with @samp{zlib}, it will be able to read the
   40836 debug information in such binaries.
   40837 
   40838 The @samp{zlib} library is likely included with your operating system
   40839 distribution; if it is not, you can get the latest version from
   40840 @url{http://zlib.net}.
   40841 
   40842 @c FIXME: what about other optional libraries: debuginfod, zstd,
   40843 @c libipt, babeltrace, xxhash, source-highlight?
   40844 @end table
   40845 
   40846 @node Running Configure
   40847 @section Invoking the @value{GDBN} @file{configure} Script
   40848 @cindex configuring @value{GDBN}
   40849 @value{GDBN} comes with a @file{configure} script that automates the process
   40850 of preparing @value{GDBN} for installation; you can then use @code{make} to
   40851 build the @code{gdb} program.
   40852 @iftex
   40853 @c irrelevant in info file; it's as current as the code it lives with.
   40854 @footnote{If you have a more recent version of @value{GDBN} than @value{GDBVN},
   40855 look at the @file{README} file in the sources; we may have improved the
   40856 installation procedures since publishing this manual.}
   40857 @end iftex
   40858 
   40859 The @value{GDBN} distribution includes all the source code you need for
   40860 @value{GDBN} in a single directory, whose name is usually composed by
   40861 appending the version number to @samp{gdb}.
   40862 
   40863 For example, the @value{GDBN} version @value{GDBVN} distribution is in the
   40864 @file{gdb-@value{GDBVN}} directory.  That directory contains:
   40865 
   40866 @table @code
   40867 @item gdb-@value{GDBVN}/configure @r{(and supporting files)}
   40868 script for configuring @value{GDBN} and all its supporting libraries
   40869 
   40870 @item gdb-@value{GDBVN}/gdb
   40871 the source specific to @value{GDBN} itself
   40872 
   40873 @item gdb-@value{GDBVN}/bfd
   40874 source for the Binary File Descriptor library
   40875 
   40876 @item gdb-@value{GDBVN}/include
   40877 @sc{gnu} include files
   40878 
   40879 @item gdb-@value{GDBVN}/libiberty
   40880 source for the @samp{-liberty} free software library
   40881 
   40882 @item gdb-@value{GDBVN}/opcodes
   40883 source for the library of opcode tables and disassemblers
   40884 
   40885 @item gdb-@value{GDBVN}/readline
   40886 source for the @sc{gnu} command-line interface
   40887 @end table
   40888 
   40889 There may be other subdirectories as well.
   40890 
   40891 The simplest way to configure and build @value{GDBN} is to run @file{configure}
   40892 from the @file{gdb-@var{version-number}} source directory, which in
   40893 this example is the @file{gdb-@value{GDBVN}} directory.
   40894 
   40895 First switch to the @file{gdb-@var{version-number}} source directory
   40896 if you are not already in it; then run @file{configure}.  Pass the
   40897 identifier for the platform on which @value{GDBN} will run as an
   40898 argument.
   40899 
   40900 For example:
   40901 
   40902 @smallexample
   40903 cd gdb-@value{GDBVN}
   40904 ./configure
   40905 make
   40906 @end smallexample
   40907 
   40908 Running @samp{configure} and then running @code{make} builds the
   40909 included supporting libraries, then @code{gdb} itself.  The configured
   40910 source files, and the binaries, are left in the corresponding source
   40911 directories.
   40912 
   40913 @need 750
   40914 @file{configure} is a Bourne-shell (@code{/bin/sh}) script; if your
   40915 system does not recognize this automatically when you run a different
   40916 shell, you may need to run @code{sh} on it explicitly:
   40917 
   40918 @smallexample
   40919 sh configure
   40920 @end smallexample
   40921 
   40922 You should run the @file{configure} script from the top directory in the
   40923 source tree, the @file{gdb-@var{version-number}} directory.  If you run
   40924 @file{configure} from one of the subdirectories, you will configure only
   40925 that subdirectory.  That is usually not what you want.  In particular,
   40926 if you run the first @file{configure} from the @file{gdb} subdirectory
   40927 of the @file{gdb-@var{version-number}} directory, you will omit the
   40928 configuration of @file{bfd}, @file{readline}, and other sibling
   40929 directories of the @file{gdb} subdirectory.  This leads to build errors
   40930 about missing include files such as @file{bfd/bfd.h}.
   40931 
   40932 You can install @code{@value{GDBN}} anywhere.  The best way to do this
   40933 is to pass the @code{--prefix} option to @code{configure}, and then
   40934 install it with @code{make install}.
   40935 
   40936 @node Separate Objdir
   40937 @section Compiling @value{GDBN} in Another Directory
   40938 
   40939 If you want to run @value{GDBN} versions for several host or target machines,
   40940 you need a different @code{gdb} compiled for each combination of
   40941 host and target.  @file{configure} is designed to make this easy by
   40942 allowing you to generate each configuration in a separate subdirectory,
   40943 rather than in the source directory.  If your @code{make} program
   40944 handles the @samp{VPATH} feature (@sc{gnu} @code{make} does), running
   40945 @code{make} in each of these directories builds the @code{gdb}
   40946 program specified there.
   40947 
   40948 To build @code{gdb} in a separate directory, run @file{configure}
   40949 with the @samp{--srcdir} option to specify where to find the source.
   40950 (You also need to specify a path to find @file{configure}
   40951 itself from your working directory.  If the path to @file{configure}
   40952 would be the same as the argument to @samp{--srcdir}, you can leave out
   40953 the @samp{--srcdir} option; it is assumed.)
   40954 
   40955 For example, with version @value{GDBVN}, you can build @value{GDBN} in a
   40956 separate directory for a Sun 4 like this:
   40957 
   40958 @smallexample
   40959 @group
   40960 cd gdb-@value{GDBVN}
   40961 mkdir ../gdb-sun4
   40962 cd ../gdb-sun4
   40963 ../gdb-@value{GDBVN}/configure
   40964 make
   40965 @end group
   40966 @end smallexample
   40967 
   40968 When @file{configure} builds a configuration using a remote source
   40969 directory, it creates a tree for the binaries with the same structure
   40970 (and using the same names) as the tree under the source directory.  In
   40971 the example, you'd find the Sun 4 library @file{libiberty.a} in the
   40972 directory @file{gdb-sun4/libiberty}, and @value{GDBN} itself in
   40973 @file{gdb-sun4/gdb}.
   40974 
   40975 Make sure that your path to the @file{configure} script has just one
   40976 instance of @file{gdb} in it.  If your path to @file{configure} looks
   40977 like @file{../gdb-@value{GDBVN}/gdb/configure}, you are configuring only
   40978 one subdirectory of @value{GDBN}, not the whole package.  This leads to
   40979 build errors about missing include files such as @file{bfd/bfd.h}.
   40980 
   40981 One popular reason to build several @value{GDBN} configurations in separate
   40982 directories is to configure @value{GDBN} for cross-compiling (where
   40983 @value{GDBN} runs on one machine---the @dfn{host}---while debugging
   40984 programs that run on another machine---the @dfn{target}).
   40985 You specify a cross-debugging target by
   40986 giving the @samp{--target=@var{target}} option to @file{configure}.
   40987 
   40988 When you run @code{make} to build a program or library, you must run
   40989 it in a configured directory---whatever directory you were in when you
   40990 called @file{configure} (or one of its subdirectories).
   40991 
   40992 The @code{Makefile} that @file{configure} generates in each source
   40993 directory also runs recursively.  If you type @code{make} in a source
   40994 directory such as @file{gdb-@value{GDBVN}} (or in a separate configured
   40995 directory configured with @samp{--srcdir=@var{dirname}/gdb-@value{GDBVN}}), you
   40996 will build all the required libraries, and then build GDB.
   40997 
   40998 When you have multiple hosts or targets configured in separate
   40999 directories, you can run @code{make} on them in parallel (for example,
   41000 if they are NFS-mounted on each of the hosts); they will not interfere
   41001 with each other.
   41002 
   41003 @node Config Names
   41004 @section Specifying Names for Hosts and Targets
   41005 
   41006 The specifications used for hosts and targets in the @file{configure}
   41007 script are based on a three-part naming scheme, but some short predefined
   41008 aliases are also supported.  The full naming scheme encodes three pieces
   41009 of information in the following pattern:
   41010 
   41011 @smallexample
   41012 @var{architecture}-@var{vendor}-@var{os}
   41013 @end smallexample
   41014 
   41015 For example, you can use the alias @code{sun4} as a @var{host} argument,
   41016 or as the value for @var{target} in a @code{--target=@var{target}}
   41017 option.  The equivalent full name is @samp{sparc-sun-sunos4}.
   41018 
   41019 The @file{configure} script accompanying @value{GDBN} does not provide
   41020 any query facility to list all supported host and target names or
   41021 aliases.  @file{configure} calls the Bourne shell script
   41022 @code{config.sub} to map abbreviations to full names; you can read the
   41023 script, if you wish, or you can use it to test your guesses on
   41024 abbreviations---for example:
   41025 
   41026 @smallexample
   41027 % sh config.sub i386-linux
   41028 i386-pc-linux-gnu
   41029 % sh config.sub alpha-linux
   41030 alpha-unknown-linux-gnu
   41031 % sh config.sub hp9k700
   41032 hppa1.1-hp-hpux
   41033 % sh config.sub sun4
   41034 sparc-sun-sunos4.1.1
   41035 % sh config.sub sun3
   41036 m68k-sun-sunos4.1.1
   41037 % sh config.sub i986v
   41038 Invalid configuration `i986v': machine `i986v' not recognized
   41039 @end smallexample
   41040 
   41041 @noindent
   41042 @code{config.sub} is also distributed in the @value{GDBN} source
   41043 directory (@file{gdb-@value{GDBVN}}, for version @value{GDBVN}).
   41044 
   41045 @node Configure Options
   41046 @section @file{configure} Options
   41047 
   41048 @c FIXME: This largely repeats what was already described in
   41049 @c ``Requirements'', and OTOH doesn't describe the more fgine-granular
   41050 @c options like --with-libexpat-prefix and --with-python-libdir.
   41051 @c Should it?
   41052 Here is a summary of the @file{configure} options and arguments that
   41053 are most often useful for building @value{GDBN}.  @file{configure}
   41054 also has several other options not listed here.  @xref{Running
   41055 configure Scripts,,,autoconf}, for a full
   41056 explanation of @file{configure}.
   41057 
   41058 @smallexample
   41059 configure @r{[}--help@r{]}
   41060           @r{[}--prefix=@var{dir}@r{]}
   41061           @r{[}--exec-prefix=@var{dir}@r{]}
   41062           @r{[}--srcdir=@var{dirname}@r{]}
   41063           @r{[}--target=@var{target}@r{]}
   41064 @end smallexample
   41065 
   41066 @noindent
   41067 You may introduce options with a single @samp{-} rather than
   41068 @samp{--} if you prefer; but you may abbreviate option names if you use
   41069 @samp{--}.
   41070 
   41071 @table @code
   41072 @item --help
   41073 Display a quick summary of how to invoke @file{configure}.
   41074 
   41075 @item --prefix=@var{dir}
   41076 Configure the source to install programs and files under directory
   41077 @file{@var{dir}}.
   41078 
   41079 @item --exec-prefix=@var{dir}
   41080 Configure the source to install programs under directory
   41081 @file{@var{dir}}.
   41082 
   41083 @c avoid splitting the warning from the explanation:
   41084 @need 2000
   41085 @item --srcdir=@var{dirname}
   41086 Use this option to make configurations in directories separate from the
   41087 @value{GDBN} source directories.  Among other things, you can use this to
   41088 build (or maintain) several configurations simultaneously, in separate
   41089 directories.  @file{configure} writes configuration-specific files in
   41090 the current directory, but arranges for them to use the source in the
   41091 directory @var{dirname}.  @file{configure} creates directories under
   41092 the working directory in parallel to the source directories below
   41093 @var{dirname}.
   41094 
   41095 @item --target=@var{target}
   41096 Configure @value{GDBN} for cross-debugging programs running on the specified
   41097 @var{target}.  Without this option, @value{GDBN} is configured to debug
   41098 programs that run on the same machine (@var{host}) as @value{GDBN} itself.
   41099 
   41100 There is no convenient way to generate a list of all available
   41101 targets.  Also see the @code{--enable-targets} option, below.
   41102 @end table
   41103 
   41104 There are many other options that are specific to @value{GDBN}.  This
   41105 lists just the most common ones; there are some very specialized
   41106 options not described here.
   41107 
   41108 @table @code
   41109 @item --enable-targets=@r{[}@var{target}@r{]}@dots{}
   41110 @itemx --enable-targets=all
   41111 Configure @value{GDBN} for cross-debugging programs running on the
   41112 specified list of targets.  The special value @samp{all} configures
   41113 @value{GDBN} for debugging programs running on any target it supports.
   41114 
   41115 @item --with-gdb-datadir=@var{path}
   41116 Set the @value{GDBN}-specific data directory.  @value{GDBN} will look
   41117 here for certain supporting files or scripts.  This defaults to the
   41118 @file{gdb} subdirectory of @samp{datadir} (which can be set using
   41119 @code{--datadir}).
   41120 
   41121 @item --with-relocated-sources=@var{dir}
   41122 Sets up the default source path substitution rule so that directory
   41123 names recorded in debug information will be automatically adjusted for
   41124 any directory under @var{dir}.  @var{dir} should be a subdirectory of
   41125 @value{GDBN}'s configured prefix, the one mentioned in the
   41126 @code{--prefix} or @code{--exec-prefix} options to configure.  This
   41127 option is useful if GDB is supposed to be moved to a different place
   41128 after it is built.
   41129 
   41130 @item --enable-64-bit-bfd
   41131 Enable 64-bit support in BFD on 32-bit hosts.
   41132 
   41133 @item --disable-gdbmi
   41134 Build @value{GDBN} without the GDB/MI machine interface
   41135 (@pxref{GDB/MI}).
   41136 
   41137 @item --enable-tui
   41138 Build @value{GDBN} with the text-mode full-screen user interface
   41139 (TUI).  Requires a curses library (ncurses and cursesX are also
   41140 supported).
   41141 
   41142 @item --with-curses
   41143 Use the curses library instead of the termcap library, for text-mode
   41144 terminal operations.
   41145 
   41146 @item --with-debuginfod
   41147 Build @value{GDBN} with @file{libdebuginfod}, the @code{debuginfod} client
   41148 library.  Used to automatically fetch ELF, DWARF and source files from
   41149 @code{debuginfod} servers using build IDs associated with any missing
   41150 files.  Enabled by default if @file{libdebuginfod} is installed and found
   41151 at configure time.  For more information regarding @code{debuginfod} see
   41152 @ref{Debuginfod}.
   41153 
   41154 @item --with-libunwind-ia64
   41155 Use the libunwind library for unwinding function call stack on ia64
   41156 target platforms.  See @url{http://www.nongnu.org/libunwind/index.html} for
   41157 details.
   41158 
   41159 @item --with-system-readline
   41160 Use the readline library installed on the host, rather than the
   41161 library supplied as part of @value{GDBN}.  Readline 7 or newer is
   41162 required; this is enforced by the build system.
   41163 
   41164 @item --with-system-zlib
   41165 Use the zlib library installed on the host, rather than the library
   41166 supplied as part of @value{GDBN}.
   41167 
   41168 @item --with-expat
   41169 Build @value{GDBN} with Expat, a library for XML parsing.  (Done by
   41170 default if libexpat is installed and found at configure time.)  This
   41171 library is used to read XML files supplied with @value{GDBN}.  If it
   41172 is unavailable, some features, such as remote protocol memory maps,
   41173 target descriptions, and shared library lists, that are based on XML
   41174 files, will not be available in @value{GDBN}.  If your host does not
   41175 have libexpat installed, you can get the latest version from
   41176 @url{http://expat.sourceforge.net}.
   41177 
   41178 @item --with-libiconv-prefix@r{[}=@var{dir}@r{]}
   41179 Build @value{GDBN} with GNU libiconv, a character set encoding
   41180 conversion library.  This is not done by default, as on GNU systems
   41181 the @code{iconv} that is built in to the C library is sufficient.  If
   41182 your host does not have a working @code{iconv}, you can get the latest
   41183 version of GNU iconv from @url{https://www.gnu.org/software/libiconv/}.
   41184 
   41185 @value{GDBN}'s build system also supports building GNU libiconv as
   41186 part of the overall build.   @xref{Requirements}.
   41187 
   41188 @item --with-lzma
   41189 Build @value{GDBN} with LZMA, a compression library.  (Done by default
   41190 if liblzma is installed and found at configure time.)  LZMA is used by
   41191 @value{GDBN}'s "mini debuginfo" feature, which is only useful on
   41192 platforms using the ELF object file format.  If your host does not
   41193 have liblzma installed, you can get the latest version from
   41194 @url{https://tukaani.org/xz/}.
   41195 
   41196 @item --with-python@r{[}=@var{python}@r{]}
   41197 Build @value{GDBN} with Python scripting support.  (Done by default if
   41198 libpython is present and found at configure time.)  Python makes
   41199 @value{GDBN} scripting much more powerful than the restricted CLI
   41200 scripting language.  If your host does not have Python installed, you
   41201 can find it on @url{http://www.python.org/download/}.  The oldest version
   41202 of Python supported by GDB is 3.0.1.  The optional argument @var{python}
   41203 is used to find the Python headers and libraries.  It can be either
   41204 the name of a Python executable, or the name of the directory in which
   41205 Python is installed.
   41206 
   41207 @item --with-guile[=@var{guile}]
   41208 Build @value{GDBN} with GNU Guile scripting support.  (Done by default
   41209 if libguile is present and found at configure time.)  If your host
   41210 does not have Guile installed, you can find it at
   41211 @url{https://www.gnu.org/software/guile/}.  The optional argument @var{guile}
   41212 can be a version number, which will cause @code{configure} to try to
   41213 use that version of Guile; or the file name of a @code{pkg-config}
   41214 executable, which will be queried to find the information needed to
   41215 compile and link against Guile.
   41216 
   41217 @item --without-included-regex
   41218 Don't use the regex library included with @value{GDBN} (as part of the
   41219 libiberty library).  This is the default on hosts with version 2 of
   41220 the GNU C library.
   41221 
   41222 @item --with-sysroot=@var{dir}
   41223 Use @var{dir} as the default system root directory for libraries whose
   41224 file names begin with @file{/lib}' or @file{/usr/lib'}.  (The value of
   41225 @var{dir} can be modified at run time by using the @command{set
   41226 sysroot} command.)  If @var{dir} is under the @value{GDBN} configured
   41227 prefix (set with @code{--prefix} or @code{--exec-prefix options}, the
   41228 default system root will be automatically adjusted if and when
   41229 @value{GDBN} is moved to a different location.
   41230 
   41231 @item --with-system-gdbinit=@var{file}
   41232 Configure @value{GDBN} to automatically load a system-wide init file.
   41233 @var{file} should be an absolute file name.  If @var{file} is in a
   41234 directory under the configured prefix, and @value{GDBN} is moved to
   41235 another location after being built, the location of the system-wide
   41236 init file will be adjusted accordingly.
   41237 
   41238 @item --with-system-gdbinit-dir=@var{directory}
   41239 Configure @value{GDBN} to automatically load init files from a
   41240 system-wide directory.  @var{directory} should be an absolute directory
   41241 name.  If @var{directory} is in a directory under the configured
   41242 prefix, and @value{GDBN} is moved to another location after being
   41243 built, the location of the system-wide init directory will be
   41244 adjusted accordingly.
   41245 
   41246 @item --enable-build-warnings
   41247 When building the @value{GDBN} sources, ask the compiler to warn about
   41248 any code which looks even vaguely suspicious.  It passes many
   41249 different warning flags, depending on the exact version of the
   41250 compiler you are using.
   41251 
   41252 @item --enable-werror
   41253 Treat compiler warnings as errors.  It adds the @code{-Werror} flag
   41254 to the compiler, which will fail the compilation if the compiler
   41255 outputs any warning messages.
   41256 
   41257 @item --enable-ubsan
   41258 Enable the GCC undefined behavior sanitizer.  This is disabled by
   41259 default, but passing @code{--enable-ubsan=yes} or
   41260 @code{--enable-ubsan=auto} to @code{configure} will enable it.  The
   41261 undefined behavior sanitizer checks for C@t{++} undefined behavior.
   41262 It has a performance cost, so if you are looking at @value{GDBN}'s
   41263 performance, you should disable it.  The undefined behavior sanitizer
   41264 was first introduced in GCC 4.9.
   41265 @end table
   41266 
   41267 @node System-wide configuration
   41268 @section System-wide configuration and settings
   41269 @cindex system-wide init file
   41270 
   41271 @value{GDBN} can be configured to have a system-wide init file and a
   41272 system-wide init file directory; this file and files in that directory
   41273 (if they have a recognized file extension) will be read and executed at
   41274 startup (@pxref{Startup, , What @value{GDBN} does during startup}).
   41275 
   41276 Here are the corresponding configure options:
   41277 
   41278 @table @code
   41279 @item --with-system-gdbinit=@var{file}
   41280 Specify that the default location of the system-wide init file is
   41281 @var{file}.
   41282 @item --with-system-gdbinit-dir=@var{directory}
   41283 Specify that the default location of the system-wide init file directory
   41284 is @var{directory}.
   41285 @end table
   41286 
   41287 If @value{GDBN} has been configured with the option @option{--prefix=$prefix},
   41288 they may be subject to relocation.  Two possible cases:
   41289 
   41290 @itemize @bullet
   41291 @item 
   41292 If the default location of this init file/directory contains @file{$prefix},
   41293 it will be subject to relocation.  Suppose that the configure options
   41294 are @option{--prefix=$prefix --with-system-gdbinit=$prefix/etc/gdbinit};
   41295 if @value{GDBN} is moved from @file{$prefix} to @file{$install}, the system
   41296 init file is looked for as @file{$install/etc/gdbinit} instead of
   41297 @file{$prefix/etc/gdbinit}.
   41298 
   41299 @item
   41300 By contrast, if the default location does not contain the prefix,
   41301 it will not be relocated.  E.g.@: if @value{GDBN} has been configured with
   41302 @option{--prefix=/usr/local --with-system-gdbinit=/usr/share/gdb/gdbinit},
   41303 then @value{GDBN} will always look for @file{/usr/share/gdb/gdbinit},
   41304 wherever @value{GDBN} is installed.
   41305 @end itemize
   41306 
   41307 If the configured location of the system-wide init file (as given by the
   41308 @option{--with-system-gdbinit} option at configure time) is in the
   41309 data-directory (as specified by @option{--with-gdb-datadir} at configure
   41310 time) or in one of its subdirectories, then @value{GDBN} will look for the
   41311 system-wide init file in the directory specified by the
   41312 @option{--data-directory} command-line option.
   41313 Note that the system-wide init file is only read once, during @value{GDBN}
   41314 initialization.  If the data-directory is changed after @value{GDBN} has
   41315 started with the @code{set data-directory} command, the file will not be
   41316 reread.
   41317 
   41318 This applies similarly to the system-wide directory specified in
   41319 @option{--with-system-gdbinit-dir}.
   41320 
   41321 Any supported scripting language can be used for these init files, as long
   41322 as the file extension matches the scripting language.  To be interpreted
   41323 as regular @value{GDBN} commands, the files needs to have a @file{.gdb}
   41324 extension.
   41325 
   41326 @menu
   41327 * System-wide Configuration Scripts::  Installed System-wide Configuration Scripts
   41328 @end menu
   41329 
   41330 @node System-wide Configuration Scripts
   41331 @subsection Installed System-wide Configuration Scripts
   41332 @cindex system-wide configuration scripts
   41333 
   41334 The @file{system-gdbinit} directory, located inside the data-directory
   41335 (as specified by @option{--with-gdb-datadir} at configure time) contains
   41336 a number of scripts which can be used as system-wide init files.  To
   41337 automatically source those scripts at startup, @value{GDBN} should be
   41338 configured with @option{--with-system-gdbinit}.  Otherwise, any user
   41339 should be able to source them by hand as needed.
   41340 
   41341 The following scripts are currently available:
   41342 @itemize @bullet
   41343 
   41344 @item @file{elinos.py}
   41345 @pindex elinos.py
   41346 @cindex ELinOS system-wide configuration script
   41347 This script is useful when debugging a program on an ELinOS target.
   41348 It takes advantage of the environment variables defined in a standard
   41349 ELinOS environment in order to determine the location of the system
   41350 shared libraries, and then sets the @samp{solib-absolute-prefix}
   41351 and @samp{solib-search-path} variables appropriately.
   41352 
   41353 @item @file{wrs-linux.py}
   41354 @pindex wrs-linux.py
   41355 @cindex Wind River Linux system-wide configuration script
   41356 This script is useful when debugging a program on a target running
   41357 Wind River Linux.  It expects the @env{ENV_PREFIX} to be set to
   41358 the host-side sysroot used by the target system.
   41359 
   41360 @end itemize
   41361 
   41362 @node Maintenance Commands
   41363 @appendix Maintenance Commands
   41364 @cindex maintenance commands
   41365 @cindex internal commands
   41366 
   41367 In addition to commands intended for @value{GDBN} users, @value{GDBN}
   41368 includes a number of commands intended for @value{GDBN} developers,
   41369 that are not documented elsewhere in this manual.  These commands are
   41370 provided here for reference.  (For commands that turn on debugging
   41371 messages, see @ref{Debugging Output}.)
   41372 
   41373 @table @code
   41374 @kindex maint agent
   41375 @kindex maint agent-eval
   41376 @item maint agent @r{[}-at @var{linespec}@r{,}@r{]} @var{expression}
   41377 @itemx maint agent-eval @r{[}-at @var{linespec}@r{,}@r{]} @var{expression}
   41378 Translate the given @var{expression} into remote agent bytecodes.
   41379 This command is useful for debugging the Agent Expression mechanism
   41380 (@pxref{Agent Expressions}).  The @samp{agent} version produces an
   41381 expression useful for data collection, such as by tracepoints, while
   41382 @samp{maint agent-eval} produces an expression that evaluates directly
   41383 to a result.  For instance, a collection expression for @code{globa +
   41384 globb} will include bytecodes to record four bytes of memory at each
   41385 of the addresses of @code{globa} and @code{globb}, while discarding
   41386 the result of the addition, while an evaluation expression will do the
   41387 addition and return the sum.
   41388 If @code{-at} is given, generate remote agent bytecode for all the
   41389 addresses to which @var{linespec} resolves (@pxref{Linespec
   41390 Locations}).
   41391 If not, generate remote agent bytecode for current frame PC address.
   41392 
   41393 @kindex maint agent-printf
   41394 @item maint agent-printf @var{format},@var{expr},...
   41395 Translate the given format string and list of argument expressions
   41396 into remote agent bytecodes and display them as a disassembled list.
   41397 This command is useful for debugging the agent version of dynamic
   41398 printf (@pxref{Dynamic Printf}).
   41399 
   41400 @kindex maint info breakpoints
   41401 @anchor{maint info breakpoints}
   41402 @item maint info breakpoints
   41403 Using the same format as @samp{info breakpoints}, display both the
   41404 breakpoints you've set explicitly, and those @value{GDBN} is using for
   41405 internal purposes.  Internal breakpoints are shown with negative
   41406 breakpoint numbers.  The type column identifies what kind of breakpoint
   41407 is shown:
   41408 
   41409 @table @code
   41410 @item breakpoint
   41411 Normal, explicitly set breakpoint.
   41412 
   41413 @item watchpoint
   41414 Normal, explicitly set watchpoint.
   41415 
   41416 @item longjmp
   41417 Internal breakpoint, used to handle correctly stepping through
   41418 @code{longjmp} calls.
   41419 
   41420 @item longjmp resume
   41421 Internal breakpoint at the target of a @code{longjmp}.
   41422 
   41423 @item until
   41424 Temporary internal breakpoint used by the @value{GDBN} @code{until} command.
   41425 
   41426 @item finish
   41427 Temporary internal breakpoint used by the @value{GDBN} @code{finish} command.
   41428 
   41429 @item shlib events
   41430 Shared library events.
   41431 
   41432 @end table
   41433 
   41434 @kindex maint info btrace
   41435 @item maint info btrace
   41436 Pint information about raw branch tracing data.
   41437 
   41438 @kindex maint btrace packet-history
   41439 @item maint btrace packet-history
   41440 Print the raw branch trace packets that are used to compute the
   41441 execution history for the @samp{record btrace} command.  Both the
   41442 information and the format in which it is printed depend on the btrace
   41443 recording format.
   41444 
   41445 @table @code
   41446 @item bts
   41447 For the BTS recording format, print a list of blocks of sequential
   41448 code.  For each block, the following information is printed:
   41449 
   41450 @table @asis
   41451 @item Block number
   41452 Newer blocks have higher numbers.  The oldest block has number zero.
   41453 @item Lowest @samp{PC}
   41454 @item Highest @samp{PC}
   41455 @end table
   41456 
   41457 @item pt
   41458 For the Intel Processor Trace recording format, print a list of
   41459 Intel Processor Trace packets.  For each packet, the following
   41460 information is printed:
   41461 
   41462 @table @asis
   41463 @item Packet number
   41464 Newer packets have higher numbers.  The oldest packet has number zero.
   41465 @item Trace offset
   41466 The packet's offset in the trace stream.
   41467 @item Packet opcode and payload
   41468 @end table
   41469 @end table
   41470 
   41471 @kindex maint btrace clear-packet-history
   41472 @item maint btrace clear-packet-history
   41473 Discards the cached packet history printed by the @samp{maint btrace
   41474 packet-history} command.  The history will be computed again when
   41475 needed.
   41476 
   41477 @kindex maint btrace clear
   41478 @item maint btrace clear
   41479 Discard the branch trace data.  The data will be fetched anew and the
   41480 branch trace will be recomputed when needed.
   41481 
   41482 This implicitly truncates the branch trace to a single branch trace
   41483 buffer.  When updating branch trace incrementally, the branch trace
   41484 available to @value{GDBN} may be bigger than a single branch trace
   41485 buffer.
   41486 
   41487 @kindex maint set btrace pt skip-pad
   41488 @item maint set btrace pt skip-pad
   41489 @kindex maint show btrace pt skip-pad
   41490 @item maint show btrace pt skip-pad
   41491 Control whether @value{GDBN} will skip PAD packets when computing the
   41492 packet history.
   41493 
   41494 @kindex maint info jit
   41495 @item maint info jit
   41496 Print information about JIT code objects loaded in the current inferior.
   41497 
   41498 @anchor{maint info python-disassemblers}
   41499 @kindex maint info python-disassemblers
   41500 @item maint info python-disassemblers
   41501 This command is defined within the @code{gdb.disassembler} Python
   41502 module (@pxref{Disassembly In Python}), and will only be present after
   41503 that module has been imported.  To force the module to be imported do
   41504 the following:
   41505 
   41506 @kindex maint info linux-lwps
   41507 @item maint info linux-lwps
   41508 Print information about LWPs under control of the Linux native target.
   41509 
   41510 @smallexample
   41511 (@value{GDBP}) python import gdb.disassembler
   41512 @end smallexample
   41513 
   41514 This command lists all the architectures for which a disassembler is
   41515 currently registered, and the name of the disassembler.  If a
   41516 disassembler is registered for all architectures, then this is listed
   41517 last against the @samp{GLOBAL} architecture.
   41518 
   41519 If one of the disassemblers would be selected for the architecture of
   41520 the current inferior, then this disassembler will be marked.
   41521 
   41522 The following example shows a situation in which two disassemblers are
   41523 registered, initially the @samp{i386} disassembler matches the current
   41524 architecture, then the architecture is changed, now the @samp{GLOBAL}
   41525 disassembler matches.
   41526 
   41527 @smallexample
   41528 @group
   41529 (@value{GDBP}) show architecture
   41530 The target architecture is set to "auto" (currently "i386").
   41531 (@value{GDBP}) maint info python-disassemblers
   41532 Architecture        Disassember Name
   41533 i386                Disassembler_1	(Matches current architecture)
   41534 GLOBAL              Disassembler_2
   41535 @end group
   41536 @group
   41537 (@value{GDBP}) set architecture arm
   41538 The target architecture is set to "arm".
   41539 (@value{GDBP}) maint info python-disassemblers
   41540 quit
   41541 Architecture        Disassember Name
   41542 i386                Disassembler_1
   41543 GLOBAL              Disassembler_2	(Matches current architecture)
   41544 @end group
   41545 @end smallexample
   41546 
   41547 @kindex set displaced-stepping
   41548 @kindex show displaced-stepping
   41549 @cindex displaced stepping support
   41550 @cindex out-of-line single-stepping
   41551 @item set displaced-stepping
   41552 @itemx show displaced-stepping
   41553 Control whether or not @value{GDBN} will do @dfn{displaced stepping}
   41554 if the target supports it.  Displaced stepping is a way to single-step
   41555 over breakpoints without removing them from the inferior, by executing
   41556 an out-of-line copy of the instruction that was originally at the
   41557 breakpoint location.  It is also known as out-of-line single-stepping.
   41558 
   41559 @table @code
   41560 @item set displaced-stepping on
   41561 If the target architecture supports it, @value{GDBN} will use
   41562 displaced stepping to step over breakpoints.
   41563 
   41564 @item set displaced-stepping off
   41565 @value{GDBN} will not use displaced stepping to step over breakpoints,
   41566 even if such is supported by the target architecture.
   41567 
   41568 @cindex non-stop mode, and @samp{set displaced-stepping}
   41569 @item set displaced-stepping auto
   41570 This is the default mode.  @value{GDBN} will use displaced stepping
   41571 only if non-stop mode is active (@pxref{Non-Stop Mode}) and the target
   41572 architecture supports displaced stepping.
   41573 @end table
   41574 
   41575 @kindex maint check-psymtabs
   41576 @item maint check-psymtabs
   41577 Check the consistency of currently expanded psymtabs versus symtabs.
   41578 Use this to check, for example, whether a symbol is in one but not the other.
   41579 
   41580 @kindex maint check-symtabs
   41581 @item maint check-symtabs
   41582 Check the consistency of currently expanded symtabs.
   41583 
   41584 @kindex maint expand-symtabs
   41585 @item maint expand-symtabs [@var{regexp}]
   41586 Expand symbol tables.
   41587 If @var{regexp} is specified, only expand symbol tables for file
   41588 names matching @var{regexp}.
   41589 
   41590 @kindex maint set catch-demangler-crashes
   41591 @kindex maint show catch-demangler-crashes
   41592 @cindex demangler crashes
   41593 @item maint set catch-demangler-crashes [on|off]
   41594 @itemx maint show catch-demangler-crashes
   41595 Control whether @value{GDBN} should attempt to catch crashes in the
   41596 symbol name demangler.  The default is to attempt to catch crashes.
   41597 If enabled, the first time a crash is caught, a core file is created,
   41598 the offending symbol is displayed and the user is presented with the
   41599 option to terminate the current session.
   41600 
   41601 @kindex maint cplus first_component
   41602 @item maint cplus first_component @var{name}
   41603 Print the first C@t{++} class/namespace component of @var{name}.
   41604 
   41605 @kindex maint cplus namespace
   41606 @item maint cplus namespace
   41607 Print the list of possible C@t{++} namespaces.
   41608 
   41609 @kindex maint deprecate
   41610 @kindex maint undeprecate
   41611 @cindex deprecated commands
   41612 @item maint deprecate @var{command} @r{[}@var{replacement}@r{]}
   41613 @itemx maint undeprecate @var{command}
   41614 Deprecate or undeprecate the named @var{command}.  Deprecated commands
   41615 cause @value{GDBN} to issue a warning when you use them.  The optional
   41616 argument @var{replacement} says which newer command should be used in
   41617 favor of the deprecated one; if it is given, @value{GDBN} will mention
   41618 the replacement as part of the warning.
   41619 
   41620 @kindex maint dump-me
   41621 @item maint dump-me
   41622 @cindex @code{SIGQUIT} signal, dump core of @value{GDBN}
   41623 Cause a fatal signal in the debugger and force it to dump its core.
   41624 This is supported only on systems which support aborting a program
   41625 with the @code{SIGQUIT} signal.
   41626 
   41627 @kindex maint internal-error
   41628 @kindex maint internal-warning
   41629 @kindex maint demangler-warning
   41630 @cindex demangler crashes
   41631 @item maint internal-error @r{[}@var{message-text}@r{]}
   41632 @itemx maint internal-warning @r{[}@var{message-text}@r{]}
   41633 @itemx maint demangler-warning @r{[}@var{message-text}@r{]}
   41634 
   41635 Cause @value{GDBN} to call the internal function @code{internal_error},
   41636 @code{internal_warning} or @code{demangler_warning} and hence behave
   41637 as though an internal problem has been detected.  In addition to
   41638 reporting the internal problem, these functions give the user the
   41639 opportunity to either quit @value{GDBN} or (for @code{internal_error}
   41640 and @code{internal_warning}) create a core file of the current
   41641 @value{GDBN} session.
   41642 
   41643 These commands take an optional parameter @var{message-text} that is
   41644 used as the text of the error or warning message.
   41645 
   41646 Here's an example of using @code{internal-error}:
   41647 
   41648 @smallexample
   41649 (@value{GDBP}) @kbd{maint internal-error testing, 1, 2}
   41650 @dots{}/maint.c:121: internal-error: testing, 1, 2
   41651 A problem internal to GDB has been detected.  Further
   41652 debugging may prove unreliable.
   41653 Quit this debugging session? (y or n) @kbd{n}
   41654 Create a core file? (y or n) @kbd{n}
   41655 (@value{GDBP})
   41656 @end smallexample
   41657 
   41658 @kindex maint set debuginfod download-sections
   41659 @kindex maint show debuginfod download-sections
   41660 @cindex debuginfod, maintenance commands
   41661 @item maint set debuginfod download-sections
   41662 @itemx maint set debuginfod download-sections @r{[}on|off@r{]}
   41663 @itemx maint show debuginfod download-sections
   41664 Controls whether @value{GDBN} will attempt to download individual
   41665 ELF/DWARF sections from @code{debuginfod}.  If disabled, only
   41666 whole debug info files will be downloaded; this could result
   41667 in @value{GDBN} downloading larger amounts of data.
   41668 
   41669 @cindex @value{GDBN} internal error
   41670 @cindex internal errors, control of @value{GDBN} behavior
   41671 @cindex demangler crashes
   41672 
   41673 @kindex maint set internal-error
   41674 @kindex maint show internal-error
   41675 @kindex maint set internal-warning
   41676 @kindex maint show internal-warning
   41677 @kindex maint set demangler-warning
   41678 @kindex maint show demangler-warning
   41679 @item maint set internal-error @var{action} [ask|yes|no]
   41680 @itemx maint show internal-error @var{action}
   41681 @itemx maint set internal-warning @var{action} [ask|yes|no]
   41682 @itemx maint show internal-warning @var{action}
   41683 @itemx maint set demangler-warning @var{action} [ask|yes|no]
   41684 @itemx maint show demangler-warning @var{action}
   41685 When @value{GDBN} reports an internal problem (error or warning) it
   41686 gives the user the opportunity to both quit @value{GDBN} and create a
   41687 core file of the current @value{GDBN} session.  These commands let you
   41688 override the default behavior for each particular @var{action},
   41689 described in the table below.
   41690 
   41691 @table @samp
   41692 @item quit
   41693 You can specify that @value{GDBN} should always (yes) or never (no)
   41694 quit.  The default is to ask the user what to do.
   41695 
   41696 @item corefile
   41697 You can specify that @value{GDBN} should always (yes) or never (no)
   41698 create a core file.  The default is to ask the user what to do.  Note
   41699 that there is no @code{corefile} option for @code{demangler-warning}:
   41700 demangler warnings always create a core file and this cannot be
   41701 disabled.
   41702 @end table
   41703 
   41704 @kindex maint set internal-error
   41705 @kindex maint show internal-error
   41706 @kindex maint set internal-warning
   41707 @kindex maint show internal-warning
   41708 @item maint set internal-error backtrace @r{[}on|off@r{]}
   41709 @itemx maint show internal-error backtrace
   41710 @itemx maint set internal-warning backtrace @r{[}on|off@r{]}
   41711 @itemx maint show internal-warning backtrace
   41712 When @value{GDBN} reports an internal problem (error or warning) it is
   41713 possible to have a backtrace of @value{GDBN} printed to the standard
   41714 error stream.  This is @samp{on} by default for @code{internal-error}
   41715 and @samp{off} by default for @code{internal-warning}.
   41716 
   41717 @anchor{maint packet}
   41718 @kindex maint packet
   41719 @item maint packet @var{text}
   41720 If @value{GDBN} is talking to an inferior via the serial protocol,
   41721 then this command sends the string @var{text} to the inferior, and
   41722 displays the response packet.  @value{GDBN} supplies the initial
   41723 @samp{$} character, the terminating @samp{#} character, and the
   41724 checksum.
   41725 
   41726 Any non-printable characters in the reply are printed as escaped hex,
   41727 e.g. @samp{\x00}, @samp{\x01}, etc.
   41728 
   41729 @kindex maint print architecture
   41730 @item maint print architecture @r{[}@var{file}@r{]}
   41731 Print the entire architecture configuration.  The optional argument
   41732 @var{file} names the file where the output goes.
   41733 
   41734 @kindex maint print c-tdesc
   41735 @item maint print c-tdesc @r{[}-single-feature@r{]} @r{[}@var{file}@r{]}
   41736 Print the target description (@pxref{Target Descriptions}) as
   41737 a C source file.  By default, the target description is for the current
   41738 target, but if the optional argument @var{file} is provided, that file
   41739 is used to produce the description.  The @var{file} should be an XML
   41740 document, of the form described in @ref{Target Description Format}.
   41741 The created source file is built into @value{GDBN} when @value{GDBN} is
   41742 built again.  This command is used by developers after they add or
   41743 modify XML target descriptions.
   41744 
   41745 When the optional flag @samp{-single-feature} is provided then the
   41746 target description being processed (either the default, or from
   41747 @var{file}) must only contain a single feature.  The source file
   41748 produced is different in this case.
   41749 
   41750 The @var{file} argument supports escaping and quoting, see
   41751 @ref{Filename Arguments,,Filenames As Command Arguments}.
   41752 
   41753 @kindex maint print xml-tdesc
   41754 @item maint print xml-tdesc  @r{[}@var{file}@r{]}
   41755 Print the target description (@pxref{Target Descriptions}) as an XML
   41756 file.  By default print the target description for the current target,
   41757 but if the optional argument @var{file} is provided, then that file is
   41758 read in by GDB and then used to produce the description.  The
   41759 @var{file} should be an XML document, of the form described in
   41760 @ref{Target Description Format}.
   41761 
   41762 @kindex maint check xml-descriptions
   41763 @item maint check xml-descriptions @var{dir}
   41764 Check that the target descriptions dynamically created by @value{GDBN}
   41765 equal the descriptions created from XML files found in @var{dir}.
   41766 
   41767 @anchor{maint check libthread-db}
   41768 @kindex maint check libthread-db
   41769 @item maint check libthread-db
   41770 Run integrity checks on the current inferior's thread debugging
   41771 library.  This exercises all @code{libthread_db} functionality used by
   41772 @value{GDBN} on GNU/Linux systems, and by extension also exercises the
   41773 @code{proc_service} functions provided by @value{GDBN} that
   41774 @code{libthread_db} uses.  Note that parts of the test may be skipped
   41775 on some platforms when debugging core files.
   41776 
   41777 @kindex maint print core-file-backed-mappings
   41778 @cindex memory address space mappings
   41779 @item maint print core-file-backed-mappings
   41780 Print the file-backed mappings which were loaded from a core file note.
   41781 This output represents state internal to @value{GDBN} and should be
   41782 similar to the mappings displayed by the @code{info proc mappings}
   41783 command.
   41784 
   41785 @kindex maint print dummy-frames
   41786 @item maint print dummy-frames
   41787 Prints the contents of @value{GDBN}'s internal dummy-frame stack.
   41788 
   41789 @smallexample
   41790 (@value{GDBP}) @kbd{b add}
   41791 @dots{}
   41792 (@value{GDBP}) @kbd{print add(2,3)}
   41793 Breakpoint 2, add (a=2, b=3) at @dots{}
   41794 58	  return (a + b);
   41795 The program being debugged stopped while in a function called from GDB.
   41796 @dots{}
   41797 (@value{GDBP}) @kbd{maint print dummy-frames}
   41798 0xa8206d8: id=@{stack=0xbfffe734,code=0xbfffe73f,!special@}, ptid=process 9353
   41799 (@value{GDBP})
   41800 @end smallexample
   41801 
   41802 Takes an optional file parameter.
   41803 
   41804 @kindex maint print frame-id
   41805 @item maint print frame-id
   41806 @itemx maint print frame-id @var{level}
   41807 Print @value{GDBN}'s internal frame-id for the frame at relative
   41808 @var{level}, or for the currently selected frame when @var{level} is
   41809 not given.
   41810 
   41811 If used, @var{level} should be an integer, as displayed in the
   41812 @command{backtrace} output.
   41813 
   41814 @smallexample
   41815 (@value{GDBP}) maint print frame-id
   41816 frame-id for frame #0: @{stack=0x7fffffffac70,code=0x0000000000401106,!special@}
   41817 (@value{GDBP}) maint print frame-id 2
   41818 frame-id for frame #2: @{stack=0x7fffffffac90,code=0x000000000040111c,!special@}
   41819 @end smallexample
   41820 
   41821 @item maint info inline-frames
   41822 @itemx maint info inline-frames @var{address}
   41823 @cindex frames of inlined functions
   41824 @kindex maint info inline-frames
   41825 Print information about inlined frames which start at the current
   41826 address, or @var{address} if specified.
   41827 
   41828 In order to allow the user to correctly step into inlined functions,
   41829 @value{GDBN} needs to identify which inlined functions start at a
   41830 particular address, and @value{GDBN} also needs to track which of
   41831 these functions was last displayed to the user as the current frame.
   41832 
   41833 Imagine a situation where function @code{main} calls @code{foo}, which
   41834 then calls @code{bar}, something like this:
   41835 
   41836 @smallexample
   41837 @group
   41838 int
   41839 main ()
   41840 @{
   41841   /* Some interesting code here...  */
   41842 
   41843   foo ();
   41844 
   41845   /* More interesting code here... */
   41846 @}
   41847 
   41848 void
   41849 foo ()
   41850 @{
   41851   bar ();
   41852 @}
   41853 
   41854 void
   41855 bar ()
   41856 @{
   41857   /* Some interesting code here...  */
   41858 @}
   41859 @end group
   41860 @end smallexample
   41861 
   41862 As both @code{foo} and @code{bar} are inlined within @code{main} then
   41863 there could be one address within @code{main} which is also the start
   41864 of @code{foo} and also the start of @code{bar}.  When the user stops
   41865 at this address they will initially be told the inferior is in
   41866 @code{main}, if the user does a @kbd{step} then @value{GDBN} doesn't
   41867 actually step the inferior, instead the user is told the inferior
   41868 entered @code{foo}.  After the next @kbd{step} the user is told the
   41869 inferior entered @code{bar}.  The @kbd{maint info inline-frames}
   41870 command can be used to view this internal @value{GDBN} state, like
   41871 this:
   41872 
   41873 @smallexample
   41874 @group
   41875 (@value{GDBP}) step
   41876 24	  foo ();
   41877 (@value{GDBP}) maintenance info inline-frames
   41878 Cached inline state information for thread 1.
   41879 program counter = 0x401137
   41880 skipped frames = 2
   41881   bar
   41882   foo
   41883 > main
   41884 @end group
   41885 @end smallexample
   41886 
   41887 Here the user is stopped in @code{main} at the call to @code{foo}.  The
   41888 inline-frames information shows that at this address @value{GDBN} has
   41889 found the start of inlined functions @code{bar} and @code{foo}, but
   41890 currently @value{GDBN} has skipped 2 frames and considers @code{main}
   41891 to be the current frame, this is indicated with the @samp{>}.
   41892 
   41893 If the user performs a @kbd{step} to enter @code{foo} then the
   41894 situation is updated:
   41895 
   41896 @smallexample
   41897 @group
   41898 (@value{GDBP}) step
   41899 foo () at inline.c:14
   41900 14	  bar ();
   41901 (@value{GDBP}) maintenance info inline-frames
   41902 Cached inline state information for thread 1.
   41903 program counter = 0x401137
   41904 skipped frames = 1
   41905   bar
   41906 > foo
   41907   main
   41908 @end group
   41909 @end smallexample
   41910 
   41911 Notice that the program counter value @code{0x401137} hasn't change,
   41912 but now @value{GDBN} considers @code{foo} to be the current frame, and
   41913 it is marked as such with the @samp{>}.
   41914 
   41915 Finally, the user performs another @kbd{step} to enter @code{bar}:
   41916 
   41917 @smallexample
   41918 @group
   41919 (@value{GDBP}) step
   41920 bar () at inline.c:6
   41921 6	  ++global_counter;
   41922 (@value{GDBP}) maintenance info inline-frames
   41923 Cached inline state information for thread 1.
   41924 program counter = 0x401137
   41925 skipped frames = 0
   41926 > bar
   41927   foo
   41928   main
   41929 @end group
   41930 @end smallexample
   41931 
   41932 @kindex maint info blocks
   41933 @item maint info blocks
   41934 @itemx maint info blocks @var{address}
   41935 Print information about all blocks at @var{address}, or at the current
   41936 @code{$pc} if @var{address} is not given.
   41937 
   41938 For information about what blocks are in @value{GDBN} see @ref{Blocks
   41939 In Python}.
   41940 
   41941 Blocks are listed starting from the global block, then the static
   41942 block, and then proceeding through progressively narrower scopes.
   41943 
   41944 Here is an example of the command's output:
   41945 @smallexample
   41946 @group
   41947 (@value{GDBP}) maintenance info blocks
   41948 Blocks at 0x401137:
   41949   from objfile: [(objfile *) 0x50507d0] /tmp/inline_func_demo
   41950 
   41951 [(block *) 0x504da90] 0x401106..0x40119a
   41952   entry pc: 0x401106
   41953   is global block
   41954   symbol count: 2
   41955   is contiguous
   41956 @end group
   41957 @group
   41958 [(block *) 0x504d9f0] 0x401106..0x40119a
   41959   entry pc: 0x401106
   41960   is static block
   41961   symbol count: 1
   41962   is contiguous
   41963 @end group
   41964 @group
   41965 [(block *) 0x504d9a0] 0x401106..0x40119a
   41966   entry pc: 0x401106
   41967   function: main
   41968   is contiguous
   41969 @end group
   41970 @group
   41971 [(block *) 0x504d900] 0x401137..0x401166
   41972   entry pc: 0x401137
   41973   inline function: foo
   41974   symbol count: 1
   41975   is contiguous
   41976 @end group
   41977 @group
   41978 [(block *) 0x504d860] 0x401137..0x401165
   41979   entry pc: 0x401137
   41980   inline function: bar
   41981   symbol count: 1
   41982   is contiguous
   41983 @end group
   41984 @end smallexample
   41985 
   41986 The command @kbd{maint info blocks} lists the symbol count for each
   41987 block but doesn't print the symbols themselves.  The symbol names can
   41988 be found using @kbd{maint print symbols} (@pxref{maint print
   41989 symbols}).
   41990 
   41991 @kindex maint print registers
   41992 @kindex maint print raw-registers
   41993 @kindex maint print cooked-registers
   41994 @kindex maint print register-groups
   41995 @kindex maint print remote-registers
   41996 @item maint print registers @r{[}@var{file}@r{]}
   41997 @itemx maint print raw-registers @r{[}@var{file}@r{]}
   41998 @itemx maint print cooked-registers @r{[}@var{file}@r{]}
   41999 @itemx maint print register-groups @r{[}@var{file}@r{]}
   42000 @itemx maint print remote-registers @r{[}@var{file}@r{]}
   42001 Print @value{GDBN}'s internal register data structures.
   42002 
   42003 The command @code{maint print raw-registers} includes the contents of
   42004 the raw register cache; the command @code{maint print
   42005 cooked-registers} includes the (cooked) value of all registers,
   42006 including registers which aren't available on the target nor visible
   42007 to user; the command @code{maint print register-groups} includes the
   42008 groups that each register is a member of; and the command @code{maint
   42009 print remote-registers} includes the remote target's register numbers
   42010 and offsets in the `G' packets, as well as an indication of which
   42011 registers were included in the last stop reply packet received by
   42012 @value{GDBN} (@pxref{Stop Reply Packets}).  Please note that the list
   42013 of registers included in a stop reply can change from one stop to the
   42014 next.
   42015 
   42016 These commands take an optional parameter, a file name to which to
   42017 write the information.
   42018 
   42019 @kindex maint print reggroups
   42020 @item maint print reggroups @r{[}@var{file}@r{]}
   42021 Print @value{GDBN}'s internal register group data structures.  The
   42022 optional argument @var{file} tells to what file to write the
   42023 information.
   42024 
   42025 The register groups info looks like this:
   42026 
   42027 @smallexample
   42028 (@value{GDBP}) @kbd{maint print reggroups}
   42029  Group      Type
   42030  general    user
   42031  float      user
   42032  all        user
   42033  vector     user
   42034  system     user
   42035  save       internal
   42036  restore    internal
   42037 @end smallexample
   42038 
   42039 @kindex maint flush register-cache
   42040 @kindex flushregs
   42041 @cindex register cache, flushing
   42042 @item maint flush register-cache
   42043 @itemx flushregs
   42044 Flush the contents of the register cache and as a consequence the
   42045 frame cache.  This command is useful when debugging issues related to
   42046 register fetching, or frame unwinding.  The command @code{flushregs}
   42047 is deprecated in favor of @code{maint flush register-cache}.
   42048 
   42049 @kindex maint flush source-cache
   42050 @cindex source code, caching
   42051 @item maint flush source-cache
   42052 Flush @value{GDBN}'s cache of source code file contents.  After
   42053 @value{GDBN} reads a source file, and optionally applies styling
   42054 (@pxref{Output Styling}), the file contents are cached.  This command
   42055 clears that cache.  The next time @value{GDBN} wants to show lines
   42056 from a source file, the content will be re-read.
   42057 
   42058 This command is useful when debugging issues related to source code
   42059 styling.  After flushing the cache any source code displayed by
   42060 @value{GDBN} will be re-read and re-styled.
   42061 
   42062 @kindex maint print objfiles
   42063 @cindex info for known object files
   42064 @item maint print objfiles @r{[}@var{regexp}@r{]}
   42065 Print a dump of all known object files.
   42066 If @var{regexp} is specified, only print object files whose names
   42067 match @var{regexp}.  For each object file, this command prints its name,
   42068 address in memory, and all of its psymtabs and symtabs.
   42069 
   42070 @kindex maint print user-registers
   42071 @cindex user registers
   42072 @item maint print user-registers
   42073 List all currently available @dfn{user registers}.  User registers
   42074 typically provide alternate names for actual hardware registers.  They
   42075 include the four ``standard'' registers @code{$fp}, @code{$pc},
   42076 @code{$sp}, and @code{$ps}.  @xref{standard registers}.  User
   42077 registers can be used in expressions in the same way as the canonical
   42078 register names, but only the latter are listed by the @code{info
   42079 registers} and @code{maint print registers} commands.
   42080 
   42081 @kindex maint print section-scripts
   42082 @cindex info for known .debug_gdb_scripts-loaded scripts
   42083 @item maint print section-scripts [@var{regexp}]
   42084 Print a dump of scripts specified in the @code{.debug_gdb_section} section.
   42085 If @var{regexp} is specified, only print scripts loaded by object files
   42086 matching @var{regexp}.
   42087 For each script, this command prints its name as specified in the objfile,
   42088 and the full path if known.
   42089 @xref{dotdebug_gdb_scripts section}.
   42090 
   42091 @kindex maint print statistics
   42092 @cindex bcache statistics
   42093 @item maint print statistics
   42094 This command prints, for each object file in the program, various data
   42095 about that object file followed by the byte cache (@dfn{bcache})
   42096 statistics for the object file.  The objfile data includes the number
   42097 of minimal, partial, full, and stabs symbols, the number of types
   42098 defined by the objfile, the number of as yet unexpanded psym tables,
   42099 the number of line tables and string tables, and the amount of memory
   42100 used by the various tables.  The bcache statistics include the counts,
   42101 sizes, and counts of duplicates of all and unique objects, max,
   42102 average, and median entry size, total memory used and its overhead and
   42103 savings, and various measures of the hash table size and chain
   42104 lengths.
   42105 
   42106 @kindex maint print target-stack
   42107 @cindex target stack description
   42108 @item maint print target-stack
   42109 A @dfn{target} is an interface between the debugger and a particular
   42110 kind of file or process.  Targets can be stacked in @dfn{strata},
   42111 so that more than one target can potentially respond to a request.
   42112 In particular, memory accesses will walk down the stack of targets
   42113 until they find a target that is interested in handling that particular
   42114 address.
   42115 
   42116 This command prints a short description of each layer that was pushed on
   42117 the @dfn{target stack}, starting from the top layer down to the bottom one.
   42118 
   42119 @kindex maint print type
   42120 @cindex type chain of a data type
   42121 @item maint print type @var{expr}
   42122 Print the type chain for a type specified by @var{expr}.  The argument
   42123 can be either a type name or a symbol.  If it is a symbol, the type of
   42124 that symbol is described.  The type chain produced by this command is
   42125 a recursive definition of the data type as stored in @value{GDBN}'s
   42126 data structures, including its flags and contained types.
   42127 
   42128 @kindex maint print record-instruction
   42129 @item maint print record-instruction
   42130 @itemx maint print record-instruction @var{N}
   42131 print how GDB recorded a given instruction.  If @var{n} is not positive
   42132 number, it prints the values stored by the inferior before the @var{n}-th previous
   42133 instruction was executed.  If @var{n} is positive, print the values after the @var{n}-th
   42134 following instruction is executed.  If @var{n} is not given, 0 is assumed.
   42135 
   42136 @kindex maint selftest
   42137 @cindex self tests
   42138 @item maint selftest @r{[}-verbose@r{]} @r{[}@var{filter}@r{]}
   42139 Run any self tests that were compiled in to @value{GDBN}.  This will
   42140 print a message showing how many tests were run, and how many failed.
   42141 If a @var{filter} is passed, only the tests with @var{filter} in their
   42142 name will be ran.  If @code{-verbose} is passed, the self tests can be
   42143 more verbose.
   42144 
   42145 @kindex maint set selftest verbose
   42146 @kindex maint show selftest verbose
   42147 @cindex self tests
   42148 @item maint set selftest verbose
   42149 @item maint show selftest verbose
   42150 Control whether self tests are run verbosely or not.
   42151 
   42152 @kindex maint info selftests
   42153 @cindex self tests
   42154 @item maint info selftests
   42155 List the selftests compiled in to @value{GDBN}.
   42156 
   42157 @kindex maint set dwarf always-disassemble
   42158 @kindex maint show dwarf always-disassemble
   42159 @item maint set dwarf always-disassemble
   42160 @item maint show dwarf always-disassemble
   42161 Control the behavior of @code{info address} when using DWARF debugging
   42162 information.
   42163 
   42164 The default is @code{off}, which means that @value{GDBN} should try to
   42165 describe a variable's location in an easily readable format.  When
   42166 @code{on}, @value{GDBN} will instead display the DWARF location
   42167 expression in an assembly-like format.  Note that some locations are
   42168 too complex for @value{GDBN} to describe simply; in this case you will
   42169 always see the disassembly form.
   42170 
   42171 Here is an example of the resulting disassembly:
   42172 
   42173 @smallexample
   42174 (@value{GDBP}) info addr argc
   42175 Symbol "argc" is a complex DWARF expression:
   42176      1: DW_OP_fbreg 0
   42177 @end smallexample
   42178 
   42179 For more information on these expressions, see
   42180 @uref{http://www.dwarfstd.org/, the DWARF standard}.
   42181 
   42182 @kindex maint set dwarf max-cache-age
   42183 @kindex maint show dwarf max-cache-age
   42184 @item maint set dwarf max-cache-age
   42185 @itemx maint show dwarf max-cache-age
   42186 Control the DWARF compilation unit cache.
   42187 
   42188 @cindex DWARF compilation units cache
   42189 In object files with inter-compilation-unit references, such as those
   42190 produced by the GCC option @samp{-feliminate-dwarf2-dups}, the DWARF
   42191 reader needs to frequently refer to previously read compilation units.
   42192 This setting controls how long a compilation unit will remain in the
   42193 cache if it is not referenced.  A higher limit means that cached
   42194 compilation units will be stored in memory longer, and more total
   42195 memory will be used.  Setting it to zero disables caching, which will
   42196 slow down @value{GDBN} startup, but reduce memory consumption.
   42197 
   42198 @kindex maint set dwarf synchronous
   42199 @kindex maint show dwarf synchronous
   42200 @item maint set dwarf synchronous
   42201 @itemx maint show dwarf synchronous
   42202 Control whether DWARF is read asynchronously.
   42203 
   42204 On hosts where threading is available, the DWARF reader is mostly
   42205 asynchronous with respect to the rest of @value{GDBN}.  That is, the
   42206 bulk of the reading is done in the background, and @value{GDBN} will
   42207 only pause for completion of this task when absolutely necessary.
   42208 
   42209 When this setting is enabled, @value{GDBN} will instead wait for DWARF
   42210 processing to complete before continuing.
   42211 
   42212 On hosts without threading, or where worker threads have been disabled
   42213 at runtime, this setting has no effect, as DWARF reading is always
   42214 done on the main thread, and is therefore always synchronous.
   42215 
   42216 @kindex maint set dwarf unwinders
   42217 @kindex maint show dwarf unwinders
   42218 @item maint set dwarf unwinders
   42219 @itemx maint show dwarf unwinders
   42220 Control use of the DWARF frame unwinders.
   42221 
   42222 @cindex DWARF frame unwinders
   42223 Many targets that support DWARF debugging use @value{GDBN}'s DWARF
   42224 frame unwinders to build the backtrace.  Many of these targets will
   42225 also have a second mechanism for building the backtrace for use in
   42226 cases where DWARF information is not available, this second mechanism
   42227 is often an analysis of a function's prologue.
   42228 
   42229 In order to extend testing coverage of the second level stack
   42230 unwinding mechanisms it is helpful to be able to disable the DWARF
   42231 stack unwinders, this can be done with this switch.
   42232 
   42233 In normal use of @value{GDBN} disabling the DWARF unwinders is not
   42234 advisable, there are cases that are better handled through DWARF than
   42235 prologue analysis, and the debug experience is likely to be better
   42236 with the DWARF frame unwinders enabled.
   42237 
   42238 If DWARF frame unwinders are not supported for a particular target
   42239 architecture, then enabling this flag does not cause them to be used.
   42240 
   42241 @kindex maint info frame-unwinders
   42242 @item maint info frame-unwinders
   42243 List the frame unwinders currently in effect, starting with the highest priority.
   42244 
   42245 @kindex maint set worker-threads
   42246 @kindex maint show worker-threads
   42247 @item maint set worker-threads
   42248 @item maint show worker-threads
   42249 Control the number of worker threads that may be used by @value{GDBN}.
   42250 On capable hosts, @value{GDBN} may use multiple threads to speed up
   42251 certain CPU-intensive operations, such as demangling symbol names.
   42252 While the number of threads used by @value{GDBN} may vary, this
   42253 command can be used to set an upper bound on this number.  The default
   42254 is @code{unlimited}, which lets @value{GDBN} choose a reasonable
   42255 number.  Note that this only controls worker threads started by
   42256 @value{GDBN} itself; libraries used by @value{GDBN} may start threads
   42257 of their own.
   42258 
   42259 @kindex maint set profile
   42260 @kindex maint show profile
   42261 @cindex profiling GDB
   42262 @item maint set profile
   42263 @itemx maint show profile
   42264 Control profiling of @value{GDBN}.
   42265 
   42266 Profiling will be disabled until you use the @samp{maint set profile}
   42267 command to enable it.  When you enable profiling, the system will begin
   42268 collecting timing and execution count data; when you disable profiling or
   42269 exit @value{GDBN}, the results will be written to a log file.  Remember that
   42270 if you use profiling, @value{GDBN} will overwrite the profiling log file
   42271 (often called @file{gmon.out}).  If you have a record of important profiling
   42272 data in a @file{gmon.out} file, be sure to move it to a safe location.
   42273 
   42274 Configuring with @samp{--enable-profiling} arranges for @value{GDBN} to be
   42275 compiled with the @samp{-pg} compiler option.
   42276 
   42277 @kindex maint set show-debug-regs
   42278 @kindex maint show show-debug-regs
   42279 @cindex hardware debug registers
   42280 @item maint set show-debug-regs
   42281 @itemx maint show show-debug-regs
   42282 Control whether to show variables that mirror the hardware debug
   42283 registers.  Use @code{on} to enable, @code{off} to disable.  If
   42284 enabled, the debug registers values are shown when @value{GDBN} inserts or
   42285 removes a hardware breakpoint or watchpoint, and when the inferior
   42286 triggers a hardware-assisted breakpoint or watchpoint.
   42287 
   42288 @kindex maint set show-all-tib
   42289 @kindex maint show show-all-tib
   42290 @item maint set show-all-tib
   42291 @itemx maint show show-all-tib
   42292 Control whether to show all non zero areas within a 1k block starting
   42293 at thread local base, when using the @samp{info w32 thread-information-block}
   42294 command.
   42295 
   42296 @kindex maint set target-async
   42297 @kindex maint show target-async
   42298 @item maint set target-async
   42299 @itemx maint show target-async
   42300 This controls whether @value{GDBN} targets operate in synchronous or
   42301 asynchronous mode (@pxref{Background Execution}).  Normally the
   42302 default is asynchronous, if it is available; but this can be changed
   42303 to more easily debug problems occurring only in synchronous mode.
   42304 
   42305 @kindex maint set target-non-stop @var{mode} [on|off|auto]
   42306 @kindex maint show target-non-stop
   42307 @item maint set target-non-stop
   42308 @itemx maint show target-non-stop
   42309 
   42310 This controls whether @value{GDBN} targets always operate in non-stop
   42311 mode even if @code{set non-stop} is @code{off} (@pxref{Non-Stop
   42312 Mode}).  The default is @code{auto}, meaning non-stop mode is enabled
   42313 if supported by the target.
   42314 
   42315 @table @code
   42316 @item maint set target-non-stop auto
   42317 This is the default mode.  @value{GDBN} controls the target in
   42318 non-stop mode if the target supports it.
   42319 
   42320 @item maint set target-non-stop on
   42321 @value{GDBN} controls the target in non-stop mode even if the target
   42322 does not indicate support.
   42323 
   42324 @item maint set target-non-stop off
   42325 @value{GDBN} does not control the target in non-stop mode even if the
   42326 target supports it.
   42327 @end table
   42328 
   42329 @kindex maint set tui-resize-message
   42330 @kindex maint show tui-resize-message
   42331 @item maint set tui-resize-message
   42332 @item maint show tui-resize-message
   42333 Control whether @value{GDBN} displays a message each time the terminal
   42334 is resized when in TUI mode.  The default is @code{off}, which means
   42335 that @value{GDBN} is silent during resizes.  When @code{on},
   42336 @value{GDBN} will display a message after a resize is completed; the
   42337 message will include a number indicating how many times the terminal
   42338 has been resized.  This setting is intended for use by the test suite,
   42339 where it would otherwise be difficult to determine when a resize and
   42340 refresh has been completed.
   42341 
   42342 @kindex maint set tui-left-margin-verbose
   42343 @kindex maint show tui-left-margin-verbose
   42344 @item maint set tui-left-margin-verbose
   42345 @item maint show tui-left-margin-verbose
   42346 Control whether the left margin of the TUI source and disassembly windows
   42347 uses @samp{_} and @samp{0} at locations where otherwise there would be a
   42348 space.  The default is @code{off}, which means spaces are used.  The
   42349 setting is intended to make it clear where the left margin begins and
   42350 ends, to avoid incorrectly interpreting a space as being part of the
   42351 the left margin.
   42352 
   42353 @kindex maint set per-command
   42354 @kindex maint show per-command
   42355 @item maint set per-command
   42356 @itemx maint show per-command
   42357 @cindex resources used by commands
   42358 
   42359 @value{GDBN} can display the resources used by each command.
   42360 This is useful in debugging performance problems.
   42361 
   42362 @table @code
   42363 @item maint set per-command space [on|off]
   42364 @itemx maint show per-command space
   42365 Enable or disable the printing of the memory used by GDB for each command.
   42366 If enabled, @value{GDBN} will display how much memory each command
   42367 took, following the command's own output.
   42368 This can also be requested by invoking @value{GDBN} with the
   42369 @option{--statistics} command-line switch (@pxref{Mode Options}).
   42370 
   42371 @item maint set per-command time [on|off]
   42372 @itemx maint show per-command time
   42373 Enable or disable the printing of the execution time of @value{GDBN}
   42374 for each command.
   42375 If enabled, @value{GDBN} will display how much time it
   42376 took to execute each command, following the command's own output.
   42377 Both CPU time and wallclock time are printed.
   42378 Printing both is useful when trying to determine whether the cost is
   42379 CPU or, e.g., disk/network latency.
   42380 Note that the CPU time printed is for @value{GDBN} only, it does not include
   42381 the execution time of the inferior because there's no mechanism currently
   42382 to compute how much time was spent by @value{GDBN} and how much time was
   42383 spent by the program been debugged.
   42384 This can also be requested by invoking @value{GDBN} with the
   42385 @option{--statistics} command-line switch (@pxref{Mode Options}).
   42386 
   42387 @item maint set per-command symtab [on|off]
   42388 @itemx maint show per-command symtab
   42389 Enable or disable the printing of basic symbol table statistics
   42390 for each command.
   42391 If enabled, @value{GDBN} will display the following information:
   42392 
   42393 @enumerate a
   42394 @item
   42395 number of symbol tables
   42396 @item
   42397 number of primary symbol tables
   42398 @item
   42399 number of blocks in the blockvector
   42400 @end enumerate
   42401 @end table
   42402 
   42403 @kindex maint set check-libthread-db
   42404 @kindex maint show check-libthread-db
   42405 @item maint set check-libthread-db [on|off]
   42406 @itemx maint show check-libthread-db
   42407 Control whether @value{GDBN} should run integrity checks on inferior
   42408 specific thread debugging libraries as they are loaded.  The default
   42409 is not to perform such checks.  If any check fails @value{GDBN} will
   42410 unload the library and continue searching for a suitable candidate as
   42411 described in @ref{set libthread-db-search-path}.  For more information
   42412 about the tests, see @ref{maint check libthread-db}.
   42413 
   42414 @kindex maint set gnu-source-highlight enabled
   42415 @kindex maint show gnu-source-highlight enabled
   42416 @item maint set gnu-source-highlight enabled @r{[}on|off@r{]}
   42417 @itemx maint show gnu-source-highlight enabled
   42418 Control whether @value{GDBN} should use the GNU Source Highlight
   42419 library for applying styling to source code (@pxref{Output Styling}).
   42420 This will be @samp{on} by default if the GNU Source Highlight library
   42421 is available.  If the GNU Source Highlight library is not available,
   42422 then this will be @samp{off} by default, and attempting to change this
   42423 value to @samp{on} will give an error.
   42424 
   42425 If the GNU Source Highlight library is not being used, then
   42426 @value{GDBN} will use the Python Pygments package for source code
   42427 styling, if it is available.
   42428 
   42429 This option is useful for debugging @value{GDBN}'s use of the Pygments
   42430 library when @value{GDBN} is linked against the GNU Source Highlight
   42431 library.
   42432 
   42433 @anchor{maint_libopcodes_styling}
   42434 @kindex maint set libopcodes-styling enabled
   42435 @kindex maint show libopcodes-styling enabled
   42436 @item maint set libopcodes-styling enabled @r{[}on|off@r{]}
   42437 @itemx maint show libopcodes-styling enabled
   42438 Control whether @value{GDBN} should use its builtin disassembler
   42439 (@file{libopcodes}) to style disassembler output (@pxref{Output
   42440 Styling}).  The builtin disassembler does not support styling for all
   42441 architectures.
   42442 
   42443 When this option is @samp{off} the builtin disassembler will not be
   42444 used for styling, @value{GDBN} will fall back to using the Python
   42445 Pygments package if possible.
   42446 
   42447 Trying to set this option @samp{on} for an architecture that the
   42448 builtin disassembler is unable to style will give an error, otherwise,
   42449 the builtin disassembler will be used to style disassembler output.
   42450 
   42451 This option is @samp{on} by default for supported architectures.
   42452 
   42453 This option is useful for debugging @value{GDBN}'s use of the Pygments
   42454 library when @value{GDBN} is built for an architecture that supports
   42455 styling with the builtin disassembler
   42456 
   42457 @kindex maint info screen
   42458 @cindex show screen characteristics
   42459 @item maint info screen
   42460 Print various characteristics of the screen, such as various notions
   42461 of width and height.
   42462 
   42463 @kindex maint space
   42464 @cindex memory used by commands
   42465 @item maint space @var{value}
   42466 An alias for @code{maint set per-command space}.
   42467 A non-zero value enables it, zero disables it.
   42468 
   42469 @kindex maint time
   42470 @cindex time of command execution
   42471 @item maint time @var{value}
   42472 An alias for @code{maint set per-command time}.
   42473 A non-zero value enables it, zero disables it.
   42474 
   42475 @kindex maint translate-address
   42476 @item maint translate-address @r{[}@var{section}@r{]} @var{addr}
   42477 Find the symbol stored at the location specified by the address
   42478 @var{addr} and an optional section name @var{section}.  If found,
   42479 @value{GDBN} prints the name of the closest symbol and an offset from
   42480 the symbol's location to the specified address.  This is similar to
   42481 the @code{info address} command (@pxref{Symbols}), except that this
   42482 command also allows to find symbols in other sections.
   42483 
   42484 If section was not specified, the section in which the symbol was found
   42485 is also printed.  For dynamically linked executables, the name of
   42486 executable or shared library containing the symbol is printed as well.
   42487 
   42488 @kindex maint test-options
   42489 @item maint test-options require-delimiter
   42490 @itemx maint test-options unknown-is-error
   42491 @itemx maint test-options unknown-is-operand
   42492 These commands are used by the testsuite to validate the command
   42493 options framework.  The @code{require-delimiter} variant requires a
   42494 double-dash delimiter to indicate end of options.  The
   42495 @code{unknown-is-error} and @code{unknown-is-operand} do not.  The
   42496 @code{unknown-is-error} variant throws an error on unknown option,
   42497 while @code{unknown-is-operand} treats unknown options as the start of
   42498 the command's operands.  When run, the commands output the result of
   42499 the processed options.  When completed, the commands store the
   42500 internal result of completion in a variable exposed by the @code{maint
   42501 show test-options-completion-result} command.
   42502 
   42503 @kindex maint show test-options-completion-result
   42504 @item maint show test-options-completion-result
   42505 Shows the result of completing the @code{maint test-options}
   42506 subcommands.  This is used by the testsuite to validate completion
   42507 support in the command options framework.
   42508 
   42509 @kindex maint set test-settings
   42510 @kindex maint show test-settings
   42511 @item maint set test-settings @var{kind}
   42512 @itemx maint show test-settings @var{kind}
   42513 These are representative commands for each @var{kind} of setting type
   42514 @value{GDBN} supports.  They are used by the testsuite for exercising
   42515 the settings infrastructure.
   42516 
   42517 @kindex maint set backtrace-on-fatal-signal
   42518 @kindex maint show backtrace-on-fatal-signal
   42519 @item maint set backtrace-on-fatal-signal [on|off]
   42520 @itemx maint show backtrace-on-fatal-signal
   42521 When this setting is @code{on}, if @value{GDBN} itself terminates with
   42522 a fatal signal (e.g.@: SIGSEGV), then a limited backtrace will be
   42523 printed to the standard error stream.  This backtrace can be used to
   42524 help diagnose crashes within @value{GDBN} in situations where a user
   42525 is unable to share a corefile with the @value{GDBN} developers.
   42526 
   42527 If the functionality to provide this backtrace is not available for
   42528 the platform on which GDB is running then this feature will be
   42529 @code{off} by default, and attempting to turn this feature on will
   42530 give an error.
   42531 
   42532 For platforms that do support creating the backtrace this feature is
   42533 @code{on} by default.
   42534 
   42535 @kindex maint wait-for-index-cache
   42536 @item maint wait-for-index-cache
   42537 Wait until all pending writes to the index cache have completed.  This
   42538 is used by the test suite to avoid races when the index cache is being
   42539 updated by a worker thread.
   42540 
   42541 @kindex maint with
   42542 @item maint with @var{setting} [@var{value}] [-- @var{command}]
   42543 Like the @code{with} command, but works with @code{maintenance set}
   42544 variables.  This is used by the testsuite to exercise the @code{with}
   42545 command's infrastructure.
   42546 
   42547 @kindex maint ignore-probes
   42548 @item maint ignore-probes [@var{-v}|@var{-verbose}] [@var{provider} [@var{name} [@var{objfile}]]]
   42549 @itemx maint ignore-probes @var{-reset}
   42550 Set or reset the ignore-probes filter.  The @var{provider}, @var{name}
   42551 and @var{objfile} arguments are as in @code{enable probes} and
   42552 @code{disable probes} (@pxref{enable probes}).  Only supported for
   42553 SystemTap probes.
   42554 
   42555 Here's an example of using @code{maint ignore-probes}:
   42556 @smallexample
   42557 (gdb) maint ignore-probes -verbose libc ^longjmp$
   42558 ignore-probes filter has been set to:
   42559 PROVIDER: 'libc'
   42560 PROBE_NAME: '^longjmp$'
   42561 OBJNAME: ''
   42562 (gdb) start
   42563 <... more output ...>
   42564 Ignoring SystemTap probe libc longjmp in /lib64/libc.so.6.^M
   42565 Ignoring SystemTap probe libc longjmp in /lib64/libc.so.6.^M
   42566 Ignoring SystemTap probe libc longjmp in /lib64/libc.so.6.^M
   42567 @end smallexample
   42568 @end table
   42569 
   42570 The following command is useful for non-interactive invocations of
   42571 @value{GDBN}, such as in the test suite.
   42572 
   42573 @table @code
   42574 @item set watchdog @var{nsec}
   42575 @kindex set watchdog
   42576 @cindex watchdog timer
   42577 @cindex timeout for commands
   42578 Set the maximum number of seconds @value{GDBN} will wait for the
   42579 target operation to finish.  If this time expires, @value{GDBN}
   42580 reports and error and the command is aborted.
   42581 
   42582 @item show watchdog
   42583 Show the current setting of the target wait timeout.
   42584 @end table
   42585 
   42586 @node Remote Protocol
   42587 @appendix @value{GDBN} Remote Serial Protocol
   42588 
   42589 @menu
   42590 * Overview::
   42591 * Standard Replies::
   42592 * Packets::
   42593 * Stop Reply Packets::
   42594 * General Query Packets::
   42595 * Architecture-Specific Protocol Details::
   42596 * Tracepoint Packets::
   42597 * Host I/O Packets::
   42598 * Interrupts::
   42599 * Notification Packets::
   42600 * Remote Non-Stop::
   42601 * Packet Acknowledgment::
   42602 * Examples::
   42603 * File-I/O Remote Protocol Extension::
   42604 * Library List Format::
   42605 * Library List Format for SVR4 Targets::
   42606 * Memory Map Format::
   42607 * Thread List Format::
   42608 * Traceframe Info Format::
   42609 * Branch Trace Format::
   42610 * Branch Trace Configuration Format::
   42611 @end menu
   42612 
   42613 @node Overview
   42614 @section Overview
   42615 
   42616 There may be occasions when you need to know something about the
   42617 protocol---for example, if there is only one serial port to your target
   42618 machine, you might want your program to do something special if it
   42619 recognizes a packet meant for @value{GDBN}.
   42620 
   42621 In the examples below, @samp{->} and @samp{<-} are used to indicate
   42622 transmitted and received data, respectively.
   42623 
   42624 @cindex protocol, @value{GDBN} remote serial
   42625 @cindex serial protocol, @value{GDBN} remote
   42626 @cindex remote serial protocol
   42627 All @value{GDBN} commands and responses (other than acknowledgments
   42628 and notifications, see @ref{Notification Packets}) are sent as a
   42629 @var{packet}.  A @var{packet} is introduced with the character
   42630 @samp{$}, the actual @var{packet-data}, and the terminating character
   42631 @samp{#} followed by a two-digit @var{checksum}:
   42632 
   42633 @smallexample
   42634 @code{$}@var{packet-data}@code{#}@var{checksum}
   42635 @end smallexample
   42636 @noindent
   42637 
   42638 @cindex checksum, for @value{GDBN} remote
   42639 @noindent
   42640 The two-digit @var{checksum} is computed as the modulo 256 sum of all
   42641 characters between the leading @samp{$} and the trailing @samp{#} (an
   42642 eight bit unsigned checksum).
   42643 
   42644 Implementors should note that prior to @value{GDBN} 5.0 the protocol
   42645 specification also included an optional two-digit @var{sequence-id}:
   42646 
   42647 @smallexample
   42648 @code{$}@var{sequence-id}@code{:}@var{packet-data}@code{#}@var{checksum}
   42649 @end smallexample
   42650 
   42651 @cindex sequence-id, for @value{GDBN} remote
   42652 @noindent
   42653 That @var{sequence-id} was appended to the acknowledgment.  @value{GDBN}
   42654 has never output @var{sequence-id}s.  Stubs that handle packets added
   42655 since @value{GDBN} 5.0 must not accept @var{sequence-id}.
   42656 
   42657 When either the host or the target machine receives a packet, the first
   42658 response expected is an acknowledgment: either @samp{+} (to indicate
   42659 the package was received correctly) or @samp{-} (to request
   42660 retransmission):
   42661 
   42662 @smallexample
   42663 -> @code{$}@var{packet-data}@code{#}@var{checksum}
   42664 <- @code{+}
   42665 @end smallexample
   42666 @noindent
   42667 
   42668 The @samp{+}/@samp{-} acknowledgments can be disabled
   42669 once a connection is established.
   42670 @xref{Packet Acknowledgment}, for details.
   42671 
   42672 The host (@value{GDBN}) sends @var{command}s, and the target (the
   42673 debugging stub incorporated in your program) sends a @var{response}.  In
   42674 the case of step and continue @var{command}s, the response is only sent
   42675 when the operation has completed, and the target has again stopped all
   42676 threads in all attached processes.  This is the default all-stop mode
   42677 behavior, but the remote protocol also supports @value{GDBN}'s non-stop 
   42678 execution mode; see @ref{Remote Non-Stop}, for details.
   42679 
   42680 @var{packet-data} consists of a sequence of characters with the
   42681 exception of @samp{#} and @samp{$} (see @samp{X} packet for additional
   42682 exceptions).
   42683 
   42684 @cindex remote protocol, field separator
   42685 Fields within the packet should be separated using @samp{,} @samp{;} or
   42686 @samp{:}.  Except where otherwise noted all numbers are represented in
   42687 @sc{hex} with leading zeros suppressed.
   42688 
   42689 Implementors should note that prior to @value{GDBN} 5.0, the character
   42690 @samp{:} could not appear as the third character in a packet (as it
   42691 would potentially conflict with the @var{sequence-id}).
   42692 
   42693 @cindex remote protocol, binary data
   42694 @anchor{Binary Data}
   42695 Binary data in most packets is encoded as two hexadecimal
   42696 digits per byte of binary data.  This allowed the traditional remote
   42697 protocol to work over connections which were only seven-bit clean.
   42698 Some packets designed more recently assume an eight-bit clean
   42699 connection, and use a more efficient encoding to send and receive
   42700 binary data.
   42701 
   42702 The binary data representation uses @code{7d} (@sc{ascii} @samp{@}})
   42703 as an escape character.  Any escaped byte is transmitted as the escape
   42704 character followed by the original character XORed with @code{0x20}.
   42705 For example, the byte @code{0x7d} would be transmitted as the two
   42706 bytes @code{0x7d 0x5d}.  The bytes @code{0x23} (@sc{ascii} @samp{#}),
   42707 @code{0x24} (@sc{ascii} @samp{$}), and @code{0x7d} (@sc{ascii}
   42708 @samp{@}}) must always be escaped.  Responses sent by the stub
   42709 must also escape @code{0x2a} (@sc{ascii} @samp{*}), so that it
   42710 is not interpreted as the start of a run-length encoded sequence
   42711 (described next).
   42712 
   42713 Response @var{data} can be run-length encoded to save space.
   42714 Run-length encoding replaces runs of identical characters with one
   42715 instance of the repeated character, followed by a @samp{*} and a
   42716 repeat count.  The repeat count is itself sent encoded, to avoid
   42717 binary characters in @var{data}: a value of @var{n} is sent as
   42718 @code{@var{n}+29}.  For a repeat count greater or equal to 3, this
   42719 produces a printable @sc{ascii} character, e.g.@: a space (@sc{ascii}
   42720 code 32) for a repeat count of 3.  (This is because run-length
   42721 encoding starts to win for counts 3 or more.)  Thus, for example,
   42722 @samp{0* } is a run-length encoding of ``0000'': the space character
   42723 after @samp{*} means repeat the leading @code{0} @w{@code{32 - 29 =
   42724 3}} more times.
   42725 
   42726 The printable characters @samp{#} and @samp{$} or with a numeric value
   42727 greater than 126 must not be used.  Runs of six repeats (@samp{#}) or
   42728 seven repeats (@samp{$}) can be expanded using a repeat count of only
   42729 five (@samp{"}).  For example, @samp{00000000} can be encoded as
   42730 @samp{0*"00}.
   42731 
   42732 @xref{Standard Replies} for standard error responses, and how to
   42733 respond indicating a command is not supported.
   42734 
   42735 In describing packets (commands and responses), each description has a
   42736 template showing the overall syntax, followed by an explanation of the
   42737 packet's meaning.  We include spaces in some of the templates for
   42738 clarity; these are not part of the packet's syntax.  No @value{GDBN}
   42739 packet uses spaces to separate its components.  For example, a
   42740 template like @samp{foo @var{bar} @var{baz}} describes a packet
   42741 beginning with the three ASCII bytes @samp{foo}, followed by a
   42742 @var{bar}, followed directly by a @var{baz}.  @value{GDBN} does not
   42743 transmit a space character between the @samp{foo} and the @var{bar},
   42744 or between the @var{bar} and the @var{baz}.
   42745 
   42746 We place optional portions of a packet in [square brackets];
   42747 for example, a template like @samp{c @r{[}@var{addr}@r{]}} describes a
   42748 packet beginning with the single ASCII character @samp{c}, possibly
   42749 followed by an @var{addr}.
   42750 
   42751 At a minimum, a stub is required to support the @samp{?} command to
   42752 tell @value{GDBN} the reason for halting, @samp{g} and @samp{G}
   42753 commands for register access, and the @samp{m} and @samp{M} commands
   42754 for memory access.  Stubs that only control single-threaded targets
   42755 can implement run control with the @samp{c} (continue) command, and if
   42756 the target architecture supports hardware-assisted single-stepping,
   42757 the @samp{s} (step) command.  Stubs that support multi-threading
   42758 targets should support the @samp{vCont} command.  All other commands
   42759 are optional.
   42760 
   42761 @node Standard Replies
   42762 @section Standard Replies
   42763 @cindex standard responses for remote packets
   42764 @cindex remote packets, standard replies
   42765 
   42766 The remote protocol specifies a few standard replies.  All commands
   42767 support these, except as noted in the individual command descriptions.
   42768 
   42769 @table @asis
   42770 
   42771 @item empty response
   42772 
   42773 @cindex empty response, for unsupported packets
   42774 @cindex unsupported packets, empty response for
   42775 An empty response (raw character sequence @samp{$#00}) means the
   42776 @var{command} is not supported by the stub.  This way it is possible
   42777 to extend the protocol.  A newer @value{GDBN} can tell if a command is
   42778 supported based on that response (but see also @ref{qSupported}).
   42779 
   42780 @item @samp{E @var{xx}}
   42781 An error has occurred; @var{xx} is a two-digit hexadecimal error
   42782 number.  In almost all cases, the protocol does not specify the
   42783 meaning of the error numbers; @value{GDBN} usually ignores the
   42784 numbers, or displays them to the user without further interpretation.
   42785 
   42786 @anchor{textual error reply}
   42787 @item @samp{E.@var{errtext}}
   42788 An error has occurred; @var{errtext} is the textual error message,
   42789 encoded in @sc{ascii}.
   42790 
   42791 @end table
   42792 
   42793 @node Packets
   42794 @section Packets
   42795 
   42796 The following table provides a complete list of all currently defined
   42797 @var{command}s and their corresponding response @var{data}.
   42798 @xref{File-I/O Remote Protocol Extension}, for details about the File
   42799 I/O extension of the remote protocol.
   42800 
   42801 Each packet's description has a template showing the packet's overall
   42802 syntax, followed by an explanation of the packet's meaning.  We
   42803 include spaces in some of the templates for clarity; these are not
   42804 part of the packet's syntax.  No @value{GDBN} packet uses spaces to
   42805 separate its components.  For example, a template like @samp{foo
   42806 @var{bar} @var{baz}} describes a packet beginning with the three ASCII
   42807 bytes @samp{foo}, followed by a @var{bar}, followed directly by a
   42808 @var{baz}.  @value{GDBN} does not transmit a space character between the
   42809 @samp{foo} and the @var{bar}, or between the @var{bar} and the
   42810 @var{baz}.
   42811 
   42812 @cindex @var{thread-id}, in remote protocol
   42813 @anchor{thread-id syntax} 
   42814 Several packets and replies include a @var{thread-id} field to identify
   42815 a thread.  Normally these are positive numbers with a target-specific
   42816 interpretation, formatted as big-endian hex strings.  A @var{thread-id}
   42817 can also be a literal @samp{-1} to indicate all threads, or @samp{0} to
   42818 pick any thread.
   42819 
   42820 In addition, the remote protocol supports a multiprocess feature in
   42821 which the @var{thread-id} syntax is extended to optionally include both
   42822 process and thread ID fields, as @samp{p@var{pid}.@var{tid}}.
   42823 The @var{pid} (process) and @var{tid} (thread) components each have the
   42824 format described above: a positive number with target-specific
   42825 interpretation formatted as a big-endian hex string, literal @samp{-1}
   42826 to indicate all processes or threads (respectively), or @samp{0} to
   42827 indicate an arbitrary process or thread.  Specifying just a process, as
   42828 @samp{p@var{pid}}, is equivalent to @samp{p@var{pid}.-1}.  It is an
   42829 error to specify all processes but a specific thread, such as
   42830 @samp{p-1.@var{tid}}.  Note that the @samp{p} prefix is @emph{not} used
   42831 for those packets and replies explicitly documented to include a process
   42832 ID, rather than a @var{thread-id}.
   42833 
   42834 The multiprocess @var{thread-id} syntax extensions are only used if both
   42835 @value{GDBN} and the stub report support for the @samp{multiprocess}
   42836 feature using @samp{qSupported}.  @xref{multiprocess extensions}, for
   42837 more information.
   42838 
   42839 Note that all packet forms beginning with an upper- or lower-case
   42840 letter, other than those described here, are reserved for future use.
   42841 
   42842 Here are the packet descriptions.
   42843 
   42844 @table @samp
   42845 
   42846 @item !
   42847 @cindex @samp{!} packet
   42848 @anchor{extended mode}
   42849 Enable extended mode.  In extended mode, the remote server is made
   42850 persistent.  The @samp{R} packet is used to restart the program being
   42851 debugged.
   42852 
   42853 Reply:
   42854 @table @samp
   42855 @item OK
   42856 The remote target both supports and has enabled extended mode.
   42857 @end table
   42858 
   42859 @item ?
   42860 @cindex @samp{?} packet
   42861 @anchor{? packet}
   42862 This is sent when connection is first established to query the reason
   42863 the target halted.  The reply is the same as for step and continue.
   42864 This packet has a special interpretation when the target is in
   42865 non-stop mode; see @ref{Remote Non-Stop}.
   42866 
   42867 Reply:
   42868 @xref{Stop Reply Packets}, for the reply specifications.
   42869 
   42870 @item A @var{arglen},@var{argnum},@var{arg},@dots{}
   42871 @cindex @samp{A} packet
   42872 Initialized @code{argv[]} array passed into program. @var{arglen}
   42873 specifies the number of bytes in the hex encoded byte stream
   42874 @var{arg}.  See @code{gdbserver} for more details.
   42875 
   42876 Reply:
   42877 @table @samp
   42878 @item OK
   42879 The arguments were set.
   42880 @end table
   42881 
   42882 @item b @var{baud}
   42883 @cindex @samp{b} packet
   42884 (Don't use this packet; its behavior is not well-defined.)
   42885 Change the serial line speed to @var{baud}.
   42886 
   42887 JTC: @emph{When does the transport layer state change?  When it's
   42888 received, or after the ACK is transmitted.  In either case, there are
   42889 problems if the command or the acknowledgment packet is dropped.}
   42890 
   42891 Stan: @emph{If people really wanted to add something like this, and get
   42892 it working for the first time, they ought to modify ser-unix.c to send
   42893 some kind of out-of-band message to a specially-setup stub and have the
   42894 switch happen "in between" packets, so that from remote protocol's point
   42895 of view, nothing actually happened.}
   42896 
   42897 @item B @var{addr},@var{mode}
   42898 @cindex @samp{B} packet
   42899 Set (@var{mode} is @samp{S}) or clear (@var{mode} is @samp{C}) a
   42900 breakpoint at @var{addr}.
   42901 
   42902 Don't use this packet.  Use the @samp{Z} and @samp{z} packets instead
   42903 (@pxref{insert breakpoint or watchpoint packet}).
   42904 
   42905 @cindex @samp{bc} packet
   42906 @anchor{bc}
   42907 @item bc
   42908 Backward continue.  Execute the target system in reverse.  No parameter.
   42909 @xref{Reverse Execution}, for more information.
   42910 
   42911 Reply:
   42912 @xref{Stop Reply Packets}, for the reply specifications.
   42913 
   42914 @cindex @samp{bs} packet
   42915 @anchor{bs}
   42916 @item bs
   42917 Backward single step.  Execute one instruction in reverse.  No parameter.
   42918 @xref{Reverse Execution}, for more information.
   42919 
   42920 Reply:
   42921 @xref{Stop Reply Packets}, for the reply specifications.
   42922 
   42923 @item c @r{[}@var{addr}@r{]}
   42924 @cindex @samp{c} packet
   42925 Continue at @var{addr}, which is the address to resume.  If @var{addr}
   42926 is omitted, resume at current address.
   42927 
   42928 This packet is deprecated for multi-threading support.  @xref{vCont
   42929 packet}.
   42930 
   42931 Reply:
   42932 @xref{Stop Reply Packets}, for the reply specifications.
   42933 
   42934 @item C @var{sig}@r{[};@var{addr}@r{]}
   42935 @cindex @samp{C} packet
   42936 Continue with signal @var{sig} (hex signal number).  If
   42937 @samp{;@var{addr}} is omitted, resume at same address.
   42938 
   42939 This packet is deprecated for multi-threading support.  @xref{vCont
   42940 packet}.
   42941 
   42942 Reply:
   42943 @xref{Stop Reply Packets}, for the reply specifications.
   42944 
   42945 @item d
   42946 @cindex @samp{d} packet
   42947 Toggle debug flag.
   42948 
   42949 Don't use this packet; instead, define a general set packet
   42950 (@pxref{General Query Packets}).
   42951 
   42952 @item D
   42953 @itemx D;@var{pid}
   42954 @cindex @samp{D} packet
   42955 The first form of the packet is used to detach @value{GDBN} from the 
   42956 remote system.  It is sent to the remote target
   42957 before @value{GDBN} disconnects via the @code{detach} command.
   42958 
   42959 The second form, including a process ID, is used when multiprocess
   42960 protocol extensions are enabled (@pxref{multiprocess extensions}), to
   42961 detach only a specific process.  The @var{pid} is specified as a
   42962 big-endian hex string.
   42963 
   42964 Reply:
   42965 @table @samp
   42966 @item OK
   42967 for success
   42968 @end table
   42969 
   42970 @item F @var{RC},@var{EE},@var{CF};@var{XX}
   42971 @cindex @samp{F} packet
   42972 A reply from @value{GDBN} to an @samp{F} packet sent by the target.
   42973 This is part of the File-I/O protocol extension.  @xref{File-I/O
   42974 Remote Protocol Extension}, for the specification.
   42975 
   42976 @item g
   42977 @anchor{read registers packet}
   42978 @cindex @samp{g} packet
   42979 Read general registers.
   42980 
   42981 Reply:
   42982 @table @samp
   42983 @item @var{XX@dots{}}
   42984 Each byte of register data is described by two hex digits.  The bytes
   42985 with the register are transmitted in target byte order.  The size of
   42986 each register and their position within the @samp{g} packet are
   42987 determined by the target description (@pxref{Target Descriptions}); in
   42988 the absence of a target description, this is done using code internal
   42989 to @value{GDBN}; typically this is some customary register layout for
   42990 the architecture in question.
   42991 
   42992 When reading registers, the stub may also return a string of literal
   42993 @samp{x}'s in place of the register data digits, to indicate that the
   42994 corresponding register's value is unavailable.  For example, when
   42995 reading registers from a trace frame (@pxref{Analyze Collected
   42996 Data,,Using the Collected Data}), this means that the register has not
   42997 been collected in the trace frame.  When reading registers from a live
   42998 program, this indicates that the stub has no means to access the
   42999 register contents, even though the corresponding register is known to
   43000 exist.  Note that if a register truly does not exist on the target,
   43001 then it is better to not include it in the target description in the
   43002 first place.
   43003 
   43004 For example, for an architecture with 4 registers of
   43005 4 bytes each, the following reply indicates to @value{GDBN} that
   43006 registers 0 and 2 are unavailable, while registers 1 and 3
   43007 are available, and both have zero value:
   43008 
   43009 @smallexample
   43010 -> @code{g}
   43011 <- @code{xxxxxxxx00000000xxxxxxxx00000000}
   43012 @end smallexample
   43013 
   43014 @end table
   43015 
   43016 @item G @var{XX@dots{}}
   43017 @cindex @samp{G} packet
   43018 Write general registers.  @xref{read registers packet}, for a
   43019 description of the @var{XX@dots{}} data.
   43020 
   43021 Reply:
   43022 @table @samp
   43023 @item OK
   43024 for success
   43025 @end table
   43026 
   43027 @item H @var{op} @var{thread-id}
   43028 @cindex @samp{H} packet
   43029 Set thread for subsequent operations (@samp{m}, @samp{M}, @samp{g},
   43030 @samp{G}, et.al.).  Depending on the operation to be performed, @var{op}
   43031 should be @samp{c} for step and continue operations (note that this
   43032 is deprecated, supporting the @samp{vCont} command is a better
   43033 option), and @samp{g} for other operations.  The thread designator
   43034 @var{thread-id} has the format and interpretation described in
   43035 @ref{thread-id syntax}.
   43036 
   43037 Reply:
   43038 @table @samp
   43039 @item OK
   43040 for success
   43041 @end table
   43042 
   43043 @c FIXME: JTC:
   43044 @c   'H': How restrictive (or permissive) is the thread model.  If a
   43045 @c        thread is selected and stopped, are other threads allowed
   43046 @c        to continue to execute?  As I mentioned above, I think the
   43047 @c        semantics of each command when a thread is selected must be
   43048 @c        described.  For example:
   43049 @c
   43050 @c        'g':    If the stub supports threads and a specific thread is
   43051 @c                selected, returns the register block from that thread;
   43052 @c                otherwise returns current registers.
   43053 @c
   43054 @c        'G'     If the stub supports threads and a specific thread is
   43055 @c                selected, sets the registers of the register block of
   43056 @c                that thread; otherwise sets current registers.
   43057 
   43058 @item i @r{[}@var{addr}@r{[},@var{nnn}@r{]]}
   43059 @anchor{cycle step packet}
   43060 @cindex @samp{i} packet
   43061 Step the remote target by a single clock cycle.  If @samp{,@var{nnn}} is
   43062 present, cycle step @var{nnn} cycles.  If @var{addr} is present, cycle
   43063 step starting at that address.
   43064 
   43065 @item I
   43066 @cindex @samp{I} packet
   43067 Signal, then cycle step.  @xref{step with signal packet}.  @xref{cycle
   43068 step packet}.
   43069 
   43070 @item k
   43071 @cindex @samp{k} packet
   43072 Kill request.
   43073 
   43074 The exact effect of this packet is not specified.
   43075 
   43076 For a bare-metal target, it may power cycle or reset the target
   43077 system.  For that reason, the @samp{k} packet has no reply.
   43078 
   43079 For a single-process target, it may kill that process if possible.
   43080 
   43081 A multiple-process target may choose to kill just one process, or all
   43082 that are under @value{GDBN}'s control.  For more precise control, use
   43083 the vKill packet (@pxref{vKill packet}).
   43084 
   43085 If the target system immediately closes the connection in response to
   43086 @samp{k}, @value{GDBN} does not consider the lack of packet
   43087 acknowledgment to be an error, and assumes the kill was successful.
   43088 
   43089 If connected using @kbd{target extended-remote}, and the target does
   43090 not close the connection in response to a kill request, @value{GDBN}
   43091 probes the target state as if a new connection was opened
   43092 (@pxref{? packet}).
   43093 
   43094 @item m @var{addr},@var{length}
   43095 @cindex @samp{m} packet
   43096 Read @var{length} addressable memory units starting at address @var{addr}
   43097 (@pxref{addressable memory unit}).  Note that @var{addr} does not have to
   43098 be aligned to any particular boundary.
   43099 
   43100 @cindex alignment of remote memory accesses
   43101 @cindex size of remote memory accesses
   43102 @cindex memory, alignment and size of remote accesses
   43103 The stub need not use any particular size or alignment when gathering
   43104 data from memory for the response; even if @var{addr} is word-aligned
   43105 and @var{length} is a multiple of the word size, the stub is free to
   43106 use byte accesses, or not.  For this reason, this packet may not be
   43107 suitable for accessing memory-mapped I/O devices.
   43108 
   43109 Reply:
   43110 @table @samp
   43111 @item @var{XX@dots{}}
   43112 Memory contents; each byte is transmitted as a two-digit hexadecimal number.
   43113 The reply may contain fewer addressable memory units than requested if the
   43114 server was reading from a trace frame memory and was able to read only part
   43115 of the region of memory.
   43116 @end table
   43117 
   43118 Unlike most packets, this packet does not support
   43119 @samp{E.@var{errtext}}-style textual error replies (@pxref{textual
   43120 error reply}) by default.  Stubs should be careful to only send such a
   43121 reply if @value{GDBN} reported support for it with the
   43122 @code{error-message} feature (@pxref{error-message}).
   43123 
   43124 @item M @var{addr},@var{length}:@var{XX@dots{}}
   43125 @cindex @samp{M} packet
   43126 Write @var{length} addressable memory units starting at address @var{addr}
   43127 (@pxref{addressable memory unit}).  The data is given by @var{XX@dots{}}; each
   43128 byte is transmitted as a two-digit hexadecimal number.
   43129 
   43130 Reply:
   43131 @table @samp
   43132 @item OK
   43133 All the data was written successfully.  (If only part of the data was
   43134 written, this command returns an error.)
   43135 @end table
   43136 
   43137 @item p @var{n}
   43138 @cindex @samp{p} packet
   43139 Read the value of register @var{n}; @var{n} is in hex.
   43140 @xref{read registers packet}, for a description of how the returned
   43141 register value is encoded.
   43142 
   43143 Reply:
   43144 @table @samp
   43145 @item @var{XX@dots{}}
   43146 the register's value
   43147 @end table
   43148 
   43149 @item P @var{n@dots{}}=@var{r@dots{}}
   43150 @anchor{write register packet}
   43151 @cindex @samp{P} packet
   43152 Write register @var{n@dots{}} with value @var{r@dots{}}.  The register
   43153 number @var{n} is in hexadecimal, and @var{r@dots{}} contains two hex
   43154 digits for each byte in the register (target byte order).
   43155 
   43156 Reply:
   43157 @table @samp
   43158 @item OK
   43159 for success
   43160 @end table
   43161 
   43162 @item q @var{name} @var{params}@dots{}
   43163 @itemx Q @var{name} @var{params}@dots{}
   43164 @cindex @samp{q} packet
   43165 @cindex @samp{Q} packet
   43166 General query (@samp{q}) and set (@samp{Q}).  These packets are
   43167 described fully in @ref{General Query Packets}.
   43168 
   43169 @item r
   43170 @cindex @samp{r} packet
   43171 Reset the entire system.
   43172 
   43173 Don't use this packet; use the @samp{R} packet instead.
   43174 
   43175 @item R @var{XX}
   43176 @cindex @samp{R} packet
   43177 Restart the program being debugged.  The @var{XX}, while needed, is ignored.
   43178 This packet is only available in extended mode (@pxref{extended mode}).
   43179 
   43180 The @samp{R} packet has no reply.
   43181 
   43182 @item s @r{[}@var{addr}@r{]}
   43183 @cindex @samp{s} packet
   43184 Single step, resuming at @var{addr}.  If
   43185 @var{addr} is omitted, resume at same address.
   43186 
   43187 This packet is deprecated for multi-threading support.  @xref{vCont
   43188 packet}.
   43189 
   43190 Reply:
   43191 @xref{Stop Reply Packets}, for the reply specifications.
   43192 
   43193 @item S @var{sig}@r{[};@var{addr}@r{]}
   43194 @anchor{step with signal packet}
   43195 @cindex @samp{S} packet
   43196 Step with signal.  This is analogous to the @samp{C} packet, but
   43197 requests a single-step, rather than a normal resumption of execution.
   43198 
   43199 This packet is deprecated for multi-threading support.  @xref{vCont
   43200 packet}.
   43201 
   43202 Reply:
   43203 @xref{Stop Reply Packets}, for the reply specifications.
   43204 
   43205 @item t @var{addr}:@var{PP},@var{MM}
   43206 @cindex @samp{t} packet
   43207 Search backwards starting at address @var{addr} for a match with pattern
   43208 @var{PP} and mask @var{MM}, both of which are are 4 byte long.
   43209 There must be at least 3 digits in @var{addr}.
   43210 
   43211 @item T @var{thread-id}
   43212 @cindex @samp{T} packet
   43213 Find out if the thread @var{thread-id} is alive.  @xref{thread-id syntax}.
   43214 
   43215 Reply:
   43216 @table @samp
   43217 @item OK
   43218 thread is still alive
   43219 @end table
   43220 
   43221 @item v
   43222 Packets starting with @samp{v} are identified by a multi-letter name,
   43223 up to the first @samp{;} or @samp{?} (or the end of the packet).
   43224 
   43225 @item vAttach;@var{pid}
   43226 @cindex @samp{vAttach} packet
   43227 Attach to a new process with the specified process ID @var{pid}.
   43228 The process ID is a
   43229 hexadecimal integer identifying the process.  In all-stop mode, all
   43230 threads in the attached process are stopped; in non-stop mode, it may be
   43231 attached without being stopped if that is supported by the target.
   43232 
   43233 @c In non-stop mode, on a successful vAttach, the stub should set the
   43234 @c current thread to a thread of the newly-attached process.  After
   43235 @c attaching, GDB queries for the attached process's thread ID with qC.
   43236 @c Also note that, from a user perspective, whether or not the 
   43237 @c target is stopped on attach in non-stop mode depends on whether you 
   43238 @c use the foreground or background version of the attach command, not 
   43239 @c on what vAttach does; GDB does the right thing with respect to either 
   43240 @c stopping or restarting threads.
   43241 
   43242 This packet is only available in extended mode (@pxref{extended mode}).
   43243 
   43244 Reply:
   43245 @table @samp
   43246 @item @r{Any stop packet}
   43247 for success in all-stop mode (@pxref{Stop Reply Packets})
   43248 @item OK
   43249 for success in non-stop mode (@pxref{Remote Non-Stop})
   43250 @end table
   43251 
   43252 @item vCont@r{[};@var{action}@r{[}:@var{thread-id}@r{]]}@dots{}
   43253 @cindex @samp{vCont} packet
   43254 @anchor{vCont packet}
   43255 Resume the inferior, specifying different actions for each thread.
   43256 
   43257 For each inferior thread, the leftmost action with a matching
   43258 @var{thread-id} is applied.  Threads that don't match any action
   43259 remain in their current state.  Thread IDs are specified using the
   43260 syntax described in @ref{thread-id syntax}.  If multiprocess
   43261 extensions (@pxref{multiprocess extensions}) are supported, actions
   43262 can be specified to match all threads in a process by using the
   43263 @samp{p@var{pid}.-1} form of the @var{thread-id}.  An action with no
   43264 @var{thread-id} matches all threads.  Specifying no actions is an
   43265 error.
   43266 
   43267 Currently supported actions are:
   43268 
   43269 @table @samp
   43270 @item c
   43271 Continue.
   43272 @item C @var{sig}
   43273 Continue with signal @var{sig}.  The signal @var{sig} should be two hex digits.
   43274 @item s
   43275 Step.
   43276 @item S @var{sig}
   43277 Step with signal @var{sig}.  The signal @var{sig} should be two hex digits.
   43278 @item t
   43279 Stop.
   43280 @item r @var{start},@var{end}
   43281 Step once, and then keep stepping as long as the thread stops at
   43282 addresses between @var{start} (inclusive) and @var{end} (exclusive).
   43283 The remote stub reports a stop reply when either the thread goes out
   43284 of the range or is stopped due to an unrelated reason, such as hitting
   43285 a breakpoint.  @xref{range stepping}.
   43286 
   43287 If the range is empty (@var{start} == @var{end}), then the action
   43288 becomes equivalent to the @samp{s} action.  In other words,
   43289 single-step once, and report the stop (even if the stepped instruction
   43290 jumps to @var{start}).
   43291 
   43292 (A stop reply may be sent at any point even if the PC is still within
   43293 the stepping range; for example, it is valid to implement this packet
   43294 in a degenerate way as a single instruction step operation.)
   43295 
   43296 @end table
   43297 
   43298 The optional argument @var{addr} normally associated with the 
   43299 @samp{c}, @samp{C}, @samp{s}, and @samp{S} packets is
   43300 not supported in @samp{vCont}.
   43301 
   43302 The @samp{t} action is only relevant in non-stop mode
   43303 (@pxref{Remote Non-Stop}) and may be ignored by the stub otherwise.
   43304 A stop reply should be generated for any affected thread not already stopped.
   43305 When a thread is stopped by means of a @samp{t} action,
   43306 the corresponding stop reply should indicate that the thread has stopped with
   43307 signal @samp{0}, regardless of whether the target uses some other signal
   43308 as an implementation detail.
   43309 
   43310 The server must ignore @samp{c}, @samp{C}, @samp{s}, @samp{S}, and
   43311 @samp{r} actions for threads that are already running.  Conversely,
   43312 the server must ignore @samp{t} actions for threads that are already
   43313 stopped.
   43314 
   43315 @emph{Note:} In non-stop mode, a thread is considered running until
   43316 @value{GDBN} acknowledges an asynchronous stop notification for it with
   43317 the @samp{vStopped} packet (@pxref{Remote Non-Stop}).
   43318 
   43319 The stub must support @samp{vCont} if it reports support for
   43320 multiprocess extensions (@pxref{multiprocess extensions}).
   43321 
   43322 Reply:
   43323 @xref{Stop Reply Packets}, for the reply specifications.
   43324 
   43325 @item vCont?
   43326 @cindex @samp{vCont?} packet
   43327 Request a list of actions supported by the @samp{vCont} packet.
   43328 
   43329 Reply:
   43330 @table @samp
   43331 @item vCont@r{[};@var{action}@dots{}@r{]}
   43332 The @samp{vCont} packet is supported.  Each @var{action} is a supported
   43333 command in the @samp{vCont} packet.
   43334 @end table
   43335 
   43336 @anchor{vCtrlC packet}
   43337 @item vCtrlC
   43338 @cindex @samp{vCtrlC} packet
   43339 Interrupt remote target as if a control-C was pressed on the remote
   43340 terminal.  This is the equivalent to reacting to the @code{^C}
   43341 (@samp{\003}, the control-C character) character in all-stop mode
   43342 while the target is running, except this works in non-stop mode.
   43343 @xref{interrupting remote targets}, for more info on the all-stop
   43344 variant.
   43345 
   43346 Reply:
   43347 @table @samp
   43348 @item OK
   43349 for success
   43350 @end table
   43351 
   43352 @item vFile:@var{operation}:@var{parameter}@dots{}
   43353 @cindex @samp{vFile} packet
   43354 Perform a file operation on the target system.  For details,
   43355 see @ref{Host I/O Packets}.
   43356 
   43357 @item vFlashErase:@var{addr},@var{length}
   43358 @cindex @samp{vFlashErase} packet
   43359 Direct the stub to erase @var{length} bytes of flash starting at
   43360 @var{addr}.  The region may enclose any number of flash blocks, but
   43361 its start and end must fall on block boundaries, as indicated by the
   43362 flash block size appearing in the memory map (@pxref{Memory Map
   43363 Format}).  @value{GDBN} groups flash memory programming operations
   43364 together, and sends a @samp{vFlashDone} request after each group; the
   43365 stub is allowed to delay erase operation until the @samp{vFlashDone}
   43366 packet is received.
   43367 
   43368 Reply:
   43369 @table @samp
   43370 @item OK
   43371 for success
   43372 @end table
   43373 
   43374 @item vFlashWrite:@var{addr}:@var{XX@dots{}}
   43375 @cindex @samp{vFlashWrite} packet
   43376 Direct the stub to write data to flash address @var{addr}.  The data
   43377 is passed in binary form using the same encoding as for the @samp{X}
   43378 packet (@pxref{Binary Data}).  The memory ranges specified by
   43379 @samp{vFlashWrite} packets preceding a @samp{vFlashDone} packet must
   43380 not overlap, and must appear in order of increasing addresses
   43381 (although @samp{vFlashErase} packets for higher addresses may already
   43382 have been received; the ordering is guaranteed only between
   43383 @samp{vFlashWrite} packets).  If a packet writes to an address that was
   43384 neither erased by a preceding @samp{vFlashErase} packet nor by some other
   43385 target-specific method, the results are unpredictable.
   43386 
   43387 
   43388 Reply:
   43389 @table @samp
   43390 @item OK
   43391 for success
   43392 @item E.memtype
   43393 for vFlashWrite addressing non-flash memory
   43394 @end table
   43395 
   43396 @item vFlashDone
   43397 @cindex @samp{vFlashDone} packet
   43398 Indicate to the stub that flash programming operation is finished.
   43399 The stub is permitted to delay or batch the effects of a group of
   43400 @samp{vFlashErase} and @samp{vFlashWrite} packets until a
   43401 @samp{vFlashDone} packet is received.  The contents of the affected
   43402 regions of flash memory are unpredictable until the @samp{vFlashDone}
   43403 request is completed.
   43404 
   43405 @item vKill;@var{pid}
   43406 @cindex @samp{vKill} packet
   43407 @anchor{vKill packet}
   43408 Kill the process with the specified process ID @var{pid}, which is a
   43409 hexadecimal integer identifying the process.  This packet is used in
   43410 preference to @samp{k} when multiprocess protocol extensions are
   43411 supported; see @ref{multiprocess extensions}.
   43412 
   43413 Reply:
   43414 @table @samp
   43415 @item OK
   43416 for success
   43417 @end table
   43418 
   43419 @item vMustReplyEmpty
   43420 @cindex @samp{vMustReplyEmpty} packet
   43421 The correct reply to an unknown @samp{v} packet is to return the empty
   43422 string, however, some older versions of @command{gdbserver} would
   43423 incorrectly return @samp{OK} for unknown @samp{v} packets.
   43424 
   43425 The @samp{vMustReplyEmpty} is used as a feature test to check how
   43426 @command{gdbserver} handles unknown packets, it is important that this
   43427 packet be handled in the same way as other unknown @samp{v} packets.
   43428 If this packet is handled differently to other unknown @samp{v}
   43429 packets then it is possible that @value{GDBN} may run into problems in
   43430 other areas, specifically around use of @samp{vFile:setfs:}.
   43431 
   43432 @item vRun;@var{filename}@r{[};@var{argument}@r{]}@dots{}
   43433 @cindex @samp{vRun} packet
   43434 Run the program @var{filename}, passing it each @var{argument} on its
   43435 command line.  The file and arguments are hex-encoded strings.  If
   43436 @var{filename} is an empty string, the stub may use a default program
   43437 (e.g.@: the last program run).  The program is created in the stopped
   43438 state.
   43439 
   43440 @c FIXME:  What about non-stop mode?
   43441 
   43442 This packet is only available in extended mode (@pxref{extended mode}).
   43443 
   43444 Reply:
   43445 @table @samp
   43446 @item @r{Any stop packet}
   43447 for success (@pxref{Stop Reply Packets})
   43448 @end table
   43449 
   43450 @item vStopped
   43451 @cindex @samp{vStopped} packet
   43452 @xref{Notification Packets}.
   43453 
   43454 @item x @var{addr},@var{length}
   43455 @anchor{x packet}
   43456 @cindex @samp{x} packet
   43457 Read @var{length} addressable memory units starting at address @var{addr}
   43458 (@pxref{addressable memory unit}).  Note that @var{addr} does not have to
   43459 be aligned to any particular boundary.
   43460 
   43461 @cindex alignment of remote memory accesses
   43462 @cindex size of remote memory accesses
   43463 @cindex memory, alignment and size of remote accesses
   43464 The stub need not use any particular size or alignment when gathering
   43465 data from memory for the response; even if @var{addr} is word-aligned
   43466 and @var{length} is a multiple of the word size, the stub is free to
   43467 use byte accesses, or not.  For this reason, this packet may not be
   43468 suitable for accessing memory-mapped I/O devices.
   43469 
   43470 @value{GDBN} will only use this packet if the stub reports the
   43471 @samp{binary-upload} feature is supported in its @samp{qSupported}
   43472 reply (@pxref{qSupported}).
   43473 
   43474 Reply:
   43475 @table @samp
   43476 @item b @var{XX@dots{}}
   43477 Memory contents as binary data (@pxref{Binary Data}).
   43478 The reply may contain fewer addressable memory units than requested if the
   43479 server was reading from a trace frame memory and was able to read only part
   43480 of the region of memory.
   43481 @item E @var{NN}
   43482 for an error
   43483 @end table
   43484 
   43485 @item X @var{addr},@var{length}:@var{XX@dots{}}
   43486 @anchor{X packet}
   43487 @cindex @samp{X} packet
   43488 Write data to memory, where the data is transmitted in binary.
   43489 Memory is specified by its address @var{addr} and number of addressable memory
   43490 units @var{length} (@pxref{addressable memory unit});
   43491 @samp{@var{XX}@dots{}} is binary data (@pxref{Binary Data}).
   43492 
   43493 Reply:
   43494 @table @samp
   43495 @item OK
   43496 for success
   43497 @end table
   43498 
   43499 @item z @var{type},@var{addr},@var{kind}
   43500 @itemx Z @var{type},@var{addr},@var{kind}
   43501 @anchor{insert breakpoint or watchpoint packet}
   43502 @cindex @samp{z} packet
   43503 @cindex @samp{Z} packets
   43504 Insert (@samp{Z}) or remove (@samp{z}) a @var{type} breakpoint or
   43505 watchpoint starting at address @var{address} of kind @var{kind}.
   43506 
   43507 Each breakpoint and watchpoint packet @var{type} is documented
   43508 separately.
   43509 
   43510 @emph{Implementation notes: A remote target shall return an empty string
   43511 for an unrecognized breakpoint or watchpoint packet @var{type}.  A
   43512 remote target shall support either both or neither of a given
   43513 @samp{Z@var{type}@dots{}} and @samp{z@var{type}@dots{}} packet pair.  To
   43514 avoid potential problems with duplicate packets, the operations should
   43515 be implemented in an idempotent way.}
   43516 
   43517 @item z0,@var{addr},@var{kind}
   43518 @itemx Z0,@var{addr},@var{kind}@r{[};@var{cond_list}@dots{}@r{]}@r{[};cmds:@var{persist},@var{cmd_list}@dots{}@r{]}
   43519 @cindex @samp{z0} packet
   43520 @cindex @samp{Z0} packet
   43521 Insert (@samp{Z0}) or remove (@samp{z0}) a software breakpoint at address
   43522 @var{addr} of type @var{kind}.
   43523 
   43524 A software breakpoint is implemented by replacing the instruction at
   43525 @var{addr} with a software breakpoint or trap instruction.  The
   43526 @var{kind} is target-specific and typically indicates the size of the
   43527 breakpoint in bytes that should be inserted.  E.g., the @sc{arm} and
   43528 @sc{mips} can insert either a 2 or 4 byte breakpoint.  Some
   43529 architectures have additional meanings for @var{kind}
   43530 (@pxref{Architecture-Specific Protocol Details}); if no
   43531 architecture-specific value is being used, it should be @samp{0}.
   43532 @var{kind} is hex-encoded.  @var{cond_list} is an optional list of
   43533 conditional expressions in bytecode form that should be evaluated on
   43534 the target's side.  These are the conditions that should be taken into
   43535 consideration when deciding if the breakpoint trigger should be
   43536 reported back to @value{GDBN}.
   43537 
   43538 See also the @samp{swbreak} stop reason (@pxref{swbreak stop reason})
   43539 for how to best report a software breakpoint event to @value{GDBN}.
   43540 
   43541 The @var{cond_list} parameter is comprised of a series of expressions,
   43542 concatenated without separators. Each expression has the following form:
   43543 
   43544 @table @samp
   43545 
   43546 @item X @var{len},@var{expr}
   43547 @var{len} is the length of the bytecode expression and @var{expr} is the
   43548 actual conditional expression in bytecode form.
   43549 
   43550 @end table
   43551 
   43552 The optional @var{cmd_list} parameter introduces commands that may be
   43553 run on the target, rather than being reported back to @value{GDBN}.
   43554 The parameter starts with a numeric flag @var{persist}; if the flag is
   43555 nonzero, then the breakpoint may remain active and the commands
   43556 continue to be run even when @value{GDBN} disconnects from the target.
   43557 Following this flag is a series of expressions concatenated with no
   43558 separators.  Each expression has the following form:
   43559 
   43560 @table @samp
   43561 
   43562 @item X @var{len},@var{expr}
   43563 @var{len} is the length of the bytecode expression and @var{expr} is the
   43564 actual commands expression in bytecode form.
   43565 
   43566 @end table
   43567 
   43568 @emph{Implementation note: It is possible for a target to copy or move
   43569 code that contains software breakpoints (e.g., when implementing
   43570 overlays).  The behavior of this packet, in the presence of such a
   43571 target, is not defined.}
   43572 
   43573 Reply:
   43574 @table @samp
   43575 @item OK
   43576 success
   43577 @end table
   43578 
   43579 @item z1,@var{addr},@var{kind}
   43580 @itemx Z1,@var{addr},@var{kind}@r{[};@var{cond_list}@dots{}@r{]}@r{[};cmds:@var{persist},@var{cmd_list}@dots{}@r{]}
   43581 @cindex @samp{z1} packet
   43582 @cindex @samp{Z1} packet
   43583 Insert (@samp{Z1}) or remove (@samp{z1}) a hardware breakpoint at
   43584 address @var{addr}.
   43585 
   43586 A hardware breakpoint is implemented using a mechanism that is not
   43587 dependent on being able to modify the target's memory.  The
   43588 @var{kind}, @var{cond_list}, and @var{cmd_list} arguments have the
   43589 same meaning as in @samp{Z0} packets.
   43590 
   43591 @emph{Implementation note: A hardware breakpoint is not affected by code
   43592 movement.}
   43593 
   43594 Reply:
   43595 @table @samp
   43596 @item OK
   43597 success
   43598 @end table
   43599 
   43600 @item z2,@var{addr},@var{kind}
   43601 @itemx Z2,@var{addr},@var{kind}
   43602 @cindex @samp{z2} packet
   43603 @cindex @samp{Z2} packet
   43604 Insert (@samp{Z2}) or remove (@samp{z2}) a write watchpoint at @var{addr}.
   43605 The number of bytes to watch is specified by @var{kind}.
   43606 
   43607 Reply:
   43608 @table @samp
   43609 @item OK
   43610 success
   43611 @end table
   43612 
   43613 @item z3,@var{addr},@var{kind}
   43614 @itemx Z3,@var{addr},@var{kind}
   43615 @cindex @samp{z3} packet
   43616 @cindex @samp{Z3} packet
   43617 Insert (@samp{Z3}) or remove (@samp{z3}) a read watchpoint at @var{addr}.
   43618 The number of bytes to watch is specified by @var{kind}.
   43619 
   43620 Reply:
   43621 @table @samp
   43622 @item OK
   43623 success
   43624 @end table
   43625 
   43626 @item z4,@var{addr},@var{kind}
   43627 @itemx Z4,@var{addr},@var{kind}
   43628 @cindex @samp{z4} packet
   43629 @cindex @samp{Z4} packet
   43630 Insert (@samp{Z4}) or remove (@samp{z4}) an access watchpoint at @var{addr}.
   43631 The number of bytes to watch is specified by @var{kind}.
   43632 
   43633 Reply:
   43634 @table @samp
   43635 @item OK
   43636 success
   43637 @end table
   43638 
   43639 @end table
   43640 
   43641 @node Stop Reply Packets
   43642 @section Stop Reply Packets
   43643 @cindex stop reply packets
   43644 
   43645 The @samp{C}, @samp{c}, @samp{S}, @samp{s}, @samp{vCont},
   43646 @samp{vAttach}, @samp{vRun}, @samp{vStopped}, and @samp{?} packets can
   43647 receive any of the below as a reply.  Except for @samp{?}
   43648 and @samp{vStopped}, that reply is only returned
   43649 when the target halts.  In the below the exact meaning of @dfn{signal
   43650 number} is defined by the header @file{include/gdb/signals.h} in the
   43651 @value{GDBN} source code.
   43652 
   43653 In non-stop mode, the server will simply reply @samp{OK} to commands
   43654 such as @samp{vCont}; any stop will be the subject of a future
   43655 notification.  @xref{Remote Non-Stop}.
   43656 
   43657 As in the description of request packets, we include spaces in the
   43658 reply templates for clarity; these are not part of the reply packet's
   43659 syntax.  No @value{GDBN} stop reply packet uses spaces to separate its
   43660 components.
   43661 
   43662 @table @samp
   43663 
   43664 @item S @var{AA}
   43665 The program received signal number @var{AA} (a two-digit hexadecimal
   43666 number).  This is equivalent to a @samp{T} response with no
   43667 @var{n}:@var{r} pairs.
   43668 
   43669 @item T @var{AA} @var{n1}:@var{r1};@var{n2}:@var{r2};@dots{}
   43670 @cindex @samp{T} packet reply
   43671 The program received signal number @var{AA} (a two-digit hexadecimal
   43672 number).  This is equivalent to an @samp{S} response, except that the
   43673 @samp{@var{n}:@var{r}} pairs can carry values of important registers
   43674 and other information directly in the stop reply packet, reducing
   43675 round-trip latency.  Single-step and breakpoint traps are reported
   43676 this way.  Each @samp{@var{n}:@var{r}} pair is interpreted as follows:
   43677 
   43678 @itemize @bullet
   43679 @item
   43680 If @var{n} is a hexadecimal number, it is a register number, and the
   43681 corresponding @var{r} gives that register's value.  The data @var{r} is a
   43682 series of bytes in target byte order, with each byte given by a
   43683 two-digit hex number.
   43684 
   43685 @item
   43686 If @var{n} is @samp{thread}, then @var{r} is the thread ID of
   43687 the stopped thread, as specified in @ref{thread-id syntax}.
   43688 
   43689 @item
   43690 If @var{n} is @samp{core}, then @var{r} is the hexadecimal number of
   43691 the core on which the stop event was detected.
   43692 
   43693 @item
   43694 If @var{n} is a recognized @dfn{stop reason}, it describes a more
   43695 specific event that stopped the target.  The currently defined stop
   43696 reasons are listed below.  The @var{aa} should be @samp{05}, the trap
   43697 signal.  At most one stop reason should be present.
   43698 
   43699 @item
   43700 Otherwise, @value{GDBN} should ignore this @samp{@var{n}:@var{r}} pair
   43701 and go on to the next; this allows us to extend the protocol in the
   43702 future.
   43703 @end itemize
   43704 
   43705 The currently defined stop reasons are:
   43706 
   43707 @table @samp
   43708 @item watch
   43709 @itemx rwatch
   43710 @itemx awatch
   43711 The packet indicates a watchpoint hit, and @var{r} is the data address, in
   43712 hex.
   43713 
   43714 @item syscall_entry
   43715 @itemx syscall_return
   43716 The packet indicates a syscall entry or return, and @var{r} is the
   43717 syscall number, in hex.
   43718 
   43719 @cindex shared library events, remote reply
   43720 @item library
   43721 The packet indicates that the loaded libraries have changed.
   43722 @value{GDBN} should use @samp{qXfer:libraries:read} to fetch a new
   43723 list of loaded libraries.  The @var{r} part is ignored.
   43724 
   43725 @cindex replay log events, remote reply
   43726 @item replaylog
   43727 The packet indicates that the target cannot continue replaying 
   43728 logged execution events, because it has reached the end (or the
   43729 beginning when executing backward) of the log.  The value of @var{r}
   43730 will be either @samp{begin} or @samp{end}.  @xref{Reverse Execution}, 
   43731 for more information.
   43732 
   43733 @item swbreak
   43734 @anchor{swbreak stop reason}
   43735 The packet indicates a software breakpoint instruction was executed,
   43736 irrespective of whether it was @value{GDBN} that planted the
   43737 breakpoint or the breakpoint is hardcoded in the program.  The @var{r}
   43738 part must be left empty.
   43739 
   43740 On some architectures, such as x86, at the architecture level, when a
   43741 breakpoint instruction executes the program counter points at the
   43742 breakpoint address plus an offset.  On such targets, the stub is
   43743 responsible for adjusting the PC to point back at the breakpoint
   43744 address.
   43745 
   43746 This packet should not be sent by default; older @value{GDBN} versions
   43747 did not support it.  @value{GDBN} requests it, by supplying an
   43748 appropriate @samp{qSupported} feature (@pxref{qSupported}).  The
   43749 remote stub must also supply the appropriate @samp{qSupported} feature
   43750 indicating support.
   43751 
   43752 This packet is required for correct non-stop mode operation.
   43753 
   43754 @item hwbreak
   43755 The packet indicates the target stopped for a hardware breakpoint.
   43756 The @var{r} part must be left empty.
   43757 
   43758 The same remarks about @samp{qSupported} and non-stop mode above
   43759 apply.
   43760 
   43761 @cindex fork events, remote reply
   43762 @item fork
   43763 The packet indicates that @code{fork} was called, and @var{r} is the
   43764 thread ID of the new child process, as specified in @ref{thread-id
   43765 syntax}.  This packet is only applicable to targets that support fork
   43766 events.
   43767 
   43768 This packet should not be sent by default; older @value{GDBN} versions
   43769 did not support it.  @value{GDBN} requests it, by supplying an
   43770 appropriate @samp{qSupported} feature (@pxref{qSupported}).  The
   43771 remote stub must also supply the appropriate @samp{qSupported} feature
   43772 indicating support.
   43773 
   43774 @cindex vfork events, remote reply
   43775 @item vfork
   43776 The packet indicates that @code{vfork} was called, and @var{r} is the
   43777 thread ID of the new child process, as specified in @ref{thread-id
   43778 syntax}.  This packet is only applicable to targets that support vfork
   43779 events.
   43780 
   43781 This packet should not be sent by default; older @value{GDBN} versions
   43782 did not support it.  @value{GDBN} requests it, by supplying an
   43783 appropriate @samp{qSupported} feature (@pxref{qSupported}).  The
   43784 remote stub must also supply the appropriate @samp{qSupported} feature
   43785 indicating support.
   43786 
   43787 @cindex vforkdone events, remote reply
   43788 @item vforkdone
   43789 The packet indicates that a child process created by a vfork
   43790 has either called @code{exec} or terminated, so that the
   43791 address spaces of the parent and child process are no longer
   43792 shared. The @var{r} part is ignored.  This packet is only
   43793 applicable to targets that support vforkdone events.
   43794 
   43795 This packet should not be sent by default; older @value{GDBN} versions
   43796 did not support it.  @value{GDBN} requests it, by supplying an
   43797 appropriate @samp{qSupported} feature (@pxref{qSupported}).  The
   43798 remote stub must also supply the appropriate @samp{qSupported} feature
   43799 indicating support.
   43800 
   43801 @cindex exec events, remote reply
   43802 @item exec
   43803 The packet indicates that @code{execve} was called, and @var{r}
   43804 is the absolute pathname of the file that was executed, in hex.
   43805 This packet is only applicable to targets that support exec events.
   43806 
   43807 This packet should not be sent by default; older @value{GDBN} versions
   43808 did not support it.  @value{GDBN} requests it, by supplying an
   43809 appropriate @samp{qSupported} feature (@pxref{qSupported}).  The
   43810 remote stub must also supply the appropriate @samp{qSupported} feature
   43811 indicating support.
   43812 
   43813 @cindex thread clone events, remote reply
   43814 @anchor{thread clone event}
   43815 @item clone
   43816 The packet indicates that @code{clone} was called, and @var{r} is the
   43817 thread ID of the new child thread, as specified in @ref{thread-id
   43818 syntax}.  This packet is only applicable to targets that support clone
   43819 events.
   43820 
   43821 This packet should not be sent by default; @value{GDBN} requests it
   43822 with the @ref{QThreadOptions} packet.
   43823 
   43824 @cindex thread create event, remote reply
   43825 @anchor{thread create event}
   43826 @item create
   43827 The packet indicates that the thread was just created.  The new thread
   43828 is stopped until @value{GDBN} sets it running with a resumption packet
   43829 (@pxref{vCont packet}).  This packet should not be sent by default;
   43830 @value{GDBN} requests it with the @ref{QThreadEvents} packet.  See
   43831 also the @samp{w} (@pxref{thread exit event}) remote reply below.  The
   43832 @var{r} part is ignored.
   43833 
   43834 @end table
   43835 
   43836 @item W @var{AA}
   43837 @itemx W @var{AA} ; process:@var{pid}
   43838 The process exited, and @var{AA} is the exit status.  This is only
   43839 applicable to certain targets.
   43840 
   43841 The second form of the response, including the process ID of the
   43842 exited process, can be used only when @value{GDBN} has reported
   43843 support for multiprocess protocol extensions; see @ref{multiprocess
   43844 extensions}.  Both @var{AA} and @var{pid} are formatted as big-endian
   43845 hex strings.
   43846 
   43847 @item X @var{AA}
   43848 @itemx X @var{AA} ; process:@var{pid}
   43849 The process terminated with signal @var{AA}.
   43850 
   43851 The second form of the response, including the process ID of the
   43852 terminated process, can be used only when @value{GDBN} has reported
   43853 support for multiprocess protocol extensions; see @ref{multiprocess
   43854 extensions}.  Both @var{AA} and @var{pid} are formatted as big-endian
   43855 hex strings.
   43856 
   43857 @anchor{thread exit event}
   43858 @cindex thread exit event, remote reply
   43859 @item w @var{AA} ; @var{tid}
   43860 
   43861 The thread exited, and @var{AA} is the exit status.  This response
   43862 should not be sent by default; @value{GDBN} requests it with either
   43863 the @ref{QThreadEvents} or @ref{QThreadOptions} packets.  See also
   43864 @ref{thread create event} above.  @var{AA} is formatted as a
   43865 big-endian hex string.
   43866 
   43867 @item N
   43868 There are no resumed threads left in the target.  In other words, even
   43869 though the process is alive, the last resumed thread has exited.  For
   43870 example, say the target process has two threads: thread 1 and thread
   43871 2.  The client leaves thread 1 stopped, and resumes thread 2, which
   43872 subsequently exits.  At this point, even though the process is still
   43873 alive, and thus no @samp{W} stop reply is sent, no thread is actually
   43874 executing either.  The @samp{N} stop reply thus informs the client
   43875 that it can stop waiting for stop replies.  This packet should not be
   43876 sent by default; older @value{GDBN} versions did not support it.
   43877 @value{GDBN} requests it, by supplying an appropriate
   43878 @samp{qSupported} feature (@pxref{qSupported}).  The remote stub must
   43879 also supply the appropriate @samp{qSupported} feature indicating
   43880 support.
   43881 
   43882 @item O @var{XX}@dots{}
   43883 @samp{@var{XX}@dots{}} is hex encoding of @sc{ascii} data, to be
   43884 written as the program's console output.  This can happen at any time
   43885 while the program is running and the debugger should continue to wait
   43886 for @samp{W}, @samp{T}, etc.  This reply is not permitted in non-stop mode.
   43887 
   43888 @item F @var{call-id},@var{parameter}@dots{}
   43889 @var{call-id} is the identifier which says which host system call should
   43890 be called.  This is just the name of the function.  Translation into the
   43891 correct system call is only applicable as it's defined in @value{GDBN}.
   43892 @xref{File-I/O Remote Protocol Extension}, for a list of implemented
   43893 system calls.
   43894 
   43895 @samp{@var{parameter}@dots{}} is a list of parameters as defined for
   43896 this very system call.
   43897 
   43898 The target replies with this packet when it expects @value{GDBN} to
   43899 call a host system call on behalf of the target.  @value{GDBN} replies
   43900 with an appropriate @samp{F} packet and keeps up waiting for the next
   43901 reply packet from the target.  The latest @samp{C}, @samp{c}, @samp{S}
   43902 or @samp{s} action is expected to be continued.  @xref{File-I/O Remote
   43903 Protocol Extension}, for more details.
   43904 
   43905 @end table
   43906 
   43907 @node General Query Packets
   43908 @section General Query Packets
   43909 @cindex remote query requests
   43910 
   43911 Packets starting with @samp{q} are @dfn{general query packets};
   43912 packets starting with @samp{Q} are @dfn{general set packets}.  General
   43913 query and set packets are a semi-unified form for retrieving and
   43914 sending information to and from the stub.
   43915 
   43916 The initial letter of a query or set packet is followed by a name
   43917 indicating what sort of thing the packet applies to.  For example,
   43918 @value{GDBN} may use a @samp{qSymbol} packet to exchange symbol
   43919 definitions with the stub.  These packet names follow some
   43920 conventions:
   43921 
   43922 @itemize @bullet
   43923 @item
   43924 The name must not contain commas, colons or semicolons.
   43925 @item
   43926 Most @value{GDBN} query and set packets have a leading upper case
   43927 letter.
   43928 @item
   43929 The names of custom vendor packets should use a company prefix, in
   43930 lower case, followed by a period.  For example, packets designed at
   43931 the Acme Corporation might begin with @samp{qacme.foo} (for querying
   43932 foos) or @samp{Qacme.bar} (for setting bars).
   43933 @end itemize
   43934 
   43935 The name of a query or set packet should be separated from any
   43936 parameters by a @samp{:}; the parameters themselves should be
   43937 separated by @samp{,} or @samp{;}.  Stubs must be careful to match the
   43938 full packet name, and check for a separator or the end of the packet,
   43939 in case two packet names share a common prefix.  New packets should not begin
   43940 with @samp{qC}, @samp{qP}, or @samp{qL}@footnote{The @samp{qP} and @samp{qL}
   43941 packets predate these conventions, and have arguments without any terminator
   43942 for the packet name; we suspect they are in widespread use in places that
   43943 are difficult to upgrade.  The @samp{qC} packet has no arguments, but some
   43944 existing stubs (e.g.@: RedBoot) are known to not check for the end of the
   43945 packet.}.
   43946 
   43947 Like the descriptions of the other packets, each description here
   43948 has a template showing the packet's overall syntax, followed by an
   43949 explanation of the packet's meaning.  We include spaces in some of the
   43950 templates for clarity; these are not part of the packet's syntax.  No
   43951 @value{GDBN} packet uses spaces to separate its components.
   43952 
   43953 Here are the currently defined query and set packets:
   43954 
   43955 @table @samp
   43956 
   43957 @item QAgent:1
   43958 @itemx QAgent:0
   43959 Turn on or off the agent as a helper to perform some debugging operations
   43960 delegated from @value{GDBN} (@pxref{Control Agent}).
   43961 
   43962 @item QAllow:@var{op}:@var{val}@dots{}
   43963 @cindex @samp{QAllow} packet
   43964 Specify which operations @value{GDBN} expects to request of the
   43965 target, as a semicolon-separated list of operation name and value
   43966 pairs.  Possible values for @var{op} include @samp{WriteReg},
   43967 @samp{WriteMem}, @samp{InsertBreak}, @samp{InsertTrace},
   43968 @samp{InsertFastTrace}, and @samp{Stop}. @var{val} is either 0,
   43969 indicating that @value{GDBN} will not request the operation, or 1,
   43970 indicating that it may.  (The target can then use this to set up its
   43971 own internals optimally, for instance if the debugger never expects to
   43972 insert breakpoints, it may not need to install its own trap handler.)
   43973 
   43974 @item qC
   43975 @cindex current thread, remote request
   43976 @cindex @samp{qC} packet
   43977 Return the current thread ID.
   43978 
   43979 Reply:
   43980 @table @samp
   43981 @item QC @var{thread-id}
   43982 Where @var{thread-id} is a thread ID as documented in 
   43983 @ref{thread-id syntax}.
   43984 @item @r{(anything else)}
   43985 Any other reply implies the old thread ID.
   43986 @end table
   43987 
   43988 @item qCRC:@var{addr},@var{length}
   43989 @cindex CRC of memory block, remote request
   43990 @cindex @samp{qCRC} packet
   43991 @anchor{qCRC packet}
   43992 Compute the CRC checksum of a block of memory using CRC-32 defined in
   43993 IEEE 802.3.  The CRC is computed byte at a time, taking the most
   43994 significant bit of each byte first.  The initial pattern code
   43995 @code{0xffffffff} is used to ensure leading zeros affect the CRC.
   43996 
   43997 @emph{Note:} This is the same CRC used in validating separate debug
   43998 files (@pxref{Separate Debug Files, , Debugging Information in Separate
   43999 Files}).  However the algorithm is slightly different.  When validating
   44000 separate debug files, the CRC is computed taking the @emph{least}
   44001 significant bit of each byte first, and the final result is inverted to
   44002 detect trailing zeros.
   44003 
   44004 Reply:
   44005 @table @samp
   44006 @item C @var{crc32}
   44007 The specified memory region's checksum is @var{crc32}.
   44008 @end table
   44009 
   44010 @item QDisableRandomization:@var{value}
   44011 @cindex disable address space randomization, remote request
   44012 @cindex @samp{QDisableRandomization} packet
   44013 Some target operating systems will randomize the virtual address space
   44014 of the inferior process as a security feature, but provide a feature
   44015 to disable such randomization, e.g.@: to allow for a more deterministic
   44016 debugging experience.  On such systems, this packet with a @var{value}
   44017 of 1 directs the target to disable address space randomization for
   44018 processes subsequently started via @samp{vRun} packets, while a packet
   44019 with a @var{value} of 0 tells the target to enable address space
   44020 randomization.
   44021 
   44022 This packet is only available in extended mode (@pxref{extended mode}).
   44023 
   44024 Reply:
   44025 @table @samp
   44026 @item OK
   44027 The request succeeded.
   44028 @end table
   44029 
   44030 This packet is not probed by default; the remote stub must request it,
   44031 by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
   44032 This should only be done on targets that actually support disabling
   44033 address space randomization.
   44034 
   44035 @item QStartupWithShell:@var{value}
   44036 @cindex startup with shell, remote request
   44037 @cindex @samp{QStartupWithShell} packet
   44038 On UNIX-like targets, it is possible to start the inferior using a
   44039 shell program.  This is the default behavior on both @value{GDBN} and
   44040 @command{gdbserver} (@pxref{set startup-with-shell}).  This packet is
   44041 used to inform @command{gdbserver} whether it should start the
   44042 inferior using a shell or not.
   44043 
   44044 If @var{value} is @samp{0}, @command{gdbserver} will not use a shell
   44045 to start the inferior.  If @var{value} is @samp{1},
   44046 @command{gdbserver} will use a shell to start the inferior.  All other
   44047 values are considered an error.
   44048 
   44049 This packet is only available in extended mode (@pxref{extended
   44050 mode}).
   44051 
   44052 Reply:
   44053 @table @samp
   44054 @item OK
   44055 The request succeeded.
   44056 @end table
   44057 
   44058 This packet is not probed by default; the remote stub must request it,
   44059 by supplying an appropriate @samp{qSupported} response
   44060 (@pxref{qSupported}).  This should only be done on targets that
   44061 actually support starting the inferior using a shell.
   44062 
   44063 Use of this packet is controlled by the @code{set startup-with-shell}
   44064 command; @pxref{set startup-with-shell}.
   44065 
   44066 @item QEnvironmentHexEncoded:@var{hex-value}
   44067 @anchor{QEnvironmentHexEncoded}
   44068 @cindex set environment variable, remote request
   44069 @cindex @samp{QEnvironmentHexEncoded} packet
   44070 On UNIX-like targets, it is possible to set environment variables that
   44071 will be passed to the inferior during the startup process.  This
   44072 packet is used to inform @command{gdbserver} of an environment
   44073 variable that has been defined by the user on @value{GDBN} (@pxref{set
   44074 environment}).
   44075 
   44076 The packet is composed by @var{hex-value}, an hex encoded
   44077 representation of the @var{name=value} format representing an
   44078 environment variable.  The name of the environment variable is
   44079 represented by @var{name}, and the value to be assigned to the
   44080 environment variable is represented by @var{value}.  If the variable
   44081 has no value (i.e., the value is @code{null}), then @var{value} will
   44082 not be present.
   44083 
   44084 This packet is only available in extended mode (@pxref{extended
   44085 mode}).
   44086 
   44087 Reply:
   44088 @table @samp
   44089 @item OK
   44090 The request succeeded.
   44091 @end table
   44092 
   44093 This packet is not probed by default; the remote stub must request it,
   44094 by supplying an appropriate @samp{qSupported} response
   44095 (@pxref{qSupported}).  This should only be done on targets that
   44096 actually support passing environment variables to the starting
   44097 inferior.
   44098 
   44099 This packet is related to the @code{set environment} command;
   44100 @pxref{set environment}.
   44101 
   44102 @item QEnvironmentUnset:@var{hex-value}
   44103 @anchor{QEnvironmentUnset}
   44104 @cindex unset environment variable, remote request
   44105 @cindex @samp{QEnvironmentUnset} packet
   44106 On UNIX-like targets, it is possible to unset environment variables
   44107 before starting the inferior in the remote target.  This packet is
   44108 used to inform @command{gdbserver} of an environment variable that has
   44109 been unset by the user on @value{GDBN} (@pxref{unset environment}).
   44110 
   44111 The packet is composed by @var{hex-value}, an hex encoded
   44112 representation of the name of the environment variable to be unset.
   44113 
   44114 This packet is only available in extended mode (@pxref{extended
   44115 mode}).
   44116 
   44117 Reply:
   44118 @table @samp
   44119 @item OK
   44120 The request succeeded.
   44121 @end table
   44122 
   44123 This packet is not probed by default; the remote stub must request it,
   44124 by supplying an appropriate @samp{qSupported} response
   44125 (@pxref{qSupported}).  This should only be done on targets that
   44126 actually support passing environment variables to the starting
   44127 inferior.
   44128 
   44129 This packet is related to the @code{unset environment} command;
   44130 @pxref{unset environment}.
   44131 
   44132 @item QEnvironmentReset
   44133 @anchor{QEnvironmentReset}
   44134 @cindex reset environment, remote request
   44135 @cindex @samp{QEnvironmentReset} packet
   44136 On UNIX-like targets, this packet is used to reset the state of
   44137 environment variables in the remote target before starting the
   44138 inferior.  In this context, reset means unsetting all environment
   44139 variables that were previously set by the user (i.e., were not
   44140 initially present in the environment).  It is sent to
   44141 @command{gdbserver} before the @samp{QEnvironmentHexEncoded}
   44142 (@pxref{QEnvironmentHexEncoded}) and the @samp{QEnvironmentUnset}
   44143 (@pxref{QEnvironmentUnset}) packets.
   44144 
   44145 This packet is only available in extended mode (@pxref{extended
   44146 mode}).
   44147 
   44148 Reply:
   44149 @table @samp
   44150 @item OK
   44151 The request succeeded.
   44152 @end table
   44153 
   44154 This packet is not probed by default; the remote stub must request it,
   44155 by supplying an appropriate @samp{qSupported} response
   44156 (@pxref{qSupported}).  This should only be done on targets that
   44157 actually support passing environment variables to the starting
   44158 inferior.
   44159 
   44160 @item QSetWorkingDir:@r{[}@var{directory}@r{]}
   44161 @anchor{QSetWorkingDir packet}
   44162 @cindex set working directory, remote request
   44163 @cindex @samp{QSetWorkingDir} packet
   44164 This packet is used to inform the remote server of the intended
   44165 current working directory for programs that are going to be executed.
   44166 
   44167 The packet is composed by @var{directory}, an hex encoded
   44168 representation of the directory that the remote inferior will use as
   44169 its current working directory.  If @var{directory} is an empty string,
   44170 the remote server should reset the inferior's current working
   44171 directory to its original, empty value.
   44172 
   44173 This packet is only available in extended mode (@pxref{extended
   44174 mode}).
   44175 
   44176 Reply:
   44177 @table @samp
   44178 @item OK
   44179 The request succeeded.
   44180 @end table
   44181 
   44182 @item qfThreadInfo
   44183 @itemx qsThreadInfo
   44184 @cindex list active threads, remote request
   44185 @cindex @samp{qfThreadInfo} packet
   44186 @cindex @samp{qsThreadInfo} packet
   44187 Obtain a list of all active thread IDs from the target (OS).  Since there
   44188 may be too many active threads to fit into one reply packet, this query
   44189 works iteratively: it may require more than one query/reply sequence to
   44190 obtain the entire list of threads.  The first query of the sequence will
   44191 be the @samp{qfThreadInfo} query; subsequent queries in the
   44192 sequence will be the @samp{qsThreadInfo} query.
   44193 
   44194 NOTE: This packet replaces the @samp{qL} query (see below).
   44195 
   44196 Reply:
   44197 @table @samp
   44198 @item m @var{thread-id}
   44199 A single thread ID
   44200 @item m @var{thread-id},@var{thread-id}@dots{}
   44201 a comma-separated list of thread IDs
   44202 @item l
   44203 (lower case letter @samp{L}) denotes end of list.
   44204 @end table
   44205 
   44206 In response to each query, the target will reply with a list of one or
   44207 more thread IDs, separated by commas.
   44208 @value{GDBN} will respond to each reply with a request for more thread
   44209 ids (using the @samp{qs} form of the query), until the target responds
   44210 with @samp{l} (lower-case ell, for @dfn{last}).
   44211 Refer to @ref{thread-id syntax}, for the format of the @var{thread-id}
   44212 fields.
   44213 
   44214 @emph{Note: @value{GDBN} will send the @code{qfThreadInfo} query during the
   44215 initial connection with the remote target, and the very first thread ID
   44216 mentioned in the reply will be stopped by @value{GDBN} in a subsequent
   44217 message.  Therefore, the stub should ensure that the first thread ID in
   44218 the @code{qfThreadInfo} reply is suitable for being stopped by @value{GDBN}.}
   44219 
   44220 @item qGetTLSAddr:@var{thread-id},@var{offset},@var{lm}
   44221 @cindex get thread-local storage address, remote request
   44222 @cindex @samp{qGetTLSAddr} packet
   44223 Fetch the address associated with thread local storage specified
   44224 by @var{thread-id}, @var{offset}, and @var{lm}.
   44225 
   44226 @var{thread-id} is the thread ID associated with the
   44227 thread for which to fetch the TLS address.  @xref{thread-id syntax}.
   44228 
   44229 @var{offset} is the (big endian, hex encoded) offset associated with the
   44230 thread local variable.  (This offset is obtained from the debug
   44231 information associated with the variable.)
   44232 
   44233 @var{lm} is the (big endian, hex encoded) OS/ABI-specific encoding of the
   44234 load module associated with the thread local storage.  For example,
   44235 a @sc{gnu}/Linux system will pass the link map address of the shared
   44236 object associated with the thread local storage under consideration. 
   44237 Other operating environments may choose to represent the load module
   44238 differently, so the precise meaning of this parameter will vary.
   44239 
   44240 Reply:
   44241 @table @samp
   44242 @item @var{XX}@dots{}
   44243 Hex encoded (big endian) bytes representing the address of the thread
   44244 local storage requested.
   44245 @end table
   44246 
   44247 @item qGetTIBAddr:@var{thread-id}
   44248 @cindex get thread information block address
   44249 @cindex @samp{qGetTIBAddr} packet
   44250 Fetch address of the Windows OS specific Thread Information Block.
   44251 
   44252 @var{thread-id} is the thread ID associated with the thread.
   44253 
   44254 Reply:
   44255 @table @samp
   44256 @item @var{XX}@dots{}
   44257 Hex encoded (big endian) bytes representing the linear address of the
   44258 thread information block.
   44259 @end table
   44260 
   44261 @item qL @var{startflag} @var{threadcount} @var{nextthread}
   44262 Obtain thread information from RTOS.  Where: @var{startflag} (one hex
   44263 digit) is one to indicate the first query and zero to indicate a
   44264 subsequent query; @var{threadcount} (two hex digits) is the maximum
   44265 number of threads the response packet can contain; and @var{nextthread}
   44266 (eight hex digits), for subsequent queries (@var{startflag} is zero), is
   44267 returned in the response as @var{argthread}.
   44268 
   44269 Don't use this packet; use the @samp{qfThreadInfo} query instead (see above).
   44270 
   44271 Reply:
   44272 @table @samp
   44273 @item qM @var{count} @var{done} @var{argthread} @var{thread}@dots{}
   44274 Where: @var{count} (two hex digits) is the number of threads being
   44275 returned; @var{done} (one hex digit) is zero to indicate more threads
   44276 and one indicates no further threads; @var{argthreadid} (eight hex
   44277 digits) is @var{nextthread} from the request packet; @var{thread}@dots{}
   44278 is a sequence of thread IDs, @var{threadid} (eight hex
   44279 digits), from the target.  See @code{remote.c:parse_threadlist_response()}.
   44280 @end table
   44281 
   44282 @item qMemTags:@var{start address},@var{length}:@var{type}
   44283 @anchor{qMemTags}
   44284 @cindex fetch memory tags
   44285 @cindex @samp{qMemTags} packet
   44286 Fetch memory tags of type @var{type} from the address range
   44287 @w{@r{[}@var{start address}, @var{start address} + @var{length}@r{)}}.  The
   44288 target is responsible for calculating how many tags will be returned, as this
   44289 is architecture-specific.
   44290 
   44291 @var{start address} is the starting address of the memory range.
   44292 
   44293 @var{length} is the length, in bytes, of the memory range.
   44294 
   44295 @var{type} is the type of tag the request wants to fetch.  The type is a signed
   44296 integer.
   44297 
   44298 @value{GDBN} will only send this packet if the stub has advertised
   44299 support for memory tagging via @samp{qSupported}.
   44300 
   44301 Reply:
   44302 @table @samp
   44303 @item @var{mxx}@dots{}
   44304 Hex encoded sequence of uninterpreted bytes, @var{xx}@dots{}, representing the
   44305 tags found in the requested memory range.
   44306 
   44307 @end table
   44308 
   44309 @cindex check if a given address is in a memory tagged region
   44310 @cindex @samp{qIsAddressTagged} packet
   44311 @item qIsAddressTagged:@var{address}
   44312 @anchor {qIsAddressTagged}
   44313 Check if address @var{address} is in a memory tagged region; if it is, it's
   44314 said to be @dfn{tagged}.  The target is responsible for checking it, as this
   44315 is architecture-specific.
   44316 
   44317 @var{address} is the address to be checked.
   44318 
   44319 Reply:
   44320 @table @samp
   44321 Replies to this packet should all be in two hex digit format, as follows:
   44322 
   44323 @item @samp{01}
   44324 Address @var{address} is tagged.
   44325 
   44326 @item @samp{00}
   44327 Address @var{address} is not tagged.
   44328 @end table
   44329 
   44330 @item QMemTags:@var{start address},@var{length}:@var{type}:@var{tag bytes}
   44331 @anchor{QMemTags}
   44332 @cindex store memory tags
   44333 @cindex @samp{QMemTags} packet
   44334 Store memory tags of type @var{type} to the address range
   44335 @w{@r{[}@var{start address}, @var{start address} + @var{length}@r{)}}.  The
   44336 target is responsible for interpreting the type, the tag bytes and modifying
   44337 the memory tag granules accordingly, given this is architecture-specific.
   44338 
   44339 The interpretation of how many tags (@var{nt}) should be written to how many
   44340 memory tag granules (@var{ng}) is also architecture-specific.  The behavior is
   44341 implementation-specific, but the following is suggested.
   44342 
   44343 If the number of memory tags, @var{nt}, is greater than or equal to the
   44344 number of memory tag granules, @var{ng}, only @var{ng} tags will be
   44345 stored.
   44346 
   44347 If @var{nt} is less than @var{ng}, the behavior is that of a fill operation,
   44348 and the tag bytes will be used as a pattern that will get repeated until
   44349 @var{ng} tags are stored.
   44350 
   44351 @var{start address} is the starting address of the memory range.  The address
   44352 does not have any restriction on alignment or size.
   44353 
   44354 @var{length} is the length, in bytes, of the memory range.
   44355 
   44356 @var{type} is the type of tag the request wants to fetch.  The type is a signed
   44357 integer.
   44358 
   44359 @var{tag bytes} is a sequence of hex encoded uninterpreted bytes which will be
   44360 interpreted by the target.  Each pair of hex digits is interpreted as a
   44361 single byte.
   44362 
   44363 @value{GDBN} will only send this packet if the stub has advertised
   44364 support for memory tagging via @samp{qSupported}.
   44365 
   44366 Reply:
   44367 @table @samp
   44368 @item OK
   44369 The request was successful and the memory tag granules were modified
   44370 accordingly.
   44371 @end table
   44372 
   44373 @item qOffsets
   44374 @cindex section offsets, remote request
   44375 @cindex @samp{qOffsets} packet
   44376 Get section offsets that the target used when relocating the downloaded
   44377 image.
   44378 
   44379 Reply:
   44380 @table @samp
   44381 @item Text=@var{xxx};Data=@var{yyy}@r{[};Bss=@var{zzz}@r{]}
   44382 Relocate the @code{Text} section by @var{xxx} from its original address.
   44383 Relocate the @code{Data} section by @var{yyy} from its original address.
   44384 If the object file format provides segment information (e.g.@: @sc{elf}
   44385 @samp{PT_LOAD} program headers), @value{GDBN} will relocate entire
   44386 segments by the supplied offsets.
   44387 
   44388 @emph{Note: while a @code{Bss} offset may be included in the response,
   44389 @value{GDBN} ignores this and instead applies the @code{Data} offset
   44390 to the @code{Bss} section.}
   44391 
   44392 @item TextSeg=@var{xxx}@r{[};DataSeg=@var{yyy}@r{]}
   44393 Relocate the first segment of the object file, which conventionally
   44394 contains program code, to a starting address of @var{xxx}.  If
   44395 @samp{DataSeg} is specified, relocate the second segment, which
   44396 conventionally contains modifiable data, to a starting address of
   44397 @var{yyy}.  @value{GDBN} will report an error if the object file
   44398 does not contain segment information, or does not contain at least
   44399 as many segments as mentioned in the reply.  Extra segments are
   44400 kept at fixed offsets relative to the last relocated segment.
   44401 @end table
   44402 
   44403 @item qP @var{mode} @var{thread-id}
   44404 @cindex thread information, remote request
   44405 @cindex @samp{qP} packet
   44406 Returns information on @var{thread-id}.  Where: @var{mode} is a hex
   44407 encoded 32 bit mode; @var{thread-id} is a thread ID 
   44408 (@pxref{thread-id syntax}).
   44409 
   44410 Don't use this packet; use the @samp{qThreadExtraInfo} query instead
   44411 (see below).
   44412 
   44413 Reply: see @code{remote.c:remote_unpack_thread_info_response()}.
   44414 
   44415 @item QNonStop:1
   44416 @itemx QNonStop:0
   44417 @cindex non-stop mode, remote request
   44418 @cindex @samp{QNonStop} packet
   44419 @anchor{QNonStop}
   44420 Enter non-stop (@samp{QNonStop:1}) or all-stop (@samp{QNonStop:0}) mode.
   44421 @xref{Remote Non-Stop}, for more information.
   44422 
   44423 Reply:
   44424 @table @samp
   44425 @item OK
   44426 The request succeeded.
   44427 @end table
   44428 
   44429 This packet is not probed by default; the remote stub must request it,
   44430 by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
   44431 Use of this packet is controlled by the @code{set non-stop} command; 
   44432 @pxref{Non-Stop Mode}.
   44433 
   44434 @item QCatchSyscalls:1 @r{[};@var{sysno}@r{]}@dots{}
   44435 @itemx QCatchSyscalls:0
   44436 @cindex catch syscalls from inferior, remote request
   44437 @cindex @samp{QCatchSyscalls} packet
   44438 @anchor{QCatchSyscalls}
   44439 Enable (@samp{QCatchSyscalls:1}) or disable (@samp{QCatchSyscalls:0})
   44440 catching syscalls from the inferior process.
   44441 
   44442 For @samp{QCatchSyscalls:1}, each listed syscall @var{sysno} (encoded
   44443 in hex) should be reported to @value{GDBN}.  If no syscall @var{sysno}
   44444 is listed, every system call should be reported.
   44445 
   44446 Note that if a syscall not in the list is reported, @value{GDBN} will
   44447 still filter the event according to its own list from all corresponding
   44448 @code{catch syscall} commands.  However, it is more efficient to only
   44449 report the requested syscalls.
   44450 
   44451 Multiple @samp{QCatchSyscalls:1} packets do not combine; any earlier
   44452 @samp{QCatchSyscalls:1} list is completely replaced by the new list.
   44453 
   44454 If the inferior process execs, the state of @samp{QCatchSyscalls} is
   44455 kept for the new process too.  On targets where exec may affect syscall
   44456 numbers, for example with exec between 32 and 64-bit processes, the
   44457 client should send a new packet with the new syscall list.
   44458 
   44459 Reply:
   44460 @table @samp
   44461 @item OK
   44462 The request succeeded.
   44463 @end table
   44464 
   44465 Use of this packet is controlled by the @code{set remote catch-syscalls}
   44466 command (@pxref{Remote Configuration, set remote catch-syscalls}).
   44467 This packet is not probed by default; the remote stub must request it,
   44468 by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
   44469 
   44470 @item QPassSignals: @var{signal} @r{[};@var{signal}@r{]}@dots{}
   44471 @cindex pass signals to inferior, remote request
   44472 @cindex @samp{QPassSignals} packet
   44473 @anchor{QPassSignals}
   44474 Each listed @var{signal} should be passed directly to the inferior process. 
   44475 Signals are numbered identically to continue packets and stop replies
   44476 (@pxref{Stop Reply Packets}).  Each @var{signal} list item should be
   44477 strictly greater than the previous item.  These signals do not need to stop
   44478 the inferior, or be reported to @value{GDBN}.  All other signals should be
   44479 reported to @value{GDBN}.  Multiple @samp{QPassSignals} packets do not
   44480 combine; any earlier @samp{QPassSignals} list is completely replaced by the
   44481 new list.  This packet improves performance when using @samp{handle
   44482 @var{signal} nostop noprint pass}.
   44483 
   44484 Reply:
   44485 @table @samp
   44486 @item OK
   44487 The request succeeded.
   44488 @end table
   44489 
   44490 Use of this packet is controlled by the @code{set remote pass-signals}
   44491 command (@pxref{Remote Configuration, set remote pass-signals}).
   44492 This packet is not probed by default; the remote stub must request it,
   44493 by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
   44494 
   44495 @item QProgramSignals: @var{signal} @r{[};@var{signal}@r{]}@dots{}
   44496 @cindex signals the inferior may see, remote request
   44497 @cindex @samp{QProgramSignals} packet
   44498 @anchor{QProgramSignals}
   44499 Each listed @var{signal} may be delivered to the inferior process.
   44500 Others should be silently discarded.
   44501 
   44502 In some cases, the remote stub may need to decide whether to deliver a
   44503 signal to the program or not without @value{GDBN} involvement.  One
   44504 example of that is while detaching --- the program's threads may have
   44505 stopped for signals that haven't yet had a chance of being reported to
   44506 @value{GDBN}, and so the remote stub can use the signal list specified
   44507 by this packet to know whether to deliver or ignore those pending
   44508 signals.
   44509 
   44510 This does not influence whether to deliver a signal as requested by a
   44511 resumption packet (@pxref{vCont packet}).
   44512 
   44513 Signals are numbered identically to continue packets and stop replies
   44514 (@pxref{Stop Reply Packets}).  Each @var{signal} list item should be
   44515 strictly greater than the previous item.  Multiple
   44516 @samp{QProgramSignals} packets do not combine; any earlier
   44517 @samp{QProgramSignals} list is completely replaced by the new list.
   44518 
   44519 Reply:
   44520 @table @samp
   44521 @item OK
   44522 The request succeeded.
   44523 @end table
   44524 
   44525 Use of this packet is controlled by the @code{set remote program-signals}
   44526 command (@pxref{Remote Configuration, set remote program-signals}).
   44527 This packet is not probed by default; the remote stub must request it,
   44528 by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
   44529 
   44530 @anchor{QThreadEvents}
   44531 @item QThreadEvents:1
   44532 @itemx QThreadEvents:0
   44533 @cindex thread create/exit events, remote request
   44534 @cindex @samp{QThreadEvents} packet
   44535 
   44536 Enable (@samp{QThreadEvents:1}) or disable (@samp{QThreadEvents:0})
   44537 reporting of thread create and exit events.  @xref{thread create
   44538 event}, for the reply specifications.  For example, this is used in
   44539 non-stop mode when @value{GDBN} stops a set of threads and
   44540 synchronously waits for the their corresponding stop replies.  Without
   44541 exit events, if one of the threads exits, @value{GDBN} would hang
   44542 forever not knowing that it should no longer expect a stop for that
   44543 same thread.  @value{GDBN} does not enable this feature unless the
   44544 stub reports that it supports it by including @samp{QThreadEvents+} in
   44545 its @samp{qSupported} reply.
   44546 
   44547 This packet always enables/disables event reporting for all threads of
   44548 all processes under control of the remote stub.  For per-thread
   44549 control of optional event reporting, see the @ref{QThreadOptions}
   44550 packet.
   44551 
   44552 Reply:
   44553 @table @samp
   44554 @item OK
   44555 The request succeeded.
   44556 @end table
   44557 
   44558 Use of this packet is controlled by the @code{set remote thread-events}
   44559 command (@pxref{Remote Configuration, set remote thread-events}).
   44560 
   44561 @anchor{QThreadOptions}
   44562 @item QThreadOptions@r{[};@var{options}@r{[}:@var{thread-id}@r{]]}@dots{}
   44563 @cindex thread options, remote request
   44564 @cindex @samp{QThreadOptions} packet
   44565 
   44566 For each inferior thread, the last @var{options} in the list with a
   44567 matching @var{thread-id} are applied.  Any options previously set on a
   44568 thread are discarded and replaced by the new options specified.
   44569 Threads that do not match any @var{thread-id} retain their
   44570 previously-set options.  Thread IDs are specified using the syntax
   44571 described in @ref{thread-id syntax}.  If multiprocess extensions
   44572 (@pxref{multiprocess extensions}) are supported, options can be
   44573 specified to apply to all threads of a process by using the
   44574 @samp{p@var{pid}.-1} form of @var{thread-id}.  Options with no
   44575 @var{thread-id} apply to all threads.  Specifying no options value is
   44576 an error.  Zero is a valid value.
   44577 
   44578 @var{options} is an hexadecimal integer specifying the enabled thread
   44579 options, and is the bitwise @code{OR} of the following values.  All
   44580 values are given in hexadecimal representation.
   44581 
   44582 @table @code
   44583 @item GDB_THREAD_OPTION_CLONE (0x1)
   44584 Report thread clone events (@pxref{thread clone event}).  This is only
   44585 meaningful for targets that support clone events (e.g., GNU/Linux
   44586 systems).
   44587 
   44588 @item GDB_THREAD_OPTION_EXIT (0x2)
   44589 Report thread exit events (@pxref{thread exit event}).
   44590 @end table
   44591 
   44592 @noindent
   44593 
   44594 For example, @value{GDBN} enables the @code{GDB_THREAD_OPTION_EXIT}
   44595 and @code{GDB_THREAD_OPTION_CLONE} options when single-stepping a
   44596 thread past a breakpoint, for the following reasons:
   44597 
   44598 @itemize @bullet
   44599 @item
   44600 If the single-stepped thread exits (e.g., it executes a thread exit
   44601 system call), enabling @code{GDB_THREAD_OPTION_EXIT} prevents
   44602 @value{GDBN} from waiting forever, not knowing that it should no
   44603 longer expect a stop for that same thread, and blocking other threads
   44604 from progressing.
   44605 
   44606 @item
   44607 If the single-stepped thread spawns a new clone child (i.e., it
   44608 executes a clone system call), enabling @code{GDB_THREAD_OPTION_CLONE}
   44609 halts the cloned thread before it executes any instructions, and thus
   44610 prevents the following problematic situations:
   44611 
   44612 @itemize @minus
   44613 @item
   44614 If the breakpoint is stepped-over in-line, the spawned thread would
   44615 incorrectly run free while the breakpoint being stepped over is not
   44616 inserted, and thus the cloned thread may potentially run past the
   44617 breakpoint without stopping for it;
   44618 
   44619 @item
   44620 If displaced (out-of-line) stepping is used, the cloned thread starts
   44621 running at the out-of-line PC, leading to undefined behavior, usually
   44622 crashing or corrupting data.
   44623 @end itemize
   44624 
   44625 @end itemize
   44626 
   44627 New threads start with thread options cleared.
   44628 
   44629 @value{GDBN} does not enable this feature unless the stub reports that
   44630 it supports it by including
   44631 @samp{QThreadOptions=@var{supported_options}} in its @samp{qSupported}
   44632 reply.
   44633 
   44634 Reply:
   44635 @table @samp
   44636 @item OK
   44637 The request succeeded.
   44638 @end table
   44639 
   44640 Use of this packet is controlled by the @code{set remote thread-options}
   44641 command (@pxref{Remote Configuration, set remote thread-options}).
   44642 
   44643 @item qRcmd,@var{command}
   44644 @cindex execute remote command, remote request
   44645 @cindex @samp{qRcmd} packet
   44646 @var{command} (hex encoded) is passed to the local interpreter for
   44647 execution.  Invalid commands should be reported using the output
   44648 string.  Before the final result packet, the target may also respond
   44649 with a number of intermediate @samp{O@var{output}} console output
   44650 packets.  @emph{Implementors should note that providing access to a
   44651 stubs's interpreter may have security implications}.
   44652 
   44653 Reply:
   44654 @table @samp
   44655 @item OK
   44656 A command response with no output.
   44657 @item @var{OUTPUT}
   44658 A command response with the hex encoded output string @var{OUTPUT}.
   44659 @end table
   44660 
   44661 Unlike most packets, this packet does not support
   44662 @samp{E.@var{errtext}}-style textual error replies (@pxref{textual
   44663 error reply}) by default.  Stubs should be careful to only send such a
   44664 reply if @value{GDBN} reported support for it with the
   44665 @code{error-message} feature (@pxref{error-message}).
   44666 
   44667 (Note that the @code{qRcmd} packet's name is separated from the
   44668 command by a @samp{,}, not a @samp{:}, contrary to the naming
   44669 conventions above.  Please don't use this packet as a model for new
   44670 packets.)
   44671 
   44672 @item qSearch:memory:@var{address};@var{length};@var{search-pattern}
   44673 @cindex searching memory, in remote debugging
   44674 @ifnotinfo
   44675 @cindex @samp{qSearch:memory} packet
   44676 @end ifnotinfo
   44677 @cindex @samp{qSearch memory} packet
   44678 @anchor{qSearch memory}
   44679 Search @var{length} bytes at @var{address} for @var{search-pattern}.
   44680 Both @var{address} and @var{length} are encoded in hex;
   44681 @var{search-pattern} is a sequence of bytes, also hex encoded.
   44682 
   44683 Reply:
   44684 @table @samp
   44685 @item 0
   44686 The pattern was not found.
   44687 @item 1,address
   44688 The pattern was found at @var{address}.
   44689 @end table
   44690 
   44691 @item QStartNoAckMode
   44692 @cindex @samp{QStartNoAckMode} packet
   44693 @anchor{QStartNoAckMode}
   44694 Request that the remote stub disable the normal @samp{+}/@samp{-}
   44695 protocol acknowledgments (@pxref{Packet Acknowledgment}).
   44696 
   44697 Reply:
   44698 @table @samp
   44699 @item OK
   44700 The stub has switched to no-acknowledgment mode.
   44701 @value{GDBN} acknowledges this response,
   44702 but neither the stub nor @value{GDBN} shall send or expect further
   44703 @samp{+}/@samp{-} acknowledgments in the current connection.
   44704 @end table
   44705 
   44706 @item qSupported @r{[}:@var{gdbfeature} @r{[};@var{gdbfeature}@r{]}@dots{} @r{]}
   44707 @cindex supported packets, remote query
   44708 @cindex features of the remote protocol
   44709 @cindex @samp{qSupported} packet
   44710 @anchor{qSupported}
   44711 Tell the remote stub about features supported by @value{GDBN}, and
   44712 query the stub for features it supports.  This packet allows
   44713 @value{GDBN} and the remote stub to take advantage of each others'
   44714 features.  @samp{qSupported} also consolidates multiple feature probes
   44715 at startup, to improve @value{GDBN} performance---a single larger
   44716 packet performs better than multiple smaller probe packets on
   44717 high-latency links.  Some features may enable behavior which must not
   44718 be on by default, e.g.@: because it would confuse older clients or
   44719 stubs.  Other features may describe packets which could be
   44720 automatically probed for, but are not.  These features must be
   44721 reported before @value{GDBN} will use them.  This ``default
   44722 unsupported'' behavior is not appropriate for all packets, but it
   44723 helps to keep the initial connection time under control with new
   44724 versions of @value{GDBN} which support increasing numbers of packets.
   44725 
   44726 Reply:
   44727 @table @samp
   44728 @item @var{stubfeature} @r{[};@var{stubfeature}@r{]}@dots{}
   44729 The stub supports or does not support each returned @var{stubfeature},
   44730 depending on the form of each @var{stubfeature} (see below for the
   44731 possible forms).
   44732 @end table
   44733 
   44734 The allowed forms for each feature (either a @var{gdbfeature} in the
   44735 @samp{qSupported} packet, or a @var{stubfeature} in the response)
   44736 are:
   44737 
   44738 @table @samp
   44739 @item @var{name}=@var{value}
   44740 The remote protocol feature @var{name} is supported, and associated
   44741 with the specified @var{value}.  The format of @var{value} depends
   44742 on the feature, but it must not include a semicolon.
   44743 @item @var{name}+
   44744 The remote protocol feature @var{name} is supported, and does not
   44745 need an associated value.
   44746 @item @var{name}-
   44747 The remote protocol feature @var{name} is not supported.
   44748 @item @var{name}?
   44749 The remote protocol feature @var{name} may be supported, and
   44750 @value{GDBN} should auto-detect support in some other way when it is
   44751 needed.  This form will not be used for @var{gdbfeature} notifications,
   44752 but may be used for @var{stubfeature} responses.
   44753 @end table
   44754 
   44755 Whenever the stub receives a @samp{qSupported} request, the
   44756 supplied set of @value{GDBN} features should override any previous
   44757 request.  This allows @value{GDBN} to put the stub in a known
   44758 state, even if the stub had previously been communicating with
   44759 a different version of @value{GDBN}.
   44760 
   44761 The following values of @var{gdbfeature} (for the packet sent by @value{GDBN})
   44762 are defined:  
   44763 
   44764 @table @samp
   44765 @item multiprocess
   44766 This feature indicates whether @value{GDBN} supports multiprocess 
   44767 extensions to the remote protocol.  @value{GDBN} does not use such
   44768 extensions unless the stub also reports that it supports them by
   44769 including @samp{multiprocess+} in its @samp{qSupported} reply.
   44770 @xref{multiprocess extensions}, for details.
   44771 
   44772 @item xmlRegisters
   44773 This feature indicates that @value{GDBN} supports the XML target
   44774 description.  If the stub sees @samp{xmlRegisters=} with target
   44775 specific strings separated by a comma, it will report register
   44776 description.
   44777 
   44778 @item qRelocInsn
   44779 This feature indicates whether @value{GDBN} supports the
   44780 @samp{qRelocInsn} packet (@pxref{Tracepoint Packets,,Relocate
   44781 instruction reply packet}).
   44782 
   44783 @item swbreak
   44784 This feature indicates whether @value{GDBN} supports the swbreak stop
   44785 reason in stop replies.  @xref{swbreak stop reason}, for details.
   44786 
   44787 @item hwbreak
   44788 This feature indicates whether @value{GDBN} supports the hwbreak stop
   44789 reason in stop replies.  @xref{swbreak stop reason}, for details.
   44790 
   44791 @item fork-events
   44792 This feature indicates whether @value{GDBN} supports fork event
   44793 extensions to the remote protocol.  @value{GDBN} does not use such
   44794 extensions unless the stub also reports that it supports them by
   44795 including @samp{fork-events+} in its @samp{qSupported} reply.
   44796 
   44797 @item vfork-events
   44798 This feature indicates whether @value{GDBN} supports vfork event
   44799 extensions to the remote protocol.  @value{GDBN} does not use such
   44800 extensions unless the stub also reports that it supports them by
   44801 including @samp{vfork-events+} in its @samp{qSupported} reply.
   44802 
   44803 @item exec-events
   44804 This feature indicates whether @value{GDBN} supports exec event
   44805 extensions to the remote protocol.  @value{GDBN} does not use such
   44806 extensions unless the stub also reports that it supports them by
   44807 including @samp{exec-events+} in its @samp{qSupported} reply.
   44808 
   44809 @item vContSupported
   44810 This feature indicates whether @value{GDBN} wants to know the
   44811 supported actions in the reply to @samp{vCont?} packet.
   44812 
   44813 @anchor{error-message}
   44814 @item error-message
   44815 This feature indicates whether @value{GDBN} supports accepting a reply
   44816 in @samp{E.@var{errtext}} format (@xref{textual error reply}) from the
   44817 @samp{qRcmd} and @samp{m} packets.  These packets, historically,
   44818 didn't support @samp{E.@var{errtext}}, and older versions of
   44819 @value{GDBN} didn't expect to see a reply in this format.
   44820 
   44821 New packets should be written to support @samp{E.@var{errtext}}
   44822 regardless of this feature being true or not.
   44823 @end table
   44824 
   44825 Stubs should ignore any unknown values for
   44826 @var{gdbfeature}.  Any @value{GDBN} which sends a @samp{qSupported}
   44827 packet supports receiving packets of unlimited length (earlier
   44828 versions of @value{GDBN} may reject overly long responses).  Additional values
   44829 for @var{gdbfeature} may be defined in the future to let the stub take
   44830 advantage of new features in @value{GDBN}, e.g.@: incompatible
   44831 improvements in the remote protocol---the @samp{multiprocess} feature is
   44832 an example of such a feature.  The stub's reply should be independent
   44833 of the @var{gdbfeature} entries sent by @value{GDBN}; first @value{GDBN}
   44834 describes all the features it supports, and then the stub replies with
   44835 all the features it supports.
   44836 
   44837 Similarly, @value{GDBN} will silently ignore unrecognized stub feature
   44838 responses, as long as each response uses one of the standard forms.
   44839 
   44840 Some features are flags.  A stub which supports a flag feature
   44841 should respond with a @samp{+} form response.  Other features
   44842 require values, and the stub should respond with an @samp{=}
   44843 form response.
   44844 
   44845 Each feature has a default value, which @value{GDBN} will use if
   44846 @samp{qSupported} is not available or if the feature is not mentioned
   44847 in the @samp{qSupported} response.  The default values are fixed; a
   44848 stub is free to omit any feature responses that match the defaults.
   44849 
   44850 Not all features can be probed, but for those which can, the probing
   44851 mechanism is useful: in some cases, a stub's internal
   44852 architecture may not allow the protocol layer to know some information
   44853 about the underlying target in advance.  This is especially common in
   44854 stubs which may be configured for multiple targets.
   44855 
   44856 These are the currently defined stub features and their properties:
   44857 
   44858 @multitable @columnfractions 0.35 0.2 0.12 0.2
   44859 @c NOTE: The first row should be @headitem, but we do not yet require
   44860 @c a new enough version of Texinfo (4.7) to use @headitem.
   44861 @item Feature Name
   44862 @tab Value Required
   44863 @tab Default
   44864 @tab Probe Allowed
   44865 
   44866 @item @samp{PacketSize}
   44867 @tab Yes
   44868 @tab @samp{-}
   44869 @tab No
   44870 
   44871 @item @samp{qXfer:auxv:read}
   44872 @tab No
   44873 @tab @samp{-}
   44874 @tab Yes
   44875 
   44876 @item @samp{qXfer:btrace:read}
   44877 @tab No
   44878 @tab @samp{-}
   44879 @tab Yes
   44880 
   44881 @item @samp{qXfer:btrace-conf:read}
   44882 @tab No
   44883 @tab @samp{-}
   44884 @tab Yes
   44885 
   44886 @item @samp{qXfer:exec-file:read}
   44887 @tab No
   44888 @tab @samp{-}
   44889 @tab Yes
   44890 
   44891 @item @samp{qXfer:features:read}
   44892 @tab No
   44893 @tab @samp{-}
   44894 @tab Yes
   44895 
   44896 @item @samp{qXfer:libraries:read}
   44897 @tab No
   44898 @tab @samp{-}
   44899 @tab Yes
   44900 
   44901 @item @samp{qXfer:libraries-svr4:read}
   44902 @tab No
   44903 @tab @samp{-}
   44904 @tab Yes
   44905 
   44906 @item @samp{augmented-libraries-svr4-read}
   44907 @tab No
   44908 @tab @samp{-}
   44909 @tab No
   44910 
   44911 @item @samp{qXfer:memory-map:read}
   44912 @tab No
   44913 @tab @samp{-}
   44914 @tab Yes
   44915 
   44916 @item @samp{qXfer:sdata:read}
   44917 @tab No
   44918 @tab @samp{-}
   44919 @tab Yes
   44920 
   44921 @item @samp{qXfer:siginfo:read}
   44922 @tab No
   44923 @tab @samp{-}
   44924 @tab Yes
   44925 
   44926 @item @samp{qXfer:siginfo:write}
   44927 @tab No
   44928 @tab @samp{-}
   44929 @tab Yes
   44930 
   44931 @item @samp{qXfer:threads:read}
   44932 @tab No
   44933 @tab @samp{-}
   44934 @tab Yes
   44935 
   44936 @item @samp{qXfer:traceframe-info:read}
   44937 @tab No
   44938 @tab @samp{-}
   44939 @tab Yes
   44940 
   44941 @item @samp{qXfer:uib:read}
   44942 @tab No
   44943 @tab @samp{-}
   44944 @tab Yes
   44945 
   44946 @item @samp{qXfer:fdpic:read}
   44947 @tab No
   44948 @tab @samp{-}
   44949 @tab Yes
   44950 
   44951 @item @samp{Qbtrace:off}
   44952 @tab Yes
   44953 @tab @samp{-}
   44954 @tab Yes
   44955 
   44956 @item @samp{Qbtrace:bts}
   44957 @tab Yes
   44958 @tab @samp{-}
   44959 @tab Yes
   44960 
   44961 @item @samp{Qbtrace:pt}
   44962 @tab Yes
   44963 @tab @samp{-}
   44964 @tab Yes
   44965 
   44966 @item @samp{Qbtrace-conf:bts:size}
   44967 @tab Yes
   44968 @tab @samp{-}
   44969 @tab Yes
   44970 
   44971 @item @samp{Qbtrace-conf:pt:size}
   44972 @tab Yes
   44973 @tab @samp{-}
   44974 @tab Yes
   44975 
   44976 @item @samp{Qbtrace-conf:pt:ptwrite}
   44977 @tab Yes
   44978 @tab @samp{-}
   44979 @tab Yes
   44980 
   44981 @item @samp{Qbtrace-conf:pt:event-tracing}
   44982 @tab Yes
   44983 @tab @samp{-}
   44984 @tab Yes
   44985 
   44986 @item @samp{QNonStop}
   44987 @tab No
   44988 @tab @samp{-}
   44989 @tab Yes
   44990 
   44991 @item @samp{QCatchSyscalls}
   44992 @tab No
   44993 @tab @samp{-}
   44994 @tab Yes
   44995 
   44996 @item @samp{QPassSignals}
   44997 @tab No
   44998 @tab @samp{-}
   44999 @tab Yes
   45000 
   45001 @item @samp{QStartNoAckMode}
   45002 @tab No
   45003 @tab @samp{-}
   45004 @tab Yes
   45005 
   45006 @item @samp{multiprocess}
   45007 @tab No
   45008 @tab @samp{-}
   45009 @tab No
   45010 
   45011 @item @samp{ConditionalBreakpoints}
   45012 @tab No
   45013 @tab @samp{-}
   45014 @tab No
   45015 
   45016 @item @samp{ConditionalTracepoints}
   45017 @tab No
   45018 @tab @samp{-}
   45019 @tab No
   45020 
   45021 @item @samp{ReverseContinue}
   45022 @tab No
   45023 @tab @samp{-}
   45024 @tab No
   45025 
   45026 @item @samp{ReverseStep}
   45027 @tab No
   45028 @tab @samp{-}
   45029 @tab No
   45030 
   45031 @item @samp{TracepointSource}
   45032 @tab No
   45033 @tab @samp{-}
   45034 @tab No
   45035 
   45036 @item @samp{QAgent}
   45037 @tab No
   45038 @tab @samp{-}
   45039 @tab No
   45040 
   45041 @item @samp{QAllow}
   45042 @tab No
   45043 @tab @samp{-}
   45044 @tab No
   45045 
   45046 @item @samp{QDisableRandomization}
   45047 @tab No
   45048 @tab @samp{-}
   45049 @tab No
   45050 
   45051 @item @samp{EnableDisableTracepoints}
   45052 @tab No
   45053 @tab @samp{-}
   45054 @tab No
   45055 
   45056 @item @samp{QTBuffer:size}
   45057 @tab No
   45058 @tab @samp{-}
   45059 @tab No
   45060 
   45061 @item @samp{tracenz}
   45062 @tab No
   45063 @tab @samp{-}
   45064 @tab No
   45065 
   45066 @item @samp{BreakpointCommands}
   45067 @tab No
   45068 @tab @samp{-}
   45069 @tab No
   45070 
   45071 @item @samp{swbreak}
   45072 @tab No
   45073 @tab @samp{-}
   45074 @tab No
   45075 
   45076 @item @samp{hwbreak}
   45077 @tab No
   45078 @tab @samp{-}
   45079 @tab No
   45080 
   45081 @item @samp{fork-events}
   45082 @tab No
   45083 @tab @samp{-}
   45084 @tab No
   45085 
   45086 @item @samp{vfork-events}
   45087 @tab No
   45088 @tab @samp{-}
   45089 @tab No
   45090 
   45091 @item @samp{exec-events}
   45092 @tab No
   45093 @tab @samp{-}
   45094 @tab No
   45095 
   45096 @item @samp{QThreadEvents}
   45097 @tab No
   45098 @tab @samp{-}
   45099 @tab No
   45100 
   45101 @item @samp{QThreadOptions}
   45102 @tab Yes
   45103 @tab @samp{-}
   45104 @tab No
   45105 
   45106 @item @samp{no-resumed}
   45107 @tab No
   45108 @tab @samp{-}
   45109 @tab No
   45110 
   45111 @item @samp{memory-tagging}
   45112 @tab No
   45113 @tab @samp{-}
   45114 @tab No
   45115 
   45116 @item @samp{error-message}
   45117 @tab No
   45118 @tab @samp{+}
   45119 @tab No
   45120 
   45121 @item @samp{binary-upload}
   45122 @tab No
   45123 @tab @samp{-}
   45124 @tab No
   45125 
   45126 @end multitable
   45127 
   45128 These are the currently defined stub features, in more detail:
   45129 
   45130 @table @samp
   45131 @cindex packet size, remote protocol
   45132 @item PacketSize=@var{bytes}
   45133 The remote stub can accept packets up to at least @var{bytes} in
   45134 length.  @value{GDBN} will send packets up to this size for bulk
   45135 transfers, and will never send larger packets.  This is a limit on the
   45136 data characters in the packet, not including the frame and checksum.
   45137 There is no trailing NUL byte in a remote protocol packet; if the stub
   45138 stores packets in a NUL-terminated format, it should allow an extra
   45139 byte in its buffer for the NUL.  If this stub feature is not supported,
   45140 @value{GDBN} guesses based on the size of the @samp{g} packet response.
   45141 
   45142 @item qXfer:auxv:read
   45143 The remote stub understands the @samp{qXfer:auxv:read} packet
   45144 (@pxref{qXfer auxiliary vector read}).
   45145 
   45146 @item qXfer:btrace:read
   45147 The remote stub understands the @samp{qXfer:btrace:read}
   45148 packet (@pxref{qXfer btrace read}).
   45149 
   45150 @item qXfer:btrace-conf:read
   45151 The remote stub understands the @samp{qXfer:btrace-conf:read}
   45152 packet (@pxref{qXfer btrace-conf read}).
   45153 
   45154 @item qXfer:exec-file:read
   45155 The remote stub understands the @samp{qXfer:exec-file:read} packet
   45156 (@pxref{qXfer executable filename read}).
   45157 
   45158 @item qXfer:features:read
   45159 The remote stub understands the @samp{qXfer:features:read} packet
   45160 (@pxref{qXfer target description read}).
   45161 
   45162 @item qXfer:libraries:read
   45163 The remote stub understands the @samp{qXfer:libraries:read} packet
   45164 (@pxref{qXfer library list read}).
   45165 
   45166 @item qXfer:libraries-svr4:read
   45167 The remote stub understands the @samp{qXfer:libraries-svr4:read} packet
   45168 (@pxref{qXfer svr4 library list read}).
   45169 
   45170 @item augmented-libraries-svr4-read
   45171 The remote stub understands the augmented form of the
   45172 @samp{qXfer:libraries-svr4:read} packet
   45173 (@pxref{qXfer svr4 library list read}).
   45174 
   45175 @item qXfer:memory-map:read
   45176 The remote stub understands the @samp{qXfer:memory-map:read} packet
   45177 (@pxref{qXfer memory map read}).
   45178 
   45179 @item qXfer:sdata:read
   45180 The remote stub understands the @samp{qXfer:sdata:read} packet
   45181 (@pxref{qXfer sdata read}).
   45182 
   45183 @item qXfer:siginfo:read
   45184 The remote stub understands the @samp{qXfer:siginfo:read} packet
   45185 (@pxref{qXfer siginfo read}).
   45186 
   45187 @item qXfer:siginfo:write
   45188 The remote stub understands the @samp{qXfer:siginfo:write} packet
   45189 (@pxref{qXfer siginfo write}).
   45190 
   45191 @item qXfer:threads:read
   45192 The remote stub understands the @samp{qXfer:threads:read} packet
   45193 (@pxref{qXfer threads read}).
   45194 
   45195 @item qXfer:traceframe-info:read
   45196 The remote stub understands the @samp{qXfer:traceframe-info:read}
   45197 packet (@pxref{qXfer traceframe info read}).
   45198 
   45199 @item qXfer:uib:read
   45200 The remote stub understands the @samp{qXfer:uib:read}
   45201 packet (@pxref{qXfer unwind info block}).
   45202 
   45203 @item qXfer:fdpic:read
   45204 The remote stub understands the @samp{qXfer:fdpic:read}
   45205 packet (@pxref{qXfer fdpic loadmap read}).
   45206 
   45207 @item QNonStop
   45208 The remote stub understands the @samp{QNonStop} packet
   45209 (@pxref{QNonStop}).
   45210 
   45211 @item QCatchSyscalls
   45212 The remote stub understands the @samp{QCatchSyscalls} packet
   45213 (@pxref{QCatchSyscalls}).
   45214 
   45215 @item QPassSignals
   45216 The remote stub understands the @samp{QPassSignals} packet
   45217 (@pxref{QPassSignals}).
   45218 
   45219 @item QStartNoAckMode
   45220 The remote stub understands the @samp{QStartNoAckMode} packet and
   45221 prefers to operate in no-acknowledgment mode.  @xref{Packet Acknowledgment}.
   45222 
   45223 @item multiprocess
   45224 @anchor{multiprocess extensions}
   45225 @cindex multiprocess extensions, in remote protocol
   45226 The remote stub understands the multiprocess extensions to the remote
   45227 protocol syntax.  The multiprocess extensions affect the syntax of
   45228 thread IDs in both packets and replies (@pxref{thread-id syntax}), and
   45229 add process IDs to the @samp{D} packet and @samp{W} and @samp{X}
   45230 replies.  Note that reporting this feature indicates support for the
   45231 syntactic extensions only, not that the stub necessarily supports
   45232 debugging of more than one process at a time.  The stub must not use
   45233 multiprocess extensions in packet replies unless @value{GDBN} has also
   45234 indicated it supports them in its @samp{qSupported} request.
   45235 
   45236 @item qXfer:osdata:read
   45237 The remote stub understands the @samp{qXfer:osdata:read} packet
   45238 ((@pxref{qXfer osdata read}).
   45239 
   45240 @item ConditionalBreakpoints
   45241 The target accepts and implements evaluation of conditional expressions
   45242 defined for breakpoints.  The target will only report breakpoint triggers
   45243 when such conditions are true (@pxref{Conditions, ,Break Conditions}).
   45244 
   45245 @item ConditionalTracepoints
   45246 The remote stub accepts and implements conditional expressions defined
   45247 for tracepoints (@pxref{Tracepoint Conditions}).
   45248 
   45249 @item ReverseContinue
   45250 The remote stub accepts and implements the reverse continue packet
   45251 (@pxref{bc}).
   45252 
   45253 @item ReverseStep
   45254 The remote stub accepts and implements the reverse step packet
   45255 (@pxref{bs}).
   45256 
   45257 @item TracepointSource
   45258 The remote stub understands the @samp{QTDPsrc} packet that supplies
   45259 the source form of tracepoint definitions.
   45260 
   45261 @item QAgent
   45262 The remote stub understands the @samp{QAgent} packet.
   45263 
   45264 @item QAllow
   45265 The remote stub understands the @samp{QAllow} packet.
   45266 
   45267 @item QDisableRandomization
   45268 The remote stub understands the @samp{QDisableRandomization} packet.
   45269 
   45270 @item StaticTracepoint
   45271 @cindex static tracepoints, in remote protocol
   45272 The remote stub supports static tracepoints.
   45273 
   45274 @item InstallInTrace
   45275 @anchor{install tracepoint in tracing}
   45276 The remote stub supports installing tracepoint in tracing.
   45277 
   45278 @item EnableDisableTracepoints
   45279 The remote stub supports the @samp{QTEnable} (@pxref{QTEnable}) and
   45280 @samp{QTDisable} (@pxref{QTDisable}) packets that allow tracepoints
   45281 to be enabled and disabled while a trace experiment is running.
   45282 
   45283 @item QTBuffer:size
   45284 The remote stub supports the @samp{QTBuffer:size} (@pxref{QTBuffer-size})
   45285 packet that allows to change the size of the trace buffer.
   45286 
   45287 @item tracenz
   45288 @cindex string tracing, in remote protocol
   45289 The remote stub supports the @samp{tracenz} bytecode for collecting strings.
   45290 See @ref{Bytecode Descriptions} for details about the bytecode.
   45291 
   45292 @item BreakpointCommands
   45293 @cindex breakpoint commands, in remote protocol
   45294 The remote stub supports running a breakpoint's command list itself,
   45295 rather than reporting the hit to @value{GDBN}.
   45296 
   45297 @item Qbtrace:off
   45298 The remote stub understands the @samp{Qbtrace:off} packet.
   45299 
   45300 @item Qbtrace:bts
   45301 The remote stub understands the @samp{Qbtrace:bts} packet.
   45302 
   45303 @item Qbtrace:pt
   45304 The remote stub understands the @samp{Qbtrace:pt} packet.
   45305 
   45306 @item Qbtrace-conf:bts:size
   45307 The remote stub understands the @samp{Qbtrace-conf:bts:size} packet.
   45308 
   45309 @item Qbtrace-conf:pt:size
   45310 The remote stub understands the @samp{Qbtrace-conf:pt:size} packet.
   45311 
   45312 @item Qbtrace-conf:pt:ptwrite
   45313 The remote stub understands the @samp{Qbtrace-conf:pt:ptwrite} packet.
   45314 
   45315 @item Qbtrace-conf:pt:event-tracing
   45316 The remote stub understands the @samp{Qbtrace-conf:pt:event-tracing} packet.
   45317 
   45318 @item swbreak
   45319 The remote stub reports the @samp{swbreak} stop reason for memory
   45320 breakpoints.
   45321 
   45322 @item hwbreak
   45323 The remote stub reports the @samp{hwbreak} stop reason for hardware
   45324 breakpoints.
   45325 
   45326 @item fork-events
   45327 The remote stub reports the @samp{fork} stop reason for fork events.
   45328 
   45329 @item vfork-events
   45330 The remote stub reports the @samp{vfork} stop reason for vfork events
   45331 and vforkdone events.
   45332 
   45333 @item exec-events
   45334 The remote stub reports the @samp{exec} stop reason for exec events.
   45335 
   45336 @item vContSupported
   45337 The remote stub reports the supported actions in the reply to
   45338 @samp{vCont?} packet.
   45339 
   45340 @item QThreadEvents
   45341 The remote stub understands the @samp{QThreadEvents} packet.
   45342 
   45343 @item QThreadOptions=@var{supported_options}
   45344 The remote stub understands the @samp{QThreadOptions} packet.
   45345 @var{supported_options} indicates the set of thread options the remote
   45346 stub supports.  @var{supported_options} has the same format as the
   45347 @var{options} parameter of the @code{QThreadOptions} packet, described
   45348 at @ref{QThreadOptions}.
   45349 
   45350 @item no-resumed
   45351 The remote stub reports the @samp{N} stop reply.
   45352 
   45353 
   45354 @item memory-tagging
   45355 The remote stub supports and implements the required memory tagging
   45356 functionality and understands the @samp{qMemTags} (@pxref{qMemTags}) and
   45357 @samp{QMemTags} (@pxref{QMemTags}) packets.
   45358 
   45359 For AArch64 GNU/Linux systems, this feature can require access to the
   45360 @file{/proc/@var{pid}/smaps} file so memory mapping page flags can be
   45361 inspected, if @samp{qIsAddressTagged} (@pxref{qIsAddressTagged}) packet
   45362 is not supported by the stub.  Access to the @file{/proc/@var{pid}/smaps}
   45363 file is done via @samp{vFile} requests.
   45364 
   45365 @item error-message
   45366 The remote stub supports replying with an error in a
   45367 @samp{E.@var{errtext}} (@xref{textual error reply}) format from the
   45368 @samp{m} and @samp{qRcmd} packets.  It is not usually necessary to
   45369 send this feature back to @value{GDBN} in the @samp{qSupported} reply,
   45370 @value{GDBN} will always support @samp{E.@var{errtext}} format replies
   45371 if it sent the @samp{error-message} feature.
   45372 
   45373 @item binary-upload
   45374 The remote stub supports the @samp{x} packet (@pxref{x packet}).
   45375 @end table
   45376 
   45377 @item qSymbol::
   45378 @cindex symbol lookup, remote request
   45379 @cindex @samp{qSymbol} packet
   45380 Notify the target that @value{GDBN} is prepared to serve symbol lookup
   45381 requests.  Accept requests from the target for the values of symbols.
   45382 
   45383 Reply:
   45384 @table @samp
   45385 @item OK
   45386 The target does not need to look up any (more) symbols.
   45387 @item qSymbol:@var{sym_name}
   45388 The target requests the value of symbol @var{sym_name} (hex encoded).
   45389 @value{GDBN} may provide the value by using the
   45390 @samp{qSymbol:@var{sym_value}:@var{sym_name}} message, described
   45391 below.
   45392 @end table
   45393 
   45394 @item qSymbol:@var{sym_value}:@var{sym_name}
   45395 Set the value of @var{sym_name} to @var{sym_value}.
   45396 
   45397 @var{sym_name} (hex encoded) is the name of a symbol whose value the
   45398 target has previously requested.
   45399 
   45400 @var{sym_value} (hex) is the value for symbol @var{sym_name}.  If
   45401 @value{GDBN} cannot supply a value for @var{sym_name}, then this field
   45402 will be empty.
   45403 
   45404 Reply:
   45405 @table @samp
   45406 @item OK
   45407 The target does not need to look up any (more) symbols.
   45408 @item qSymbol:@var{sym_name}
   45409 The target requests the value of a new symbol @var{sym_name} (hex
   45410 encoded).  @value{GDBN} will continue to supply the values of symbols
   45411 (if available), until the target ceases to request them.
   45412 @end table
   45413 
   45414 @item qTBuffer
   45415 @itemx QTBuffer
   45416 @itemx QTDisconnected
   45417 @itemx QTDP
   45418 @itemx QTDPsrc
   45419 @itemx QTDV
   45420 @itemx qTfP
   45421 @itemx qTfV
   45422 @itemx QTFrame
   45423 @itemx qTMinFTPILen
   45424 
   45425 @xref{Tracepoint Packets}.
   45426 
   45427 @anchor{qThreadExtraInfo}
   45428 @item qThreadExtraInfo,@var{thread-id}
   45429 @cindex thread attributes info, remote request
   45430 @cindex @samp{qThreadExtraInfo} packet
   45431 Obtain from the target OS a printable string description of thread
   45432 attributes for the thread @var{thread-id}; see @ref{thread-id syntax},
   45433 for the forms of @var{thread-id}.  This
   45434 string may contain anything that the target OS thinks is interesting
   45435 for @value{GDBN} to tell the user about the thread.  The string is
   45436 displayed in @value{GDBN}'s @code{info threads} display.  Some
   45437 examples of possible thread extra info strings are @samp{Runnable}, or
   45438 @samp{Blocked on Mutex}.
   45439 
   45440 Reply:
   45441 @table @samp
   45442 @item @var{XX}@dots{}
   45443 Where @samp{@var{XX}@dots{}} is a hex encoding of @sc{ascii} data,
   45444 comprising the printable string containing the extra information about
   45445 the thread's attributes.
   45446 @end table
   45447 
   45448 (Note that the @code{qThreadExtraInfo} packet's name is separated from
   45449 the command by a @samp{,}, not a @samp{:}, contrary to the naming
   45450 conventions above.  Please don't use this packet as a model for new
   45451 packets.)
   45452 
   45453 @item QTNotes
   45454 @itemx qTP
   45455 @itemx QTSave
   45456 @itemx qTsP
   45457 @itemx qTsV
   45458 @itemx QTStart    
   45459 @itemx QTStop     
   45460 @itemx QTEnable
   45461 @itemx QTDisable
   45462 @itemx QTinit     
   45463 @itemx QTro       
   45464 @itemx qTStatus   
   45465 @itemx qTV
   45466 @itemx qTfSTM
   45467 @itemx qTsSTM
   45468 @itemx qTSTMat
   45469 @xref{Tracepoint Packets}.
   45470 
   45471 @item qXfer:@var{object}:read:@var{annex}:@var{offset},@var{length}
   45472 @cindex read special object, remote request
   45473 @cindex @samp{qXfer} packet
   45474 @anchor{qXfer read}
   45475 Read uninterpreted bytes from the target's special data area
   45476 identified by the keyword @var{object}.  Request @var{length} bytes
   45477 starting at @var{offset} bytes into the data.  The content and
   45478 encoding of @var{annex} is specific to @var{object}; it can supply
   45479 additional details about what data to access.
   45480 
   45481 Reply:
   45482 @table @samp
   45483 @item m @var{data}
   45484 Data @var{data} (@pxref{Binary Data}) has been read from the
   45485 target.  There may be more data at a higher address (although
   45486 it is permitted to return @samp{m} even for the last valid
   45487 block of data, as long as at least one byte of data was read).
   45488 It is possible for @var{data} to have fewer bytes than the @var{length} in the
   45489 request.
   45490 
   45491 @item l @var{data}
   45492 Data @var{data} (@pxref{Binary Data}) has been read from the target.
   45493 There is no more data to be read.  It is possible for @var{data} to
   45494 have fewer bytes than the @var{length} in the request.
   45495 
   45496 @item l
   45497 The @var{offset} in the request is at the end of the data.
   45498 There is no more data to be read.
   45499 @end table
   45500 
   45501 Here are the specific requests of this form defined so far.  All the
   45502 @samp{qXfer:@var{object}:read:@dots{}} requests use the same reply
   45503 formats, listed above.
   45504 
   45505 @table @samp
   45506 @item qXfer:auxv:read::@var{offset},@var{length}
   45507 @anchor{qXfer auxiliary vector read}
   45508 Access the target's @dfn{auxiliary vector}.  @xref{OS Information,
   45509 auxiliary vector}.  Note @var{annex} must be empty.
   45510 
   45511 This packet is not probed by default; the remote stub must request it,
   45512 by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
   45513 
   45514 @item qXfer:btrace:read:@var{annex}:@var{offset},@var{length}
   45515 @anchor{qXfer btrace read}
   45516 
   45517 Return a description of the current branch trace.
   45518 @xref{Branch Trace Format}.  The annex part of the generic @samp{qXfer}
   45519 packet may have one of the following values:
   45520 
   45521 @table @code
   45522 @item all
   45523 Returns all available branch trace.
   45524 
   45525 @item new
   45526 Returns all available branch trace if the branch trace changed since
   45527 the last read request.
   45528 
   45529 @item delta
   45530 Returns the new branch trace since the last read request.  Adds a new
   45531 block to the end of the trace that begins at zero and ends at the source
   45532 location of the first branch in the trace buffer.  This extra block is
   45533 used to stitch traces together.
   45534 
   45535 If the trace buffer overflowed, returns an error indicating the overflow.
   45536 @end table
   45537 
   45538 This packet is not probed by default; the remote stub must request it
   45539 by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
   45540 
   45541 @item qXfer:btrace-conf:read::@var{offset},@var{length}
   45542 @anchor{qXfer btrace-conf read}
   45543 
   45544 Return a description of the current branch trace configuration.
   45545 @xref{Branch Trace Configuration Format}.
   45546 
   45547 This packet is not probed by default; the remote stub must request it
   45548 by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
   45549 
   45550 @item qXfer:exec-file:read:@var{annex}:@var{offset},@var{length}
   45551 @anchor{qXfer executable filename read}
   45552 Return the full absolute name of the file that was executed to create
   45553 a process running on the remote system.  The annex specifies the
   45554 numeric process ID of the process to query, encoded as a hexadecimal
   45555 number.  If the annex part is empty the remote stub should return the
   45556 filename corresponding to the currently executing process.
   45557 
   45558 This packet is not probed by default; the remote stub must request it,
   45559 by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
   45560 
   45561 @item qXfer:features:read:@var{annex}:@var{offset},@var{length}
   45562 @anchor{qXfer target description read}
   45563 Access the @dfn{target description}.  @xref{Target Descriptions}.  The
   45564 annex specifies which XML document to access.  The main description is
   45565 always loaded from the @samp{target.xml} annex.
   45566 
   45567 This packet is not probed by default; the remote stub must request it,
   45568 by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
   45569 
   45570 @item qXfer:libraries:read:@var{annex}:@var{offset},@var{length}
   45571 @anchor{qXfer library list read}
   45572 Access the target's list of loaded libraries.  @xref{Library List Format}.
   45573 The annex part of the generic @samp{qXfer} packet must be empty
   45574 (@pxref{qXfer read}).
   45575 
   45576 Targets which maintain a list of libraries in the program's memory do
   45577 not need to implement this packet; it is designed for platforms where
   45578 the operating system manages the list of loaded libraries.
   45579 
   45580 This packet is not probed by default; the remote stub must request it,
   45581 by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
   45582 
   45583 @item qXfer:libraries-svr4:read:@var{annex}:@var{offset},@var{length}
   45584 @anchor{qXfer svr4 library list read}
   45585 Access the target's list of loaded libraries when the target is an SVR4
   45586 platform.  @xref{Library List Format for SVR4 Targets}.  The annex part
   45587 of the generic @samp{qXfer} packet must be empty unless the remote
   45588 stub indicated it supports the augmented form of this packet
   45589 by supplying an appropriate @samp{qSupported} response
   45590 (@pxref{qXfer read}, @ref{qSupported}).
   45591 
   45592 This packet is optional for better performance on SVR4 targets.  
   45593 @value{GDBN} uses memory read packets to read the SVR4 library list otherwise.
   45594 
   45595 This packet is not probed by default; the remote stub must request it,
   45596 by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
   45597 
   45598 If the remote stub indicates it supports the augmented form of this
   45599 packet then the annex part of the generic @samp{qXfer} packet may
   45600 contain a semicolon-separated list of @samp{@var{name}=@var{value}}
   45601 arguments.  The currently supported arguments are:
   45602 
   45603 @table @code
   45604 @item start=@var{address}
   45605 A hexadecimal number specifying the address of the @samp{struct
   45606 link_map} to start reading the library list from.  If unset or zero
   45607 then the first @samp{struct link_map} in the library list will be
   45608 chosen as the starting point.
   45609 
   45610 @item prev=@var{address}
   45611 A hexadecimal number specifying the address of the @samp{struct
   45612 link_map} immediately preceding the @samp{struct link_map}
   45613 specified by the @samp{start} argument.  If unset or zero then
   45614 the remote stub will expect that no @samp{struct link_map}
   45615 exists prior to the starting point.
   45616 
   45617 @item lmid=@var{lmid}
   45618 A hexadecimal number specifying a namespace identifier.  This is
   45619 currently only used together with @samp{start} to provide the
   45620 namespace identifier back to @value{GDBN} in the response.
   45621 @value{GDBN} will only provide values that were previously reported to
   45622 it.  If unset, the response will include @samp{lmid="0x0"}.
   45623 @end table
   45624 
   45625 Arguments that are not understood by the remote stub will be silently
   45626 ignored.
   45627 
   45628 @item qXfer:memory-map:read::@var{offset},@var{length}
   45629 @anchor{qXfer memory map read}
   45630 Access the target's @dfn{memory-map}.  @xref{Memory Map Format}.  The
   45631 annex part of the generic @samp{qXfer} packet must be empty
   45632 (@pxref{qXfer read}).
   45633 
   45634 This packet is not probed by default; the remote stub must request it,
   45635 by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
   45636 
   45637 @item qXfer:sdata:read::@var{offset},@var{length}
   45638 @anchor{qXfer sdata read}
   45639 
   45640 Read contents of the extra collected static tracepoint marker
   45641 information.  The annex part of the generic @samp{qXfer} packet must
   45642 be empty (@pxref{qXfer read}).  @xref{Tracepoint Actions,,Tracepoint
   45643 Action Lists}.
   45644 
   45645 This packet is not probed by default; the remote stub must request it,
   45646 by supplying an appropriate @samp{qSupported} response
   45647 (@pxref{qSupported}).
   45648 
   45649 @item qXfer:siginfo:read::@var{offset},@var{length}
   45650 @anchor{qXfer siginfo read}
   45651 Read contents of the extra signal information on the target
   45652 system.  The annex part of the generic @samp{qXfer} packet must be
   45653 empty (@pxref{qXfer read}).
   45654 
   45655 This packet is not probed by default; the remote stub must request it,
   45656 by supplying an appropriate @samp{qSupported} response
   45657 (@pxref{qSupported}).
   45658 
   45659 @item qXfer:threads:read::@var{offset},@var{length}
   45660 @anchor{qXfer threads read}
   45661 Access the list of threads on target.  @xref{Thread List Format}.  The
   45662 annex part of the generic @samp{qXfer} packet must be empty
   45663 (@pxref{qXfer read}).
   45664 
   45665 This packet is not probed by default; the remote stub must request it,
   45666 by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
   45667 
   45668 @item qXfer:traceframe-info:read::@var{offset},@var{length}
   45669 @anchor{qXfer traceframe info read}
   45670 
   45671 Return a description of the current traceframe's contents.
   45672 @xref{Traceframe Info Format}.  The annex part of the generic
   45673 @samp{qXfer} packet must be empty (@pxref{qXfer read}).
   45674 
   45675 This packet is not probed by default; the remote stub must request it,
   45676 by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
   45677 
   45678 @item qXfer:uib:read:@var{pc}:@var{offset},@var{length}
   45679 @anchor{qXfer unwind info block}
   45680 
   45681 Return the unwind information block for @var{pc}.  This packet is used
   45682 on OpenVMS/ia64 to ask the kernel unwind information.
   45683 
   45684 This packet is not probed by default.
   45685 
   45686 @item qXfer:fdpic:read:@var{annex}:@var{offset},@var{length}
   45687 @anchor{qXfer fdpic loadmap read}
   45688 Read contents of @code{loadmap}s on the target system.  The
   45689 annex, either @samp{exec} or @samp{interp}, specifies which @code{loadmap},
   45690 executable @code{loadmap} or interpreter @code{loadmap} to read.
   45691 
   45692 This packet is not probed by default; the remote stub must request it,
   45693 by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
   45694 
   45695 @item qXfer:osdata:read::@var{offset},@var{length}
   45696 @anchor{qXfer osdata read}
   45697 Access the target's @dfn{operating system information}.
   45698 @xref{Operating System Information}.
   45699 
   45700 @end table
   45701 
   45702 @item qXfer:@var{object}:write:@var{annex}:@var{offset}:@var{data}@dots{}
   45703 @cindex write data into object, remote request
   45704 @anchor{qXfer write}
   45705 Write uninterpreted bytes into the target's special data area
   45706 identified by the keyword @var{object}, starting at @var{offset} bytes
   45707 into the data.  The binary-encoded data (@pxref{Binary Data}) to be
   45708 written is given by @var{data}@dots{}.  The content and encoding of @var{annex}
   45709 is specific to @var{object}; it can supply additional details about what data
   45710 to access.
   45711 
   45712 Reply:
   45713 @table @samp
   45714 @item @var{nn}
   45715 @var{nn} (hex encoded) is the number of bytes written.
   45716 This may be fewer bytes than supplied in the request.
   45717 @end table
   45718 
   45719 Here are the specific requests of this form defined so far.  All the
   45720 @samp{qXfer:@var{object}:write:@dots{}} requests use the same reply
   45721 formats, listed above.
   45722 
   45723 @table @samp
   45724 @item qXfer:siginfo:write::@var{offset}:@var{data}@dots{}
   45725 @anchor{qXfer siginfo write}
   45726 Write @var{data} to the extra signal information on the target system.
   45727 The annex part of the generic @samp{qXfer} packet must be
   45728 empty (@pxref{qXfer write}).
   45729 
   45730 This packet is not probed by default; the remote stub must request it,
   45731 by supplying an appropriate @samp{qSupported} response
   45732 (@pxref{qSupported}).
   45733 @end table
   45734 
   45735 @item qXfer:@var{object}:@var{operation}:@dots{}
   45736 Requests of this form may be added in the future.  When a stub does
   45737 not recognize the @var{object} keyword, or its support for
   45738 @var{object} does not recognize the @var{operation} keyword, the stub
   45739 must respond with an empty packet.
   45740 
   45741 @item qAttached:@var{pid}
   45742 @cindex query attached, remote request
   45743 @cindex @samp{qAttached} packet
   45744 Return an indication of whether the remote server attached to an
   45745 existing process or created a new process.  When the multiprocess
   45746 protocol extensions are supported (@pxref{multiprocess extensions}),
   45747 @var{pid} is an integer in hexadecimal format identifying the target
   45748 process.  Otherwise, @value{GDBN} will omit the @var{pid} field and
   45749 the query packet will be simplified as @samp{qAttached}.
   45750 
   45751 This query is used, for example, to know whether the remote process
   45752 should be detached or killed when a @value{GDBN} session is ended with
   45753 the @code{quit} command.
   45754 
   45755 Reply:
   45756 @table @samp
   45757 @item 1
   45758 The remote server attached to an existing process.
   45759 @item 0
   45760 The remote server created a new process.
   45761 @end table
   45762 
   45763 @item Qbtrace:bts
   45764 Enable branch tracing for the current thread using Branch Trace Store.
   45765 
   45766 Reply:
   45767 @table @samp
   45768 @item OK
   45769 Branch tracing has been enabled.
   45770 @end table
   45771 
   45772 @item Qbtrace:pt
   45773 Enable branch tracing for the current thread using Intel Processor Trace.
   45774 
   45775 Reply:
   45776 @table @samp
   45777 @item OK
   45778 Branch tracing has been enabled.
   45779 @end table
   45780 
   45781 @item Qbtrace:off
   45782 Disable branch tracing for the current thread.
   45783 
   45784 Reply:
   45785 @table @samp
   45786 @item OK
   45787 Branch tracing has been disabled.
   45788 @end table
   45789 
   45790 @item Qbtrace-conf:bts:size=@var{value}
   45791 Set the requested ring buffer size for new threads that use the
   45792 btrace recording method in bts format.
   45793 
   45794 Reply:
   45795 @table @samp
   45796 @item OK
   45797 The ring buffer size has been set.
   45798 @end table
   45799 
   45800 @item Qbtrace-conf:pt:size=@var{value}
   45801 Set the requested ring buffer size for new threads that use the
   45802 btrace recording method in pt format.
   45803 
   45804 Reply:
   45805 @table @samp
   45806 @item OK
   45807 The ring buffer size has been set.
   45808 @end table
   45809 
   45810 @item Qbtrace-conf:pt:ptwrite=@var{(yes|no)}
   45811 Indicate support for @code{PTWRITE} packets.  This allows for backwards
   45812 compatibility.
   45813 
   45814 Reply:
   45815 @table @samp
   45816 @item OK
   45817 The ptwrite config parameter has been set.
   45818 @item E.errtext
   45819 A badly formed request or an error was encountered.
   45820 @end table
   45821 
   45822 @item Qbtrace-conf:pt:event-tracing=@var{(yes|no)}
   45823 Indicate support for event-tracing packets.  This allows for backwards
   45824 compatibility.
   45825 
   45826 Reply:
   45827 @table @samp
   45828 @item OK
   45829 The event-tracing config parameter has been set.
   45830 @item E.errtext
   45831 A badly formed request or an error was encountered.
   45832 @end table
   45833 
   45834 @end table
   45835 
   45836 @node Architecture-Specific Protocol Details
   45837 @section Architecture-Specific Protocol Details
   45838 
   45839 This section describes how the remote protocol is applied to specific
   45840 target architectures.  Also see @ref{Standard Target Features}, for
   45841 details of XML target descriptions for each architecture.
   45842 
   45843 @menu
   45844 * ARM-Specific Protocol Details::
   45845 * MIPS-Specific Protocol Details::
   45846 @end menu
   45847 
   45848 @node ARM-Specific Protocol Details
   45849 @subsection @acronym{ARM}-specific Protocol Details
   45850 
   45851 @menu
   45852 * ARM Breakpoint Kinds::
   45853 * ARM Memory Tag Types::
   45854 @end menu
   45855 
   45856 @node ARM Breakpoint Kinds
   45857 @subsubsection @acronym{ARM} Breakpoint Kinds
   45858 @cindex breakpoint kinds, @acronym{ARM}
   45859 
   45860 These breakpoint kinds are defined for the @samp{Z0} and @samp{Z1} packets.
   45861 
   45862 @table @r
   45863 
   45864 @item 2
   45865 16-bit Thumb mode breakpoint.
   45866 
   45867 @item 3
   45868 32-bit Thumb mode (Thumb-2) breakpoint.
   45869 
   45870 @item 4
   45871 32-bit @acronym{ARM} mode breakpoint.
   45872 
   45873 @end table
   45874 
   45875 @node ARM Memory Tag Types
   45876 @subsubsection @acronym{ARM} Memory Tag Types
   45877 @cindex memory tag types, @acronym{ARM}
   45878 
   45879 These memory tag types are defined for the @samp{qMemTag} and @samp{QMemTag}
   45880 packets.
   45881 
   45882 @table @r
   45883 
   45884 @item 0
   45885 MTE logical tag
   45886 
   45887 @item 1
   45888 MTE allocation tag
   45889 
   45890 @end table
   45891 
   45892 @node MIPS-Specific Protocol Details
   45893 @subsection @acronym{MIPS}-specific Protocol Details
   45894 
   45895 @menu
   45896 * MIPS Register packet Format::
   45897 * MIPS Breakpoint Kinds::
   45898 @end menu
   45899 
   45900 @node MIPS Register packet Format
   45901 @subsubsection @acronym{MIPS} Register Packet Format
   45902 @cindex register packet format, @acronym{MIPS}
   45903 
   45904 The following @code{g}/@code{G} packets have previously been defined.
   45905 In the below, some thirty-two bit registers are transferred as
   45906 sixty-four bits.  Those registers should be zero/sign extended (which?)
   45907 to fill the space allocated.  Register bytes are transferred in target
   45908 byte order.  The two nibbles within a register byte are transferred
   45909 most-significant -- least-significant.
   45910 
   45911 @table @r
   45912 
   45913 @item MIPS32
   45914 All registers are transferred as thirty-two bit quantities in the order:
   45915 32 general-purpose; sr; lo; hi; bad; cause; pc; 32 floating-point
   45916 registers; fsr; fir; fp.
   45917 
   45918 @item MIPS64
   45919 All registers are transferred as sixty-four bit quantities (including
   45920 thirty-two bit registers such as @code{sr}).  The ordering is the same
   45921 as @code{MIPS32}.
   45922 
   45923 @end table
   45924 
   45925 @node MIPS Breakpoint Kinds
   45926 @subsubsection @acronym{MIPS} Breakpoint Kinds
   45927 @cindex breakpoint kinds, @acronym{MIPS}
   45928 
   45929 These breakpoint kinds are defined for the @samp{Z0} and @samp{Z1} packets.
   45930 
   45931 @table @r
   45932 
   45933 @item 2
   45934 16-bit @acronym{MIPS16} mode breakpoint.
   45935 
   45936 @item 3
   45937 16-bit @acronym{microMIPS} mode breakpoint.
   45938 
   45939 @item 4
   45940 32-bit standard @acronym{MIPS} mode breakpoint.
   45941 
   45942 @item 5
   45943 32-bit @acronym{microMIPS} mode breakpoint.
   45944 
   45945 @end table
   45946 
   45947 @node Tracepoint Packets
   45948 @section Tracepoint Packets
   45949 @cindex tracepoint packets
   45950 @cindex packets, tracepoint
   45951 
   45952 Here we describe the packets @value{GDBN} uses to implement
   45953 tracepoints (@pxref{Tracepoints}).
   45954 
   45955 @table @samp
   45956 
   45957 @item QTDP:@var{n}:@var{addr}:@var{ena}:@var{step}:@var{pass}[:F@var{flen}][:X@var{len},@var{bytes}]@r{[}-@r{]}
   45958 @cindex @samp{QTDP} packet
   45959 Create a new tracepoint, number @var{n}, at @var{addr}.  If @var{ena}
   45960 is @samp{E}, then the tracepoint is enabled; if it is @samp{D}, then
   45961 the tracepoint is disabled.  The @var{step} gives the tracepoint's step
   45962 count, and @var{pass} gives its pass count.  If an @samp{F} is present,
   45963 then the tracepoint is to be a fast tracepoint, and the @var{flen} is
   45964 the number of bytes that the target should copy elsewhere to make room
   45965 for the tracepoint.  If an @samp{X} is present, it introduces a
   45966 tracepoint condition, which consists of a hexadecimal length, followed
   45967 by a comma and hex-encoded bytes, in a manner similar to action
   45968 encodings as described below.  If the trailing @samp{-} is present,
   45969 further @samp{QTDP} packets will follow to specify this tracepoint's
   45970 actions.
   45971 
   45972 Replies:
   45973 @table @samp
   45974 @item OK
   45975 The packet was understood and carried out.
   45976 @item qRelocInsn
   45977 @xref{Tracepoint Packets,,Relocate instruction reply packet}.
   45978 @end table
   45979 
   45980 @item QTDP:-@var{n}:@var{addr}:@r{[}S@r{]}@var{action}@dots{}@r{[}-@r{]}
   45981 Define actions to be taken when a tracepoint is hit.  The @var{n} and
   45982 @var{addr} must be the same as in the initial @samp{QTDP} packet for
   45983 this tracepoint.  This packet may only be sent immediately after
   45984 another @samp{QTDP} packet that ended with a @samp{-}.  If the
   45985 trailing @samp{-} is present, further @samp{QTDP} packets will follow,
   45986 specifying more actions for this tracepoint.
   45987 
   45988 In the series of action packets for a given tracepoint, at most one
   45989 can have an @samp{S} before its first @var{action}.  If such a packet
   45990 is sent, it and the following packets define ``while-stepping''
   45991 actions.  Any prior packets define ordinary actions --- that is, those
   45992 taken when the tracepoint is first hit.  If no action packet has an
   45993 @samp{S}, then all the packets in the series specify ordinary
   45994 tracepoint actions.
   45995 
   45996 The @samp{@var{action}@dots{}} portion of the packet is a series of
   45997 actions, concatenated without separators.  Each action has one of the
   45998 following forms:
   45999 
   46000 @table @samp
   46001 
   46002 @item R @var{mask}
   46003 Collect the registers whose bits are set in @var{mask},
   46004 a hexadecimal number whose @var{i}'th bit is set if register number
   46005 @var{i} should be collected.  (The least significant bit is numbered
   46006 zero.)  Note that @var{mask} may be any number of digits long; it may
   46007 not fit in a 32-bit word.
   46008 
   46009 @item M @var{basereg},@var{offset},@var{len}
   46010 Collect @var{len} bytes of memory starting at the address in register
   46011 number @var{basereg}, plus @var{offset}.  If @var{basereg} is
   46012 @samp{-1}, then the range has a fixed address: @var{offset} is the
   46013 address of the lowest byte to collect.  The @var{basereg},
   46014 @var{offset}, and @var{len} parameters are all unsigned hexadecimal
   46015 values (the @samp{-1} value for @var{basereg} is a special case).
   46016 
   46017 @item X @var{len},@var{expr}
   46018 Evaluate @var{expr}, whose length is @var{len}, and collect memory as
   46019 it directs.  The agent expression @var{expr} is as described in
   46020 @ref{Agent Expressions}.  Each byte of the expression is encoded as a
   46021 two-digit hex number in the packet; @var{len} is the number of bytes
   46022 in the expression (and thus one-half the number of hex digits in the
   46023 packet).
   46024 
   46025 @end table
   46026 
   46027 Any number of actions may be packed together in a single @samp{QTDP}
   46028 packet, as long as the packet does not exceed the maximum packet
   46029 length (400 bytes, for many stubs).  There may be only one @samp{R}
   46030 action per tracepoint, and it must precede any @samp{M} or @samp{X}
   46031 actions.  Any registers referred to by @samp{M} and @samp{X} actions
   46032 must be collected by a preceding @samp{R} action.  (The
   46033 ``while-stepping'' actions are treated as if they were attached to a
   46034 separate tracepoint, as far as these restrictions are concerned.)
   46035 
   46036 Replies:
   46037 @table @samp
   46038 @item OK
   46039 The packet was understood and carried out.
   46040 @item qRelocInsn
   46041 @xref{Tracepoint Packets,,Relocate instruction reply packet}.
   46042 @end table
   46043 
   46044 @item QTDPsrc:@var{n}:@var{addr}:@var{type}:@var{start}:@var{slen}:@var{bytes}
   46045 @cindex @samp{QTDPsrc} packet
   46046 Specify a source string of tracepoint @var{n} at address @var{addr}.
   46047 This is useful to get accurate reproduction of the tracepoints
   46048 originally downloaded at the beginning of the trace run.  The @var{type}
   46049 is the name of the tracepoint part, such as @samp{cond} for the
   46050 tracepoint's conditional expression (see below for a list of types), while
   46051 @var{bytes} is the string, encoded in hexadecimal.
   46052 
   46053 @var{start} is the offset of the @var{bytes} within the overall source
   46054 string, while @var{slen} is the total length of the source string.
   46055 This is intended for handling source strings that are longer than will
   46056 fit in a single packet.
   46057 @c Add detailed example when this info is moved into a dedicated
   46058 @c tracepoint descriptions section.
   46059 
   46060 The available string types are @samp{at} for the location,
   46061 @samp{cond} for the conditional, and @samp{cmd} for an action command.
   46062 @value{GDBN} sends a separate packet for each command in the action
   46063 list, in the same order in which the commands are stored in the list.
   46064 
   46065 The target does not need to do anything with source strings except
   46066 report them back as part of the replies to the @samp{qTfP}/@samp{qTsP}
   46067 query packets.
   46068 
   46069 Although this packet is optional, and @value{GDBN} will only send it
   46070 if the target replies with @samp{TracepointSource} @xref{General
   46071 Query Packets}, it makes both disconnected tracing and trace files
   46072 much easier to use.  Otherwise the user must be careful that the
   46073 tracepoints in effect while looking at trace frames are identical to
   46074 the ones in effect during the trace run; even a small discrepancy
   46075 could cause @samp{tdump} not to work, or a particular trace frame not
   46076 be found.
   46077 
   46078 @item QTDV:@var{n}:@var{value}:@var{builtin}:@var{name}
   46079 @cindex define trace state variable, remote request
   46080 @cindex @samp{QTDV} packet
   46081 Create a new trace state variable, number @var{n}, with an initial
   46082 value of @var{value}, which is a 64-bit signed integer.  Both @var{n}
   46083 and @var{value} are encoded as hexadecimal values. @value{GDBN} has
   46084 the option of not using this packet for initial values of zero; the
   46085 target should simply create the trace state variables as they are
   46086 mentioned in expressions.  The value @var{builtin} should be 1 (one)
   46087 if the trace state variable is builtin and 0 (zero) if it is not builtin.
   46088 @value{GDBN} only sets @var{builtin} to 1 if a previous @samp{qTfV} or
   46089 @samp{qTsV} packet had it set.  The contents of @var{name} is the
   46090 hex-encoded name (without the leading @samp{$}) of the trace state
   46091 variable.
   46092 
   46093 @item QTFrame:@var{n}
   46094 @cindex @samp{QTFrame} packet
   46095 Select the @var{n}'th tracepoint frame from the buffer, and use the
   46096 register and memory contents recorded there to answer subsequent
   46097 request packets from @value{GDBN}.
   46098 
   46099 A successful reply from the stub indicates that the stub has found the
   46100 requested frame.  The response is a series of parts, concatenated
   46101 without separators, describing the frame we selected.  Each part has
   46102 one of the following forms:
   46103 
   46104 @table @samp
   46105 @item F @var{f}
   46106 The selected frame is number @var{n} in the trace frame buffer;
   46107 @var{f} is a hexadecimal number.  If @var{f} is @samp{-1}, then there
   46108 was no frame matching the criteria in the request packet.
   46109 
   46110 @item T @var{t}
   46111 The selected trace frame records a hit of tracepoint number @var{t};
   46112 @var{t} is a hexadecimal number.
   46113 
   46114 @end table
   46115 
   46116 @item QTFrame:pc:@var{addr}
   46117 Like @samp{QTFrame:@var{n}}, but select the first tracepoint frame after the
   46118 currently selected frame whose PC is @var{addr};
   46119 @var{addr} is a hexadecimal number.
   46120 
   46121 @item QTFrame:tdp:@var{t}
   46122 Like @samp{QTFrame:@var{n}}, but select the first tracepoint frame after the
   46123 currently selected frame that is a hit of tracepoint @var{t}; @var{t}
   46124 is a hexadecimal number.
   46125 
   46126 @item QTFrame:range:@var{start}:@var{end}
   46127 Like @samp{QTFrame:@var{n}}, but select the first tracepoint frame after the
   46128 currently selected frame whose PC is between @var{start} (inclusive)
   46129 and @var{end} (inclusive); @var{start} and @var{end} are hexadecimal
   46130 numbers.
   46131 
   46132 @item QTFrame:outside:@var{start}:@var{end}
   46133 Like @samp{QTFrame:range:@var{start}:@var{end}}, but select the first
   46134 frame @emph{outside} the given range of addresses (exclusive).
   46135 
   46136 @item qTMinFTPILen
   46137 @cindex @samp{qTMinFTPILen} packet
   46138 This packet requests the minimum length of instruction at which a fast
   46139 tracepoint (@pxref{Set Tracepoints}) may be placed.  For instance, on
   46140 the 32-bit x86 architecture, it is possible to use a 4-byte jump, but
   46141 it depends on the target system being able to create trampolines in
   46142 the first 64K of memory, which might or might not be possible for that
   46143 system.  So the reply to this packet will be 4 if it is able to
   46144 arrange for that.
   46145 
   46146 Replies:
   46147 
   46148 @table @samp
   46149 @item 0
   46150 The minimum instruction length is currently unknown.
   46151 @item @var{length}
   46152 The minimum instruction length is @var{length}, where @var{length}
   46153 is a hexadecimal number greater or equal to 1.  A reply
   46154 of 1 means that a fast tracepoint may be placed on any instruction
   46155 regardless of size.
   46156 @item E
   46157 An error has occurred.
   46158 @end table
   46159 
   46160 @item QTStart
   46161 @cindex @samp{QTStart} packet
   46162 Begin the tracepoint experiment.  Begin collecting data from
   46163 tracepoint hits in the trace frame buffer.  This packet supports the
   46164 @samp{qRelocInsn} reply (@pxref{Tracepoint Packets,,Relocate
   46165 instruction reply packet}).
   46166 
   46167 @item QTStop
   46168 @cindex @samp{QTStop} packet
   46169 End the tracepoint experiment.  Stop collecting trace frames.
   46170 
   46171 @item QTEnable:@var{n}:@var{addr}
   46172 @anchor{QTEnable}
   46173 @cindex @samp{QTEnable} packet
   46174 Enable tracepoint @var{n} at address @var{addr} in a started tracepoint
   46175 experiment.  If the tracepoint was previously disabled, then collection
   46176 of data from it will resume.
   46177 
   46178 @item QTDisable:@var{n}:@var{addr}
   46179 @anchor{QTDisable}
   46180 @cindex @samp{QTDisable} packet
   46181 Disable tracepoint @var{n} at address @var{addr} in a started tracepoint
   46182 experiment.  No more data will be collected from the tracepoint unless
   46183 @samp{QTEnable:@var{n}:@var{addr}} is subsequently issued.
   46184 
   46185 @item QTinit
   46186 @cindex @samp{QTinit} packet
   46187 Clear the table of tracepoints, and empty the trace frame buffer.
   46188 
   46189 @item QTro:@var{start1},@var{end1}:@var{start2},@var{end2}:@dots{}
   46190 @cindex @samp{QTro} packet
   46191 Establish the given ranges of memory as ``transparent''.  The stub
   46192 will answer requests for these ranges from memory's current contents,
   46193 if they were not collected as part of the tracepoint hit.
   46194 
   46195 @value{GDBN} uses this to mark read-only regions of memory, like those
   46196 containing program code.  Since these areas never change, they should
   46197 still have the same contents they did when the tracepoint was hit, so
   46198 there's no reason for the stub to refuse to provide their contents.
   46199 
   46200 @item QTDisconnected:@var{value}
   46201 @cindex @samp{QTDisconnected} packet
   46202 Set the choice to what to do with the tracing run when @value{GDBN}
   46203 disconnects from the target.  A @var{value} of 1 directs the target to
   46204 continue the tracing run, while 0 tells the target to stop tracing if
   46205 @value{GDBN} is no longer in the picture.
   46206 
   46207 @item qTStatus
   46208 @cindex @samp{qTStatus} packet
   46209 Ask the stub if there is a trace experiment running right now.
   46210 
   46211 The reply has the form:
   46212 
   46213 @table @samp
   46214 
   46215 @item T@var{running}@r{[};@var{field}@r{]}@dots{}
   46216 @var{running} is a single digit @code{1} if the trace is presently
   46217 running, or @code{0} if not.  It is followed by semicolon-separated
   46218 optional fields that an agent may use to report additional status.
   46219 
   46220 @end table
   46221 
   46222 If the trace is not running, the agent may report any of several
   46223 explanations as one of the optional fields:
   46224 
   46225 @table @samp
   46226 
   46227 @item tnotrun:0
   46228 No trace has been run yet.
   46229 
   46230 @item tstop[:@var{text}]:0
   46231 The trace was stopped by a user-originated stop command.  The optional
   46232 @var{text} field is a user-supplied string supplied as part of the
   46233 stop command (for instance, an explanation of why the trace was
   46234 stopped manually).  It is hex-encoded.
   46235 
   46236 @item tfull:0
   46237 The trace stopped because the trace buffer filled up.
   46238 
   46239 @item tdisconnected:0
   46240 The trace stopped because @value{GDBN} disconnected from the target.
   46241 
   46242 @item tpasscount:@var{tpnum}
   46243 The trace stopped because tracepoint @var{tpnum} exceeded its pass count.
   46244 
   46245 @item terror:@var{text}:@var{tpnum}
   46246 The trace stopped because tracepoint @var{tpnum} had an error.  The
   46247 string @var{text} is available to describe the nature of the error
   46248 (for instance, a divide by zero in the condition expression); it
   46249 is hex encoded.
   46250 
   46251 @item tunknown:0
   46252 The trace stopped for some other reason.
   46253 
   46254 @end table
   46255 
   46256 Additional optional fields supply statistical and other information.
   46257 Although not required, they are extremely useful for users monitoring
   46258 the progress of a trace run.  If a trace has stopped, and these
   46259 numbers are reported, they must reflect the state of the just-stopped
   46260 trace.
   46261 
   46262 @table @samp
   46263 
   46264 @item tframes:@var{n}
   46265 The number of trace frames in the buffer.
   46266 
   46267 @item tcreated:@var{n}
   46268 The total number of trace frames created during the run. This may
   46269 be larger than the trace frame count, if the buffer is circular.
   46270 
   46271 @item tsize:@var{n}
   46272 The total size of the trace buffer, in bytes.
   46273 
   46274 @item tfree:@var{n}
   46275 The number of bytes still unused in the buffer.
   46276 
   46277 @item circular:@var{n}
   46278 The value of the circular trace buffer flag.  @code{1} means that the
   46279 trace buffer is circular and old trace frames will be discarded if
   46280 necessary to make room, @code{0} means that the trace buffer is linear
   46281 and may fill up.
   46282 
   46283 @item disconn:@var{n}
   46284 The value of the disconnected tracing flag.  @code{1} means that
   46285 tracing will continue after @value{GDBN} disconnects, @code{0} means
   46286 that the trace run will stop.
   46287 
   46288 @end table
   46289 
   46290 @item qTP:@var{tp}:@var{addr}
   46291 @cindex tracepoint status, remote request
   46292 @cindex @samp{qTP} packet
   46293 Ask the stub for the current state of tracepoint number @var{tp} at
   46294 address @var{addr}.
   46295 
   46296 Replies:
   46297 @table @samp
   46298 @item V@var{hits}:@var{usage}
   46299 The tracepoint has been hit @var{hits} times so far during the trace
   46300 run, and accounts for @var{usage} in the trace buffer.  Note that
   46301 @code{while-stepping} steps are not counted as separate hits, but the
   46302 steps' space consumption is added into the usage number.
   46303 
   46304 @end table
   46305 
   46306 @item qTV:@var{var}
   46307 @cindex trace state variable value, remote request
   46308 @cindex @samp{qTV} packet
   46309 Ask the stub for the value of the trace state variable number @var{var}.
   46310 
   46311 Replies:
   46312 @table @samp
   46313 @item V@var{value}
   46314 The value of the variable is @var{value}.  This will be the current
   46315 value of the variable if the user is examining a running target, or a
   46316 saved value if the variable was collected in the trace frame that the
   46317 user is looking at.  Note that multiple requests may result in
   46318 different reply values, such as when requesting values while the
   46319 program is running.
   46320 
   46321 @item U
   46322 The value of the variable is unknown.  This would occur, for example,
   46323 if the user is examining a trace frame in which the requested variable
   46324 was not collected.
   46325 @end table
   46326 
   46327 @item qTfP
   46328 @cindex @samp{qTfP} packet
   46329 @itemx qTsP
   46330 @cindex @samp{qTsP} packet
   46331 These packets request data about tracepoints that are being used by
   46332 the target.  @value{GDBN} sends @code{qTfP} to get the first piece
   46333 of data, and multiple @code{qTsP} to get additional pieces.  Replies
   46334 to these packets generally take the form of the @code{QTDP} packets
   46335 that define tracepoints. (FIXME add detailed syntax)
   46336 
   46337 @item qTfV
   46338 @cindex @samp{qTfV} packet
   46339 @itemx qTsV
   46340 @cindex @samp{qTsV} packet
   46341 These packets request data about trace state variables that are on the
   46342 target.  @value{GDBN} sends @code{qTfV} to get the first vari of data,
   46343 and multiple @code{qTsV} to get additional variables.  Replies to
   46344 these packets follow the syntax of the @code{QTDV} packets that define
   46345 trace state variables.
   46346 
   46347 @item qTfSTM
   46348 @itemx qTsSTM
   46349 @anchor{qTfSTM}
   46350 @anchor{qTsSTM}
   46351 @cindex @samp{qTfSTM} packet
   46352 @cindex @samp{qTsSTM} packet
   46353 These packets request data about static tracepoint markers that exist
   46354 in the target program.  @value{GDBN} sends @code{qTfSTM} to get the
   46355 first piece of data, and multiple @code{qTsSTM} to get additional
   46356 pieces.  Replies to these packets take the following form:
   46357 
   46358 Reply:
   46359 @table @samp
   46360 @item m @var{address}:@var{id}:@var{extra}
   46361 A single marker
   46362 @item m @var{address}:@var{id}:@var{extra},@var{address}:@var{id}:@var{extra}@dots{}
   46363 a comma-separated list of markers
   46364 @item l
   46365 (lower case letter @samp{L}) denotes end of list.
   46366 @end table
   46367 
   46368 The @var{address} is encoded in hex;
   46369 @var{id} and @var{extra} are strings encoded in hex.
   46370 
   46371 In response to each query, the target will reply with a list of one or
   46372 more markers, separated by commas.  @value{GDBN} will respond to each
   46373 reply with a request for more markers (using the @samp{qs} form of the
   46374 query), until the target responds with @samp{l} (lower-case ell, for
   46375 @dfn{last}).
   46376 
   46377 @item qTSTMat:@var{address}
   46378 @anchor{qTSTMat}
   46379 @cindex @samp{qTSTMat} packet
   46380 This packets requests data about static tracepoint markers in the
   46381 target program at @var{address}.  Replies to this packet follow the
   46382 syntax of the @samp{qTfSTM} and @code{qTsSTM} packets that list static
   46383 tracepoint markers.
   46384 
   46385 @item QTSave:@var{filename}
   46386 @cindex @samp{QTSave} packet
   46387 This packet directs the target to save trace data to the file name
   46388 @var{filename} in the target's filesystem.  The @var{filename} is encoded
   46389 as a hex string; the interpretation of the file name (relative vs
   46390 absolute, wild cards, etc) is up to the target.
   46391 
   46392 @item qTBuffer:@var{offset},@var{len}
   46393 @cindex @samp{qTBuffer} packet
   46394 Return up to @var{len} bytes of the current contents of trace buffer,
   46395 starting at @var{offset}.  The trace buffer is treated as if it were
   46396 a contiguous collection of traceframes, as per the trace file format.
   46397 The reply consists as many hex-encoded bytes as the target can deliver
   46398 in a packet; it is not an error to return fewer than were asked for.
   46399 A reply consisting of just @code{l} indicates that no bytes are
   46400 available.
   46401 
   46402 @item QTBuffer:circular:@var{value}
   46403 This packet directs the target to use a circular trace buffer if
   46404 @var{value} is 1, or a linear buffer if the value is 0.
   46405 
   46406 @item QTBuffer:size:@var{size}
   46407 @anchor{QTBuffer-size}
   46408 @cindex @samp{QTBuffer size} packet
   46409 This packet directs the target to make the trace buffer be of size
   46410 @var{size} if possible.  A value of @code{-1} tells the target to
   46411 use whatever size it prefers.
   46412 
   46413 @item QTNotes:@r{[}@var{type}:@var{text}@r{]}@r{[};@var{type}:@var{text}@r{]}@dots{}
   46414 @cindex @samp{QTNotes} packet
   46415 This packet adds optional textual notes to the trace run.  Allowable
   46416 types include @code{user}, @code{notes}, and @code{tstop}, the
   46417 @var{text} fields are arbitrary strings, hex-encoded.
   46418 
   46419 @end table
   46420 
   46421 @subsection Relocate instruction reply packet
   46422 When installing fast tracepoints in memory, the target may need to
   46423 relocate the instruction currently at the tracepoint address to a
   46424 different address in memory.  For most instructions, a simple copy is
   46425 enough, but, for example, call instructions that implicitly push the
   46426 return address on the stack, and relative branches or other
   46427 PC-relative instructions require offset adjustment, so that the effect
   46428 of executing the instruction at a different address is the same as if
   46429 it had executed in the original location.
   46430 
   46431 In response to several of the tracepoint packets, the target may also
   46432 respond with a number of intermediate @samp{qRelocInsn} request
   46433 packets before the final result packet, to have @value{GDBN} handle
   46434 this relocation operation.  If a packet supports this mechanism, its
   46435 documentation will explicitly say so.  See for example the above
   46436 descriptions for the @samp{QTStart} and @samp{QTDP} packets.  The
   46437 format of the request is:
   46438 
   46439 @table @samp
   46440 @item qRelocInsn:@var{from};@var{to}
   46441 
   46442 This requests @value{GDBN} to copy instruction at address @var{from}
   46443 to address @var{to}, possibly adjusted so that executing the
   46444 instruction at @var{to} has the same effect as executing it at
   46445 @var{from}.  @value{GDBN} writes the adjusted instruction to target
   46446 memory starting at @var{to}.
   46447 @end table
   46448 
   46449 Replies:
   46450 @table @samp
   46451 @item qRelocInsn:@var{adjusted_size}
   46452 Informs the stub the relocation is complete.  The @var{adjusted_size} is
   46453 the length in bytes of resulting relocated instruction sequence.
   46454 @end table
   46455 
   46456 @node Host I/O Packets
   46457 @section Host I/O Packets
   46458 @cindex Host I/O, remote protocol
   46459 @cindex file transfer, remote protocol
   46460 
   46461 The @dfn{Host I/O} packets allow @value{GDBN} to perform I/O
   46462 operations on the far side of a remote link.  For example, Host I/O is
   46463 used to upload and download files to a remote target with its own
   46464 filesystem.  Host I/O uses the same constant values and data structure
   46465 layout as the target-initiated File-I/O protocol.  However, the
   46466 Host I/O packets are structured differently.  The target-initiated
   46467 protocol relies on target memory to store parameters and buffers.
   46468 Host I/O requests are initiated by @value{GDBN}, and the
   46469 target's memory is not involved.  @xref{File-I/O Remote Protocol
   46470 Extension}, for more details on the target-initiated protocol.
   46471 
   46472 The Host I/O request packets all encode a single operation along with
   46473 its arguments.  They have this format:
   46474 
   46475 @table @samp
   46476 
   46477 @item vFile:@var{operation}: @var{parameter}@dots{}
   46478 @var{operation} is the name of the particular request; the target
   46479 should compare the entire packet name up to the second colon when checking
   46480 for a supported operation.  The format of @var{parameter} depends on
   46481 the operation.  Numbers are always passed in hexadecimal.  Negative
   46482 numbers have an explicit minus sign (i.e.@: two's complement is not
   46483 used).  Strings (e.g.@: filenames) are encoded as a series of
   46484 hexadecimal bytes.  The last argument to a system call may be a
   46485 buffer of escaped binary data (@pxref{Binary Data}).
   46486 
   46487 @end table
   46488 
   46489 The valid responses to Host I/O packets are:
   46490 
   46491 @table @samp
   46492 
   46493 @item F @var{result} [, @var{errno}] [; @var{attachment}]
   46494 @var{result} is the integer value returned by this operation, usually
   46495 non-negative for success and -1 for errors.  If an error has occurred,
   46496 @var{errno} will be included in the result specifying a
   46497 value defined by the File-I/O protocol (@pxref{Errno Values}).  For
   46498 operations which return data, @var{attachment} supplies the data as a
   46499 binary buffer.  Binary buffers in response packets are escaped in the
   46500 normal way (@pxref{Binary Data}).  See the individual packet
   46501 documentation for the interpretation of @var{result} and
   46502 @var{attachment}.
   46503 
   46504 @item @w{}
   46505 An empty response indicates that this operation is not recognized.
   46506 
   46507 @end table
   46508 
   46509 These are the supported Host I/O operations:
   46510 
   46511 @table @samp
   46512 @item vFile:open: @var{filename}, @var{flags}, @var{mode}
   46513 Open a file at @var{filename} and return a file descriptor for it, or
   46514 return -1 if an error occurs.  The @var{filename} is a string,
   46515 @var{flags} is an integer indicating a mask of open flags
   46516 (@pxref{Open Flags}), and @var{mode} is an integer indicating a mask
   46517 of mode bits to use if the file is created (@pxref{mode_t Values}).
   46518 @xref{open}, for details of the open flags and mode values.
   46519 
   46520 @item vFile:close: @var{fd}
   46521 Close the open file corresponding to @var{fd} and return 0, or
   46522 -1 if an error occurs.
   46523 
   46524 @item vFile:pread: @var{fd}, @var{count}, @var{offset}
   46525 Read data from the open file corresponding to @var{fd}.  Up to
   46526 @var{count} bytes will be read from the file, starting at @var{offset}
   46527 relative to the start of the file.  The target may read fewer bytes;
   46528 common reasons include packet size limits and an end-of-file
   46529 condition.  The number of bytes read is returned.  Zero should only be
   46530 returned for a successful read at the end of the file, or if
   46531 @var{count} was zero.
   46532 
   46533 The data read should be returned as a binary attachment on success.
   46534 If zero bytes were read, the response should include an empty binary
   46535 attachment (i.e.@: a trailing semicolon).  The return value is the
   46536 number of target bytes read; the binary attachment may be longer if
   46537 some characters were escaped.
   46538 
   46539 @item vFile:pwrite: @var{fd}, @var{offset}, @var{data}
   46540 Write @var{data} (a binary buffer) to the open file corresponding
   46541 to @var{fd}.  Start the write at @var{offset} from the start of the
   46542 file.  Unlike many @code{write} system calls, there is no
   46543 separate @var{count} argument; the length of @var{data} in the
   46544 packet is used.  @samp{vFile:pwrite} returns the number of bytes written,
   46545 which may be shorter than the length of @var{data}, or -1 if an
   46546 error occurred.
   46547 
   46548 @item vFile:fstat: @var{fd}
   46549 Get information about the open file corresponding to @var{fd}.
   46550 On success the information is returned as a binary attachment
   46551 and the return value is the size of this attachment in bytes.
   46552 If an error occurs the return value is -1.  The format of the
   46553 returned binary attachment is as described in @ref{struct stat}.
   46554 
   46555 @item vFile:stat: @var{filename}
   46556 Get information about the file @var{filename} on the target.
   46557 On success the information is returned as a binary attachment
   46558 and the return value is the size of this attachment in bytes.
   46559 If an error occurs the return value is -1.  The format of the
   46560 returned binary attachment is as described in @ref{struct stat}.
   46561 
   46562 @item vFile:unlink: @var{filename}
   46563 Delete the file at @var{filename} on the target.  Return 0,
   46564 or -1 if an error occurs.  The @var{filename} is a string.
   46565 
   46566 @item vFile:readlink: @var{filename}
   46567 Read value of symbolic link @var{filename} on the target.  Return
   46568 the number of bytes read, or -1 if an error occurs.
   46569 
   46570 The data read should be returned as a binary attachment on success.
   46571 If zero bytes were read, the response should include an empty binary
   46572 attachment (i.e.@: a trailing semicolon).  The return value is the
   46573 number of target bytes read; the binary attachment may be longer if
   46574 some characters were escaped.
   46575 
   46576 @item vFile:setfs: @var{pid}
   46577 Select the filesystem on which @code{vFile} operations with
   46578 @var{filename} arguments will operate.  This is required for
   46579 @value{GDBN} to be able to access files on remote targets where
   46580 the remote stub does not share a common filesystem with the
   46581 inferior(s).
   46582 
   46583 If @var{pid} is nonzero, select the filesystem as seen by process
   46584 @var{pid}.  If @var{pid} is zero, select the filesystem as seen by
   46585 the remote stub.  Return 0 on success, or -1 if an error occurs.
   46586 If @code{vFile:setfs:} indicates success, the selected filesystem
   46587 remains selected until the next successful @code{vFile:setfs:}
   46588 operation.
   46589 
   46590 @end table
   46591 
   46592 @node Interrupts
   46593 @section Interrupts
   46594 @cindex interrupts (remote protocol)
   46595 @anchor{interrupting remote targets}
   46596 
   46597 In all-stop mode, when a program on the remote target is running,
   46598 @value{GDBN} may attempt to interrupt it by sending a @samp{Ctrl-C},
   46599 @code{BREAK} or a @code{BREAK} followed by @code{g}, control of which
   46600 is specified via @value{GDBN}'s @samp{interrupt-sequence}.
   46601 
   46602 The precise meaning of @code{BREAK} is defined by the transport
   46603 mechanism and may, in fact, be undefined.  @value{GDBN} does not
   46604 currently define a @code{BREAK} mechanism for any of the network
   46605 interfaces except for TCP, in which case @value{GDBN} sends the
   46606 @code{telnet} BREAK sequence.
   46607 
   46608 @samp{Ctrl-C}, on the other hand, is defined and implemented for all
   46609 transport mechanisms.  It is represented by sending the single byte
   46610 @code{0x03} without any of the usual packet overhead described in
   46611 the Overview section (@pxref{Overview}).  When a @code{0x03} byte is
   46612 transmitted as part of a packet, it is considered to be packet data
   46613 and does @emph{not} represent an interrupt.  E.g., an @samp{X} packet
   46614 (@pxref{X packet}), used for binary downloads, may include an unescaped
   46615 @code{0x03} as part of its packet.
   46616 
   46617 @code{BREAK} followed by @code{g} is also known as Magic SysRq g.
   46618 When Linux kernel receives this sequence from serial port,
   46619 it stops execution and connects to gdb.
   46620 
   46621 In non-stop mode, because packet resumptions are asynchronous
   46622 (@pxref{vCont packet}), @value{GDBN} is always free to send a remote
   46623 command to the remote stub, even when the target is running.  For that
   46624 reason, @value{GDBN} instead sends a regular packet (@pxref{vCtrlC
   46625 packet}) with the usual packet framing instead of the single byte
   46626 @code{0x03}.
   46627 
   46628 Stubs are not required to recognize these interrupt mechanisms and the
   46629 precise meaning associated with receipt of the interrupt is
   46630 implementation defined.  If the target supports debugging of multiple
   46631 threads and/or processes, it should attempt to interrupt all 
   46632 currently-executing threads and processes.
   46633 If the stub is successful at interrupting the
   46634 running program, it should send one of the stop
   46635 reply packets (@pxref{Stop Reply Packets}) to @value{GDBN} as a result
   46636 of successfully stopping the program in all-stop mode, and a stop reply
   46637 for each stopped thread in non-stop mode.
   46638 Interrupts received while the
   46639 program is stopped are queued and the program will be interrupted when
   46640 it is resumed next time.
   46641 
   46642 @node Notification Packets
   46643 @section Notification Packets
   46644 @cindex notification packets
   46645 @cindex packets, notification
   46646 
   46647 The @value{GDBN} remote serial protocol includes @dfn{notifications},
   46648 packets that require no acknowledgment.  Both the GDB and the stub
   46649 may send notifications (although the only notifications defined at
   46650 present are sent by the stub).  Notifications carry information
   46651 without incurring the round-trip latency of an acknowledgment, and so
   46652 are useful for low-impact communications where occasional packet loss
   46653 is not a problem.
   46654 
   46655 A notification packet has the form @samp{% @var{data} #
   46656 @var{checksum}}, where @var{data} is the content of the notification,
   46657 and @var{checksum} is a checksum of @var{data}, computed and formatted
   46658 as for ordinary @value{GDBN} packets.  A notification's @var{data}
   46659 never contains @samp{$}, @samp{%} or @samp{#} characters.  Upon
   46660 receiving a notification, the recipient sends no @samp{+} or @samp{-}
   46661 to acknowledge the notification's receipt or to report its corruption.
   46662 
   46663 Every notification's @var{data} begins with a name, which contains no
   46664 colon characters, followed by a colon character.
   46665 
   46666 Recipients should silently ignore corrupted notifications and
   46667 notifications they do not understand.  Recipients should restart
   46668 timeout periods on receipt of a well-formed notification, whether or
   46669 not they understand it.
   46670 
   46671 Senders should only send the notifications described here when this
   46672 protocol description specifies that they are permitted.  In the
   46673 future, we may extend the protocol to permit existing notifications in
   46674 new contexts; this rule helps older senders avoid confusing newer
   46675 recipients.
   46676 
   46677 (Older versions of @value{GDBN} ignore bytes received until they see
   46678 the @samp{$} byte that begins an ordinary packet, so new stubs may
   46679 transmit notifications without fear of confusing older clients.  There
   46680 are no notifications defined for @value{GDBN} to send at the moment, but we
   46681 assume that most older stubs would ignore them, as well.)
   46682 
   46683 Each notification is comprised of three parts:
   46684 @table @samp
   46685 @item @var{name}:@var{event}
   46686 The notification packet is sent by the side that initiates the
   46687 exchange (currently, only the stub does that), with @var{event}
   46688 carrying the specific information about the notification, and
   46689 @var{name} specifying the name of the notification.
   46690 @item @var{ack}
   46691 The acknowledge sent by the other side, usually @value{GDBN}, to
   46692 acknowledge the exchange and request the event.
   46693 @end table
   46694 
   46695 The purpose of an asynchronous notification mechanism is to report to
   46696 @value{GDBN} that something interesting happened in the remote stub.
   46697 
   46698 The remote stub may send notification @var{name}:@var{event}
   46699 at any time, but @value{GDBN} acknowledges the notification when
   46700 appropriate.  The notification event is pending before @value{GDBN}
   46701 acknowledges.  Only one notification at a time may be pending; if
   46702 additional events occur before @value{GDBN} has acknowledged the
   46703 previous notification, they must be queued by the stub for later
   46704 synchronous transmission in response to @var{ack} packets from
   46705 @value{GDBN}.  Because the notification mechanism is unreliable,
   46706 the stub is permitted to resend a notification if it believes
   46707 @value{GDBN} may not have received it.
   46708 
   46709 Specifically, notifications may appear when @value{GDBN} is not
   46710 otherwise reading input from the stub, or when @value{GDBN} is
   46711 expecting to read a normal synchronous response or a
   46712 @samp{+}/@samp{-} acknowledgment to a packet it has sent.
   46713 Notification packets are distinct from any other communication from
   46714 the stub so there is no ambiguity.
   46715 
   46716 After receiving a notification, @value{GDBN} shall acknowledge it by
   46717 sending a @var{ack} packet as a regular, synchronous request to the
   46718 stub.  Such acknowledgment is not required to happen immediately, as
   46719 @value{GDBN} is permitted to send other, unrelated packets to the
   46720 stub first, which the stub should process normally.
   46721 
   46722 Upon receiving a @var{ack} packet, if the stub has other queued
   46723 events to report to @value{GDBN}, it shall respond by sending a
   46724 normal @var{event}.  @value{GDBN} shall then send another @var{ack}
   46725 packet to solicit further responses; again, it is permitted to send
   46726 other, unrelated packets as well which the stub should process
   46727 normally.
   46728 
   46729 If the stub receives a @var{ack} packet and there are no additional
   46730 @var{event} to report, the stub shall return an @samp{OK} response.
   46731 At this point, @value{GDBN} has finished processing a notification
   46732 and the stub has completed sending any queued events.  @value{GDBN}
   46733 won't accept any new notifications until the final @samp{OK} is
   46734 received .  If further notification events occur, the stub shall send
   46735 a new notification, @value{GDBN} shall accept the notification, and
   46736 the process shall be repeated.
   46737 
   46738 The process of asynchronous notification can be illustrated by the
   46739 following example:
   46740 @smallexample
   46741 <- @code{%Stop:T0505:98e7ffbf;04:4ce6ffbf;08:b1b6e54c;thread:p7526.7526;core:0;}
   46742 @code{...}
   46743 -> @code{vStopped}
   46744 <- @code{T0505:68f37db7;04:40f37db7;08:63850408;thread:p7526.7528;core:0;}
   46745 -> @code{vStopped}
   46746 <- @code{T0505:68e3fdb6;04:40e3fdb6;08:63850408;thread:p7526.7529;core:0;}
   46747 -> @code{vStopped}
   46748 <- @code{OK}
   46749 @end smallexample
   46750 
   46751 The following notifications are defined:
   46752 @multitable @columnfractions 0.12 0.12 0.38 0.38
   46753 
   46754 @item Notification
   46755 @tab Ack
   46756 @tab Event
   46757 @tab Description
   46758 
   46759 @item Stop
   46760 @tab vStopped
   46761 @tab @var{reply}.  The @var{reply} has the form of a stop reply, as
   46762 described in @ref{Stop Reply Packets}.  Refer to @ref{Remote Non-Stop},
   46763 for information on how these notifications are acknowledged by 
   46764 @value{GDBN}.
   46765 @tab Report an asynchronous stop event in non-stop mode.
   46766 
   46767 @end multitable
   46768 
   46769 @node Remote Non-Stop
   46770 @section Remote Protocol Support for Non-Stop Mode
   46771 
   46772 @value{GDBN}'s remote protocol supports non-stop debugging of
   46773 multi-threaded programs, as described in @ref{Non-Stop Mode}.  If the stub
   46774 supports non-stop mode, it should report that to @value{GDBN} by including
   46775 @samp{QNonStop+} in its @samp{qSupported} response (@pxref{qSupported}).
   46776 
   46777 @value{GDBN} typically sends a @samp{QNonStop} packet only when
   46778 establishing a new connection with the stub.  Entering non-stop mode
   46779 does not alter the state of any currently-running threads, but targets
   46780 must stop all threads in any already-attached processes when entering
   46781 all-stop mode.  @value{GDBN} uses the @samp{?} packet as necessary to
   46782 probe the target state after a mode change.
   46783 
   46784 In non-stop mode, when an attached process encounters an event that
   46785 would otherwise be reported with a stop reply, it uses the
   46786 asynchronous notification mechanism (@pxref{Notification Packets}) to
   46787 inform @value{GDBN}.  In contrast to all-stop mode, where all threads
   46788 in all processes are stopped when a stop reply is sent, in non-stop
   46789 mode only the thread reporting the stop event is stopped.  That is,
   46790 when reporting a @samp{S} or @samp{T} response to indicate completion
   46791 of a step operation, hitting a breakpoint, or a fault, only the
   46792 affected thread is stopped; any other still-running threads continue
   46793 to run.  When reporting a @samp{W} or @samp{X} response, all running
   46794 threads belonging to other attached processes continue to run.
   46795 
   46796 In non-stop mode, the target shall respond to the @samp{?} packet as
   46797 follows.  First, any incomplete stop reply notification/@samp{vStopped} 
   46798 sequence in progress is abandoned.  The target must begin a new
   46799 sequence reporting stop events for all stopped threads, whether or not
   46800 it has previously reported those events to @value{GDBN}.  The first
   46801 stop reply is sent as a synchronous reply to the @samp{?} packet, and
   46802 subsequent stop replies are sent as responses to @samp{vStopped} packets
   46803 using the mechanism described above.  The target must not send
   46804 asynchronous stop reply notifications until the sequence is complete.
   46805 If all threads are running when the target receives the @samp{?} packet,
   46806 or if the target is not attached to any process, it shall respond
   46807 @samp{OK}.
   46808 
   46809 If the stub supports non-stop mode, it should also support the
   46810 @samp{swbreak} stop reason if software breakpoints are supported, and
   46811 the @samp{hwbreak} stop reason if hardware breakpoints are supported
   46812 (@pxref{swbreak stop reason}).  This is because given the asynchronous
   46813 nature of non-stop mode, between the time a thread hits a breakpoint
   46814 and the time the event is finally processed by @value{GDBN}, the
   46815 breakpoint may have already been removed from the target.  Due to
   46816 this, @value{GDBN} needs to be able to tell whether a trap stop was
   46817 caused by a delayed breakpoint event, which should be ignored, as
   46818 opposed to a random trap signal, which should be reported to the user.
   46819 Note the @samp{swbreak} feature implies that the target is responsible
   46820 for adjusting the PC when a software breakpoint triggers, if
   46821 necessary, such as on the x86 architecture.
   46822 
   46823 @node Packet Acknowledgment
   46824 @section Packet Acknowledgment
   46825 
   46826 @cindex acknowledgment, for @value{GDBN} remote
   46827 @cindex packet acknowledgment, for @value{GDBN} remote
   46828 By default, when either the host or the target machine receives a packet,
   46829 the first response expected is an acknowledgment: either @samp{+} (to indicate
   46830 the package was received correctly) or @samp{-} (to request retransmission).
   46831 This mechanism allows the @value{GDBN} remote protocol to operate over
   46832 unreliable transport mechanisms, such as a serial line.
   46833 
   46834 In cases where the transport mechanism is itself reliable (such as a pipe or
   46835 TCP connection), the @samp{+}/@samp{-} acknowledgments are redundant.
   46836 It may be desirable to disable them in that case to reduce communication
   46837 overhead, or for other reasons.  This can be accomplished by means of the
   46838 @samp{QStartNoAckMode} packet; @pxref{QStartNoAckMode}.
   46839 
   46840 When in no-acknowledgment mode, neither the stub nor @value{GDBN} shall send or
   46841 expect @samp{+}/@samp{-} protocol acknowledgments.  The packet
   46842 and response format still includes the normal checksum, as described in
   46843 @ref{Overview}, but the checksum may be ignored by the receiver.
   46844 
   46845 If the stub supports @samp{QStartNoAckMode} and prefers to operate in
   46846 no-acknowledgment mode, it should report that to @value{GDBN}
   46847 by including @samp{QStartNoAckMode+} in its response to @samp{qSupported};
   46848 @pxref{qSupported}.
   46849 If @value{GDBN} also supports @samp{QStartNoAckMode} and it has not been
   46850 disabled via the @code{set remote noack-packet off} command
   46851 (@pxref{Remote Configuration}),
   46852 @value{GDBN} may then send a @samp{QStartNoAckMode} packet to the stub.
   46853 Only then may the stub actually turn off packet acknowledgments.
   46854 @value{GDBN} sends a final @samp{+} acknowledgment of the stub's @samp{OK}
   46855 response, which can be safely ignored by the stub.
   46856 
   46857 Note that @code{set remote noack-packet} command only affects negotiation
   46858 between @value{GDBN} and the stub when subsequent connections are made;
   46859 it does not affect the protocol acknowledgment state for any current
   46860 connection.
   46861 Since @samp{+}/@samp{-} acknowledgments are enabled by default when a
   46862 new connection is established,
   46863 there is also no protocol request to re-enable the acknowledgments
   46864 for the current connection, once disabled.
   46865 
   46866 @node Examples
   46867 @section Examples
   46868 
   46869 Example sequence of a target being re-started.  Notice how the restart
   46870 does not get any direct output:
   46871 
   46872 @smallexample
   46873 -> @code{R00}
   46874 <- @code{+}
   46875 @emph{target restarts}
   46876 -> @code{?}
   46877 <- @code{+}
   46878 <- @code{T001:1234123412341234}
   46879 -> @code{+}
   46880 @end smallexample
   46881 
   46882 Example sequence of a target being stepped by a single instruction:
   46883 
   46884 @smallexample
   46885 -> @code{G1445@dots{}}
   46886 <- @code{+}
   46887 -> @code{s}
   46888 <- @code{+}
   46889 @emph{time passes}
   46890 <- @code{T001:1234123412341234}
   46891 -> @code{+}
   46892 -> @code{g}
   46893 <- @code{+}
   46894 <- @code{1455@dots{}}
   46895 -> @code{+}
   46896 @end smallexample
   46897 
   46898 @node File-I/O Remote Protocol Extension
   46899 @section File-I/O Remote Protocol Extension
   46900 @cindex File-I/O remote protocol extension
   46901 
   46902 @menu
   46903 * File-I/O Overview::
   46904 * Protocol Basics::
   46905 * The F Request Packet::
   46906 * The F Reply Packet::
   46907 * The Ctrl-C Message::
   46908 * Console I/O::
   46909 * List of Supported Calls::
   46910 * Protocol-specific Representation of Datatypes::
   46911 * Constants::
   46912 * File-I/O Examples::
   46913 @end menu
   46914 
   46915 @node File-I/O Overview
   46916 @subsection File-I/O Overview
   46917 @cindex file-i/o overview
   46918 
   46919 The @dfn{File I/O remote protocol extension} (short: File-I/O) allows the
   46920 target to use the host's file system and console I/O to perform various
   46921 system calls.  System calls on the target system are translated into a
   46922 remote protocol packet to the host system, which then performs the needed
   46923 actions and returns a response packet to the target system.
   46924 This simulates file system operations even on targets that lack file systems.
   46925 
   46926 The protocol is defined to be independent of both the host and target systems.
   46927 It uses its own internal representation of datatypes and values.  Both
   46928 @value{GDBN} and the target's @value{GDBN} stub are responsible for
   46929 translating the system-dependent value representations into the internal
   46930 protocol representations when data is transmitted.
   46931 
   46932 The communication is synchronous.  A system call is possible only when 
   46933 @value{GDBN} is waiting for a response from the @samp{C}, @samp{c}, @samp{S} 
   46934 or @samp{s} packets.  While @value{GDBN} handles the request for a system call,
   46935 the target is stopped to allow deterministic access to the target's
   46936 memory.  Therefore File-I/O is not interruptible by target signals.  On
   46937 the other hand, it is possible to interrupt File-I/O by a user interrupt 
   46938 (@samp{Ctrl-C}) within @value{GDBN}.
   46939 
   46940 The target's request to perform a host system call does not finish
   46941 the latest @samp{C}, @samp{c}, @samp{S} or @samp{s} action.  That means,
   46942 after finishing the system call, the target returns to continuing the
   46943 previous activity (continue, step).  No additional continue or step
   46944 request from @value{GDBN} is required.
   46945 
   46946 @smallexample
   46947 (@value{GDBP}) continue
   46948   <- target requests 'system call X'
   46949   target is stopped, @value{GDBN} executes system call
   46950   -> @value{GDBN} returns result
   46951   ... target continues, @value{GDBN} returns to wait for the target
   46952   <- target hits breakpoint and sends a Txx packet
   46953 @end smallexample
   46954 
   46955 The protocol only supports I/O on the console and to regular files on 
   46956 the host file system.  Character or block special devices, pipes,
   46957 named pipes, sockets or any other communication method on the host
   46958 system are not supported by this protocol.
   46959 
   46960 File I/O is not supported in non-stop mode.
   46961 
   46962 @node Protocol Basics
   46963 @subsection Protocol Basics
   46964 @cindex protocol basics, file-i/o
   46965 
   46966 The File-I/O protocol uses the @code{F} packet as the request as well
   46967 as reply packet.  Since a File-I/O system call can only occur when
   46968 @value{GDBN} is waiting for a response from the continuing or stepping target, 
   46969 the File-I/O request is a reply that @value{GDBN} has to expect as a result
   46970 of a previous @samp{C}, @samp{c}, @samp{S} or @samp{s} packet.
   46971 This @code{F} packet contains all information needed to allow @value{GDBN}
   46972 to call the appropriate host system call:
   46973 
   46974 @itemize @bullet
   46975 @item
   46976 A unique identifier for the requested system call.
   46977 
   46978 @item
   46979 All parameters to the system call.  Pointers are given as addresses
   46980 in the target memory address space.  Pointers to strings are given as
   46981 pointer/length pair.  Numerical values are given as they are.
   46982 Numerical control flags are given in a protocol-specific representation.
   46983 
   46984 @end itemize
   46985 
   46986 At this point, @value{GDBN} has to perform the following actions.
   46987 
   46988 @itemize @bullet
   46989 @item
   46990 If the parameters include pointer values to data needed as input to a 
   46991 system call, @value{GDBN} requests this data from the target with a
   46992 standard @code{m} packet request.  This additional communication has to be
   46993 expected by the target implementation and is handled as any other @code{m}
   46994 packet.
   46995 
   46996 @item
   46997 @value{GDBN} translates all value from protocol representation to host
   46998 representation as needed.  Datatypes are coerced into the host types.
   46999 
   47000 @item
   47001 @value{GDBN} calls the system call.
   47002 
   47003 @item
   47004 It then coerces datatypes back to protocol representation.
   47005 
   47006 @item
   47007 If the system call is expected to return data in buffer space specified
   47008 by pointer parameters to the call, the data is transmitted to the
   47009 target using a @code{M} or @code{X} packet.  This packet has to be expected
   47010 by the target implementation and is handled as any other @code{M} or @code{X}
   47011 packet.
   47012 
   47013 @end itemize
   47014 
   47015 Eventually @value{GDBN} replies with another @code{F} packet which contains all
   47016 necessary information for the target to continue.  This at least contains
   47017 
   47018 @itemize @bullet
   47019 @item
   47020 Return value.
   47021 
   47022 @item
   47023 @code{errno}, if has been changed by the system call.
   47024 
   47025 @item
   47026 ``Ctrl-C'' flag.
   47027 
   47028 @end itemize
   47029 
   47030 After having done the needed type and value coercion, the target continues
   47031 the latest continue or step action.
   47032 
   47033 @node The F Request Packet
   47034 @subsection The @code{F} Request Packet
   47035 @cindex file-i/o request packet
   47036 @cindex @code{F} request packet
   47037 
   47038 The @code{F} request packet has the following format:
   47039 
   47040 @table @samp
   47041 @item F@var{call-id},@var{parameter@dots{}}
   47042 
   47043 @var{call-id} is the identifier to indicate the host system call to be called.
   47044 This is just the name of the function.
   47045 
   47046 @var{parameter@dots{}} are the parameters to the system call.  
   47047 Parameters are hexadecimal integer values, either the actual values in case
   47048 of scalar datatypes, pointers to target buffer space in case of compound
   47049 datatypes and unspecified memory areas, or pointer/length pairs in case
   47050 of string parameters.  These are appended to the @var{call-id} as a 
   47051 comma-delimited list.  All values are transmitted in ASCII
   47052 string representation, pointer/length pairs separated by a slash.
   47053 
   47054 @end table
   47055 
   47056 
   47057 
   47058 @node The F Reply Packet
   47059 @subsection The @code{F} Reply Packet
   47060 @cindex file-i/o reply packet
   47061 @cindex @code{F} reply packet
   47062 
   47063 The @code{F} reply packet has the following format:
   47064 
   47065 @table @samp
   47066 
   47067 @item F@var{retcode},@var{errno},@var{Ctrl-C flag};@var{call-specific attachment}
   47068 
   47069 @var{retcode} is the return code of the system call as hexadecimal value.
   47070 
   47071 @var{errno} is the @code{errno} set by the call, in protocol-specific
   47072 representation.
   47073 This parameter can be omitted if the call was successful.
   47074 
   47075 @var{Ctrl-C flag} is only sent if the user requested a break.  In this
   47076 case, @var{errno} must be sent as well, even if the call was successful.
   47077 The @var{Ctrl-C flag} itself consists of the character @samp{C}:
   47078 
   47079 @smallexample
   47080 F0,0,C
   47081 @end smallexample
   47082 
   47083 @noindent
   47084 or, if the call was interrupted before the host call has been performed:
   47085 
   47086 @smallexample
   47087 F-1,4,C
   47088 @end smallexample
   47089 
   47090 @noindent
   47091 assuming 4 is the protocol-specific representation of @code{EINTR}.
   47092 
   47093 @end table
   47094 
   47095 
   47096 @node The Ctrl-C Message
   47097 @subsection The @samp{Ctrl-C} Message
   47098 @cindex ctrl-c message, in file-i/o protocol
   47099 
   47100 If the @samp{Ctrl-C} flag is set in the @value{GDBN}
   47101 reply packet (@pxref{The F Reply Packet}),
   47102 the target should behave as if it had
   47103 gotten a break message.  The meaning for the target is ``system call
   47104 interrupted by @code{SIGINT}''.  Consequently, the target should actually stop
   47105 (as with a break message) and return to @value{GDBN} with a @code{T02}
   47106 packet.
   47107 
   47108 It's important for the target to know in which
   47109 state the system call was interrupted.  There are two possible cases:
   47110 
   47111 @itemize @bullet
   47112 @item
   47113 The system call hasn't been performed on the host yet.
   47114 
   47115 @item
   47116 The system call on the host has been finished.
   47117 
   47118 @end itemize
   47119 
   47120 These two states can be distinguished by the target by the value of the
   47121 returned @code{errno}.  If it's the protocol representation of @code{EINTR}, the system
   47122 call hasn't been performed.  This is equivalent to the @code{EINTR} handling
   47123 on POSIX systems.  In any other case, the target may presume that the
   47124 system call has been finished --- successfully or not --- and should behave
   47125 as if the break message arrived right after the system call.
   47126 
   47127 @value{GDBN} must behave reliably.  If the system call has not been called
   47128 yet, @value{GDBN} may send the @code{F} reply immediately, setting @code{EINTR} as
   47129 @code{errno} in the packet.  If the system call on the host has been finished
   47130 before the user requests a break, the full action must be finished by
   47131 @value{GDBN}.  This requires sending @code{M} or @code{X} packets as necessary.
   47132 The @code{F} packet may only be sent when either nothing has happened
   47133 or the full action has been completed.
   47134 
   47135 @node Console I/O
   47136 @subsection Console I/O
   47137 @cindex console i/o as part of file-i/o
   47138 
   47139 By default and if not explicitly closed by the target system, the file
   47140 descriptors 0, 1 and 2 are connected to the @value{GDBN} console.  Output
   47141 on the @value{GDBN} console is handled as any other file output operation
   47142 (@code{write(1, @dots{})} or @code{write(2, @dots{})}).  Console input is handled
   47143 by @value{GDBN} so that after the target read request from file descriptor
   47144 0 all following typing is buffered until either one of the following
   47145 conditions is met:
   47146 
   47147 @itemize @bullet
   47148 @item
   47149 The user types @kbd{Ctrl-c}.  The behavior is as explained above, and the
   47150 @code{read}
   47151 system call is treated as finished.
   47152 
   47153 @item
   47154 The user presses @key{RET}.  This is treated as end of input with a trailing
   47155 newline.
   47156 
   47157 @item
   47158 The user types @kbd{Ctrl-d}.  This is treated as end of input.  No trailing
   47159 character (neither newline nor @samp{Ctrl-D}) is appended to the input.
   47160 
   47161 @end itemize
   47162 
   47163 If the user has typed more characters than fit in the buffer given to
   47164 the @code{read} call, the trailing characters are buffered in @value{GDBN} until
   47165 either another @code{read(0, @dots{})} is requested by the target, or debugging
   47166 is stopped at the user's request.
   47167 
   47168 
   47169 @node List of Supported Calls
   47170 @subsection List of Supported Calls
   47171 @cindex list of supported file-i/o calls
   47172 
   47173 @menu
   47174 * open::
   47175 * close::
   47176 * read::
   47177 * write::
   47178 * lseek::
   47179 * rename::
   47180 * unlink::
   47181 * stat/fstat::
   47182 * gettimeofday::
   47183 * isatty::
   47184 * system::
   47185 @end menu
   47186 
   47187 @node open
   47188 @unnumberedsubsubsec open
   47189 @cindex open, file-i/o system call
   47190 
   47191 @table @asis
   47192 @item Synopsis:
   47193 @smallexample
   47194 int open(const char *pathname, int flags);
   47195 int open(const char *pathname, int flags, mode_t mode);
   47196 @end smallexample
   47197 
   47198 @item Request:
   47199 @samp{Fopen,@var{pathptr}/@var{len},@var{flags},@var{mode}}
   47200 
   47201 @noindent
   47202 @var{flags} is the bitwise @code{OR} of the following values:
   47203 
   47204 @table @code
   47205 @item O_CREAT
   47206 If the file does not exist it will be created.  The host
   47207 rules apply as far as file ownership and time stamps
   47208 are concerned.
   47209 
   47210 @item O_EXCL
   47211 When used with @code{O_CREAT}, if the file already exists it is
   47212 an error and open() fails.
   47213 
   47214 @item O_TRUNC
   47215 If the file already exists and the open mode allows
   47216 writing (@code{O_RDWR} or @code{O_WRONLY} is given) it will be
   47217 truncated to zero length.
   47218 
   47219 @item O_APPEND
   47220 The file is opened in append mode.
   47221 
   47222 @item O_RDONLY
   47223 The file is opened for reading only.
   47224 
   47225 @item O_WRONLY
   47226 The file is opened for writing only.
   47227 
   47228 @item O_RDWR
   47229 The file is opened for reading and writing.
   47230 @end table
   47231 
   47232 @noindent
   47233 Other bits are silently ignored.
   47234 
   47235 
   47236 @noindent
   47237 @var{mode} is the bitwise @code{OR} of the following values:
   47238 
   47239 @table @code
   47240 @item S_IRUSR
   47241 User has read permission.
   47242 
   47243 @item S_IWUSR
   47244 User has write permission.
   47245 
   47246 @item S_IRGRP
   47247 Group has read permission.
   47248 
   47249 @item S_IWGRP
   47250 Group has write permission.
   47251 
   47252 @item S_IROTH
   47253 Others have read permission.
   47254 
   47255 @item S_IWOTH
   47256 Others have write permission.
   47257 @end table
   47258 
   47259 @noindent
   47260 Other bits are silently ignored.
   47261 
   47262 
   47263 @item Return value:
   47264 @code{open} returns the new file descriptor or -1 if an error
   47265 occurred.
   47266 
   47267 @item Errors:
   47268 
   47269 @table @code
   47270 @item EEXIST
   47271 @var{pathname} already exists and @code{O_CREAT} and @code{O_EXCL} were used.
   47272 
   47273 @item EISDIR
   47274 @var{pathname} refers to a directory.
   47275 
   47276 @item EACCES
   47277 The requested access is not allowed.
   47278 
   47279 @item ENAMETOOLONG
   47280 @var{pathname} was too long.
   47281 
   47282 @item ENOENT
   47283 A directory component in @var{pathname} does not exist.
   47284 
   47285 @item ENODEV
   47286 @var{pathname} refers to a device, pipe, named pipe or socket.
   47287 
   47288 @item EROFS
   47289 @var{pathname} refers to a file on a read-only filesystem and
   47290 write access was requested.
   47291 
   47292 @item EFAULT
   47293 @var{pathname} is an invalid pointer value.
   47294 
   47295 @item ENOSPC
   47296 No space on device to create the file.
   47297 
   47298 @item EMFILE
   47299 The process already has the maximum number of files open.
   47300 
   47301 @item ENFILE
   47302 The limit on the total number of files open on the system
   47303 has been reached.
   47304 
   47305 @item EINTR
   47306 The call was interrupted by the user.
   47307 @end table
   47308 
   47309 @end table
   47310 
   47311 @node close
   47312 @unnumberedsubsubsec close
   47313 @cindex close, file-i/o system call
   47314 
   47315 @table @asis
   47316 @item Synopsis:
   47317 @smallexample
   47318 int close(int fd);
   47319 @end smallexample
   47320 
   47321 @item Request:
   47322 @samp{Fclose,@var{fd}}
   47323 
   47324 @item Return value:
   47325 @code{close} returns zero on success, or -1 if an error occurred.
   47326 
   47327 @item Errors:
   47328 
   47329 @table @code
   47330 @item EBADF
   47331 @var{fd} isn't a valid open file descriptor.
   47332 
   47333 @item EINTR
   47334 The call was interrupted by the user.
   47335 @end table
   47336 
   47337 @end table
   47338 
   47339 @node read
   47340 @unnumberedsubsubsec read
   47341 @cindex read, file-i/o system call
   47342 
   47343 @table @asis
   47344 @item Synopsis:
   47345 @smallexample
   47346 int read(int fd, void *buf, unsigned int count);
   47347 @end smallexample
   47348 
   47349 @item Request:
   47350 @samp{Fread,@var{fd},@var{bufptr},@var{count}}
   47351 
   47352 @item Return value:
   47353 On success, the number of bytes read is returned.
   47354 Zero indicates end of file.  If count is zero, read
   47355 returns zero as well.  On error, -1 is returned.
   47356 
   47357 @item Errors:
   47358 
   47359 @table @code
   47360 @item EBADF
   47361 @var{fd} is not a valid file descriptor or is not open for
   47362 reading.
   47363 
   47364 @item EFAULT
   47365 @var{bufptr} is an invalid pointer value.
   47366 
   47367 @item EINTR
   47368 The call was interrupted by the user.
   47369 @end table
   47370 
   47371 @end table
   47372 
   47373 @node write
   47374 @unnumberedsubsubsec write
   47375 @cindex write, file-i/o system call
   47376 
   47377 @table @asis
   47378 @item Synopsis:
   47379 @smallexample
   47380 int write(int fd, const void *buf, unsigned int count);
   47381 @end smallexample
   47382 
   47383 @item Request:
   47384 @samp{Fwrite,@var{fd},@var{bufptr},@var{count}}
   47385 
   47386 @item Return value:
   47387 On success, the number of bytes written are returned.
   47388 Zero indicates nothing was written.  On error, -1
   47389 is returned.
   47390 
   47391 @item Errors:
   47392 
   47393 @table @code
   47394 @item EBADF
   47395 @var{fd} is not a valid file descriptor or is not open for
   47396 writing.
   47397 
   47398 @item EFAULT
   47399 @var{bufptr} is an invalid pointer value.
   47400 
   47401 @item EFBIG
   47402 An attempt was made to write a file that exceeds the
   47403 host-specific maximum file size allowed.
   47404 
   47405 @item ENOSPC
   47406 No space on device to write the data.
   47407 
   47408 @item EINTR
   47409 The call was interrupted by the user.
   47410 @end table
   47411 
   47412 @end table
   47413 
   47414 @node lseek
   47415 @unnumberedsubsubsec lseek
   47416 @cindex lseek, file-i/o system call
   47417 
   47418 @table @asis
   47419 @item Synopsis:
   47420 @smallexample
   47421 long lseek (int fd, long offset, int flag);
   47422 @end smallexample
   47423 
   47424 @item Request:
   47425 @samp{Flseek,@var{fd},@var{offset},@var{flag}}
   47426 
   47427 @var{flag} is one of:
   47428 
   47429 @table @code
   47430 @item SEEK_SET
   47431 The offset is set to @var{offset} bytes.
   47432 
   47433 @item SEEK_CUR
   47434 The offset is set to its current location plus @var{offset}
   47435 bytes.
   47436 
   47437 @item SEEK_END
   47438 The offset is set to the size of the file plus @var{offset}
   47439 bytes.
   47440 @end table
   47441 
   47442 @item Return value:
   47443 On success, the resulting unsigned offset in bytes from
   47444 the beginning of the file is returned.  Otherwise, a
   47445 value of -1 is returned.
   47446 
   47447 @item Errors:
   47448 
   47449 @table @code
   47450 @item EBADF
   47451 @var{fd} is not a valid open file descriptor.
   47452 
   47453 @item ESPIPE
   47454 @var{fd} is associated with the @value{GDBN} console.
   47455 
   47456 @item EINVAL
   47457 @var{flag} is not a proper value.
   47458 
   47459 @item EINTR
   47460 The call was interrupted by the user.
   47461 @end table
   47462 
   47463 @end table
   47464 
   47465 @node rename
   47466 @unnumberedsubsubsec rename
   47467 @cindex rename, file-i/o system call
   47468 
   47469 @table @asis
   47470 @item Synopsis:
   47471 @smallexample
   47472 int rename(const char *oldpath, const char *newpath);
   47473 @end smallexample
   47474 
   47475 @item Request:
   47476 @samp{Frename,@var{oldpathptr}/@var{len},@var{newpathptr}/@var{len}}
   47477 
   47478 @item Return value:
   47479 On success, zero is returned.  On error, -1 is returned.
   47480 
   47481 @item Errors:
   47482 
   47483 @table @code
   47484 @item EISDIR
   47485 @var{newpath} is an existing directory, but @var{oldpath} is not a
   47486 directory.
   47487 
   47488 @item EEXIST
   47489 @var{newpath} is a non-empty directory.
   47490 
   47491 @item EBUSY
   47492 @var{oldpath} or @var{newpath} is a directory that is in use by some
   47493 process.
   47494 
   47495 @item EINVAL
   47496 An attempt was made to make a directory a subdirectory
   47497 of itself.
   47498 
   47499 @item ENOTDIR
   47500 A  component used as a directory in @var{oldpath} or new
   47501 path is not a directory.  Or @var{oldpath} is a directory
   47502 and @var{newpath} exists but is not a directory.
   47503 
   47504 @item EFAULT
   47505 @var{oldpathptr} or @var{newpathptr} are invalid pointer values.
   47506 
   47507 @item EACCES
   47508 No access to the file or the path of the file.
   47509 
   47510 @item ENAMETOOLONG
   47511 
   47512 @var{oldpath} or @var{newpath} was too long.
   47513 
   47514 @item ENOENT
   47515 A directory component in @var{oldpath} or @var{newpath} does not exist.
   47516 
   47517 @item EROFS
   47518 The file is on a read-only filesystem.
   47519 
   47520 @item ENOSPC
   47521 The device containing the file has no room for the new
   47522 directory entry.
   47523 
   47524 @item EINTR
   47525 The call was interrupted by the user.
   47526 @end table
   47527 
   47528 @end table
   47529 
   47530 @node unlink
   47531 @unnumberedsubsubsec unlink
   47532 @cindex unlink, file-i/o system call
   47533 
   47534 @table @asis
   47535 @item Synopsis:
   47536 @smallexample
   47537 int unlink(const char *pathname);
   47538 @end smallexample
   47539 
   47540 @item Request:
   47541 @samp{Funlink,@var{pathnameptr}/@var{len}}
   47542 
   47543 @item Return value:
   47544 On success, zero is returned.  On error, -1 is returned.
   47545 
   47546 @item Errors:
   47547 
   47548 @table @code
   47549 @item EACCES
   47550 No access to the file or the path of the file.
   47551 
   47552 @item EPERM
   47553 The system does not allow unlinking of directories.
   47554 
   47555 @item EBUSY
   47556 The file @var{pathname} cannot be unlinked because it's
   47557 being used by another process.
   47558 
   47559 @item EFAULT
   47560 @var{pathnameptr} is an invalid pointer value.
   47561 
   47562 @item ENAMETOOLONG
   47563 @var{pathname} was too long.
   47564 
   47565 @item ENOENT
   47566 A directory component in @var{pathname} does not exist.
   47567 
   47568 @item ENOTDIR
   47569 A component of the path is not a directory.
   47570 
   47571 @item EROFS
   47572 The file is on a read-only filesystem.
   47573 
   47574 @item EINTR
   47575 The call was interrupted by the user.
   47576 @end table
   47577 
   47578 @end table
   47579 
   47580 @node stat/fstat
   47581 @unnumberedsubsubsec stat/fstat
   47582 @cindex fstat, file-i/o system call
   47583 @cindex stat, file-i/o system call
   47584 
   47585 @table @asis
   47586 @item Synopsis:
   47587 @smallexample
   47588 int stat(const char *pathname, struct stat *buf);
   47589 int fstat(int fd, struct stat *buf);
   47590 @end smallexample
   47591 
   47592 @item Request:
   47593 @samp{Fstat,@var{pathnameptr}/@var{len},@var{bufptr}}@*
   47594 @samp{Ffstat,@var{fd},@var{bufptr}}
   47595 
   47596 @item Return value:
   47597 On success, zero is returned.  On error, -1 is returned.
   47598 
   47599 @item Errors:
   47600 
   47601 @table @code
   47602 @item EBADF
   47603 @var{fd} is not a valid open file.
   47604 
   47605 @item ENOENT
   47606 A directory component in @var{pathname} does not exist or the
   47607 path is an empty string.
   47608 
   47609 @item ENOTDIR
   47610 A component of the path is not a directory.
   47611 
   47612 @item EFAULT
   47613 @var{pathnameptr} is an invalid pointer value.
   47614 
   47615 @item EACCES
   47616 No access to the file or the path of the file.
   47617 
   47618 @item ENAMETOOLONG
   47619 @var{pathname} was too long.
   47620 
   47621 @item EINTR
   47622 The call was interrupted by the user.
   47623 @end table
   47624 
   47625 @end table
   47626 
   47627 @node gettimeofday
   47628 @unnumberedsubsubsec gettimeofday
   47629 @cindex gettimeofday, file-i/o system call
   47630 
   47631 @table @asis
   47632 @item Synopsis:
   47633 @smallexample
   47634 int gettimeofday(struct timeval *tv, void *tz);
   47635 @end smallexample
   47636 
   47637 @item Request:
   47638 @samp{Fgettimeofday,@var{tvptr},@var{tzptr}}
   47639 
   47640 @item Return value:
   47641 On success, 0 is returned, -1 otherwise.
   47642 
   47643 @item Errors:
   47644 
   47645 @table @code
   47646 @item EINVAL
   47647 @var{tz} is a non-NULL pointer.
   47648 
   47649 @item EFAULT
   47650 @var{tvptr} and/or @var{tzptr} is an invalid pointer value.
   47651 @end table
   47652 
   47653 @end table
   47654 
   47655 @node isatty
   47656 @unnumberedsubsubsec isatty
   47657 @cindex isatty, file-i/o system call
   47658 
   47659 @table @asis
   47660 @item Synopsis:
   47661 @smallexample
   47662 int isatty(int fd);
   47663 @end smallexample
   47664 
   47665 @item Request:
   47666 @samp{Fisatty,@var{fd}}
   47667 
   47668 @item Return value:
   47669 Returns 1 if @var{fd} refers to the @value{GDBN} console, 0 otherwise.
   47670 
   47671 @item Errors:
   47672 
   47673 @table @code
   47674 @item EINTR
   47675 The call was interrupted by the user.
   47676 @end table
   47677 
   47678 @end table
   47679 
   47680 Note that the @code{isatty} call is treated as a special case: it returns
   47681 1 to the target if the file descriptor is attached
   47682 to the @value{GDBN} console, 0 otherwise.  Implementing through system calls
   47683 would require implementing @code{ioctl} and would be more complex than
   47684 needed.
   47685 
   47686 
   47687 @node system
   47688 @unnumberedsubsubsec system
   47689 @cindex system, file-i/o system call
   47690 
   47691 @table @asis
   47692 @item Synopsis:
   47693 @smallexample
   47694 int system(const char *command);
   47695 @end smallexample
   47696 
   47697 @item Request:
   47698 @samp{Fsystem,@var{commandptr}/@var{len}}
   47699 
   47700 @item Return value:
   47701 If @var{len} is zero, the return value indicates whether a shell is
   47702 available.  A zero return value indicates a shell is not available.
   47703 For non-zero @var{len}, the value returned is -1 on error and the
   47704 return status of the command otherwise.  Only the exit status of the
   47705 command is returned, which is extracted from the host's @code{system}
   47706 return value by calling @code{WEXITSTATUS(retval)}.  In case
   47707 @file{/bin/sh} could not be executed, 127 is returned.
   47708 
   47709 @item Errors:
   47710 
   47711 @table @code
   47712 @item EINTR
   47713 The call was interrupted by the user.
   47714 @end table
   47715 
   47716 @end table
   47717 
   47718 @value{GDBN} takes over the full task of calling the necessary host calls 
   47719 to perform the @code{system} call.  The return value of @code{system} on 
   47720 the host is simplified before it's returned
   47721 to the target.  Any termination signal information from the child process 
   47722 is discarded, and the return value consists
   47723 entirely of the exit status of the called command.
   47724 
   47725 Due to security concerns, the @code{system} call is by default refused
   47726 by @value{GDBN}.  The user has to allow this call explicitly with the
   47727 @code{set remote system-call-allowed 1} command.
   47728 
   47729 @table @code
   47730 @item set remote system-call-allowed
   47731 @kindex set remote system-call-allowed
   47732 Control whether to allow the @code{system} calls in the File I/O
   47733 protocol for the remote target.  The default is zero (disabled).
   47734 
   47735 @item show remote system-call-allowed
   47736 @kindex show remote system-call-allowed
   47737 Show whether the @code{system} calls are allowed in the File I/O
   47738 protocol.
   47739 @end table
   47740 
   47741 @node Protocol-specific Representation of Datatypes
   47742 @subsection Protocol-specific Representation of Datatypes
   47743 @cindex protocol-specific representation of datatypes, in file-i/o protocol
   47744 
   47745 @menu
   47746 * Integral Datatypes::
   47747 * Pointer Values::
   47748 * Memory Transfer::
   47749 * struct stat::
   47750 * struct timeval::
   47751 @end menu
   47752 
   47753 @node Integral Datatypes
   47754 @unnumberedsubsubsec Integral Datatypes
   47755 @cindex integral datatypes, in file-i/o protocol
   47756 
   47757 The integral datatypes used in the system calls are @code{int}, 
   47758 @code{unsigned int}, @code{long}, @code{unsigned long},
   47759 @code{mode_t}, and @code{time_t}.  
   47760 
   47761 @code{int}, @code{unsigned int}, @code{mode_t} and @code{time_t} are
   47762 implemented as 32 bit values in this protocol.
   47763 
   47764 @code{long} and @code{unsigned long} are implemented as 64 bit types.
   47765 
   47766 @xref{Limits}, for corresponding MIN and MAX values (similar to those
   47767 in @file{limits.h}) to allow range checking on host and target.
   47768 
   47769 @code{time_t} datatypes are defined as seconds since the Epoch.
   47770 
   47771 All integral datatypes transferred as part of a memory read or write of a
   47772 structured datatype e.g.@: a @code{struct stat} have to be given in big endian
   47773 byte order.
   47774 
   47775 @node Pointer Values
   47776 @unnumberedsubsubsec Pointer Values
   47777 @cindex pointer values, in file-i/o protocol
   47778 
   47779 Pointers to target data are transmitted as they are.  An exception
   47780 is made for pointers to buffers for which the length isn't
   47781 transmitted as part of the function call, namely strings.  Strings
   47782 are transmitted as a pointer/length pair, both as hex values, e.g.@:
   47783 
   47784 @smallexample
   47785 @code{1aaf/12}
   47786 @end smallexample
   47787 
   47788 @noindent
   47789 which is a pointer to data of length 18 bytes at position 0x1aaf.
   47790 The length is defined as the full string length in bytes, including
   47791 the trailing null byte.  For example, the string @code{"hello world"}
   47792 at address 0x123456 is transmitted as
   47793 
   47794 @smallexample
   47795 @code{123456/d}
   47796 @end smallexample
   47797 
   47798 @node Memory Transfer
   47799 @unnumberedsubsubsec Memory Transfer
   47800 @cindex memory transfer, in file-i/o protocol
   47801 
   47802 Structured data which is transferred using a memory read or write (for
   47803 example, a @code{struct stat}) is expected to be in a protocol-specific format 
   47804 with all scalar multibyte datatypes being big endian.  Translation to
   47805 this representation needs to be done both by the target before the @code{F} 
   47806 packet is sent, and by @value{GDBN} before 
   47807 it transfers memory to the target.  Transferred pointers to structured
   47808 data should point to the already-coerced data at any time.
   47809 
   47810 
   47811 @node struct stat
   47812 @unnumberedsubsubsec struct stat
   47813 @cindex struct stat, in file-i/o protocol
   47814 
   47815 The buffer of type @code{struct stat} used by the target and @value{GDBN} 
   47816 is defined as follows:
   47817 
   47818 @smallexample
   47819 struct stat @{
   47820     unsigned int  st_dev;      /* device */
   47821     unsigned int  st_ino;      /* inode */
   47822     mode_t        st_mode;     /* protection */
   47823     unsigned int  st_nlink;    /* number of hard links */
   47824     unsigned int  st_uid;      /* user ID of owner */
   47825     unsigned int  st_gid;      /* group ID of owner */
   47826     unsigned int  st_rdev;     /* device type (if inode device) */
   47827     unsigned long st_size;     /* total size, in bytes */
   47828     unsigned long st_blksize;  /* blocksize for filesystem I/O */
   47829     unsigned long st_blocks;   /* number of blocks allocated */
   47830     time_t        st_atime;    /* time of last access */
   47831     time_t        st_mtime;    /* time of last modification */
   47832     time_t        st_ctime;    /* time of last change */
   47833 @};
   47834 @end smallexample
   47835 
   47836 The integral datatypes conform to the definitions given in the
   47837 appropriate section (see @ref{Integral Datatypes}, for details) so this
   47838 structure is of size 64 bytes.
   47839 
   47840 The values of several fields have a restricted meaning and/or
   47841 range of values.
   47842 
   47843 @table @code
   47844 
   47845 @item st_dev
   47846 A value of 0 represents a file, 1 the console.
   47847 
   47848 @item st_ino
   47849 No valid meaning for the target.  Transmitted unchanged.
   47850 
   47851 @item st_mode
   47852 Valid mode bits are described in @ref{Constants}.  Any other
   47853 bits have currently no meaning for the target.
   47854 
   47855 @item st_uid
   47856 @itemx st_gid
   47857 @itemx st_rdev
   47858 No valid meaning for the target.  Transmitted unchanged.
   47859 
   47860 @item st_atime
   47861 @itemx st_mtime
   47862 @itemx st_ctime
   47863 These values have a host and file system dependent
   47864 accuracy.  Especially on Windows hosts, the file system may not
   47865 support exact timing values.
   47866 @end table
   47867 
   47868 The target gets a @code{struct stat} of the above representation and is
   47869 responsible for coercing it to the target representation before
   47870 continuing.
   47871 
   47872 Note that due to size differences between the host, target, and protocol
   47873 representations of @code{struct stat} members, these members could eventually
   47874 get truncated on the target.
   47875 
   47876 @node struct timeval
   47877 @unnumberedsubsubsec struct timeval
   47878 @cindex struct timeval, in file-i/o protocol
   47879 
   47880 The buffer of type @code{struct timeval} used by the File-I/O protocol
   47881 is defined as follows:
   47882 
   47883 @smallexample
   47884 struct timeval @{
   47885     time_t tv_sec;  /* second */
   47886     long   tv_usec; /* microsecond */
   47887 @};
   47888 @end smallexample
   47889 
   47890 The integral datatypes conform to the definitions given in the
   47891 appropriate section (see @ref{Integral Datatypes}, for details) so this
   47892 structure is of size 8 bytes.
   47893 
   47894 @node Constants
   47895 @subsection Constants
   47896 @cindex constants, in file-i/o protocol
   47897 
   47898 The following values are used for the constants inside of the
   47899 protocol.  @value{GDBN} and target are responsible for translating these
   47900 values before and after the call as needed.
   47901 
   47902 @menu
   47903 * Open Flags::
   47904 * mode_t Values::
   47905 * Errno Values::
   47906 * Lseek Flags::
   47907 * Limits::
   47908 @end menu
   47909 
   47910 @node Open Flags
   47911 @unnumberedsubsubsec Open Flags
   47912 @cindex open flags, in file-i/o protocol
   47913 
   47914 All values are given in hexadecimal representation.
   47915 
   47916 @smallexample
   47917   O_RDONLY        0x0
   47918   O_WRONLY        0x1
   47919   O_RDWR          0x2
   47920   O_APPEND        0x8
   47921   O_CREAT       0x200
   47922   O_TRUNC       0x400
   47923   O_EXCL        0x800
   47924 @end smallexample
   47925 
   47926 @node mode_t Values
   47927 @unnumberedsubsubsec mode_t Values
   47928 @cindex mode_t values, in file-i/o protocol
   47929 
   47930 All values are given in octal representation.
   47931 
   47932 @smallexample
   47933   S_IFREG       0100000
   47934   S_IFDIR        040000
   47935   S_IRUSR          0400
   47936   S_IWUSR          0200
   47937   S_IXUSR          0100
   47938   S_IRGRP           040
   47939   S_IWGRP           020
   47940   S_IXGRP           010
   47941   S_IROTH            04
   47942   S_IWOTH            02
   47943   S_IXOTH            01
   47944 @end smallexample
   47945 
   47946 @node Errno Values
   47947 @unnumberedsubsubsec Errno Values
   47948 @cindex errno values, in file-i/o protocol
   47949 
   47950 All values are given in decimal representation.
   47951 
   47952 @smallexample
   47953   EPERM           1
   47954   ENOENT          2
   47955   EINTR           4
   47956   EBADF           9
   47957   EACCES         13
   47958   EFAULT         14
   47959   EBUSY          16
   47960   EEXIST         17
   47961   ENODEV         19
   47962   ENOTDIR        20
   47963   EISDIR         21
   47964   EINVAL         22
   47965   ENFILE         23
   47966   EMFILE         24
   47967   EFBIG          27
   47968   ENOSPC         28
   47969   ESPIPE         29
   47970   EROFS          30
   47971   ENAMETOOLONG   91
   47972   EUNKNOWN       9999
   47973 @end smallexample
   47974 
   47975   @code{EUNKNOWN} is used as a fallback error value if a host system returns
   47976   any error value not in the list of supported error numbers.
   47977 
   47978 @node Lseek Flags
   47979 @unnumberedsubsubsec Lseek Flags
   47980 @cindex lseek flags, in file-i/o protocol
   47981 
   47982 @smallexample
   47983   SEEK_SET      0
   47984   SEEK_CUR      1
   47985   SEEK_END      2
   47986 @end smallexample
   47987 
   47988 @node Limits
   47989 @unnumberedsubsubsec Limits
   47990 @cindex limits, in file-i/o protocol
   47991 
   47992 All values are given in decimal representation.
   47993 
   47994 @smallexample
   47995   INT_MIN       -2147483648
   47996   INT_MAX        2147483647
   47997   UINT_MAX       4294967295
   47998   LONG_MIN      -9223372036854775808
   47999   LONG_MAX       9223372036854775807
   48000   ULONG_MAX      18446744073709551615
   48001 @end smallexample
   48002 
   48003 @node File-I/O Examples
   48004 @subsection File-I/O Examples
   48005 @cindex file-i/o examples
   48006 
   48007 Example sequence of a write call, file descriptor 3, buffer is at target
   48008 address 0x1234, 6 bytes should be written:
   48009 
   48010 @smallexample
   48011 <- @code{Fwrite,3,1234,6}
   48012 @emph{request memory read from target}
   48013 -> @code{m1234,6}
   48014 <- XXXXXX
   48015 @emph{return "6 bytes written"}
   48016 -> @code{F6}
   48017 @end smallexample
   48018 
   48019 Example sequence of a read call, file descriptor 3, buffer is at target
   48020 address 0x1234, 6 bytes should be read:
   48021 
   48022 @smallexample
   48023 <- @code{Fread,3,1234,6}
   48024 @emph{request memory write to target}
   48025 -> @code{X1234,6:XXXXXX}
   48026 @emph{return "6 bytes read"}
   48027 -> @code{F6}
   48028 @end smallexample
   48029 
   48030 Example sequence of a read call, call fails on the host due to invalid
   48031 file descriptor (@code{EBADF}):
   48032 
   48033 @smallexample
   48034 <- @code{Fread,3,1234,6}
   48035 -> @code{F-1,9}
   48036 @end smallexample
   48037 
   48038 Example sequence of a read call, user presses @kbd{Ctrl-c} before syscall on
   48039 host is called:
   48040 
   48041 @smallexample
   48042 <- @code{Fread,3,1234,6}
   48043 -> @code{F-1,4,C}
   48044 <- @code{T02}
   48045 @end smallexample
   48046 
   48047 Example sequence of a read call, user presses @kbd{Ctrl-c} after syscall on
   48048 host is called:
   48049 
   48050 @smallexample
   48051 <- @code{Fread,3,1234,6}
   48052 -> @code{X1234,6:XXXXXX}
   48053 <- @code{T02}
   48054 @end smallexample
   48055 
   48056 @node Library List Format
   48057 @section Library List Format
   48058 @cindex library list format, remote protocol
   48059 
   48060 On some platforms, a dynamic loader (e.g.@: @file{ld.so}) runs in the
   48061 same process as your application to manage libraries.  In this case,
   48062 @value{GDBN} can use the loader's symbol table and normal memory
   48063 operations to maintain a list of shared libraries.  On other
   48064 platforms, the operating system manages loaded libraries.
   48065 @value{GDBN} can not retrieve the list of currently loaded libraries
   48066 through memory operations, so it uses the @samp{qXfer:libraries:read}
   48067 packet (@pxref{qXfer library list read}) instead.  The remote stub
   48068 queries the target's operating system and reports which libraries
   48069 are loaded.
   48070 
   48071 The @samp{qXfer:libraries:read} packet returns an XML document which
   48072 lists loaded libraries and their offsets.  Each library has an
   48073 associated name and one or more segment or section base addresses,
   48074 which report where the library was loaded in memory.
   48075 
   48076 For the common case of libraries that are fully linked binaries, the
   48077 library should have a list of segments.  If the target supports
   48078 dynamic linking of a relocatable object file, its library XML element
   48079 should instead include a list of allocated sections.  The segment or
   48080 section bases are start addresses, not relocation offsets; they do not
   48081 depend on the library's link-time base addresses.
   48082 
   48083 @value{GDBN} must be linked with the Expat library to support XML
   48084 library lists.  @xref{Expat}.
   48085 
   48086 A simple memory map, with one loaded library relocated by a single
   48087 offset, looks like this:
   48088 
   48089 @smallexample
   48090 <library-list>
   48091   <library name="/lib/libc.so.6">
   48092     <segment address="0x10000000"/>
   48093   </library>
   48094 </library-list>
   48095 @end smallexample
   48096 
   48097 Another simple memory map, with one loaded library with three
   48098 allocated sections (.text, .data, .bss), looks like this:
   48099 
   48100 @smallexample
   48101 <library-list>
   48102   <library name="sharedlib.o">
   48103     <section address="0x10000000"/>
   48104     <section address="0x20000000"/>
   48105     <section address="0x30000000"/>
   48106   </library>
   48107 </library-list>
   48108 @end smallexample
   48109 
   48110 The format of a library list is described by this DTD:
   48111 
   48112 @smallexample
   48113 <!-- library-list: Root element with versioning -->
   48114 <!ELEMENT library-list  (library)*>
   48115 <!ATTLIST library-list  version CDATA   #FIXED  "1.0">
   48116 <!ELEMENT library       (segment*, section*)>
   48117 <!ATTLIST library       name    CDATA   #REQUIRED>
   48118 <!ELEMENT segment       EMPTY>
   48119 <!ATTLIST segment       address CDATA   #REQUIRED>
   48120 <!ELEMENT section       EMPTY>
   48121 <!ATTLIST section       address CDATA   #REQUIRED>
   48122 @end smallexample
   48123 
   48124 In addition, segments and section descriptors cannot be mixed within a
   48125 single library element, and you must supply at least one segment or
   48126 section for each library.
   48127 
   48128 @node Library List Format for SVR4 Targets
   48129 @section Library List Format for SVR4 Targets
   48130 @cindex library list format, remote protocol
   48131 
   48132 On SVR4 platforms @value{GDBN} can use the symbol table of a dynamic loader
   48133 (e.g.@: @file{ld.so}) and normal memory operations to maintain a list of
   48134 shared libraries.  Still a special library list provided by this packet is
   48135 more efficient for the @value{GDBN} remote protocol.
   48136 
   48137 The @samp{qXfer:libraries-svr4:read} packet returns an XML document which lists
   48138 loaded libraries and their SVR4 linker parameters.  For each library on SVR4
   48139 target, the following parameters are reported:
   48140 
   48141 @itemize @minus
   48142 @item
   48143 @code{name}, the absolute file name from the @code{l_name} field of
   48144 @code{struct link_map}.
   48145 @item
   48146 @code{lm} with address of @code{struct link_map} used for TLS
   48147 (Thread Local Storage) access.
   48148 @item
   48149 @code{l_addr}, the displacement as read from the field @code{l_addr} of
   48150 @code{struct link_map}.  For prelinked libraries this is not an absolute
   48151 memory address.  It is a displacement of absolute memory address against
   48152 address the file was prelinked to during the library load.
   48153 @item
   48154 @code{l_ld}, which is memory address of the @code{PT_DYNAMIC} segment
   48155 @item
   48156 @code{lmid}, which is an identifier for a linker namespace, such as
   48157 the memory address of the @code{r_debug} object that contains this
   48158 namespace's load map or the namespace identifier returned by
   48159 @code{dlinfo (3)}.
   48160 @end itemize
   48161 
   48162 Additionally the single @code{main-lm} attribute specifies address of
   48163 @code{struct link_map} used for the main executable.  This parameter is used
   48164 for TLS access and its presence is optional.
   48165 
   48166 @value{GDBN} must be linked with the Expat library to support XML
   48167 SVR4 library lists.  @xref{Expat}.
   48168 
   48169 A simple memory map, with two loaded libraries (which do not use prelink),
   48170 looks like this:
   48171 
   48172 @smallexample
   48173 <library-list-svr4 version="1.0" main-lm="0xe4f8f8">
   48174   <library name="/lib/ld-linux.so.2" lm="0xe4f51c" l_addr="0xe2d000"
   48175            l_ld="0xe4eefc" lmid="0xfffe0"/>
   48176   <library name="/lib/libc.so.6" lm="0xe4fbe8" l_addr="0x154000"
   48177            l_ld="0x152350" lmid="0xfffe0"/>
   48178 </library-list-svr>
   48179 @end smallexample
   48180 
   48181 The format of an SVR4 library list is described by this DTD:
   48182 
   48183 @smallexample
   48184 <!-- library-list-svr4: Root element with versioning -->
   48185 <!ELEMENT library-list-svr4  (library)*>
   48186 <!ATTLIST library-list-svr4  version CDATA   #FIXED  "1.0">
   48187 <!ATTLIST library-list-svr4  main-lm CDATA   #IMPLIED>
   48188 <!ELEMENT library            EMPTY>
   48189 <!ATTLIST library            name    CDATA   #REQUIRED>
   48190 <!ATTLIST library            lm      CDATA   #REQUIRED>
   48191 <!ATTLIST library            l_addr  CDATA   #REQUIRED>
   48192 <!ATTLIST library            l_ld    CDATA   #REQUIRED>
   48193 <!ATTLIST library            lmid    CDATA   #IMPLIED>
   48194 @end smallexample
   48195 
   48196 @node Memory Map Format
   48197 @section Memory Map Format
   48198 @cindex memory map format
   48199 
   48200 To be able to write into flash memory, @value{GDBN} needs to obtain a
   48201 memory map from the target.  This section describes the format of the
   48202 memory map.
   48203 
   48204 The memory map is obtained using the @samp{qXfer:memory-map:read}
   48205 (@pxref{qXfer memory map read}) packet and is an XML document that
   48206 lists memory regions.
   48207 
   48208 @value{GDBN} must be linked with the Expat library to support XML
   48209 memory maps.  @xref{Expat}.
   48210 
   48211 The top-level structure of the document is shown below:
   48212 
   48213 @smallexample
   48214 <?xml version="1.0"?>
   48215 <!DOCTYPE memory-map
   48216           PUBLIC "+//IDN gnu.org//DTD GDB Memory Map V1.0//EN"
   48217                  "http://sourceware.org/gdb/gdb-memory-map.dtd">
   48218 <memory-map>
   48219     region...
   48220 </memory-map>
   48221 @end smallexample
   48222 
   48223 Each region can be either:
   48224 
   48225 @itemize
   48226 
   48227 @item
   48228 A region of RAM starting at @var{addr} and extending for @var{length}
   48229 bytes from there:
   48230 
   48231 @smallexample
   48232 <memory type="ram" start="@var{addr}" length="@var{length}"/>
   48233 @end smallexample
   48234 
   48235 
   48236 @item
   48237 A region of read-only memory:
   48238 
   48239 @smallexample
   48240 <memory type="rom" start="@var{addr}" length="@var{length}"/>
   48241 @end smallexample
   48242 
   48243 
   48244 @item
   48245 A region of flash memory, with erasure blocks @var{blocksize}
   48246 bytes in length:
   48247 
   48248 @smallexample
   48249 <memory type="flash" start="@var{addr}" length="@var{length}">
   48250   <property name="blocksize">@var{blocksize}</property>
   48251 </memory>
   48252 @end smallexample
   48253 
   48254 @end itemize
   48255 
   48256 Regions must not overlap.  @value{GDBN} assumes that areas of memory not covered
   48257 by the memory map are RAM, and uses the ordinary @samp{M} and @samp{X}
   48258 packets to write to addresses in such ranges.
   48259 
   48260 The formal DTD for memory map format is given below:
   48261 
   48262 @smallexample
   48263 <!-- ................................................... -->
   48264 <!-- Memory Map XML DTD ................................ -->
   48265 <!-- File: memory-map.dtd .............................. -->
   48266 <!-- .................................... .............. -->
   48267 <!-- memory-map.dtd -->
   48268 <!-- memory-map: Root element with versioning -->
   48269 <!ELEMENT memory-map (memory)*>
   48270 <!ATTLIST memory-map    version CDATA   #FIXED  "1.0.0">
   48271 <!ELEMENT memory (property)*>
   48272 <!-- memory: Specifies a memory region,
   48273              and its type, or device. -->
   48274 <!ATTLIST memory        type    (ram|rom|flash) #REQUIRED
   48275                         start   CDATA   #REQUIRED
   48276                         length  CDATA   #REQUIRED>
   48277 <!-- property: Generic attribute tag -->
   48278 <!ELEMENT property (#PCDATA | property)*>
   48279 <!ATTLIST property      name    (blocksize) #REQUIRED>
   48280 @end smallexample
   48281 
   48282 @node Thread List Format
   48283 @section Thread List Format
   48284 @cindex thread list format
   48285 
   48286 To efficiently update the list of threads and their attributes,
   48287 @value{GDBN} issues the @samp{qXfer:threads:read} packet
   48288 (@pxref{qXfer threads read}) and obtains the XML document with
   48289 the following structure:
   48290 
   48291 @smallexample
   48292 <?xml version="1.0"?>
   48293 <threads>
   48294     <thread id="id" core="0" name="name" handle="1a2b3c">
   48295     ... description ...
   48296     </thread>
   48297 </threads>
   48298 @end smallexample
   48299 
   48300 Each @samp{thread} element must have the @samp{id} attribute that
   48301 identifies the thread (@pxref{thread-id syntax}).  The
   48302 @samp{core} attribute, if present, specifies which processor core
   48303 the thread was last executing on.  The @samp{name} attribute, if
   48304 present, specifies the human-readable name of the thread.  The content
   48305 of the of @samp{thread} element is interpreted as human-readable
   48306 auxiliary information.  The @samp{handle} attribute, if present,
   48307 is a hex encoded representation of the thread handle.
   48308 
   48309 
   48310 @node Traceframe Info Format
   48311 @section Traceframe Info Format
   48312 @cindex traceframe info format
   48313 
   48314 To be able to know which objects in the inferior can be examined when
   48315 inspecting a tracepoint hit, @value{GDBN} needs to obtain the list of
   48316 memory ranges, registers and trace state variables that have been
   48317 collected in a traceframe.
   48318 
   48319 This list is obtained using the @samp{qXfer:traceframe-info:read}
   48320 (@pxref{qXfer traceframe info read}) packet and is an XML document.
   48321 
   48322 @value{GDBN} must be linked with the Expat library to support XML
   48323 traceframe info discovery.  @xref{Expat}.
   48324 
   48325 The top-level structure of the document is shown below:
   48326 
   48327 @smallexample
   48328 <?xml version="1.0"?>
   48329 <!DOCTYPE traceframe-info
   48330           PUBLIC "+//IDN gnu.org//DTD GDB Memory Map V1.0//EN"
   48331                  "http://sourceware.org/gdb/gdb-traceframe-info.dtd">
   48332 <traceframe-info>
   48333    block...
   48334 </traceframe-info>
   48335 @end smallexample
   48336 
   48337 Each traceframe block can be either:
   48338 
   48339 @itemize
   48340 
   48341 @item
   48342 A region of collected memory starting at @var{addr} and extending for
   48343 @var{length} bytes from there:
   48344 
   48345 @smallexample
   48346 <memory start="@var{addr}" length="@var{length}"/>
   48347 @end smallexample
   48348 
   48349 @item
   48350 A block indicating trace state variable numbered @var{number} has been
   48351 collected:
   48352 
   48353 @smallexample
   48354 <tvar id="@var{number}"/>
   48355 @end smallexample
   48356 
   48357 @end itemize
   48358 
   48359 The formal DTD for the traceframe info format is given below:
   48360 
   48361 @smallexample
   48362 <!ELEMENT traceframe-info  (memory | tvar)* >
   48363 <!ATTLIST traceframe-info  version CDATA   #FIXED  "1.0">
   48364 
   48365 <!ELEMENT memory        EMPTY>
   48366 <!ATTLIST memory        start   CDATA   #REQUIRED
   48367                         length  CDATA   #REQUIRED>
   48368 <!ELEMENT tvar>
   48369 <!ATTLIST tvar          id      CDATA   #REQUIRED>
   48370 @end smallexample
   48371 
   48372 @node Branch Trace Format
   48373 @section Branch Trace Format
   48374 @cindex branch trace format
   48375 
   48376 In order to display the branch trace of an inferior thread,
   48377 @value{GDBN} needs to obtain the list of branches.  This list is
   48378 represented as list of sequential code blocks that are connected via
   48379 branches.  The code in each block has been executed sequentially.
   48380 
   48381 This list is obtained using the @samp{qXfer:btrace:read}
   48382 (@pxref{qXfer btrace read}) packet and is an XML document.
   48383 
   48384 @value{GDBN} must be linked with the Expat library to support XML
   48385 traceframe info discovery.  @xref{Expat}.
   48386 
   48387 The top-level structure of the document is shown below:
   48388 
   48389 @smallexample
   48390 <?xml version="1.0"?>
   48391 <!DOCTYPE btrace
   48392           PUBLIC "+//IDN gnu.org//DTD GDB Branch Trace V1.0//EN"
   48393                  "http://sourceware.org/gdb/gdb-btrace.dtd">
   48394 <btrace>
   48395    block...
   48396 </btrace>
   48397 @end smallexample
   48398 
   48399 @itemize
   48400 
   48401 @item
   48402 A block of sequentially executed instructions starting at @var{begin}
   48403 and ending at @var{end}:
   48404 
   48405 @smallexample
   48406 <block begin="@var{begin}" end="@var{end}"/>
   48407 @end smallexample
   48408 
   48409 @end itemize
   48410 
   48411 The formal DTD for the branch trace format is given below:
   48412 
   48413 @smallexample
   48414 <!ELEMENT btrace  (block* | pt) >
   48415 <!ATTLIST btrace  version CDATA   #FIXED "1.0">
   48416 
   48417 <!ELEMENT block        EMPTY>
   48418 <!ATTLIST block        begin  CDATA   #REQUIRED
   48419                        end    CDATA   #REQUIRED>
   48420 
   48421 <!ELEMENT pt (pt-config?, raw?)>
   48422 
   48423 <!ELEMENT pt-config (cpu?)>
   48424 
   48425 <!ELEMENT cpu EMPTY>
   48426 <!ATTLIST cpu vendor   CDATA #REQUIRED
   48427               family   CDATA #REQUIRED
   48428               model    CDATA #REQUIRED
   48429               stepping CDATA #REQUIRED>
   48430 
   48431 <!ELEMENT raw (#PCDATA)>
   48432 @end smallexample
   48433 
   48434 @node Branch Trace Configuration Format
   48435 @section Branch Trace Configuration Format
   48436 @cindex branch trace configuration format
   48437 
   48438 For each inferior thread, @value{GDBN} can obtain the branch trace
   48439 configuration using the @samp{qXfer:btrace-conf:read}
   48440 (@pxref{qXfer btrace-conf read}) packet.
   48441 
   48442 The configuration describes the branch trace format and configuration
   48443 settings for that format.  The following information is described:
   48444 
   48445 @table @code
   48446 @item bts
   48447 This thread uses the @dfn{Branch Trace Store} (@acronym{BTS}) format.
   48448 @table @code
   48449 @item size
   48450 The size of the @acronym{BTS} ring buffer in bytes.
   48451 @end table
   48452 @item pt
   48453 This thread uses the @dfn{Intel Processor Trace} (@acronym{Intel
   48454 PT}) format.
   48455 @table @code
   48456 @item size
   48457 The size of the @acronym{Intel PT} ring buffer in bytes.
   48458 @end table
   48459 @end table
   48460 
   48461 @value{GDBN} must be linked with the Expat library to support XML
   48462 branch trace configuration discovery.  @xref{Expat}.
   48463 
   48464 The formal DTD for the branch trace configuration format is given below:
   48465 
   48466 @smallexample
   48467 <!ELEMENT btrace-conf		(bts?, pt?)>
   48468 <!ATTLIST btrace-conf		version	CDATA	#FIXED "1.0">
   48469 
   48470 <!ELEMENT bts	EMPTY>
   48471 <!ATTLIST bts	size		CDATA	#IMPLIED>
   48472 
   48473 <!ELEMENT pt	EMPTY>
   48474 <!ATTLIST pt	size		CDATA	#IMPLIED>
   48475 <!ATTLIST pt	ptwrite		(yes | no)	#IMPLIED>
   48476 <!ATTLIST pt	event-tracing	(yes | no)	#IMPLIED>
   48477 @end smallexample
   48478 
   48479 @include agentexpr.texi
   48480 
   48481 @node Target Descriptions
   48482 @appendix Target Descriptions
   48483 @cindex target descriptions
   48484 
   48485 One of the challenges of using @value{GDBN} to debug embedded systems
   48486 is that there are so many minor variants of each processor
   48487 architecture in use.  It is common practice for vendors to start with
   48488 a standard processor core --- ARM, PowerPC, or @acronym{MIPS}, for example ---
   48489 and then make changes to adapt it to a particular market niche.  Some
   48490 architectures have hundreds of variants, available from dozens of
   48491 vendors.  This leads to a number of problems:
   48492 
   48493 @itemize @bullet
   48494 @item
   48495 With so many different customized processors, it is difficult for
   48496 the @value{GDBN} maintainers to keep up with the changes.
   48497 @item
   48498 Since individual variants may have short lifetimes or limited
   48499 audiences, it may not be worthwhile to carry information about every
   48500 variant in the @value{GDBN} source tree.
   48501 @item
   48502 When @value{GDBN} does support the architecture of the embedded system
   48503 at hand, the task of finding the correct architecture name to give the
   48504 @command{set architecture} command can be error-prone.
   48505 @end itemize
   48506 
   48507 To address these problems, the @value{GDBN} remote protocol allows a
   48508 target system to not only identify itself to @value{GDBN}, but to
   48509 actually describe its own features.  This lets @value{GDBN} support
   48510 processor variants it has never seen before --- to the extent that the
   48511 descriptions are accurate, and that @value{GDBN} understands them.
   48512 
   48513 @value{GDBN} must be linked with the Expat library to support XML
   48514 target descriptions.  @xref{Expat}.
   48515 
   48516 @menu
   48517 * Retrieving Descriptions::         How descriptions are fetched from a target.
   48518 * Target Description Format::       The contents of a target description.
   48519 * Predefined Target Types::         Standard types available for target
   48520                                     descriptions.
   48521 * Enum Target Types::               How to define enum target types.
   48522 * Standard Target Features::        Features @value{GDBN} knows about.
   48523 @end menu
   48524 
   48525 @node Retrieving Descriptions
   48526 @section Retrieving Descriptions
   48527 
   48528 Target descriptions can be read from the target automatically, or
   48529 specified by the user manually.  The default behavior is to read the
   48530 description from the target.  @value{GDBN} retrieves it via the remote
   48531 protocol using @samp{qXfer} requests (@pxref{General Query Packets,
   48532 qXfer}).  The @var{annex} in the @samp{qXfer} packet will be
   48533 @samp{target.xml}.  The contents of the @samp{target.xml} annex are an
   48534 XML document, of the form described in @ref{Target Description
   48535 Format}.
   48536 
   48537 Alternatively, you can specify a file to read for the target description.
   48538 If a file is set, the target will not be queried.  The commands to
   48539 specify a file are:
   48540 
   48541 @table @code
   48542 @cindex set tdesc filename
   48543 @item set tdesc filename @var{path}
   48544 Read the target description from @var{path}.
   48545 
   48546 @cindex unset tdesc filename
   48547 @item unset tdesc filename
   48548 Do not read the XML target description from a file.  @value{GDBN}
   48549 will use the description supplied by the current target.
   48550 
   48551 @cindex show tdesc filename
   48552 @item show tdesc filename
   48553 Show the filename to read for a target description, if any.
   48554 @end table
   48555 
   48556 
   48557 @node Target Description Format
   48558 @section Target Description Format
   48559 @cindex target descriptions, XML format
   48560 
   48561 A target description annex is an @uref{http://www.w3.org/XML/, XML}
   48562 document which complies with the Document Type Definition provided in
   48563 the @value{GDBN} sources in @file{gdb/features/gdb-target.dtd}.  This
   48564 means you can use generally available tools like @command{xmllint} to
   48565 check that your feature descriptions are well-formed and valid.
   48566 However, to help people unfamiliar with XML write descriptions for
   48567 their targets, we also describe the grammar here.
   48568 
   48569 Target descriptions can identify the architecture of the remote target
   48570 and (for some architectures) provide information about custom register
   48571 sets.  They can also identify the OS ABI of the remote target.
   48572 @value{GDBN} can use this information to autoconfigure for your
   48573 target, or to warn you if you connect to an unsupported target.
   48574 
   48575 Here is a simple target description:
   48576 
   48577 @smallexample
   48578 <target version="1.0">
   48579   <architecture>i386:x86-64</architecture>
   48580 </target>
   48581 @end smallexample
   48582 
   48583 @noindent
   48584 This minimal description only says that the target uses
   48585 the x86-64 architecture.
   48586 
   48587 A target description has the following overall form, with [ ] marking
   48588 optional elements and @dots{} marking repeatable elements.  The elements
   48589 are explained further below.
   48590 
   48591 @smallexample
   48592 <?xml version="1.0"?>
   48593 <!DOCTYPE target SYSTEM "gdb-target.dtd">
   48594 <target version="1.0">
   48595   @r{[}@var{architecture}@r{]}
   48596   @r{[}@var{osabi}@r{]}
   48597   @r{[}@var{compatible}@r{]}
   48598   @r{[}@var{feature}@dots{}@r{]}
   48599 </target>
   48600 @end smallexample
   48601 
   48602 @noindent
   48603 The description is generally insensitive to whitespace and line
   48604 breaks, under the usual common-sense rules.  The XML version
   48605 declaration and document type declaration can generally be omitted
   48606 (@value{GDBN} does not require them), but specifying them may be
   48607 useful for XML validation tools.  The @samp{version} attribute for
   48608 @samp{<target>} may also be omitted, but we recommend
   48609 including it; if future versions of @value{GDBN} use an incompatible
   48610 revision of @file{gdb-target.dtd}, they will detect and report
   48611 the version mismatch.
   48612 
   48613 @subsection Inclusion
   48614 @cindex target descriptions, inclusion
   48615 @cindex XInclude
   48616 @ifnotinfo
   48617 @cindex <xi:include>
   48618 @end ifnotinfo
   48619 
   48620 It can sometimes be valuable to split a target description up into
   48621 several different annexes, either for organizational purposes, or to
   48622 share files between different possible target descriptions.  You can
   48623 divide a description into multiple files by replacing any element of
   48624 the target description with an inclusion directive of the form:
   48625 
   48626 @smallexample
   48627 <xi:include href="@var{document}"/>
   48628 @end smallexample
   48629 
   48630 @noindent
   48631 When @value{GDBN} encounters an element of this form, it will retrieve
   48632 the named XML @var{document}, and replace the inclusion directive with
   48633 the contents of that document.  If the current description was read
   48634 using @samp{qXfer}, then so will be the included document;
   48635 @var{document} will be interpreted as the name of an annex.  If the
   48636 current description was read from a file, @value{GDBN} will look for
   48637 @var{document} as a file in the same directory where it found the
   48638 original description.
   48639 
   48640 @subsection Architecture
   48641 @cindex <architecture>
   48642 
   48643 An @samp{<architecture>} element has this form:
   48644 
   48645 @smallexample
   48646   <architecture>@var{arch}</architecture>
   48647 @end smallexample
   48648 
   48649 @var{arch} is one of the architectures from the set accepted by
   48650 @code{set architecture} (@pxref{Targets, ,Specifying a Debugging Target}).
   48651 
   48652 @subsection OS ABI
   48653 @cindex @code{<osabi>}
   48654 
   48655 This optional field was introduced in @value{GDBN} version 7.0.
   48656 Previous versions of @value{GDBN} ignore it.
   48657 
   48658 An @samp{<osabi>} element has this form:
   48659 
   48660 @smallexample
   48661   <osabi>@var{abi-name}</osabi>
   48662 @end smallexample
   48663 
   48664 @var{abi-name} is an OS ABI name from the same selection accepted by
   48665 @w{@code{set osabi}} (@pxref{ABI, ,Configuring the Current ABI}).
   48666 
   48667 @subsection Compatible Architecture
   48668 @cindex @code{<compatible>}
   48669 
   48670 This optional field was introduced in @value{GDBN} version 7.0.
   48671 Previous versions of @value{GDBN} ignore it.
   48672 
   48673 A @samp{<compatible>} element has this form:
   48674 
   48675 @smallexample
   48676   <compatible>@var{arch}</compatible>
   48677 @end smallexample
   48678 
   48679 @var{arch} is one of the architectures from the set accepted by
   48680 @code{set architecture} (@pxref{Targets, ,Specifying a Debugging Target}).
   48681 
   48682 A @samp{<compatible>} element is used to specify that the target
   48683 is able to run binaries in some other than the main target architecture
   48684 given by the @samp{<architecture>} element.  For example, on the
   48685 Cell Broadband Engine, the main architecture is @code{powerpc:common}
   48686 or @code{powerpc:common64}, but the system is able to run binaries
   48687 in the @code{spu} architecture as well.  The way to describe this
   48688 capability with @samp{<compatible>} is as follows:
   48689 
   48690 @smallexample
   48691   <architecture>powerpc:common</architecture>
   48692   <compatible>spu</compatible>
   48693 @end smallexample
   48694 
   48695 @subsection Features
   48696 @cindex <feature>
   48697 
   48698 Each @samp{<feature>} describes some logical portion of the target
   48699 system.  Features are currently used to describe available CPU
   48700 registers and the types of their contents.  A @samp{<feature>} element
   48701 has this form:
   48702 
   48703 @smallexample
   48704 <feature name="@var{name}">
   48705   @r{[}@var{type}@dots{}@r{]}
   48706   @var{reg}@dots{}
   48707 </feature>
   48708 @end smallexample
   48709 
   48710 @noindent
   48711 Each feature's name should be unique within the description.  The name
   48712 of a feature does not matter unless @value{GDBN} has some special
   48713 knowledge of the contents of that feature; if it does, the feature
   48714 should have its standard name.  @xref{Standard Target Features}.
   48715 
   48716 @subsection Types
   48717 
   48718 Any register's value is a collection of bits which @value{GDBN} must
   48719 interpret.  The default interpretation is a two's complement integer,
   48720 but other types can be requested by name in the register description.
   48721 Some predefined types are provided by @value{GDBN} (@pxref{Predefined
   48722 Target Types}), and the description can define additional composite
   48723 and enum types.
   48724 
   48725 Each type element must have an @samp{id} attribute, which gives
   48726 a unique (within the containing @samp{<feature>}) name to the type.
   48727 Types must be defined before they are used.
   48728 
   48729 @cindex <vector>
   48730 Some targets offer vector registers, which can be treated as arrays
   48731 of scalar elements.  These types are written as @samp{<vector>} elements,
   48732 specifying the array element type, @var{type}, and the number of elements,
   48733 @var{count}:
   48734 
   48735 @smallexample
   48736 <vector id="@var{id}" type="@var{type}" count="@var{count}"/>
   48737 @end smallexample
   48738 
   48739 @cindex <union>
   48740 If a register's value is usefully viewed in multiple ways, define it
   48741 with a union type containing the useful representations.  The
   48742 @samp{<union>} element contains one or more @samp{<field>} elements,
   48743 each of which has a @var{name} and a @var{type}:
   48744 
   48745 @smallexample
   48746 <union id="@var{id}">
   48747   <field name="@var{name}" type="@var{type}"/>
   48748   @dots{}
   48749 </union>
   48750 @end smallexample
   48751 
   48752 @cindex <struct>
   48753 @cindex <flags>
   48754 If a register's value is composed from several separate values, define
   48755 it with either a structure type or a flags type.
   48756 A flags type may only contain bitfields.
   48757 A structure type may either contain only bitfields or contain no bitfields.
   48758 If the value contains only bitfields, its total size in bytes must be
   48759 specified.
   48760 
   48761 Non-bitfield values have a @var{name} and @var{type}.
   48762 
   48763 @smallexample
   48764 <struct id="@var{id}">
   48765   <field name="@var{name}" type="@var{type}"/>
   48766   @dots{}
   48767 </struct>
   48768 @end smallexample
   48769 
   48770 Both @var{name} and @var{type} values are required.
   48771 No implicit padding is added.
   48772 
   48773 Bitfield values have a @var{name}, @var{start}, @var{end} and @var{type}.
   48774 
   48775 @smallexample
   48776 <struct id="@var{id}" size="@var{size}">
   48777   <field name="@var{name}" start="@var{start}" end="@var{end}" type="@var{type}"/>
   48778   @dots{}
   48779 </struct>
   48780 @end smallexample
   48781 
   48782 @smallexample
   48783 <flags id="@var{id}" size="@var{size}">
   48784   <field name="@var{name}" start="@var{start}" end="@var{end}" type="@var{type}"/>
   48785   @dots{}
   48786 </flags>
   48787 @end smallexample
   48788 
   48789 The @var{name} value is required.
   48790 Bitfield values may be named with the empty string, @samp{""},
   48791 in which case the field is ``filler'' and its value is not printed.
   48792 Not all bits need to be specified, so ``filler'' fields are optional.
   48793 
   48794 The @var{start} and @var{end} values are required, and @var{type}
   48795 is optional.
   48796 The field's @var{start} must be less than or equal to its @var{end},
   48797 and zero represents the least significant bit.
   48798 
   48799 The default value of @var{type} is @code{bool} for single bit fields,
   48800 and an unsigned integer otherwise.
   48801 
   48802 Which to choose?  Structures or flags?
   48803 
   48804 Registers defined with @samp{flags} have these advantages over
   48805 defining them with @samp{struct}:
   48806 
   48807 @itemize @bullet
   48808 @item
   48809 Arithmetic may be performed on them as if they were integers.
   48810 @item
   48811 They are printed in a more readable fashion.
   48812 @end itemize
   48813 
   48814 Registers defined with @samp{struct} have one advantage over
   48815 defining them with @samp{flags}:
   48816 
   48817 @itemize @bullet
   48818 @item
   48819 One can fetch individual fields like in @samp{C}.
   48820 
   48821 @smallexample
   48822 (@value{GDBP}) print $my_struct_reg.field3
   48823 $1 = 42
   48824 @end smallexample
   48825 
   48826 @end itemize
   48827 
   48828 @subsection Registers
   48829 @cindex <reg>
   48830 
   48831 Each register is represented as an element with this form:
   48832 
   48833 @smallexample
   48834 <reg name="@var{name}"
   48835      bitsize="@var{size}"
   48836      @r{[}regnum="@var{num}"@r{]}
   48837      @r{[}save-restore="@var{save-restore}"@r{]}
   48838      @r{[}type="@var{type}"@r{]}
   48839      @r{[}group="@var{group}"@r{]}/>
   48840 @end smallexample
   48841 
   48842 @noindent
   48843 The components are as follows:
   48844 
   48845 @table @var
   48846 
   48847 @item name
   48848 The register's name; it must be unique within the target description.
   48849 
   48850 @item bitsize
   48851 The register's size, in bits.
   48852 
   48853 @item regnum
   48854 The register's number.  If omitted, a register's number is one greater
   48855 than that of the previous register (either in the current feature or in
   48856 a preceding feature); the first register in the target description
   48857 defaults to zero.  This register number is used to read or write
   48858 the register; e.g.@: it is used in the remote @code{p} and @code{P}
   48859 packets, and registers appear in the @code{g} and @code{G} packets
   48860 in order of increasing register number.
   48861 
   48862 @item save-restore
   48863 Whether the register should be preserved across inferior function
   48864 calls; this must be either @code{yes} or @code{no}.  The default is
   48865 @code{yes}, which is appropriate for most registers except for
   48866 some system control registers; this is not related to the target's
   48867 ABI.
   48868 
   48869 @item type
   48870 The type of the register.  It may be a predefined type, a type
   48871 defined in the current feature, or one of the special types @code{int}
   48872 and @code{float}.  @code{int} is an integer type of the correct size
   48873 for @var{bitsize}, and @code{float} is a floating point type (in the
   48874 architecture's normal floating point format) of the correct size for
   48875 @var{bitsize}.  The default is @code{int}.
   48876 
   48877 @item group
   48878 The register group to which this register belongs.  It can be one of the
   48879 standard register groups @code{general}, @code{float}, @code{vector} or an
   48880 arbitrary string.  Group names should be limited to alphanumeric characters.
   48881 If a group name is made up of multiple words the words may be separated by
   48882 hyphens; e.g.@: @code{special-group} or @code{ultra-special-group}.  If no
   48883 @var{group} is specified, @value{GDBN} will not display the register in
   48884 @code{info registers}.
   48885 
   48886 @end table
   48887 
   48888 @node Predefined Target Types
   48889 @section Predefined Target Types
   48890 @cindex target descriptions, predefined types
   48891 
   48892 Type definitions in the self-description can build up composite types
   48893 from basic building blocks, but can not define fundamental types.  Instead,
   48894 standard identifiers are provided by @value{GDBN} for the fundamental
   48895 types.  The currently supported types are:
   48896 
   48897 @table @code
   48898 
   48899 @item bool
   48900 Boolean type, occupying a single bit.
   48901 
   48902 @item int8
   48903 @itemx int16
   48904 @itemx int24
   48905 @itemx int32
   48906 @itemx int64
   48907 @itemx int128
   48908 Signed integer types holding the specified number of bits.
   48909 
   48910 @item uint8
   48911 @itemx uint16
   48912 @itemx uint24
   48913 @itemx uint32
   48914 @itemx uint64
   48915 @itemx uint128
   48916 Unsigned integer types holding the specified number of bits.
   48917 
   48918 @item code_ptr
   48919 @itemx data_ptr
   48920 Pointers to unspecified code and data.  The program counter and
   48921 any dedicated return address register may be marked as code
   48922 pointers; printing a code pointer converts it into a symbolic
   48923 address.  The stack pointer and any dedicated address registers
   48924 may be marked as data pointers.
   48925 
   48926 @item ieee_half
   48927 Half precision IEEE floating point.
   48928 
   48929 @item ieee_single
   48930 Single precision IEEE floating point.
   48931 
   48932 @item ieee_double
   48933 Double precision IEEE floating point.
   48934 
   48935 @item bfloat16
   48936 The 16-bit @dfn{brain floating point} format used e.g.@: by x86 and ARM.
   48937 
   48938 @item arm_fpa_ext
   48939 The 12-byte extended precision format used by ARM FPA registers.
   48940 
   48941 @item i387_ext
   48942 The 10-byte extended precision format used by x87 registers.
   48943 
   48944 @item i386_eflags
   48945 32bit @sc{eflags} register used by x86.
   48946 
   48947 @item i386_mxcsr
   48948 32bit @sc{mxcsr} register used by x86.
   48949 
   48950 @end table
   48951 
   48952 @node Enum Target Types
   48953 @section Enum Target Types
   48954 @cindex target descriptions, enum types
   48955 
   48956 Enum target types are useful in @samp{struct} and @samp{flags}
   48957 register descriptions.  @xref{Target Description Format}.
   48958 
   48959 Enum types have a name, size and a list of name/value pairs.
   48960 
   48961 @smallexample
   48962 <enum id="@var{id}" size="@var{size}">
   48963   <evalue name="@var{name}" value="@var{value}"/>
   48964   @dots{}
   48965 </enum>
   48966 @end smallexample
   48967 
   48968 Enums must be defined before they are used.
   48969 
   48970 @smallexample
   48971 <enum id="levels_type" size="4">
   48972   <evalue name="low" value="0"/>
   48973   <evalue name="high" value="1"/>
   48974 </enum>
   48975 <flags id="flags_type" size="4">
   48976   <field name="X" start="0"/>
   48977   <field name="LEVEL" start="1" end="1" type="levels_type"/>
   48978 </flags>
   48979 <reg name="flags" bitsize="32" type="flags_type"/>
   48980 @end smallexample
   48981 
   48982 Given that description, a value of 3 for the @samp{flags} register
   48983 would be printed as:
   48984 
   48985 @smallexample
   48986 (@value{GDBP}) info register flags
   48987 flags 0x3 [ X LEVEL=high ]
   48988 @end smallexample
   48989 
   48990 @node Standard Target Features
   48991 @section Standard Target Features
   48992 @cindex target descriptions, standard features
   48993 
   48994 A target description must contain either no registers or all the
   48995 target's registers.  If the description contains no registers, then
   48996 @value{GDBN} will assume a default register layout, selected based on
   48997 the architecture.  If the description contains any registers, the
   48998 default layout will not be used; the standard registers must be
   48999 described in the target description, in such a way that @value{GDBN}
   49000 can recognize them.
   49001 
   49002 This is accomplished by giving specific names to feature elements
   49003 which contain standard registers.  @value{GDBN} will look for features
   49004 with those names and verify that they contain the expected registers;
   49005 if any known feature is missing required registers, or if any required
   49006 feature is missing, @value{GDBN} will reject the target
   49007 description.  You can add additional registers to any of the
   49008 standard features --- @value{GDBN} will display them just as if
   49009 they were added to an unrecognized feature.
   49010 
   49011 This section lists the known features and their expected contents.
   49012 Sample XML documents for these features are included in the
   49013 @value{GDBN} source tree, in the directory @file{gdb/features}.
   49014 
   49015 Names recognized by @value{GDBN} should include the name of the
   49016 company or organization which selected the name, and the overall
   49017 architecture to which the feature applies; so e.g.@: the feature
   49018 containing ARM core registers is named @samp{org.gnu.gdb.arm.core}.
   49019 
   49020 The names of registers are not case sensitive for the purpose
   49021 of recognizing standard features, but @value{GDBN} will only display
   49022 registers using the capitalization used in the description.
   49023 
   49024 @menu
   49025 * AArch64 Features::
   49026 * ARC Features::
   49027 * ARM Features::
   49028 * i386 Features::
   49029 * LoongArch Features::
   49030 * MicroBlaze Features::
   49031 * MIPS Features::
   49032 * M68K Features::
   49033 * NDS32 Features::
   49034 * OpenRISC 1000 Features::
   49035 * PowerPC Features::
   49036 * RISC-V Features::
   49037 * RX Features::
   49038 * S/390 and System z Features::
   49039 * Sparc Features::
   49040 * TIC6x Features::
   49041 @end menu
   49042 
   49043 
   49044 @node AArch64 Features
   49045 @subsection AArch64 Features
   49046 @cindex target descriptions, AArch64 features
   49047 
   49048 @subsubsection AArch64 core registers feature
   49049 
   49050 The @samp{org.gnu.gdb.aarch64.core} feature is required for AArch64
   49051 targets.  It must contain the following:
   49052 
   49053 @itemize @minus
   49054 @item
   49055 @samp{x0} through @samp{x30}, the general purpose registers, with size of
   49056 64 bits.  Register @samp{x30} is also known as the @dfn{link register},
   49057 or @samp{lr}.
   49058 @item
   49059 @samp{sp}, the stack pointer register or @samp{x31}.  It is 64 bits in size and
   49060 has a type of @samp{data_ptr}.
   49061 @item
   49062 @samp{pc}, the program counter register.  It is 64 bits in size and has a type
   49063 of @samp{code_ptr}.
   49064 @item
   49065 @samp{cpsr}, the current program status register.  It is 32 bits in size
   49066 and has a custom flags type.
   49067 @end itemize
   49068 
   49069 The semantics of the individual flags and fields in @samp{cpsr} can change as
   49070 new architectural features are added.  The current layout can be found in the
   49071 aarch64-core.xml file.
   49072 
   49073 Extra registers are allowed in this feature, but they will not affect
   49074 @value{GDBN}.
   49075 
   49076 @subsubsection AArch64 floating-point registers feature
   49077 
   49078 The @samp{org.gnu.gdb.aarch64.fpu} feature is optional.  If present,
   49079 it must contain the following registers:
   49080 
   49081 @itemize @minus
   49082 @item
   49083 @samp{v0} through @samp{v31}, the vector registers with size of 128 bits.  The
   49084 type is a custom vector type.
   49085 @item
   49086 @samp{fpsr}, the floating-point status register.  It is 32 bits in size and has
   49087 a custom flags type.
   49088 @item
   49089 @samp{fpcr}, the floating-point control register.  It is 32 bits in size and has
   49090 a custom flags type.
   49091 @end itemize
   49092 
   49093 The semantics of the individual flags and fields in @samp{fpsr} and @samp{fpcr}
   49094 can change as new architectural features are added.
   49095 
   49096 The types for the vector registers, @samp{fpsr} and @samp{fpcr} registers can
   49097 be found in the aarch64-fpu.xml file.
   49098 
   49099 Extra registers are allowed in this feature, but they will not affect
   49100 @value{GDBN}.
   49101 
   49102 @subsubsection AArch64 SVE registers feature
   49103 
   49104 The @samp{org.gnu.gdb.aarch64.sve} feature is optional.  If present,
   49105 it means the target supports the Scalable Vector Extension and must contain
   49106 the following registers:
   49107 
   49108 @itemize @minus
   49109 @item
   49110 @samp{z0} through @samp{z31}, the scalable vector registers.  Their sizes are
   49111 variable and a multiple of 128 bits up to a maximum of 2048 bit.  Their type is
   49112 a custom union type that helps visualize different sizes of sub-vectors.
   49113 @item
   49114 @samp{fpsr}, the floating-point status register.  It is 32 bits in size and has
   49115 a custom flags type.
   49116 @item
   49117 @samp{fpcr}, the floating-point control register.  It is 32 bits in size and has
   49118 a custom flags type.
   49119 @item
   49120 @samp{p0} through @samp{p15}, the predicate registers.  Their sizes are
   49121 variable, based on the current vector length, and a multiple of
   49122 16 bits.  Their types are a custom union to help visualize sub-elements.
   49123 @item
   49124 @samp{ffr}, the First Fault register.  It has a variable size based on the
   49125 current vector length and is a multiple of 16 bits.  The type is the same as
   49126 the predicate registers.
   49127 @item
   49128 @samp{vg}, the vector granule.  It represents the number of 64 bits chunks in
   49129 a @samp{z} register.  It is closely associated with the current vector
   49130 length.  It has a type of @samp{int}.
   49131 @end itemize
   49132 
   49133 When @value{GDBN} sees the SVE feature, it will assume the Scalable Vector
   49134 Extension is supported, and will adjust the sizes of the @samp{z}, @samp{p}
   49135 and @samp{ffr} registers accordingly, based on the value of @samp{vg}.
   49136 
   49137 @value{GDBN} will also create pseudo-registers equivalent to the @samp{v}
   49138 vector registers from the @samp{org.gnu.gdb.aarch64.fpu} feature.
   49139 
   49140 The first 128 bits of the @samp{z} registers overlap the 128 bits of the
   49141 @samp{v} registers, so changing one will trigger a change to the other.
   49142 
   49143 For the types of the @samp{z}, @samp{p} and @samp{ffr} registers, please
   49144 check the aarch64-sve.c file.  No XML file is available for this feature
   49145 because it is dynamically generated based on the current vector length.
   49146 
   49147 The semantics of the individual flags and fields in @samp{fpsr} and @samp{fpcr}
   49148 can change as new architectural features are added.
   49149 
   49150 The types for the @samp{fpsr} and @samp{fpcr} registers can be found in the
   49151 aarch64-sve.c file, and should match what is described in aarch64-fpu.xml.
   49152 
   49153 Extra registers are allowed in this feature, but they will not affect
   49154 @value{GDBN}.
   49155 
   49156 @subsubsection AArch64 Pointer Authentication registers feature
   49157 
   49158 The @samp{org.gnu.gdb.aarch64.pauth} optional feature was introduced so
   49159 @value{GDBN} could detect support for the Pointer Authentication
   49160 extension.  If present, it must contain one of two possible register sets.
   49161 
   49162 Pointer Authentication masks for user-mode:
   49163 
   49164 @itemize @minus
   49165 @item
   49166 @samp{pauth_dmask}, the user-mode pointer authentication mask for data
   49167 pointers.  It is 64 bits in size.
   49168 @item
   49169 @samp{pauth_cmask}, the user-mode pointer authentication mask for code
   49170 pointers.  It is 64 bits in size.
   49171 @end itemize
   49172 
   49173 Pointer Authentication masks for user-mode and kernel-mode:
   49174 
   49175 @itemize @minus
   49176 @item
   49177 @samp{pauth_dmask}, the user-mode pointer authentication mask for data
   49178 pointers.  It is 64 bits in size.
   49179 @item
   49180 @samp{pauth_cmask}, the user-mode pointer authentication mask for code
   49181 pointers.  It is 64 bits in size.
   49182 @item
   49183 @samp{pauth_dmask_high}, the kernel-mode pointer authentication mask for
   49184 data pointers.  It is 64 bits in size.
   49185 @item
   49186 @samp{pauth_cmask_high}, the kernel-mode pointer authentication mask for
   49187 code pointers.  It is 64 bits in size.
   49188 @end itemize
   49189 
   49190 If @value{GDBN} sees any of the two sets of registers in this feature, it will
   49191 assume the target is capable of signing pointers.  If so, @value{GDBN} will
   49192 decorate backtraces with a @samp{[PAC]} marker alongside a function that
   49193 has a signed link register value that needs to be unmasked/decoded.
   49194 
   49195 @value{GDBN} will also use the masks to remove non-address bits from pointers.
   49196 
   49197 Extra registers are allowed in this feature, but they will not affect
   49198 @value{GDBN}.
   49199 
   49200 Please note the @samp{org.gnu.gdb.aarch64.pauth} feature string is deprecated
   49201 and must only be used for backwards compatibility with older releases of
   49202 @value{GDBN} and @command{gdbserver}.  Targets that support Pointer
   49203 Authentication must advertise such capability by using the
   49204 @samp{org.gnu.gdb.aarch64.pauth_v2} feature string instead.
   49205 
   49206 The @samp{org.gnu.gdb.aarch64.pauth_v2} feature has the exact same contents
   49207 as feature @samp{org.gnu.gdb.aarch64.pauth}.
   49208 
   49209 The reason for having feature @samp{org.gnu.gdb.aarch64.pauth_v2} is a bug in
   49210 previous versions of @value{GDBN} (versions 9, 10, 11 and 12).  This bug
   49211 caused @value{GDBN} to crash whenever the target reported support for Pointer
   49212 Authentication (using feature string @samp{org.gnu.gdb.aarch64.pauth}) and also
   49213 reported additional system registers that were not accounted for by
   49214 @value{GDBN}.  This is more common when using emulators and on bare-metal
   49215 debugging scenarios.
   49216 
   49217 It can also happen if a newer gdbserver is used with an old @value{GDBN} that
   49218 has the bug.  In such a case, the newer gdbserver might report Pointer
   49219 Authentication support via the @samp{org.gnu.gdb.aarch64.pauth} feature string
   49220 and also report additional registers the older @value{GDBN} does not know
   49221 about, potentially leading to a crash.
   49222 
   49223 @subsubsection AArch64 TLS registers feature
   49224 
   49225 The @samp{org.gnu.gdb.aarch64.tls} optional feature was introduced to expose
   49226 the TLS registers to @value{GDBN}.  If present, it must contain either one
   49227 of the following register sets.
   49228 
   49229 Only @samp{tpidr}:
   49230 
   49231 @itemize @minus
   49232 @item
   49233 @samp{tpidr}, the software thread id register.  It is 64 bits in size and has a
   49234 type of @samp{data_ptr}.
   49235 @end itemize
   49236 
   49237 Both @samp{tpidr} and @samp{tpidr2}.
   49238 
   49239 @itemize @minus
   49240 @item
   49241 @samp{tpidr}, the software thread id register.  It is 64 bits in size and has a
   49242 type of @samp{data_ptr}.
   49243 @item
   49244 @samp{tpidr2}, the second software thread id register.  It is 64 bits in size
   49245 and has a type of @samp{data_ptr}.  It may be used in the future alongside
   49246 the Scalable Matrix Extension for a lazy restore scheme.
   49247 @end itemize
   49248 
   49249 If @value{GDBN} sees this feature, it will attempt to find one of the
   49250 variations of the register set.  If @samp{tpidr2} is available,
   49251 @value{GDBN} may act on it to display additional data in the future.
   49252 
   49253 There is no XML for this feature as the presence of @samp{tpidr2} is
   49254 determined dynamically at runtime.
   49255 
   49256 Extra registers are allowed in this feature, but they will not affect
   49257 @value{GDBN}.
   49258 
   49259 @subsubsection AArch64 MTE registers feature
   49260 
   49261 The @samp{org.gnu.gdb.aarch64.mte} optional feature was introduced so
   49262 @value{GDBN} could detect support for the Memory Tagging Extension and
   49263 control memory tagging settings.  If present, this feature must have the
   49264 following register:
   49265 
   49266 @itemize @minus
   49267 @item
   49268 @samp{tag_ctl}, the tag control register.  It is 64 bits in size and has a type
   49269 of @samp{uint64}.
   49270 @end itemize
   49271 
   49272 Memory Tagging detection is done via a runtime check though, so the presence
   49273 of this feature and register is not enough to enable memory tagging support.
   49274 
   49275 This restriction may be lifted in the future.
   49276 
   49277 Extra registers are allowed in this feature, but they will not affect
   49278 @value{GDBN}.
   49279 
   49280 @subsubsection AArch64 SME registers feature
   49281 
   49282 The @samp{org.gnu.gdb.aarch64.sme} feature is optional.  If present,
   49283 it should contain registers @code{ZA}, @code{SVG} and @code{SVCR}.
   49284 @xref{AArch64 SME}.
   49285 
   49286 @itemize @minus
   49287 
   49288 @item
   49289 @code{ZA} is a register represented by a vector of @var{svl}x@var{svl}
   49290 bytes.  @xref{svl}.
   49291 
   49292 @item
   49293 @code{SVG} is a 64-bit register containing the value of @var{svg}.  @xref{svg}.
   49294 
   49295 @item
   49296 @code{SVCR} is a 64-bit status pseudo-register with two valid bits.  Bit 0
   49297 (@sc{sm}) shows whether the streaming @acronym{SVE} mode is enabled or disabled.
   49298 Bit 1 (@sc{ZA}) shows whether the @code{ZA} register state is active (in use) or
   49299 not.
   49300 @xref{aarch64 sme svcr}.
   49301 
   49302 The rest of the unused bits of the @code{SVCR} pseudo-register is undefined
   49303 and reserved.  Such bits should not be used and may be defined by future
   49304 extensions of the architecture.
   49305 
   49306 @end itemize
   49307 
   49308 Extra registers are allowed in this feature, but they will not affect
   49309 @value{GDBN}.
   49310 
   49311 The @samp{org.gnu.gdb.aarch64.sme} feature is required when the target also
   49312 reports support for the @samp{org.gnu.gdb.aarch64.sme2} feature.
   49313 
   49314 @subsubsection AArch64 SME2 registers feature
   49315 
   49316 The @samp{org.gnu.gdb.aarch64.sme2} feature is optional.  If present,
   49317 then the @samp{org.gnu.gdb.aarch64.sme} feature must also be present.  The
   49318 @samp{org.gnu.gdb.aarch64.sme2} feature should contain the following:
   49319 @xref{AArch64 SME2}.
   49320 
   49321 @itemize @minus
   49322 
   49323 @item
   49324 @code{ZT0} is a register of 512 bits (64 bytes).  It is defined as a vector
   49325 of bytes.
   49326 
   49327 @end itemize
   49328 
   49329 Extra registers are allowed in this feature, but they will not affect
   49330 @value{GDBN}.
   49331 
   49332 @node ARC Features
   49333 @subsection ARC Features
   49334 @cindex target descriptions, ARC Features
   49335 
   49336 ARC processors are so configurable that even core registers and their numbers
   49337 are not predetermined completely.  Moreover, @emph{flags} and @emph{PC}
   49338 registers, which are important to @value{GDBN}, are not ``core'' registers in
   49339 ARC.  Therefore, there are two features that their presence is mandatory:
   49340 @samp{org.gnu.gdb.arc.core} and @samp{org.gnu.gdb.arc.aux}.
   49341 
   49342 The @samp{org.gnu.gdb.arc.core} feature is required for all targets.  It must
   49343 contain registers:
   49344 
   49345 @itemize @minus
   49346 @item
   49347 @samp{r0} through @samp{r25} for normal register file targets.
   49348 @item
   49349 @samp{r0} through @samp{r3}, and @samp{r10} through @samp{r15} for reduced
   49350 register file targets.
   49351 @item
   49352 @samp{gp}, @samp{fp}, @samp{sp}, @samp{r30}@footnote{Not necessary for ARCv1.},
   49353 @samp{blink}, @samp{lp_count}, @samp{pcl}.
   49354 @end itemize
   49355 
   49356 In case of an ARCompact target (ARCv1 ISA), the @samp{org.gnu.gdb.arc.core}
   49357 feature may contain registers @samp{ilink1} and @samp{ilink2}.  While in case
   49358 of ARC EM and ARC HS targets (ARCv2 ISA), register @samp{ilink} may be present.
   49359 The difference between ARCv1 and ARCv2 is the naming of registers @emph{29th}
   49360 and @emph{30th}.  They are called @samp{ilink1} and @samp{ilink2} for ARCv1 and
   49361 are optional.  For ARCv2, they are called @samp{ilink} and @samp{r30} and only
   49362 @samp{ilink} is optional.  The optionality of @samp{ilink*} registers is
   49363 because of their inaccessibility during user space debugging sessions.
   49364 
   49365 Extension core registers @samp{r32} through @samp{r59} are optional and their
   49366 existence depends on the configuration.  When debugging GNU/Linux applications,
   49367 i.e.@: user space debugging, these core registers are not available.
   49368 
   49369 The @samp{org.gnu.gdb.arc.aux} feature is required for all ARC targets.  Here
   49370 is the list of registers pertinent to this feature:
   49371 
   49372 @itemize @minus
   49373 @item
   49374 mandatory: @samp{pc} and @samp{status32}.
   49375 @item
   49376 optional: @samp{lp_start}, @samp{lp_end}, and @samp{bta}.
   49377 @end itemize
   49378 
   49379 @node ARM Features
   49380 @subsection ARM Features
   49381 @cindex target descriptions, ARM features
   49382 
   49383 @subsubsection Core register set for non-M-profile
   49384 
   49385 The @samp{org.gnu.gdb.arm.core} feature is required for non-M-profile
   49386 ARM targets. It must contain the following registers:
   49387 
   49388 @itemize @minus
   49389 @item
   49390 @samp{r0} through @samp{r12}.  The general purpose registers.  They are 32 bits
   49391 in size and have a type of @samp{uint32}.
   49392 @item
   49393 @samp{sp}, the stack pointer register, also known as @samp{r13}.  It is 32 bits
   49394 in size and has a type of @samp{data_ptr}.
   49395 @item
   49396 @samp{lr}, the link register.  It is 32 bits in size.
   49397 @item
   49398 @samp{pc}, the program counter register.  It is 32 bit in size and of type
   49399 @samp{code_ptr}.
   49400 @item
   49401 @samp{cpsr}, the current program status register containing all the status
   49402 bits.  It is 32 bits in size.  Historically this register was hardwired to
   49403 number 25, but debugging stubs that report XML do not need to use this number
   49404 anymore.
   49405 @end itemize
   49406 
   49407 Extra registers are allowed in this feature, but they will not affect
   49408 @value{GDBN}.
   49409 
   49410 @subsubsection Core register set for M-profile
   49411 
   49412 For M-profile targets (e.g.@: Cortex-M3), the @samp{org.gnu.gdb.arm.core}
   49413 feature is replaced by @samp{org.gnu.gdb.arm.m-profile}, and it is a required
   49414 feature.  It must contain the following registers:
   49415 
   49416 @itemize @minus
   49417 @item
   49418 @samp{r0} through @samp{r12}, the general purpose registers.  They have a size
   49419 of 32 bits and a type of @samp{uint32}.
   49420 @item
   49421 @samp{sp}, the stack pointer register, also known as @samp{r13}.  It has a size
   49422 of 32 bits and a type of @samp{data_ptr}.
   49423 @item
   49424 @samp{lr}, the link register.  It has a size of 32 bits.
   49425 @item
   49426 @samp{pc}, the program counter register.  It has a size of 32 bits and a type
   49427 of @samp{code_ptr}.
   49428 @item
   49429 @samp{xpsr}, the program status register containing all the status
   49430 bits.  It has a size of 32 bits.  Historically this register was hardwired to
   49431 number 25, but debugging stubs that report XML do not need to use this number
   49432 anymore.
   49433 @end itemize
   49434 
   49435 Upon seeing this feature, @value{GDBN} will acknowledge that it is dealing
   49436 with an M-profile target.  This means @value{GDBN} will use hooks and
   49437 configurations that are meaningful to M-profiles.
   49438 
   49439 Extra registers are allowed in this feature, but they will not affect
   49440 @value{GDBN}.
   49441 
   49442 @subsubsection FPA registers feature (obsolete)
   49443 
   49444 The @samp{org.gnu.gdb.arm.fpa} feature is obsolete and should not be
   49445 advertised by debugging stubs anymore.  It used to advertise registers for
   49446 the old FPA architecture that has long been discontinued in toolchains.
   49447 
   49448 It is kept in @value{GDBN} for backward compatibility purposes so older
   49449 debugging stubs that don't support XML target descriptions still work
   49450 correctly.  One such example is the KGDB debugging stub from
   49451 Linux or BSD kernels.
   49452 
   49453 The description below is for historical purposes only.  This feature
   49454 used to contain the following registers:
   49455 
   49456 @itemize @minus
   49457 @item
   49458 @samp{f0} through @samp{f8}.  The floating point registers.  They are 96 bits
   49459 in size and of type @samp{arm_fpa_ext}.  @samp{f0} is pinned to register
   49460 number 16.
   49461 @item
   49462 @samp{fps}, the status register.  It has a size of 32 bits.
   49463 @end itemize
   49464 
   49465 @subsubsection M-profile Vector Extension (MVE)
   49466 
   49467 Also known as Helium, the M-profile Vector Extension is advertised via the
   49468 optional @samp{org.gnu.gdb.arm.m-profile-mve} feature.
   49469 
   49470 It must contain the following:
   49471 
   49472 @itemize @minus
   49473 @item
   49474 @samp{vpr}, the vector predication status and control register.  It is 32 bits
   49475 in size and has a custom flags type.  The flags type is laid out in a way that
   49476 exposes the @samp{P0} field from bits 0 to 15, the @samp{MASK01} field from
   49477 bits 16 to 19 and the @samp{MASK23} field from bits 20 to 23.
   49478 
   49479 Bits 24 through 31 are reserved.
   49480 @end itemize
   49481 
   49482 When this feature is available, @value{GDBN} will synthesize the @samp{p0}
   49483 pseudo-register from @samp{vpr} contents.
   49484 
   49485 This feature must only be advertised if the target is M-profile.  Advertising
   49486 this feature for targets that are not M-profile may cause @value{GDBN} to
   49487 assume the target is M-profile when it isn't.
   49488 
   49489 If the @samp{org.gnu.gdb.arm.vfp} feature is available alongside the
   49490 @samp{org.gnu.gdb.arm.m-profile-mve} feature, @value{GDBN} will
   49491 synthesize the @samp{q} pseudo-registers from @samp{d} register
   49492 contents.
   49493 
   49494 Extra registers are allowed in this feature, but they will not affect
   49495 @value{GDBN}.
   49496 
   49497 @subsubsection XScale iwMMXt feature
   49498 
   49499 The XScale @samp{org.gnu.gdb.xscale.iwmmxt} feature is optional.  If present,
   49500 it must contain the following:
   49501 
   49502 @itemize @minus
   49503 @item
   49504 @samp{wR0} through @samp{wR15}, registers with size 64 bits and a custom type
   49505 @samp{iwmmxt_vec64i}.  @samp{iwmmxt_vec64i} is a union of four other
   49506 types: @samp{uint64}, a 2-element vector of @samp{uint32}, a 4-element
   49507 vector of @samp{uint16} and a 8-element vector of @samp{uint8}.
   49508 @item
   49509 @samp{wCGR0} through @samp{wCGR3}, registers with size 32 bits and
   49510 type @samp{int}.
   49511 @end itemize
   49512 
   49513 The following registers are optional:
   49514 
   49515 @itemize @minus
   49516 @item
   49517 @samp{wCID}, register with size of 32 bits and type @samp{int}.
   49518 @item
   49519 @samp{wCon}, register with size 32 bits and type @samp{int}.
   49520 @item
   49521 @samp{wCSSF}, register with size 32 bits and type @samp{int}.
   49522 @item
   49523 @samp{wCASF}, register with size 32 bit and type @samp{int}.
   49524 @end itemize
   49525 
   49526 This feature should only be reported if the target is XScale.
   49527 
   49528 Extra registers are allowed in this feature, but they will not affect
   49529 @value{GDBN}.
   49530 
   49531 @subsubsection Vector Floating-Point (VFP) feature
   49532 
   49533 The @samp{org.gnu.gdb.arm.vfp} feature is optional.  If present, it
   49534 should contain one of two possible sets of values depending on whether
   49535 VFP version 2 or VFP version 3 is in use.
   49536 
   49537 For VFP v2:
   49538 
   49539 @itemize @minus
   49540 @item
   49541 @samp{d0} through @samp{d15}.  The double-precision registers.  They are
   49542 64 bits in size and have type @samp{ieee_double}.
   49543 @item
   49544 @samp{fpscr}, the floating-point status and control register.  It has a size
   49545 of 32 bits and a type of @samp{int}.
   49546 @end itemize
   49547 
   49548 For VFP v3:
   49549 
   49550 @itemize @minus
   49551 @item
   49552 @samp{d0} through @samp{d31}.  The double-precision registers.  They are
   49553 64 bits in size and have type @samp{ieee_double}.
   49554 @item
   49555 @samp{fpscr}, the floating-point status and control register.  It has a size
   49556 of 32 bits and a type of @samp{int}.
   49557 @end itemize
   49558 
   49559 If this feature is available, @value{GDBN} will synthesize the
   49560 single-precision floating-point registers from halves of the double-precision
   49561 registers as pseudo-registers.
   49562 
   49563 Extra registers are allowed in this feature, but they will not affect
   49564 @value{GDBN}.
   49565 
   49566 @subsubsection NEON architecture feature
   49567 
   49568 The @samp{org.gnu.gdb.arm.neon} feature is optional.  It does not
   49569 need to contain registers; it instructs @value{GDBN} to display the
   49570 VFP double-precision registers as vectors and to synthesize the
   49571 quad-precision registers from pairs of double-precision registers.
   49572 If this feature is present, @samp{org.gnu.gdb.arm.vfp} must also
   49573 be present and include 32 double-precision registers.
   49574 
   49575 Extra registers are allowed in this feature, but they will not affect
   49576 @value{GDBN}.
   49577 
   49578 @subsubsection M-profile Pointer Authentication and Branch Target Identification feature
   49579 
   49580 The @samp{org.gnu.gdb.arm.m-profile-pacbti} feature is optional, and
   49581 acknowledges support for the ARMv8.1-m PACBTI extensions.
   49582 
   49583 This feature doesn't contain any required registers, and it only serves as a
   49584 hint to @value{GDBN} that the debugging stub supports the ARMv8.1-m PACBTI
   49585 extensions.
   49586 
   49587 When @value{GDBN} sees this feature, it will track return address signing
   49588 states and will decorate backtraces using the [PAC] marker, similar to
   49589 AArch64's PAC extension.
   49590 @xref{AArch64 PAC}.
   49591 
   49592 Extra registers are allowed in this feature, but they will not affect
   49593 @value{GDBN}.
   49594 
   49595 @subsubsection M-profile system registers feature
   49596 
   49597 The @samp{org.gnu.gdb.arm.m-system} optional feature was introduced as a way to
   49598 inform @value{GDBN} about additional system registers.
   49599 
   49600 At the moment this feature must contain the following:
   49601 
   49602 @itemize @minus
   49603 @item
   49604 @samp{msp}, the main stack pointer register.  It is 32 bits in size with
   49605 type @samp{data_ptr}.
   49606 @item
   49607 @samp{psp}, the process stack pointer register.  It is 32 bits in size with
   49608 type @samp{data_ptr}.
   49609 @end itemize
   49610 
   49611 This feature must only be advertised for M-profile targets.  When @value{GDBN}
   49612 sees this feature, it will attempt to track the values of @samp{msp} and
   49613 @samp{psp} across frames.
   49614 
   49615 Extra registers are allowed in this feature, but they will not affect
   49616 @value{GDBN}.
   49617 
   49618 @subsubsection M-profile Security Extensions feature
   49619 
   49620 The @samp{org.gnu.gdb.arm.secext} optional feature was introduced so
   49621 @value{GDBN} could better support the switching of stack pointers and
   49622 secure states in the Security Extensions.
   49623 
   49624 At the moment this feature must contain the following:
   49625 
   49626 @itemize @minus
   49627 @item
   49628 @samp{msp_ns}, the main stack pointer register (non-secure state).  It is
   49629 32 bits in size with type @samp{data_ptr}.
   49630 @item
   49631 @samp{psp_ns}, the process stack pointer register (non-secure state).  It is
   49632 32 bits in size with type @samp{data_ptr}.
   49633 @item
   49634 @samp{msp_s}, the main stack pointer register (secure state).  It is 32 bits
   49635 in size with type @samp{data_ptr}.
   49636 @item
   49637 @samp{psp_s}, the process stack pointer register (secure state).  It is 32 bits
   49638 in size with type @samp{data_ptr}.
   49639 @end itemize
   49640 
   49641 When @value{GDBN} sees this feature, it will attempt to track the values of
   49642 all 4 stack pointers across secure state transitions, potentially improving
   49643 unwinding when applications switch between security states.
   49644 
   49645 Extra registers are allowed in this feature, but they will not affect
   49646 @value{GDBN}.
   49647 
   49648 @subsubsection TLS registers feature
   49649 
   49650 The optional @samp{org.gnu.gdb.arm.tls} feature contains TLS registers.
   49651 
   49652 Currently it contains the following:
   49653 
   49654 @itemize @minus
   49655 @item
   49656 @samp{tpidruro}, the user read-only thread id register.  It is 32 bits in size
   49657 and has type @samp{data_ptr}.
   49658 @end itemize
   49659 
   49660 At the moment @value{GDBN} looks for this feature, but doesn't do anything
   49661 with it other than displaying it.
   49662 
   49663 Extra registers are allowed in this feature, but they will not affect
   49664 @value{GDBN}.
   49665 
   49666 @node i386 Features
   49667 @subsection i386 Features
   49668 @cindex target descriptions, i386 features
   49669 
   49670 The @samp{org.gnu.gdb.i386.core} feature is required for i386/amd64
   49671 targets.  It should describe the following registers:
   49672 
   49673 @itemize @minus
   49674 @item
   49675 @samp{eax} through @samp{edi} plus @samp{eip} for i386
   49676 @item
   49677 @samp{rax} through @samp{r15} plus @samp{rip} for amd64
   49678 @item
   49679 @samp{eflags}, @samp{cs}, @samp{ss}, @samp{ds}, @samp{es},
   49680 @samp{fs}, @samp{gs}
   49681 @item 
   49682 @samp{st0} through @samp{st7}
   49683 @item 
   49684 @samp{fctrl}, @samp{fstat}, @samp{ftag}, @samp{fiseg}, @samp{fioff},
   49685 @samp{foseg}, @samp{fooff} and @samp{fop}
   49686 @end itemize
   49687 
   49688 The register sets may be different, depending on the target.
   49689 
   49690 The @samp{org.gnu.gdb.i386.sse} feature is optional.  It should
   49691 describe registers:
   49692 
   49693 @itemize @minus
   49694 @item
   49695 @samp{xmm0} through @samp{xmm7} for i386
   49696 @item
   49697 @samp{xmm0} through @samp{xmm15} for amd64
   49698 @item 
   49699 @samp{mxcsr}
   49700 @end itemize
   49701 
   49702 The @samp{org.gnu.gdb.i386.avx} feature is optional and requires the
   49703 @samp{org.gnu.gdb.i386.sse} feature.  It should
   49704 describe the upper 128 bits of @sc{ymm} registers:
   49705 
   49706 @itemize @minus
   49707 @item
   49708 @samp{ymm0h} through @samp{ymm7h} for i386
   49709 @item
   49710 @samp{ymm0h} through @samp{ymm15h} for amd64
   49711 @end itemize
   49712 
   49713 The @samp{org.gnu.gdb.i386.linux} feature is optional.  It should
   49714 describe a single register, @samp{orig_eax}.
   49715 
   49716 The @samp{org.gnu.gdb.i386.segments} feature is optional.  It should
   49717 describe two system registers: @samp{fs_base} and @samp{gs_base}.
   49718 
   49719 The @samp{org.gnu.gdb.i386.avx512} feature is optional and requires the
   49720 @samp{org.gnu.gdb.i386.avx} feature.  It should
   49721 describe additional @sc{xmm} registers:
   49722 
   49723 @itemize @minus
   49724 @item
   49725 @samp{xmm16} through @samp{xmm31}, only valid for amd64.
   49726 @end itemize
   49727 
   49728 It should describe the upper 128 bits of additional @sc{ymm} registers:
   49729 
   49730 @itemize @minus
   49731 @item
   49732 @samp{ymm16h} through @samp{ymm31h}, only valid for amd64.
   49733 @end itemize
   49734 
   49735 It should
   49736 describe the upper 256 bits of @sc{zmm} registers:
   49737 
   49738 @itemize @minus
   49739 @item
   49740 @samp{zmm0h} through @samp{zmm7h} for i386.
   49741 @item
   49742 @samp{zmm0h} through @samp{zmm15h} for amd64.
   49743 @end itemize
   49744 
   49745 It should
   49746 describe the additional @sc{zmm} registers:
   49747 
   49748 @itemize @minus
   49749 @item
   49750 @samp{zmm16h} through @samp{zmm31h}, only valid for amd64.
   49751 @end itemize
   49752 
   49753 It should
   49754 describe the additional 64-bit @sc{k} registers:
   49755 
   49756 @itemize @minus
   49757 @item
   49758 @samp{k0} through @samp{k7}, valid for amd64 and i386.
   49759 @end itemize
   49760 
   49761 The @samp{org.gnu.gdb.i386.pkeys} feature is optional.  It should
   49762 describe a single register, @samp{pkru}.  It is a 32-bit register
   49763 valid for i386 and amd64.
   49764 
   49765 @node LoongArch Features
   49766 @subsection LoongArch Features
   49767 @cindex target descriptions, LoongArch Features
   49768 
   49769 The @samp{org.gnu.gdb.loongarch.base} feature is required for LoongArch
   49770 targets.  It should contain the registers @samp{r0} through @samp{r31},
   49771 @samp{pc}, and @samp{badv}.  Either the architectural names (@samp{r0},
   49772 @samp{r1}, etc) can be used, or the ABI names (@samp{zero}, @samp{ra}, etc).
   49773 
   49774 The @samp{org.gnu.gdb.loongarch.fpu} feature is optional.  If present,
   49775 it should contain registers @samp{f0} through @samp{f31}, @samp{fcc},
   49776 and @samp{fcsr}.
   49777 
   49778 @node MicroBlaze Features
   49779 @subsection MicroBlaze Features
   49780 @cindex target descriptions, MicroBlaze features
   49781 
   49782 The @samp{org.gnu.gdb.microblaze.core} feature is required for MicroBlaze
   49783 targets.  It should contain registers @samp{r0} through @samp{r31},
   49784 @samp{rpc}, @samp{rmsr}, @samp{rear}, @samp{resr}, @samp{rfsr}, @samp{rbtr},
   49785 @samp{rpvr}, @samp{rpvr1} through @samp{rpvr11}, @samp{redr}, @samp{rpid},
   49786 @samp{rzpr}, @samp{rtlbx}, @samp{rtlbsx}, @samp{rtlblo}, and @samp{rtlbhi}.
   49787 
   49788 The @samp{org.gnu.gdb.microblaze.stack-protect} feature is optional.
   49789 If present, it should contain registers @samp{rshr} and @samp{rslr}
   49790 
   49791 @node MIPS Features
   49792 @subsection @acronym{MIPS} Features
   49793 @cindex target descriptions, @acronym{MIPS} features
   49794 
   49795 The @samp{org.gnu.gdb.mips.cpu} feature is required for @acronym{MIPS} targets.
   49796 It should contain registers @samp{r0} through @samp{r31}, @samp{lo},
   49797 @samp{hi}, and @samp{pc}.  They may be 32-bit or 64-bit depending
   49798 on the target.
   49799 
   49800 The @samp{org.gnu.gdb.mips.cp0} feature is also required.  It should
   49801 contain at least the @samp{status}, @samp{badvaddr}, and @samp{cause}
   49802 registers.  They may be 32-bit or 64-bit depending on the target.
   49803 
   49804 The @samp{org.gnu.gdb.mips.fpu} feature is currently required, though
   49805 it may be optional in a future version of @value{GDBN}.  It should
   49806 contain registers @samp{f0} through @samp{f31}, @samp{fcsr}, and
   49807 @samp{fir}.  They may be 32-bit or 64-bit depending on the target.
   49808 
   49809 The @samp{org.gnu.gdb.mips.dsp} feature is optional.  It should
   49810 contain registers @samp{hi1} through @samp{hi3}, @samp{lo1} through
   49811 @samp{lo3}, and @samp{dspctl}.  The @samp{dspctl} register should
   49812 be 32-bit and the rest may be 32-bit or 64-bit depending on the target.
   49813 
   49814 The @samp{org.gnu.gdb.mips.linux} feature is optional.  It should
   49815 contain a single register, @samp{restart}, which is used by the
   49816 Linux kernel to control restartable syscalls.
   49817 
   49818 @node M68K Features
   49819 @subsection M68K Features
   49820 @cindex target descriptions, M68K features
   49821 
   49822 @table @code
   49823 @item @samp{org.gnu.gdb.m68k.core}
   49824 @itemx @samp{org.gnu.gdb.coldfire.core}
   49825 @itemx @samp{org.gnu.gdb.fido.core}
   49826 One of those features must be always present. 
   49827 The feature that is present determines which flavor of m68k is
   49828 used.  The feature that is present should contain registers
   49829 @samp{d0} through @samp{d7}, @samp{a0} through @samp{a5}, @samp{fp},
   49830 @samp{sp}, @samp{ps} and @samp{pc}.
   49831 
   49832 @item @samp{org.gnu.gdb.coldfire.fp}
   49833 This feature is optional.  If present, it should contain registers
   49834 @samp{fp0} through @samp{fp7}, @samp{fpcontrol}, @samp{fpstatus} and
   49835 @samp{fpiaddr}.
   49836 
   49837 Note that, despite the fact that this feature's name says
   49838 @samp{coldfire}, it is used to describe any floating point registers.
   49839 The size of the registers must match the main m68k flavor; so, for
   49840 example, if the primary feature is reported as @samp{coldfire}, then
   49841 64-bit floating point registers are required.
   49842 @end table
   49843 
   49844 @node NDS32 Features
   49845 @subsection NDS32 Features
   49846 @cindex target descriptions, NDS32 features
   49847 
   49848 The @samp{org.gnu.gdb.nds32.core} feature is required for NDS32
   49849 targets.  It should contain at least registers @samp{r0} through
   49850 @samp{r10}, @samp{r15}, @samp{fp}, @samp{gp}, @samp{lp}, @samp{sp},
   49851 and @samp{pc}.
   49852 
   49853 The @samp{org.gnu.gdb.nds32.fpu} feature is optional.  If present,
   49854 it should contain 64-bit double-precision floating-point registers
   49855 @samp{fd0} through @emph{fdN}, which should be @samp{fd3}, @samp{fd7},
   49856 @samp{fd15}, or @samp{fd31} based on the FPU configuration implemented.
   49857 
   49858 @emph{Note:} The first sixteen 64-bit double-precision floating-point
   49859 registers are overlapped with the thirty-two 32-bit single-precision
   49860 floating-point registers.  The 32-bit single-precision registers, if
   49861 not being listed explicitly, will be synthesized from halves of the
   49862 overlapping 64-bit double-precision registers.  Listing 32-bit
   49863 single-precision registers explicitly is deprecated, and the
   49864 support to it could be totally removed some day.
   49865 
   49866 @node OpenRISC 1000 Features
   49867 @subsection Openrisc 1000 Features
   49868 @cindex target descriptions, OpenRISC 1000 features
   49869 
   49870 The @samp{org.gnu.gdb.or1k.group0} feature is required for OpenRISC 1000
   49871 targets.  It should contain the 32 general purpose registers (@samp{r0}
   49872 through @samp{r31}), @samp{ppc}, @samp{npc} and @samp{sr}.
   49873 
   49874 @node PowerPC Features
   49875 @subsection PowerPC Features
   49876 @cindex target descriptions, PowerPC features
   49877 
   49878 The @samp{org.gnu.gdb.power.core} feature is required for PowerPC
   49879 targets.  It should contain registers @samp{r0} through @samp{r31},
   49880 @samp{pc}, @samp{msr}, @samp{cr}, @samp{lr}, @samp{ctr}, and
   49881 @samp{xer}.  They may be 32-bit or 64-bit depending on the target.
   49882 
   49883 The @samp{org.gnu.gdb.power.fpu} feature is optional.  It should
   49884 contain registers @samp{f0} through @samp{f31} and @samp{fpscr}.
   49885 
   49886 The @samp{org.gnu.gdb.power.altivec} feature is optional.  It should
   49887 contain registers @samp{vr0} through @samp{vr31}, @samp{vscr}, and
   49888 @samp{vrsave}.  @value{GDBN} will define pseudo-registers @samp{v0}
   49889 through @samp{v31} as aliases for the corresponding @samp{vrX}
   49890 registers.
   49891 
   49892 The @samp{org.gnu.gdb.power.vsx} feature is optional.  It should
   49893 contain registers @samp{vs0h} through @samp{vs31h}.  @value{GDBN} will
   49894 combine these registers with the floating point registers (@samp{f0}
   49895 through @samp{f31}) and the altivec registers (@samp{vr0} through
   49896 @samp{vr31}) to present the 128-bit wide registers @samp{vs0} through
   49897 @samp{vs63}, the set of vector-scalar registers for POWER7.
   49898 Therefore, this feature requires both @samp{org.gnu.gdb.power.fpu} and
   49899 @samp{org.gnu.gdb.power.altivec}.
   49900 
   49901 The @samp{org.gnu.gdb.power.spe} feature is optional.  It should
   49902 contain registers @samp{ev0h} through @samp{ev31h}, @samp{acc}, and
   49903 @samp{spefscr}.  SPE targets should provide 32-bit registers in
   49904 @samp{org.gnu.gdb.power.core} and provide the upper halves in
   49905 @samp{ev0h} through @samp{ev31h}.  @value{GDBN} will combine
   49906 these to present registers @samp{ev0} through @samp{ev31} to the
   49907 user.
   49908 
   49909 The @samp{org.gnu.gdb.power.ppr} feature is optional.  It should
   49910 contain the 64-bit register @samp{ppr}.
   49911 
   49912 The @samp{org.gnu.gdb.power.dscr} feature is optional.  It should
   49913 contain the 64-bit register @samp{dscr}.
   49914 
   49915 The @samp{org.gnu.gdb.power.tar} feature is optional.  It should
   49916 contain the 64-bit register @samp{tar}.
   49917 
   49918 The @samp{org.gnu.gdb.power.ebb} feature is optional.  It should
   49919 contain registers @samp{bescr}, @samp{ebbhr} and @samp{ebbrr}, all
   49920 64-bit wide.
   49921 
   49922 The @samp{org.gnu.gdb.power.linux.pmu} feature is optional.  It should
   49923 contain registers @samp{mmcr0}, @samp{mmcr2}, @samp{siar}, @samp{sdar}
   49924 and @samp{sier}, all 64-bit wide.  This is the subset of the isa 2.07
   49925 server PMU registers provided by @sc{gnu}/Linux.
   49926 
   49927 The @samp{org.gnu.gdb.power.htm.spr} feature is optional.  It should
   49928 contain registers @samp{tfhar}, @samp{texasr} and @samp{tfiar}, all
   49929 64-bit wide.
   49930 
   49931 The @samp{org.gnu.gdb.power.htm.core} feature is optional.  It should
   49932 contain the checkpointed general-purpose registers @samp{cr0} through
   49933 @samp{cr31}, as well as the checkpointed registers @samp{clr} and
   49934 @samp{cctr}.  These registers may all be either 32-bit or 64-bit
   49935 depending on the target.  It should also contain the checkpointed
   49936 registers @samp{ccr} and @samp{cxer}, which should both be 32-bit
   49937 wide.
   49938 
   49939 The @samp{org.gnu.gdb.power.htm.fpu} feature is optional.  It should
   49940 contain the checkpointed 64-bit floating-point registers @samp{cf0}
   49941 through @samp{cf31}, as well as the checkpointed 64-bit register
   49942 @samp{cfpscr}.
   49943 
   49944 The @samp{org.gnu.gdb.power.htm.altivec} feature is optional.  It
   49945 should contain the checkpointed altivec registers @samp{cvr0} through
   49946 @samp{cvr31}, all 128-bit wide.  It should also contain the
   49947 checkpointed registers @samp{cvscr} and @samp{cvrsave}, both 32-bit
   49948 wide.
   49949 
   49950 The @samp{org.gnu.gdb.power.htm.vsx} feature is optional.  It should
   49951 contain registers @samp{cvs0h} through @samp{cvs31h}.  @value{GDBN}
   49952 will combine these registers with the checkpointed floating point
   49953 registers (@samp{cf0} through @samp{cf31}) and the checkpointed
   49954 altivec registers (@samp{cvr0} through @samp{cvr31}) to present the
   49955 128-bit wide checkpointed vector-scalar registers @samp{cvs0} through
   49956 @samp{cvs63}.  Therefore, this feature requires both
   49957 @samp{org.gnu.gdb.power.htm.altivec} and
   49958 @samp{org.gnu.gdb.power.htm.fpu}.
   49959 
   49960 The @samp{org.gnu.gdb.power.htm.ppr} feature is optional.  It should
   49961 contain the 64-bit checkpointed register @samp{cppr}.
   49962 
   49963 The @samp{org.gnu.gdb.power.htm.dscr} feature is optional.  It should
   49964 contain the 64-bit checkpointed register @samp{cdscr}.
   49965 
   49966 The @samp{org.gnu.gdb.power.htm.tar} feature is optional.  It should
   49967 contain the 64-bit checkpointed register @samp{ctar}.
   49968 
   49969 
   49970 @node RISC-V Features
   49971 @subsection RISC-V Features
   49972 @cindex target descriptions, RISC-V Features
   49973 
   49974 The @samp{org.gnu.gdb.riscv.cpu} feature is required for RISC-V
   49975 targets.  It should contain the registers @samp{x0} through
   49976 @samp{x31}, and @samp{pc}.  Either the architectural names (@samp{x0},
   49977 @samp{x1}, etc) can be used, or the ABI names (@samp{zero}, @samp{ra},
   49978 etc).
   49979 
   49980 The @samp{org.gnu.gdb.riscv.fpu} feature is optional.  If present, it
   49981 should contain registers @samp{f0} through @samp{f31}, @samp{fflags},
   49982 @samp{frm}, and @samp{fcsr}.  As with the cpu feature, either the
   49983 architectural register names, or the ABI names can be used.
   49984 
   49985 The @samp{org.gnu.gdb.riscv.virtual} feature is optional.  If present,
   49986 it should contain registers that are not backed by real registers on
   49987 the target, but are instead virtual, where the register value is
   49988 derived from other target state.  In many ways these are like
   49989 @value{GDBN}s pseudo-registers, except implemented by the target.
   49990 Currently the only register expected in this set is the one byte
   49991 @samp{priv} register that contains the target's privilege level in the
   49992 least significant two bits.
   49993 
   49994 The @samp{org.gnu.gdb.riscv.csr} feature is optional.  If present, it
   49995 should contain all of the target's standard CSRs.  Standard CSRs are
   49996 those defined in the RISC-V specification documents.  There is some
   49997 overlap between this feature and the fpu feature; the @samp{fflags},
   49998 @samp{frm}, and @samp{fcsr} registers could be in either feature.  The
   49999 expectation is that these registers will be in the fpu feature if the
   50000 target has floating point hardware, but can be moved into the csr
   50001 feature if the target has the floating point control registers, but no
   50002 other floating point hardware.
   50003 
   50004 The @samp{org.gnu.gdb.riscv.vector} feature is optional.  If present,
   50005 it should contain registers @samp{v0} through @samp{v31}, all of which
   50006 must be the same size.
   50007 
   50008 @node RX Features
   50009 @subsection RX Features
   50010 @cindex target descriptions, RX Features
   50011 
   50012 The @samp{org.gnu.gdb.rx.core} feature is required for RX
   50013 targets.  It should contain the registers @samp{r0} through
   50014 @samp{r15}, @samp{usp}, @samp{isp}, @samp{psw}, @samp{pc}, @samp{intb},
   50015 @samp{bpsw}, @samp{bpc}, @samp{fintv}, @samp{fpsw}, and @samp{acc}.
   50016 
   50017 @node S/390 and System z Features
   50018 @subsection S/390 and System z Features
   50019 @cindex target descriptions, S/390 features
   50020 @cindex target descriptions, System z features
   50021 
   50022 The @samp{org.gnu.gdb.s390.core} feature is required for S/390 and
   50023 System z targets.  It should contain the PSW and the 16 general
   50024 registers.  In particular, System z targets should provide the 64-bit
   50025 registers @samp{pswm}, @samp{pswa}, and @samp{r0} through @samp{r15}.
   50026 S/390 targets should provide the 32-bit versions of these registers.
   50027 A System z target that runs in 31-bit addressing mode should provide
   50028 32-bit versions of @samp{pswm} and @samp{pswa}, as well as the general
   50029 register's upper halves @samp{r0h} through @samp{r15h}, and their
   50030 lower halves @samp{r0l} through @samp{r15l}.
   50031 
   50032 The @samp{org.gnu.gdb.s390.fpr} feature is required.  It should
   50033 contain the 64-bit registers @samp{f0} through @samp{f15}, and
   50034 @samp{fpc}.
   50035 
   50036 The @samp{org.gnu.gdb.s390.acr} feature is required.  It should
   50037 contain the 32-bit registers @samp{acr0} through @samp{acr15}.
   50038 
   50039 The @samp{org.gnu.gdb.s390.linux} feature is optional.  It should
   50040 contain the register @samp{orig_r2}, which is 64-bit wide on System z
   50041 targets and 32-bit otherwise.  In addition, the feature may contain
   50042 the @samp{last_break} register, whose width depends on the addressing
   50043 mode, as well as the @samp{system_call} register, which is always
   50044 32-bit wide.
   50045 
   50046 The @samp{org.gnu.gdb.s390.tdb} feature is optional.  It should
   50047 contain the 64-bit registers @samp{tdb0}, @samp{tac}, @samp{tct},
   50048 @samp{atia}, and @samp{tr0} through @samp{tr15}.
   50049 
   50050 The @samp{org.gnu.gdb.s390.vx} feature is optional.  It should contain
   50051 64-bit wide registers @samp{v0l} through @samp{v15l}, which will be
   50052 combined by @value{GDBN} with the floating point registers @samp{f0}
   50053 through @samp{f15} to present the 128-bit wide vector registers
   50054 @samp{v0} through @samp{v15}.  In addition, this feature should
   50055 contain the 128-bit wide vector registers @samp{v16} through
   50056 @samp{v31}.
   50057 
   50058 The @samp{org.gnu.gdb.s390.gs} feature is optional.  It should contain
   50059 the 64-bit wide guarded-storage-control registers @samp{gsd},
   50060 @samp{gssm}, and @samp{gsepla}.
   50061 
   50062 The @samp{org.gnu.gdb.s390.gsbc} feature is optional.  It should contain
   50063 the 64-bit wide guarded-storage broadcast control registers
   50064 @samp{bc_gsd}, @samp{bc_gssm}, and @samp{bc_gsepla}.
   50065 
   50066 @node Sparc Features
   50067 @subsection Sparc Features
   50068 @cindex target descriptions, sparc32 features
   50069 @cindex target descriptions, sparc64 features
   50070 The @samp{org.gnu.gdb.sparc.cpu} feature is required for sparc32/sparc64
   50071 targets.  It should describe the following registers:
   50072 
   50073 @itemize @minus
   50074 @item
   50075 @samp{g0} through @samp{g7}
   50076 @item
   50077 @samp{o0} through @samp{o7}
   50078 @item
   50079 @samp{l0} through @samp{l7}
   50080 @item
   50081 @samp{i0} through @samp{i7}
   50082 @end itemize
   50083 
   50084 They may be 32-bit or 64-bit depending on the target.
   50085 
   50086 Also the @samp{org.gnu.gdb.sparc.fpu} feature is required for sparc32/sparc64
   50087 targets.  It should describe the following registers:
   50088 
   50089 @itemize @minus
   50090 @item
   50091 @samp{f0} through @samp{f31}
   50092 @item
   50093 @samp{f32} through @samp{f62} for sparc64
   50094 @end itemize
   50095 
   50096 The @samp{org.gnu.gdb.sparc.cp0} feature is required for sparc32/sparc64
   50097 targets.  It should describe the following registers:
   50098 
   50099 @itemize @minus
   50100 @item
   50101 @samp{y}, @samp{psr}, @samp{wim}, @samp{tbr}, @samp{pc}, @samp{npc},
   50102 @samp{fsr}, and @samp{csr} for sparc32
   50103 @item
   50104 @samp{pc}, @samp{npc}, @samp{state}, @samp{fsr}, @samp{fprs}, and @samp{y}
   50105 for sparc64
   50106 @end itemize
   50107 
   50108 @node TIC6x Features
   50109 @subsection TMS320C6x Features
   50110 @cindex target descriptions, TIC6x features
   50111 @cindex target descriptions, TMS320C6x features
   50112 The @samp{org.gnu.gdb.tic6x.core} feature is required for TMS320C6x
   50113 targets.  It should contain registers @samp{A0} through @samp{A15},
   50114 registers @samp{B0} through @samp{B15}, @samp{CSR} and @samp{PC}.
   50115 
   50116 The @samp{org.gnu.gdb.tic6x.gp} feature is optional.  It should
   50117 contain registers @samp{A16} through @samp{A31} and @samp{B16}
   50118 through @samp{B31}.
   50119 
   50120 The @samp{org.gnu.gdb.tic6x.c6xp} feature is optional.  It should
   50121 contain registers @samp{TSR}, @samp{ILC} and @samp{RILC}.
   50122 
   50123 @node Operating System Information
   50124 @appendix Operating System Information
   50125 @cindex operating system information
   50126 
   50127 Users of @value{GDBN} often wish to obtain information about the state of
   50128 the operating system running on the target---for example the list of
   50129 processes, or the list of open files.  This section describes the
   50130 mechanism that makes it possible.  This mechanism is similar to the 
   50131 target features mechanism (@pxref{Target Descriptions}), but focuses
   50132 on a different aspect of target.
   50133 
   50134 Operating system information is retrieved from the target via the
   50135 remote protocol, using @samp{qXfer} requests (@pxref{qXfer osdata
   50136 read}).  The object name in the request should be @samp{osdata}, and
   50137 the @var{annex} identifies the data to be fetched.
   50138 
   50139 @menu
   50140 * Process list::
   50141 @end menu
   50142 
   50143 @node Process list
   50144 @appendixsection Process list
   50145 @cindex operating system information, process list
   50146 
   50147 When requesting the process list, the @var{annex} field in the
   50148 @samp{qXfer} request should be @samp{processes}.  The returned data is
   50149 an XML document.  The formal syntax of this document is defined in
   50150 @file{gdb/features/osdata.dtd}.
   50151 
   50152 An example document is:
   50153 
   50154 @smallexample
   50155 <?xml version="1.0"?>
   50156 <!DOCTYPE target SYSTEM "osdata.dtd">
   50157 <osdata type="processes">
   50158   <item>
   50159     <column name="pid">1</column>
   50160     <column name="user">root</column>
   50161     <column name="command">/sbin/init</column>
   50162     <column name="cores">1,2,3</column>
   50163   </item>
   50164 </osdata>
   50165 @end smallexample
   50166 
   50167 Each item should include a column whose name is @samp{pid}.  The value
   50168 of that column should identify the process on the target.  The
   50169 @samp{user} and @samp{command} columns are optional, and will be
   50170 displayed by @value{GDBN}.  The @samp{cores} column, if present,
   50171 should contain a comma-separated list of cores that this process
   50172 is running on.  Target may provide additional columns,
   50173 which @value{GDBN} currently ignores.
   50174 
   50175 @node Trace File Format
   50176 @appendix Trace File Format
   50177 @cindex trace file format
   50178 
   50179 The trace file comes in three parts: a header, a textual description
   50180 section, and a trace frame section with binary data.
   50181 
   50182 The header has the form @code{\x7fTRACE0\n}.  The first byte is
   50183 @code{0x7f} so as to indicate that the file contains binary data,
   50184 while the @code{0} is a version number that may have different values
   50185 in the future.
   50186 
   50187 The description section consists of multiple lines of @sc{ascii} text
   50188 separated by newline characters (@code{0xa}).  The lines may include a
   50189 variety of optional descriptive or context-setting information, such
   50190 as tracepoint definitions or register set size.  @value{GDBN} will
   50191 ignore any line that it does not recognize.  An empty line marks the end
   50192 of this section.
   50193 
   50194 @table @code
   50195 @item R @var{size}
   50196 Specifies the size of a register block in bytes.  This is equal to the
   50197 size of a @code{g} packet payload in the remote protocol.  @var{size}
   50198 is an ascii decimal number.  There should be only one such line in
   50199 a single trace file.
   50200 
   50201 @item status @var{status}
   50202 Trace status.  @var{status} has the same format as a @code{qTStatus}
   50203 remote packet reply.  There should be only one such line in a single trace
   50204 file.
   50205 
   50206 @item tp @var{payload}
   50207 Tracepoint definition.  The @var{payload} has the same format as
   50208 @code{qTfP}/@code{qTsP} remote packet reply payload.  A single tracepoint
   50209 may take multiple lines of definition, corresponding to the multiple
   50210 reply packets.
   50211 
   50212 @item tsv @var{payload}
   50213 Trace state variable definition.  The @var{payload} has the same format as
   50214 @code{qTfV}/@code{qTsV} remote packet reply payload.  A single variable
   50215 may take multiple lines of definition, corresponding to the multiple
   50216 reply packets.
   50217 
   50218 @item tdesc @var{payload}
   50219 Target description in XML format.  The @var{payload} is a single line of
   50220 the XML file.  All such lines should be concatenated together to get
   50221 the original XML file.  This file is in the same format as @code{qXfer}
   50222 @code{features} payload, and corresponds to the main @code{target.xml}
   50223 file.  Includes are not allowed.
   50224 
   50225 @end table
   50226 
   50227 The trace frame section consists of a number of consecutive frames.
   50228 Each frame begins with a two-byte tracepoint number, followed by a
   50229 four-byte size giving the amount of data in the frame.  The data in
   50230 the frame consists of a number of blocks, each introduced by a
   50231 character indicating its type (at least register, memory, and trace
   50232 state variable).  The data in this section is raw binary, not a
   50233 hexadecimal or other encoding; its endianness matches the target's
   50234 endianness.
   50235 
   50236 @c FIXME bi-arch may require endianness/arch info in description section
   50237 
   50238 @table @code
   50239 @item R @var{bytes}
   50240 Register block.  The number and ordering of bytes matches that of a
   50241 @code{g} packet in the remote protocol.  Note that these are the
   50242 actual bytes, in target order, not a hexadecimal encoding.
   50243 
   50244 @item M @var{address} @var{length} @var{bytes}...
   50245 Memory block.  This is a contiguous block of memory, at the 8-byte
   50246 address @var{address}, with a 2-byte length @var{length}, followed by
   50247 @var{length} bytes.
   50248 
   50249 @item V @var{number} @var{value}
   50250 Trace state variable block.  This records the 8-byte signed value
   50251 @var{value} of trace state variable numbered @var{number}.
   50252 
   50253 @end table
   50254 
   50255 Future enhancements of the trace file format may include additional types
   50256 of blocks.
   50257 
   50258 @node Index Section Format
   50259 @appendix @code{.gdb_index} section format
   50260 @cindex .gdb_index section format
   50261 @cindex index section format
   50262 
   50263 This section documents the index section that is created by @code{save
   50264 gdb-index} (@pxref{Index Files}).  The index section is
   50265 DWARF-specific; some knowledge of DWARF is assumed in this
   50266 description.
   50267 
   50268 The mapped index file format is designed to be directly
   50269 @code{mmap}able on any architecture.  In most cases, a datum is
   50270 represented using a little-endian 32-bit integer value, called an
   50271 @code{offset_type}.  Big endian machines must byte-swap the values
   50272 before using them.  Exceptions to this rule are noted.  The data is
   50273 laid out such that alignment is always respected.
   50274 
   50275 A mapped index consists of several areas, laid out in order.
   50276 
   50277 @enumerate
   50278 @item
   50279 The file header.  This is a sequence of values, of @code{offset_type}
   50280 unless otherwise noted:
   50281 
   50282 @enumerate
   50283 @item
   50284 The version number, currently 9.  Versions 1, 2 and 3 are obsolete.
   50285 Version 4 uses a different hashing function from versions 5 and 6.
   50286 Version 6 includes symbols for inlined functions, whereas versions 4
   50287 and 5 do not.  Version 7 adds attributes to the CU indices in the
   50288 symbol table.  Version 8 specifies that symbols from DWARF type units
   50289 (@samp{DW_TAG_type_unit}) refer to the type unit's symbol table and not the
   50290 compilation unit (@samp{DW_TAG_comp_unit}) using the type.  Version 9 adds
   50291 the name and the language of the main function to the index.
   50292 
   50293 @value{GDBN} will only read version 4, 5, or 6 indices
   50294 by specifying @code{set use-deprecated-index-sections on}.
   50295 GDB has a workaround for potentially broken version 7 indices so it is
   50296 currently not flagged as deprecated.
   50297 
   50298 @item
   50299 The offset, from the start of the file, of the CU list.
   50300 
   50301 @item
   50302 The offset, from the start of the file, of the types CU list.  Note
   50303 that this area can be empty, in which case this offset will be equal
   50304 to the next offset.
   50305 
   50306 @item
   50307 The offset, from the start of the file, of the address area.
   50308 
   50309 @item
   50310 The offset, from the start of the file, of the symbol table.
   50311 
   50312 @item
   50313 The offset, from the start of the file, of the shortcut table.
   50314 
   50315 @item
   50316 The offset, from the start of the file, of the constant pool.
   50317 @end enumerate
   50318 
   50319 @item
   50320 The CU list.  This is a sequence of pairs of 64-bit little-endian
   50321 values, sorted by the CU offset.  The first element in each pair is
   50322 the offset of a CU in the @code{.debug_info} section.  The second
   50323 element in each pair is the length of that CU.  References to a CU
   50324 elsewhere in the map are done using a CU index, which is just the
   50325 0-based index into this table.  Note that if there are type CUs, then
   50326 conceptually CUs and type CUs form a single list for the purposes of
   50327 CU indices.
   50328 
   50329 @item
   50330 The types CU list.  This is a sequence of triplets of 64-bit
   50331 little-endian values.  In a triplet, the first value is the CU offset,
   50332 the second value is the type offset in the CU, and the third value is
   50333 the type signature.  The types CU list is not sorted.
   50334 
   50335 @item
   50336 The address area.  The address area consists of a sequence of address
   50337 entries.  Each address entry has three elements:
   50338 
   50339 @enumerate
   50340 @item
   50341 The low address.  This is a 64-bit little-endian value.
   50342 
   50343 @item
   50344 The high address.  This is a 64-bit little-endian value.  Like
   50345 @code{DW_AT_high_pc}, the value is one byte beyond the end.
   50346 
   50347 @item
   50348 The CU index.  This is an @code{offset_type} value.
   50349 @end enumerate
   50350 
   50351 @item
   50352 The symbol table.  This is an open-addressed hash table.  The size of
   50353 the hash table is always a power of 2.
   50354 
   50355 Each slot in the hash table consists of a pair of @code{offset_type}
   50356 values.  The first value is the offset of the symbol's name in the
   50357 constant pool.  The second value is the offset of the CU vector in the
   50358 constant pool.
   50359 
   50360 If both values are 0, then this slot in the hash table is empty.  This
   50361 is ok because while 0 is a valid constant pool index, it cannot be a
   50362 valid index for both a string and a CU vector.
   50363 
   50364 The hash value for a table entry is computed by applying an
   50365 iterative hash function to the symbol's name.  Starting with an
   50366 initial value of @code{r = 0}, each (unsigned) character @samp{c} in
   50367 the string is incorporated into the hash using the formula depending on the
   50368 index version:
   50369 
   50370 @table @asis
   50371 @item Version 4
   50372 The formula is @code{r = r * 67 + c - 113}.
   50373 
   50374 @item Versions 5 to 7
   50375 The formula is @code{r = r * 67 + tolower (c) - 113}.
   50376 @end table
   50377 
   50378 The terminating @samp{\0} is not incorporated into the hash.
   50379 
   50380 The step size used in the hash table is computed via
   50381 @code{((hash * 17) & (size - 1)) | 1}, where @samp{hash} is the hash
   50382 value, and @samp{size} is the size of the hash table.  The step size
   50383 is used to find the next candidate slot when handling a hash
   50384 collision.
   50385 
   50386 The names of C@t{++} symbols in the hash table are canonicalized.  We
   50387 don't currently have a simple description of the canonicalization
   50388 algorithm; if you intend to create new index sections, you must read
   50389 the code.
   50390 
   50391 @item The shortcut table
   50392 This is a data structure with the following fields:
   50393 
   50394 @table @asis
   50395 @item Language of main
   50396 An @code{offset_type} value indicating the language of the main function as a
   50397 @code{DW_LANG_} constant.  This value will be zero if main function information
   50398 is not present.
   50399 
   50400 @item Name of main
   50401 An @code{offset_type} value indicating the offset of the main function's name
   50402 in the constant pool.  This value must be ignored if the value for the language
   50403 of main is zero.
   50404 @end table
   50405 
   50406 @item
   50407 The constant pool.  This is simply a bunch of bytes.  It is organized
   50408 so that alignment is correct: CU vectors are stored first, followed by
   50409 strings.
   50410 
   50411 A CU vector in the constant pool is a sequence of @code{offset_type}
   50412 values.  The first value is the number of CU indices in the vector.
   50413 Each subsequent value is the index and symbol attributes of a CU in
   50414 the CU list.  This element in the hash table is used to indicate which
   50415 CUs define the symbol and how the symbol is used.
   50416 See below for the format of each CU index+attributes entry.
   50417 
   50418 A string in the constant pool is zero-terminated.
   50419 @end enumerate
   50420 
   50421 Attributes were added to CU index values in @code{.gdb_index} version 7.
   50422 If a symbol has multiple uses within a CU then there is one
   50423 CU index+attributes value for each use.
   50424 
   50425 The format of each CU index+attributes entry is as follows
   50426 (bit 0 = LSB):
   50427 
   50428 @table @asis
   50429 
   50430 @item Bits 0-23
   50431 This is the index of the CU in the CU list.
   50432 @item Bits 24-27
   50433 These bits are reserved for future purposes and must be zero.
   50434 @item Bits 28-30
   50435 The kind of the symbol in the CU.
   50436 
   50437 @table @asis
   50438 @item 0
   50439 This value is reserved and should not be used.
   50440 By reserving zero the full @code{offset_type} value is backwards compatible
   50441 with previous versions of the index.
   50442 @item 1
   50443 The symbol is a type.
   50444 @item 2
   50445 The symbol is a variable or an enum value.
   50446 @item 3
   50447 The symbol is a function.
   50448 @item 4
   50449 Any other kind of symbol.
   50450 @item 5,6,7
   50451 These values are reserved.
   50452 @end table
   50453 
   50454 @item Bit 31
   50455 This bit is zero if the value is global and one if it is static.
   50456 
   50457 The determination of whether a symbol is global or static is complicated.
   50458 The authoritative reference is the file @file{dwarf2read.c} in
   50459 @value{GDBN} sources.
   50460 
   50461 @end table
   50462 
   50463 This pseudo-code describes the computation of a symbol's kind and
   50464 global/static attributes in the index.
   50465 
   50466 @smallexample
   50467 is_external = get_attribute (die, DW_AT_external);
   50468 language = get_attribute (cu_die, DW_AT_language);
   50469 switch (die->tag)
   50470   @{
   50471   case DW_TAG_typedef:
   50472   case DW_TAG_base_type:
   50473   case DW_TAG_subrange_type:
   50474     kind = TYPE;
   50475     is_static = 1;
   50476     break;
   50477   case DW_TAG_enumerator:
   50478     kind = VARIABLE;
   50479     is_static = language != CPLUS;
   50480     break;
   50481   case DW_TAG_subprogram:
   50482     kind = FUNCTION;
   50483     is_static = ! (is_external || language == ADA);
   50484     break;
   50485   case DW_TAG_constant:
   50486     kind = VARIABLE;
   50487     is_static = ! is_external;
   50488     break;
   50489   case DW_TAG_variable:
   50490     kind = VARIABLE;
   50491     is_static = ! is_external;
   50492     break;
   50493   case DW_TAG_namespace:
   50494     kind = TYPE;
   50495     is_static = 0;
   50496     break;
   50497   case DW_TAG_class_type:
   50498   case DW_TAG_interface_type:
   50499   case DW_TAG_structure_type:
   50500   case DW_TAG_union_type:
   50501   case DW_TAG_enumeration_type:
   50502     kind = TYPE;
   50503     is_static = language != CPLUS;
   50504     break;
   50505   default:
   50506     assert (0);
   50507   @}
   50508 @end smallexample
   50509 
   50510 @node Debuginfod
   50511 @appendix Download debugging resources with Debuginfod
   50512 @cindex debuginfod
   50513 
   50514 @code{debuginfod} is an HTTP server for distributing ELF, DWARF and source
   50515 files.
   50516 
   50517 With the @code{debuginfod} client library, @file{libdebuginfod}, @value{GDBN}
   50518 can query servers using the build IDs associated with missing debug info,
   50519 executables and source files in order to download them on demand.
   50520 
   50521 For instructions on building @value{GDBN} with @file{libdebuginfod},
   50522 @pxref{Configure Options,,--with-debuginfod}.  @code{debuginfod} is packaged
   50523 with @code{elfutils}, starting with version 0.178.  See
   50524 @uref{https://sourceware.org/elfutils/Debuginfod.html} for more information
   50525 regarding @code{debuginfod}.
   50526 
   50527 @menu
   50528 * Debuginfod Settings::         Configuring debuginfod with @value{GDBN}
   50529 @end menu
   50530 
   50531 @node Debuginfod Settings
   50532 @section Debuginfod Settings
   50533 
   50534 @value{GDBN} provides the following commands for configuring @code{debuginfod}.
   50535 
   50536 @table @code
   50537 @kindex set debuginfod enabled
   50538 @anchor{set debuginfod enabled}
   50539 @item set debuginfod enabled
   50540 @itemx set debuginfod enabled on
   50541 @cindex enable debuginfod
   50542 @value{GDBN} may query @code{debuginfod} servers for missing debug info and
   50543 source files.  @value{GDBN} may also download individual ELF/DWARF sections
   50544 such as @code{.gdb_index} to help reduce the total amount of data downloaded
   50545 from @code{debuginfod} servers; this can be controlled by @w{@code{maint
   50546 set debuginfod download-sections}} (@pxref{Maintenance Commands, maint set
   50547 debuginfod download-sections}).
   50548 
   50549 @item set debuginfod enabled off
   50550 @value{GDBN} will not attempt to query @code{debuginfod} servers when missing
   50551 debug info or source files.  By default, @code{debuginfod enabled} is set to
   50552 @code{off} for non-interactive sessions.
   50553 
   50554 @item set debuginfod enabled ask
   50555 @value{GDBN} will prompt the user to enable or disable @code{debuginfod} before
   50556 attempting to perform the next query.  By default, @code{debuginfod enabled}
   50557 is set to @code{ask} for interactive sessions.
   50558 
   50559 @kindex show debuginfod enabled
   50560 @item show debuginfod enabled
   50561 Display whether @code{debuginfod enabled} is set to @code{on}, @code{off} or
   50562 @code{ask}.
   50563 
   50564 @kindex set debuginfod urls
   50565 @cindex configure debuginfod URLs
   50566 @item set debuginfod urls
   50567 @itemx set debuginfod urls @var{urls}
   50568 Set the space-separated list of URLs that @code{debuginfod} will attempt to
   50569 query.  Only @code{http://}, @code{https://} and @code{file://} protocols
   50570 should be used.  The default value of @code{debuginfod urls} is copied from
   50571 the @var{DEBUGINFOD_URLS} environment variable.
   50572 
   50573 @kindex show debuginfod urls
   50574 @item show debuginfod urls
   50575 Display the list of URLs that @code{debuginfod} will attempt to query.
   50576 
   50577 @kindex set debuginfod verbose
   50578 @cindex debuginfod verbosity
   50579 @item set debuginfod verbose
   50580 @itemx set debuginfod verbose @var{n}
   50581 Enable or disable @code{debuginfod}-related output.  Use a non-zero value
   50582 to enable and @code{0} to disable.  @code{debuginfod} output is shown by
   50583 default.
   50584 
   50585 @kindex show debuginfod verbose
   50586 @item show debuginfod verbose
   50587 Show the current verbosity setting.
   50588 
   50589 @end table
   50590 
   50591 @node Man Pages
   50592 @appendix Manual pages
   50593 @cindex Man pages
   50594 
   50595 @menu
   50596 * gdb man::                     The GNU Debugger man page
   50597 * gdbserver man::               Remote Server for the GNU Debugger man page
   50598 * gcore man::                   Generate a core file of a running program
   50599 * gstack man::                  Print a stack trace of a running program
   50600 * gdbinit man::                 gdbinit scripts
   50601 * gdb-add-index man::           Add index files to speed up GDB
   50602 @end menu
   50603 
   50604 @node gdb man
   50605 @heading gdb man
   50606 
   50607 @c man title gdb The GNU Debugger
   50608 
   50609 @c man begin SYNOPSIS gdb
   50610 gdb [OPTIONS] [@var{prog}|@var{prog} @var{procID}|@var{prog} @var{core}]
   50611 @c man end
   50612 
   50613 @c man begin DESCRIPTION gdb
   50614 The purpose of a debugger such as @value{GDBN} is to allow you to see what is
   50615 going on ``inside'' another program while it executes -- or what another
   50616 program was doing at the moment it crashed.
   50617 
   50618 @value{GDBN} can do four main kinds of things (plus other things in support of
   50619 these) to help you catch bugs in the act:
   50620 
   50621 @itemize @bullet
   50622 @item
   50623 Start your program, specifying anything that might affect its behavior.
   50624 
   50625 @item
   50626 Make your program stop on specified conditions.
   50627 
   50628 @item
   50629 Examine what has happened, when your program has stopped.
   50630 
   50631 @item
   50632 Change things in your program, so you can experiment with correcting the
   50633 effects of one bug and go on to learn about another.
   50634 @end itemize
   50635 
   50636 You can use @value{GDBN} to debug programs written in C, C@t{++}, Fortran and
   50637 Modula-2.
   50638 
   50639 @value{GDBN} is invoked with the shell command @code{gdb}.  Once started, it reads
   50640 commands from the terminal until you tell it to exit with the @value{GDBN}
   50641 command @code{quit} or @code{exit}.  You can get online help from @value{GDBN} itself
   50642 by using the command @code{help}.
   50643 
   50644 You can run @code{gdb} with no arguments or options; but the most
   50645 usual way to start @value{GDBN} is with one argument or two, specifying an
   50646 executable program as the argument:
   50647 
   50648 @smallexample
   50649 gdb program
   50650 @end smallexample
   50651 
   50652 You can also start with both an executable program and a core file specified:
   50653 
   50654 @smallexample
   50655 gdb program core
   50656 @end smallexample
   50657 
   50658 You can, instead, specify a process ID as a second argument or use option
   50659 @code{-p}, if you want to debug a running process:
   50660 
   50661 @smallexample
   50662 gdb program 1234
   50663 gdb -p 1234
   50664 @end smallexample
   50665 
   50666 @noindent
   50667 would attach @value{GDBN} to process @code{1234}.  With option @option{-p} you
   50668 can omit the @var{program} filename.
   50669 
   50670 Here are some of the most frequently needed @value{GDBN} commands:
   50671 
   50672 @c pod2man highlights the right hand side of the @item lines.
   50673 @table @env
   50674 @item break [@var{file}:][@var{function}|@var{line}]
   50675 Set a breakpoint at @var{function} or @var{line} (in @var{file}).
   50676 
   50677 @item run [@var{arglist}]
   50678 Start your program (with @var{arglist}, if specified).
   50679 
   50680 @item bt
   50681 Backtrace: display the program stack.
   50682 
   50683 @item print @var{expr}
   50684 Display the value of an expression.
   50685 
   50686 @item c
   50687 Continue running your program (after stopping, e.g.@: at a breakpoint).
   50688 
   50689 @item next
   50690 Execute next program line (after stopping); step @emph{over} any
   50691 function calls in the line.
   50692 
   50693 @item edit [@var{file}:]@var{function}
   50694 look at the program line where it is presently stopped.
   50695 
   50696 @item list [@var{file}:]@var{function}
   50697 type the text of the program in the vicinity of where it is presently stopped.
   50698 
   50699 @item step
   50700 Execute next program line (after stopping); step @emph{into} any
   50701 function calls in the line.
   50702 
   50703 @item help [@var{name}]
   50704 Show information about @value{GDBN} command @var{name}, or general information
   50705 about using @value{GDBN}.
   50706 
   50707 @item quit
   50708 @itemx exit
   50709 Exit from @value{GDBN}.
   50710 @end table
   50711 
   50712 @ifset man
   50713 For full details on @value{GDBN},
   50714 see @cite{Using GDB: A Guide to the GNU Source-Level Debugger},
   50715 by Richard M. Stallman and Roland H. Pesch.  The same text is available online
   50716 as the @code{gdb} entry in the @code{info} program.
   50717 @end ifset
   50718 @c man end
   50719 
   50720 @c man begin OPTIONS gdb
   50721 Any arguments other than options specify an executable
   50722 file and core file (or process ID); that is, the first argument
   50723 encountered with no
   50724 associated option flag is equivalent to a @option{--se} option, and the second,
   50725 if any, is equivalent to a @option{-c} option if it's the name of a file.
   50726 Many options have
   50727 both long and abbreviated forms; both are shown here.  The long forms are also
   50728 recognized if you truncate them, so long as enough of the option is
   50729 present to be unambiguous.
   50730 
   50731 The abbreviated forms are shown here with @samp{-} and long forms are shown
   50732 with @samp{--} to reflect how they are shown in @option{--help}. However,
   50733 @value{GDBN} recognizes all of the following conventions for most options:
   50734 
   50735 @table @code
   50736 @item --option=@var{value}
   50737 @item --option @var{value}
   50738 @item -option=@var{value}
   50739 @item -option @var{value}
   50740 @item --o=@var{value}
   50741 @item --o @var{value}
   50742 @item -o=@var{value}
   50743 @item -o @var{value}
   50744 @end table
   50745 
   50746 All the options and command line arguments you give are processed
   50747 in sequential order.  The order makes a difference when the @option{-x}
   50748 option is used.
   50749 
   50750 @table @env
   50751 @item --help
   50752 @itemx -h
   50753 List all options, with brief explanations.
   50754 
   50755 @item --symbols=@var{file}
   50756 @itemx -s @var{file}
   50757 Read symbol table from @var{file}.
   50758 
   50759 @item --write
   50760 Enable writing into executable and core files.
   50761 
   50762 @item --exec=@var{file}
   50763 @itemx -e @var{file}
   50764 Use @var{file} as the executable file to execute when
   50765 appropriate, and for examining pure data in conjunction with a core
   50766 dump.
   50767 
   50768 @item --se=@var{file}
   50769 Read symbol table from @var{file} and use it as the executable
   50770 file.
   50771 
   50772 @item --core=@var{file}
   50773 @itemx -c @var{file}
   50774 Use @var{file} as a core dump to examine.
   50775 
   50776 @item --command=@var{file}
   50777 @itemx -x @var{file}
   50778 Execute @value{GDBN} commands from @var{file}.
   50779 
   50780 @item --eval-command=@var{command}
   50781 @item -ex @var{command}
   50782 Execute given @value{GDBN} @var{command}.
   50783 
   50784 @item --init-eval-command=@var{command}
   50785 @item -iex
   50786 Execute @value{GDBN} @var{command} before loading the inferior.
   50787 
   50788 @item --directory=@var{directory}
   50789 @itemx -d @var{directory}
   50790 Add @var{directory} to the path to search for source files.
   50791 
   50792 @item --nh
   50793 Do not execute commands from @file{~/.config/gdb/gdbinit},
   50794 @file{~/.gdbinit}, @file{~/.config/gdb/gdbearlyinit}, or
   50795 @file{~/.gdbearlyinit}
   50796 
   50797 @item --nx
   50798 @itemx -n
   50799 Do not execute commands from any @file{.gdbinit} or
   50800 @file{.gdbearlyinit} initialization files.
   50801 
   50802 @item --quiet
   50803 @item --silent
   50804 @itemx -q
   50805 ``Quiet''.  Do not print the introductory and copyright messages.  These
   50806 messages are also suppressed in batch mode.
   50807 
   50808 @item --batch
   50809 Run in batch mode.  Exit with status @code{0} after processing all the command
   50810 files specified with @option{-x} (and @file{.gdbinit}, if not inhibited).
   50811 Exit with nonzero status if an error occurs in executing the @value{GDBN}
   50812 commands in the command files.
   50813 
   50814 Batch mode may be useful for running @value{GDBN} as a filter, for example to
   50815 download and run a program on another computer; in order to make this
   50816 more useful, the message
   50817 
   50818 @smallexample
   50819 Program exited normally.
   50820 @end smallexample
   50821 
   50822 @noindent
   50823 (which is ordinarily issued whenever a program running under @value{GDBN} control
   50824 terminates) is not issued when running in batch mode.
   50825 
   50826 @item --batch-silent
   50827 Run in batch mode, just like @option{--batch}, but totally silent.  All @value{GDBN}
   50828 output is suppressed (stderr is unaffected).  This is much quieter than
   50829 @option{--silent} and would be useless for an interactive session.
   50830 
   50831 This is particularly useful when using targets that give @samp{Loading section}
   50832 messages, for example.
   50833 
   50834 Note that targets that give their output via @value{GDBN}, as opposed to writing
   50835 directly to @code{stdout}, will also be made silent.
   50836 
   50837 @item --args @var{prog} [@var{arglist}]
   50838 Change interpretation of command line so that arguments following this
   50839 option are passed as arguments to the inferior.  As an example, take
   50840 the following command:
   50841 
   50842 @smallexample
   50843 gdb ./a.out -q
   50844 @end smallexample
   50845 
   50846 @noindent
   50847 It would start @value{GDBN} with @option{-q}, not printing the introductory message.  On
   50848 the other hand, using:
   50849 
   50850 @smallexample
   50851 gdb --args ./a.out -q
   50852 @end smallexample
   50853 
   50854 @noindent
   50855 starts @value{GDBN} with the introductory message, and passes the option to the inferior.
   50856 
   50857 @item --pid=@var{pid}
   50858 Attach @value{GDBN} to an already running program, with the PID @var{pid}.
   50859 
   50860 @item --tui
   50861 Open the terminal user interface.
   50862 
   50863 @item --readnow
   50864 Read all symbols from the given symfile on the first access.
   50865 
   50866 @item --readnever
   50867 Do not read symbol files.
   50868 
   50869 @item --return-child-result
   50870 @value{GDBN}'s exit code will be the same as the child's exit code.
   50871 
   50872 @item --configuration
   50873 Print details about GDB configuration and then exit.
   50874 
   50875 @item --version
   50876 Print version information and then exit.
   50877 
   50878 @item --cd=@var{directory}
   50879 Run @value{GDBN} using @var{directory} as its working directory,
   50880 instead of the current directory.
   50881 
   50882 @item --data-directory=@var{directory}
   50883 @item -D
   50884 Run @value{GDBN} using @var{directory} as its data directory.  The data
   50885 directory is where @value{GDBN} searches for its auxiliary files.
   50886 
   50887 @item --fullname
   50888 @itemx -f
   50889 Emacs sets this option when it runs @value{GDBN} as a subprocess.  It tells
   50890 @value{GDBN} to output the full file name and line number in a standard,
   50891 recognizable fashion each time a stack frame is displayed (which
   50892 includes each time the program stops).  This recognizable format looks
   50893 like two @samp{\032} characters, followed by the file name, line number
   50894 and character position separated by colons, and a newline.  The
   50895 Emacs-to-@value{GDBN} interface program uses the two @samp{\032}
   50896 characters as a signal to display the source code for the frame.
   50897 
   50898 @item -b @var{baudrate}
   50899 Set the line speed (baud rate or bits per second) of any serial
   50900 interface used by @value{GDBN} for remote debugging.
   50901 
   50902 @item -l @var{timeout}
   50903 Set timeout, in seconds, for remote debugging.
   50904 
   50905 @item --tty=@var{device}
   50906 Run using @var{device} for your program's standard input and output.
   50907 @end table
   50908 @c man end
   50909 
   50910 @c man begin SEEALSO gdb
   50911 @ifset man
   50912 The full documentation for @value{GDBN} is maintained as a Texinfo manual.
   50913 If the @code{info} and @code{gdb} programs and @value{GDBN}'s Texinfo
   50914 documentation are properly installed at your site, the command
   50915 
   50916 @smallexample
   50917 info gdb
   50918 @end smallexample
   50919 
   50920 @noindent
   50921 should give you access to the complete manual.
   50922 
   50923 @cite{Using GDB: A Guide to the GNU Source-Level Debugger},
   50924 Richard M. Stallman and Roland H. Pesch, July 1991.
   50925 @end ifset
   50926 @c man end
   50927 
   50928 @node gdbserver man
   50929 @heading gdbserver man
   50930 
   50931 @c man title gdbserver Remote Server for the GNU Debugger
   50932 @format
   50933 @c man begin SYNOPSIS gdbserver
   50934 gdbserver @var{comm} @var{prog} [@var{args}@dots{}]
   50935 
   50936 gdbserver --attach @var{comm} @var{pid}
   50937 
   50938 gdbserver --multi @var{comm}
   50939 @c man end
   50940 @end format
   50941 
   50942 @c man begin DESCRIPTION gdbserver
   50943 @command{gdbserver} is a program that allows you to run @value{GDBN} on a different machine
   50944 than the one which is running the program being debugged.
   50945 
   50946 @ifclear man
   50947 @subheading Usage (server (target) side)
   50948 @end ifclear
   50949 @ifset man
   50950 Usage (server (target) side):
   50951 @end ifset
   50952 
   50953 First, you need to have a copy of the program you want to debug put onto
   50954 the target system.  The program can be stripped to save space if needed, as
   50955 @command{gdbserver} doesn't care about symbols.  All symbol handling is taken care of by
   50956 the @value{GDBN} running on the host system.
   50957 
   50958 To use the server, you log on to the target system, and run the @command{gdbserver}
   50959 program.  You must tell it (a) how to communicate with @value{GDBN}, (b) the name of
   50960 your program, and (c) its arguments.  The general syntax is:
   50961 
   50962 @smallexample
   50963 target> gdbserver @var{comm} @var{program} [@var{args} ...]
   50964 @end smallexample
   50965 
   50966 For example, using a serial port, you might say:
   50967 
   50968 @smallexample
   50969 @ifset man
   50970 @c @file would wrap it as F</dev/com1>.
   50971 target> gdbserver /dev/com1 emacs foo.txt
   50972 @end ifset
   50973 @ifclear man
   50974 target> gdbserver @file{/dev/com1} emacs foo.txt
   50975 @end ifclear
   50976 @end smallexample
   50977 
   50978 This tells @command{gdbserver} to debug emacs with an argument of foo.txt, and
   50979 to communicate with @value{GDBN} via @file{/dev/com1}.  @command{gdbserver} now
   50980 waits patiently for the host @value{GDBN} to communicate with it.
   50981 
   50982 To use a TCP connection, you could say:
   50983 
   50984 @smallexample
   50985 target> gdbserver host:2345 emacs foo.txt
   50986 @end smallexample
   50987 
   50988 This says pretty much the same thing as the last example, except that we are
   50989 going to communicate with the @code{host} @value{GDBN} via TCP.  The @code{host:2345} argument means
   50990 that we are expecting to see a TCP connection from @code{host} to local TCP port
   50991 2345.  (Currently, the @code{host} part is ignored.)  You can choose any number you
   50992 want for the port number as long as it does not conflict with any existing TCP
   50993 ports on the target system.  This same port number must be used in the host
   50994 @value{GDBN}s @code{target remote} command, which will be described shortly.  Note that if
   50995 you chose a port number that conflicts with another service, @command{gdbserver} will
   50996 print an error message and exit.
   50997 
   50998 @command{gdbserver} can also attach to running programs.
   50999 This is accomplished via the @option{--attach} argument.  The syntax is:
   51000 
   51001 @smallexample
   51002 target> gdbserver --attach @var{comm} @var{pid}
   51003 @end smallexample
   51004 
   51005 @var{pid} is the process ID of a currently running process.  It isn't
   51006 necessary to point @command{gdbserver} at a binary for the running process.
   51007 
   51008 To start @code{gdbserver} without supplying an initial command to run
   51009 or process ID to attach, use the @option{--multi} command line option.
   51010 In such case you should connect using @kbd{target extended-remote} to start
   51011 the program you want to debug.
   51012 
   51013 @smallexample
   51014 target> gdbserver --multi @var{comm}
   51015 @end smallexample
   51016 
   51017 @ifclear man
   51018 @subheading Usage (host side)
   51019 @end ifclear
   51020 @ifset man
   51021 Usage (host side):
   51022 @end ifset
   51023 
   51024 You need an unstripped copy of the target program on your host system, since
   51025 @value{GDBN} needs to examine its symbol tables and such.  Start up @value{GDBN} as you normally
   51026 would, with the target program as the first argument.  (You may need to use the
   51027 @option{--baud} option if the serial line is running at anything except 9600 baud.)
   51028 That is @code{gdb TARGET-PROG}, or @code{gdb --baud BAUD TARGET-PROG}.  After that, the only
   51029 new command you need to know about is @code{target remote}
   51030 (or @code{target extended-remote}).  Its argument is either
   51031 a device name (usually a serial device, like @file{/dev/ttyb}), or a @code{HOST:PORT}
   51032 descriptor.  For example:
   51033 
   51034 @smallexample
   51035 @ifset man
   51036 @c @file would wrap it as F</dev/ttyb>.
   51037 (@value{GDBP}) target remote /dev/ttyb
   51038 @end ifset
   51039 @ifclear man
   51040 (@value{GDBP}) target remote @file{/dev/ttyb}
   51041 @end ifclear
   51042 @end smallexample
   51043 
   51044 @noindent
   51045 communicates with the server via serial line @file{/dev/ttyb}, and:
   51046 
   51047 @smallexample
   51048 (@value{GDBP}) target remote the-target:2345
   51049 @end smallexample
   51050 
   51051 @noindent
   51052 communicates via a TCP connection to port 2345 on host `the-target', where
   51053 you previously started up @command{gdbserver} with the same port number.  Note that for
   51054 TCP connections, you must start up @command{gdbserver} prior to using the `target remote'
   51055 command, otherwise you may get an error that looks something like
   51056 `Connection refused'.
   51057 
   51058 @command{gdbserver} can also debug multiple inferiors at once,
   51059 described in
   51060 @ifset man
   51061 the @value{GDBN} manual in node @code{Inferiors Connections and Programs}
   51062 -- shell command @code{info -f gdb -n 'Inferiors Connections and Programs'}.
   51063 @end ifset
   51064 @ifclear man
   51065 @ref{Inferiors Connections and Programs}.
   51066 @end ifclear
   51067 In such case use the @code{extended-remote} @value{GDBN} command variant:
   51068 
   51069 @smallexample
   51070 (@value{GDBP}) target extended-remote the-target:2345
   51071 @end smallexample
   51072 
   51073 The @command{gdbserver} option @option{--multi} may or may not be used in such
   51074 case.
   51075 @c man end
   51076 
   51077 @c man begin OPTIONS gdbserver
   51078 There are three different modes for invoking @command{gdbserver}:
   51079 
   51080 @itemize @bullet
   51081 
   51082 @item
   51083 Debug a specific program specified by its program name:
   51084 
   51085 @smallexample
   51086 gdbserver @var{comm} @var{prog} [@var{args}@dots{}]
   51087 @end smallexample
   51088 
   51089 The @var{comm} parameter specifies how should the server communicate
   51090 with @value{GDBN}; it is either a device name (to use a serial line),
   51091 a TCP port number (@code{:1234}), or @code{-} or @code{stdio} to use
   51092 stdin/stdout of @code{gdbserver}.  Specify the name of the program to
   51093 debug in @var{prog}.  Any remaining arguments will be passed to the
   51094 program verbatim.  When the program exits, @value{GDBN} will close the
   51095 connection, and @code{gdbserver} will exit.
   51096 
   51097 @item
   51098 Debug a specific program by specifying the process ID of a running
   51099 program:
   51100 
   51101 @smallexample
   51102 gdbserver --attach @var{comm} @var{pid}
   51103 @end smallexample
   51104 
   51105 The @var{comm} parameter is as described above.  Supply the process ID
   51106 of a running program in @var{pid}; @value{GDBN} will do everything
   51107 else.  Like with the previous mode, when the process @var{pid} exits,
   51108 @value{GDBN} will close the connection, and @code{gdbserver} will exit.
   51109 
   51110 @item
   51111 Multi-process mode -- debug more than one program/process:
   51112 
   51113 @smallexample
   51114 gdbserver --multi @var{comm}
   51115 @end smallexample
   51116 
   51117 In this mode, @value{GDBN} can instruct @command{gdbserver} which
   51118 command(s) to run.  Unlike the other 2 modes, @value{GDBN} will not
   51119 close the connection when a process being debugged exits, so you can
   51120 debug several processes in the same session.
   51121 @end itemize
   51122 
   51123 In each of the modes you may specify these options:
   51124 
   51125 @table @env
   51126 
   51127 @item --help
   51128 List all options, with brief explanations.
   51129 
   51130 @item --version
   51131 This option causes @command{gdbserver} to print its version number and exit.
   51132 
   51133 @item --attach
   51134 @command{gdbserver} will attach to a running program.  The syntax is:
   51135 
   51136 @smallexample
   51137 target> gdbserver --attach @var{comm} @var{pid}
   51138 @end smallexample
   51139 
   51140 @var{pid} is the process ID of a currently running process.  It isn't
   51141 necessary to point @command{gdbserver} at a binary for the running process.
   51142 
   51143 @item --multi
   51144 To start @code{gdbserver} without supplying an initial command to run
   51145 or process ID to attach, use this command line option.
   51146 Then you can connect using @kbd{target extended-remote} and start
   51147 the program you want to debug.  The syntax is:
   51148 
   51149 @smallexample
   51150 target> gdbserver --multi @var{comm}
   51151 @end smallexample
   51152 
   51153 @item --debug@r{[}=option1,option2,@dots{}@r{]}
   51154 Instruct @code{gdbserver} to display extra status information about
   51155 the debugging process.  This option is intended for @code{gdbserver}
   51156 development and for bug reports to the developers.
   51157 
   51158 Each @var{option} is the name of a component for which debugging
   51159 should be enabled.  The list of possible options is @option{all},
   51160 @option{threads}, @option{event-loop}, @option{remote}.  The special
   51161 option @option{all} enables all components.  The option list is
   51162 processed left to right, and an option can be prefixed with the
   51163 @kbd{-} character to disable output for that component, so you could write:
   51164 
   51165 @smallexample
   51166 target> gdbserver --debug=all,-event-loop
   51167 @end smallexample
   51168 
   51169 @noindent
   51170 to turn on debug output for all components except @option{event-loop}.
   51171 If no options are passed to @option{--debug} then this is treated as
   51172 equivalent to @option{--debug=threads}.  This could change in future
   51173 releases of @code{gdbserver}.
   51174 
   51175 @item --debug-file=@var{filename}
   51176 Instruct @code{gdbserver} to send any debug output to the given @var{filename}.
   51177 This option is intended for @code{gdbserver} development and for bug reports to
   51178 the developers.
   51179 
   51180 @item --debug-format=option1@r{[},option2,...@r{]}
   51181 Instruct @code{gdbserver} to include extra information in each line
   51182 of debugging output.
   51183 @xref{Other Command-Line Arguments for gdbserver}.
   51184 
   51185 @item --wrapper
   51186 Specify a wrapper to launch programs
   51187 for debugging.  The option should be followed by the name of the
   51188 wrapper, then any command-line arguments to pass to the wrapper, then
   51189 @kbd{--} indicating the end of the wrapper arguments.
   51190 
   51191 @item --once
   51192 By default, @command{gdbserver} keeps the listening TCP port open, so that
   51193 additional connections are possible.  However, if you start @code{gdbserver}
   51194 with the @option{--once} option, it will stop listening for any further
   51195 connection attempts after connecting to the first @value{GDBN} session.
   51196 
   51197 @c --disable-packet is not documented for users.
   51198 
   51199 @c --disable-randomization and --no-disable-randomization are superseded by
   51200 @c QDisableRandomization.
   51201 
   51202 @end table
   51203 @c man end
   51204 
   51205 @c man begin SEEALSO gdbserver
   51206 @ifset man
   51207 The full documentation for @value{GDBN} is maintained as a Texinfo manual.
   51208 If the @code{info} and @code{gdb} programs and @value{GDBN}'s Texinfo
   51209 documentation are properly installed at your site, the command
   51210 
   51211 @smallexample
   51212 info gdb
   51213 @end smallexample
   51214 
   51215 should give you access to the complete manual.
   51216 
   51217 @cite{Using GDB: A Guide to the GNU Source-Level Debugger},
   51218 Richard M. Stallman and Roland H. Pesch, July 1991.
   51219 @end ifset
   51220 @c man end
   51221 
   51222 @node gcore man
   51223 @heading gcore
   51224 
   51225 @c man title gcore Generate a core file of a running program
   51226 
   51227 @format
   51228 @c man begin SYNOPSIS gcore
   51229 gcore [-a] [-o @var{prefix}] [-d @var{directory}] @var{pid1} [@var{pid2}...@var{pidN}]
   51230 @c man end
   51231 @end format
   51232 
   51233 @c man begin DESCRIPTION gcore
   51234 Generate core dumps of one or more running programs with process IDs
   51235 @var{pid1}, @var{pid2}, etc.  A core file produced by @command{gcore}
   51236 is equivalent to one produced by the kernel when the process crashes
   51237 (and when @kbd{ulimit -c} was used to set up an appropriate core dump
   51238 limit).  However, unlike after a crash, after @command{gcore} finishes
   51239 its job the program remains running without any change.
   51240 @c man end
   51241 
   51242 @c man begin OPTIONS gcore
   51243 @table @env
   51244 @item -a
   51245 Dump all memory mappings.  The actual effect of this option depends on
   51246 the Operating System.  On @sc{gnu}/Linux, it will disable
   51247 @code{use-coredump-filter} (@pxref{set use-coredump-filter}) and
   51248 enable @code{dump-excluded-mappings} (@pxref{set
   51249 dump-excluded-mappings}).
   51250 
   51251 @item -o @var{prefix}
   51252 The optional argument @var{prefix} specifies the prefix to be used
   51253 when composing the file names of the core dumps.  The file name is
   51254 composed as @file{@var{prefix}.@var{pid}}, where @var{pid} is the
   51255 process ID of the running program being analyzed by @command{gcore}.
   51256 If not specified, @var{prefix} defaults to @var{gcore}.
   51257 
   51258 @item -d @var{directory}
   51259 Use @var{directory} as the data directory when invoking @value{GDBN} for running
   51260 the gcore command. This argument is optional.
   51261 @end table
   51262 @c man end
   51263 
   51264 @c man begin SEEALSO gcore
   51265 @ifset man
   51266 The full documentation for @value{GDBN} is maintained as a Texinfo manual.
   51267 If the @code{info} and @code{gdb} programs and @value{GDBN}'s Texinfo
   51268 documentation are properly installed at your site, the command
   51269 
   51270 @smallexample
   51271 info gdb
   51272 @end smallexample
   51273 
   51274 @noindent
   51275 should give you access to the complete manual.
   51276 
   51277 @cite{Using GDB: A Guide to the GNU Source-Level Debugger},
   51278 Richard M. Stallman and Roland H. Pesch, July 1991.
   51279 @end ifset
   51280 @c man end
   51281 
   51282 @node gstack man
   51283 @heading gstack
   51284 
   51285 @c man title gstack Print a stack trace of a running program
   51286 
   51287 @format
   51288 @c man begin SYNOPSIS gstack
   51289 gstack [-h | --help] [-v | --version] @var{pid}
   51290 @c man end
   51291 @end format
   51292 
   51293 @c man begin DESCRIPTION gstack
   51294 Print a stack trace of a running program with process ID @var{pid}.  If the process
   51295 is multi-threaded, @command{gstack} outputs backtraces for every thread which exists
   51296 in the process.
   51297 
   51298 The script invokes @value{GDBN}, attaches to the given process ID, prints the stack trace,
   51299 and detaches from the process.
   51300 
   51301 @command{gstack} exits with non-zero status if @code{gdb} was unable to attach to
   51302 the given process ID for any reason, such as a non-existent process ID or
   51303 insufficient privileges to attach to the process.
   51304 @c man end
   51305 
   51306 @c man begin OPTIONS gstack
   51307 @table @env
   51308 @item --help
   51309 @itemx -h
   51310 List all options, with brief explanations.
   51311 
   51312 @item --version
   51313 @itemx -v
   51314 Print version information and then exit.
   51315 @end table
   51316 @c man end
   51317 
   51318 @c man begin ENVIRONMENT gstack
   51319 @table @env
   51320 @item AWK
   51321 Full file name for an Awk interpreter to use.  If not set, @env{PATH} will be
   51322 searched for an @code{awk} program.
   51323 
   51324 @item GDB
   51325 Full file name for a @value{GDBN} executable to use to generate stack backtraces.
   51326 If not set, @env{PATH} will be searched for a @code{gdb} program.
   51327 
   51328 @item GDBARGS
   51329 Optional arguments to be passed to the @code{gdb} program.
   51330 @end table
   51331 @c man end
   51332 
   51333 @c man begin SEEALSO gstack
   51334 @ifset man
   51335 The full documentation for @value{GDBN} is maintained as a Texinfo manual.
   51336 If the @code{info} and @code{gdb} programs and @value{GDBN}'s Texinfo
   51337 documentation are properly installed at your site, the command
   51338 
   51339 @smallexample
   51340 info gdb
   51341 @end smallexample
   51342 
   51343 @noindent
   51344 should give you access to the complete manual.
   51345 
   51346 @cite{Using GDB: A Guide to the GNU Source-Level Debugger},
   51347 Richard M. Stallman and Roland H. Pesch, July 1991.
   51348 @end ifset
   51349 @c man end
   51350 
   51351 @node gdbinit man
   51352 @heading gdbinit
   51353 
   51354 @c man title gdbinit GDB initialization scripts
   51355 
   51356 @format
   51357 @c man begin SYNOPSIS gdbinit
   51358 @ifset SYSTEM_GDBINIT
   51359 @value{SYSTEM_GDBINIT}
   51360 @end ifset
   51361 
   51362 @ifset SYSTEM_GDBINIT_DIR
   51363 @value{SYSTEM_GDBINIT_DIR}/*
   51364 @end ifset
   51365 
   51366 ~/.config/gdb/gdbinit
   51367 
   51368 ~/.gdbinit
   51369 
   51370 ./.gdbinit
   51371 @c man end
   51372 @end format
   51373 
   51374 @c man begin DESCRIPTION gdbinit
   51375 These files contain @value{GDBN} commands to automatically execute during
   51376 @value{GDBN} startup.  The lines of contents are canned sequences of commands,
   51377 described in
   51378 @ifset man
   51379 the @value{GDBN} manual in node @code{Sequences}
   51380 -- shell command @code{info -f gdb -n Sequences}.
   51381 @end ifset
   51382 @ifclear man
   51383 @ref{Sequences}.
   51384 @end ifclear
   51385 
   51386 Please read more in
   51387 @ifset man
   51388 the @value{GDBN} manual in node @code{Startup}
   51389 -- shell command @code{info -f gdb -n Startup}.
   51390 @end ifset
   51391 @ifclear man
   51392 @ref{Startup}.
   51393 @end ifclear
   51394 
   51395 @table @env
   51396 @ifset SYSTEM_GDBINIT
   51397 @item @value{SYSTEM_GDBINIT}
   51398 @end ifset
   51399 @ifclear SYSTEM_GDBINIT
   51400 @item (not enabled with @code{--with-system-gdbinit} during compilation)
   51401 @end ifclear
   51402 System-wide initialization file.  It is executed unless user specified
   51403 @value{GDBN} option @code{-nx} or @code{-n}.
   51404 See more in
   51405 @ifset man
   51406 the @value{GDBN} manual in node @code{System-wide configuration}
   51407 -- shell command @code{info -f gdb -n 'System-wide configuration'}.
   51408 @end ifset
   51409 @ifset SYSTEM_GDBINIT_DIR
   51410 @item @value{SYSTEM_GDBINIT_DIR}
   51411 @end ifset
   51412 @ifclear SYSTEM_GDBINIT_DIR
   51413 @item (not enabled with @code{--with-system-gdbinit-dir} during compilation)
   51414 @end ifclear
   51415 System-wide initialization directory.  All files in this directory are
   51416 executed on startup unless user specified @value{GDBN} option @code{-nx} or
   51417 @code{-n}, as long as they have a recognized file extension.
   51418 See more in
   51419 @ifset man
   51420 the @value{GDBN} manual in node @code{System-wide configuration}
   51421 -- shell command @code{info -f gdb -n 'System-wide configuration'}.
   51422 @end ifset
   51423 @ifclear man
   51424 @ref{System-wide configuration}.
   51425 @end ifclear
   51426 
   51427 @item @file{~/.config/gdb/gdbinit} or @file{~/.gdbinit}
   51428 User initialization file.  It is executed unless user specified
   51429 @value{GDBN} options @code{-nx}, @code{-n} or @code{-nh}.
   51430 
   51431 @item @file{.gdbinit}
   51432 Initialization file for current directory.  It may need to be enabled with
   51433 @value{GDBN} security command @code{set auto-load local-gdbinit}.
   51434 See more in
   51435 @ifset man
   51436 the @value{GDBN} manual in node @code{Init File in the Current Directory}
   51437 -- shell command @code{info -f gdb -n 'Init File in the Current Directory'}.
   51438 @end ifset
   51439 @ifclear man
   51440 @ref{Init File in the Current Directory}.
   51441 @end ifclear
   51442 @end table
   51443 @c man end
   51444 
   51445 @c man begin SEEALSO gdbinit
   51446 @ifset man
   51447 gdb(1), @code{info -f gdb -n Startup}
   51448 
   51449 The full documentation for @value{GDBN} is maintained as a Texinfo manual.
   51450 If the @code{info} and @code{gdb} programs and @value{GDBN}'s Texinfo
   51451 documentation are properly installed at your site, the command
   51452 
   51453 @smallexample
   51454 info gdb
   51455 @end smallexample
   51456 
   51457 should give you access to the complete manual.
   51458 
   51459 @cite{Using GDB: A Guide to the GNU Source-Level Debugger},
   51460 Richard M. Stallman and Roland H. Pesch, July 1991.
   51461 @end ifset
   51462 @c man end
   51463 
   51464 @node gdb-add-index man
   51465 @heading gdb-add-index
   51466 @pindex gdb-add-index
   51467 @anchor{gdb-add-index}
   51468 
   51469 @c man title gdb-add-index Add index files to speed up GDB
   51470 
   51471 @c man begin SYNOPSIS gdb-add-index
   51472 gdb-add-index [-dwarf-5] @var{filename}
   51473 @c man end
   51474 
   51475 @c man begin DESCRIPTION gdb-add-index
   51476 When @value{GDBN} finds a symbol file, it scans the symbols in the
   51477 file in order to construct an internal symbol table.  This lets most
   51478 @value{GDBN} operations work quickly--at the cost of a delay early on.
   51479 For large programs, this delay can be quite lengthy, so @value{GDBN}
   51480 provides a way to build an index, which speeds up startup.
   51481 
   51482 To determine whether a file contains such an index, use the command
   51483 @kbd{readelf -S filename}: the index is stored in a section named
   51484 @code{.gdb_index} (pre-DWARF 5) or @code{.debug_names} and
   51485 @code{.debug_str} (DWARF 5).  Indexes can only be produced on systems
   51486 which use ELF binaries and DWARF debug information (i.e., sections
   51487 named @code{.debug_*}).
   51488 
   51489 By default @command{gdb-add-index} will add a pre-DWARF 5
   51490 @code{.gdb_index} section to @var{filename}.  With @option{-dwarf-5}
   51491 DWARF 5 sections are added instead.
   51492 
   51493 @var{filename} must be writable.
   51494 
   51495 @command{gdb-add-index} uses @value{GDBN}, @command{objcopy}, and
   51496 @command{readelf} found in the @env{PATH} environment variable.  If
   51497 you want to use different versions of these programs, you can specify
   51498 them through the appropriate environment variables (see below).
   51499 
   51500 @command{gdb-add-index} exits with status 0 if it succeeds in creating
   51501 the index for @var{filename} or greater than 0 if an error occurs.
   51502 
   51503 See more in
   51504 @ifset man
   51505 the @value{GDBN} manual in node @code{Index Files}
   51506 -- shell command @kbd{info -f gdb -n "Index Files"}.
   51507 @end ifset
   51508 @ifclear man
   51509 @ref{Index Files}.
   51510 @end ifclear
   51511 @c man end
   51512 
   51513 @c man begin OPTIONS gdb-add-index
   51514 @table @env
   51515 @item -dwarf-5
   51516 Add DWARF 5 sections instead of previous @code{.debug_index} section.
   51517 
   51518 @end table
   51519 @c man end
   51520 
   51521 @c man begin ENVIRONMENT gdb-add-index
   51522 @table @env
   51523 @item GDB
   51524 Full file name of the @code{gdb} program to use for index generation.
   51525 If not set, the @env{PATH} will be searched for a @code{gdb} program.
   51526 
   51527 @item OBJCOPY
   51528 Full file name of the @code{objcopy} program to use to copy section
   51529 information into the given file.  If not set, the @env{PATH} will be searched
   51530 for a @code{objcopy} program.
   51531 
   51532 @item READELF
   51533 Full file name of the @code{readelf} program to use to inspect
   51534 properties of the given file.  If not set, the @env{PATH} will be searched
   51535 for a @code{readelf} program.
   51536 @end table
   51537 @c man end
   51538 
   51539 @c man begin SEEALSO gdb-add-index
   51540 @ifset man
   51541 The full documentation for @value{GDBN} is maintained as a Texinfo manual.
   51542 If the @code{info} and @code{gdb} programs and @value{GDBN}'s Texinfo
   51543 documentation are properly installed at your site, the command
   51544 
   51545 @smallexample
   51546 info gdb
   51547 @end smallexample
   51548 
   51549 should give you access to the complete manual.
   51550 
   51551 @cite{Using GDB: A Guide to the GNU Source-Level Debugger},
   51552 Richard M. Stallman and Roland H. Pesch, July 1991.
   51553 @end ifset
   51554 @c man end
   51555 
   51556 @include gpl.texi
   51557 
   51558 @node GNU Free Documentation License
   51559 @appendix GNU Free Documentation License
   51560 @include fdl.texi
   51561 
   51562 @node Concept Index
   51563 @unnumbered Concept Index
   51564 
   51565 @printindex cp
   51566 
   51567 @node Command and Variable Index
   51568 @unnumbered Command, Variable, and Function Index
   51569 
   51570 @printindex fn
   51571 
   51572 @tex
   51573 % I think something like @@colophon should be in texinfo.  In the
   51574 % meantime:
   51575 \long\def\colophon{\hbox to0pt{}\vfill
   51576 \centerline{The body of this manual is set in}
   51577 \centerline{\fontname\tenrm,}
   51578 \centerline{with headings in {\bf\fontname\tenbf}}
   51579 \centerline{and examples in {\tt\fontname\tentt}.}
   51580 \centerline{{\it\fontname\tenit\/},}
   51581 \centerline{{\bf\fontname\tenbf}, and}
   51582 \centerline{{\sl\fontname\tensl\/}}
   51583 \centerline{are used for emphasis.}\vfill}
   51584 \page\colophon
   51585 % Blame: doc@@cygnus.com, 1991.
   51586 @end tex
   51587 
   51588 @bye
   51589