1 This is gdb.info, produced by makeinfo version 4.13 from 2 /tmp/android-8532/src/build/../gdb/gdb-7.3.x/gdb/doc/gdb.texinfo. 3 4 INFO-DIR-SECTION Software development 5 START-INFO-DIR-ENTRY 6 * Gdb: (gdb). The GNU debugger. 7 END-INFO-DIR-ENTRY 8 9 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 10 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 11 2010 Free Software Foundation, Inc. 12 13 Permission is granted to copy, distribute and/or modify this document 14 under the terms of the GNU Free Documentation License, Version 1.3 or 15 any later version published by the Free Software Foundation; with the 16 Invariant Sections being "Free Software" and "Free Software Needs Free 17 Documentation", with the Front-Cover Texts being "A GNU Manual," and 18 with the Back-Cover Texts as in (a) below. 19 20 (a) The FSF's Back-Cover Text is: "You are free to copy and modify 21 this GNU Manual. Buying copies from GNU Press supports the FSF in 22 developing GNU and promoting software freedom." 23 24 This file documents the GNU debugger GDB. 25 26 This is the Tenth Edition, of `Debugging with GDB: the GNU 27 Source-Level Debugger' for GDB (GDB) Version 7.3.1-gg2. 28 29 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 30 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 31 2010 Free Software Foundation, Inc. 32 33 Permission is granted to copy, distribute and/or modify this document 34 under the terms of the GNU Free Documentation License, Version 1.3 or 35 any later version published by the Free Software Foundation; with the 36 Invariant Sections being "Free Software" and "Free Software Needs Free 37 Documentation", with the Front-Cover Texts being "A GNU Manual," and 38 with the Back-Cover Texts as in (a) below. 39 40 (a) The FSF's Back-Cover Text is: "You are free to copy and modify 41 this GNU Manual. Buying copies from GNU Press supports the FSF in 42 developing GNU and promoting software freedom." 43 44 45 File: gdb.info, Node: Top, Next: Summary, Prev: (dir), Up: (dir) 46 47 Debugging with GDB 48 ****************** 49 50 This file describes GDB, the GNU symbolic debugger. 51 52 This is the Tenth Edition, for GDB (GDB) Version 7.3.1-gg2. 53 54 Copyright (C) 1988-2010 Free Software Foundation, Inc. 55 56 This edition of the GDB manual is dedicated to the memory of Fred 57 Fish. Fred was a long-standing contributor to GDB and to Free software 58 in general. We will miss him. 59 60 * Menu: 61 62 * Summary:: Summary of GDB 63 * Sample Session:: A sample GDB session 64 65 * Invocation:: Getting in and out of GDB 66 * Commands:: GDB commands 67 * Running:: Running programs under GDB 68 * Stopping:: Stopping and continuing 69 * Reverse Execution:: Running programs backward 70 * Process Record and Replay:: Recording inferior's execution and replaying it 71 * Stack:: Examining the stack 72 * Source:: Examining source files 73 * Data:: Examining data 74 * Optimized Code:: Debugging optimized code 75 * Macros:: Preprocessor Macros 76 * Tracepoints:: Debugging remote targets non-intrusively 77 * Overlays:: Debugging programs that use overlays 78 79 * Languages:: Using GDB with different languages 80 81 * Symbols:: Examining the symbol table 82 * Altering:: Altering execution 83 * GDB Files:: GDB files 84 * Targets:: Specifying a debugging target 85 * Remote Debugging:: Debugging remote programs 86 * Configurations:: Configuration-specific information 87 * Controlling GDB:: Controlling GDB 88 * Extending GDB:: Extending GDB 89 * Interpreters:: Command Interpreters 90 * TUI:: GDB Text User Interface 91 * Emacs:: Using GDB under GNU Emacs 92 * GDB/MI:: GDB's Machine Interface. 93 * Annotations:: GDB's annotation interface. 94 * JIT Interface:: Using the JIT debugging interface. 95 96 * GDB Bugs:: Reporting bugs in GDB 97 98 99 * Command Line Editing:: Command Line Editing 100 * Using History Interactively:: Using History Interactively 101 * In Memoriam:: In Memoriam 102 * Formatting Documentation:: How to format and print GDB documentation 103 * Installing GDB:: Installing GDB 104 * Maintenance Commands:: Maintenance Commands 105 * Remote Protocol:: GDB Remote Serial Protocol 106 * Agent Expressions:: The GDB Agent Expression Mechanism 107 * Target Descriptions:: How targets can describe themselves to 108 GDB 109 * Operating System Information:: Getting additional information from 110 the operating system 111 * Trace File Format:: GDB trace file format 112 * Copying:: GNU General Public License says 113 how you can copy and share GDB 114 * GNU Free Documentation License:: The license for this documentation 115 * Index:: Index 116 117 118 File: gdb.info, Node: Summary, Next: Sample Session, Prev: Top, Up: Top 119 120 Summary of GDB 121 ************** 122 123 The purpose of a debugger such as GDB is to allow you to see what is 124 going on "inside" another program while it executes--or what another 125 program was doing at the moment it crashed. 126 127 GDB can do four main kinds of things (plus other things in support of 128 these) to help you catch bugs in the act: 129 130 * Start your program, specifying anything that might affect its 131 behavior. 132 133 * Make your program stop on specified conditions. 134 135 * Examine what has happened, when your program has stopped. 136 137 * Change things in your program, so you can experiment with 138 correcting the effects of one bug and go on to learn about another. 139 140 You can use GDB to debug programs written in C and C++. For more 141 information, see *note Supported Languages: Supported Languages. For 142 more information, see *note C and C++: C. 143 144 Support for D is partial. For information on D, see *note D: D. 145 146 Support for Modula-2 is partial. For information on Modula-2, see 147 *note Modula-2: Modula-2. 148 149 Support for OpenCL C is partial. For information on OpenCL C, see 150 *note OpenCL C: OpenCL C. 151 152 Debugging Pascal programs which use sets, subranges, file variables, 153 or nested functions does not currently work. GDB does not support 154 entering expressions, printing values, or similar features using Pascal 155 syntax. 156 157 GDB can be used to debug programs written in Fortran, although it 158 may be necessary to refer to some variables with a trailing underscore. 159 160 GDB can be used to debug programs written in Objective-C, using 161 either the Apple/NeXT or the GNU Objective-C runtime. 162 163 * Menu: 164 165 * Free Software:: Freely redistributable software 166 * Contributors:: Contributors to GDB 167 168 169 File: gdb.info, Node: Free Software, Next: Contributors, Up: Summary 170 171 Free Software 172 ============= 173 174 GDB is "free software", protected by the GNU General Public License 175 (GPL). The GPL gives you the freedom to copy or adapt a licensed 176 program--but every person getting a copy also gets with it the freedom 177 to modify that copy (which means that they must get access to the 178 source code), and the freedom to distribute further copies. Typical 179 software companies use copyrights to limit your freedoms; the Free 180 Software Foundation uses the GPL to preserve these freedoms. 181 182 Fundamentally, the General Public License is a license which says 183 that you have these freedoms and that you cannot take these freedoms 184 away from anyone else. 185 186 Free Software Needs Free Documentation 187 ====================================== 188 189 The biggest deficiency in the free software community today is not in 190 the software--it is the lack of good free documentation that we can 191 include with the free software. Many of our most important programs do 192 not come with free reference manuals and free introductory texts. 193 Documentation is an essential part of any software package; when an 194 important free software package does not come with a free manual and a 195 free tutorial, that is a major gap. We have many such gaps today. 196 197 Consider Perl, for instance. The tutorial manuals that people 198 normally use are non-free. How did this come about? Because the 199 authors of those manuals published them with restrictive terms--no 200 copying, no modification, source files not available--which exclude 201 them from the free software world. 202 203 That wasn't the first time this sort of thing happened, and it was 204 far from the last. Many times we have heard a GNU user eagerly 205 describe a manual that he is writing, his intended contribution to the 206 community, only to learn that he had ruined everything by signing a 207 publication contract to make it non-free. 208 209 Free documentation, like free software, is a matter of freedom, not 210 price. The problem with the non-free manual is not that publishers 211 charge a price for printed copies--that in itself is fine. (The Free 212 Software Foundation sells printed copies of manuals, too.) The problem 213 is the restrictions on the use of the manual. Free manuals are 214 available in source code form, and give you permission to copy and 215 modify. Non-free manuals do not allow this. 216 217 The criteria of freedom for a free manual are roughly the same as for 218 free software. Redistribution (including the normal kinds of 219 commercial redistribution) must be permitted, so that the manual can 220 accompany every copy of the program, both on-line and on paper. 221 222 Permission for modification of the technical content is crucial too. 223 When people modify the software, adding or changing features, if they 224 are conscientious they will change the manual too--so they can provide 225 accurate and clear documentation for the modified program. A manual 226 that leaves you no choice but to write a new manual to document a 227 changed version of the program is not really available to our community. 228 229 Some kinds of limits on the way modification is handled are 230 acceptable. For example, requirements to preserve the original 231 author's copyright notice, the distribution terms, or the list of 232 authors, are ok. It is also no problem to require modified versions to 233 include notice that they were modified. Even entire sections that may 234 not be deleted or changed are acceptable, as long as they deal with 235 nontechnical topics (like this one). These kinds of restrictions are 236 acceptable because they don't obstruct the community's normal use of 237 the manual. 238 239 However, it must be possible to modify all the _technical_ content 240 of the manual, and then distribute the result in all the usual media, 241 through all the usual channels. Otherwise, the restrictions obstruct 242 the use of the manual, it is not free, and we need another manual to 243 replace it. 244 245 Please spread the word about this issue. Our community continues to 246 lose manuals to proprietary publishing. If we spread the word that 247 free software needs free reference manuals and free tutorials, perhaps 248 the next person who wants to contribute by writing documentation will 249 realize, before it is too late, that only free manuals contribute to 250 the free software community. 251 252 If you are writing documentation, please insist on publishing it 253 under the GNU Free Documentation License or another free documentation 254 license. Remember that this decision requires your approval--you don't 255 have to let the publisher decide. Some commercial publishers will use 256 a free license if you insist, but they will not propose the option; it 257 is up to you to raise the issue and say firmly that this is what you 258 want. If the publisher you are dealing with refuses, please try other 259 publishers. If you're not sure whether a proposed license is free, 260 write to <licensing (a] gnu.org>. 261 262 You can encourage commercial publishers to sell more free, copylefted 263 manuals and tutorials by buying them, and particularly by buying copies 264 from the publishers that paid for their writing or for major 265 improvements. Meanwhile, try to avoid buying non-free documentation at 266 all. Check the distribution terms of a manual before you buy it, and 267 insist that whoever seeks your business must respect your freedom. 268 Check the history of the book, and try to reward the publishers that 269 have paid or pay the authors to work on it. 270 271 The Free Software Foundation maintains a list of free documentation 272 published by other publishers, at 273 `http://www.fsf.org/doc/other-free-books.html'. 274 275 276 File: gdb.info, Node: Contributors, Prev: Free Software, Up: Summary 277 278 Contributors to GDB 279 =================== 280 281 Richard Stallman was the original author of GDB, and of many other GNU 282 programs. Many others have contributed to its development. This 283 section attempts to credit major contributors. One of the virtues of 284 free software is that everyone is free to contribute to it; with 285 regret, we cannot actually acknowledge everyone here. The file 286 `ChangeLog' in the GDB distribution approximates a blow-by-blow account. 287 288 Changes much prior to version 2.0 are lost in the mists of time. 289 290 _Plea:_ Additions to this section are particularly welcome. If you 291 or your friends (or enemies, to be evenhanded) have been unfairly 292 omitted from this list, we would like to add your names! 293 294 So that they may not regard their many labors as thankless, we 295 particularly thank those who shepherded GDB through major releases: 296 Andrew Cagney (releases 6.3, 6.2, 6.1, 6.0, 5.3, 5.2, 5.1 and 5.0); Jim 297 Blandy (release 4.18); Jason Molenda (release 4.17); Stan Shebs 298 (release 4.14); Fred Fish (releases 4.16, 4.15, 4.13, 4.12, 4.11, 4.10, 299 and 4.9); Stu Grossman and John Gilmore (releases 4.8, 4.7, 4.6, 4.5, 300 and 4.4); John Gilmore (releases 4.3, 4.2, 4.1, 4.0, and 3.9); Jim 301 Kingdon (releases 3.5, 3.4, and 3.3); and Randy Smith (releases 3.2, 302 3.1, and 3.0). 303 304 Richard Stallman, assisted at various times by Peter TerMaat, Chris 305 Hanson, and Richard Mlynarik, handled releases through 2.8. 306 307 Michael Tiemann is the author of most of the GNU C++ support in GDB, 308 with significant additional contributions from Per Bothner and Daniel 309 Berlin. James Clark wrote the GNU C++ demangler. Early work on C++ 310 was by Peter TerMaat (who also did much general update work leading to 311 release 3.0). 312 313 GDB uses the BFD subroutine library to examine multiple object-file 314 formats; BFD was a joint project of David V. Henkel-Wallace, Rich 315 Pixley, Steve Chamberlain, and John Gilmore. 316 317 David Johnson wrote the original COFF support; Pace Willison did the 318 original support for encapsulated COFF. 319 320 Brent Benson of Harris Computer Systems contributed DWARF 2 support. 321 322 Adam de Boor and Bradley Davis contributed the ISI Optimum V support. 323 Per Bothner, Noboyuki Hikichi, and Alessandro Forin contributed MIPS 324 support. Jean-Daniel Fekete contributed Sun 386i support. Chris 325 Hanson improved the HP9000 support. Noboyuki Hikichi and Tomoyuki 326 Hasei contributed Sony/News OS 3 support. David Johnson contributed 327 Encore Umax support. Jyrki Kuoppala contributed Altos 3068 support. 328 Jeff Law contributed HP PA and SOM support. Keith Packard contributed 329 NS32K support. Doug Rabson contributed Acorn Risc Machine support. 330 Bob Rusk contributed Harris Nighthawk CX-UX support. Chris Smith 331 contributed Convex support (and Fortran debugging). Jonathan Stone 332 contributed Pyramid support. Michael Tiemann contributed SPARC support. 333 Tim Tucker contributed support for the Gould NP1 and Gould Powernode. 334 Pace Willison contributed Intel 386 support. Jay Vosburgh contributed 335 Symmetry support. Marko Mlinar contributed OpenRISC 1000 support. 336 337 Andreas Schwab contributed M68K GNU/Linux support. 338 339 Rich Schaefer and Peter Schauer helped with support of SunOS shared 340 libraries. 341 342 Jay Fenlason and Roland McGrath ensured that GDB and GAS agree about 343 several machine instruction sets. 344 345 Patrick Duval, Ted Goldstein, Vikram Koka and Glenn Engel helped 346 develop remote debugging. Intel Corporation, Wind River Systems, AMD, 347 and ARM contributed remote debugging modules for the i960, VxWorks, 348 A29K UDI, and RDI targets, respectively. 349 350 Brian Fox is the author of the readline libraries providing 351 command-line editing and command history. 352 353 Andrew Beers of SUNY Buffalo wrote the language-switching code, the 354 Modula-2 support, and contributed the Languages chapter of this manual. 355 356 Fred Fish wrote most of the support for Unix System Vr4. He also 357 enhanced the command-completion support to cover C++ overloaded symbols. 358 359 Hitachi America (now Renesas America), Ltd. sponsored the support for 360 H8/300, H8/500, and Super-H processors. 361 362 NEC sponsored the support for the v850, Vr4xxx, and Vr5xxx 363 processors. 364 365 Mitsubishi (now Renesas) sponsored the support for D10V, D30V, and 366 M32R/D processors. 367 368 Toshiba sponsored the support for the TX39 Mips processor. 369 370 Matsushita sponsored the support for the MN10200 and MN10300 371 processors. 372 373 Fujitsu sponsored the support for SPARClite and FR30 processors. 374 375 Kung Hsu, Jeff Law, and Rick Sladkey added support for hardware 376 watchpoints. 377 378 Michael Snyder added support for tracepoints. 379 380 Stu Grossman wrote gdbserver. 381 382 Jim Kingdon, Peter Schauer, Ian Taylor, and Stu Grossman made nearly 383 innumerable bug fixes and cleanups throughout GDB. 384 385 The following people at the Hewlett-Packard Company contributed 386 support for the PA-RISC 2.0 architecture, HP-UX 10.20, 10.30, and 11.0 387 (narrow mode), HP's implementation of kernel threads, HP's aC++ 388 compiler, and the Text User Interface (nee Terminal User Interface): 389 Ben Krepp, Richard Title, John Bishop, Susan Macchia, Kathy Mann, 390 Satish Pai, India Paul, Steve Rehrauer, and Elena Zannoni. Kim Haase 391 provided HP-specific information in this manual. 392 393 DJ Delorie ported GDB to MS-DOS, for the DJGPP project. Robert 394 Hoehne made significant contributions to the DJGPP port. 395 396 Cygnus Solutions has sponsored GDB maintenance and much of its 397 development since 1991. Cygnus engineers who have worked on GDB 398 fulltime include Mark Alexander, Jim Blandy, Per Bothner, Kevin 399 Buettner, Edith Epstein, Chris Faylor, Fred Fish, Martin Hunt, Jim 400 Ingham, John Gilmore, Stu Grossman, Kung Hsu, Jim Kingdon, John Metzler, 401 Fernando Nasser, Geoffrey Noer, Dawn Perchik, Rich Pixley, Zdenek 402 Radouch, Keith Seitz, Stan Shebs, David Taylor, and Elena Zannoni. In 403 addition, Dave Brolley, Ian Carmichael, Steve Chamberlain, Nick Clifton, 404 JT Conklin, Stan Cox, DJ Delorie, Ulrich Drepper, Frank Eigler, Doug 405 Evans, Sean Fagan, David Henkel-Wallace, Richard Henderson, Jeff 406 Holcomb, Jeff Law, Jim Lemke, Tom Lord, Bob Manson, Michael Meissner, 407 Jason Merrill, Catherine Moore, Drew Moseley, Ken Raeburn, Gavin 408 Romig-Koch, Rob Savoye, Jamie Smith, Mike Stump, Ian Taylor, Angela 409 Thomas, Michael Tiemann, Tom Tromey, Ron Unrau, Jim Wilson, and David 410 Zuhn have made contributions both large and small. 411 412 Andrew Cagney, Fernando Nasser, and Elena Zannoni, while working for 413 Cygnus Solutions, implemented the original GDB/MI interface. 414 415 Jim Blandy added support for preprocessor macros, while working for 416 Red Hat. 417 418 Andrew Cagney designed GDB's architecture vector. Many people 419 including Andrew Cagney, Stephane Carrez, Randolph Chung, Nick Duffek, 420 Richard Henderson, Mark Kettenis, Grace Sainsbury, Kei Sakamoto, 421 Yoshinori Sato, Michael Snyder, Andreas Schwab, Jason Thorpe, Corinna 422 Vinschen, Ulrich Weigand, and Elena Zannoni, helped with the migration 423 of old architectures to this new framework. 424 425 Andrew Cagney completely re-designed and re-implemented GDB's 426 unwinder framework, this consisting of a fresh new design featuring 427 frame IDs, independent frame sniffers, and the sentinel frame. Mark 428 Kettenis implemented the DWARF 2 unwinder, Jeff Johnston the libunwind 429 unwinder, and Andrew Cagney the dummy, sentinel, tramp, and trad 430 unwinders. The architecture-specific changes, each involving a 431 complete rewrite of the architecture's frame code, were carried out by 432 Jim Blandy, Joel Brobecker, Kevin Buettner, Andrew Cagney, Stephane 433 Carrez, Randolph Chung, Orjan Friberg, Richard Henderson, Daniel 434 Jacobowitz, Jeff Johnston, Mark Kettenis, Theodore A. Roth, Kei 435 Sakamoto, Yoshinori Sato, Michael Snyder, Corinna Vinschen, and Ulrich 436 Weigand. 437 438 Christian Zankel, Ross Morley, Bob Wilson, and Maxim Grigoriev from 439 Tensilica, Inc. contributed support for Xtensa processors. Others who 440 have worked on the Xtensa port of GDB in the past include Steve Tjiang, 441 John Newlin, and Scott Foehner. 442 443 Michael Eager and staff of Xilinx, Inc., contributed support for the 444 Xilinx MicroBlaze architecture. 445 446 447 File: gdb.info, Node: Sample Session, Next: Invocation, Prev: Summary, Up: Top 448 449 1 A Sample GDB Session 450 ********************** 451 452 You can use this manual at your leisure to read all about GDB. 453 However, a handful of commands are enough to get started using the 454 debugger. This chapter illustrates those commands. 455 456 One of the preliminary versions of GNU `m4' (a generic macro 457 processor) exhibits the following bug: sometimes, when we change its 458 quote strings from the default, the commands used to capture one macro 459 definition within another stop working. In the following short `m4' 460 session, we define a macro `foo' which expands to `0000'; we then use 461 the `m4' built-in `defn' to define `bar' as the same thing. However, 462 when we change the open quote string to `<QUOTE>' and the close quote 463 string to `<UNQUOTE>', the same procedure fails to define a new synonym 464 `baz': 465 466 $ cd gnu/m4 467 $ ./m4 468 define(foo,0000) 469 470 foo 471 0000 472 define(bar,defn(`foo')) 473 474 bar 475 0000 476 changequote(<QUOTE>,<UNQUOTE>) 477 478 define(baz,defn(<QUOTE>foo<UNQUOTE>)) 479 baz 480 Ctrl-d 481 m4: End of input: 0: fatal error: EOF in string 482 483 Let us use GDB to try to see what is going on. 484 485 $ gdb m4 486 GDB is free software and you are welcome to distribute copies 487 of it under certain conditions; type "show copying" to see 488 the conditions. 489 There is absolutely no warranty for GDB; type "show warranty" 490 for details. 491 492 GDB 7.3.1-gg2, Copyright 1999 Free Software Foundation, Inc... 493 (gdb) 494 495 GDB reads only enough symbol data to know where to find the rest when 496 needed; as a result, the first prompt comes up very quickly. We now 497 tell GDB to use a narrower display width than usual, so that examples 498 fit in this manual. 499 500 (gdb) set width 70 501 502 We need to see how the `m4' built-in `changequote' works. Having 503 looked at the source, we know the relevant subroutine is 504 `m4_changequote', so we set a breakpoint there with the GDB `break' 505 command. 506 507 (gdb) break m4_changequote 508 Breakpoint 1 at 0x62f4: file builtin.c, line 879. 509 510 Using the `run' command, we start `m4' running under GDB control; as 511 long as control does not reach the `m4_changequote' subroutine, the 512 program runs as usual: 513 514 (gdb) run 515 Starting program: /work/Editorial/gdb/gnu/m4/m4 516 define(foo,0000) 517 518 foo 519 0000 520 521 To trigger the breakpoint, we call `changequote'. GDB suspends 522 execution of `m4', displaying information about the context where it 523 stops. 524 525 changequote(<QUOTE>,<UNQUOTE>) 526 527 Breakpoint 1, m4_changequote (argc=3, argv=0x33c70) 528 at builtin.c:879 529 879 if (bad_argc(TOKEN_DATA_TEXT(argv[0]),argc,1,3)) 530 531 Now we use the command `n' (`next') to advance execution to the next 532 line of the current function. 533 534 (gdb) n 535 882 set_quotes((argc >= 2) ? TOKEN_DATA_TEXT(argv[1])\ 536 : nil, 537 538 `set_quotes' looks like a promising subroutine. We can go into it by 539 using the command `s' (`step') instead of `next'. `step' goes to the 540 next line to be executed in _any_ subroutine, so it steps into 541 `set_quotes'. 542 543 (gdb) s 544 set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>") 545 at input.c:530 546 530 if (lquote != def_lquote) 547 548 The display that shows the subroutine where `m4' is now suspended (and 549 its arguments) is called a stack frame display. It shows a summary of 550 the stack. We can use the `backtrace' command (which can also be 551 spelled `bt'), to see where we are in the stack as a whole: the 552 `backtrace' command displays a stack frame for each active subroutine. 553 554 (gdb) bt 555 #0 set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>") 556 at input.c:530 557 #1 0x6344 in m4_changequote (argc=3, argv=0x33c70) 558 at builtin.c:882 559 #2 0x8174 in expand_macro (sym=0x33320) at macro.c:242 560 #3 0x7a88 in expand_token (obs=0x0, t=209696, td=0xf7fffa30) 561 at macro.c:71 562 #4 0x79dc in expand_input () at macro.c:40 563 #5 0x2930 in main (argc=0, argv=0xf7fffb20) at m4.c:195 564 565 We step through a few more lines to see what happens. The first two 566 times, we can use `s'; the next two times we use `n' to avoid falling 567 into the `xstrdup' subroutine. 568 569 (gdb) s 570 0x3b5c 532 if (rquote != def_rquote) 571 (gdb) s 572 0x3b80 535 lquote = (lq == nil || *lq == '\0') ? \ 573 def_lquote : xstrdup(lq); 574 (gdb) n 575 536 rquote = (rq == nil || *rq == '\0') ? def_rquote\ 576 : xstrdup(rq); 577 (gdb) n 578 538 len_lquote = strlen(rquote); 579 580 The last line displayed looks a little odd; we can examine the variables 581 `lquote' and `rquote' to see if they are in fact the new left and right 582 quotes we specified. We use the command `p' (`print') to see their 583 values. 584 585 (gdb) p lquote 586 $1 = 0x35d40 "<QUOTE>" 587 (gdb) p rquote 588 $2 = 0x35d50 "<UNQUOTE>" 589 590 `lquote' and `rquote' are indeed the new left and right quotes. To 591 look at some context, we can display ten lines of source surrounding 592 the current line with the `l' (`list') command. 593 594 (gdb) l 595 533 xfree(rquote); 596 534 597 535 lquote = (lq == nil || *lq == '\0') ? def_lquote\ 598 : xstrdup (lq); 599 536 rquote = (rq == nil || *rq == '\0') ? def_rquote\ 600 : xstrdup (rq); 601 537 602 538 len_lquote = strlen(rquote); 603 539 len_rquote = strlen(lquote); 604 540 } 605 541 606 542 void 607 608 Let us step past the two lines that set `len_lquote' and `len_rquote', 609 and then examine the values of those variables. 610 611 (gdb) n 612 539 len_rquote = strlen(lquote); 613 (gdb) n 614 540 } 615 (gdb) p len_lquote 616 $3 = 9 617 (gdb) p len_rquote 618 $4 = 7 619 620 That certainly looks wrong, assuming `len_lquote' and `len_rquote' are 621 meant to be the lengths of `lquote' and `rquote' respectively. We can 622 set them to better values using the `p' command, since it can print the 623 value of any expression--and that expression can include subroutine 624 calls and assignments. 625 626 (gdb) p len_lquote=strlen(lquote) 627 $5 = 7 628 (gdb) p len_rquote=strlen(rquote) 629 $6 = 9 630 631 Is that enough to fix the problem of using the new quotes with the `m4' 632 built-in `defn'? We can allow `m4' to continue executing with the `c' 633 (`continue') command, and then try the example that caused trouble 634 initially: 635 636 (gdb) c 637 Continuing. 638 639 define(baz,defn(<QUOTE>foo<UNQUOTE>)) 640 641 baz 642 0000 643 644 Success! The new quotes now work just as well as the default ones. The 645 problem seems to have been just the two typos defining the wrong 646 lengths. We allow `m4' exit by giving it an EOF as input: 647 648 Ctrl-d 649 Program exited normally. 650 651 The message `Program exited normally.' is from GDB; it indicates `m4' 652 has finished executing. We can end our GDB session with the GDB `quit' 653 command. 654 655 (gdb) quit 656 657 658 File: gdb.info, Node: Invocation, Next: Commands, Prev: Sample Session, Up: Top 659 660 2 Getting In and Out of GDB 661 *************************** 662 663 This chapter discusses how to start GDB, and how to get out of it. The 664 essentials are: 665 * type `gdb' to start GDB. 666 667 * type `quit' or `Ctrl-d' to exit. 668 669 * Menu: 670 671 * Invoking GDB:: How to start GDB 672 * Quitting GDB:: How to quit GDB 673 * Shell Commands:: How to use shell commands inside GDB 674 * Logging Output:: How to log GDB's output to a file 675 676 677 File: gdb.info, Node: Invoking GDB, Next: Quitting GDB, Up: Invocation 678 679 2.1 Invoking GDB 680 ================ 681 682 Invoke GDB by running the program `gdb'. Once started, GDB reads 683 commands from the terminal until you tell it to exit. 684 685 You can also run `gdb' with a variety of arguments and options, to 686 specify more of your debugging environment at the outset. 687 688 The command-line options described here are designed to cover a 689 variety of situations; in some environments, some of these options may 690 effectively be unavailable. 691 692 The most usual way to start GDB is with one argument, specifying an 693 executable program: 694 695 gdb PROGRAM 696 697 You can also start with both an executable program and a core file 698 specified: 699 700 gdb PROGRAM CORE 701 702 You can, instead, specify a process ID as a second argument, if you 703 want to debug a running process: 704 705 gdb PROGRAM 1234 706 707 would attach GDB to process `1234' (unless you also have a file named 708 `1234'; GDB does check for a core file first). 709 710 Taking advantage of the second command-line argument requires a 711 fairly complete operating system; when you use GDB as a remote debugger 712 attached to a bare board, there may not be any notion of "process", and 713 there is often no way to get a core dump. GDB will warn you if it is 714 unable to attach or to read core dumps. 715 716 You can optionally have `gdb' pass any arguments after the 717 executable file to the inferior using `--args'. This option stops 718 option processing. 719 gdb --args gcc -O2 -c foo.c 720 This will cause `gdb' to debug `gcc', and to set `gcc''s 721 command-line arguments (*note Arguments::) to `-O2 -c foo.c'. 722 723 You can run `gdb' without printing the front material, which 724 describes GDB's non-warranty, by specifying `-silent': 725 726 gdb -silent 727 728 You can further control how GDB starts up by using command-line 729 options. GDB itself can remind you of the options available. 730 731 Type 732 733 gdb -help 734 735 to display all available options and briefly describe their use (`gdb 736 -h' is a shorter equivalent). 737 738 All options and command line arguments you give are processed in 739 sequential order. The order makes a difference when the `-x' option is 740 used. 741 742 * Menu: 743 744 * File Options:: Choosing files 745 * Mode Options:: Choosing modes 746 * Startup:: What GDB does during startup 747 748 749 File: gdb.info, Node: File Options, Next: Mode Options, Up: Invoking GDB 750 751 2.1.1 Choosing Files 752 -------------------- 753 754 When GDB starts, it reads any arguments other than options as 755 specifying an executable file and core file (or process ID). This is 756 the same as if the arguments were specified by the `-se' and `-c' (or 757 `-p') options respectively. (GDB reads the first argument that does 758 not have an associated option flag as equivalent to the `-se' option 759 followed by that argument; and the second argument that does not have 760 an associated option flag, if any, as equivalent to the `-c'/`-p' 761 option followed by that argument.) If the second argument begins with 762 a decimal digit, GDB will first attempt to attach to it as a process, 763 and if that fails, attempt to open it as a corefile. If you have a 764 corefile whose name begins with a digit, you can prevent GDB from 765 treating it as a pid by prefixing it with `./', e.g. `./12345'. 766 767 If GDB has not been configured to included core file support, such 768 as for most embedded targets, then it will complain about a second 769 argument and ignore it. 770 771 Many options have both long and short forms; both are shown in the 772 following list. GDB also recognizes the long forms if you truncate 773 them, so long as enough of the option is present to be unambiguous. 774 (If you prefer, you can flag option arguments with `--' rather than 775 `-', though we illustrate the more usual convention.) 776 777 `-symbols FILE' 778 `-s FILE' 779 Read symbol table from file FILE. 780 781 `-exec FILE' 782 `-e FILE' 783 Use file FILE as the executable file to execute when appropriate, 784 and for examining pure data in conjunction with a core dump. 785 786 `-se FILE' 787 Read symbol table from file FILE and use it as the executable file. 788 789 `-core FILE' 790 `-c FILE' 791 Use file FILE as a core dump to examine. 792 793 `-pid NUMBER' 794 `-p NUMBER' 795 Connect to process ID NUMBER, as with the `attach' command. 796 797 `-command FILE' 798 `-x FILE' 799 Execute commands from file FILE. The contents of this file is 800 evaluated exactly as the `source' command would. *Note Command 801 files: Command Files. 802 803 `-eval-command COMMAND' 804 `-ex COMMAND' 805 Execute a single GDB command. 806 807 This option may be used multiple times to call multiple commands. 808 It may also be interleaved with `-command' as required. 809 810 gdb -ex 'target sim' -ex 'load' \ 811 -x setbreakpoints -ex 'run' a.out 812 813 `-directory DIRECTORY' 814 `-d DIRECTORY' 815 Add DIRECTORY to the path to search for source and script files. 816 817 `-r' 818 `-readnow' 819 Read each symbol file's entire symbol table immediately, rather 820 than the default, which is to read it incrementally as it is 821 needed. This makes startup slower, but makes future operations 822 faster. 823 824 825 826 File: gdb.info, Node: Mode Options, Next: Startup, Prev: File Options, Up: Invoking GDB 827 828 2.1.2 Choosing Modes 829 -------------------- 830 831 You can run GDB in various alternative modes--for example, in batch 832 mode or quiet mode. 833 834 `-nx' 835 `-n' 836 Do not execute commands found in any initialization files. 837 Normally, GDB executes the commands in these files after all the 838 command options and arguments have been processed. *Note Command 839 Files: Command Files. 840 841 `-quiet' 842 `-silent' 843 `-q' 844 "Quiet". Do not print the introductory and copyright messages. 845 These messages are also suppressed in batch mode. 846 847 `-batch' 848 Run in batch mode. Exit with status `0' after processing all the 849 command files specified with `-x' (and all commands from 850 initialization files, if not inhibited with `-n'). Exit with 851 nonzero status if an error occurs in executing the GDB commands in 852 the command files. Batch mode also disables pagination, sets 853 unlimited terminal width and height *note Screen Size::, and acts 854 as if `set confirm off' were in effect (*note Messages/Warnings::). 855 856 Batch mode may be useful for running GDB as a filter, for example 857 to download and run a program on another computer; in order to 858 make this more useful, the message 859 860 Program exited normally. 861 862 (which is ordinarily issued whenever a program running under GDB 863 control terminates) is not issued when running in batch mode. 864 865 `-batch-silent' 866 Run in batch mode exactly like `-batch', but totally silently. All 867 GDB output to `stdout' is prevented (`stderr' is unaffected). 868 This is much quieter than `-silent' and would be useless for an 869 interactive session. 870 871 This is particularly useful when using targets that give `Loading 872 section' messages, for example. 873 874 Note that targets that give their output via GDB, as opposed to 875 writing directly to `stdout', will also be made silent. 876 877 `-return-child-result' 878 The return code from GDB will be the return code from the child 879 process (the process being debugged), with the following 880 exceptions: 881 882 * GDB exits abnormally. E.g., due to an incorrect argument or 883 an internal error. In this case the exit code is the same as 884 it would have been without `-return-child-result'. 885 886 * The user quits with an explicit value. E.g., `quit 1'. 887 888 * The child process never runs, or is not allowed to terminate, 889 in which case the exit code will be -1. 890 891 This option is useful in conjunction with `-batch' or 892 `-batch-silent', when GDB is being used as a remote program loader 893 or simulator interface. 894 895 `-nowindows' 896 `-nw' 897 "No windows". If GDB comes with a graphical user interface (GUI) 898 built in, then this option tells GDB to only use the command-line 899 interface. If no GUI is available, this option has no effect. 900 901 `-windows' 902 `-w' 903 If GDB includes a GUI, then this option requires it to be used if 904 possible. 905 906 `-cd DIRECTORY' 907 Run GDB using DIRECTORY as its working directory, instead of the 908 current directory. 909 910 `-data-directory DIRECTORY' 911 Run GDB using DIRECTORY as its data directory. The data directory 912 is where GDB searches for its auxiliary files. *Note Data Files::. 913 914 `-fullname' 915 `-f' 916 GNU Emacs sets this option when it runs GDB as a subprocess. It 917 tells GDB to output the full file name and line number in a 918 standard, recognizable fashion each time a stack frame is 919 displayed (which includes each time your program stops). This 920 recognizable format looks like two `\032' characters, followed by 921 the file name, line number and character position separated by 922 colons, and a newline. The Emacs-to-GDB interface program uses 923 the two `\032' characters as a signal to display the source code 924 for the frame. 925 926 `-epoch' 927 The Epoch Emacs-GDB interface sets this option when it runs GDB as 928 a subprocess. It tells GDB to modify its print routines so as to 929 allow Epoch to display values of expressions in a separate window. 930 931 `-annotate LEVEL' 932 This option sets the "annotation level" inside GDB. Its effect is 933 identical to using `set annotate LEVEL' (*note Annotations::). 934 The annotation LEVEL controls how much information GDB prints 935 together with its prompt, values of expressions, source lines, and 936 other types of output. Level 0 is the normal, level 1 is for use 937 when GDB is run as a subprocess of GNU Emacs, level 3 is the 938 maximum annotation suitable for programs that control GDB, and 939 level 2 has been deprecated. 940 941 The annotation mechanism has largely been superseded by GDB/MI 942 (*note GDB/MI::). 943 944 `--args' 945 Change interpretation of command line so that arguments following 946 the executable file are passed as command line arguments to the 947 inferior. This option stops option processing. 948 949 `-baud BPS' 950 `-b BPS' 951 Set the line speed (baud rate or bits per second) of any serial 952 interface used by GDB for remote debugging. 953 954 `-l TIMEOUT' 955 Set the timeout (in seconds) of any communication used by GDB for 956 remote debugging. 957 958 `-tty DEVICE' 959 `-t DEVICE' 960 Run using DEVICE for your program's standard input and output. 961 962 `-tui' 963 Activate the "Text User Interface" when starting. The Text User 964 Interface manages several text windows on the terminal, showing 965 source, assembly, registers and GDB command outputs (*note GDB 966 Text User Interface: TUI.). Alternatively, the Text User 967 Interface can be enabled by invoking the program `gdbtui'. Do not 968 use this option if you run GDB from Emacs (*note Using GDB under 969 GNU Emacs: Emacs.). 970 971 `-interpreter INTERP' 972 Use the interpreter INTERP for interface with the controlling 973 program or device. This option is meant to be set by programs 974 which communicate with GDB using it as a back end. *Note Command 975 Interpreters: Interpreters. 976 977 `--interpreter=mi' (or `--interpreter=mi2') causes GDB to use the 978 "GDB/MI interface" (*note The GDB/MI Interface: GDB/MI.) included 979 since GDB version 6.0. The previous GDB/MI interface, included in 980 GDB version 5.3 and selected with `--interpreter=mi1', is 981 deprecated. Earlier GDB/MI interfaces are no longer supported. 982 983 `-write' 984 Open the executable and core files for both reading and writing. 985 This is equivalent to the `set write on' command inside GDB (*note 986 Patching::). 987 988 `-statistics' 989 This option causes GDB to print statistics about time and memory 990 usage after it completes each command and returns to the prompt. 991 992 `-version' 993 This option causes GDB to print its version number and no-warranty 994 blurb, and exit. 995 996 `-disable-gdb-index' 997 This option causes GDB to avoid using the `.gdb_index' ELF 998 section, even if present in the executable or a shared library. 999 This section improves the speed of loading of debug information. 1000 This option is present as an escape hatch in case there is a 1001 problem with the contents of this section. 1002 1003 1004 1005 File: gdb.info, Node: Startup, Prev: Mode Options, Up: Invoking GDB 1006 1007 2.1.3 What GDB Does During Startup 1008 ---------------------------------- 1009 1010 Here's the description of what GDB does during session startup: 1011 1012 1. Sets up the command interpreter as specified by the command line 1013 (*note interpreter: Mode Options.). 1014 1015 2. Reads the system-wide "init file" (if `--with-system-gdbinit' was 1016 used when building GDB; *note System-wide configuration and 1017 settings: System-wide configuration.) and executes all the 1018 commands in that file. 1019 1020 3. Reads the init file (if any) in your home directory(1) and 1021 executes all the commands in that file. 1022 1023 4. Processes command line options and operands. 1024 1025 5. Reads and executes the commands from init file (if any) in the 1026 current working directory. This is only done if the current 1027 directory is different from your home directory. Thus, you can 1028 have more than one init file, one generic in your home directory, 1029 and another, specific to the program you are debugging, in the 1030 directory where you invoke GDB. 1031 1032 6. If the command line specified a program to debug, or a process to 1033 attach to, or a core file, GDB loads any auto-loaded scripts 1034 provided for the program or for its loaded shared libraries. 1035 *Note Auto-loading::. 1036 1037 If you wish to disable the auto-loading during startup, you must 1038 do something like the following: 1039 1040 $ gdb -ex "set auto-load-scripts off" -ex "file myprogram" 1041 1042 The following does not work because the auto-loading is turned off 1043 too late: 1044 1045 $ gdb -ex "set auto-load-scripts off" myprogram 1046 1047 7. Reads command files specified by the `-x' option. *Note Command 1048 Files::, for more details about GDB command files. 1049 1050 8. Reads the command history recorded in the "history file". *Note 1051 Command History::, for more details about the command history and 1052 the files where GDB records it. 1053 1054 Init files use the same syntax as "command files" (*note Command 1055 Files::) and are processed by GDB in the same way. The init file in 1056 your home directory can set options (such as `set complaints') that 1057 affect subsequent processing of command line options and operands. 1058 Init files are not executed if you use the `-nx' option (*note Choosing 1059 Modes: Mode Options.). 1060 1061 To display the list of init files loaded by gdb at startup, you can 1062 use `gdb --help'. 1063 1064 The GDB init files are normally called `.gdbinit'. The DJGPP port 1065 of GDB uses the name `gdb.ini', due to the limitations of file names 1066 imposed by DOS filesystems. The Windows ports of GDB use the standard 1067 name, but if they find a `gdb.ini' file, they warn you about that and 1068 suggest to rename the file to the standard name. 1069 1070 ---------- Footnotes ---------- 1071 1072 (1) On DOS/Windows systems, the home directory is the one pointed to 1073 by the `HOME' environment variable. 1074 1075 1076 File: gdb.info, Node: Quitting GDB, Next: Shell Commands, Prev: Invoking GDB, Up: Invocation 1077 1078 2.2 Quitting GDB 1079 ================ 1080 1081 `quit [EXPRESSION]' 1082 `q' 1083 To exit GDB, use the `quit' command (abbreviated `q'), or type an 1084 end-of-file character (usually `Ctrl-d'). If you do not supply 1085 EXPRESSION, GDB will terminate normally; otherwise it will 1086 terminate using the result of EXPRESSION as the error code. 1087 1088 An interrupt (often `Ctrl-c') does not exit from GDB, but rather 1089 terminates the action of any GDB command that is in progress and 1090 returns to GDB command level. It is safe to type the interrupt 1091 character at any time because GDB does not allow it to take effect 1092 until a time when it is safe. 1093 1094 If you have been using GDB to control an attached process or device, 1095 you can release it with the `detach' command (*note Debugging an 1096 Already-running Process: Attach.). 1097 1098 1099 File: gdb.info, Node: Shell Commands, Next: Logging Output, Prev: Quitting GDB, Up: Invocation 1100 1101 2.3 Shell Commands 1102 ================== 1103 1104 If you need to execute occasional shell commands during your debugging 1105 session, there is no need to leave or suspend GDB; you can just use the 1106 `shell' command. 1107 1108 `shell COMMAND STRING' 1109 Invoke a standard shell to execute COMMAND STRING. If it exists, 1110 the environment variable `SHELL' determines which shell to run. 1111 Otherwise GDB uses the default shell (`/bin/sh' on Unix systems, 1112 `COMMAND.COM' on MS-DOS, etc.). 1113 1114 The utility `make' is often needed in development environments. You 1115 do not have to use the `shell' command for this purpose in GDB: 1116 1117 `make MAKE-ARGS' 1118 Execute the `make' program with the specified arguments. This is 1119 equivalent to `shell make MAKE-ARGS'. 1120 1121 1122 File: gdb.info, Node: Logging Output, Prev: Shell Commands, Up: Invocation 1123 1124 2.4 Logging Output 1125 ================== 1126 1127 You may want to save the output of GDB commands to a file. There are 1128 several commands to control GDB's logging. 1129 1130 `set logging on' 1131 Enable logging. 1132 1133 `set logging off' 1134 Disable logging. 1135 1136 `set logging file FILE' 1137 Change the name of the current logfile. The default logfile is 1138 `gdb.txt'. 1139 1140 `set logging overwrite [on|off]' 1141 By default, GDB will append to the logfile. Set `overwrite' if 1142 you want `set logging on' to overwrite the logfile instead. 1143 1144 `set logging redirect [on|off]' 1145 By default, GDB output will go to both the terminal and the 1146 logfile. Set `redirect' if you want output to go only to the log 1147 file. 1148 1149 `show logging' 1150 Show the current values of the logging settings. 1151 1152 1153 File: gdb.info, Node: Commands, Next: Running, Prev: Invocation, Up: Top 1154 1155 3 GDB Commands 1156 ************** 1157 1158 You can abbreviate a GDB command to the first few letters of the command 1159 name, if that abbreviation is unambiguous; and you can repeat certain 1160 GDB commands by typing just <RET>. You can also use the <TAB> key to 1161 get GDB to fill out the rest of a word in a command (or to show you the 1162 alternatives available, if there is more than one possibility). 1163 1164 * Menu: 1165 1166 * Command Syntax:: How to give commands to GDB 1167 * Completion:: Command completion 1168 * Help:: How to ask GDB for help 1169 1170 1171 File: gdb.info, Node: Command Syntax, Next: Completion, Up: Commands 1172 1173 3.1 Command Syntax 1174 ================== 1175 1176 A GDB command is a single line of input. There is no limit on how long 1177 it can be. It starts with a command name, which is followed by 1178 arguments whose meaning depends on the command name. For example, the 1179 command `step' accepts an argument which is the number of times to 1180 step, as in `step 5'. You can also use the `step' command with no 1181 arguments. Some commands do not allow any arguments. 1182 1183 GDB command names may always be truncated if that abbreviation is 1184 unambiguous. Other possible command abbreviations are listed in the 1185 documentation for individual commands. In some cases, even ambiguous 1186 abbreviations are allowed; for example, `s' is specially defined as 1187 equivalent to `step' even though there are other commands whose names 1188 start with `s'. You can test abbreviations by using them as arguments 1189 to the `help' command. 1190 1191 A blank line as input to GDB (typing just <RET>) means to repeat the 1192 previous command. Certain commands (for example, `run') will not 1193 repeat this way; these are commands whose unintentional repetition 1194 might cause trouble and which you are unlikely to want to repeat. 1195 User-defined commands can disable this feature; see *note dont-repeat: 1196 Define. 1197 1198 The `list' and `x' commands, when you repeat them with <RET>, 1199 construct new arguments rather than repeating exactly as typed. This 1200 permits easy scanning of source or memory. 1201 1202 GDB can also use <RET> in another way: to partition lengthy output, 1203 in a way similar to the common utility `more' (*note Screen Size: 1204 Screen Size.). Since it is easy to press one <RET> too many in this 1205 situation, GDB disables command repetition after any command that 1206 generates this sort of display. 1207 1208 Any text from a `#' to the end of the line is a comment; it does 1209 nothing. This is useful mainly in command files (*note Command Files: 1210 Command Files.). 1211 1212 The `Ctrl-o' binding is useful for repeating a complex sequence of 1213 commands. This command accepts the current line, like <RET>, and then 1214 fetches the next line relative to the current line from the history for 1215 editing. 1216 1217 1218 File: gdb.info, Node: Completion, Next: Help, Prev: Command Syntax, Up: Commands 1219 1220 3.2 Command Completion 1221 ====================== 1222 1223 GDB can fill in the rest of a word in a command for you, if there is 1224 only one possibility; it can also show you what the valid possibilities 1225 are for the next word in a command, at any time. This works for GDB 1226 commands, GDB subcommands, and the names of symbols in your program. 1227 1228 Press the <TAB> key whenever you want GDB to fill out the rest of a 1229 word. If there is only one possibility, GDB fills in the word, and 1230 waits for you to finish the command (or press <RET> to enter it). For 1231 example, if you type 1232 1233 (gdb) info bre <TAB> 1234 1235 GDB fills in the rest of the word `breakpoints', since that is the only 1236 `info' subcommand beginning with `bre': 1237 1238 (gdb) info breakpoints 1239 1240 You can either press <RET> at this point, to run the `info breakpoints' 1241 command, or backspace and enter something else, if `breakpoints' does 1242 not look like the command you expected. (If you were sure you wanted 1243 `info breakpoints' in the first place, you might as well just type 1244 <RET> immediately after `info bre', to exploit command abbreviations 1245 rather than command completion). 1246 1247 If there is more than one possibility for the next word when you 1248 press <TAB>, GDB sounds a bell. You can either supply more characters 1249 and try again, or just press <TAB> a second time; GDB displays all the 1250 possible completions for that word. For example, you might want to set 1251 a breakpoint on a subroutine whose name begins with `make_', but when 1252 you type `b make_<TAB>' GDB just sounds the bell. Typing <TAB> again 1253 displays all the function names in your program that begin with those 1254 characters, for example: 1255 1256 (gdb) b make_ <TAB> 1257 GDB sounds bell; press <TAB> again, to see: 1258 make_a_section_from_file make_environ 1259 make_abs_section make_function_type 1260 make_blockvector make_pointer_type 1261 make_cleanup make_reference_type 1262 make_command make_symbol_completion_list 1263 (gdb) b make_ 1264 1265 After displaying the available possibilities, GDB copies your partial 1266 input (`b make_' in the example) so you can finish the command. 1267 1268 If you just want to see the list of alternatives in the first place, 1269 you can press `M-?' rather than pressing <TAB> twice. `M-?' means 1270 `<META> ?'. You can type this either by holding down a key designated 1271 as the <META> shift on your keyboard (if there is one) while typing 1272 `?', or as <ESC> followed by `?'. 1273 1274 Sometimes the string you need, while logically a "word", may contain 1275 parentheses or other characters that GDB normally excludes from its 1276 notion of a word. To permit word completion to work in this situation, 1277 you may enclose words in `'' (single quote marks) in GDB commands. 1278 1279 The most likely situation where you might need this is in typing the 1280 name of a C++ function. This is because C++ allows function 1281 overloading (multiple definitions of the same function, distinguished 1282 by argument type). For example, when you want to set a breakpoint you 1283 may need to distinguish whether you mean the version of `name' that 1284 takes an `int' parameter, `name(int)', or the version that takes a 1285 `float' parameter, `name(float)'. To use the word-completion 1286 facilities in this situation, type a single quote `'' at the beginning 1287 of the function name. This alerts GDB that it may need to consider 1288 more information than usual when you press <TAB> or `M-?' to request 1289 word completion: 1290 1291 (gdb) b 'bubble( M-? 1292 bubble(double,double) bubble(int,int) 1293 (gdb) b 'bubble( 1294 1295 In some cases, GDB can tell that completing a name requires using 1296 quotes. When this happens, GDB inserts the quote for you (while 1297 completing as much as it can) if you do not type the quote in the first 1298 place: 1299 1300 (gdb) b bub <TAB> 1301 GDB alters your input line to the following, and rings a bell: 1302 (gdb) b 'bubble( 1303 1304 In general, GDB can tell that a quote is needed (and inserts it) if you 1305 have not yet started typing the argument list when you ask for 1306 completion on an overloaded symbol. 1307 1308 For more information about overloaded functions, see *note C++ 1309 Expressions: C Plus Plus Expressions. You can use the command `set 1310 overload-resolution off' to disable overload resolution; see *note GDB 1311 Features for C++: Debugging C Plus Plus. 1312 1313 When completing in an expression which looks up a field in a 1314 structure, GDB also tries(1) to limit completions to the field names 1315 available in the type of the left-hand-side: 1316 1317 (gdb) p gdb_stdout.M-? 1318 magic to_delete to_fputs to_put to_rewind 1319 to_data to_flush to_isatty to_read to_write 1320 1321 This is because the `gdb_stdout' is a variable of the type `struct 1322 ui_file' that is defined in GDB sources as follows: 1323 1324 struct ui_file 1325 { 1326 int *magic; 1327 ui_file_flush_ftype *to_flush; 1328 ui_file_write_ftype *to_write; 1329 ui_file_fputs_ftype *to_fputs; 1330 ui_file_read_ftype *to_read; 1331 ui_file_delete_ftype *to_delete; 1332 ui_file_isatty_ftype *to_isatty; 1333 ui_file_rewind_ftype *to_rewind; 1334 ui_file_put_ftype *to_put; 1335 void *to_data; 1336 } 1337 1338 ---------- Footnotes ---------- 1339 1340 (1) The completer can be confused by certain kinds of invalid 1341 expressions. Also, it only examines the static type of the expression, 1342 not the dynamic type. 1343 1344 1345 File: gdb.info, Node: Help, Prev: Completion, Up: Commands 1346 1347 3.3 Getting Help 1348 ================ 1349 1350 You can always ask GDB itself for information on its commands, using 1351 the command `help'. 1352 1353 `help' 1354 `h' 1355 You can use `help' (abbreviated `h') with no arguments to display 1356 a short list of named classes of commands: 1357 1358 (gdb) help 1359 List of classes of commands: 1360 1361 aliases -- Aliases of other commands 1362 breakpoints -- Making program stop at certain points 1363 data -- Examining data 1364 files -- Specifying and examining files 1365 internals -- Maintenance commands 1366 obscure -- Obscure features 1367 running -- Running the program 1368 stack -- Examining the stack 1369 status -- Status inquiries 1370 support -- Support facilities 1371 tracepoints -- Tracing of program execution without 1372 stopping the program 1373 user-defined -- User-defined commands 1374 1375 Type "help" followed by a class name for a list of 1376 commands in that class. 1377 Type "help" followed by command name for full 1378 documentation. 1379 Command name abbreviations are allowed if unambiguous. 1380 (gdb) 1381 1382 `help CLASS' 1383 Using one of the general help classes as an argument, you can get a 1384 list of the individual commands in that class. For example, here 1385 is the help display for the class `status': 1386 1387 (gdb) help status 1388 Status inquiries. 1389 1390 List of commands: 1391 1392 info -- Generic command for showing things 1393 about the program being debugged 1394 show -- Generic command for showing things 1395 about the debugger 1396 1397 Type "help" followed by command name for full 1398 documentation. 1399 Command name abbreviations are allowed if unambiguous. 1400 (gdb) 1401 1402 `help COMMAND' 1403 With a command name as `help' argument, GDB displays a short 1404 paragraph on how to use that command. 1405 1406 `apropos ARGS' 1407 The `apropos' command searches through all of the GDB commands, 1408 and their documentation, for the regular expression specified in 1409 ARGS. It prints out all matches found. For example: 1410 1411 apropos reload 1412 1413 results in: 1414 1415 set symbol-reloading -- Set dynamic symbol table reloading 1416 multiple times in one run 1417 show symbol-reloading -- Show dynamic symbol table reloading 1418 multiple times in one run 1419 1420 `complete ARGS' 1421 The `complete ARGS' command lists all the possible completions for 1422 the beginning of a command. Use ARGS to specify the beginning of 1423 the command you want completed. For example: 1424 1425 complete i 1426 1427 results in: 1428 1429 if 1430 ignore 1431 info 1432 inspect 1433 1434 This is intended for use by GNU Emacs. 1435 1436 In addition to `help', you can use the GDB commands `info' and 1437 `show' to inquire about the state of your program, or the state of GDB 1438 itself. Each command supports many topics of inquiry; this manual 1439 introduces each of them in the appropriate context. The listings under 1440 `info' and under `show' in the Index point to all the sub-commands. 1441 *Note Index::. 1442 1443 `info' 1444 This command (abbreviated `i') is for describing the state of your 1445 program. For example, you can show the arguments passed to a 1446 function with `info args', list the registers currently in use 1447 with `info registers', or list the breakpoints you have set with 1448 `info breakpoints'. You can get a complete list of the `info' 1449 sub-commands with `help info'. 1450 1451 `set' 1452 You can assign the result of an expression to an environment 1453 variable with `set'. For example, you can set the GDB prompt to a 1454 $-sign with `set prompt $'. 1455 1456 `show' 1457 In contrast to `info', `show' is for describing the state of GDB 1458 itself. You can change most of the things you can `show', by 1459 using the related command `set'; for example, you can control what 1460 number system is used for displays with `set radix', or simply 1461 inquire which is currently in use with `show radix'. 1462 1463 To display all the settable parameters and their current values, 1464 you can use `show' with no arguments; you may also use `info set'. 1465 Both commands produce the same display. 1466 1467 Here are three miscellaneous `show' subcommands, all of which are 1468 exceptional in lacking corresponding `set' commands: 1469 1470 `show version' 1471 Show what version of GDB is running. You should include this 1472 information in GDB bug-reports. If multiple versions of GDB are 1473 in use at your site, you may need to determine which version of 1474 GDB you are running; as GDB evolves, new commands are introduced, 1475 and old ones may wither away. Also, many system vendors ship 1476 variant versions of GDB, and there are variant versions of GDB in 1477 GNU/Linux distributions as well. The version number is the same 1478 as the one announced when you start GDB. 1479 1480 `show copying' 1481 `info copying' 1482 Display information about permission for copying GDB. 1483 1484 `show warranty' 1485 `info warranty' 1486 Display the GNU "NO WARRANTY" statement, or a warranty, if your 1487 version of GDB comes with one. 1488 1489 1490 1491 File: gdb.info, Node: Running, Next: Stopping, Prev: Commands, Up: Top 1492 1493 4 Running Programs Under GDB 1494 **************************** 1495 1496 When you run a program under GDB, you must first generate debugging 1497 information when you compile it. 1498 1499 You may start GDB with its arguments, if any, in an environment of 1500 your choice. If you are doing native debugging, you may redirect your 1501 program's input and output, debug an already running process, or kill a 1502 child process. 1503 1504 * Menu: 1505 1506 * Compilation:: Compiling for debugging 1507 * Starting:: Starting your program 1508 * Arguments:: Your program's arguments 1509 * Environment:: Your program's environment 1510 1511 * Working Directory:: Your program's working directory 1512 * Input/Output:: Your program's input and output 1513 * Attach:: Debugging an already-running process 1514 * Kill Process:: Killing the child process 1515 1516 * Inferiors and Programs:: Debugging multiple inferiors and programs 1517 * Threads:: Debugging programs with multiple threads 1518 * Forks:: Debugging forks 1519 * Checkpoint/Restart:: Setting a _bookmark_ to return to later 1520 1521 1522 File: gdb.info, Node: Compilation, Next: Starting, Up: Running 1523 1524 4.1 Compiling for Debugging 1525 =========================== 1526 1527 In order to debug a program effectively, you need to generate debugging 1528 information when you compile it. This debugging information is stored 1529 in the object file; it describes the data type of each variable or 1530 function and the correspondence between source line numbers and 1531 addresses in the executable code. 1532 1533 To request debugging information, specify the `-g' option when you 1534 run the compiler. 1535 1536 Programs that are to be shipped to your customers are compiled with 1537 optimizations, using the `-O' compiler option. However, some compilers 1538 are unable to handle the `-g' and `-O' options together. Using those 1539 compilers, you cannot generate optimized executables containing 1540 debugging information. 1541 1542 GCC, the GNU C/C++ compiler, supports `-g' with or without `-O', 1543 making it possible to debug optimized code. We recommend that you 1544 _always_ use `-g' whenever you compile a program. You may think your 1545 program is correct, but there is no sense in pushing your luck. For 1546 more information, see *note Optimized Code::. 1547 1548 Older versions of the GNU C compiler permitted a variant option 1549 `-gg' for debugging information. GDB no longer supports this format; 1550 if your GNU C compiler has this option, do not use it. 1551 1552 GDB knows about preprocessor macros and can show you their expansion 1553 (*note Macros::). Most compilers do not include information about 1554 preprocessor macros in the debugging information if you specify the 1555 `-g' flag alone, because this information is rather large. Version 3.1 1556 and later of GCC, the GNU C compiler, provides macro information if you 1557 specify the options `-gdwarf-2' and `-g3'; the former option requests 1558 debugging information in the Dwarf 2 format, and the latter requests 1559 "extra information". In the future, we hope to find more compact ways 1560 to represent macro information, so that it can be included with `-g' 1561 alone. 1562 1563 1564 File: gdb.info, Node: Starting, Next: Arguments, Prev: Compilation, Up: Running 1565 1566 4.2 Starting your Program 1567 ========================= 1568 1569 `run' 1570 `r' 1571 Use the `run' command to start your program under GDB. You must 1572 first specify the program name (except on VxWorks) with an 1573 argument to GDB (*note Getting In and Out of GDB: Invocation.), or 1574 by using the `file' or `exec-file' command (*note Commands to 1575 Specify Files: Files.). 1576 1577 1578 If you are running your program in an execution environment that 1579 supports processes, `run' creates an inferior process and makes that 1580 process run your program. In some environments without processes, 1581 `run' jumps to the start of your program. Other targets, like 1582 `remote', are always running. If you get an error message like this 1583 one: 1584 1585 The "remote" target does not support "run". 1586 Try "help target" or "continue". 1587 1588 then use `continue' to run your program. You may need `load' first 1589 (*note load::). 1590 1591 The execution of a program is affected by certain information it 1592 receives from its superior. GDB provides ways to specify this 1593 information, which you must do _before_ starting your program. (You 1594 can change it after starting your program, but such changes only affect 1595 your program the next time you start it.) This information may be 1596 divided into four categories: 1597 1598 The _arguments._ 1599 Specify the arguments to give your program as the arguments of the 1600 `run' command. If a shell is available on your target, the shell 1601 is used to pass the arguments, so that you may use normal 1602 conventions (such as wildcard expansion or variable substitution) 1603 in describing the arguments. In Unix systems, you can control 1604 which shell is used with the `SHELL' environment variable. *Note 1605 Your Program's Arguments: Arguments. 1606 1607 The _environment._ 1608 Your program normally inherits its environment from GDB, but you 1609 can use the GDB commands `set environment' and `unset environment' 1610 to change parts of the environment that affect your program. 1611 *Note Your Program's Environment: Environment. 1612 1613 The _working directory._ 1614 Your program inherits its working directory from GDB. You can set 1615 the GDB working directory with the `cd' command in GDB. *Note 1616 Your Program's Working Directory: Working Directory. 1617 1618 The _standard input and output._ 1619 Your program normally uses the same device for standard input and 1620 standard output as GDB is using. You can redirect input and output 1621 in the `run' command line, or you can use the `tty' command to set 1622 a different device for your program. *Note Your Program's Input 1623 and Output: Input/Output. 1624 1625 _Warning:_ While input and output redirection work, you cannot use 1626 pipes to pass the output of the program you are debugging to 1627 another program; if you attempt this, GDB is likely to wind up 1628 debugging the wrong program. 1629 1630 When you issue the `run' command, your program begins to execute 1631 immediately. *Note Stopping and Continuing: Stopping, for discussion 1632 of how to arrange for your program to stop. Once your program has 1633 stopped, you may call functions in your program, using the `print' or 1634 `call' commands. *Note Examining Data: Data. 1635 1636 If the modification time of your symbol file has changed since the 1637 last time GDB read its symbols, GDB discards its symbol table, and 1638 reads it again. When it does this, GDB tries to retain your current 1639 breakpoints. 1640 1641 `start' 1642 The name of the main procedure can vary from language to language. 1643 With C or C++, the main procedure name is always `main', but other 1644 languages such as Ada do not require a specific name for their 1645 main procedure. The debugger provides a convenient way to start 1646 the execution of the program and to stop at the beginning of the 1647 main procedure, depending on the language used. 1648 1649 The `start' command does the equivalent of setting a temporary 1650 breakpoint at the beginning of the main procedure and then invoking 1651 the `run' command. 1652 1653 Some programs contain an "elaboration" phase where some startup 1654 code is executed before the main procedure is called. This 1655 depends on the languages used to write your program. In C++, for 1656 instance, constructors for static and global objects are executed 1657 before `main' is called. It is therefore possible that the 1658 debugger stops before reaching the main procedure. However, the 1659 temporary breakpoint will remain to halt execution. 1660 1661 Specify the arguments to give to your program as arguments to the 1662 `start' command. These arguments will be given verbatim to the 1663 underlying `run' command. Note that the same arguments will be 1664 reused if no argument is provided during subsequent calls to 1665 `start' or `run'. 1666 1667 It is sometimes necessary to debug the program during elaboration. 1668 In these cases, using the `start' command would stop the execution 1669 of your program too late, as the program would have already 1670 completed the elaboration phase. Under these circumstances, 1671 insert breakpoints in your elaboration code before running your 1672 program. 1673 1674 `set exec-wrapper WRAPPER' 1675 `show exec-wrapper' 1676 `unset exec-wrapper' 1677 When `exec-wrapper' is set, the specified wrapper is used to 1678 launch programs for debugging. GDB starts your program with a 1679 shell command of the form `exec WRAPPER PROGRAM'. Quoting is 1680 added to PROGRAM and its arguments, but not to WRAPPER, so you 1681 should add quotes if appropriate for your shell. The wrapper runs 1682 until it executes your program, and then GDB takes control. 1683 1684 You can use any program that eventually calls `execve' with its 1685 arguments as a wrapper. Several standard Unix utilities do this, 1686 e.g. `env' and `nohup'. Any Unix shell script ending with `exec 1687 "$@"' will also work. 1688 1689 For example, you can use `env' to pass an environment variable to 1690 the debugged program, without setting the variable in your shell's 1691 environment: 1692 1693 (gdb) set exec-wrapper env 'LD_PRELOAD=libtest.so' 1694 (gdb) run 1695 1696 This command is available when debugging locally on most targets, 1697 excluding DJGPP, Cygwin, MS Windows, and QNX Neutrino. 1698 1699 `set disable-randomization' 1700 `set disable-randomization on' 1701 This option (enabled by default in GDB) will turn off the native 1702 randomization of the virtual address space of the started program. 1703 This option is useful for multiple debugging sessions to make the 1704 execution better reproducible and memory addresses reusable across 1705 debugging sessions. 1706 1707 This feature is implemented only on GNU/Linux. You can get the 1708 same behavior using 1709 1710 (gdb) set exec-wrapper setarch `uname -m` -R 1711 1712 `set disable-randomization off' 1713 Leave the behavior of the started executable unchanged. Some bugs 1714 rear their ugly heads only when the program is loaded at certain 1715 addresses. If your bug disappears when you run the program under 1716 GDB, that might be because GDB by default disables the address 1717 randomization on platforms, such as GNU/Linux, which do that for 1718 stand-alone programs. Use `set disable-randomization off' to try 1719 to reproduce such elusive bugs. 1720 1721 The virtual address space randomization is implemented only on 1722 GNU/Linux. It protects the programs against some kinds of 1723 security attacks. In these cases the attacker needs to know the 1724 exact location of a concrete executable code. Randomizing its 1725 location makes it impossible to inject jumps misusing a code at 1726 its expected addresses. 1727 1728 Prelinking shared libraries provides a startup performance 1729 advantage but it makes addresses in these libraries predictable 1730 for privileged processes by having just unprivileged access at the 1731 target system. Reading the shared library binary gives enough 1732 information for assembling the malicious code misusing it. Still 1733 even a prelinked shared library can get loaded at a new random 1734 address just requiring the regular relocation process during the 1735 startup. Shared libraries not already prelinked are always loaded 1736 at a randomly chosen address. 1737 1738 Position independent executables (PIE) contain position 1739 independent code similar to the shared libraries and therefore 1740 such executables get loaded at a randomly chosen address upon 1741 startup. PIE executables always load even already prelinked 1742 shared libraries at a random address. You can build such 1743 executable using `gcc -fPIE -pie'. 1744 1745 Heap (malloc storage), stack and custom mmap areas are always 1746 placed randomly (as long as the randomization is enabled). 1747 1748 `show disable-randomization' 1749 Show the current setting of the explicit disable of the native 1750 randomization of the virtual address space of the started program. 1751 1752 1753 1754 File: gdb.info, Node: Arguments, Next: Environment, Prev: Starting, Up: Running 1755 1756 4.3 Your Program's Arguments 1757 ============================ 1758 1759 The arguments to your program can be specified by the arguments of the 1760 `run' command. They are passed to a shell, which expands wildcard 1761 characters and performs redirection of I/O, and thence to your program. 1762 Your `SHELL' environment variable (if it exists) specifies what shell 1763 GDB uses. If you do not define `SHELL', GDB uses the default shell 1764 (`/bin/sh' on Unix). 1765 1766 On non-Unix systems, the program is usually invoked directly by GDB, 1767 which emulates I/O redirection via the appropriate system calls, and 1768 the wildcard characters are expanded by the startup code of the 1769 program, not by the shell. 1770 1771 `run' with no arguments uses the same arguments used by the previous 1772 `run', or those set by the `set args' command. 1773 1774 `set args' 1775 Specify the arguments to be used the next time your program is 1776 run. If `set args' has no arguments, `run' executes your program 1777 with no arguments. Once you have run your program with arguments, 1778 using `set args' before the next `run' is the only way to run it 1779 again without arguments. 1780 1781 `show args' 1782 Show the arguments to give your program when it is started. 1783 1784 1785 File: gdb.info, Node: Environment, Next: Working Directory, Prev: Arguments, Up: Running 1786 1787 4.4 Your Program's Environment 1788 ============================== 1789 1790 The "environment" consists of a set of environment variables and their 1791 values. Environment variables conventionally record such things as 1792 your user name, your home directory, your terminal type, and your search 1793 path for programs to run. Usually you set up environment variables with 1794 the shell and they are inherited by all the other programs you run. 1795 When debugging, it can be useful to try running your program with a 1796 modified environment without having to start GDB over again. 1797 1798 `path DIRECTORY' 1799 Add DIRECTORY to the front of the `PATH' environment variable (the 1800 search path for executables) that will be passed to your program. 1801 The value of `PATH' used by GDB does not change. You may specify 1802 several directory names, separated by whitespace or by a 1803 system-dependent separator character (`:' on Unix, `;' on MS-DOS 1804 and MS-Windows). If DIRECTORY is already in the path, it is moved 1805 to the front, so it is searched sooner. 1806 1807 You can use the string `$cwd' to refer to whatever is the current 1808 working directory at the time GDB searches the path. If you use 1809 `.' instead, it refers to the directory where you executed the 1810 `path' command. GDB replaces `.' in the DIRECTORY argument (with 1811 the current path) before adding DIRECTORY to the search path. 1812 1813 `show paths' 1814 Display the list of search paths for executables (the `PATH' 1815 environment variable). 1816 1817 `show environment [VARNAME]' 1818 Print the value of environment variable VARNAME to be given to 1819 your program when it starts. If you do not supply VARNAME, print 1820 the names and values of all environment variables to be given to 1821 your program. You can abbreviate `environment' as `env'. 1822 1823 `set environment VARNAME [=VALUE]' 1824 Set environment variable VARNAME to VALUE. The value changes for 1825 your program only, not for GDB itself. VALUE may be any string; 1826 the values of environment variables are just strings, and any 1827 interpretation is supplied by your program itself. The VALUE 1828 parameter is optional; if it is eliminated, the variable is set to 1829 a null value. 1830 1831 For example, this command: 1832 1833 set env USER = foo 1834 1835 tells the debugged program, when subsequently run, that its user 1836 is named `foo'. (The spaces around `=' are used for clarity here; 1837 they are not actually required.) 1838 1839 `unset environment VARNAME' 1840 Remove variable VARNAME from the environment to be passed to your 1841 program. This is different from `set env VARNAME ='; `unset 1842 environment' removes the variable from the environment, rather 1843 than assigning it an empty value. 1844 1845 _Warning:_ On Unix systems, GDB runs your program using the shell 1846 indicated by your `SHELL' environment variable if it exists (or 1847 `/bin/sh' if not). If your `SHELL' variable names a shell that runs an 1848 initialization file--such as `.cshrc' for C-shell, or `.bashrc' for 1849 BASH--any variables you set in that file affect your program. You may 1850 wish to move setting of environment variables to files that are only 1851 run when you sign on, such as `.login' or `.profile'. 1852 1853 1854 File: gdb.info, Node: Working Directory, Next: Input/Output, Prev: Environment, Up: Running 1855 1856 4.5 Your Program's Working Directory 1857 ==================================== 1858 1859 Each time you start your program with `run', it inherits its working 1860 directory from the current working directory of GDB. The GDB working 1861 directory is initially whatever it inherited from its parent process 1862 (typically the shell), but you can specify a new working directory in 1863 GDB with the `cd' command. 1864 1865 The GDB working directory also serves as a default for the commands 1866 that specify files for GDB to operate on. *Note Commands to Specify 1867 Files: Files. 1868 1869 `cd DIRECTORY' 1870 Set the GDB working directory to DIRECTORY. 1871 1872 `pwd' 1873 Print the GDB working directory. 1874 1875 It is generally impossible to find the current working directory of 1876 the process being debugged (since a program can change its directory 1877 during its run). If you work on a system where GDB is configured with 1878 the `/proc' support, you can use the `info proc' command (*note SVR4 1879 Process Information::) to find out the current working directory of the 1880 debuggee. 1881 1882 1883 File: gdb.info, Node: Input/Output, Next: Attach, Prev: Working Directory, Up: Running 1884 1885 4.6 Your Program's Input and Output 1886 =================================== 1887 1888 By default, the program you run under GDB does input and output to the 1889 same terminal that GDB uses. GDB switches the terminal to its own 1890 terminal modes to interact with you, but it records the terminal modes 1891 your program was using and switches back to them when you continue 1892 running your program. 1893 1894 `info terminal' 1895 Displays information recorded by GDB about the terminal modes your 1896 program is using. 1897 1898 You can redirect your program's input and/or output using shell 1899 redirection with the `run' command. For example, 1900 1901 run > outfile 1902 1903 starts your program, diverting its output to the file `outfile'. 1904 1905 Another way to specify where your program should do input and output 1906 is with the `tty' command. This command accepts a file name as 1907 argument, and causes this file to be the default for future `run' 1908 commands. It also resets the controlling terminal for the child 1909 process, for future `run' commands. For example, 1910 1911 tty /dev/ttyb 1912 1913 directs that processes started with subsequent `run' commands default 1914 to do input and output on the terminal `/dev/ttyb' and have that as 1915 their controlling terminal. 1916 1917 An explicit redirection in `run' overrides the `tty' command's 1918 effect on the input/output device, but not its effect on the controlling 1919 terminal. 1920 1921 When you use the `tty' command or redirect input in the `run' 1922 command, only the input _for your program_ is affected. The input for 1923 GDB still comes from your terminal. `tty' is an alias for `set 1924 inferior-tty'. 1925 1926 You can use the `show inferior-tty' command to tell GDB to display 1927 the name of the terminal that will be used for future runs of your 1928 program. 1929 1930 `set inferior-tty /dev/ttyb' 1931 Set the tty for the program being debugged to /dev/ttyb. 1932 1933 `show inferior-tty' 1934 Show the current tty for the program being debugged. 1935 1936 1937 File: gdb.info, Node: Attach, Next: Kill Process, Prev: Input/Output, Up: Running 1938 1939 4.7 Debugging an Already-running Process 1940 ======================================== 1941 1942 `attach PROCESS-ID' 1943 This command attaches to a running process--one that was started 1944 outside GDB. (`info files' shows your active targets.) The 1945 command takes as argument a process ID. The usual way to find out 1946 the PROCESS-ID of a Unix process is with the `ps' utility, or with 1947 the `jobs -l' shell command. 1948 1949 `attach' does not repeat if you press <RET> a second time after 1950 executing the command. 1951 1952 To use `attach', your program must be running in an environment 1953 which supports processes; for example, `attach' does not work for 1954 programs on bare-board targets that lack an operating system. You must 1955 also have permission to send the process a signal. 1956 1957 When you use `attach', the debugger finds the program running in the 1958 process first by looking in the current working directory, then (if the 1959 program is not found) by using the source file search path (*note 1960 Specifying Source Directories: Source Path.). You can also use the 1961 `file' command to load the program. *Note Commands to Specify Files: 1962 Files. 1963 1964 The first thing GDB does after arranging to debug the specified 1965 process is to stop it. You can examine and modify an attached process 1966 with all the GDB commands that are ordinarily available when you start 1967 processes with `run'. You can insert breakpoints; you can step and 1968 continue; you can modify storage. If you would rather the process 1969 continue running, you may use the `continue' command after attaching 1970 GDB to the process. 1971 1972 `detach' 1973 When you have finished debugging the attached process, you can use 1974 the `detach' command to release it from GDB control. Detaching 1975 the process continues its execution. After the `detach' command, 1976 that process and GDB become completely independent once more, and 1977 you are ready to `attach' another process or start one with `run'. 1978 `detach' does not repeat if you press <RET> again after executing 1979 the command. 1980 1981 If you exit GDB while you have an attached process, you detach that 1982 process. If you use the `run' command, you kill that process. By 1983 default, GDB asks for confirmation if you try to do either of these 1984 things; you can control whether or not you need to confirm by using the 1985 `set confirm' command (*note Optional Warnings and Messages: 1986 Messages/Warnings.). 1987 1988 1989 File: gdb.info, Node: Kill Process, Next: Inferiors and Programs, Prev: Attach, Up: Running 1990 1991 4.8 Killing the Child Process 1992 ============================= 1993 1994 `kill' 1995 Kill the child process in which your program is running under GDB. 1996 1997 This command is useful if you wish to debug a core dump instead of a 1998 running process. GDB ignores any core dump file while your program is 1999 running. 2000 2001 On some operating systems, a program cannot be executed outside GDB 2002 while you have breakpoints set on it inside GDB. You can use the 2003 `kill' command in this situation to permit running your program outside 2004 the debugger. 2005 2006 The `kill' command is also useful if you wish to recompile and 2007 relink your program, since on many systems it is impossible to modify an 2008 executable file while it is running in a process. In this case, when 2009 you next type `run', GDB notices that the file has changed, and reads 2010 the symbol table again (while trying to preserve your current 2011 breakpoint settings). 2012 2013 2014 File: gdb.info, Node: Inferiors and Programs, Next: Threads, Prev: Kill Process, Up: Running 2015 2016 4.9 Debugging Multiple Inferiors and Programs 2017 ============================================= 2018 2019 GDB lets you run and debug multiple programs in a single session. In 2020 addition, GDB on some systems may let you run several programs 2021 simultaneously (otherwise you have to exit from one before starting 2022 another). In the most general case, you can have multiple threads of 2023 execution in each of multiple processes, launched from multiple 2024 executables. 2025 2026 GDB represents the state of each program execution with an object 2027 called an "inferior". An inferior typically corresponds to a process, 2028 but is more general and applies also to targets that do not have 2029 processes. Inferiors may be created before a process runs, and may be 2030 retained after a process exits. Inferiors have unique identifiers that 2031 are different from process ids. Usually each inferior will also have 2032 its own distinct address space, although some embedded targets may have 2033 several inferiors running in different parts of a single address space. 2034 Each inferior may in turn have multiple threads running in it. 2035 2036 To find out what inferiors exist at any moment, use `info inferiors': 2037 2038 `info inferiors' 2039 Print a list of all inferiors currently being managed by GDB. 2040 2041 GDB displays for each inferior (in this order): 2042 2043 1. the inferior number assigned by GDB 2044 2045 2. the target system's inferior identifier 2046 2047 3. the name of the executable the inferior is running. 2048 2049 2050 An asterisk `*' preceding the GDB inferior number indicates the 2051 current inferior. 2052 2053 For example, 2054 2055 (gdb) info inferiors 2056 Num Description Executable 2057 2 process 2307 hello 2058 * 1 process 3401 goodbye 2059 2060 To switch focus between inferiors, use the `inferior' command: 2061 2062 `inferior INFNO' 2063 Make inferior number INFNO the current inferior. The argument 2064 INFNO is the inferior number assigned by GDB, as shown in the 2065 first field of the `info inferiors' display. 2066 2067 You can get multiple executables into a debugging session via the 2068 `add-inferior' and `clone-inferior' commands. On some systems GDB can 2069 add inferiors to the debug session automatically by following calls to 2070 `fork' and `exec'. To remove inferiors from the debugging session use 2071 the `remove-inferiors' command. 2072 2073 `add-inferior [ -copies N ] [ -exec EXECUTABLE ]' 2074 Adds N inferiors to be run using EXECUTABLE as the executable. N 2075 defaults to 1. If no executable is specified, the inferiors 2076 begins empty, with no program. You can still assign or change the 2077 program assigned to the inferior at any time by using the `file' 2078 command with the executable name as its argument. 2079 2080 `clone-inferior [ -copies N ] [ INFNO ]' 2081 Adds N inferiors ready to execute the same program as inferior 2082 INFNO. N defaults to 1. INFNO defaults to the number of the 2083 current inferior. This is a convenient command when you want to 2084 run another instance of the inferior you are debugging. 2085 2086 (gdb) info inferiors 2087 Num Description Executable 2088 * 1 process 29964 helloworld 2089 (gdb) clone-inferior 2090 Added inferior 2. 2091 1 inferiors added. 2092 (gdb) info inferiors 2093 Num Description Executable 2094 2 <null> helloworld 2095 * 1 process 29964 helloworld 2096 2097 You can now simply switch focus to inferior 2 and run it. 2098 2099 `remove-inferiors INFNO...' 2100 Removes the inferior or inferiors INFNO.... It is not possible to 2101 remove an inferior that is running with this command. For those, 2102 use the `kill' or `detach' command first. 2103 2104 2105 To quit debugging one of the running inferiors that is not the 2106 current inferior, you can either detach from it by using the 2107 `detach inferior' command (allowing it to run independently), or kill it 2108 using the `kill inferiors' command: 2109 2110 `detach inferior INFNO...' 2111 Detach from the inferior or inferiors identified by GDB inferior 2112 number(s) INFNO.... Note that the inferior's entry still stays on 2113 the list of inferiors shown by `info inferiors', but its 2114 Description will show `<null>'. 2115 2116 `kill inferiors INFNO...' 2117 Kill the inferior or inferiors identified by GDB inferior 2118 number(s) INFNO.... Note that the inferior's entry still stays on 2119 the list of inferiors shown by `info inferiors', but its 2120 Description will show `<null>'. 2121 2122 After the successful completion of a command such as `detach', 2123 `detach inferiors', `kill' or `kill inferiors', or after a normal 2124 process exit, the inferior is still valid and listed with `info 2125 inferiors', ready to be restarted. 2126 2127 To be notified when inferiors are started or exit under GDB's 2128 control use `set print inferior-events': 2129 2130 `set print inferior-events' 2131 `set print inferior-events on' 2132 `set print inferior-events off' 2133 The `set print inferior-events' command allows you to enable or 2134 disable printing of messages when GDB notices that new inferiors 2135 have started or that inferiors have exited or have been detached. 2136 By default, these messages will not be printed. 2137 2138 `show print inferior-events' 2139 Show whether messages will be printed when GDB detects that 2140 inferiors have started, exited or have been detached. 2141 2142 Many commands will work the same with multiple programs as with a 2143 single program: e.g., `print myglobal' will simply display the value of 2144 `myglobal' in the current inferior. 2145 2146 Occasionaly, when debugging GDB itself, it may be useful to get more 2147 info about the relationship of inferiors, programs, address spaces in a 2148 debug session. You can do that with the `maint info program-spaces' 2149 command. 2150 2151 `maint info program-spaces' 2152 Print a list of all program spaces currently being managed by GDB. 2153 2154 GDB displays for each program space (in this order): 2155 2156 1. the program space number assigned by GDB 2157 2158 2. the name of the executable loaded into the program space, 2159 with e.g., the `file' command. 2160 2161 2162 An asterisk `*' preceding the GDB program space number indicates 2163 the current program space. 2164 2165 In addition, below each program space line, GDB prints extra 2166 information that isn't suitable to display in tabular form. For 2167 example, the list of inferiors bound to the program space. 2168 2169 (gdb) maint info program-spaces 2170 Id Executable 2171 2 goodbye 2172 Bound inferiors: ID 1 (process 21561) 2173 * 1 hello 2174 2175 Here we can see that no inferior is running the program `hello', 2176 while `process 21561' is running the program `goodbye'. On some 2177 targets, it is possible that multiple inferiors are bound to the 2178 same program space. The most common example is that of debugging 2179 both the parent and child processes of a `vfork' call. For 2180 example, 2181 2182 (gdb) maint info program-spaces 2183 Id Executable 2184 * 1 vfork-test 2185 Bound inferiors: ID 2 (process 18050), ID 1 (process 18045) 2186 2187 Here, both inferior 2 and inferior 1 are running in the same 2188 program space as a result of inferior 1 having executed a `vfork' 2189 call. 2190 2191 2192 File: gdb.info, Node: Threads, Next: Forks, Prev: Inferiors and Programs, Up: Running 2193 2194 4.10 Debugging Programs with Multiple Threads 2195 ============================================= 2196 2197 In some operating systems, such as HP-UX and Solaris, a single program 2198 may have more than one "thread" of execution. The precise semantics of 2199 threads differ from one operating system to another, but in general the 2200 threads of a single program are akin to multiple processes--except that 2201 they share one address space (that is, they can all examine and modify 2202 the same variables). On the other hand, each thread has its own 2203 registers and execution stack, and perhaps private memory. 2204 2205 GDB provides these facilities for debugging multi-thread programs: 2206 2207 * automatic notification of new threads 2208 2209 * `thread THREADNO', a command to switch among threads 2210 2211 * `info threads', a command to inquire about existing threads 2212 2213 * `thread apply [THREADNO] [ALL] ARGS', a command to apply a command 2214 to a list of threads 2215 2216 * thread-specific breakpoints 2217 2218 * `set print thread-events', which controls printing of messages on 2219 thread start and exit. 2220 2221 * `set libthread-db-search-path PATH', which lets the user specify 2222 which `libthread_db' to use if the default choice isn't compatible 2223 with the program. 2224 2225 _Warning:_ These facilities are not yet available on every GDB 2226 configuration where the operating system supports threads. If 2227 your GDB does not support threads, these commands have no effect. 2228 For example, a system without thread support shows no output from 2229 `info threads', and always rejects the `thread' command, like this: 2230 2231 (gdb) info threads 2232 (gdb) thread 1 2233 Thread ID 1 not known. Use the "info threads" command to 2234 see the IDs of currently known threads. 2235 2236 The GDB thread debugging facility allows you to observe all threads 2237 while your program runs--but whenever GDB takes control, one thread in 2238 particular is always the focus of debugging. This thread is called the 2239 "current thread". Debugging commands show program information from the 2240 perspective of the current thread. 2241 2242 Whenever GDB detects a new thread in your program, it displays the 2243 target system's identification for the thread with a message in the 2244 form `[New SYSTAG]'. SYSTAG is a thread identifier whose form varies 2245 depending on the particular system. For example, on GNU/Linux, you 2246 might see 2247 2248 [New Thread 0x41e02940 (LWP 25582)] 2249 2250 when GDB notices a new thread. In contrast, on an SGI system, the 2251 SYSTAG is simply something like `process 368', with no further 2252 qualifier. 2253 2254 For debugging purposes, GDB associates its own thread number--always 2255 a single integer--with each thread in your program. 2256 2257 `info threads [ID...]' 2258 Display a summary of all threads currently in your program. 2259 Optional argument ID... is one or more thread ids separated by 2260 spaces, and means to print information only about the specified 2261 thread or threads. GDB displays for each thread (in this order): 2262 2263 1. the thread number assigned by GDB 2264 2265 2. the target system's thread identifier (SYSTAG) 2266 2267 3. the thread's name, if one is known. A thread can either be 2268 named by the user (see `thread name', below), or, in some 2269 cases, by the program itself. 2270 2271 4. the current stack frame summary for that thread 2272 2273 An asterisk `*' to the left of the GDB thread number indicates the 2274 current thread. 2275 2276 For example, 2277 2278 (gdb) info threads 2279 Id Target Id Frame 2280 3 process 35 thread 27 0x34e5 in sigpause () 2281 2 process 35 thread 23 0x34e5 in sigpause () 2282 * 1 process 35 thread 13 main (argc=1, argv=0x7ffffff8) 2283 at threadtest.c:68 2284 2285 On Solaris, you can display more information about user threads with 2286 a Solaris-specific command: 2287 2288 `maint info sol-threads' 2289 Display info on Solaris user threads. 2290 2291 `thread THREADNO' 2292 Make thread number THREADNO the current thread. The command 2293 argument THREADNO is the internal GDB thread number, as shown in 2294 the first field of the `info threads' display. GDB responds by 2295 displaying the system identifier of the thread you selected, and 2296 its current stack frame summary: 2297 2298 (gdb) thread 2 2299 [Switching to thread 2 (Thread 0xb7fdab70 (LWP 12747))] 2300 #0 some_function (ignore=0x0) at example.c:8 2301 8 printf ("hello\n"); 2302 2303 As with the `[New ...]' message, the form of the text after 2304 `Switching to' depends on your system's conventions for identifying 2305 threads. 2306 2307 The debugger convenience variable `$_thread' contains the number 2308 of the current thread. You may find this useful in writing 2309 breakpoint conditional expressions, command scripts, and so forth. 2310 See *Note Convenience Variables: Convenience Vars, for general 2311 information on convenience variables. 2312 2313 `thread apply [THREADNO | all] COMMAND' 2314 The `thread apply' command allows you to apply the named COMMAND 2315 to one or more threads. Specify the numbers of the threads that 2316 you want affected with the command argument THREADNO. It can be a 2317 single thread number, one of the numbers shown in the first field 2318 of the `info threads' display; or it could be a range of thread 2319 numbers, as in `2-4'. To apply a command to all threads, type 2320 `thread apply all COMMAND'. 2321 2322 `thread name [NAME]' 2323 This command assigns a name to the current thread. If no argument 2324 is given, any existing user-specified name is removed. The thread 2325 name appears in the `info threads' display. 2326 2327 On some systems, such as GNU/Linux, GDB is able to determine the 2328 name of the thread as given by the OS. On these systems, a name 2329 specified with `thread name' will override the system-give name, 2330 and removing the user-specified name will cause GDB to once again 2331 display the system-specified name. 2332 2333 `thread find [REGEXP]' 2334 Search for and display thread ids whose name or SYSTAG matches the 2335 supplied regular expression. 2336 2337 As well as being the complement to the `thread name' command, this 2338 command also allows you to identify a thread by its target SYSTAG. 2339 For instance, on GNU/Linux, the target SYSTAG is the LWP id. 2340 2341 (GDB) thread find 26688 2342 Thread 4 has target id 'Thread 0x41e02940 (LWP 26688)' 2343 (GDB) info thread 4 2344 Id Target Id Frame 2345 4 Thread 0x41e02940 (LWP 26688) 0x00000031ca6cd372 in select () 2346 2347 `set print thread-events' 2348 `set print thread-events on' 2349 `set print thread-events off' 2350 The `set print thread-events' command allows you to enable or 2351 disable printing of messages when GDB notices that new threads have 2352 started or that threads have exited. By default, these messages 2353 will be printed if detection of these events is supported by the 2354 target. Note that these messages cannot be disabled on all 2355 targets. 2356 2357 `show print thread-events' 2358 Show whether messages will be printed when GDB detects that threads 2359 have started and exited. 2360 2361 *Note Stopping and Starting Multi-thread Programs: Thread Stops, for 2362 more information about how GDB behaves when you stop and start programs 2363 with multiple threads. 2364 2365 *Note Setting Watchpoints: Set Watchpoints, for information about 2366 watchpoints in programs with multiple threads. 2367 2368 `set libthread-db-search-path [PATH]' 2369 If this variable is set, PATH is a colon-separated list of 2370 directories GDB will use to search for `libthread_db'. If you 2371 omit PATH, `libthread-db-search-path' will be reset to its default 2372 value (`$sdir:$pdir' on GNU/Linux and Solaris systems). 2373 Internally, the default value comes from the 2374 `LIBTHREAD_DB_SEARCH_PATH' macro. 2375 2376 On GNU/Linux and Solaris systems, GDB uses a "helper" 2377 `libthread_db' library to obtain information about threads in the 2378 inferior process. GDB will use `libthread-db-search-path' to find 2379 `libthread_db'. 2380 2381 A special entry `$sdir' for `libthread-db-search-path' refers to 2382 the default system directories that are normally searched for 2383 loading shared libraries. 2384 2385 A special entry `$pdir' for `libthread-db-search-path' refers to 2386 the directory from which `libpthread' was loaded in the inferior 2387 process. 2388 2389 For any `libthread_db' library GDB finds in above directories, GDB 2390 attempts to initialize it with the current inferior process. If 2391 this initialization fails (which could happen because of a version 2392 mismatch between `libthread_db' and `libpthread'), GDB will unload 2393 `libthread_db', and continue with the next directory. If none of 2394 `libthread_db' libraries initialize successfully, GDB will issue a 2395 warning and thread debugging will be disabled. 2396 2397 Setting `libthread-db-search-path' is currently implemented only 2398 on some platforms. 2399 2400 `show libthread-db-search-path' 2401 Display current libthread_db search path. 2402 2403 `set debug libthread-db' 2404 `show debug libthread-db' 2405 Turns on or off display of `libthread_db'-related events. Use `1' 2406 to enable, `0' to disable. 2407 2408 2409 File: gdb.info, Node: Forks, Next: Checkpoint/Restart, Prev: Threads, Up: Running 2410 2411 4.11 Debugging Forks 2412 ==================== 2413 2414 On most systems, GDB has no special support for debugging programs 2415 which create additional processes using the `fork' function. When a 2416 program forks, GDB will continue to debug the parent process and the 2417 child process will run unimpeded. If you have set a breakpoint in any 2418 code which the child then executes, the child will get a `SIGTRAP' 2419 signal which (unless it catches the signal) will cause it to terminate. 2420 2421 However, if you want to debug the child process there is a workaround 2422 which isn't too painful. Put a call to `sleep' in the code which the 2423 child process executes after the fork. It may be useful to sleep only 2424 if a certain environment variable is set, or a certain file exists, so 2425 that the delay need not occur when you don't want to run GDB on the 2426 child. While the child is sleeping, use the `ps' program to get its 2427 process ID. Then tell GDB (a new invocation of GDB if you are also 2428 debugging the parent process) to attach to the child process (*note 2429 Attach::). From that point on you can debug the child process just 2430 like any other process which you attached to. 2431 2432 On some systems, GDB provides support for debugging programs that 2433 create additional processes using the `fork' or `vfork' functions. 2434 Currently, the only platforms with this feature are HP-UX (11.x and 2435 later only?) and GNU/Linux (kernel version 2.5.60 and later). 2436 2437 By default, when a program forks, GDB will continue to debug the 2438 parent process and the child process will run unimpeded. 2439 2440 If you want to follow the child process instead of the parent 2441 process, use the command `set follow-fork-mode'. 2442 2443 `set follow-fork-mode MODE' 2444 Set the debugger response to a program call of `fork' or `vfork'. 2445 A call to `fork' or `vfork' creates a new process. The MODE 2446 argument can be: 2447 2448 `parent' 2449 The original process is debugged after a fork. The child 2450 process runs unimpeded. This is the default. 2451 2452 `child' 2453 The new process is debugged after a fork. The parent process 2454 runs unimpeded. 2455 2456 2457 `show follow-fork-mode' 2458 Display the current debugger response to a `fork' or `vfork' call. 2459 2460 On Linux, if you want to debug both the parent and child processes, 2461 use the command `set detach-on-fork'. 2462 2463 `set detach-on-fork MODE' 2464 Tells gdb whether to detach one of the processes after a fork, or 2465 retain debugger control over them both. 2466 2467 `on' 2468 The child process (or parent process, depending on the value 2469 of `follow-fork-mode') will be detached and allowed to run 2470 independently. This is the default. 2471 2472 `off' 2473 Both processes will be held under the control of GDB. One 2474 process (child or parent, depending on the value of 2475 `follow-fork-mode') is debugged as usual, while the other is 2476 held suspended. 2477 2478 2479 `show detach-on-fork' 2480 Show whether detach-on-fork mode is on/off. 2481 2482 If you choose to set `detach-on-fork' mode off, then GDB will retain 2483 control of all forked processes (including nested forks). You can list 2484 the forked processes under the control of GDB by using the 2485 `info inferiors' command, and switch from one fork to another by using 2486 the `inferior' command (*note Debugging Multiple Inferiors and 2487 Programs: Inferiors and Programs.). 2488 2489 To quit debugging one of the forked processes, you can either detach 2490 from it by using the `detach inferiors' command (allowing it to run 2491 independently), or kill it using the `kill inferiors' command. *Note 2492 Debugging Multiple Inferiors and Programs: Inferiors and Programs. 2493 2494 If you ask to debug a child process and a `vfork' is followed by an 2495 `exec', GDB executes the new target up to the first breakpoint in the 2496 new target. If you have a breakpoint set on `main' in your original 2497 program, the breakpoint will also be set on the child process's `main'. 2498 2499 On some systems, when a child process is spawned by `vfork', you 2500 cannot debug the child or parent until an `exec' call completes. 2501 2502 If you issue a `run' command to GDB after an `exec' call executes, 2503 the new target restarts. To restart the parent process, use the `file' 2504 command with the parent executable name as its argument. By default, 2505 after an `exec' call executes, GDB discards the symbols of the previous 2506 executable image. You can change this behaviour with the 2507 `set follow-exec-mode' command. 2508 2509 `set follow-exec-mode MODE' 2510 Set debugger response to a program call of `exec'. An `exec' call 2511 replaces the program image of a process. 2512 2513 `follow-exec-mode' can be: 2514 2515 `new' 2516 GDB creates a new inferior and rebinds the process to this 2517 new inferior. The program the process was running before the 2518 `exec' call can be restarted afterwards by restarting the 2519 original inferior. 2520 2521 For example: 2522 2523 (gdb) info inferiors 2524 (gdb) info inferior 2525 Id Description Executable 2526 * 1 <null> prog1 2527 (gdb) run 2528 process 12020 is executing new program: prog2 2529 Program exited normally. 2530 (gdb) info inferiors 2531 Id Description Executable 2532 * 2 <null> prog2 2533 1 <null> prog1 2534 2535 `same' 2536 GDB keeps the process bound to the same inferior. The new 2537 executable image replaces the previous executable loaded in 2538 the inferior. Restarting the inferior after the `exec' call, 2539 with e.g., the `run' command, restarts the executable the 2540 process was running after the `exec' call. This is the 2541 default mode. 2542 2543 For example: 2544 2545 (gdb) info inferiors 2546 Id Description Executable 2547 * 1 <null> prog1 2548 (gdb) run 2549 process 12020 is executing new program: prog2 2550 Program exited normally. 2551 (gdb) info inferiors 2552 Id Description Executable 2553 * 1 <null> prog2 2554 2555 2556 You can use the `catch' command to make GDB stop whenever a `fork', 2557 `vfork', or `exec' call is made. *Note Setting Catchpoints: Set 2558 Catchpoints. 2559 2560 2561 File: gdb.info, Node: Checkpoint/Restart, Prev: Forks, Up: Running 2562 2563 4.12 Setting a _Bookmark_ to Return to Later 2564 ============================================ 2565 2566 On certain operating systems(1), GDB is able to save a "snapshot" of a 2567 program's state, called a "checkpoint", and come back to it later. 2568 2569 Returning to a checkpoint effectively undoes everything that has 2570 happened in the program since the `checkpoint' was saved. This 2571 includes changes in memory, registers, and even (within some limits) 2572 system state. Effectively, it is like going back in time to the moment 2573 when the checkpoint was saved. 2574 2575 Thus, if you're stepping thru a program and you think you're getting 2576 close to the point where things go wrong, you can save a checkpoint. 2577 Then, if you accidentally go too far and miss the critical statement, 2578 instead of having to restart your program from the beginning, you can 2579 just go back to the checkpoint and start again from there. 2580 2581 This can be especially useful if it takes a lot of time or steps to 2582 reach the point where you think the bug occurs. 2583 2584 To use the `checkpoint'/`restart' method of debugging: 2585 2586 `checkpoint' 2587 Save a snapshot of the debugged program's current execution state. 2588 The `checkpoint' command takes no arguments, but each checkpoint 2589 is assigned a small integer id, similar to a breakpoint id. 2590 2591 `info checkpoints' 2592 List the checkpoints that have been saved in the current debugging 2593 session. For each checkpoint, the following information will be 2594 listed: 2595 2596 `Checkpoint ID' 2597 2598 `Process ID' 2599 2600 `Code Address' 2601 2602 `Source line, or label' 2603 2604 `restart CHECKPOINT-ID' 2605 Restore the program state that was saved as checkpoint number 2606 CHECKPOINT-ID. All program variables, registers, stack frames 2607 etc. will be returned to the values that they had when the 2608 checkpoint was saved. In essence, gdb will "wind back the clock" 2609 to the point in time when the checkpoint was saved. 2610 2611 Note that breakpoints, GDB variables, command history etc. are 2612 not affected by restoring a checkpoint. In general, a checkpoint 2613 only restores things that reside in the program being debugged, 2614 not in the debugger. 2615 2616 `delete checkpoint CHECKPOINT-ID' 2617 Delete the previously-saved checkpoint identified by CHECKPOINT-ID. 2618 2619 2620 Returning to a previously saved checkpoint will restore the user 2621 state of the program being debugged, plus a significant subset of the 2622 system (OS) state, including file pointers. It won't "un-write" data 2623 from a file, but it will rewind the file pointer to the previous 2624 location, so that the previously written data can be overwritten. For 2625 files opened in read mode, the pointer will also be restored so that the 2626 previously read data can be read again. 2627 2628 Of course, characters that have been sent to a printer (or other 2629 external device) cannot be "snatched back", and characters received 2630 from eg. a serial device can be removed from internal program buffers, 2631 but they cannot be "pushed back" into the serial pipeline, ready to be 2632 received again. Similarly, the actual contents of files that have been 2633 changed cannot be restored (at this time). 2634 2635 However, within those constraints, you actually can "rewind" your 2636 program to a previously saved point in time, and begin debugging it 2637 again -- and you can change the course of events so as to debug a 2638 different execution path this time. 2639 2640 Finally, there is one bit of internal program state that will be 2641 different when you return to a checkpoint -- the program's process id. 2642 Each checkpoint will have a unique process id (or PID), and each will 2643 be different from the program's original PID. If your program has 2644 saved a local copy of its process id, this could potentially pose a 2645 problem. 2646 2647 4.12.1 A Non-obvious Benefit of Using Checkpoints 2648 ------------------------------------------------- 2649 2650 On some systems such as GNU/Linux, address space randomization is 2651 performed on new processes for security reasons. This makes it 2652 difficult or impossible to set a breakpoint, or watchpoint, on an 2653 absolute address if you have to restart the program, since the absolute 2654 location of a symbol will change from one execution to the next. 2655 2656 A checkpoint, however, is an _identical_ copy of a process. 2657 Therefore if you create a checkpoint at (eg.) the start of main, and 2658 simply return to that checkpoint instead of restarting the process, you 2659 can avoid the effects of address randomization and your symbols will 2660 all stay in the same place. 2661 2662 ---------- Footnotes ---------- 2663 2664 (1) Currently, only GNU/Linux. 2665 2666 2667 File: gdb.info, Node: Stopping, Next: Reverse Execution, Prev: Running, Up: Top 2668 2669 5 Stopping and Continuing 2670 ************************* 2671 2672 The principal purposes of using a debugger are so that you can stop your 2673 program before it terminates; or so that, if your program runs into 2674 trouble, you can investigate and find out why. 2675 2676 Inside GDB, your program may stop for any of several reasons, such 2677 as a signal, a breakpoint, or reaching a new line after a GDB command 2678 such as `step'. You may then examine and change variables, set new 2679 breakpoints or remove old ones, and then continue execution. Usually, 2680 the messages shown by GDB provide ample explanation of the status of 2681 your program--but you can also explicitly request this information at 2682 any time. 2683 2684 `info program' 2685 Display information about the status of your program: whether it is 2686 running or not, what process it is, and why it stopped. 2687 2688 * Menu: 2689 2690 * Breakpoints:: Breakpoints, watchpoints, and catchpoints 2691 * Continuing and Stepping:: Resuming execution 2692 * Signals:: Signals 2693 * Thread Stops:: Stopping and starting multi-thread programs 2694 2695 2696 File: gdb.info, Node: Breakpoints, Next: Continuing and Stepping, Up: Stopping 2697 2698 5.1 Breakpoints, Watchpoints, and Catchpoints 2699 ============================================= 2700 2701 A "breakpoint" makes your program stop whenever a certain point in the 2702 program is reached. For each breakpoint, you can add conditions to 2703 control in finer detail whether your program stops. You can set 2704 breakpoints with the `break' command and its variants (*note Setting 2705 Breakpoints: Set Breaks.), to specify the place where your program 2706 should stop by line number, function name or exact address in the 2707 program. 2708 2709 On some systems, you can set breakpoints in shared libraries before 2710 the executable is run. There is a minor limitation on HP-UX systems: 2711 you must wait until the executable is run in order to set breakpoints 2712 in shared library routines that are not called directly by the program 2713 (for example, routines that are arguments in a `pthread_create' call). 2714 2715 A "watchpoint" is a special breakpoint that stops your program when 2716 the value of an expression changes. The expression may be a value of a 2717 variable, or it could involve values of one or more variables combined 2718 by operators, such as `a + b'. This is sometimes called "data 2719 breakpoints". You must use a different command to set watchpoints 2720 (*note Setting Watchpoints: Set Watchpoints.), but aside from that, you 2721 can manage a watchpoint like any other breakpoint: you enable, disable, 2722 and delete both breakpoints and watchpoints using the same commands. 2723 2724 You can arrange to have values from your program displayed 2725 automatically whenever GDB stops at a breakpoint. *Note Automatic 2726 Display: Auto Display. 2727 2728 A "catchpoint" is another special breakpoint that stops your program 2729 when a certain kind of event occurs, such as the throwing of a C++ 2730 exception or the loading of a library. As with watchpoints, you use a 2731 different command to set a catchpoint (*note Setting Catchpoints: Set 2732 Catchpoints.), but aside from that, you can manage a catchpoint like any 2733 other breakpoint. (To stop when your program receives a signal, use the 2734 `handle' command; see *note Signals: Signals.) 2735 2736 GDB assigns a number to each breakpoint, watchpoint, or catchpoint 2737 when you create it; these numbers are successive integers starting with 2738 one. In many of the commands for controlling various features of 2739 breakpoints you use the breakpoint number to say which breakpoint you 2740 want to change. Each breakpoint may be "enabled" or "disabled"; if 2741 disabled, it has no effect on your program until you enable it again. 2742 2743 Some GDB commands accept a range of breakpoints on which to operate. 2744 A breakpoint range is either a single breakpoint number, like `5', or 2745 two such numbers, in increasing order, separated by a hyphen, like 2746 `5-7'. When a breakpoint range is given to a command, all breakpoints 2747 in that range are operated on. 2748 2749 * Menu: 2750 2751 * Set Breaks:: Setting breakpoints 2752 * Set Watchpoints:: Setting watchpoints 2753 * Set Catchpoints:: Setting catchpoints 2754 * Delete Breaks:: Deleting breakpoints 2755 * Disabling:: Disabling breakpoints 2756 * Conditions:: Break conditions 2757 * Break Commands:: Breakpoint command lists 2758 * Save Breakpoints:: How to save breakpoints in a file 2759 * Error in Breakpoints:: ``Cannot insert breakpoints'' 2760 * Breakpoint-related Warnings:: ``Breakpoint address adjusted...'' 2761 2762 2763 File: gdb.info, Node: Set Breaks, Next: Set Watchpoints, Up: Breakpoints 2764 2765 5.1.1 Setting Breakpoints 2766 ------------------------- 2767 2768 Breakpoints are set with the `break' command (abbreviated `b'). The 2769 debugger convenience variable `$bpnum' records the number of the 2770 breakpoint you've set most recently; see *note Convenience Variables: 2771 Convenience Vars, for a discussion of what you can do with convenience 2772 variables. 2773 2774 `break LOCATION' 2775 Set a breakpoint at the given LOCATION, which can specify a 2776 function name, a line number, or an address of an instruction. 2777 (*Note Specify Location::, for a list of all the possible ways to 2778 specify a LOCATION.) The breakpoint will stop your program just 2779 before it executes any of the code in the specified LOCATION. 2780 2781 When using source languages that permit overloading of symbols, 2782 such as C++, a function name may refer to more than one possible 2783 place to break. *Note Ambiguous Expressions: Ambiguous 2784 Expressions, for a discussion of that situation. 2785 2786 It is also possible to insert a breakpoint that will stop the 2787 program only if a specific thread (*note Thread-Specific 2788 Breakpoints::) or a specific task (*note Ada Tasks::) hits that 2789 breakpoint. 2790 2791 `break' 2792 When called without any arguments, `break' sets a breakpoint at 2793 the next instruction to be executed in the selected stack frame 2794 (*note Examining the Stack: Stack.). In any selected frame but the 2795 innermost, this makes your program stop as soon as control returns 2796 to that frame. This is similar to the effect of a `finish' 2797 command in the frame inside the selected frame--except that 2798 `finish' does not leave an active breakpoint. If you use `break' 2799 without an argument in the innermost frame, GDB stops the next 2800 time it reaches the current location; this may be useful inside 2801 loops. 2802 2803 GDB normally ignores breakpoints when it resumes execution, until 2804 at least one instruction has been executed. If it did not do 2805 this, you would be unable to proceed past a breakpoint without 2806 first disabling the breakpoint. This rule applies whether or not 2807 the breakpoint already existed when your program stopped. 2808 2809 `break ... if COND' 2810 Set a breakpoint with condition COND; evaluate the expression COND 2811 each time the breakpoint is reached, and stop only if the value is 2812 nonzero--that is, if COND evaluates as true. `...' stands for one 2813 of the possible arguments described above (or no argument) 2814 specifying where to break. *Note Break Conditions: Conditions, 2815 for more information on breakpoint conditions. 2816 2817 `tbreak ARGS' 2818 Set a breakpoint enabled only for one stop. ARGS are the same as 2819 for the `break' command, and the breakpoint is set in the same 2820 way, but the breakpoint is automatically deleted after the first 2821 time your program stops there. *Note Disabling Breakpoints: 2822 Disabling. 2823 2824 `hbreak ARGS' 2825 Set a hardware-assisted breakpoint. ARGS are the same as for the 2826 `break' command and the breakpoint is set in the same way, but the 2827 breakpoint requires hardware support and some target hardware may 2828 not have this support. The main purpose of this is EPROM/ROM code 2829 debugging, so you can set a breakpoint at an instruction without 2830 changing the instruction. This can be used with the new 2831 trap-generation provided by SPARClite DSU and most x86-based 2832 targets. These targets will generate traps when a program 2833 accesses some data or instruction address that is assigned to the 2834 debug registers. However the hardware breakpoint registers can 2835 take a limited number of breakpoints. For example, on the DSU, 2836 only two data breakpoints can be set at a time, and GDB will 2837 reject this command if more than two are used. Delete or disable 2838 unused hardware breakpoints before setting new ones (*note 2839 Disabling Breakpoints: Disabling.). *Note Break Conditions: 2840 Conditions. For remote targets, you can restrict the number of 2841 hardware breakpoints GDB will use, see *note set remote 2842 hardware-breakpoint-limit::. 2843 2844 `thbreak ARGS' 2845 Set a hardware-assisted breakpoint enabled only for one stop. ARGS 2846 are the same as for the `hbreak' command and the breakpoint is set 2847 in the same way. However, like the `tbreak' command, the 2848 breakpoint is automatically deleted after the first time your 2849 program stops there. Also, like the `hbreak' command, the 2850 breakpoint requires hardware support and some target hardware may 2851 not have this support. *Note Disabling Breakpoints: Disabling. 2852 See also *note Break Conditions: Conditions. 2853 2854 `rbreak REGEX' 2855 Set breakpoints on all functions matching the regular expression 2856 REGEX. This command sets an unconditional breakpoint on all 2857 matches, printing a list of all breakpoints it set. Once these 2858 breakpoints are set, they are treated just like the breakpoints 2859 set with the `break' command. You can delete them, disable them, 2860 or make them conditional the same way as any other breakpoint. 2861 2862 The syntax of the regular expression is the standard one used with 2863 tools like `grep'. Note that this is different from the syntax 2864 used by shells, so for instance `foo*' matches all functions that 2865 include an `fo' followed by zero or more `o's. There is an 2866 implicit `.*' leading and trailing the regular expression you 2867 supply, so to match only functions that begin with `foo', use 2868 `^foo'. 2869 2870 When debugging C++ programs, `rbreak' is useful for setting 2871 breakpoints on overloaded functions that are not members of any 2872 special classes. 2873 2874 The `rbreak' command can be used to set breakpoints in *all* the 2875 functions in a program, like this: 2876 2877 (gdb) rbreak . 2878 2879 `rbreak FILE:REGEX' 2880 If `rbreak' is called with a filename qualification, it limits the 2881 search for functions matching the given regular expression to the 2882 specified FILE. This can be used, for example, to set breakpoints 2883 on every function in a given file: 2884 2885 (gdb) rbreak file.c:. 2886 2887 The colon separating the filename qualifier from the regex may 2888 optionally be surrounded by spaces. 2889 2890 `info breakpoints [N...]' 2891 `info break [N...]' 2892 Print a table of all breakpoints, watchpoints, and catchpoints set 2893 and not deleted. Optional argument N means print information only 2894 about the specified breakpoint(s) (or watchpoint(s) or 2895 catchpoint(s)). For each breakpoint, following columns are 2896 printed: 2897 2898 _Breakpoint Numbers_ 2899 2900 _Type_ 2901 Breakpoint, watchpoint, or catchpoint. 2902 2903 _Disposition_ 2904 Whether the breakpoint is marked to be disabled or deleted 2905 when hit. 2906 2907 _Enabled or Disabled_ 2908 Enabled breakpoints are marked with `y'. `n' marks 2909 breakpoints that are not enabled. 2910 2911 _Address_ 2912 Where the breakpoint is in your program, as a memory address. 2913 For a pending breakpoint whose address is not yet known, this 2914 field will contain `<PENDING>'. Such breakpoint won't fire 2915 until a shared library that has the symbol or line referred 2916 by breakpoint is loaded. See below for details. A 2917 breakpoint with several locations will have `<MULTIPLE>' in 2918 this field--see below for details. 2919 2920 _What_ 2921 Where the breakpoint is in the source for your program, as a 2922 file and line number. For a pending breakpoint, the original 2923 string passed to the breakpoint command will be listed as it 2924 cannot be resolved until the appropriate shared library is 2925 loaded in the future. 2926 2927 If a breakpoint is conditional, `info break' shows the condition on 2928 the line following the affected breakpoint; breakpoint commands, 2929 if any, are listed after that. A pending breakpoint is allowed to 2930 have a condition specified for it. The condition is not parsed 2931 for validity until a shared library is loaded that allows the 2932 pending breakpoint to resolve to a valid location. 2933 2934 `info break' with a breakpoint number N as argument lists only 2935 that breakpoint. The convenience variable `$_' and the default 2936 examining-address for the `x' command are set to the address of 2937 the last breakpoint listed (*note Examining Memory: Memory.). 2938 2939 `info break' displays a count of the number of times the breakpoint 2940 has been hit. This is especially useful in conjunction with the 2941 `ignore' command. You can ignore a large number of breakpoint 2942 hits, look at the breakpoint info to see how many times the 2943 breakpoint was hit, and then run again, ignoring one less than 2944 that number. This will get you quickly to the last hit of that 2945 breakpoint. 2946 2947 GDB allows you to set any number of breakpoints at the same place in 2948 your program. There is nothing silly or meaningless about this. When 2949 the breakpoints are conditional, this is even useful (*note Break 2950 Conditions: Conditions.). 2951 2952 It is possible that a breakpoint corresponds to several locations in 2953 your program. Examples of this situation are: 2954 2955 * For a C++ constructor, the GCC compiler generates several 2956 instances of the function body, used in different cases. 2957 2958 * For a C++ template function, a given line in the function can 2959 correspond to any number of instantiations. 2960 2961 * For an inlined function, a given source line can correspond to 2962 several places where that function is inlined. 2963 2964 In all those cases, GDB will insert a breakpoint at all the relevant 2965 locations(1). 2966 2967 A breakpoint with multiple locations is displayed in the breakpoint 2968 table using several rows--one header row, followed by one row for each 2969 breakpoint location. The header row has `<MULTIPLE>' in the address 2970 column. The rows for individual locations contain the actual addresses 2971 for locations, and show the functions to which those locations belong. 2972 The number column for a location is of the form 2973 BREAKPOINT-NUMBER.LOCATION-NUMBER. 2974 2975 For example: 2976 2977 Num Type Disp Enb Address What 2978 1 breakpoint keep y <MULTIPLE> 2979 stop only if i==1 2980 breakpoint already hit 1 time 2981 1.1 y 0x080486a2 in void foo<int>() at t.cc:8 2982 1.2 y 0x080486ca in void foo<double>() at t.cc:8 2983 2984 Each location can be individually enabled or disabled by passing 2985 BREAKPOINT-NUMBER.LOCATION-NUMBER as argument to the `enable' and 2986 `disable' commands. Note that you cannot delete the individual 2987 locations from the list, you can only delete the entire list of 2988 locations that belong to their parent breakpoint (with the `delete NUM' 2989 command, where NUM is the number of the parent breakpoint, 1 in the 2990 above example). Disabling or enabling the parent breakpoint (*note 2991 Disabling::) affects all of the locations that belong to that 2992 breakpoint. 2993 2994 It's quite common to have a breakpoint inside a shared library. 2995 Shared libraries can be loaded and unloaded explicitly, and possibly 2996 repeatedly, as the program is executed. To support this use case, GDB 2997 updates breakpoint locations whenever any shared library is loaded or 2998 unloaded. Typically, you would set a breakpoint in a shared library at 2999 the beginning of your debugging session, when the library is not 3000 loaded, and when the symbols from the library are not available. When 3001 you try to set breakpoint, GDB will ask you if you want to set a so 3002 called "pending breakpoint"--breakpoint whose address is not yet 3003 resolved. 3004 3005 After the program is run, whenever a new shared library is loaded, 3006 GDB reevaluates all the breakpoints. When a newly loaded shared 3007 library contains the symbol or line referred to by some pending 3008 breakpoint, that breakpoint is resolved and becomes an ordinary 3009 breakpoint. When a library is unloaded, all breakpoints that refer to 3010 its symbols or source lines become pending again. 3011 3012 This logic works for breakpoints with multiple locations, too. For 3013 example, if you have a breakpoint in a C++ template function, and a 3014 newly loaded shared library has an instantiation of that template, a 3015 new location is added to the list of locations for the breakpoint. 3016 3017 Except for having unresolved address, pending breakpoints do not 3018 differ from regular breakpoints. You can set conditions or commands, 3019 enable and disable them and perform other breakpoint operations. 3020 3021 GDB provides some additional commands for controlling what happens 3022 when the `break' command cannot resolve breakpoint address 3023 specification to an address: 3024 3025 `set breakpoint pending auto' 3026 This is the default behavior. When GDB cannot find the breakpoint 3027 location, it queries you whether a pending breakpoint should be 3028 created. 3029 3030 `set breakpoint pending on' 3031 This indicates that an unrecognized breakpoint location should 3032 automatically result in a pending breakpoint being created. 3033 3034 `set breakpoint pending off' 3035 This indicates that pending breakpoints are not to be created. Any 3036 unrecognized breakpoint location results in an error. This 3037 setting does not affect any pending breakpoints previously created. 3038 3039 `show breakpoint pending' 3040 Show the current behavior setting for creating pending breakpoints. 3041 3042 The settings above only affect the `break' command and its variants. 3043 Once breakpoint is set, it will be automatically updated as shared 3044 libraries are loaded and unloaded. 3045 3046 For some targets, GDB can automatically decide if hardware or 3047 software breakpoints should be used, depending on whether the 3048 breakpoint address is read-only or read-write. This applies to 3049 breakpoints set with the `break' command as well as to internal 3050 breakpoints set by commands like `next' and `finish'. For breakpoints 3051 set with `hbreak', GDB will always use hardware breakpoints. 3052 3053 You can control this automatic behaviour with the following 3054 commands:: 3055 3056 `set breakpoint auto-hw on' 3057 This is the default behavior. When GDB sets a breakpoint, it will 3058 try to use the target memory map to decide if software or hardware 3059 breakpoint must be used. 3060 3061 `set breakpoint auto-hw off' 3062 This indicates GDB should not automatically select breakpoint 3063 type. If the target provides a memory map, GDB will warn when 3064 trying to set software breakpoint at a read-only address. 3065 3066 GDB normally implements breakpoints by replacing the program code at 3067 the breakpoint address with a special instruction, which, when 3068 executed, given control to the debugger. By default, the program code 3069 is so modified only when the program is resumed. As soon as the 3070 program stops, GDB restores the original instructions. This behaviour 3071 guards against leaving breakpoints inserted in the target should gdb 3072 abrubptly disconnect. However, with slow remote targets, inserting and 3073 removing breakpoint can reduce the performance. This behavior can be 3074 controlled with the following commands:: 3075 3076 `set breakpoint always-inserted off' 3077 All breakpoints, including newly added by the user, are inserted in 3078 the target only when the target is resumed. All breakpoints are 3079 removed from the target when it stops. 3080 3081 `set breakpoint always-inserted on' 3082 Causes all breakpoints to be inserted in the target at all times. 3083 If the user adds a new breakpoint, or changes an existing 3084 breakpoint, the breakpoints in the target are updated immediately. 3085 A breakpoint is removed from the target only when breakpoint 3086 itself is removed. 3087 3088 `set breakpoint always-inserted auto' 3089 This is the default mode. If GDB is controlling the inferior in 3090 non-stop mode (*note Non-Stop Mode::), gdb behaves as if 3091 `breakpoint always-inserted' mode is on. If GDB is controlling 3092 the inferior in all-stop mode, GDB behaves as if `breakpoint 3093 always-inserted' mode is off. 3094 3095 GDB itself sometimes sets breakpoints in your program for special 3096 purposes, such as proper handling of `longjmp' (in C programs). These 3097 internal breakpoints are assigned negative numbers, starting with `-1'; 3098 `info breakpoints' does not display them. You can see these 3099 breakpoints with the GDB maintenance command `maint info breakpoints' 3100 (*note maint info breakpoints::). 3101 3102 ---------- Footnotes ---------- 3103 3104 (1) As of this writing, multiple-location breakpoints work only if 3105 there's line number information for all the locations. This means that 3106 they will generally not work in system libraries, unless you have debug 3107 info with line numbers for them. 3108 3109 3110 File: gdb.info, Node: Set Watchpoints, Next: Set Catchpoints, Prev: Set Breaks, Up: Breakpoints 3111 3112 5.1.2 Setting Watchpoints 3113 ------------------------- 3114 3115 You can use a watchpoint to stop execution whenever the value of an 3116 expression changes, without having to predict a particular place where 3117 this may happen. (This is sometimes called a "data breakpoint".) The 3118 expression may be as simple as the value of a single variable, or as 3119 complex as many variables combined by operators. Examples include: 3120 3121 * A reference to the value of a single variable. 3122 3123 * An address cast to an appropriate data type. For example, `*(int 3124 *)0x12345678' will watch a 4-byte region at the specified address 3125 (assuming an `int' occupies 4 bytes). 3126 3127 * An arbitrarily complex expression, such as `a*b + c/d'. The 3128 expression can use any operators valid in the program's native 3129 language (*note Languages::). 3130 3131 You can set a watchpoint on an expression even if the expression can 3132 not be evaluated yet. For instance, you can set a watchpoint on 3133 `*global_ptr' before `global_ptr' is initialized. GDB will stop when 3134 your program sets `global_ptr' and the expression produces a valid 3135 value. If the expression becomes valid in some other way than changing 3136 a variable (e.g. if the memory pointed to by `*global_ptr' becomes 3137 readable as the result of a `malloc' call), GDB may not stop until the 3138 next time the expression changes. 3139 3140 Depending on your system, watchpoints may be implemented in software 3141 or hardware. GDB does software watchpointing by single-stepping your 3142 program and testing the variable's value each time, which is hundreds of 3143 times slower than normal execution. (But this may still be worth it, to 3144 catch errors where you have no clue what part of your program is the 3145 culprit.) 3146 3147 On some systems, such as HP-UX, PowerPC, GNU/Linux and most other 3148 x86-based targets, GDB includes support for hardware watchpoints, which 3149 do not slow down the running of your program. 3150 3151 `watch [-l|-location] EXPR [thread THREADNUM]' 3152 Set a watchpoint for an expression. GDB will break when the 3153 expression EXPR is written into by the program and its value 3154 changes. The simplest (and the most popular) use of this command 3155 is to watch the value of a single variable: 3156 3157 (gdb) watch foo 3158 3159 If the command includes a `[thread THREADNUM]' clause, GDB breaks 3160 only when the thread identified by THREADNUM changes the value of 3161 EXPR. If any other threads change the value of EXPR, GDB will not 3162 break. Note that watchpoints restricted to a single thread in 3163 this way only work with Hardware Watchpoints. 3164 3165 Ordinarily a watchpoint respects the scope of variables in EXPR 3166 (see below). The `-location' argument tells GDB to instead watch 3167 the memory referred to by EXPR. In this case, GDB will evaluate 3168 EXPR, take the address of the result, and watch the memory at that 3169 address. The type of the result is used to determine the size of 3170 the watched memory. If the expression's result does not have an 3171 address, then GDB will print an error. 3172 3173 `rwatch [-l|-location] EXPR [thread THREADNUM]' 3174 Set a watchpoint that will break when the value of EXPR is read by 3175 the program. 3176 3177 `awatch [-l|-location] EXPR [thread THREADNUM]' 3178 Set a watchpoint that will break when EXPR is either read from or 3179 written into by the program. 3180 3181 `info watchpoints [N...]' 3182 This command prints a list of watchpoints, using the same format as 3183 `info break' (*note Set Breaks::). 3184 3185 If you watch for a change in a numerically entered address you need 3186 to dereference it, as the address itself is just a constant number 3187 which will never change. GDB refuses to create a watchpoint that 3188 watches a never-changing value: 3189 3190 (gdb) watch 0x600850 3191 Cannot watch constant value 0x600850. 3192 (gdb) watch *(int *) 0x600850 3193 Watchpoint 1: *(int *) 6293584 3194 3195 GDB sets a "hardware watchpoint" if possible. Hardware watchpoints 3196 execute very quickly, and the debugger reports a change in value at the 3197 exact instruction where the change occurs. If GDB cannot set a 3198 hardware watchpoint, it sets a software watchpoint, which executes more 3199 slowly and reports the change in value at the next _statement_, not the 3200 instruction, after the change occurs. 3201 3202 You can force GDB to use only software watchpoints with the `set 3203 can-use-hw-watchpoints 0' command. With this variable set to zero, GDB 3204 will never try to use hardware watchpoints, even if the underlying 3205 system supports them. (Note that hardware-assisted watchpoints that 3206 were set _before_ setting `can-use-hw-watchpoints' to zero will still 3207 use the hardware mechanism of watching expression values.) 3208 3209 `set can-use-hw-watchpoints' 3210 Set whether or not to use hardware watchpoints. 3211 3212 `show can-use-hw-watchpoints' 3213 Show the current mode of using hardware watchpoints. 3214 3215 For remote targets, you can restrict the number of hardware 3216 watchpoints GDB will use, see *note set remote 3217 hardware-breakpoint-limit::. 3218 3219 When you issue the `watch' command, GDB reports 3220 3221 Hardware watchpoint NUM: EXPR 3222 3223 if it was able to set a hardware watchpoint. 3224 3225 Currently, the `awatch' and `rwatch' commands can only set hardware 3226 watchpoints, because accesses to data that don't change the value of 3227 the watched expression cannot be detected without examining every 3228 instruction as it is being executed, and GDB does not do that 3229 currently. If GDB finds that it is unable to set a hardware breakpoint 3230 with the `awatch' or `rwatch' command, it will print a message like 3231 this: 3232 3233 Expression cannot be implemented with read/access watchpoint. 3234 3235 Sometimes, GDB cannot set a hardware watchpoint because the data 3236 type of the watched expression is wider than what a hardware watchpoint 3237 on the target machine can handle. For example, some systems can only 3238 watch regions that are up to 4 bytes wide; on such systems you cannot 3239 set hardware watchpoints for an expression that yields a 3240 double-precision floating-point number (which is typically 8 bytes 3241 wide). As a work-around, it might be possible to break the large region 3242 into a series of smaller ones and watch them with separate watchpoints. 3243 3244 If you set too many hardware watchpoints, GDB might be unable to 3245 insert all of them when you resume the execution of your program. 3246 Since the precise number of active watchpoints is unknown until such 3247 time as the program is about to be resumed, GDB might not be able to 3248 warn you about this when you set the watchpoints, and the warning will 3249 be printed only when the program is resumed: 3250 3251 Hardware watchpoint NUM: Could not insert watchpoint 3252 3253 If this happens, delete or disable some of the watchpoints. 3254 3255 Watching complex expressions that reference many variables can also 3256 exhaust the resources available for hardware-assisted watchpoints. 3257 That's because GDB needs to watch every variable in the expression with 3258 separately allocated resources. 3259 3260 If you call a function interactively using `print' or `call', any 3261 watchpoints you have set will be inactive until GDB reaches another 3262 kind of breakpoint or the call completes. 3263 3264 GDB automatically deletes watchpoints that watch local (automatic) 3265 variables, or expressions that involve such variables, when they go out 3266 of scope, that is, when the execution leaves the block in which these 3267 variables were defined. In particular, when the program being debugged 3268 terminates, _all_ local variables go out of scope, and so only 3269 watchpoints that watch global variables remain set. If you rerun the 3270 program, you will need to set all such watchpoints again. One way of 3271 doing that would be to set a code breakpoint at the entry to the `main' 3272 function and when it breaks, set all the watchpoints. 3273 3274 In multi-threaded programs, watchpoints will detect changes to the 3275 watched expression from every thread. 3276 3277 _Warning:_ In multi-threaded programs, software watchpoints have 3278 only limited usefulness. If GDB creates a software watchpoint, it 3279 can only watch the value of an expression _in a single thread_. 3280 If you are confident that the expression can only change due to 3281 the current thread's activity (and if you are also confident that 3282 no other thread can become current), then you can use software 3283 watchpoints as usual. However, GDB may not notice when a 3284 non-current thread's activity changes the expression. (Hardware 3285 watchpoints, in contrast, watch an expression in all threads.) 3286 3287 *Note set remote hardware-watchpoint-limit::. 3288 3289 3290 File: gdb.info, Node: Set Catchpoints, Next: Delete Breaks, Prev: Set Watchpoints, Up: Breakpoints 3291 3292 5.1.3 Setting Catchpoints 3293 ------------------------- 3294 3295 You can use "catchpoints" to cause the debugger to stop for certain 3296 kinds of program events, such as C++ exceptions or the loading of a 3297 shared library. Use the `catch' command to set a catchpoint. 3298 3299 `catch EVENT' 3300 Stop when EVENT occurs. EVENT can be any of the following: 3301 `throw' 3302 The throwing of a C++ exception. 3303 3304 `catch' 3305 The catching of a C++ exception. 3306 3307 `exception' 3308 An Ada exception being raised. If an exception name is 3309 specified at the end of the command (eg `catch exception 3310 Program_Error'), the debugger will stop only when this 3311 specific exception is raised. Otherwise, the debugger stops 3312 execution when any Ada exception is raised. 3313 3314 When inserting an exception catchpoint on a user-defined 3315 exception whose name is identical to one of the exceptions 3316 defined by the language, the fully qualified name must be 3317 used as the exception name. Otherwise, GDB will assume that 3318 it should stop on the pre-defined exception rather than the 3319 user-defined one. For instance, assuming an exception called 3320 `Constraint_Error' is defined in package `Pck', then the 3321 command to use to catch such exceptions is `catch exception 3322 Pck.Constraint_Error'. 3323 3324 `exception unhandled' 3325 An exception that was raised but is not handled by the 3326 program. 3327 3328 `assert' 3329 A failed Ada assertion. 3330 3331 `exec' 3332 A call to `exec'. This is currently only available for HP-UX 3333 and GNU/Linux. 3334 3335 `syscall' 3336 `syscall [NAME | NUMBER] ...' 3337 A call to or return from a system call, a.k.a. "syscall". A 3338 syscall is a mechanism for application programs to request a 3339 service from the operating system (OS) or one of the OS 3340 system services. GDB can catch some or all of the syscalls 3341 issued by the debuggee, and show the related information for 3342 each syscall. If no argument is specified, calls to and 3343 returns from all system calls will be caught. 3344 3345 NAME can be any system call name that is valid for the 3346 underlying OS. Just what syscalls are valid depends on the 3347 OS. On GNU and Unix systems, you can find the full list of 3348 valid syscall names on `/usr/include/asm/unistd.h'. 3349 3350 Normally, GDB knows in advance which syscalls are valid for 3351 each OS, so you can use the GDB command-line completion 3352 facilities (*note command completion: Completion.) to list the 3353 available choices. 3354 3355 You may also specify the system call numerically. A syscall's 3356 number is the value passed to the OS's syscall dispatcher to 3357 identify the requested service. When you specify the syscall 3358 by its name, GDB uses its database of syscalls to convert the 3359 name into the corresponding numeric code, but using the 3360 number directly may be useful if GDB's database does not have 3361 the complete list of syscalls on your system (e.g., because 3362 GDB lags behind the OS upgrades). 3363 3364 The example below illustrates how this command works if you 3365 don't provide arguments to it: 3366 3367 (gdb) catch syscall 3368 Catchpoint 1 (syscall) 3369 (gdb) r 3370 Starting program: /tmp/catch-syscall 3371 3372 Catchpoint 1 (call to syscall 'close'), \ 3373 0xffffe424 in __kernel_vsyscall () 3374 (gdb) c 3375 Continuing. 3376 3377 Catchpoint 1 (returned from syscall 'close'), \ 3378 0xffffe424 in __kernel_vsyscall () 3379 (gdb) 3380 3381 Here is an example of catching a system call by name: 3382 3383 (gdb) catch syscall chroot 3384 Catchpoint 1 (syscall 'chroot' [61]) 3385 (gdb) r 3386 Starting program: /tmp/catch-syscall 3387 3388 Catchpoint 1 (call to syscall 'chroot'), \ 3389 0xffffe424 in __kernel_vsyscall () 3390 (gdb) c 3391 Continuing. 3392 3393 Catchpoint 1 (returned from syscall 'chroot'), \ 3394 0xffffe424 in __kernel_vsyscall () 3395 (gdb) 3396 3397 An example of specifying a system call numerically. In the 3398 case below, the syscall number has a corresponding entry in 3399 the XML file, so GDB finds its name and prints it: 3400 3401 (gdb) catch syscall 252 3402 Catchpoint 1 (syscall(s) 'exit_group') 3403 (gdb) r 3404 Starting program: /tmp/catch-syscall 3405 3406 Catchpoint 1 (call to syscall 'exit_group'), \ 3407 0xffffe424 in __kernel_vsyscall () 3408 (gdb) c 3409 Continuing. 3410 3411 Program exited normally. 3412 (gdb) 3413 3414 However, there can be situations when there is no 3415 corresponding name in XML file for that syscall number. In 3416 this case, GDB prints a warning message saying that it was 3417 not able to find the syscall name, but the catchpoint will be 3418 set anyway. See the example below: 3419 3420 (gdb) catch syscall 764 3421 warning: The number '764' does not represent a known syscall. 3422 Catchpoint 2 (syscall 764) 3423 (gdb) 3424 3425 If you configure GDB using the `--without-expat' option, it 3426 will not be able to display syscall names. Also, if your 3427 architecture does not have an XML file describing its system 3428 calls, you will not be able to see the syscall names. It is 3429 important to notice that these two features are used for 3430 accessing the syscall name database. In either case, you 3431 will see a warning like this: 3432 3433 (gdb) catch syscall 3434 warning: Could not open "syscalls/i386-linux.xml" 3435 warning: Could not load the syscall XML file 'syscalls/i386-linux.xml'. 3436 GDB will not be able to display syscall names. 3437 Catchpoint 1 (syscall) 3438 (gdb) 3439 3440 Of course, the file name will change depending on your 3441 architecture and system. 3442 3443 Still using the example above, you can also try to catch a 3444 syscall by its number. In this case, you would see something 3445 like: 3446 3447 (gdb) catch syscall 252 3448 Catchpoint 1 (syscall(s) 252) 3449 3450 Again, in this case GDB would not be able to display 3451 syscall's names. 3452 3453 `fork' 3454 A call to `fork'. This is currently only available for HP-UX 3455 and GNU/Linux. 3456 3457 `vfork' 3458 A call to `vfork'. This is currently only available for HP-UX 3459 and GNU/Linux. 3460 3461 3462 `tcatch EVENT' 3463 Set a catchpoint that is enabled only for one stop. The 3464 catchpoint is automatically deleted after the first time the event 3465 is caught. 3466 3467 3468 Use the `info break' command to list the current catchpoints. 3469 3470 There are currently some limitations to C++ exception handling 3471 (`catch throw' and `catch catch') in GDB: 3472 3473 * If you call a function interactively, GDB normally returns control 3474 to you when the function has finished executing. If the call 3475 raises an exception, however, the call may bypass the mechanism 3476 that returns control to you and cause your program either to abort 3477 or to simply continue running until it hits a breakpoint, catches 3478 a signal that GDB is listening for, or exits. This is the case 3479 even if you set a catchpoint for the exception; catchpoints on 3480 exceptions are disabled within interactive calls. 3481 3482 * You cannot raise an exception interactively. 3483 3484 * You cannot install an exception handler interactively. 3485 3486 Sometimes `catch' is not the best way to debug exception handling: 3487 if you need to know exactly where an exception is raised, it is better 3488 to stop _before_ the exception handler is called, since that way you 3489 can see the stack before any unwinding takes place. If you set a 3490 breakpoint in an exception handler instead, it may not be easy to find 3491 out where the exception was raised. 3492 3493 To stop just before an exception handler is called, you need some 3494 knowledge of the implementation. In the case of GNU C++, exceptions are 3495 raised by calling a library function named `__raise_exception' which 3496 has the following ANSI C interface: 3497 3498 /* ADDR is where the exception identifier is stored. 3499 ID is the exception identifier. */ 3500 void __raise_exception (void **addr, void *id); 3501 3502 To make the debugger catch all exceptions before any stack unwinding 3503 takes place, set a breakpoint on `__raise_exception' (*note 3504 Breakpoints; Watchpoints; and Exceptions: Breakpoints.). 3505 3506 With a conditional breakpoint (*note Break Conditions: Conditions.) 3507 that depends on the value of ID, you can stop your program when a 3508 specific exception is raised. You can use multiple conditional 3509 breakpoints to stop your program when any of a number of exceptions are 3510 raised. 3511 3512 3513 File: gdb.info, Node: Delete Breaks, Next: Disabling, Prev: Set Catchpoints, Up: Breakpoints 3514 3515 5.1.4 Deleting Breakpoints 3516 -------------------------- 3517 3518 It is often necessary to eliminate a breakpoint, watchpoint, or 3519 catchpoint once it has done its job and you no longer want your program 3520 to stop there. This is called "deleting" the breakpoint. A breakpoint 3521 that has been deleted no longer exists; it is forgotten. 3522 3523 With the `clear' command you can delete breakpoints according to 3524 where they are in your program. With the `delete' command you can 3525 delete individual breakpoints, watchpoints, or catchpoints by specifying 3526 their breakpoint numbers. 3527 3528 It is not necessary to delete a breakpoint to proceed past it. GDB 3529 automatically ignores breakpoints on the first instruction to be 3530 executed when you continue execution without changing the execution 3531 address. 3532 3533 `clear' 3534 Delete any breakpoints at the next instruction to be executed in 3535 the selected stack frame (*note Selecting a Frame: Selection.). 3536 When the innermost frame is selected, this is a good way to delete 3537 a breakpoint where your program just stopped. 3538 3539 `clear LOCATION' 3540 Delete any breakpoints set at the specified LOCATION. *Note 3541 Specify Location::, for the various forms of LOCATION; the most 3542 useful ones are listed below: 3543 3544 `clear FUNCTION' 3545 `clear FILENAME:FUNCTION' 3546 Delete any breakpoints set at entry to the named FUNCTION. 3547 3548 `clear LINENUM' 3549 `clear FILENAME:LINENUM' 3550 Delete any breakpoints set at or within the code of the 3551 specified LINENUM of the specified FILENAME. 3552 3553 `delete [breakpoints] [RANGE...]' 3554 Delete the breakpoints, watchpoints, or catchpoints of the 3555 breakpoint ranges specified as arguments. If no argument is 3556 specified, delete all breakpoints (GDB asks confirmation, unless 3557 you have `set confirm off'). You can abbreviate this command as 3558 `d'. 3559 3560 3561 File: gdb.info, Node: Disabling, Next: Conditions, Prev: Delete Breaks, Up: Breakpoints 3562 3563 5.1.5 Disabling Breakpoints 3564 --------------------------- 3565 3566 Rather than deleting a breakpoint, watchpoint, or catchpoint, you might 3567 prefer to "disable" it. This makes the breakpoint inoperative as if it 3568 had been deleted, but remembers the information on the breakpoint so 3569 that you can "enable" it again later. 3570 3571 You disable and enable breakpoints, watchpoints, and catchpoints with 3572 the `enable' and `disable' commands, optionally specifying one or more 3573 breakpoint numbers as arguments. Use `info break' to print a list of 3574 all breakpoints, watchpoints, and catchpoints if you do not know which 3575 numbers to use. 3576 3577 Disabling and enabling a breakpoint that has multiple locations 3578 affects all of its locations. 3579 3580 A breakpoint, watchpoint, or catchpoint can have any of four 3581 different states of enablement: 3582 3583 * Enabled. The breakpoint stops your program. A breakpoint set 3584 with the `break' command starts out in this state. 3585 3586 * Disabled. The breakpoint has no effect on your program. 3587 3588 * Enabled once. The breakpoint stops your program, but then becomes 3589 disabled. 3590 3591 * Enabled for deletion. The breakpoint stops your program, but 3592 immediately after it does so it is deleted permanently. A 3593 breakpoint set with the `tbreak' command starts out in this state. 3594 3595 You can use the following commands to enable or disable breakpoints, 3596 watchpoints, and catchpoints: 3597 3598 `disable [breakpoints] [RANGE...]' 3599 Disable the specified breakpoints--or all breakpoints, if none are 3600 listed. A disabled breakpoint has no effect but is not forgotten. 3601 All options such as ignore-counts, conditions and commands are 3602 remembered in case the breakpoint is enabled again later. You may 3603 abbreviate `disable' as `dis'. 3604 3605 `enable [breakpoints] [RANGE...]' 3606 Enable the specified breakpoints (or all defined breakpoints). 3607 They become effective once again in stopping your program. 3608 3609 `enable [breakpoints] once RANGE...' 3610 Enable the specified breakpoints temporarily. GDB disables any of 3611 these breakpoints immediately after stopping your program. 3612 3613 `enable [breakpoints] delete RANGE...' 3614 Enable the specified breakpoints to work once, then die. GDB 3615 deletes any of these breakpoints as soon as your program stops 3616 there. Breakpoints set by the `tbreak' command start out in this 3617 state. 3618 3619 Except for a breakpoint set with `tbreak' (*note Setting 3620 Breakpoints: Set Breaks.), breakpoints that you set are initially 3621 enabled; subsequently, they become disabled or enabled only when you 3622 use one of the commands above. (The command `until' can set and delete 3623 a breakpoint of its own, but it does not change the state of your other 3624 breakpoints; see *note Continuing and Stepping: Continuing and 3625 Stepping.) 3626 3627 3628 File: gdb.info, Node: Conditions, Next: Break Commands, Prev: Disabling, Up: Breakpoints 3629 3630 5.1.6 Break Conditions 3631 ---------------------- 3632 3633 The simplest sort of breakpoint breaks every time your program reaches a 3634 specified place. You can also specify a "condition" for a breakpoint. 3635 A condition is just a Boolean expression in your programming language 3636 (*note Expressions: Expressions.). A breakpoint with a condition 3637 evaluates the expression each time your program reaches it, and your 3638 program stops only if the condition is _true_. 3639 3640 This is the converse of using assertions for program validation; in 3641 that situation, you want to stop when the assertion is violated--that 3642 is, when the condition is false. In C, if you want to test an 3643 assertion expressed by the condition ASSERT, you should set the 3644 condition `! ASSERT' on the appropriate breakpoint. 3645 3646 Conditions are also accepted for watchpoints; you may not need them, 3647 since a watchpoint is inspecting the value of an expression anyhow--but 3648 it might be simpler, say, to just set a watchpoint on a variable name, 3649 and specify a condition that tests whether the new value is an 3650 interesting one. 3651 3652 Break conditions can have side effects, and may even call functions 3653 in your program. This can be useful, for example, to activate functions 3654 that log program progress, or to use your own print functions to format 3655 special data structures. The effects are completely predictable unless 3656 there is another enabled breakpoint at the same address. (In that 3657 case, GDB might see the other breakpoint first and stop your program 3658 without checking the condition of this one.) Note that breakpoint 3659 commands are usually more convenient and flexible than break conditions 3660 for the purpose of performing side effects when a breakpoint is reached 3661 (*note Breakpoint Command Lists: Break Commands.). 3662 3663 Break conditions can be specified when a breakpoint is set, by using 3664 `if' in the arguments to the `break' command. *Note Setting 3665 Breakpoints: Set Breaks. They can also be changed at any time with the 3666 `condition' command. 3667 3668 You can also use the `if' keyword with the `watch' command. The 3669 `catch' command does not recognize the `if' keyword; `condition' is the 3670 only way to impose a further condition on a catchpoint. 3671 3672 `condition BNUM EXPRESSION' 3673 Specify EXPRESSION as the break condition for breakpoint, 3674 watchpoint, or catchpoint number BNUM. After you set a condition, 3675 breakpoint BNUM stops your program only if the value of EXPRESSION 3676 is true (nonzero, in C). When you use `condition', GDB checks 3677 EXPRESSION immediately for syntactic correctness, and to determine 3678 whether symbols in it have referents in the context of your 3679 breakpoint. If EXPRESSION uses symbols not referenced in the 3680 context of the breakpoint, GDB prints an error message: 3681 3682 No symbol "foo" in current context. 3683 3684 GDB does not actually evaluate EXPRESSION at the time the 3685 `condition' command (or a command that sets a breakpoint with a 3686 condition, like `break if ...') is given, however. *Note 3687 Expressions: Expressions. 3688 3689 `condition BNUM' 3690 Remove the condition from breakpoint number BNUM. It becomes an 3691 ordinary unconditional breakpoint. 3692 3693 A special case of a breakpoint condition is to stop only when the 3694 breakpoint has been reached a certain number of times. This is so 3695 useful that there is a special way to do it, using the "ignore count" 3696 of the breakpoint. Every breakpoint has an ignore count, which is an 3697 integer. Most of the time, the ignore count is zero, and therefore has 3698 no effect. But if your program reaches a breakpoint whose ignore count 3699 is positive, then instead of stopping, it just decrements the ignore 3700 count by one and continues. As a result, if the ignore count value is 3701 N, the breakpoint does not stop the next N times your program reaches 3702 it. 3703 3704 `ignore BNUM COUNT' 3705 Set the ignore count of breakpoint number BNUM to COUNT. The next 3706 COUNT times the breakpoint is reached, your program's execution 3707 does not stop; other than to decrement the ignore count, GDB takes 3708 no action. 3709 3710 To make the breakpoint stop the next time it is reached, specify a 3711 count of zero. 3712 3713 When you use `continue' to resume execution of your program from a 3714 breakpoint, you can specify an ignore count directly as an 3715 argument to `continue', rather than using `ignore'. *Note 3716 Continuing and Stepping: Continuing and Stepping. 3717 3718 If a breakpoint has a positive ignore count and a condition, the 3719 condition is not checked. Once the ignore count reaches zero, GDB 3720 resumes checking the condition. 3721 3722 You could achieve the effect of the ignore count with a condition 3723 such as `$foo-- <= 0' using a debugger convenience variable that 3724 is decremented each time. *Note Convenience Variables: 3725 Convenience Vars. 3726 3727 Ignore counts apply to breakpoints, watchpoints, and catchpoints. 3728 3729 3730 File: gdb.info, Node: Break Commands, Next: Save Breakpoints, Prev: Conditions, Up: Breakpoints 3731 3732 5.1.7 Breakpoint Command Lists 3733 ------------------------------ 3734 3735 You can give any breakpoint (or watchpoint or catchpoint) a series of 3736 commands to execute when your program stops due to that breakpoint. For 3737 example, you might want to print the values of certain expressions, or 3738 enable other breakpoints. 3739 3740 `commands [RANGE...]' 3741 `... COMMAND-LIST ...' 3742 `end' 3743 Specify a list of commands for the given breakpoints. The commands 3744 themselves appear on the following lines. Type a line containing 3745 just `end' to terminate the commands. 3746 3747 To remove all commands from a breakpoint, type `commands' and 3748 follow it immediately with `end'; that is, give no commands. 3749 3750 With no argument, `commands' refers to the last breakpoint, 3751 watchpoint, or catchpoint set (not to the breakpoint most recently 3752 encountered). If the most recent breakpoints were set with a 3753 single command, then the `commands' will apply to all the 3754 breakpoints set by that command. This applies to breakpoints set 3755 by `rbreak', and also applies when a single `break' command 3756 creates multiple breakpoints (*note Ambiguous Expressions: 3757 Ambiguous Expressions.). 3758 3759 Pressing <RET> as a means of repeating the last GDB command is 3760 disabled within a COMMAND-LIST. 3761 3762 You can use breakpoint commands to start your program up again. 3763 Simply use the `continue' command, or `step', or any other command that 3764 resumes execution. 3765 3766 Any other commands in the command list, after a command that resumes 3767 execution, are ignored. This is because any time you resume execution 3768 (even with a simple `next' or `step'), you may encounter another 3769 breakpoint--which could have its own command list, leading to 3770 ambiguities about which list to execute. 3771 3772 If the first command you specify in a command list is `silent', the 3773 usual message about stopping at a breakpoint is not printed. This may 3774 be desirable for breakpoints that are to print a specific message and 3775 then continue. If none of the remaining commands print anything, you 3776 see no sign that the breakpoint was reached. `silent' is meaningful 3777 only at the beginning of a breakpoint command list. 3778 3779 The commands `echo', `output', and `printf' allow you to print 3780 precisely controlled output, and are often useful in silent 3781 breakpoints. *Note Commands for Controlled Output: Output. 3782 3783 For example, here is how you could use breakpoint commands to print 3784 the value of `x' at entry to `foo' whenever `x' is positive. 3785 3786 break foo if x>0 3787 commands 3788 silent 3789 printf "x is %d\n",x 3790 cont 3791 end 3792 3793 One application for breakpoint commands is to compensate for one bug 3794 so you can test for another. Put a breakpoint just after the erroneous 3795 line of code, give it a condition to detect the case in which something 3796 erroneous has been done, and give it commands to assign correct values 3797 to any variables that need them. End with the `continue' command so 3798 that your program does not stop, and start with the `silent' command so 3799 that no output is produced. Here is an example: 3800 3801 break 403 3802 commands 3803 silent 3804 set x = y + 4 3805 cont 3806 end 3807 3808 3809 File: gdb.info, Node: Save Breakpoints, Next: Error in Breakpoints, Prev: Break Commands, Up: Breakpoints 3810 3811 5.1.8 How to save breakpoints to a file 3812 --------------------------------------- 3813 3814 To save breakpoint definitions to a file use the `save breakpoints' 3815 command. 3816 3817 `save breakpoints [FILENAME]' 3818 This command saves all current breakpoint definitions together with 3819 their commands and ignore counts, into a file `FILENAME' suitable 3820 for use in a later debugging session. This includes all types of 3821 breakpoints (breakpoints, watchpoints, catchpoints, tracepoints). 3822 To read the saved breakpoint definitions, use the `source' command 3823 (*note Command Files::). Note that watchpoints with expressions 3824 involving local variables may fail to be recreated because it may 3825 not be possible to access the context where the watchpoint is 3826 valid anymore. Because the saved breakpoint definitions are 3827 simply a sequence of GDB commands that recreate the breakpoints, 3828 you can edit the file in your favorite editing program, and remove 3829 the breakpoint definitions you're not interested in, or that can 3830 no longer be recreated. 3831 3832 3833 File: gdb.info, Node: Error in Breakpoints, Next: Breakpoint-related Warnings, Prev: Save Breakpoints, Up: Breakpoints 3834 3835 5.1.9 "Cannot insert breakpoints" 3836 --------------------------------- 3837 3838 If you request too many active hardware-assisted breakpoints and 3839 watchpoints, you will see this error message: 3840 3841 Stopped; cannot insert breakpoints. 3842 You may have requested too many hardware breakpoints and watchpoints. 3843 3844 This message is printed when you attempt to resume the program, since 3845 only then GDB knows exactly how many hardware breakpoints and 3846 watchpoints it needs to insert. 3847 3848 When this message is printed, you need to disable or remove some of 3849 the hardware-assisted breakpoints and watchpoints, and then continue. 3850 3851 3852 File: gdb.info, Node: Breakpoint-related Warnings, Prev: Error in Breakpoints, Up: Breakpoints 3853 3854 5.1.10 "Breakpoint address adjusted..." 3855 --------------------------------------- 3856 3857 Some processor architectures place constraints on the addresses at 3858 which breakpoints may be placed. For architectures thus constrained, 3859 GDB will attempt to adjust the breakpoint's address to comply with the 3860 constraints dictated by the architecture. 3861 3862 One example of such an architecture is the Fujitsu FR-V. The FR-V is 3863 a VLIW architecture in which a number of RISC-like instructions may be 3864 bundled together for parallel execution. The FR-V architecture 3865 constrains the location of a breakpoint instruction within such a 3866 bundle to the instruction with the lowest address. GDB honors this 3867 constraint by adjusting a breakpoint's address to the first in the 3868 bundle. 3869 3870 It is not uncommon for optimized code to have bundles which contain 3871 instructions from different source statements, thus it may happen that 3872 a breakpoint's address will be adjusted from one source statement to 3873 another. Since this adjustment may significantly alter GDB's 3874 breakpoint related behavior from what the user expects, a warning is 3875 printed when the breakpoint is first set and also when the breakpoint 3876 is hit. 3877 3878 A warning like the one below is printed when setting a breakpoint 3879 that's been subject to address adjustment: 3880 3881 warning: Breakpoint address adjusted from 0x00010414 to 0x00010410. 3882 3883 Such warnings are printed both for user settable and GDB's internal 3884 breakpoints. If you see one of these warnings, you should verify that 3885 a breakpoint set at the adjusted address will have the desired affect. 3886 If not, the breakpoint in question may be removed and other breakpoints 3887 may be set which will have the desired behavior. E.g., it may be 3888 sufficient to place the breakpoint at a later instruction. A 3889 conditional breakpoint may also be useful in some cases to prevent the 3890 breakpoint from triggering too often. 3891 3892 GDB will also issue a warning when stopping at one of these adjusted 3893 breakpoints: 3894 3895 warning: Breakpoint 1 address previously adjusted from 0x00010414 3896 to 0x00010410. 3897 3898 When this warning is encountered, it may be too late to take remedial 3899 action except in cases where the breakpoint is hit earlier or more 3900 frequently than expected. 3901 3902 3903 File: gdb.info, Node: Continuing and Stepping, Next: Signals, Prev: Breakpoints, Up: Stopping 3904 3905 5.2 Continuing and Stepping 3906 =========================== 3907 3908 "Continuing" means resuming program execution until your program 3909 completes normally. In contrast, "stepping" means executing just one 3910 more "step" of your program, where "step" may mean either one line of 3911 source code, or one machine instruction (depending on what particular 3912 command you use). Either when continuing or when stepping, your 3913 program may stop even sooner, due to a breakpoint or a signal. (If it 3914 stops due to a signal, you may want to use `handle', or use `signal 0' 3915 to resume execution. *Note Signals: Signals.) 3916 3917 `continue [IGNORE-COUNT]' 3918 `c [IGNORE-COUNT]' 3919 `fg [IGNORE-COUNT]' 3920 Resume program execution, at the address where your program last 3921 stopped; any breakpoints set at that address are bypassed. The 3922 optional argument IGNORE-COUNT allows you to specify a further 3923 number of times to ignore a breakpoint at this location; its 3924 effect is like that of `ignore' (*note Break Conditions: 3925 Conditions.). 3926 3927 The argument IGNORE-COUNT is meaningful only when your program 3928 stopped due to a breakpoint. At other times, the argument to 3929 `continue' is ignored. 3930 3931 The synonyms `c' and `fg' (for "foreground", as the debugged 3932 program is deemed to be the foreground program) are provided 3933 purely for convenience, and have exactly the same behavior as 3934 `continue'. 3935 3936 To resume execution at a different place, you can use `return' 3937 (*note Returning from a Function: Returning.) to go back to the calling 3938 function; or `jump' (*note Continuing at a Different Address: Jumping.) 3939 to go to an arbitrary location in your program. 3940 3941 A typical technique for using stepping is to set a breakpoint (*note 3942 Breakpoints; Watchpoints; and Catchpoints: Breakpoints.) at the 3943 beginning of the function or the section of your program where a problem 3944 is believed to lie, run your program until it stops at that breakpoint, 3945 and then step through the suspect area, examining the variables that are 3946 interesting, until you see the problem happen. 3947 3948 `step' 3949 Continue running your program until control reaches a different 3950 source line, then stop it and return control to GDB. This command 3951 is abbreviated `s'. 3952 3953 _Warning:_ If you use the `step' command while control is 3954 within a function that was compiled without debugging 3955 information, execution proceeds until control reaches a 3956 function that does have debugging information. Likewise, it 3957 will not step into a function which is compiled without 3958 debugging information. To step through functions without 3959 debugging information, use the `stepi' command, described 3960 below. 3961 3962 The `step' command only stops at the first instruction of a source 3963 line. This prevents the multiple stops that could otherwise occur 3964 in `switch' statements, `for' loops, etc. `step' continues to 3965 stop if a function that has debugging information is called within 3966 the line. In other words, `step' _steps inside_ any functions 3967 called within the line. 3968 3969 Also, the `step' command only enters a function if there is line 3970 number information for the function. Otherwise it acts like the 3971 `next' command. This avoids problems when using `cc -gl' on MIPS 3972 machines. Previously, `step' entered subroutines if there was any 3973 debugging information about the routine. 3974 3975 `step COUNT' 3976 Continue running as in `step', but do so COUNT times. If a 3977 breakpoint is reached, or a signal not related to stepping occurs 3978 before COUNT steps, stepping stops right away. 3979 3980 `next [COUNT]' 3981 Continue to the next source line in the current (innermost) stack 3982 frame. This is similar to `step', but function calls that appear 3983 within the line of code are executed without stopping. Execution 3984 stops when control reaches a different line of code at the 3985 original stack level that was executing when you gave the `next' 3986 command. This command is abbreviated `n'. 3987 3988 An argument COUNT is a repeat count, as for `step'. 3989 3990 The `next' command only stops at the first instruction of a source 3991 line. This prevents multiple stops that could otherwise occur in 3992 `switch' statements, `for' loops, etc. 3993 3994 `set step-mode' 3995 `set step-mode on' 3996 The `set step-mode on' command causes the `step' command to stop 3997 at the first instruction of a function which contains no debug line 3998 information rather than stepping over it. 3999 4000 This is useful in cases where you may be interested in inspecting 4001 the machine instructions of a function which has no symbolic info 4002 and do not want GDB to automatically skip over this function. 4003 4004 `set step-mode off' 4005 Causes the `step' command to step over any functions which 4006 contains no debug information. This is the default. 4007 4008 `show step-mode' 4009 Show whether GDB will stop in or step over functions without 4010 source line debug information. 4011 4012 `finish' 4013 Continue running until just after function in the selected stack 4014 frame returns. Print the returned value (if any). This command 4015 can be abbreviated as `fin'. 4016 4017 Contrast this with the `return' command (*note Returning from a 4018 Function: Returning.). 4019 4020 `until' 4021 `u' 4022 Continue running until a source line past the current line, in the 4023 current stack frame, is reached. This command is used to avoid 4024 single stepping through a loop more than once. It is like the 4025 `next' command, except that when `until' encounters a jump, it 4026 automatically continues execution until the program counter is 4027 greater than the address of the jump. 4028 4029 This means that when you reach the end of a loop after single 4030 stepping though it, `until' makes your program continue execution 4031 until it exits the loop. In contrast, a `next' command at the end 4032 of a loop simply steps back to the beginning of the loop, which 4033 forces you to step through the next iteration. 4034 4035 `until' always stops your program if it attempts to exit the 4036 current stack frame. 4037 4038 `until' may produce somewhat counterintuitive results if the order 4039 of machine code does not match the order of the source lines. For 4040 example, in the following excerpt from a debugging session, the `f' 4041 (`frame') command shows that execution is stopped at line `206'; 4042 yet when we use `until', we get to line `195': 4043 4044 (gdb) f 4045 #0 main (argc=4, argv=0xf7fffae8) at m4.c:206 4046 206 expand_input(); 4047 (gdb) until 4048 195 for ( ; argc > 0; NEXTARG) { 4049 4050 This happened because, for execution efficiency, the compiler had 4051 generated code for the loop closure test at the end, rather than 4052 the start, of the loop--even though the test in a C `for'-loop is 4053 written before the body of the loop. The `until' command appeared 4054 to step back to the beginning of the loop when it advanced to this 4055 expression; however, it has not really gone to an earlier 4056 statement--not in terms of the actual machine code. 4057 4058 `until' with no argument works by means of single instruction 4059 stepping, and hence is slower than `until' with an argument. 4060 4061 `until LOCATION' 4062 `u LOCATION' 4063 Continue running your program until either the specified location 4064 is reached, or the current stack frame returns. LOCATION is any of 4065 the forms described in *note Specify Location::. This form of the 4066 command uses temporary breakpoints, and hence is quicker than 4067 `until' without an argument. The specified location is actually 4068 reached only if it is in the current frame. This implies that 4069 `until' can be used to skip over recursive function invocations. 4070 For instance in the code below, if the current location is line 4071 `96', issuing `until 99' will execute the program up to line `99' 4072 in the same invocation of factorial, i.e., after the inner 4073 invocations have returned. 4074 4075 94 int factorial (int value) 4076 95 { 4077 96 if (value > 1) { 4078 97 value *= factorial (value - 1); 4079 98 } 4080 99 return (value); 4081 100 } 4082 4083 `advance LOCATION' 4084 Continue running the program up to the given LOCATION. An 4085 argument is required, which should be of one of the forms 4086 described in *note Specify Location::. Execution will also stop 4087 upon exit from the current stack frame. This command is similar 4088 to `until', but `advance' will not skip over recursive function 4089 calls, and the target location doesn't have to be in the same 4090 frame as the current one. 4091 4092 `stepi' 4093 `stepi ARG' 4094 `si' 4095 Execute one machine instruction, then stop and return to the 4096 debugger. 4097 4098 It is often useful to do `display/i $pc' when stepping by machine 4099 instructions. This makes GDB automatically display the next 4100 instruction to be executed, each time your program stops. *Note 4101 Automatic Display: Auto Display. 4102 4103 An argument is a repeat count, as in `step'. 4104 4105 `nexti' 4106 `nexti ARG' 4107 `ni' 4108 Execute one machine instruction, but if it is a function call, 4109 proceed until the function returns. 4110 4111 An argument is a repeat count, as in `next'. 4112 4113 4114 File: gdb.info, Node: Signals, Next: Thread Stops, Prev: Continuing and Stepping, Up: Stopping 4115 4116 5.3 Signals 4117 =========== 4118 4119 A signal is an asynchronous event that can happen in a program. The 4120 operating system defines the possible kinds of signals, and gives each 4121 kind a name and a number. For example, in Unix `SIGINT' is the signal 4122 a program gets when you type an interrupt character (often `Ctrl-c'); 4123 `SIGSEGV' is the signal a program gets from referencing a place in 4124 memory far away from all the areas in use; `SIGALRM' occurs when the 4125 alarm clock timer goes off (which happens only if your program has 4126 requested an alarm). 4127 4128 Some signals, including `SIGALRM', are a normal part of the 4129 functioning of your program. Others, such as `SIGSEGV', indicate 4130 errors; these signals are "fatal" (they kill your program immediately) 4131 if the program has not specified in advance some other way to handle 4132 the signal. `SIGINT' does not indicate an error in your program, but 4133 it is normally fatal so it can carry out the purpose of the interrupt: 4134 to kill the program. 4135 4136 GDB has the ability to detect any occurrence of a signal in your 4137 program. You can tell GDB in advance what to do for each kind of 4138 signal. 4139 4140 Normally, GDB is set up to let the non-erroneous signals like 4141 `SIGALRM' be silently passed to your program (so as not to interfere 4142 with their role in the program's functioning) but to stop your program 4143 immediately whenever an error signal happens. You can change these 4144 settings with the `handle' command. 4145 4146 `info signals' 4147 `info handle' 4148 Print a table of all the kinds of signals and how GDB has been 4149 told to handle each one. You can use this to see the signal 4150 numbers of all the defined types of signals. 4151 4152 `info signals SIG' 4153 Similar, but print information only about the specified signal 4154 number. 4155 4156 `info handle' is an alias for `info signals'. 4157 4158 `handle SIGNAL [KEYWORDS...]' 4159 Change the way GDB handles signal SIGNAL. SIGNAL can be the 4160 number of a signal or its name (with or without the `SIG' at the 4161 beginning); a list of signal numbers of the form `LOW-HIGH'; or 4162 the word `all', meaning all the known signals. Optional arguments 4163 KEYWORDS, described below, say what change to make. 4164 4165 The keywords allowed by the `handle' command can be abbreviated. 4166 Their full names are: 4167 4168 `nostop' 4169 GDB should not stop your program when this signal happens. It may 4170 still print a message telling you that the signal has come in. 4171 4172 `stop' 4173 GDB should stop your program when this signal happens. This 4174 implies the `print' keyword as well. 4175 4176 `print' 4177 GDB should print a message when this signal happens. 4178 4179 `noprint' 4180 GDB should not mention the occurrence of the signal at all. This 4181 implies the `nostop' keyword as well. 4182 4183 `pass' 4184 `noignore' 4185 GDB should allow your program to see this signal; your program can 4186 handle the signal, or else it may terminate if the signal is fatal 4187 and not handled. `pass' and `noignore' are synonyms. 4188 4189 `nopass' 4190 `ignore' 4191 GDB should not allow your program to see this signal. `nopass' 4192 and `ignore' are synonyms. 4193 4194 When a signal stops your program, the signal is not visible to the 4195 program until you continue. Your program sees the signal then, if 4196 `pass' is in effect for the signal in question _at that time_. In 4197 other words, after GDB reports a signal, you can use the `handle' 4198 command with `pass' or `nopass' to control whether your program sees 4199 that signal when you continue. 4200 4201 The default is set to `nostop', `noprint', `pass' for non-erroneous 4202 signals such as `SIGALRM', `SIGWINCH' and `SIGCHLD', and to `stop', 4203 `print', `pass' for the erroneous signals. 4204 4205 You can also use the `signal' command to prevent your program from 4206 seeing a signal, or cause it to see a signal it normally would not see, 4207 or to give it any signal at any time. For example, if your program 4208 stopped due to some sort of memory reference error, you might store 4209 correct values into the erroneous variables and continue, hoping to see 4210 more execution; but your program would probably terminate immediately as 4211 a result of the fatal signal once it saw the signal. To prevent this, 4212 you can continue with `signal 0'. *Note Giving your Program a Signal: 4213 Signaling. 4214 4215 On some targets, GDB can inspect extra signal information associated 4216 with the intercepted signal, before it is actually delivered to the 4217 program being debugged. This information is exported by the 4218 convenience variable `$_siginfo', and consists of data that is passed 4219 by the kernel to the signal handler at the time of the receipt of a 4220 signal. The data type of the information itself is target dependent. 4221 You can see the data type using the `ptype $_siginfo' command. On Unix 4222 systems, it typically corresponds to the standard `siginfo_t' type, as 4223 defined in the `signal.h' system header. 4224 4225 Here's an example, on a GNU/Linux system, printing the stray 4226 referenced address that raised a segmentation fault. 4227 4228 (gdb) continue 4229 Program received signal SIGSEGV, Segmentation fault. 4230 0x0000000000400766 in main () 4231 69 *(int *)p = 0; 4232 (gdb) ptype $_siginfo 4233 type = struct { 4234 int si_signo; 4235 int si_errno; 4236 int si_code; 4237 union { 4238 int _pad[28]; 4239 struct {...} _kill; 4240 struct {...} _timer; 4241 struct {...} _rt; 4242 struct {...} _sigchld; 4243 struct {...} _sigfault; 4244 struct {...} _sigpoll; 4245 } _sifields; 4246 } 4247 (gdb) ptype $_siginfo._sifields._sigfault 4248 type = struct { 4249 void *si_addr; 4250 } 4251 (gdb) p $_siginfo._sifields._sigfault.si_addr 4252 $1 = (void *) 0x7ffff7ff7000 4253 4254 Depending on target support, `$_siginfo' may also be writable. 4255 4256 4257 File: gdb.info, Node: Thread Stops, Prev: Signals, Up: Stopping 4258 4259 5.4 Stopping and Starting Multi-thread Programs 4260 =============================================== 4261 4262 GDB supports debugging programs with multiple threads (*note Debugging 4263 Programs with Multiple Threads: Threads.). There are two modes of 4264 controlling execution of your program within the debugger. In the 4265 default mode, referred to as "all-stop mode", when any thread in your 4266 program stops (for example, at a breakpoint or while being stepped), 4267 all other threads in the program are also stopped by GDB. On some 4268 targets, GDB also supports "non-stop mode", in which other threads can 4269 continue to run freely while you examine the stopped thread in the 4270 debugger. 4271 4272 * Menu: 4273 4274 * All-Stop Mode:: All threads stop when GDB takes control 4275 * Non-Stop Mode:: Other threads continue to execute 4276 * Background Execution:: Running your program asynchronously 4277 * Thread-Specific Breakpoints:: Controlling breakpoints 4278 * Interrupted System Calls:: GDB may interfere with system calls 4279 * Observer Mode:: GDB does not alter program behavior 4280 4281 4282 File: gdb.info, Node: All-Stop Mode, Next: Non-Stop Mode, Up: Thread Stops 4283 4284 5.4.1 All-Stop Mode 4285 ------------------- 4286 4287 In all-stop mode, whenever your program stops under GDB for any reason, 4288 _all_ threads of execution stop, not just the current thread. This 4289 allows you to examine the overall state of the program, including 4290 switching between threads, without worrying that things may change 4291 underfoot. 4292 4293 Conversely, whenever you restart the program, _all_ threads start 4294 executing. _This is true even when single-stepping_ with commands like 4295 `step' or `next'. 4296 4297 In particular, GDB cannot single-step all threads in lockstep. 4298 Since thread scheduling is up to your debugging target's operating 4299 system (not controlled by GDB), other threads may execute more than one 4300 statement while the current thread completes a single step. Moreover, 4301 in general other threads stop in the middle of a statement, rather than 4302 at a clean statement boundary, when the program stops. 4303 4304 You might even find your program stopped in another thread after 4305 continuing or even single-stepping. This happens whenever some other 4306 thread runs into a breakpoint, a signal, or an exception before the 4307 first thread completes whatever you requested. 4308 4309 Whenever GDB stops your program, due to a breakpoint or a signal, it 4310 automatically selects the thread where that breakpoint or signal 4311 happened. GDB alerts you to the context switch with a message such as 4312 `[Switching to Thread N]' to identify the thread. 4313 4314 On some OSes, you can modify GDB's default behavior by locking the 4315 OS scheduler to allow only a single thread to run. 4316 4317 `set scheduler-locking MODE' 4318 Set the scheduler locking mode. If it is `off', then there is no 4319 locking and any thread may run at any time. If `on', then only the 4320 current thread may run when the inferior is resumed. The `step' 4321 mode optimizes for single-stepping; it prevents other threads from 4322 preempting the current thread while you are stepping, so that the 4323 focus of debugging does not change unexpectedly. Other threads 4324 only rarely (or never) get a chance to run when you step. They 4325 are more likely to run when you `next' over a function call, and 4326 they are completely free to run when you use commands like 4327 `continue', `until', or `finish'. However, unless another thread 4328 hits a breakpoint during its timeslice, GDB does not change the 4329 current thread away from the thread that you are debugging. 4330 4331 `show scheduler-locking' 4332 Display the current scheduler locking mode. 4333 4334 By default, when you issue one of the execution commands such as 4335 `continue', `next' or `step', GDB allows only threads of the current 4336 inferior to run. For example, if GDB is attached to two inferiors, 4337 each with two threads, the `continue' command resumes only the two 4338 threads of the current inferior. This is useful, for example, when you 4339 debug a program that forks and you want to hold the parent stopped (so 4340 that, for instance, it doesn't run to exit), while you debug the child. 4341 In other situations, you may not be interested in inspecting the 4342 current state of any of the processes GDB is attached to, and you may 4343 want to resume them all until some breakpoint is hit. In the latter 4344 case, you can instruct GDB to allow all threads of all the inferiors to 4345 run with the `set schedule-multiple' command. 4346 4347 `set schedule-multiple' 4348 Set the mode for allowing threads of multiple processes to be 4349 resumed when an execution command is issued. When `on', all 4350 threads of all processes are allowed to run. When `off', only the 4351 threads of the current process are resumed. The default is `off'. 4352 The `scheduler-locking' mode takes precedence when set to `on', or 4353 while you are stepping and set to `step'. 4354 4355 `show schedule-multiple' 4356 Display the current mode for resuming the execution of threads of 4357 multiple processes. 4358 4359 4360 File: gdb.info, Node: Non-Stop Mode, Next: Background Execution, Prev: All-Stop Mode, Up: Thread Stops 4361 4362 5.4.2 Non-Stop Mode 4363 ------------------- 4364 4365 For some multi-threaded targets, GDB supports an optional mode of 4366 operation in which you can examine stopped program threads in the 4367 debugger while other threads continue to execute freely. This 4368 minimizes intrusion when debugging live systems, such as programs where 4369 some threads have real-time constraints or must continue to respond to 4370 external events. This is referred to as "non-stop" mode. 4371 4372 In non-stop mode, when a thread stops to report a debugging event, 4373 _only_ that thread is stopped; GDB does not stop other threads as well, 4374 in contrast to the all-stop mode behavior. Additionally, execution 4375 commands such as `continue' and `step' apply by default only to the 4376 current thread in non-stop mode, rather than all threads as in all-stop 4377 mode. This allows you to control threads explicitly in ways that are 4378 not possible in all-stop mode -- for example, stepping one thread while 4379 allowing others to run freely, stepping one thread while holding all 4380 others stopped, or stepping several threads independently and 4381 simultaneously. 4382 4383 To enter non-stop mode, use this sequence of commands before you run 4384 or attach to your program: 4385 4386 # Enable the async interface. 4387 set target-async 1 4388 4389 # If using the CLI, pagination breaks non-stop. 4390 set pagination off 4391 4392 # Finally, turn it on! 4393 set non-stop on 4394 4395 You can use these commands to manipulate the non-stop mode setting: 4396 4397 `set non-stop on' 4398 Enable selection of non-stop mode. 4399 4400 `set non-stop off' 4401 Disable selection of non-stop mode. 4402 4403 `show non-stop' 4404 Show the current non-stop enablement setting. 4405 4406 Note these commands only reflect whether non-stop mode is enabled, 4407 not whether the currently-executing program is being run in non-stop 4408 mode. In particular, the `set non-stop' preference is only consulted 4409 when GDB starts or connects to the target program, and it is generally 4410 not possible to switch modes once debugging has started. Furthermore, 4411 since not all targets support non-stop mode, even when you have enabled 4412 non-stop mode, GDB may still fall back to all-stop operation by default. 4413 4414 In non-stop mode, all execution commands apply only to the current 4415 thread by default. That is, `continue' only continues one thread. To 4416 continue all threads, issue `continue -a' or `c -a'. 4417 4418 You can use GDB's background execution commands (*note Background 4419 Execution::) to run some threads in the background while you continue 4420 to examine or step others from GDB. The MI execution commands (*note 4421 GDB/MI Program Execution::) are always executed asynchronously in 4422 non-stop mode. 4423 4424 Suspending execution is done with the `interrupt' command when 4425 running in the background, or `Ctrl-c' during foreground execution. In 4426 all-stop mode, this stops the whole process; but in non-stop mode the 4427 interrupt applies only to the current thread. To stop the whole 4428 program, use `interrupt -a'. 4429 4430 Other execution commands do not currently support the `-a' option. 4431 4432 In non-stop mode, when a thread stops, GDB doesn't automatically make 4433 that thread current, as it does in all-stop mode. This is because the 4434 thread stop notifications are asynchronous with respect to GDB's 4435 command interpreter, and it would be confusing if GDB unexpectedly 4436 changed to a different thread just as you entered a command to operate 4437 on the previously current thread. 4438 4439 4440 File: gdb.info, Node: Background Execution, Next: Thread-Specific Breakpoints, Prev: Non-Stop Mode, Up: Thread Stops 4441 4442 5.4.3 Background Execution 4443 -------------------------- 4444 4445 GDB's execution commands have two variants: the normal foreground 4446 (synchronous) behavior, and a background (asynchronous) behavior. In 4447 foreground execution, GDB waits for the program to report that some 4448 thread has stopped before prompting for another command. In background 4449 execution, GDB immediately gives a command prompt so that you can issue 4450 other commands while your program runs. 4451 4452 You need to explicitly enable asynchronous mode before you can use 4453 background execution commands. You can use these commands to 4454 manipulate the asynchronous mode setting: 4455 4456 `set target-async on' 4457 Enable asynchronous mode. 4458 4459 `set target-async off' 4460 Disable asynchronous mode. 4461 4462 `show target-async' 4463 Show the current target-async setting. 4464 4465 If the target doesn't support async mode, GDB issues an error 4466 message if you attempt to use the background execution commands. 4467 4468 To specify background execution, add a `&' to the command. For 4469 example, the background form of the `continue' command is `continue&', 4470 or just `c&'. The execution commands that accept background execution 4471 are: 4472 4473 `run' 4474 *Note Starting your Program: Starting. 4475 4476 `attach' 4477 *Note Debugging an Already-running Process: Attach. 4478 4479 `step' 4480 *Note step: Continuing and Stepping. 4481 4482 `stepi' 4483 *Note stepi: Continuing and Stepping. 4484 4485 `next' 4486 *Note next: Continuing and Stepping. 4487 4488 `nexti' 4489 *Note nexti: Continuing and Stepping. 4490 4491 `continue' 4492 *Note continue: Continuing and Stepping. 4493 4494 `finish' 4495 *Note finish: Continuing and Stepping. 4496 4497 `until' 4498 *Note until: Continuing and Stepping. 4499 4500 4501 Background execution is especially useful in conjunction with 4502 non-stop mode for debugging programs with multiple threads; see *note 4503 Non-Stop Mode::. However, you can also use these commands in the 4504 normal all-stop mode with the restriction that you cannot issue another 4505 execution command until the previous one finishes. Examples of 4506 commands that are valid in all-stop mode while the program is running 4507 include `help' and `info break'. 4508 4509 You can interrupt your program while it is running in the background 4510 by using the `interrupt' command. 4511 4512 `interrupt' 4513 `interrupt -a' 4514 Suspend execution of the running program. In all-stop mode, 4515 `interrupt' stops the whole process, but in non-stop mode, it stops 4516 only the current thread. To stop the whole program in non-stop 4517 mode, use `interrupt -a'. 4518 4519 4520 File: gdb.info, Node: Thread-Specific Breakpoints, Next: Interrupted System Calls, Prev: Background Execution, Up: Thread Stops 4521 4522 5.4.4 Thread-Specific Breakpoints 4523 --------------------------------- 4524 4525 When your program has multiple threads (*note Debugging Programs with 4526 Multiple Threads: Threads.), you can choose whether to set breakpoints 4527 on all threads, or on a particular thread. 4528 4529 `break LINESPEC thread THREADNO' 4530 `break LINESPEC thread THREADNO if ...' 4531 LINESPEC specifies source lines; there are several ways of writing 4532 them (*note Specify Location::), but the effect is always to 4533 specify some source line. 4534 4535 Use the qualifier `thread THREADNO' with a breakpoint command to 4536 specify that you only want GDB to stop the program when a 4537 particular thread reaches this breakpoint. THREADNO is one of the 4538 numeric thread identifiers assigned by GDB, shown in the first 4539 column of the `info threads' display. 4540 4541 If you do not specify `thread THREADNO' when you set a breakpoint, 4542 the breakpoint applies to _all_ threads of your program. 4543 4544 You can use the `thread' qualifier on conditional breakpoints as 4545 well; in this case, place `thread THREADNO' before or after the 4546 breakpoint condition, like this: 4547 4548 (gdb) break frik.c:13 thread 28 if bartab > lim 4549 4550 4551 4552 File: gdb.info, Node: Interrupted System Calls, Next: Observer Mode, Prev: Thread-Specific Breakpoints, Up: Thread Stops 4553 4554 5.4.5 Interrupted System Calls 4555 ------------------------------ 4556 4557 There is an unfortunate side effect when using GDB to debug 4558 multi-threaded programs. If one thread stops for a breakpoint, or for 4559 some other reason, and another thread is blocked in a system call, then 4560 the system call may return prematurely. This is a consequence of the 4561 interaction between multiple threads and the signals that GDB uses to 4562 implement breakpoints and other events that stop execution. 4563 4564 To handle this problem, your program should check the return value of 4565 each system call and react appropriately. This is good programming 4566 style anyways. 4567 4568 For example, do not write code like this: 4569 4570 sleep (10); 4571 4572 The call to `sleep' will return early if a different thread stops at 4573 a breakpoint or for some other reason. 4574 4575 Instead, write this: 4576 4577 int unslept = 10; 4578 while (unslept > 0) 4579 unslept = sleep (unslept); 4580 4581 A system call is allowed to return early, so the system is still 4582 conforming to its specification. But GDB does cause your 4583 multi-threaded program to behave differently than it would without GDB. 4584 4585 Also, GDB uses internal breakpoints in the thread library to monitor 4586 certain events such as thread creation and thread destruction. When 4587 such an event happens, a system call in another thread may return 4588 prematurely, even though your program does not appear to stop. 4589 4590 4591 File: gdb.info, Node: Observer Mode, Prev: Interrupted System Calls, Up: Thread Stops 4592 4593 5.4.6 Observer Mode 4594 ------------------- 4595 4596 If you want to build on non-stop mode and observe program behavior 4597 without any chance of disruption by GDB, you can set variables to 4598 disable all of the debugger's attempts to modify state, whether by 4599 writing memory, inserting breakpoints, etc. These operate at a low 4600 level, intercepting operations from all commands. 4601 4602 When all of these are set to `off', then GDB is said to be "observer 4603 mode". As a convenience, the variable `observer' can be set to disable 4604 these, plus enable non-stop mode. 4605 4606 Note that GDB will not prevent you from making nonsensical 4607 combinations of these settings. For instance, if you have enabled 4608 `may-insert-breakpoints' but disabled `may-write-memory', then 4609 breakpoints that work by writing trap instructions into the code stream 4610 will still not be able to be placed. 4611 4612 `set observer on' 4613 `set observer off' 4614 When set to `on', this disables all the permission variables below 4615 (except for `insert-fast-tracepoints'), plus enables non-stop 4616 debugging. Setting this to `off' switches back to normal 4617 debugging, though remaining in non-stop mode. 4618 4619 `show observer' 4620 Show whether observer mode is on or off. 4621 4622 `set may-write-registers on' 4623 `set may-write-registers off' 4624 This controls whether GDB will attempt to alter the values of 4625 registers, such as with assignment expressions in `print', or the 4626 `jump' command. It defaults to `on'. 4627 4628 `show may-write-registers' 4629 Show the current permission to write registers. 4630 4631 `set may-write-memory on' 4632 `set may-write-memory off' 4633 This controls whether GDB will attempt to alter the contents of 4634 memory, such as with assignment expressions in `print'. It 4635 defaults to `on'. 4636 4637 `show may-write-memory' 4638 Show the current permission to write memory. 4639 4640 `set may-insert-breakpoints on' 4641 `set may-insert-breakpoints off' 4642 This controls whether GDB will attempt to insert breakpoints. 4643 This affects all breakpoints, including internal breakpoints 4644 defined by GDB. It defaults to `on'. 4645 4646 `show may-insert-breakpoints' 4647 Show the current permission to insert breakpoints. 4648 4649 `set may-insert-tracepoints on' 4650 `set may-insert-tracepoints off' 4651 This controls whether GDB will attempt to insert (regular) 4652 tracepoints at the beginning of a tracing experiment. It affects 4653 only non-fast tracepoints, fast tracepoints being under the 4654 control of `may-insert-fast-tracepoints'. It defaults to `on'. 4655 4656 `show may-insert-tracepoints' 4657 Show the current permission to insert tracepoints. 4658 4659 `set may-insert-fast-tracepoints on' 4660 `set may-insert-fast-tracepoints off' 4661 This controls whether GDB will attempt to insert fast tracepoints 4662 at the beginning of a tracing experiment. It affects only fast 4663 tracepoints, regular (non-fast) tracepoints being under the 4664 control of `may-insert-tracepoints'. It defaults to `on'. 4665 4666 `show may-insert-fast-tracepoints' 4667 Show the current permission to insert fast tracepoints. 4668 4669 `set may-interrupt on' 4670 `set may-interrupt off' 4671 This controls whether GDB will attempt to interrupt or stop 4672 program execution. When this variable is `off', the `interrupt' 4673 command will have no effect, nor will `Ctrl-c'. It defaults to 4674 `on'. 4675 4676 `show may-interrupt' 4677 Show the current permission to interrupt or stop the program. 4678 4679 4680 4681 File: gdb.info, Node: Reverse Execution, Next: Process Record and Replay, Prev: Stopping, Up: Top 4682 4683 6 Running programs backward 4684 *************************** 4685 4686 When you are debugging a program, it is not unusual to realize that you 4687 have gone too far, and some event of interest has already happened. If 4688 the target environment supports it, GDB can allow you to "rewind" the 4689 program by running it backward. 4690 4691 A target environment that supports reverse execution should be able 4692 to "undo" the changes in machine state that have taken place as the 4693 program was executing normally. Variables, registers etc. should 4694 revert to their previous values. Obviously this requires a great deal 4695 of sophistication on the part of the target environment; not all target 4696 environments can support reverse execution. 4697 4698 When a program is executed in reverse, the instructions that have 4699 most recently been executed are "un-executed", in reverse order. The 4700 program counter runs backward, following the previous thread of 4701 execution in reverse. As each instruction is "un-executed", the values 4702 of memory and/or registers that were changed by that instruction are 4703 reverted to their previous states. After executing a piece of source 4704 code in reverse, all side effects of that code should be "undone", and 4705 all variables should be returned to their prior values(1). 4706 4707 If you are debugging in a target environment that supports reverse 4708 execution, GDB provides the following commands. 4709 4710 `reverse-continue [IGNORE-COUNT]' 4711 `rc [IGNORE-COUNT]' 4712 Beginning at the point where your program last stopped, start 4713 executing in reverse. Reverse execution will stop for breakpoints 4714 and synchronous exceptions (signals), just like normal execution. 4715 Behavior of asynchronous signals depends on the target environment. 4716 4717 `reverse-step [COUNT]' 4718 Run the program backward until control reaches the start of a 4719 different source line; then stop it, and return control to GDB. 4720 4721 Like the `step' command, `reverse-step' will only stop at the 4722 beginning of a source line. It "un-executes" the previously 4723 executed source line. If the previous source line included calls 4724 to debuggable functions, `reverse-step' will step (backward) into 4725 the called function, stopping at the beginning of the _last_ 4726 statement in the called function (typically a return statement). 4727 4728 Also, as with the `step' command, if non-debuggable functions are 4729 called, `reverse-step' will run thru them backward without 4730 stopping. 4731 4732 `reverse-stepi [COUNT]' 4733 Reverse-execute one machine instruction. Note that the instruction 4734 to be reverse-executed is _not_ the one pointed to by the program 4735 counter, but the instruction executed prior to that one. For 4736 instance, if the last instruction was a jump, `reverse-stepi' will 4737 take you back from the destination of the jump to the jump 4738 instruction itself. 4739 4740 `reverse-next [COUNT]' 4741 Run backward to the beginning of the previous line executed in the 4742 current (innermost) stack frame. If the line contains function 4743 calls, they will be "un-executed" without stopping. Starting from 4744 the first line of a function, `reverse-next' will take you back to 4745 the caller of that function, _before_ the function was called, 4746 just as the normal `next' command would take you from the last 4747 line of a function back to its return to its caller (2). 4748 4749 `reverse-nexti [COUNT]' 4750 Like `nexti', `reverse-nexti' executes a single instruction in 4751 reverse, except that called functions are "un-executed" atomically. 4752 That is, if the previously executed instruction was a return from 4753 another function, `reverse-nexti' will continue to execute in 4754 reverse until the call to that function (from the current stack 4755 frame) is reached. 4756 4757 `reverse-finish' 4758 Just as the `finish' command takes you to the point where the 4759 current function returns, `reverse-finish' takes you to the point 4760 where it was called. Instead of ending up at the end of the 4761 current function invocation, you end up at the beginning. 4762 4763 `set exec-direction' 4764 Set the direction of target execution. 4765 4766 `set exec-direction reverse' 4767 GDB will perform all execution commands in reverse, until the 4768 exec-direction mode is changed to "forward". Affected commands 4769 include `step, stepi, next, nexti, continue, and finish'. The 4770 `return' command cannot be used in reverse mode. 4771 4772 `set exec-direction forward' 4773 GDB will perform all execution commands in the normal fashion. 4774 This is the default. 4775 4776 ---------- Footnotes ---------- 4777 4778 (1) Note that some side effects are easier to undo than others. For 4779 instance, memory and registers are relatively easy, but device I/O is 4780 hard. Some targets may be able undo things like device I/O, and some 4781 may not. 4782 4783 The contract between GDB and the reverse executing target requires 4784 only that the target do something reasonable when GDB tells it to 4785 execute backwards, and then report the results back to GDB. Whatever 4786 the target reports back to GDB, GDB will report back to the user. GDB 4787 assumes that the memory and registers that the target reports are in a 4788 consistant state, but GDB accepts whatever it is given. 4789 4790 (2) Unless the code is too heavily optimized. 4791 4792 4793 File: gdb.info, Node: Process Record and Replay, Next: Stack, Prev: Reverse Execution, Up: Top 4794 4795 7 Recording Inferior's Execution and Replaying It 4796 ************************************************* 4797 4798 On some platforms, GDB provides a special "process record and replay" 4799 target that can record a log of the process execution, and replay it 4800 later with both forward and reverse execution commands. 4801 4802 When this target is in use, if the execution log includes the record 4803 for the next instruction, GDB will debug in "replay mode". In the 4804 replay mode, the inferior does not really execute code instructions. 4805 Instead, all the events that normally happen during code execution are 4806 taken from the execution log. While code is not really executed in 4807 replay mode, the values of registers (including the program counter 4808 register) and the memory of the inferior are still changed as they 4809 normally would. Their contents are taken from the execution log. 4810 4811 If the record for the next instruction is not in the execution log, 4812 GDB will debug in "record mode". In this mode, the inferior executes 4813 normally, and GDB records the execution log for future replay. 4814 4815 The process record and replay target supports reverse execution 4816 (*note Reverse Execution::), even if the platform on which the inferior 4817 runs does not. However, the reverse execution is limited in this case 4818 by the range of the instructions recorded in the execution log. In 4819 other words, reverse execution on platforms that don't support it 4820 directly can only be done in the replay mode. 4821 4822 When debugging in the reverse direction, GDB will work in replay 4823 mode as long as the execution log includes the record for the previous 4824 instruction; otherwise, it will work in record mode, if the platform 4825 supports reverse execution, or stop if not. 4826 4827 For architecture environments that support process record and replay, 4828 GDB provides the following commands: 4829 4830 `target record' 4831 This command starts the process record and replay target. The 4832 process record and replay target can only debug a process that is 4833 already running. Therefore, you need first to start the process 4834 with the `run' or `start' commands, and then start the recording 4835 with the `target record' command. 4836 4837 Both `record' and `rec' are aliases of `target record'. 4838 4839 Displaced stepping (*note displaced stepping: Maintenance 4840 Commands.) will be automatically disabled when process record and 4841 replay target is started. That's because the process record and 4842 replay target doesn't support displaced stepping. 4843 4844 If the inferior is in the non-stop mode (*note Non-Stop Mode::) or 4845 in the asynchronous execution mode (*note Background Execution::), 4846 the process record and replay target cannot be started because it 4847 doesn't support these two modes. 4848 4849 `record stop' 4850 Stop the process record and replay target. When process record and 4851 replay target stops, the entire execution log will be deleted and 4852 the inferior will either be terminated, or will remain in its 4853 final state. 4854 4855 When you stop the process record and replay target in record mode 4856 (at the end of the execution log), the inferior will be stopped at 4857 the next instruction that would have been recorded. In other 4858 words, if you record for a while and then stop recording, the 4859 inferior process will be left in the same state as if the 4860 recording never happened. 4861 4862 On the other hand, if the process record and replay target is 4863 stopped while in replay mode (that is, not at the end of the 4864 execution log, but at some earlier point), the inferior process 4865 will become "live" at that earlier state, and it will then be 4866 possible to continue the usual "live" debugging of the process 4867 from that state. 4868 4869 When the inferior process exits, or GDB detaches from it, process 4870 record and replay target will automatically stop itself. 4871 4872 `record save FILENAME' 4873 Save the execution log to a file `FILENAME'. Default filename is 4874 `gdb_record.PROCESS_ID', where PROCESS_ID is the process ID of the 4875 inferior. 4876 4877 `record restore FILENAME' 4878 Restore the execution log from a file `FILENAME'. File must have 4879 been created with `record save'. 4880 4881 `set record insn-number-max LIMIT' 4882 Set the limit of instructions to be recorded. Default value is 4883 200000. 4884 4885 If LIMIT is a positive number, then GDB will start deleting 4886 instructions from the log once the number of the record 4887 instructions becomes greater than LIMIT. For every new recorded 4888 instruction, GDB will delete the earliest recorded instruction to 4889 keep the number of recorded instructions at the limit. (Since 4890 deleting recorded instructions loses information, GDB lets you 4891 control what happens when the limit is reached, by means of the 4892 `stop-at-limit' option, described below.) 4893 4894 If LIMIT is zero, GDB will never delete recorded instructions from 4895 the execution log. The number of recorded instructions is 4896 unlimited in this case. 4897 4898 `show record insn-number-max' 4899 Show the limit of instructions to be recorded. 4900 4901 `set record stop-at-limit' 4902 Control the behavior when the number of recorded instructions 4903 reaches the limit. If ON (the default), GDB will stop when the 4904 limit is reached for the first time and ask you whether you want 4905 to stop the inferior or continue running it and recording the 4906 execution log. If you decide to continue recording, each new 4907 recorded instruction will cause the oldest one to be deleted. 4908 4909 If this option is OFF, GDB will automatically delete the oldest 4910 record to make room for each new one, without asking. 4911 4912 `show record stop-at-limit' 4913 Show the current setting of `stop-at-limit'. 4914 4915 `set record memory-query' 4916 Control the behavior when GDB is unable to record memory changes 4917 caused by an instruction. If ON, GDB will query whether to stop 4918 the inferior in that case. 4919 4920 If this option is OFF (the default), GDB will automatically ignore 4921 the effect of such instructions on memory. Later, when GDB 4922 replays this execution log, it will mark the log of this 4923 instruction as not accessible, and it will not affect the replay 4924 results. 4925 4926 `show record memory-query' 4927 Show the current setting of `memory-query'. 4928 4929 `info record' 4930 Show various statistics about the state of process record and its 4931 in-memory execution log buffer, including: 4932 4933 * Whether in record mode or replay mode. 4934 4935 * Lowest recorded instruction number (counting from when the 4936 current execution log started recording instructions). 4937 4938 * Highest recorded instruction number. 4939 4940 * Current instruction about to be replayed (if in replay mode). 4941 4942 * Number of instructions contained in the execution log. 4943 4944 * Maximum number of instructions that may be contained in the 4945 execution log. 4946 4947 `record delete' 4948 When record target runs in replay mode ("in the past"), delete the 4949 subsequent execution log and begin to record a new execution log 4950 starting from the current address. This means you will abandon 4951 the previously recorded "future" and begin recording a new 4952 "future". 4953 4954 4955 File: gdb.info, Node: Stack, Next: Source, Prev: Process Record and Replay, Up: Top 4956 4957 8 Examining the Stack 4958 ********************* 4959 4960 When your program has stopped, the first thing you need to know is 4961 where it stopped and how it got there. 4962 4963 Each time your program performs a function call, information about 4964 the call is generated. That information includes the location of the 4965 call in your program, the arguments of the call, and the local 4966 variables of the function being called. The information is saved in a 4967 block of data called a "stack frame". The stack frames are allocated 4968 in a region of memory called the "call stack". 4969 4970 When your program stops, the GDB commands for examining the stack 4971 allow you to see all of this information. 4972 4973 One of the stack frames is "selected" by GDB and many GDB commands 4974 refer implicitly to the selected frame. In particular, whenever you 4975 ask GDB for the value of a variable in your program, the value is found 4976 in the selected frame. There are special GDB commands to select 4977 whichever frame you are interested in. *Note Selecting a Frame: 4978 Selection. 4979 4980 When your program stops, GDB automatically selects the currently 4981 executing frame and describes it briefly, similar to the `frame' 4982 command (*note Information about a Frame: Frame Info.). 4983 4984 * Menu: 4985 4986 * Frames:: Stack frames 4987 * Backtrace:: Backtraces 4988 * Selection:: Selecting a frame 4989 * Frame Info:: Information on a frame 4990 4991 4992 File: gdb.info, Node: Frames, Next: Backtrace, Up: Stack 4993 4994 8.1 Stack Frames 4995 ================ 4996 4997 The call stack is divided up into contiguous pieces called "stack 4998 frames", or "frames" for short; each frame is the data associated with 4999 one call to one function. The frame contains the arguments given to 5000 the function, the function's local variables, and the address at which 5001 the function is executing. 5002 5003 When your program is started, the stack has only one frame, that of 5004 the function `main'. This is called the "initial" frame or the 5005 "outermost" frame. Each time a function is called, a new frame is 5006 made. Each time a function returns, the frame for that function 5007 invocation is eliminated. If a function is recursive, there can be 5008 many frames for the same function. The frame for the function in which 5009 execution is actually occurring is called the "innermost" frame. This 5010 is the most recently created of all the stack frames that still exist. 5011 5012 Inside your program, stack frames are identified by their addresses. 5013 A stack frame consists of many bytes, each of which has its own 5014 address; each kind of computer has a convention for choosing one byte 5015 whose address serves as the address of the frame. Usually this address 5016 is kept in a register called the "frame pointer register" (*note $fp: 5017 Registers.) while execution is going on in that frame. 5018 5019 GDB assigns numbers to all existing stack frames, starting with zero 5020 for the innermost frame, one for the frame that called it, and so on 5021 upward. These numbers do not really exist in your program; they are 5022 assigned by GDB to give you a way of designating stack frames in GDB 5023 commands. 5024 5025 Some compilers provide a way to compile functions so that they 5026 operate without stack frames. (For example, the GCC option 5027 `-fomit-frame-pointer' 5028 generates functions without a frame.) This is occasionally done 5029 with heavily used library functions to save the frame setup time. GDB 5030 has limited facilities for dealing with these function invocations. If 5031 the innermost function invocation has no stack frame, GDB nevertheless 5032 regards it as though it had a separate frame, which is numbered zero as 5033 usual, allowing correct tracing of the function call chain. However, 5034 GDB has no provision for frameless functions elsewhere in the stack. 5035 5036 `frame ARGS' 5037 The `frame' command allows you to move from one stack frame to 5038 another, and to print the stack frame you select. ARGS may be 5039 either the address of the frame or the stack frame number. 5040 Without an argument, `frame' prints the current stack frame. 5041 5042 `select-frame' 5043 The `select-frame' command allows you to move from one stack frame 5044 to another without printing the frame. This is the silent version 5045 of `frame'. 5046 5047 5048 File: gdb.info, Node: Backtrace, Next: Selection, Prev: Frames, Up: Stack 5049 5050 8.2 Backtraces 5051 ============== 5052 5053 A backtrace is a summary of how your program got where it is. It shows 5054 one line per frame, for many frames, starting with the currently 5055 executing frame (frame zero), followed by its caller (frame one), and 5056 on up the stack. 5057 5058 `backtrace' 5059 `bt' 5060 Print a backtrace of the entire stack: one line per frame for all 5061 frames in the stack. 5062 5063 You can stop the backtrace at any time by typing the system 5064 interrupt character, normally `Ctrl-c'. 5065 5066 `backtrace N' 5067 `bt N' 5068 Similar, but print only the innermost N frames. 5069 5070 `backtrace -N' 5071 `bt -N' 5072 Similar, but print only the outermost N frames. 5073 5074 `backtrace full' 5075 `bt full' 5076 `bt full N' 5077 `bt full -N' 5078 Print the values of the local variables also. N specifies the 5079 number of frames to print, as described above. 5080 5081 The names `where' and `info stack' (abbreviated `info s') are 5082 additional aliases for `backtrace'. 5083 5084 In a multi-threaded program, GDB by default shows the backtrace only 5085 for the current thread. To display the backtrace for several or all of 5086 the threads, use the command `thread apply' (*note thread apply: 5087 Threads.). For example, if you type `thread apply all backtrace', GDB 5088 will display the backtrace for all the threads; this is handy when you 5089 debug a core dump of a multi-threaded program. 5090 5091 Each line in the backtrace shows the frame number and the function 5092 name. The program counter value is also shown--unless you use `set 5093 print address off'. The backtrace also shows the source file name and 5094 line number, as well as the arguments to the function. The program 5095 counter value is omitted if it is at the beginning of the code for that 5096 line number. 5097 5098 Here is an example of a backtrace. It was made with the command `bt 5099 3', so it shows the innermost three frames. 5100 5101 #0 m4_traceon (obs=0x24eb0, argc=1, argv=0x2b8c8) 5102 at builtin.c:993 5103 #1 0x6e38 in expand_macro (sym=0x2b600, data=...) at macro.c:242 5104 #2 0x6840 in expand_token (obs=0x0, t=177664, td=0xf7fffb08) 5105 at macro.c:71 5106 (More stack frames follow...) 5107 5108 The display for frame zero does not begin with a program counter value, 5109 indicating that your program has stopped at the beginning of the code 5110 for line `993' of `builtin.c'. 5111 5112 The value of parameter `data' in frame 1 has been replaced by `...'. 5113 By default, GDB prints the value of a parameter only if it is a scalar 5114 (integer, pointer, enumeration, etc). See command `set print 5115 frame-arguments' in *note Print Settings:: for more details on how to 5116 configure the way function parameter values are printed. 5117 5118 If your program was compiled with optimizations, some compilers will 5119 optimize away arguments passed to functions if those arguments are 5120 never used after the call. Such optimizations generate code that 5121 passes arguments through registers, but doesn't store those arguments 5122 in the stack frame. GDB has no way of displaying such arguments in 5123 stack frames other than the innermost one. Here's what such a 5124 backtrace might look like: 5125 5126 #0 m4_traceon (obs=0x24eb0, argc=1, argv=0x2b8c8) 5127 at builtin.c:993 5128 #1 0x6e38 in expand_macro (sym=<optimized out>) at macro.c:242 5129 #2 0x6840 in expand_token (obs=0x0, t=<optimized out>, td=0xf7fffb08) 5130 at macro.c:71 5131 (More stack frames follow...) 5132 5133 The values of arguments that were not saved in their stack frames are 5134 shown as `<optimized out>'. 5135 5136 If you need to display the values of such optimized-out arguments, 5137 either deduce that from other variables whose values depend on the one 5138 you are interested in, or recompile without optimizations. 5139 5140 Most programs have a standard user entry point--a place where system 5141 libraries and startup code transition into user code. For C this is 5142 `main'(1). When GDB finds the entry function in a backtrace it will 5143 terminate the backtrace, to avoid tracing into highly system-specific 5144 (and generally uninteresting) code. 5145 5146 If you need to examine the startup code, or limit the number of 5147 levels in a backtrace, you can change this behavior: 5148 5149 `set backtrace past-main' 5150 `set backtrace past-main on' 5151 Backtraces will continue past the user entry point. 5152 5153 `set backtrace past-main off' 5154 Backtraces will stop when they encounter the user entry point. 5155 This is the default. 5156 5157 `show backtrace past-main' 5158 Display the current user entry point backtrace policy. 5159 5160 `set backtrace past-entry' 5161 `set backtrace past-entry on' 5162 Backtraces will continue past the internal entry point of an 5163 application. This entry point is encoded by the linker when the 5164 application is built, and is likely before the user entry point 5165 `main' (or equivalent) is called. 5166 5167 `set backtrace past-entry off' 5168 Backtraces will stop when they encounter the internal entry point 5169 of an application. This is the default. 5170 5171 `show backtrace past-entry' 5172 Display the current internal entry point backtrace policy. 5173 5174 `set backtrace limit N' 5175 `set backtrace limit 0' 5176 Limit the backtrace to N levels. A value of zero means unlimited. 5177 5178 `show backtrace limit' 5179 Display the current limit on backtrace levels. 5180 5181 ---------- Footnotes ---------- 5182 5183 (1) Note that embedded programs (the so-called "free-standing" 5184 environment) are not required to have a `main' function as the entry 5185 point. They could even have multiple entry points. 5186 5187 5188 File: gdb.info, Node: Selection, Next: Frame Info, Prev: Backtrace, Up: Stack 5189 5190 8.3 Selecting a Frame 5191 ===================== 5192 5193 Most commands for examining the stack and other data in your program 5194 work on whichever stack frame is selected at the moment. Here are the 5195 commands for selecting a stack frame; all of them finish by printing a 5196 brief description of the stack frame just selected. 5197 5198 `frame N' 5199 `f N' 5200 Select frame number N. Recall that frame zero is the innermost 5201 (currently executing) frame, frame one is the frame that called the 5202 innermost one, and so on. The highest-numbered frame is the one 5203 for `main'. 5204 5205 `frame ADDR' 5206 `f ADDR' 5207 Select the frame at address ADDR. This is useful mainly if the 5208 chaining of stack frames has been damaged by a bug, making it 5209 impossible for GDB to assign numbers properly to all frames. In 5210 addition, this can be useful when your program has multiple stacks 5211 and switches between them. 5212 5213 On the SPARC architecture, `frame' needs two addresses to select 5214 an arbitrary frame: a frame pointer and a stack pointer. 5215 5216 On the MIPS and Alpha architecture, it needs two addresses: a stack 5217 pointer and a program counter. 5218 5219 On the 29k architecture, it needs three addresses: a register stack 5220 pointer, a program counter, and a memory stack pointer. 5221 5222 `up N' 5223 Move N frames up the stack. For positive numbers N, this advances 5224 toward the outermost frame, to higher frame numbers, to frames 5225 that have existed longer. N defaults to one. 5226 5227 `down N' 5228 Move N frames down the stack. For positive numbers N, this 5229 advances toward the innermost frame, to lower frame numbers, to 5230 frames that were created more recently. N defaults to one. You 5231 may abbreviate `down' as `do'. 5232 5233 All of these commands end by printing two lines of output describing 5234 the frame. The first line shows the frame number, the function name, 5235 the arguments, and the source file and line number of execution in that 5236 frame. The second line shows the text of that source line. 5237 5238 For example: 5239 5240 (gdb) up 5241 #1 0x22f0 in main (argc=1, argv=0xf7fffbf4, env=0xf7fffbfc) 5242 at env.c:10 5243 10 read_input_file (argv[i]); 5244 5245 After such a printout, the `list' command with no arguments prints 5246 ten lines centered on the point of execution in the frame. You can 5247 also edit the program at the point of execution with your favorite 5248 editing program by typing `edit'. *Note Printing Source Lines: List, 5249 for details. 5250 5251 `up-silently N' 5252 `down-silently N' 5253 These two commands are variants of `up' and `down', respectively; 5254 they differ in that they do their work silently, without causing 5255 display of the new frame. They are intended primarily for use in 5256 GDB command scripts, where the output might be unnecessary and 5257 distracting. 5258 5259 5260 File: gdb.info, Node: Frame Info, Prev: Selection, Up: Stack 5261 5262 8.4 Information About a Frame 5263 ============================= 5264 5265 There are several other commands to print information about the selected 5266 stack frame. 5267 5268 `frame' 5269 `f' 5270 When used without any argument, this command does not change which 5271 frame is selected, but prints a brief description of the currently 5272 selected stack frame. It can be abbreviated `f'. With an 5273 argument, this command is used to select a stack frame. *Note 5274 Selecting a Frame: Selection. 5275 5276 `info frame' 5277 `info f' 5278 This command prints a verbose description of the selected stack 5279 frame, including: 5280 5281 * the address of the frame 5282 5283 * the address of the next frame down (called by this frame) 5284 5285 * the address of the next frame up (caller of this frame) 5286 5287 * the language in which the source code corresponding to this 5288 frame is written 5289 5290 * the address of the frame's arguments 5291 5292 * the address of the frame's local variables 5293 5294 * the program counter saved in it (the address of execution in 5295 the caller frame) 5296 5297 * which registers were saved in the frame 5298 5299 The verbose description is useful when something has gone wrong 5300 that has made the stack format fail to fit the usual conventions. 5301 5302 `info frame ADDR' 5303 `info f ADDR' 5304 Print a verbose description of the frame at address ADDR, without 5305 selecting that frame. The selected frame remains unchanged by this 5306 command. This requires the same kind of address (more than one 5307 for some architectures) that you specify in the `frame' command. 5308 *Note Selecting a Frame: Selection. 5309 5310 `info args' 5311 Print the arguments of the selected frame, each on a separate line. 5312 5313 `info locals' 5314 Print the local variables of the selected frame, each on a separate 5315 line. These are all variables (declared either static or 5316 automatic) accessible at the point of execution of the selected 5317 frame. 5318 5319 `info catch' 5320 Print a list of all the exception handlers that are active in the 5321 current stack frame at the current point of execution. To see 5322 other exception handlers, visit the associated frame (using the 5323 `up', `down', or `frame' commands); then type `info catch'. *Note 5324 Setting Catchpoints: Set Catchpoints. 5325 5326 5327 5328 File: gdb.info, Node: Source, Next: Data, Prev: Stack, Up: Top 5329 5330 9 Examining Source Files 5331 ************************ 5332 5333 GDB can print parts of your program's source, since the debugging 5334 information recorded in the program tells GDB what source files were 5335 used to build it. When your program stops, GDB spontaneously prints 5336 the line where it stopped. Likewise, when you select a stack frame 5337 (*note Selecting a Frame: Selection.), GDB prints the line where 5338 execution in that frame has stopped. You can print other portions of 5339 source files by explicit command. 5340 5341 If you use GDB through its GNU Emacs interface, you may prefer to 5342 use Emacs facilities to view source; see *note Using GDB under GNU 5343 Emacs: Emacs. 5344 5345 * Menu: 5346 5347 * List:: Printing source lines 5348 * Specify Location:: How to specify code locations 5349 * Edit:: Editing source files 5350 * Search:: Searching source files 5351 * Source Path:: Specifying source directories 5352 * Machine Code:: Source and machine code 5353 5354 5355 File: gdb.info, Node: List, Next: Specify Location, Up: Source 5356 5357 9.1 Printing Source Lines 5358 ========================= 5359 5360 To print lines from a source file, use the `list' command (abbreviated 5361 `l'). By default, ten lines are printed. There are several ways to 5362 specify what part of the file you want to print; see *note Specify 5363 Location::, for the full list. 5364 5365 Here are the forms of the `list' command most commonly used: 5366 5367 `list LINENUM' 5368 Print lines centered around line number LINENUM in the current 5369 source file. 5370 5371 `list FUNCTION' 5372 Print lines centered around the beginning of function FUNCTION. 5373 5374 `list' 5375 Print more lines. If the last lines printed were printed with a 5376 `list' command, this prints lines following the last lines 5377 printed; however, if the last line printed was a solitary line 5378 printed as part of displaying a stack frame (*note Examining the 5379 Stack: Stack.), this prints lines centered around that line. 5380 5381 `list -' 5382 Print lines just before the lines last printed. 5383 5384 By default, GDB prints ten source lines with any of these forms of 5385 the `list' command. You can change this using `set listsize': 5386 5387 `set listsize COUNT' 5388 Make the `list' command display COUNT source lines (unless the 5389 `list' argument explicitly specifies some other number). 5390 5391 `show listsize' 5392 Display the number of lines that `list' prints. 5393 5394 Repeating a `list' command with <RET> discards the argument, so it 5395 is equivalent to typing just `list'. This is more useful than listing 5396 the same lines again. An exception is made for an argument of `-'; 5397 that argument is preserved in repetition so that each repetition moves 5398 up in the source file. 5399 5400 In general, the `list' command expects you to supply zero, one or two 5401 "linespecs". Linespecs specify source lines; there are several ways of 5402 writing them (*note Specify Location::), but the effect is always to 5403 specify some source line. 5404 5405 Here is a complete description of the possible arguments for `list': 5406 5407 `list LINESPEC' 5408 Print lines centered around the line specified by LINESPEC. 5409 5410 `list FIRST,LAST' 5411 Print lines from FIRST to LAST. Both arguments are linespecs. 5412 When a `list' command has two linespecs, and the source file of 5413 the second linespec is omitted, this refers to the same source 5414 file as the first linespec. 5415 5416 `list ,LAST' 5417 Print lines ending with LAST. 5418 5419 `list FIRST,' 5420 Print lines starting with FIRST. 5421 5422 `list +' 5423 Print lines just after the lines last printed. 5424 5425 `list -' 5426 Print lines just before the lines last printed. 5427 5428 `list' 5429 As described in the preceding table. 5430 5431 5432 File: gdb.info, Node: Specify Location, Next: Edit, Prev: List, Up: Source 5433 5434 9.2 Specifying a Location 5435 ========================= 5436 5437 Several GDB commands accept arguments that specify a location of your 5438 program's code. Since GDB is a source-level debugger, a location 5439 usually specifies some line in the source code; for that reason, 5440 locations are also known as "linespecs". 5441 5442 Here are all the different ways of specifying a code location that 5443 GDB understands: 5444 5445 `LINENUM' 5446 Specifies the line number LINENUM of the current source file. 5447 5448 `-OFFSET' 5449 `+OFFSET' 5450 Specifies the line OFFSET lines before or after the "current 5451 line". For the `list' command, the current line is the last one 5452 printed; for the breakpoint commands, this is the line at which 5453 execution stopped in the currently selected "stack frame" (*note 5454 Frames: Frames, for a description of stack frames.) When used as 5455 the second of the two linespecs in a `list' command, this 5456 specifies the line OFFSET lines up or down from the first linespec. 5457 5458 `FILENAME:LINENUM' 5459 Specifies the line LINENUM in the source file FILENAME. 5460 5461 `FUNCTION' 5462 Specifies the line that begins the body of the function FUNCTION. 5463 For example, in C, this is the line with the open brace. 5464 5465 `FUNCTION:LABEL' 5466 Specifies the line where LABEL appears in FUNCTION. 5467 5468 `FILENAME:FUNCTION' 5469 Specifies the line that begins the body of the function FUNCTION 5470 in the file FILENAME. You only need the file name with a function 5471 name to avoid ambiguity when there are identically named functions 5472 in different source files. 5473 5474 `LABEL' 5475 Specifies the line at which the label named LABEL appears. GDB 5476 searches for the label in the function corresponding to the 5477 currently selected stack frame. If there is no current selected 5478 stack frame (for instance, if the inferior is not running), then 5479 GDB will not search for a label. 5480 5481 `*ADDRESS' 5482 Specifies the program address ADDRESS. For line-oriented 5483 commands, such as `list' and `edit', this specifies a source line 5484 that contains ADDRESS. For `break' and other breakpoint oriented 5485 commands, this can be used to set breakpoints in parts of your 5486 program which do not have debugging information or source files. 5487 5488 Here ADDRESS may be any expression valid in the current working 5489 language (*note working language: Languages.) that specifies a code 5490 address. In addition, as a convenience, GDB extends the semantics 5491 of expressions used in locations to cover the situations that 5492 frequently happen during debugging. Here are the various forms of 5493 ADDRESS: 5494 5495 `EXPRESSION' 5496 Any expression valid in the current working language. 5497 5498 `FUNCADDR' 5499 An address of a function or procedure derived from its name. 5500 In C, C++, Java, Objective-C, Fortran, minimal, and assembly, 5501 this is simply the function's name FUNCTION (and actually a 5502 special case of a valid expression). In Pascal and Modula-2, 5503 this is `&FUNCTION'. In Ada, this is `FUNCTION'Address' 5504 (although the Pascal form also works). 5505 5506 This form specifies the address of the function's first 5507 instruction, before the stack frame and arguments have been 5508 set up. 5509 5510 `'FILENAME'::FUNCADDR' 5511 Like FUNCADDR above, but also specifies the name of the source 5512 file explicitly. This is useful if the name of the function 5513 does not specify the function unambiguously, e.g., if there 5514 are several functions with identical names in different 5515 source files. 5516 5517 5518 5519 File: gdb.info, Node: Edit, Next: Search, Prev: Specify Location, Up: Source 5520 5521 9.3 Editing Source Files 5522 ======================== 5523 5524 To edit the lines in a source file, use the `edit' command. The 5525 editing program of your choice is invoked with the current line set to 5526 the active line in the program. Alternatively, there are several ways 5527 to specify what part of the file you want to print if you want to see 5528 other parts of the program: 5529 5530 `edit LOCATION' 5531 Edit the source file specified by `location'. Editing starts at 5532 that LOCATION, e.g., at the specified source line of the specified 5533 file. *Note Specify Location::, for all the possible forms of the 5534 LOCATION argument; here are the forms of the `edit' command most 5535 commonly used: 5536 5537 `edit NUMBER' 5538 Edit the current source file with NUMBER as the active line 5539 number. 5540 5541 `edit FUNCTION' 5542 Edit the file containing FUNCTION at the beginning of its 5543 definition. 5544 5545 5546 9.3.1 Choosing your Editor 5547 -------------------------- 5548 5549 You can customize GDB to use any editor you want (1). By default, it 5550 is `/bin/ex', but you can change this by setting the environment 5551 variable `EDITOR' before using GDB. For example, to configure GDB to 5552 use the `vi' editor, you could use these commands with the `sh' shell: 5553 EDITOR=/usr/bin/vi 5554 export EDITOR 5555 gdb ... 5556 or in the `csh' shell, 5557 setenv EDITOR /usr/bin/vi 5558 gdb ... 5559 5560 ---------- Footnotes ---------- 5561 5562 (1) The only restriction is that your editor (say `ex'), recognizes 5563 the following command-line syntax: 5564 ex +NUMBER file 5565 The optional numeric value +NUMBER specifies the number of the line 5566 in the file where to start editing. 5567 5568 5569 File: gdb.info, Node: Search, Next: Source Path, Prev: Edit, Up: Source 5570 5571 9.4 Searching Source Files 5572 ========================== 5573 5574 There are two commands for searching through the current source file 5575 for a regular expression. 5576 5577 `forward-search REGEXP' 5578 `search REGEXP' 5579 The command `forward-search REGEXP' checks each line, starting 5580 with the one following the last line listed, for a match for 5581 REGEXP. It lists the line that is found. You can use the synonym 5582 `search REGEXP' or abbreviate the command name as `fo'. 5583 5584 `reverse-search REGEXP' 5585 The command `reverse-search REGEXP' checks each line, starting 5586 with the one before the last line listed and going backward, for a 5587 match for REGEXP. It lists the line that is found. You can 5588 abbreviate this command as `rev'. 5589 5590 5591 File: gdb.info, Node: Source Path, Next: Machine Code, Prev: Search, Up: Source 5592 5593 9.5 Specifying Source Directories 5594 ================================= 5595 5596 Executable programs sometimes do not record the directories of the 5597 source files from which they were compiled, just the names. Even when 5598 they do, the directories could be moved between the compilation and 5599 your debugging session. GDB has a list of directories to search for 5600 source files; this is called the "source path". Each time GDB wants a 5601 source file, it tries all the directories in the list, in the order 5602 they are present in the list, until it finds a file with the desired 5603 name. 5604 5605 For example, suppose an executable references the file 5606 `/usr/src/foo-1.0/lib/foo.c', and our source path is `/mnt/cross'. The 5607 file is first looked up literally; if this fails, 5608 `/mnt/cross/usr/src/foo-1.0/lib/foo.c' is tried; if this fails, 5609 `/mnt/cross/foo.c' is opened; if this fails, an error message is 5610 printed. GDB does not look up the parts of the source file name, such 5611 as `/mnt/cross/src/foo-1.0/lib/foo.c'. Likewise, the subdirectories of 5612 the source path are not searched: if the source path is `/mnt/cross', 5613 and the binary refers to `foo.c', GDB would not find it under 5614 `/mnt/cross/usr/src/foo-1.0/lib'. 5615 5616 Plain file names, relative file names with leading directories, file 5617 names containing dots, etc. are all treated as described above; for 5618 instance, if the source path is `/mnt/cross', and the source file is 5619 recorded as `../lib/foo.c', GDB would first try `../lib/foo.c', then 5620 `/mnt/cross/../lib/foo.c', and after that--`/mnt/cross/foo.c'. 5621 5622 Note that the executable search path is _not_ used to locate the 5623 source files. 5624 5625 Whenever you reset or rearrange the source path, GDB clears out any 5626 information it has cached about where source files are found and where 5627 each line is in the file. 5628 5629 When you start GDB, its source path includes only `cdir' and `cwd', 5630 in that order. To add other directories, use the `directory' command. 5631 5632 The search path is used to find both program source files and GDB 5633 script files (read using the `-command' option and `source' command). 5634 5635 In addition to the source path, GDB provides a set of commands that 5636 manage a list of source path substitution rules. A "substitution rule" 5637 specifies how to rewrite source directories stored in the program's 5638 debug information in case the sources were moved to a different 5639 directory between compilation and debugging. A rule is made of two 5640 strings, the first specifying what needs to be rewritten in the path, 5641 and the second specifying how it should be rewritten. In *note set 5642 substitute-path::, we name these two parts FROM and TO respectively. 5643 GDB does a simple string replacement of FROM with TO at the start of 5644 the directory part of the source file name, and uses that result 5645 instead of the original file name to look up the sources. 5646 5647 Using the previous example, suppose the `foo-1.0' tree has been 5648 moved from `/usr/src' to `/mnt/cross', then you can tell GDB to replace 5649 `/usr/src' in all source path names with `/mnt/cross'. The first 5650 lookup will then be `/mnt/cross/foo-1.0/lib/foo.c' in place of the 5651 original location of `/usr/src/foo-1.0/lib/foo.c'. To define a source 5652 path substitution rule, use the `set substitute-path' command (*note 5653 set substitute-path::). 5654 5655 To avoid unexpected substitution results, a rule is applied only if 5656 the FROM part of the directory name ends at a directory separator. For 5657 instance, a rule substituting `/usr/source' into `/mnt/cross' will be 5658 applied to `/usr/source/foo-1.0' but not to `/usr/sourceware/foo-2.0'. 5659 And because the substitution is applied only at the beginning of the 5660 directory name, this rule will not be applied to 5661 `/root/usr/source/baz.c' either. 5662 5663 In many cases, you can achieve the same result using the `directory' 5664 command. However, `set substitute-path' can be more efficient in the 5665 case where the sources are organized in a complex tree with multiple 5666 subdirectories. With the `directory' command, you need to add each 5667 subdirectory of your project. If you moved the entire tree while 5668 preserving its internal organization, then `set substitute-path' allows 5669 you to direct the debugger to all the sources with one single command. 5670 5671 `set substitute-path' is also more than just a shortcut command. 5672 The source path is only used if the file at the original location no 5673 longer exists. On the other hand, `set substitute-path' modifies the 5674 debugger behavior to look at the rewritten location instead. So, if 5675 for any reason a source file that is not relevant to your executable is 5676 located at the original location, a substitution rule is the only 5677 method available to point GDB at the new location. 5678 5679 You can configure a default source path substitution rule by 5680 configuring GDB with the `--with-relocated-sources=DIR' option. The DIR 5681 should be the name of a directory under GDB's configured prefix (set 5682 with `--prefix' or `--exec-prefix'), and directory names in debug 5683 information under DIR will be adjusted automatically if the installed 5684 GDB is moved to a new location. This is useful if GDB, libraries or 5685 executables with debug information and corresponding source code are 5686 being moved together. 5687 5688 `directory DIRNAME ...' 5689 5690 `dir DIRNAME ...' 5691 Add directory DIRNAME to the front of the source path. Several 5692 directory names may be given to this command, separated by `:' 5693 (`;' on MS-DOS and MS-Windows, where `:' usually appears as part 5694 of absolute file names) or whitespace. You may specify a 5695 directory that is already in the source path; this moves it 5696 forward, so GDB searches it sooner. 5697 5698 You can use the string `$cdir' to refer to the compilation 5699 directory (if one is recorded), and `$cwd' to refer to the current 5700 working directory. `$cwd' is not the same as `.'--the former 5701 tracks the current working directory as it changes during your GDB 5702 session, while the latter is immediately expanded to the current 5703 directory at the time you add an entry to the source path. 5704 5705 `directory' 5706 Reset the source path to its default value (`$cdir:$cwd' on Unix 5707 systems). This requires confirmation. 5708 5709 `set directories PATH-LIST' 5710 Set the source path to PATH-LIST. `$cdir:$cwd' are added if 5711 missing. 5712 5713 `show directories' 5714 Print the source path: show which directories it contains. 5715 5716 `set substitute-path FROM TO' 5717 Define a source path substitution rule, and add it at the end of 5718 the current list of existing substitution rules. If a rule with 5719 the same FROM was already defined, then the old rule is also 5720 deleted. 5721 5722 For example, if the file `/foo/bar/baz.c' was moved to 5723 `/mnt/cross/baz.c', then the command 5724 5725 (gdb) set substitute-path /usr/src /mnt/cross 5726 5727 will tell GDB to replace `/usr/src' with `/mnt/cross', which will 5728 allow GDB to find the file `baz.c' even though it was moved. 5729 5730 In the case when more than one substitution rule have been defined, 5731 the rules are evaluated one by one in the order where they have 5732 been defined. The first one matching, if any, is selected to 5733 perform the substitution. 5734 5735 For instance, if we had entered the following commands: 5736 5737 (gdb) set substitute-path /usr/src/include /mnt/include 5738 (gdb) set substitute-path /usr/src /mnt/src 5739 5740 GDB would then rewrite `/usr/src/include/defs.h' into 5741 `/mnt/include/defs.h' by using the first rule. However, it would 5742 use the second rule to rewrite `/usr/src/lib/foo.c' into 5743 `/mnt/src/lib/foo.c'. 5744 5745 `unset substitute-path [path]' 5746 If a path is specified, search the current list of substitution 5747 rules for a rule that would rewrite that path. Delete that rule 5748 if found. A warning is emitted by the debugger if no rule could 5749 be found. 5750 5751 If no path is specified, then all substitution rules are deleted. 5752 5753 `show substitute-path [path]' 5754 If a path is specified, then print the source path substitution 5755 rule which would rewrite that path, if any. 5756 5757 If no path is specified, then print all existing source path 5758 substitution rules. 5759 5760 5761 If your source path is cluttered with directories that are no longer 5762 of interest, GDB may sometimes cause confusion by finding the wrong 5763 versions of source. You can correct the situation as follows: 5764 5765 1. Use `directory' with no argument to reset the source path to its 5766 default value. 5767 5768 2. Use `directory' with suitable arguments to reinstall the 5769 directories you want in the source path. You can add all the 5770 directories in one command. 5771 5772 5773 File: gdb.info, Node: Machine Code, Prev: Source Path, Up: Source 5774 5775 9.6 Source and Machine Code 5776 =========================== 5777 5778 You can use the command `info line' to map source lines to program 5779 addresses (and vice versa), and the command `disassemble' to display a 5780 range of addresses as machine instructions. You can use the command 5781 `set disassemble-next-line' to set whether to disassemble next source 5782 line when execution stops. When run under GNU Emacs mode, the `info 5783 line' command causes the arrow to point to the line specified. Also, 5784 `info line' prints addresses in symbolic form as well as hex. 5785 5786 `info line LINESPEC' 5787 Print the starting and ending addresses of the compiled code for 5788 source line LINESPEC. You can specify source lines in any of the 5789 ways documented in *note Specify Location::. 5790 5791 For example, we can use `info line' to discover the location of the 5792 object code for the first line of function `m4_changequote': 5793 5794 (gdb) info line m4_changequote 5795 Line 895 of "builtin.c" starts at pc 0x634c and ends at 0x6350. 5796 5797 We can also inquire (using `*ADDR' as the form for LINESPEC) what 5798 source line covers a particular address: 5799 (gdb) info line *0x63ff 5800 Line 926 of "builtin.c" starts at pc 0x63e4 and ends at 0x6404. 5801 5802 After `info line', the default address for the `x' command is 5803 changed to the starting address of the line, so that `x/i' is 5804 sufficient to begin examining the machine code (*note Examining Memory: 5805 Memory.). Also, this address is saved as the value of the convenience 5806 variable `$_' (*note Convenience Variables: Convenience Vars.). 5807 5808 `disassemble' 5809 `disassemble /m' 5810 `disassemble /r' 5811 This specialized command dumps a range of memory as machine 5812 instructions. It can also print mixed source+disassembly by 5813 specifying the `/m' modifier and print the raw instructions in hex 5814 as well as in symbolic form by specifying the `/r'. The default 5815 memory range is the function surrounding the program counter of 5816 the selected frame. A single argument to this command is a 5817 program counter value; GDB dumps the function surrounding this 5818 value. When two arguments are given, they should be separated by 5819 a comma, possibly surrounded by whitespace. The arguments specify 5820 a range of addresses to dump, in one of two forms: 5821 5822 `START,END' 5823 the addresses from START (inclusive) to END (exclusive) 5824 5825 `START,+LENGTH' 5826 the addresses from START (inclusive) to `START+LENGTH' 5827 (exclusive). 5828 5829 When 2 arguments are specified, the name of the function is also 5830 printed (since there could be several functions in the given 5831 range). 5832 5833 The argument(s) can be any expression yielding a numeric value, 5834 such as `0x32c4', `&main+10' or `$pc - 8'. 5835 5836 If the range of memory being disassembled contains current program 5837 counter, the instruction at that location is shown with a `=>' 5838 marker. 5839 5840 The following example shows the disassembly of a range of addresses 5841 of HP PA-RISC 2.0 code: 5842 5843 (gdb) disas 0x32c4, 0x32e4 5844 Dump of assembler code from 0x32c4 to 0x32e4: 5845 0x32c4 <main+204>: addil 0,dp 5846 0x32c8 <main+208>: ldw 0x22c(sr0,r1),r26 5847 0x32cc <main+212>: ldil 0x3000,r31 5848 0x32d0 <main+216>: ble 0x3f8(sr4,r31) 5849 0x32d4 <main+220>: ldo 0(r31),rp 5850 0x32d8 <main+224>: addil -0x800,dp 5851 0x32dc <main+228>: ldo 0x588(r1),r26 5852 0x32e0 <main+232>: ldil 0x3000,r31 5853 End of assembler dump. 5854 5855 Here is an example showing mixed source+assembly for Intel x86, when 5856 the program is stopped just after function prologue: 5857 5858 (gdb) disas /m main 5859 Dump of assembler code for function main: 5860 5 { 5861 0x08048330 <+0>: push %ebp 5862 0x08048331 <+1>: mov %esp,%ebp 5863 0x08048333 <+3>: sub $0x8,%esp 5864 0x08048336 <+6>: and $0xfffffff0,%esp 5865 0x08048339 <+9>: sub $0x10,%esp 5866 5867 6 printf ("Hello.\n"); 5868 => 0x0804833c <+12>: movl $0x8048440,(%esp) 5869 0x08048343 <+19>: call 0x8048284 <puts@plt> 5870 5871 7 return 0; 5872 8 } 5873 0x08048348 <+24>: mov $0x0,%eax 5874 0x0804834d <+29>: leave 5875 0x0804834e <+30>: ret 5876 5877 End of assembler dump. 5878 5879 Here is another example showing raw instructions in hex for AMD 5880 x86-64, 5881 5882 (gdb) disas /r 0x400281,+10 5883 Dump of assembler code from 0x400281 to 0x40028b: 5884 0x0000000000400281: 38 36 cmp %dh,(%rsi) 5885 0x0000000000400283: 2d 36 34 2e 73 sub $0x732e3436,%eax 5886 0x0000000000400288: 6f outsl %ds:(%rsi),(%dx) 5887 0x0000000000400289: 2e 32 00 xor %cs:(%rax),%al 5888 End of assembler dump. 5889 5890 Some architectures have more than one commonly-used set of 5891 instruction mnemonics or other syntax. 5892 5893 For programs that were dynamically linked and use shared libraries, 5894 instructions that call functions or branch to locations in the shared 5895 libraries might show a seemingly bogus location--it's actually a 5896 location of the relocation table. On some architectures, GDB might be 5897 able to resolve these to actual function names. 5898 5899 `set disassembly-flavor INSTRUCTION-SET' 5900 Select the instruction set to use when disassembling the program 5901 via the `disassemble' or `x/i' commands. 5902 5903 Currently this command is only defined for the Intel x86 family. 5904 You can set INSTRUCTION-SET to either `intel' or `att'. The 5905 default is `att', the AT&T flavor used by default by Unix 5906 assemblers for x86-based targets. 5907 5908 `show disassembly-flavor' 5909 Show the current setting of the disassembly flavor. 5910 5911 `set disassemble-next-line' 5912 `show disassemble-next-line' 5913 Control whether or not GDB will disassemble the next source line 5914 or instruction when execution stops. If ON, GDB will display 5915 disassembly of the next source line when execution of the program 5916 being debugged stops. This is _in addition_ to displaying the 5917 source line itself, which GDB always does if possible. If the 5918 next source line cannot be displayed for some reason (e.g., if GDB 5919 cannot find the source file, or there's no line info in the debug 5920 info), GDB will display disassembly of the next _instruction_ 5921 instead of showing the next source line. If AUTO, GDB will 5922 display disassembly of next instruction only if the source line 5923 cannot be displayed. This setting causes GDB to display some 5924 feedback when you step through a function with no line info or 5925 whose source file is unavailable. The default is OFF, which means 5926 never display the disassembly of the next line or instruction. 5927 5928 5929 File: gdb.info, Node: Data, Next: Optimized Code, Prev: Source, Up: Top 5930 5931 10 Examining Data 5932 ***************** 5933 5934 The usual way to examine data in your program is with the `print' 5935 command (abbreviated `p'), or its synonym `inspect'. It evaluates and 5936 prints the value of an expression of the language your program is 5937 written in (*note Using GDB with Different Languages: Languages.). It 5938 may also print the expression using a Python-based pretty-printer 5939 (*note Pretty Printing::). 5940 5941 `print EXPR' 5942 `print /F EXPR' 5943 EXPR is an expression (in the source language). By default the 5944 value of EXPR is printed in a format appropriate to its data type; 5945 you can choose a different format by specifying `/F', where F is a 5946 letter specifying the format; see *note Output Formats: Output 5947 Formats. 5948 5949 `print' 5950 `print /F' 5951 If you omit EXPR, GDB displays the last value again (from the 5952 "value history"; *note Value History: Value History.). This 5953 allows you to conveniently inspect the same value in an 5954 alternative format. 5955 5956 A more low-level way of examining data is with the `x' command. It 5957 examines data in memory at a specified address and prints it in a 5958 specified format. *Note Examining Memory: Memory. 5959 5960 If you are interested in information about types, or about how the 5961 fields of a struct or a class are declared, use the `ptype EXP' command 5962 rather than `print'. *Note Examining the Symbol Table: Symbols. 5963 5964 * Menu: 5965 5966 * Expressions:: Expressions 5967 * Ambiguous Expressions:: Ambiguous Expressions 5968 * Variables:: Program variables 5969 * Arrays:: Artificial arrays 5970 * Output Formats:: Output formats 5971 * Memory:: Examining memory 5972 * Auto Display:: Automatic display 5973 * Print Settings:: Print settings 5974 * Pretty Printing:: Python pretty printing 5975 * Value History:: Value history 5976 * Convenience Vars:: Convenience variables 5977 * Registers:: Registers 5978 * Floating Point Hardware:: Floating point hardware 5979 * Vector Unit:: Vector Unit 5980 * OS Information:: Auxiliary data provided by operating system 5981 * Memory Region Attributes:: Memory region attributes 5982 * Dump/Restore Files:: Copy between memory and a file 5983 * Core File Generation:: Cause a program dump its core 5984 * Character Sets:: Debugging programs that use a different 5985 character set than GDB does 5986 * Caching Remote Data:: Data caching for remote targets 5987 * Searching Memory:: Searching memory for a sequence of bytes 5988 5989 5990 File: gdb.info, Node: Expressions, Next: Ambiguous Expressions, Up: Data 5991 5992 10.1 Expressions 5993 ================ 5994 5995 `print' and many other GDB commands accept an expression and compute 5996 its value. Any kind of constant, variable or operator defined by the 5997 programming language you are using is valid in an expression in GDB. 5998 This includes conditional expressions, function calls, casts, and 5999 string constants. It also includes preprocessor macros, if you 6000 compiled your program to include this information; see *note 6001 Compilation::. 6002 6003 GDB supports array constants in expressions input by the user. The 6004 syntax is {ELEMENT, ELEMENT...}. For example, you can use the command 6005 `print {1, 2, 3}' to create an array of three integers. If you pass an 6006 array to a function or assign it to a program variable, GDB copies the 6007 array to memory that is `malloc'ed in the target program. 6008 6009 Because C is so widespread, most of the expressions shown in 6010 examples in this manual are in C. *Note Using GDB with Different 6011 Languages: Languages, for information on how to use expressions in other 6012 languages. 6013 6014 In this section, we discuss operators that you can use in GDB 6015 expressions regardless of your programming language. 6016 6017 Casts are supported in all languages, not just in C, because it is so 6018 useful to cast a number into a pointer in order to examine a structure 6019 at that address in memory. 6020 6021 GDB supports these operators, in addition to those common to 6022 programming languages: 6023 6024 `@' 6025 `@' is a binary operator for treating parts of memory as arrays. 6026 *Note Artificial Arrays: Arrays, for more information. 6027 6028 `::' 6029 `::' allows you to specify a variable in terms of the file or 6030 function where it is defined. *Note Program Variables: Variables. 6031 6032 `{TYPE} ADDR' 6033 Refers to an object of type TYPE stored at address ADDR in memory. 6034 ADDR may be any expression whose value is an integer or pointer 6035 (but parentheses are required around binary operators, just as in 6036 a cast). This construct is allowed regardless of what kind of 6037 data is normally supposed to reside at ADDR. 6038 6039 6040 File: gdb.info, Node: Ambiguous Expressions, Next: Variables, Prev: Expressions, Up: Data 6041 6042 10.2 Ambiguous Expressions 6043 ========================== 6044 6045 Expressions can sometimes contain some ambiguous elements. For 6046 instance, some programming languages (notably Ada, C++ and Objective-C) 6047 permit a single function name to be defined several times, for 6048 application in different contexts. This is called "overloading". 6049 Another example involving Ada is generics. A "generic package" is 6050 similar to C++ templates and is typically instantiated several times, 6051 resulting in the same function name being defined in different contexts. 6052 6053 In some cases and depending on the language, it is possible to adjust 6054 the expression to remove the ambiguity. For instance in C++, you can 6055 specify the signature of the function you want to break on, as in 6056 `break FUNCTION(TYPES)'. In Ada, using the fully qualified name of 6057 your function often makes the expression unambiguous as well. 6058 6059 When an ambiguity that needs to be resolved is detected, the debugger 6060 has the capability to display a menu of numbered choices for each 6061 possibility, and then waits for the selection with the prompt `>'. The 6062 first option is always `[0] cancel', and typing `0 <RET>' aborts the 6063 current command. If the command in which the expression was used 6064 allows more than one choice to be selected, the next option in the menu 6065 is `[1] all', and typing `1 <RET>' selects all possible choices. 6066 6067 For example, the following session excerpt shows an attempt to set a 6068 breakpoint at the overloaded symbol `String::after'. We choose three 6069 particular definitions of that function name: 6070 6071 (gdb) b String::after 6072 [0] cancel 6073 [1] all 6074 [2] file:String.cc; line number:867 6075 [3] file:String.cc; line number:860 6076 [4] file:String.cc; line number:875 6077 [5] file:String.cc; line number:853 6078 [6] file:String.cc; line number:846 6079 [7] file:String.cc; line number:735 6080 > 2 4 6 6081 Breakpoint 1 at 0xb26c: file String.cc, line 867. 6082 Breakpoint 2 at 0xb344: file String.cc, line 875. 6083 Breakpoint 3 at 0xafcc: file String.cc, line 846. 6084 Multiple breakpoints were set. 6085 Use the "delete" command to delete unwanted 6086 breakpoints. 6087 (gdb) 6088 6089 `set multiple-symbols MODE' 6090 This option allows you to adjust the debugger behavior when an 6091 expression is ambiguous. 6092 6093 By default, MODE is set to `all'. If the command with which the 6094 expression is used allows more than one choice, then GDB 6095 automatically selects all possible choices. For instance, 6096 inserting a breakpoint on a function using an ambiguous name 6097 results in a breakpoint inserted on each possible match. However, 6098 if a unique choice must be made, then GDB uses the menu to help 6099 you disambiguate the expression. For instance, printing the 6100 address of an overloaded function will result in the use of the 6101 menu. 6102 6103 When MODE is set to `ask', the debugger always uses the menu when 6104 an ambiguity is detected. 6105 6106 Finally, when MODE is set to `cancel', the debugger reports an 6107 error due to the ambiguity and the command is aborted. 6108 6109 `show multiple-symbols' 6110 Show the current value of the `multiple-symbols' setting. 6111 6112 6113 File: gdb.info, Node: Variables, Next: Arrays, Prev: Ambiguous Expressions, Up: Data 6114 6115 10.3 Program Variables 6116 ====================== 6117 6118 The most common kind of expression to use is the name of a variable in 6119 your program. 6120 6121 Variables in expressions are understood in the selected stack frame 6122 (*note Selecting a Frame: Selection.); they must be either: 6123 6124 * global (or file-static) 6125 6126 or 6127 6128 * visible according to the scope rules of the programming language 6129 from the point of execution in that frame 6130 6131 This means that in the function 6132 6133 foo (a) 6134 int a; 6135 { 6136 bar (a); 6137 { 6138 int b = test (); 6139 bar (b); 6140 } 6141 } 6142 6143 you can examine and use the variable `a' whenever your program is 6144 executing within the function `foo', but you can only use or examine 6145 the variable `b' while your program is executing inside the block where 6146 `b' is declared. 6147 6148 There is an exception: you can refer to a variable or function whose 6149 scope is a single source file even if the current execution point is not 6150 in this file. But it is possible to have more than one such variable or 6151 function with the same name (in different source files). If that 6152 happens, referring to that name has unpredictable effects. If you wish, 6153 you can specify a static variable in a particular function or file, 6154 using the colon-colon (`::') notation: 6155 6156 FILE::VARIABLE 6157 FUNCTION::VARIABLE 6158 6159 Here FILE or FUNCTION is the name of the context for the static 6160 VARIABLE. In the case of file names, you can use quotes to make sure 6161 GDB parses the file name as a single word--for example, to print a 6162 global value of `x' defined in `f2.c': 6163 6164 (gdb) p 'f2.c'::x 6165 6166 This use of `::' is very rarely in conflict with the very similar 6167 use of the same notation in C++. GDB also supports use of the C++ 6168 scope resolution operator in GDB expressions. 6169 6170 _Warning:_ Occasionally, a local variable may appear to have the 6171 wrong value at certain points in a function--just after entry to a 6172 new scope, and just before exit. 6173 You may see this problem when you are stepping by machine 6174 instructions. This is because, on most machines, it takes more than 6175 one instruction to set up a stack frame (including local variable 6176 definitions); if you are stepping by machine instructions, variables 6177 may appear to have the wrong values until the stack frame is completely 6178 built. On exit, it usually also takes more than one machine 6179 instruction to destroy a stack frame; after you begin stepping through 6180 that group of instructions, local variable definitions may be gone. 6181 6182 This may also happen when the compiler does significant 6183 optimizations. To be sure of always seeing accurate values, turn off 6184 all optimization when compiling. 6185 6186 Another possible effect of compiler optimizations is to optimize 6187 unused variables out of existence, or assign variables to registers (as 6188 opposed to memory addresses). Depending on the support for such cases 6189 offered by the debug info format used by the compiler, GDB might not be 6190 able to display values for such local variables. If that happens, GDB 6191 will print a message like this: 6192 6193 No symbol "foo" in current context. 6194 6195 To solve such problems, either recompile without optimizations, or 6196 use a different debug info format, if the compiler supports several such 6197 formats. For example, GCC, the GNU C/C++ compiler, usually supports 6198 the `-gstabs+' option. `-gstabs+' produces debug info in a format that 6199 is superior to formats such as COFF. You may be able to use DWARF 2 6200 (`-gdwarf-2'), which is also an effective form for debug info. *Note 6201 Options for Debugging Your Program or GCC: (gcc.info)Debugging Options. 6202 *Note C and C++: C, for more information about debug info formats that 6203 are best suited to C++ programs. 6204 6205 If you ask to print an object whose contents are unknown to GDB, 6206 e.g., because its data type is not completely specified by the debug 6207 information, GDB will say `<incomplete type>'. *Note incomplete type: 6208 Symbols, for more about this. 6209 6210 Strings are identified as arrays of `char' values without specified 6211 signedness. Arrays of either `signed char' or `unsigned char' get 6212 printed as arrays of 1 byte sized integers. `-fsigned-char' or 6213 `-funsigned-char' GCC options have no effect as GDB defines literal 6214 string type `"char"' as `char' without a sign. For program code 6215 6216 char var0[] = "A"; 6217 signed char var1[] = "A"; 6218 6219 You get during debugging 6220 (gdb) print var0 6221 $1 = "A" 6222 (gdb) print var1 6223 $2 = {65 'A', 0 '\0'} 6224 6225 6226 File: gdb.info, Node: Arrays, Next: Output Formats, Prev: Variables, Up: Data 6227 6228 10.4 Artificial Arrays 6229 ====================== 6230 6231 It is often useful to print out several successive objects of the same 6232 type in memory; a section of an array, or an array of dynamically 6233 determined size for which only a pointer exists in the program. 6234 6235 You can do this by referring to a contiguous span of memory as an 6236 "artificial array", using the binary operator `@'. The left operand of 6237 `@' should be the first element of the desired array and be an 6238 individual object. The right operand should be the desired length of 6239 the array. The result is an array value whose elements are all of the 6240 type of the left argument. The first element is actually the left 6241 argument; the second element comes from bytes of memory immediately 6242 following those that hold the first element, and so on. Here is an 6243 example. If a program says 6244 6245 int *array = (int *) malloc (len * sizeof (int)); 6246 6247 you can print the contents of `array' with 6248 6249 p *array@len 6250 6251 The left operand of `@' must reside in memory. Array values made 6252 with `@' in this way behave just like other arrays in terms of 6253 subscripting, and are coerced to pointers when used in expressions. 6254 Artificial arrays most often appear in expressions via the value history 6255 (*note Value History: Value History.), after printing one out. 6256 6257 Another way to create an artificial array is to use a cast. This 6258 re-interprets a value as if it were an array. The value need not be in 6259 memory: 6260 (gdb) p/x (short[2])0x12345678 6261 $1 = {0x1234, 0x5678} 6262 6263 As a convenience, if you leave the array length out (as in 6264 `(TYPE[])VALUE') GDB calculates the size to fill the value (as 6265 `sizeof(VALUE)/sizeof(TYPE)': 6266 (gdb) p/x (short[])0x12345678 6267 $2 = {0x1234, 0x5678} 6268 6269 Sometimes the artificial array mechanism is not quite enough; in 6270 moderately complex data structures, the elements of interest may not 6271 actually be adjacent--for example, if you are interested in the values 6272 of pointers in an array. One useful work-around in this situation is 6273 to use a convenience variable (*note Convenience Variables: Convenience 6274 Vars.) as a counter in an expression that prints the first interesting 6275 value, and then repeat that expression via <RET>. For instance, 6276 suppose you have an array `dtab' of pointers to structures, and you are 6277 interested in the values of a field `fv' in each structure. Here is an 6278 example of what you might type: 6279 6280 set $i = 0 6281 p dtab[$i++]->fv 6282 <RET> 6283 <RET> 6284 ... 6285 6286 6287 File: gdb.info, Node: Output Formats, Next: Memory, Prev: Arrays, Up: Data 6288 6289 10.5 Output Formats 6290 =================== 6291 6292 By default, GDB prints a value according to its data type. Sometimes 6293 this is not what you want. For example, you might want to print a 6294 number in hex, or a pointer in decimal. Or you might want to view data 6295 in memory at a certain address as a character string or as an 6296 instruction. To do these things, specify an "output format" when you 6297 print a value. 6298 6299 The simplest use of output formats is to say how to print a value 6300 already computed. This is done by starting the arguments of the 6301 `print' command with a slash and a format letter. The format letters 6302 supported are: 6303 6304 `x' 6305 Regard the bits of the value as an integer, and print the integer 6306 in hexadecimal. 6307 6308 `d' 6309 Print as integer in signed decimal. 6310 6311 `u' 6312 Print as integer in unsigned decimal. 6313 6314 `o' 6315 Print as integer in octal. 6316 6317 `t' 6318 Print as integer in binary. The letter `t' stands for "two". (1) 6319 6320 `a' 6321 Print as an address, both absolute in hexadecimal and as an offset 6322 from the nearest preceding symbol. You can use this format used 6323 to discover where (in what function) an unknown address is located: 6324 6325 (gdb) p/a 0x54320 6326 $3 = 0x54320 <_initialize_vx+396> 6327 6328 The command `info symbol 0x54320' yields similar results. *Note 6329 info symbol: Symbols. 6330 6331 `c' 6332 Regard as an integer and print it as a character constant. This 6333 prints both the numerical value and its character representation. 6334 The character representation is replaced with the octal escape 6335 `\nnn' for characters outside the 7-bit ASCII range. 6336 6337 Without this format, GDB displays `char', `unsigned char', and 6338 `signed char' data as character constants. Single-byte members of 6339 vectors are displayed as integer data. 6340 6341 `f' 6342 Regard the bits of the value as a floating point number and print 6343 using typical floating point syntax. 6344 6345 `s' 6346 Regard as a string, if possible. With this format, pointers to 6347 single-byte data are displayed as null-terminated strings and 6348 arrays of single-byte data are displayed as fixed-length strings. 6349 Other values are displayed in their natural types. 6350 6351 Without this format, GDB displays pointers to and arrays of 6352 `char', `unsigned char', and `signed char' as strings. 6353 Single-byte members of a vector are displayed as an integer array. 6354 6355 `r' 6356 Print using the `raw' formatting. By default, GDB will use a 6357 Python-based pretty-printer, if one is available (*note Pretty 6358 Printing::). This typically results in a higher-level display of 6359 the value's contents. The `r' format bypasses any Python 6360 pretty-printer which might exist. 6361 6362 For example, to print the program counter in hex (*note 6363 Registers::), type 6364 6365 p/x $pc 6366 6367 Note that no space is required before the slash; this is because command 6368 names in GDB cannot contain a slash. 6369 6370 To reprint the last value in the value history with a different 6371 format, you can use the `print' command with just a format and no 6372 expression. For example, `p/x' reprints the last value in hex. 6373 6374 ---------- Footnotes ---------- 6375 6376 (1) `b' cannot be used because these format letters are also used 6377 with the `x' command, where `b' stands for "byte"; see *note Examining 6378 Memory: Memory. 6379 6380 6381 File: gdb.info, Node: Memory, Next: Auto Display, Prev: Output Formats, Up: Data 6382 6383 10.6 Examining Memory 6384 ===================== 6385 6386 You can use the command `x' (for "examine") to examine memory in any of 6387 several formats, independently of your program's data types. 6388 6389 `x/NFU ADDR' 6390 `x ADDR' 6391 `x' 6392 Use the `x' command to examine memory. 6393 6394 N, F, and U are all optional parameters that specify how much memory 6395 to display and how to format it; ADDR is an expression giving the 6396 address where you want to start displaying memory. If you use defaults 6397 for NFU, you need not type the slash `/'. Several commands set 6398 convenient defaults for ADDR. 6399 6400 N, the repeat count 6401 The repeat count is a decimal integer; the default is 1. It 6402 specifies how much memory (counting by units U) to display. 6403 6404 F, the display format 6405 The display format is one of the formats used by `print' (`x', 6406 `d', `u', `o', `t', `a', `c', `f', `s'), and in addition `i' (for 6407 machine instructions). The default is `x' (hexadecimal) 6408 initially. The default changes each time you use either `x' or 6409 `print'. 6410 6411 U, the unit size 6412 The unit size is any of 6413 6414 `b' 6415 Bytes. 6416 6417 `h' 6418 Halfwords (two bytes). 6419 6420 `w' 6421 Words (four bytes). This is the initial default. 6422 6423 `g' 6424 Giant words (eight bytes). 6425 6426 Each time you specify a unit size with `x', that size becomes the 6427 default unit the next time you use `x'. For the `i' format, the 6428 unit size is ignored and is normally not written. For the `s' 6429 format, the unit size defaults to `b', unless it is explicitly 6430 given. Use `x /hs' to display 16-bit char strings and `x /ws' to 6431 display 32-bit strings. The next use of `x /s' will again display 6432 8-bit strings. Note that the results depend on the programming 6433 language of the current compilation unit. If the language is C, 6434 the `s' modifier will use the UTF-16 encoding while `w' will use 6435 UTF-32. The encoding is set by the programming language and cannot 6436 be altered. 6437 6438 ADDR, starting display address 6439 ADDR is the address where you want GDB to begin displaying memory. 6440 The expression need not have a pointer value (though it may); it 6441 is always interpreted as an integer address of a byte of memory. 6442 *Note Expressions: Expressions, for more information on 6443 expressions. The default for ADDR is usually just after the last 6444 address examined--but several other commands also set the default 6445 address: `info breakpoints' (to the address of the last breakpoint 6446 listed), `info line' (to the starting address of a line), and 6447 `print' (if you use it to display a value from memory). 6448 6449 For example, `x/3uh 0x54320' is a request to display three halfwords 6450 (`h') of memory, formatted as unsigned decimal integers (`u'), starting 6451 at address `0x54320'. `x/4xw $sp' prints the four words (`w') of 6452 memory above the stack pointer (here, `$sp'; *note Registers: 6453 Registers.) in hexadecimal (`x'). 6454 6455 Since the letters indicating unit sizes are all distinct from the 6456 letters specifying output formats, you do not have to remember whether 6457 unit size or format comes first; either order works. The output 6458 specifications `4xw' and `4wx' mean exactly the same thing. (However, 6459 the count N must come first; `wx4' does not work.) 6460 6461 Even though the unit size U is ignored for the formats `s' and `i', 6462 you might still want to use a count N; for example, `3i' specifies that 6463 you want to see three machine instructions, including any operands. 6464 For convenience, especially when used with the `display' command, the 6465 `i' format also prints branch delay slot instructions, if any, beyond 6466 the count specified, which immediately follow the last instruction that 6467 is within the count. The command `disassemble' gives an alternative 6468 way of inspecting machine instructions; see *note Source and Machine 6469 Code: Machine Code. 6470 6471 All the defaults for the arguments to `x' are designed to make it 6472 easy to continue scanning memory with minimal specifications each time 6473 you use `x'. For example, after you have inspected three machine 6474 instructions with `x/3i ADDR', you can inspect the next seven with just 6475 `x/7'. If you use <RET> to repeat the `x' command, the repeat count N 6476 is used again; the other arguments default as for successive uses of 6477 `x'. 6478 6479 When examining machine instructions, the instruction at current 6480 program counter is shown with a `=>' marker. For example: 6481 6482 (gdb) x/5i $pc-6 6483 0x804837f <main+11>: mov %esp,%ebp 6484 0x8048381 <main+13>: push %ecx 6485 0x8048382 <main+14>: sub $0x4,%esp 6486 => 0x8048385 <main+17>: movl $0x8048460,(%esp) 6487 0x804838c <main+24>: call 0x80482d4 <puts@plt> 6488 6489 The addresses and contents printed by the `x' command are not saved 6490 in the value history because there is often too much of them and they 6491 would get in the way. Instead, GDB makes these values available for 6492 subsequent use in expressions as values of the convenience variables 6493 `$_' and `$__'. After an `x' command, the last address examined is 6494 available for use in expressions in the convenience variable `$_'. The 6495 contents of that address, as examined, are available in the convenience 6496 variable `$__'. 6497 6498 If the `x' command has a repeat count, the address and contents saved 6499 are from the last memory unit printed; this is not the same as the last 6500 address printed if several units were printed on the last line of 6501 output. 6502 6503 When you are debugging a program running on a remote target machine 6504 (*note Remote Debugging::), you may wish to verify the program's image 6505 in the remote machine's memory against the executable file you 6506 downloaded to the target. The `compare-sections' command is provided 6507 for such situations. 6508 6509 `compare-sections [SECTION-NAME]' 6510 Compare the data of a loadable section SECTION-NAME in the 6511 executable file of the program being debugged with the same 6512 section in the remote machine's memory, and report any mismatches. 6513 With no arguments, compares all loadable sections. This command's 6514 availability depends on the target's support for the `"qCRC"' 6515 remote request. 6516 6517 6518 File: gdb.info, Node: Auto Display, Next: Print Settings, Prev: Memory, Up: Data 6519 6520 10.7 Automatic Display 6521 ====================== 6522 6523 If you find that you want to print the value of an expression frequently 6524 (to see how it changes), you might want to add it to the "automatic 6525 display list" so that GDB prints its value each time your program stops. 6526 Each expression added to the list is given a number to identify it; to 6527 remove an expression from the list, you specify that number. The 6528 automatic display looks like this: 6529 6530 2: foo = 38 6531 3: bar[5] = (struct hack *) 0x3804 6532 6533 This display shows item numbers, expressions and their current values. 6534 As with displays you request manually using `x' or `print', you can 6535 specify the output format you prefer; in fact, `display' decides 6536 whether to use `print' or `x' depending your format specification--it 6537 uses `x' if you specify either the `i' or `s' format, or a unit size; 6538 otherwise it uses `print'. 6539 6540 `display EXPR' 6541 Add the expression EXPR to the list of expressions to display each 6542 time your program stops. *Note Expressions: Expressions. 6543 6544 `display' does not repeat if you press <RET> again after using it. 6545 6546 `display/FMT EXPR' 6547 For FMT specifying only a display format and not a size or count, 6548 add the expression EXPR to the auto-display list but arrange to 6549 display it each time in the specified format FMT. *Note Output 6550 Formats: Output Formats. 6551 6552 `display/FMT ADDR' 6553 For FMT `i' or `s', or including a unit-size or a number of units, 6554 add the expression ADDR as a memory address to be examined each 6555 time your program stops. Examining means in effect doing `x/FMT 6556 ADDR'. *Note Examining Memory: Memory. 6557 6558 For example, `display/i $pc' can be helpful, to see the machine 6559 instruction about to be executed each time execution stops (`$pc' is a 6560 common name for the program counter; *note Registers: Registers.). 6561 6562 `undisplay DNUMS...' 6563 `delete display DNUMS...' 6564 Remove items from the list of expressions to display. Specify the 6565 numbers of the displays that you want affected with the command 6566 argument DNUMS. It can be a single display number, one of the 6567 numbers shown in the first field of the `info display' display; or 6568 it could be a range of display numbers, as in `2-4'. 6569 6570 `undisplay' does not repeat if you press <RET> after using it. 6571 (Otherwise you would just get the error `No display number ...'.) 6572 6573 `disable display DNUMS...' 6574 Disable the display of item numbers DNUMS. A disabled display 6575 item is not printed automatically, but is not forgotten. It may be 6576 enabled again later. Specify the numbers of the displays that you 6577 want affected with the command argument DNUMS. It can be a single 6578 display number, one of the numbers shown in the first field of the 6579 `info display' display; or it could be a range of display numbers, 6580 as in `2-4'. 6581 6582 `enable display DNUMS...' 6583 Enable display of item numbers DNUMS. It becomes effective once 6584 again in auto display of its expression, until you specify 6585 otherwise. Specify the numbers of the displays that you want 6586 affected with the command argument DNUMS. It can be a single 6587 display number, one of the numbers shown in the first field of the 6588 `info display' display; or it could be a range of display numbers, 6589 as in `2-4'. 6590 6591 `display' 6592 Display the current values of the expressions on the list, just as 6593 is done when your program stops. 6594 6595 `info display' 6596 Print the list of expressions previously set up to display 6597 automatically, each one with its item number, but without showing 6598 the values. This includes disabled expressions, which are marked 6599 as such. It also includes expressions which would not be 6600 displayed right now because they refer to automatic variables not 6601 currently available. 6602 6603 If a display expression refers to local variables, then it does not 6604 make sense outside the lexical context for which it was set up. Such an 6605 expression is disabled when execution enters a context where one of its 6606 variables is not defined. For example, if you give the command 6607 `display last_char' while inside a function with an argument 6608 `last_char', GDB displays this argument while your program continues to 6609 stop inside that function. When it stops elsewhere--where there is no 6610 variable `last_char'--the display is disabled automatically. The next 6611 time your program stops where `last_char' is meaningful, you can enable 6612 the display expression once again. 6613 6614 6615 File: gdb.info, Node: Print Settings, Next: Pretty Printing, Prev: Auto Display, Up: Data 6616 6617 10.8 Print Settings 6618 =================== 6619 6620 GDB provides the following ways to control how arrays, structures, and 6621 symbols are printed. 6622 6623 These settings are useful for debugging programs in any language: 6624 6625 `set print address' 6626 `set print address on' 6627 GDB prints memory addresses showing the location of stack traces, 6628 structure values, pointer values, breakpoints, and so forth, even 6629 when it also displays the contents of those addresses. The default 6630 is `on'. For example, this is what a stack frame display looks 6631 like with `set print address on': 6632 6633 (gdb) f 6634 #0 set_quotes (lq=0x34c78 "<<", rq=0x34c88 ">>") 6635 at input.c:530 6636 530 if (lquote != def_lquote) 6637 6638 `set print address off' 6639 Do not print addresses when displaying their contents. For 6640 example, this is the same stack frame displayed with `set print 6641 address off': 6642 6643 (gdb) set print addr off 6644 (gdb) f 6645 #0 set_quotes (lq="<<", rq=">>") at input.c:530 6646 530 if (lquote != def_lquote) 6647 6648 You can use `set print address off' to eliminate all machine 6649 dependent displays from the GDB interface. For example, with 6650 `print address off', you should get the same text for backtraces on 6651 all machines--whether or not they involve pointer arguments. 6652 6653 `show print address' 6654 Show whether or not addresses are to be printed. 6655 6656 When GDB prints a symbolic address, it normally prints the closest 6657 earlier symbol plus an offset. If that symbol does not uniquely 6658 identify the address (for example, it is a name whose scope is a single 6659 source file), you may need to clarify. One way to do this is with 6660 `info line', for example `info line *0x4537'. Alternately, you can set 6661 GDB to print the source file and line number when it prints a symbolic 6662 address: 6663 6664 `set print symbol-filename on' 6665 Tell GDB to print the source file name and line number of a symbol 6666 in the symbolic form of an address. 6667 6668 `set print symbol-filename off' 6669 Do not print source file name and line number of a symbol. This 6670 is the default. 6671 6672 `show print symbol-filename' 6673 Show whether or not GDB will print the source file name and line 6674 number of a symbol in the symbolic form of an address. 6675 6676 Another situation where it is helpful to show symbol filenames and 6677 line numbers is when disassembling code; GDB shows you the line number 6678 and source file that corresponds to each instruction. 6679 6680 Also, you may wish to see the symbolic form only if the address being 6681 printed is reasonably close to the closest earlier symbol: 6682 6683 `set print max-symbolic-offset MAX-OFFSET' 6684 Tell GDB to only display the symbolic form of an address if the 6685 offset between the closest earlier symbol and the address is less 6686 than MAX-OFFSET. The default is 0, which tells GDB to always 6687 print the symbolic form of an address if any symbol precedes it. 6688 6689 `show print max-symbolic-offset' 6690 Ask how large the maximum offset is that GDB prints in a symbolic 6691 address. 6692 6693 If you have a pointer and you are not sure where it points, try `set 6694 print symbol-filename on'. Then you can determine the name and source 6695 file location of the variable where it points, using `p/a POINTER'. 6696 This interprets the address in symbolic form. For example, here GDB 6697 shows that a variable `ptt' points at another variable `t', defined in 6698 `hi2.c': 6699 6700 (gdb) set print symbol-filename on 6701 (gdb) p/a ptt 6702 $4 = 0xe008 <t in hi2.c> 6703 6704 _Warning:_ For pointers that point to a local variable, `p/a' does 6705 not show the symbol name and filename of the referent, even with 6706 the appropriate `set print' options turned on. 6707 6708 Other settings control how different kinds of objects are printed: 6709 6710 `set print array' 6711 `set print array on' 6712 Pretty print arrays. This format is more convenient to read, but 6713 uses more space. The default is off. 6714 6715 `set print array off' 6716 Return to compressed format for arrays. 6717 6718 `show print array' 6719 Show whether compressed or pretty format is selected for displaying 6720 arrays. 6721 6722 `set print array-indexes' 6723 `set print array-indexes on' 6724 Print the index of each element when displaying arrays. May be 6725 more convenient to locate a given element in the array or quickly 6726 find the index of a given element in that printed array. The 6727 default is off. 6728 6729 `set print array-indexes off' 6730 Stop printing element indexes when displaying arrays. 6731 6732 `show print array-indexes' 6733 Show whether the index of each element is printed when displaying 6734 arrays. 6735 6736 `set print elements NUMBER-OF-ELEMENTS' 6737 Set a limit on how many elements of an array GDB will print. If 6738 GDB is printing a large array, it stops printing after it has 6739 printed the number of elements set by the `set print elements' 6740 command. This limit also applies to the display of strings. When 6741 GDB starts, this limit is set to 200. Setting NUMBER-OF-ELEMENTS 6742 to zero means that the printing is unlimited. 6743 6744 `show print elements' 6745 Display the number of elements of a large array that GDB will 6746 print. If the number is 0, then the printing is unlimited. 6747 6748 `set print frame-arguments VALUE' 6749 This command allows to control how the values of arguments are 6750 printed when the debugger prints a frame (*note Frames::). The 6751 possible values are: 6752 6753 `all' 6754 The values of all arguments are printed. 6755 6756 `scalars' 6757 Print the value of an argument only if it is a scalar. The 6758 value of more complex arguments such as arrays, structures, 6759 unions, etc, is replaced by `...'. This is the default. 6760 Here is an example where only scalar arguments are shown: 6761 6762 #1 0x08048361 in call_me (i=3, s=..., ss=0xbf8d508c, u=..., e=green) 6763 at frame-args.c:23 6764 6765 `none' 6766 None of the argument values are printed. Instead, the value 6767 of each argument is replaced by `...'. In this case, the 6768 example above now becomes: 6769 6770 #1 0x08048361 in call_me (i=..., s=..., ss=..., u=..., e=...) 6771 at frame-args.c:23 6772 6773 By default, only scalar arguments are printed. This command can 6774 be used to configure the debugger to print the value of all 6775 arguments, regardless of their type. However, it is often 6776 advantageous to not print the value of more complex parameters. 6777 For instance, it reduces the amount of information printed in each 6778 frame, making the backtrace more readable. Also, it improves 6779 performance when displaying Ada frames, because the computation of 6780 large arguments can sometimes be CPU-intensive, especially in 6781 large applications. Setting `print frame-arguments' to `scalars' 6782 (the default) or `none' avoids this computation, thus speeding up 6783 the display of each Ada frame. 6784 6785 `show print frame-arguments' 6786 Show how the value of arguments should be displayed when printing 6787 a frame. 6788 6789 `set print repeats' 6790 Set the threshold for suppressing display of repeated array 6791 elements. When the number of consecutive identical elements of an 6792 array exceeds the threshold, GDB prints the string `"<repeats N 6793 times>"', where N is the number of identical repetitions, instead 6794 of displaying the identical elements themselves. Setting the 6795 threshold to zero will cause all elements to be individually 6796 printed. The default threshold is 10. 6797 6798 `show print repeats' 6799 Display the current threshold for printing repeated identical 6800 elements. 6801 6802 `set print null-stop' 6803 Cause GDB to stop printing the characters of an array when the 6804 first NULL is encountered. This is useful when large arrays 6805 actually contain only short strings. The default is off. 6806 6807 `show print null-stop' 6808 Show whether GDB stops printing an array on the first NULL 6809 character. 6810 6811 `set print pretty on' 6812 Cause GDB to print structures in an indented format with one member 6813 per line, like this: 6814 6815 $1 = { 6816 next = 0x0, 6817 flags = { 6818 sweet = 1, 6819 sour = 1 6820 }, 6821 meat = 0x54 "Pork" 6822 } 6823 6824 `set print pretty off' 6825 Cause GDB to print structures in a compact format, like this: 6826 6827 $1 = {next = 0x0, flags = {sweet = 1, sour = 1}, \ 6828 meat = 0x54 "Pork"} 6829 6830 This is the default format. 6831 6832 `show print pretty' 6833 Show which format GDB is using to print structures. 6834 6835 `set print sevenbit-strings on' 6836 Print using only seven-bit characters; if this option is set, GDB 6837 displays any eight-bit characters (in strings or character values) 6838 using the notation `\'NNN. This setting is best if you are 6839 working in English (ASCII) and you use the high-order bit of 6840 characters as a marker or "meta" bit. 6841 6842 `set print sevenbit-strings off' 6843 Print full eight-bit characters. This allows the use of more 6844 international character sets, and is the default. 6845 6846 `show print sevenbit-strings' 6847 Show whether or not GDB is printing only seven-bit characters. 6848 6849 `set print union on' 6850 Tell GDB to print unions which are contained in structures and 6851 other unions. This is the default setting. 6852 6853 `set print union off' 6854 Tell GDB not to print unions which are contained in structures and 6855 other unions. GDB will print `"{...}"' instead. 6856 6857 `show print union' 6858 Ask GDB whether or not it will print unions which are contained in 6859 structures and other unions. 6860 6861 For example, given the declarations 6862 6863 typedef enum {Tree, Bug} Species; 6864 typedef enum {Big_tree, Acorn, Seedling} Tree_forms; 6865 typedef enum {Caterpillar, Cocoon, Butterfly} 6866 Bug_forms; 6867 6868 struct thing { 6869 Species it; 6870 union { 6871 Tree_forms tree; 6872 Bug_forms bug; 6873 } form; 6874 }; 6875 6876 struct thing foo = {Tree, {Acorn}}; 6877 6878 with `set print union on' in effect `p foo' would print 6879 6880 $1 = {it = Tree, form = {tree = Acorn, bug = Cocoon}} 6881 6882 and with `set print union off' in effect it would print 6883 6884 $1 = {it = Tree, form = {...}} 6885 6886 `set print union' affects programs written in C-like languages and 6887 in Pascal. 6888 6889 These settings are of interest when debugging C++ programs: 6890 6891 `set print demangle' 6892 `set print demangle on' 6893 Print C++ names in their source form rather than in the encoded 6894 ("mangled") form passed to the assembler and linker for type-safe 6895 linkage. The default is on. 6896 6897 `show print demangle' 6898 Show whether C++ names are printed in mangled or demangled form. 6899 6900 `set print asm-demangle' 6901 `set print asm-demangle on' 6902 Print C++ names in their source form rather than their mangled 6903 form, even in assembler code printouts such as instruction 6904 disassemblies. The default is off. 6905 6906 `show print asm-demangle' 6907 Show whether C++ names in assembly listings are printed in mangled 6908 or demangled form. 6909 6910 `set demangle-style STYLE' 6911 Choose among several encoding schemes used by different compilers 6912 to represent C++ names. The choices for STYLE are currently: 6913 6914 `auto' 6915 Allow GDB to choose a decoding style by inspecting your 6916 program. 6917 6918 `gnu' 6919 Decode based on the GNU C++ compiler (`g++') encoding 6920 algorithm. This is the default. 6921 6922 `hp' 6923 Decode based on the HP ANSI C++ (`aCC') encoding algorithm. 6924 6925 `lucid' 6926 Decode based on the Lucid C++ compiler (`lcc') encoding 6927 algorithm. 6928 6929 `arm' 6930 Decode using the algorithm in the `C++ Annotated Reference 6931 Manual'. *Warning:* this setting alone is not sufficient to 6932 allow debugging `cfront'-generated executables. GDB would 6933 require further enhancement to permit that. 6934 6935 If you omit STYLE, you will see a list of possible formats. 6936 6937 `show demangle-style' 6938 Display the encoding style currently in use for decoding C++ 6939 symbols. 6940 6941 `set print object' 6942 `set print object on' 6943 When displaying a pointer to an object, identify the _actual_ 6944 (derived) type of the object rather than the _declared_ type, using 6945 the virtual function table. 6946 6947 `set print object off' 6948 Display only the declared type of objects, without reference to the 6949 virtual function table. This is the default setting. 6950 6951 `show print object' 6952 Show whether actual, or declared, object types are displayed. 6953 6954 `set print static-members' 6955 `set print static-members on' 6956 Print static members when displaying a C++ object. The default is 6957 on. 6958 6959 `set print static-members off' 6960 Do not print static members when displaying a C++ object. 6961 6962 `show print static-members' 6963 Show whether C++ static members are printed or not. 6964 6965 `set print pascal_static-members' 6966 `set print pascal_static-members on' 6967 Print static members when displaying a Pascal object. The default 6968 is on. 6969 6970 `set print pascal_static-members off' 6971 Do not print static members when displaying a Pascal object. 6972 6973 `show print pascal_static-members' 6974 Show whether Pascal static members are printed or not. 6975 6976 `set print vtbl' 6977 `set print vtbl on' 6978 Pretty print C++ virtual function tables. The default is off. 6979 (The `vtbl' commands do not work on programs compiled with the HP 6980 ANSI C++ compiler (`aCC').) 6981 6982 `set print vtbl off' 6983 Do not pretty print C++ virtual function tables. 6984 6985 `show print vtbl' 6986 Show whether C++ virtual function tables are pretty printed, or 6987 not. 6988 6989 6990 File: gdb.info, Node: Pretty Printing, Next: Value History, Prev: Print Settings, Up: Data 6991 6992 10.9 Pretty Printing 6993 ==================== 6994 6995 GDB provides a mechanism to allow pretty-printing of values using 6996 Python code. It greatly simplifies the display of complex objects. 6997 This mechanism works for both MI and the CLI. 6998 6999 * Menu: 7000 7001 * Pretty-Printer Introduction:: Introduction to pretty-printers 7002 * Pretty-Printer Example:: An example pretty-printer 7003 * Pretty-Printer Commands:: Pretty-printer commands 7004 7005 7006 File: gdb.info, Node: Pretty-Printer Introduction, Next: Pretty-Printer Example, Up: Pretty Printing 7007 7008 10.9.1 Pretty-Printer Introduction 7009 ---------------------------------- 7010 7011 When GDB prints a value, it first sees if there is a pretty-printer 7012 registered for the value. If there is then GDB invokes the 7013 pretty-printer to print the value. Otherwise the value is printed 7014 normally. 7015 7016 Pretty-printers are normally named. This makes them easy to manage. 7017 The `info pretty-printer' command will list all the installed 7018 pretty-printers with their names. If a pretty-printer can handle 7019 multiple data types, then its "subprinters" are the printers for the 7020 individual data types. Each such subprinter has its own name. The 7021 format of the name is PRINTER-NAME;SUBPRINTER-NAME. 7022 7023 Pretty-printers are installed by "registering" them with GDB. 7024 Typically they are automatically loaded and registered when the 7025 corresponding debug information is loaded, thus making them available 7026 without having to do anything special. 7027 7028 There are three places where a pretty-printer can be registered. 7029 7030 * Pretty-printers registered globally are available when debugging 7031 all inferiors. 7032 7033 * Pretty-printers registered with a program space are available only 7034 when debugging that program. *Note Progspaces In Python::, for 7035 more details on program spaces in Python. 7036 7037 * Pretty-printers registered with an objfile are loaded and unloaded 7038 with the corresponding objfile (e.g., shared library). *Note 7039 Objfiles In Python::, for more details on objfiles in Python. 7040 7041 *Note Selecting Pretty-Printers::, for further information on how 7042 pretty-printers are selected, 7043 7044 *Note Writing a Pretty-Printer::, for implementing pretty printers 7045 for new types. 7046 7047 7048 File: gdb.info, Node: Pretty-Printer Example, Next: Pretty-Printer Commands, Prev: Pretty-Printer Introduction, Up: Pretty Printing 7049 7050 10.9.2 Pretty-Printer Example 7051 ----------------------------- 7052 7053 Here is how a C++ `std::string' looks without a pretty-printer: 7054 7055 (gdb) print s 7056 $1 = { 7057 static npos = 4294967295, 7058 _M_dataplus = { 7059 <std::allocator<char>> = { 7060 <__gnu_cxx::new_allocator<char>> = { 7061 <No data fields>}, <No data fields> 7062 }, 7063 members of std::basic_string<char, std::char_traits<char>, 7064 std::allocator<char> >::_Alloc_hider: 7065 _M_p = 0x804a014 "abcd" 7066 } 7067 } 7068 7069 With a pretty-printer for `std::string' only the contents are 7070 printed: 7071 7072 (gdb) print s 7073 $2 = "abcd" 7074 7075 7076 File: gdb.info, Node: Pretty-Printer Commands, Prev: Pretty-Printer Example, Up: Pretty Printing 7077 7078 10.9.3 Pretty-Printer Commands 7079 ------------------------------ 7080 7081 `info pretty-printer [OBJECT-REGEXP [NAME-REGEXP]]' 7082 Print the list of installed pretty-printers. This includes 7083 disabled pretty-printers, which are marked as such. 7084 7085 OBJECT-REGEXP is a regular expression matching the objects whose 7086 pretty-printers to list. Objects can be `global', the program 7087 space's file (*note Progspaces In Python::), and the object files 7088 within that program space (*note Objfiles In Python::). *Note 7089 Selecting Pretty-Printers::, for details on how GDB looks up a 7090 printer from these three objects. 7091 7092 NAME-REGEXP is a regular expression matching the name of the 7093 printers to list. 7094 7095 `disable pretty-printer [OBJECT-REGEXP [NAME-REGEXP]]' 7096 Disable pretty-printers matching OBJECT-REGEXP and NAME-REGEXP. A 7097 disabled pretty-printer is not forgotten, it may be enabled again 7098 later. 7099 7100 `enable pretty-printer [OBJECT-REGEXP [NAME-REGEXP]]' 7101 Enable pretty-printers matching OBJECT-REGEXP and NAME-REGEXP. 7102 7103 Example: 7104 7105 Suppose we have three pretty-printers installed: one from library1.so 7106 named `foo' that prints objects of type `foo', and another from 7107 library2.so named `bar' that prints two types of objects, `bar1' and 7108 `bar2'. 7109 7110 (gdb) info pretty-printer 7111 library1.so: 7112 foo 7113 library2.so: 7114 bar 7115 bar1 7116 bar2 7117 (gdb) info pretty-printer library2 7118 library2.so: 7119 bar 7120 bar1 7121 bar2 7122 (gdb) disable pretty-printer library1 7123 1 printer disabled 7124 2 of 3 printers enabled 7125 (gdb) info pretty-printer 7126 library1.so: 7127 foo [disabled] 7128 library2.so: 7129 bar 7130 bar1 7131 bar2 7132 (gdb) disable pretty-printer library2 bar:bar1 7133 1 printer disabled 7134 1 of 3 printers enabled 7135 (gdb) info pretty-printer library2 7136 library1.so: 7137 foo [disabled] 7138 library2.so: 7139 bar 7140 bar1 [disabled] 7141 bar2 7142 (gdb) disable pretty-printer library2 bar 7143 1 printer disabled 7144 0 of 3 printers enabled 7145 (gdb) info pretty-printer library2 7146 library1.so: 7147 foo [disabled] 7148 library2.so: 7149 bar [disabled] 7150 bar1 [disabled] 7151 bar2 7152 7153 Note that for `bar' the entire printer can be disabled, as can each 7154 individual subprinter. 7155 7156 7157 File: gdb.info, Node: Value History, Next: Convenience Vars, Prev: Pretty Printing, Up: Data 7158 7159 10.10 Value History 7160 =================== 7161 7162 Values printed by the `print' command are saved in the GDB "value 7163 history". This allows you to refer to them in other expressions. 7164 Values are kept until the symbol table is re-read or discarded (for 7165 example with the `file' or `symbol-file' commands). When the symbol 7166 table changes, the value history is discarded, since the values may 7167 contain pointers back to the types defined in the symbol table. 7168 7169 The values printed are given "history numbers" by which you can 7170 refer to them. These are successive integers starting with one. 7171 `print' shows you the history number assigned to a value by printing 7172 `$NUM = ' before the value; here NUM is the history number. 7173 7174 To refer to any previous value, use `$' followed by the value's 7175 history number. The way `print' labels its output is designed to 7176 remind you of this. Just `$' refers to the most recent value in the 7177 history, and `$$' refers to the value before that. `$$N' refers to the 7178 Nth value from the end; `$$2' is the value just prior to `$$', `$$1' is 7179 equivalent to `$$', and `$$0' is equivalent to `$'. 7180 7181 For example, suppose you have just printed a pointer to a structure 7182 and want to see the contents of the structure. It suffices to type 7183 7184 p *$ 7185 7186 If you have a chain of structures where the component `next' points 7187 to the next one, you can print the contents of the next one with this: 7188 7189 p *$.next 7190 7191 You can print successive links in the chain by repeating this 7192 command--which you can do by just typing <RET>. 7193 7194 Note that the history records values, not expressions. If the value 7195 of `x' is 4 and you type these commands: 7196 7197 print x 7198 set x=5 7199 7200 then the value recorded in the value history by the `print' command 7201 remains 4 even though the value of `x' has changed. 7202 7203 `show values' 7204 Print the last ten values in the value history, with their item 7205 numbers. This is like `p $$9' repeated ten times, except that 7206 `show values' does not change the history. 7207 7208 `show values N' 7209 Print ten history values centered on history item number N. 7210 7211 `show values +' 7212 Print ten history values just after the values last printed. If 7213 no more values are available, `show values +' produces no display. 7214 7215 Pressing <RET> to repeat `show values N' has exactly the same effect 7216 as `show values +'. 7217 7218 7219 File: gdb.info, Node: Convenience Vars, Next: Registers, Prev: Value History, Up: Data 7220 7221 10.11 Convenience Variables 7222 =========================== 7223 7224 GDB provides "convenience variables" that you can use within GDB to 7225 hold on to a value and refer to it later. These variables exist 7226 entirely within GDB; they are not part of your program, and setting a 7227 convenience variable has no direct effect on further execution of your 7228 program. That is why you can use them freely. 7229 7230 Convenience variables are prefixed with `$'. Any name preceded by 7231 `$' can be used for a convenience variable, unless it is one of the 7232 predefined machine-specific register names (*note Registers: 7233 Registers.). (Value history references, in contrast, are _numbers_ 7234 preceded by `$'. *Note Value History: Value History.) 7235 7236 You can save a value in a convenience variable with an assignment 7237 expression, just as you would set a variable in your program. For 7238 example: 7239 7240 set $foo = *object_ptr 7241 7242 would save in `$foo' the value contained in the object pointed to by 7243 `object_ptr'. 7244 7245 Using a convenience variable for the first time creates it, but its 7246 value is `void' until you assign a new value. You can alter the value 7247 with another assignment at any time. 7248 7249 Convenience variables have no fixed types. You can assign a 7250 convenience variable any type of value, including structures and 7251 arrays, even if that variable already has a value of a different type. 7252 The convenience variable, when used as an expression, has the type of 7253 its current value. 7254 7255 `show convenience' 7256 Print a list of convenience variables used so far, and their 7257 values. Abbreviated `show conv'. 7258 7259 `init-if-undefined $VARIABLE = EXPRESSION' 7260 Set a convenience variable if it has not already been set. This 7261 is useful for user-defined commands that keep some state. It is 7262 similar, in concept, to using local static variables with 7263 initializers in C (except that convenience variables are global). 7264 It can also be used to allow users to override default values used 7265 in a command script. 7266 7267 If the variable is already defined then the expression is not 7268 evaluated so any side-effects do not occur. 7269 7270 One of the ways to use a convenience variable is as a counter to be 7271 incremented or a pointer to be advanced. For example, to print a field 7272 from successive elements of an array of structures: 7273 7274 set $i = 0 7275 print bar[$i++]->contents 7276 7277 Repeat that command by typing <RET>. 7278 7279 Some convenience variables are created automatically by GDB and given 7280 values likely to be useful. 7281 7282 `$_' 7283 The variable `$_' is automatically set by the `x' command to the 7284 last address examined (*note Examining Memory: Memory.). Other 7285 commands which provide a default address for `x' to examine also 7286 set `$_' to that address; these commands include `info line' and 7287 `info breakpoint'. The type of `$_' is `void *' except when set 7288 by the `x' command, in which case it is a pointer to the type of 7289 `$__'. 7290 7291 `$__' 7292 The variable `$__' is automatically set by the `x' command to the 7293 value found in the last address examined. Its type is chosen to 7294 match the format in which the data was printed. 7295 7296 `$_exitcode' 7297 The variable `$_exitcode' is automatically set to the exit code 7298 when the program being debugged terminates. 7299 7300 `$_sdata' 7301 The variable `$_sdata' contains extra collected static tracepoint 7302 data. *Note Tracepoint Action Lists: Tracepoint Actions. Note 7303 that `$_sdata' could be empty, if not inspecting a trace buffer, or 7304 if extra static tracepoint data has not been collected. 7305 7306 `$_siginfo' 7307 The variable `$_siginfo' contains extra signal information (*note 7308 extra signal information::). Note that `$_siginfo' could be 7309 empty, if the application has not yet received any signals. For 7310 example, it will be empty before you execute the `run' command. 7311 7312 `$_tlb' 7313 The variable `$_tlb' is automatically set when debugging 7314 applications running on MS-Windows in native mode or connected to 7315 gdbserver that supports the `qGetTIBAddr' request. *Note General 7316 Query Packets::. This variable contains the address of the thread 7317 information block. 7318 7319 7320 On HP-UX systems, if you refer to a function or variable name that 7321 begins with a dollar sign, GDB searches for a user or system name 7322 first, before it searches for a convenience variable. 7323 7324 GDB also supplies some "convenience functions". These have a syntax 7325 similar to convenience variables. A convenience function can be used 7326 in an expression just like an ordinary function; however, a convenience 7327 function is implemented internally to GDB. 7328 7329 `help function' 7330 Print a list of all convenience functions. 7331 7332 7333 File: gdb.info, Node: Registers, Next: Floating Point Hardware, Prev: Convenience Vars, Up: Data 7334 7335 10.12 Registers 7336 =============== 7337 7338 You can refer to machine register contents, in expressions, as variables 7339 with names starting with `$'. The names of registers are different for 7340 each machine; use `info registers' to see the names used on your 7341 machine. 7342 7343 `info registers' 7344 Print the names and values of all registers except floating-point 7345 and vector registers (in the selected stack frame). 7346 7347 `info all-registers' 7348 Print the names and values of all registers, including 7349 floating-point and vector registers (in the selected stack frame). 7350 7351 `info registers REGNAME ...' 7352 Print the "relativized" value of each specified register REGNAME. 7353 As discussed in detail below, register values are normally 7354 relative to the selected stack frame. REGNAME may be any register 7355 name valid on the machine you are using, with or without the 7356 initial `$'. 7357 7358 GDB has four "standard" register names that are available (in 7359 expressions) on most machines--whenever they do not conflict with an 7360 architecture's canonical mnemonics for registers. The register names 7361 `$pc' and `$sp' are used for the program counter register and the stack 7362 pointer. `$fp' is used for a register that contains a pointer to the 7363 current stack frame, and `$ps' is used for a register that contains the 7364 processor status. For example, you could print the program counter in 7365 hex with 7366 7367 p/x $pc 7368 7369 or print the instruction to be executed next with 7370 7371 x/i $pc 7372 7373 or add four to the stack pointer(1) with 7374 7375 set $sp += 4 7376 7377 Whenever possible, these four standard register names are available 7378 on your machine even though the machine has different canonical 7379 mnemonics, so long as there is no conflict. The `info registers' 7380 command shows the canonical names. For example, on the SPARC, `info 7381 registers' displays the processor status register as `$psr' but you can 7382 also refer to it as `$ps'; and on x86-based machines `$ps' is an alias 7383 for the EFLAGS register. 7384 7385 GDB always considers the contents of an ordinary register as an 7386 integer when the register is examined in this way. Some machines have 7387 special registers which can hold nothing but floating point; these 7388 registers are considered to have floating point values. There is no way 7389 to refer to the contents of an ordinary register as floating point value 7390 (although you can _print_ it as a floating point value with `print/f 7391 $REGNAME'). 7392 7393 Some registers have distinct "raw" and "virtual" data formats. This 7394 means that the data format in which the register contents are saved by 7395 the operating system is not the same one that your program normally 7396 sees. For example, the registers of the 68881 floating point 7397 coprocessor are always saved in "extended" (raw) format, but all C 7398 programs expect to work with "double" (virtual) format. In such cases, 7399 GDB normally works with the virtual format only (the format that makes 7400 sense for your program), but the `info registers' command prints the 7401 data in both formats. 7402 7403 Some machines have special registers whose contents can be 7404 interpreted in several different ways. For example, modern x86-based 7405 machines have SSE and MMX registers that can hold several values packed 7406 together in several different formats. GDB refers to such registers in 7407 `struct' notation: 7408 7409 (gdb) print $xmm1 7410 $1 = { 7411 v4_float = {0, 3.43859137e-038, 1.54142831e-044, 1.821688e-044}, 7412 v2_double = {9.92129282474342e-303, 2.7585945287983262e-313}, 7413 v16_int8 = "\000\000\000\000\3706;\001\v\000\000\000\r\000\000", 7414 v8_int16 = {0, 0, 14072, 315, 11, 0, 13, 0}, 7415 v4_int32 = {0, 20657912, 11, 13}, 7416 v2_int64 = {88725056443645952, 55834574859}, 7417 uint128 = 0x0000000d0000000b013b36f800000000 7418 } 7419 7420 To set values of such registers, you need to tell GDB which view of the 7421 register you wish to change, as if you were assigning value to a 7422 `struct' member: 7423 7424 (gdb) set $xmm1.uint128 = 0x000000000000000000000000FFFFFFFF 7425 7426 Normally, register values are relative to the selected stack frame 7427 (*note Selecting a Frame: Selection.). This means that you get the 7428 value that the register would contain if all stack frames farther in 7429 were exited and their saved registers restored. In order to see the 7430 true contents of hardware registers, you must select the innermost 7431 frame (with `frame 0'). 7432 7433 However, GDB must deduce where registers are saved, from the machine 7434 code generated by your compiler. If some registers are not saved, or if 7435 GDB is unable to locate the saved registers, the selected stack frame 7436 makes no difference. 7437 7438 ---------- Footnotes ---------- 7439 7440 (1) This is a way of removing one word from the stack, on machines 7441 where stacks grow downward in memory (most machines, nowadays). This 7442 assumes that the innermost stack frame is selected; setting `$sp' is 7443 not allowed when other stack frames are selected. To pop entire frames 7444 off the stack, regardless of machine architecture, use `return'; see 7445 *note Returning from a Function: Returning. 7446 7447 7448 File: gdb.info, Node: Floating Point Hardware, Next: Vector Unit, Prev: Registers, Up: Data 7449 7450 10.13 Floating Point Hardware 7451 ============================= 7452 7453 Depending on the configuration, GDB may be able to give you more 7454 information about the status of the floating point hardware. 7455 7456 `info float' 7457 Display hardware-dependent information about the floating point 7458 unit. The exact contents and layout vary depending on the 7459 floating point chip. Currently, `info float' is supported on the 7460 ARM and x86 machines. 7461 7462 7463 File: gdb.info, Node: Vector Unit, Next: OS Information, Prev: Floating Point Hardware, Up: Data 7464 7465 10.14 Vector Unit 7466 ================= 7467 7468 Depending on the configuration, GDB may be able to give you more 7469 information about the status of the vector unit. 7470 7471 `info vector' 7472 Display information about the vector unit. The exact contents and 7473 layout vary depending on the hardware. 7474 7475 7476 File: gdb.info, Node: OS Information, Next: Memory Region Attributes, Prev: Vector Unit, Up: Data 7477 7478 10.15 Operating System Auxiliary Information 7479 ============================================ 7480 7481 GDB provides interfaces to useful OS facilities that can help you debug 7482 your program. 7483 7484 When GDB runs on a "Posix system" (such as GNU or Unix machines), it 7485 interfaces with the inferior via the `ptrace' system call. The 7486 operating system creates a special sata structure, called `struct 7487 user', for this interface. You can use the command `info udot' to 7488 display the contents of this data structure. 7489 7490 `info udot' 7491 Display the contents of the `struct user' maintained by the OS 7492 kernel for the program being debugged. GDB displays the contents 7493 of `struct user' as a list of hex numbers, similar to the 7494 `examine' command. 7495 7496 Some operating systems supply an "auxiliary vector" to programs at 7497 startup. This is akin to the arguments and environment that you 7498 specify for a program, but contains a system-dependent variety of 7499 binary values that tell system libraries important details about the 7500 hardware, operating system, and process. Each value's purpose is 7501 identified by an integer tag; the meanings are well-known but 7502 system-specific. Depending on the configuration and operating system 7503 facilities, GDB may be able to show you this information. For remote 7504 targets, this functionality may further depend on the remote stub's 7505 support of the `qXfer:auxv:read' packet, see *note qXfer auxiliary 7506 vector read::. 7507 7508 `info auxv' 7509 Display the auxiliary vector of the inferior, which can be either a 7510 live process or a core dump file. GDB prints each tag value 7511 numerically, and also shows names and text descriptions for 7512 recognized tags. Some values in the vector are numbers, some bit 7513 masks, and some pointers to strings or other data. GDB displays 7514 each value in the most appropriate form for a recognized tag, and 7515 in hexadecimal for an unrecognized tag. 7516 7517 On some targets, GDB can access operating-system-specific information 7518 and display it to user, without interpretation. For remote targets, 7519 this functionality depends on the remote stub's support of the 7520 `qXfer:osdata:read' packet, see *note qXfer osdata read::. 7521 7522 `info os' 7523 List the types of OS information available for the target. If the 7524 target does not return a list of possible types, this command will 7525 report an error. 7526 7527 `info os processes' 7528 Display the list of processes on the target. For each process, 7529 GDB prints the process identifier, the name of the user, and the 7530 command corresponding to the process. 7531 7532 7533 File: gdb.info, Node: Memory Region Attributes, Next: Dump/Restore Files, Prev: OS Information, Up: Data 7534 7535 10.16 Memory Region Attributes 7536 ============================== 7537 7538 "Memory region attributes" allow you to describe special handling 7539 required by regions of your target's memory. GDB uses attributes to 7540 determine whether to allow certain types of memory accesses; whether to 7541 use specific width accesses; and whether to cache target memory. By 7542 default the description of memory regions is fetched from the target 7543 (if the current target supports this), but the user can override the 7544 fetched regions. 7545 7546 Defined memory regions can be individually enabled and disabled. 7547 When a memory region is disabled, GDB uses the default attributes when 7548 accessing memory in that region. Similarly, if no memory regions have 7549 been defined, GDB uses the default attributes when accessing all memory. 7550 7551 When a memory region is defined, it is given a number to identify it; 7552 to enable, disable, or remove a memory region, you specify that number. 7553 7554 `mem LOWER UPPER ATTRIBUTES...' 7555 Define a memory region bounded by LOWER and UPPER with attributes 7556 ATTRIBUTES..., and add it to the list of regions monitored by GDB. 7557 Note that UPPER == 0 is a special case: it is treated as the 7558 target's maximum memory address. (0xffff on 16 bit targets, 7559 0xffffffff on 32 bit targets, etc.) 7560 7561 `mem auto' 7562 Discard any user changes to the memory regions and use 7563 target-supplied regions, if available, or no regions if the target 7564 does not support. 7565 7566 `delete mem NUMS...' 7567 Remove memory regions NUMS... from the list of regions monitored 7568 by GDB. 7569 7570 `disable mem NUMS...' 7571 Disable monitoring of memory regions NUMS.... A disabled memory 7572 region is not forgotten. It may be enabled again later. 7573 7574 `enable mem NUMS...' 7575 Enable monitoring of memory regions NUMS.... 7576 7577 `info mem' 7578 Print a table of all defined memory regions, with the following 7579 columns for each region: 7580 7581 _Memory Region Number_ 7582 7583 _Enabled or Disabled._ 7584 Enabled memory regions are marked with `y'. Disabled memory 7585 regions are marked with `n'. 7586 7587 _Lo Address_ 7588 The address defining the inclusive lower bound of the memory 7589 region. 7590 7591 _Hi Address_ 7592 The address defining the exclusive upper bound of the memory 7593 region. 7594 7595 _Attributes_ 7596 The list of attributes set for this memory region. 7597 7598 10.16.1 Attributes 7599 ------------------ 7600 7601 10.16.1.1 Memory Access Mode 7602 ............................ 7603 7604 The access mode attributes set whether GDB may make read or write 7605 accesses to a memory region. 7606 7607 While these attributes prevent GDB from performing invalid memory 7608 accesses, they do nothing to prevent the target system, I/O DMA, etc. 7609 from accessing memory. 7610 7611 `ro' 7612 Memory is read only. 7613 7614 `wo' 7615 Memory is write only. 7616 7617 `rw' 7618 Memory is read/write. This is the default. 7619 7620 10.16.1.2 Memory Access Size 7621 ............................ 7622 7623 The access size attribute tells GDB to use specific sized accesses in 7624 the memory region. Often memory mapped device registers require 7625 specific sized accesses. If no access size attribute is specified, GDB 7626 may use accesses of any size. 7627 7628 `8' 7629 Use 8 bit memory accesses. 7630 7631 `16' 7632 Use 16 bit memory accesses. 7633 7634 `32' 7635 Use 32 bit memory accesses. 7636 7637 `64' 7638 Use 64 bit memory accesses. 7639 7640 10.16.1.3 Data Cache 7641 .................... 7642 7643 The data cache attributes set whether GDB will cache target memory. 7644 While this generally improves performance by reducing debug protocol 7645 overhead, it can lead to incorrect results because GDB does not know 7646 about volatile variables or memory mapped device registers. 7647 7648 `cache' 7649 Enable GDB to cache target memory. 7650 7651 `nocache' 7652 Disable GDB from caching target memory. This is the default. 7653 7654 10.16.2 Memory Access Checking 7655 ------------------------------ 7656 7657 GDB can be instructed to refuse accesses to memory that is not 7658 explicitly described. This can be useful if accessing such regions has 7659 undesired effects for a specific target, or to provide better error 7660 checking. The following commands control this behaviour. 7661 7662 `set mem inaccessible-by-default [on|off]' 7663 If `on' is specified, make GDB treat memory not explicitly 7664 described by the memory ranges as non-existent and refuse accesses 7665 to such memory. The checks are only performed if there's at least 7666 one memory range defined. If `off' is specified, make GDB treat 7667 the memory not explicitly described by the memory ranges as RAM. 7668 The default value is `on'. 7669 7670 `show mem inaccessible-by-default' 7671 Show the current handling of accesses to unknown memory. 7672 7673 7674 File: gdb.info, Node: Dump/Restore Files, Next: Core File Generation, Prev: Memory Region Attributes, Up: Data 7675 7676 10.17 Copy Between Memory and a File 7677 ==================================== 7678 7679 You can use the commands `dump', `append', and `restore' to copy data 7680 between target memory and a file. The `dump' and `append' commands 7681 write data to a file, and the `restore' command reads data from a file 7682 back into the inferior's memory. Files may be in binary, Motorola 7683 S-record, Intel hex, or Tektronix Hex format; however, GDB can only 7684 append to binary files. 7685 7686 `dump [FORMAT] memory FILENAME START_ADDR END_ADDR' 7687 `dump [FORMAT] value FILENAME EXPR' 7688 Dump the contents of memory from START_ADDR to END_ADDR, or the 7689 value of EXPR, to FILENAME in the given format. 7690 7691 The FORMAT parameter may be any one of: 7692 `binary' 7693 Raw binary form. 7694 7695 `ihex' 7696 Intel hex format. 7697 7698 `srec' 7699 Motorola S-record format. 7700 7701 `tekhex' 7702 Tektronix Hex format. 7703 7704 GDB uses the same definitions of these formats as the GNU binary 7705 utilities, like `objdump' and `objcopy'. If FORMAT is omitted, 7706 GDB dumps the data in raw binary form. 7707 7708 `append [binary] memory FILENAME START_ADDR END_ADDR' 7709 `append [binary] value FILENAME EXPR' 7710 Append the contents of memory from START_ADDR to END_ADDR, or the 7711 value of EXPR, to the file FILENAME, in raw binary form. (GDB can 7712 only append data to files in raw binary form.) 7713 7714 `restore FILENAME [binary] BIAS START END' 7715 Restore the contents of file FILENAME into memory. The `restore' 7716 command can automatically recognize any known BFD file format, 7717 except for raw binary. To restore a raw binary file you must 7718 specify the optional keyword `binary' after the filename. 7719 7720 If BIAS is non-zero, its value will be added to the addresses 7721 contained in the file. Binary files always start at address zero, 7722 so they will be restored at address BIAS. Other bfd files have a 7723 built-in location; they will be restored at offset BIAS from that 7724 location. 7725 7726 If START and/or END are non-zero, then only data between file 7727 offset START and file offset END will be restored. These offsets 7728 are relative to the addresses in the file, before the BIAS 7729 argument is applied. 7730 7731 7732 7733 File: gdb.info, Node: Core File Generation, Next: Character Sets, Prev: Dump/Restore Files, Up: Data 7734 7735 10.18 How to Produce a Core File from Your Program 7736 ================================================== 7737 7738 A "core file" or "core dump" is a file that records the memory image of 7739 a running process and its process status (register values etc.). Its 7740 primary use is post-mortem debugging of a program that crashed while it 7741 ran outside a debugger. A program that crashes automatically produces 7742 a core file, unless this feature is disabled by the user. *Note 7743 Files::, for information on invoking GDB in the post-mortem debugging 7744 mode. 7745 7746 Occasionally, you may wish to produce a core file of the program you 7747 are debugging in order to preserve a snapshot of its state. GDB has a 7748 special command for that. 7749 7750 `generate-core-file [FILE]' 7751 `gcore [FILE]' 7752 Produce a core dump of the inferior process. The optional argument 7753 FILE specifies the file name where to put the core dump. If not 7754 specified, the file name defaults to `core.PID', where PID is the 7755 inferior process ID. 7756 7757 Note that this command is implemented only for some systems (as of 7758 this writing, GNU/Linux, FreeBSD, Solaris, Unixware, and S390). 7759 7760 7761 File: gdb.info, Node: Character Sets, Next: Caching Remote Data, Prev: Core File Generation, Up: Data 7762 7763 10.19 Character Sets 7764 ==================== 7765 7766 If the program you are debugging uses a different character set to 7767 represent characters and strings than the one GDB uses itself, GDB can 7768 automatically translate between the character sets for you. The 7769 character set GDB uses we call the "host character set"; the one the 7770 inferior program uses we call the "target character set". 7771 7772 For example, if you are running GDB on a GNU/Linux system, which 7773 uses the ISO Latin 1 character set, but you are using GDB's remote 7774 protocol (*note Remote Debugging::) to debug a program running on an 7775 IBM mainframe, which uses the EBCDIC character set, then the host 7776 character set is Latin-1, and the target character set is EBCDIC. If 7777 you give GDB the command `set target-charset EBCDIC-US', then GDB 7778 translates between EBCDIC and Latin 1 as you print character or string 7779 values, or use character and string literals in expressions. 7780 7781 GDB has no way to automatically recognize which character set the 7782 inferior program uses; you must tell it, using the `set target-charset' 7783 command, described below. 7784 7785 Here are the commands for controlling GDB's character set support: 7786 7787 `set target-charset CHARSET' 7788 Set the current target character set to CHARSET. To display the 7789 list of supported target character sets, type 7790 `set target-charset <TAB><TAB>'. 7791 7792 `set host-charset CHARSET' 7793 Set the current host character set to CHARSET. 7794 7795 By default, GDB uses a host character set appropriate to the 7796 system it is running on; you can override that default using the 7797 `set host-charset' command. On some systems, GDB cannot 7798 automatically determine the appropriate host character set. In 7799 this case, GDB uses `UTF-8'. 7800 7801 GDB can only use certain character sets as its host character set. 7802 If you type `set host-charset <TAB><TAB>', GDB will list the host 7803 character sets it supports. 7804 7805 `set charset CHARSET' 7806 Set the current host and target character sets to CHARSET. As 7807 above, if you type `set charset <TAB><TAB>', GDB will list the 7808 names of the character sets that can be used for both host and 7809 target. 7810 7811 `show charset' 7812 Show the names of the current host and target character sets. 7813 7814 `show host-charset' 7815 Show the name of the current host character set. 7816 7817 `show target-charset' 7818 Show the name of the current target character set. 7819 7820 `set target-wide-charset CHARSET' 7821 Set the current target's wide character set to CHARSET. This is 7822 the character set used by the target's `wchar_t' type. To display 7823 the list of supported wide character sets, type 7824 `set target-wide-charset <TAB><TAB>'. 7825 7826 `show target-wide-charset' 7827 Show the name of the current target's wide character set. 7828 7829 Here is an example of GDB's character set support in action. Assume 7830 that the following source code has been placed in the file 7831 `charset-test.c': 7832 7833 #include <stdio.h> 7834 7835 char ascii_hello[] 7836 = {72, 101, 108, 108, 111, 44, 32, 119, 7837 111, 114, 108, 100, 33, 10, 0}; 7838 char ibm1047_hello[] 7839 = {200, 133, 147, 147, 150, 107, 64, 166, 7840 150, 153, 147, 132, 90, 37, 0}; 7841 7842 main () 7843 { 7844 printf ("Hello, world!\n"); 7845 } 7846 7847 In this program, `ascii_hello' and `ibm1047_hello' are arrays 7848 containing the string `Hello, world!' followed by a newline, encoded in 7849 the ASCII and IBM1047 character sets. 7850 7851 We compile the program, and invoke the debugger on it: 7852 7853 $ gcc -g charset-test.c -o charset-test 7854 $ gdb -nw charset-test 7855 GNU gdb 2001-12-19-cvs 7856 Copyright 2001 Free Software Foundation, Inc. 7857 ... 7858 (gdb) 7859 7860 We can use the `show charset' command to see what character sets GDB 7861 is currently using to interpret and display characters and strings: 7862 7863 (gdb) show charset 7864 The current host and target character set is `ISO-8859-1'. 7865 (gdb) 7866 7867 For the sake of printing this manual, let's use ASCII as our initial 7868 character set: 7869 (gdb) set charset ASCII 7870 (gdb) show charset 7871 The current host and target character set is `ASCII'. 7872 (gdb) 7873 7874 Let's assume that ASCII is indeed the correct character set for our 7875 host system -- in other words, let's assume that if GDB prints 7876 characters using the ASCII character set, our terminal will display 7877 them properly. Since our current target character set is also ASCII, 7878 the contents of `ascii_hello' print legibly: 7879 7880 (gdb) print ascii_hello 7881 $1 = 0x401698 "Hello, world!\n" 7882 (gdb) print ascii_hello[0] 7883 $2 = 72 'H' 7884 (gdb) 7885 7886 GDB uses the target character set for character and string literals 7887 you use in expressions: 7888 7889 (gdb) print '+' 7890 $3 = 43 '+' 7891 (gdb) 7892 7893 The ASCII character set uses the number 43 to encode the `+' 7894 character. 7895 7896 GDB relies on the user to tell it which character set the target 7897 program uses. If we print `ibm1047_hello' while our target character 7898 set is still ASCII, we get jibberish: 7899 7900 (gdb) print ibm1047_hello 7901 $4 = 0x4016a8 "\310\205\223\223\226k@\246\226\231\223\204Z%" 7902 (gdb) print ibm1047_hello[0] 7903 $5 = 200 '\310' 7904 (gdb) 7905 7906 If we invoke the `set target-charset' followed by <TAB><TAB>, GDB 7907 tells us the character sets it supports: 7908 7909 (gdb) set target-charset 7910 ASCII EBCDIC-US IBM1047 ISO-8859-1 7911 (gdb) set target-charset 7912 7913 We can select IBM1047 as our target character set, and examine the 7914 program's strings again. Now the ASCII string is wrong, but GDB 7915 translates the contents of `ibm1047_hello' from the target character 7916 set, IBM1047, to the host character set, ASCII, and they display 7917 correctly: 7918 7919 (gdb) set target-charset IBM1047 7920 (gdb) show charset 7921 The current host character set is `ASCII'. 7922 The current target character set is `IBM1047'. 7923 (gdb) print ascii_hello 7924 $6 = 0x401698 "\110\145%%?\054\040\167?\162%\144\041\012" 7925 (gdb) print ascii_hello[0] 7926 $7 = 72 '\110' 7927 (gdb) print ibm1047_hello 7928 $8 = 0x4016a8 "Hello, world!\n" 7929 (gdb) print ibm1047_hello[0] 7930 $9 = 200 'H' 7931 (gdb) 7932 7933 As above, GDB uses the target character set for character and string 7934 literals you use in expressions: 7935 7936 (gdb) print '+' 7937 $10 = 78 '+' 7938 (gdb) 7939 7940 The IBM1047 character set uses the number 78 to encode the `+' 7941 character. 7942 7943 7944 File: gdb.info, Node: Caching Remote Data, Next: Searching Memory, Prev: Character Sets, Up: Data 7945 7946 10.20 Caching Data of Remote Targets 7947 ==================================== 7948 7949 GDB caches data exchanged between the debugger and a remote target 7950 (*note Remote Debugging::). Such caching generally improves 7951 performance, because it reduces the overhead of the remote protocol by 7952 bundling memory reads and writes into large chunks. Unfortunately, 7953 simply caching everything would lead to incorrect results, since GDB 7954 does not necessarily know anything about volatile values, memory-mapped 7955 I/O addresses, etc. Furthermore, in non-stop mode (*note Non-Stop 7956 Mode::) memory can be changed _while_ a gdb command is executing. 7957 Therefore, by default, GDB only caches data known to be on the stack(1). 7958 Other regions of memory can be explicitly marked as cacheable; see 7959 *note Memory Region Attributes::. 7960 7961 `set remotecache on' 7962 `set remotecache off' 7963 This option no longer does anything; it exists for compatibility 7964 with old scripts. 7965 7966 `show remotecache' 7967 Show the current state of the obsolete remotecache flag. 7968 7969 `set stack-cache on' 7970 `set stack-cache off' 7971 Enable or disable caching of stack accesses. When `ON', use 7972 caching. By default, this option is `ON'. 7973 7974 `show stack-cache' 7975 Show the current state of data caching for memory accesses. 7976 7977 `info dcache [line]' 7978 Print the information about the data cache performance. The 7979 information displayed includes the dcache width and depth, and for 7980 each cache line, its number, address, and how many times it was 7981 referenced. This command is useful for debugging the data cache 7982 operation. 7983 7984 If a line number is specified, the contents of that line will be 7985 printed in hex. 7986 7987 `set dcache size SIZE' 7988 Set maximum number of entries in dcache (dcache depth above). 7989 7990 `set dcache line-size LINE-SIZE' 7991 Set number of bytes each dcache entry caches (dcache width above). 7992 Must be a power of 2. 7993 7994 `show dcache size' 7995 Show maximum number of dcache entries. See also *note info 7996 dcache: Caching Remote Data. 7997 7998 `show dcache line-size' 7999 Show default size of dcache lines. See also *note info dcache: 8000 Caching Remote Data. 8001 8002 8003 ---------- Footnotes ---------- 8004 8005 (1) In non-stop mode, it is moderately rare for a running thread to 8006 modify the stack of a stopped thread in a way that would interfere with 8007 a backtrace, and caching of stack reads provides a significant speed up 8008 of remote backtraces. 8009 8010 8011 File: gdb.info, Node: Searching Memory, Prev: Caching Remote Data, Up: Data 8012 8013 10.21 Search Memory 8014 =================== 8015 8016 Memory can be searched for a particular sequence of bytes with the 8017 `find' command. 8018 8019 `find [/SN] START_ADDR, +LEN, VAL1 [, VAL2, ...]' 8020 `find [/SN] START_ADDR, END_ADDR, VAL1 [, VAL2, ...]' 8021 Search memory for the sequence of bytes specified by VAL1, VAL2, 8022 etc. The search begins at address START_ADDR and continues for 8023 either LEN bytes or through to END_ADDR inclusive. 8024 8025 S and N are optional parameters. They may be specified in either 8026 order, apart or together. 8027 8028 S, search query size 8029 The size of each search query value. 8030 8031 `b' 8032 bytes 8033 8034 `h' 8035 halfwords (two bytes) 8036 8037 `w' 8038 words (four bytes) 8039 8040 `g' 8041 giant words (eight bytes) 8042 8043 All values are interpreted in the current language. This means, 8044 for example, that if the current source language is C/C++ then 8045 searching for the string "hello" includes the trailing '\0'. 8046 8047 If the value size is not specified, it is taken from the value's 8048 type in the current language. This is useful when one wants to 8049 specify the search pattern as a mixture of types. Note that this 8050 means, for example, that in the case of C-like languages a search 8051 for an untyped 0x42 will search for `(int) 0x42' which is 8052 typically four bytes. 8053 8054 N, maximum number of finds 8055 The maximum number of matches to print. The default is to print 8056 all finds. 8057 8058 You can use strings as search values. Quote them with double-quotes 8059 (`"'). The string value is copied into the search pattern byte by byte, 8060 regardless of the endianness of the target and the size specification. 8061 8062 The address of each match found is printed as well as a count of the 8063 number of matches found. 8064 8065 The address of the last value found is stored in convenience variable 8066 `$_'. A count of the number of matches is stored in `$numfound'. 8067 8068 For example, if stopped at the `printf' in this function: 8069 8070 void 8071 hello () 8072 { 8073 static char hello[] = "hello-hello"; 8074 static struct { char c; short s; int i; } 8075 __attribute__ ((packed)) mixed 8076 = { 'c', 0x1234, 0x87654321 }; 8077 printf ("%s\n", hello); 8078 } 8079 8080 you get during debugging: 8081 8082 (gdb) find &hello[0], +sizeof(hello), "hello" 8083 0x804956d <hello.1620+6> 8084 1 pattern found 8085 (gdb) find &hello[0], +sizeof(hello), 'h', 'e', 'l', 'l', 'o' 8086 0x8049567 <hello.1620> 8087 0x804956d <hello.1620+6> 8088 2 patterns found 8089 (gdb) find /b1 &hello[0], +sizeof(hello), 'h', 0x65, 'l' 8090 0x8049567 <hello.1620> 8091 1 pattern found 8092 (gdb) find &mixed, +sizeof(mixed), (char) 'c', (short) 0x1234, (int) 0x87654321 8093 0x8049560 <mixed.1625> 8094 1 pattern found 8095 (gdb) print $numfound 8096 $1 = 1 8097 (gdb) print $_ 8098 $2 = (void *) 0x8049560 8099 8100 8101 File: gdb.info, Node: Optimized Code, Next: Macros, Prev: Data, Up: Top 8102 8103 11 Debugging Optimized Code 8104 *************************** 8105 8106 Almost all compilers support optimization. With optimization disabled, 8107 the compiler generates assembly code that corresponds directly to your 8108 source code, in a simplistic way. As the compiler applies more 8109 powerful optimizations, the generated assembly code diverges from your 8110 original source code. With help from debugging information generated 8111 by the compiler, GDB can map from the running program back to 8112 constructs from your original source. 8113 8114 GDB is more accurate with optimization disabled. If you can 8115 recompile without optimization, it is easier to follow the progress of 8116 your program during debugging. But, there are many cases where you may 8117 need to debug an optimized version. 8118 8119 When you debug a program compiled with `-g -O', remember that the 8120 optimizer has rearranged your code; the debugger shows you what is 8121 really there. Do not be too surprised when the execution path does not 8122 exactly match your source file! An extreme example: if you define a 8123 variable, but never use it, GDB never sees that variable--because the 8124 compiler optimizes it out of existence. 8125 8126 Some things do not work as well with `-g -O' as with just `-g', 8127 particularly on machines with instruction scheduling. If in doubt, 8128 recompile with `-g' alone, and if this fixes the problem, please report 8129 it to us as a bug (including a test case!). *Note Variables::, for 8130 more information about debugging optimized code. 8131 8132 * Menu: 8133 8134 * Inline Functions:: How GDB presents inlining 8135 8136 8137 File: gdb.info, Node: Inline Functions, Up: Optimized Code 8138 8139 11.1 Inline Functions 8140 ===================== 8141 8142 "Inlining" is an optimization that inserts a copy of the function body 8143 directly at each call site, instead of jumping to a shared routine. 8144 GDB displays inlined functions just like non-inlined functions. They 8145 appear in backtraces. You can view their arguments and local 8146 variables, step into them with `step', skip them with `next', and 8147 escape from them with `finish'. You can check whether a function was 8148 inlined by using the `info frame' command. 8149 8150 For GDB to support inlined functions, the compiler must record 8151 information about inlining in the debug information -- GCC using the 8152 DWARF 2 format does this, and several other compilers do also. GDB 8153 only supports inlined functions when using DWARF 2. Versions of GCC 8154 before 4.1 do not emit two required attributes (`DW_AT_call_file' and 8155 `DW_AT_call_line'); GDB does not display inlined function calls with 8156 earlier versions of GCC. It instead displays the arguments and local 8157 variables of inlined functions as local variables in the caller. 8158 8159 The body of an inlined function is directly included at its call 8160 site; unlike a non-inlined function, there are no instructions devoted 8161 to the call. GDB still pretends that the call site and the start of 8162 the inlined function are different instructions. Stepping to the call 8163 site shows the call site, and then stepping again shows the first line 8164 of the inlined function, even though no additional instructions are 8165 executed. 8166 8167 This makes source-level debugging much clearer; you can see both the 8168 context of the call and then the effect of the call. Only stepping by 8169 a single instruction using `stepi' or `nexti' does not do this; single 8170 instruction steps always show the inlined body. 8171 8172 There are some ways that GDB does not pretend that inlined function 8173 calls are the same as normal calls: 8174 8175 * You cannot set breakpoints on inlined functions. GDB either 8176 reports that there is no symbol with that name, or else sets the 8177 breakpoint only on non-inlined copies of the function. This 8178 limitation will be removed in a future version of GDB; until then, 8179 set a breakpoint by line number on the first line of the inlined 8180 function instead. 8181 8182 * Setting breakpoints at the call site of an inlined function may not 8183 work, because the call site does not contain any code. GDB may 8184 incorrectly move the breakpoint to the next line of the enclosing 8185 function, after the call. This limitation will be removed in a 8186 future version of GDB; until then, set a breakpoint on an earlier 8187 line or inside the inlined function instead. 8188 8189 * GDB cannot locate the return value of inlined calls after using 8190 the `finish' command. This is a limitation of compiler-generated 8191 debugging information; after `finish', you can step to the next 8192 line and print a variable where your program stored the return 8193 value. 8194 8195 8196 8197 File: gdb.info, Node: Macros, Next: Tracepoints, Prev: Optimized Code, Up: Top 8198 8199 12 C Preprocessor Macros 8200 ************************ 8201 8202 Some languages, such as C and C++, provide a way to define and invoke 8203 "preprocessor macros" which expand into strings of tokens. GDB can 8204 evaluate expressions containing macro invocations, show the result of 8205 macro expansion, and show a macro's definition, including where it was 8206 defined. 8207 8208 You may need to compile your program specially to provide GDB with 8209 information about preprocessor macros. Most compilers do not include 8210 macros in their debugging information, even when you compile with the 8211 `-g' flag. *Note Compilation::. 8212 8213 A program may define a macro at one point, remove that definition 8214 later, and then provide a different definition after that. Thus, at 8215 different points in the program, a macro may have different 8216 definitions, or have no definition at all. If there is a current stack 8217 frame, GDB uses the macros in scope at that frame's source code line. 8218 Otherwise, GDB uses the macros in scope at the current listing location; 8219 see *note List::. 8220 8221 Whenever GDB evaluates an expression, it always expands any macro 8222 invocations present in the expression. GDB also provides the following 8223 commands for working with macros explicitly. 8224 8225 `macro expand EXPRESSION' 8226 `macro exp EXPRESSION' 8227 Show the results of expanding all preprocessor macro invocations in 8228 EXPRESSION. Since GDB simply expands macros, but does not parse 8229 the result, EXPRESSION need not be a valid expression; it can be 8230 any string of tokens. 8231 8232 `macro expand-once EXPRESSION' 8233 `macro exp1 EXPRESSION' 8234 (This command is not yet implemented.) Show the results of 8235 expanding those preprocessor macro invocations that appear 8236 explicitly in EXPRESSION. Macro invocations appearing in that 8237 expansion are left unchanged. This command allows you to see the 8238 effect of a particular macro more clearly, without being confused 8239 by further expansions. Since GDB simply expands macros, but does 8240 not parse the result, EXPRESSION need not be a valid expression; it 8241 can be any string of tokens. 8242 8243 `info macro MACRO' 8244 Show the definition of the macro named MACRO, and describe the 8245 source location or compiler command-line where that definition was 8246 established. 8247 8248 `macro define MACRO REPLACEMENT-LIST' 8249 `macro define MACRO(ARGLIST) REPLACEMENT-LIST' 8250 Introduce a definition for a preprocessor macro named MACRO, 8251 invocations of which are replaced by the tokens given in 8252 REPLACEMENT-LIST. The first form of this command defines an 8253 "object-like" macro, which takes no arguments; the second form 8254 defines a "function-like" macro, which takes the arguments given in 8255 ARGLIST. 8256 8257 A definition introduced by this command is in scope in every 8258 expression evaluated in GDB, until it is removed with the `macro 8259 undef' command, described below. The definition overrides all 8260 definitions for MACRO present in the program being debugged, as 8261 well as any previous user-supplied definition. 8262 8263 `macro undef MACRO' 8264 Remove any user-supplied definition for the macro named MACRO. 8265 This command only affects definitions provided with the `macro 8266 define' command, described above; it cannot remove definitions 8267 present in the program being debugged. 8268 8269 `macro list' 8270 List all the macros defined using the `macro define' command. 8271 8272 Here is a transcript showing the above commands in action. First, we 8273 show our source files: 8274 8275 $ cat sample.c 8276 #include <stdio.h> 8277 #include "sample.h" 8278 8279 #define M 42 8280 #define ADD(x) (M + x) 8281 8282 main () 8283 { 8284 #define N 28 8285 printf ("Hello, world!\n"); 8286 #undef N 8287 printf ("We're so creative.\n"); 8288 #define N 1729 8289 printf ("Goodbye, world!\n"); 8290 } 8291 $ cat sample.h 8292 #define Q < 8293 $ 8294 8295 Now, we compile the program using the GNU C compiler, GCC. We pass 8296 the `-gdwarf-2' and `-g3' flags to ensure the compiler includes 8297 information about preprocessor macros in the debugging information. 8298 8299 $ gcc -gdwarf-2 -g3 sample.c -o sample 8300 $ 8301 8302 Now, we start GDB on our sample program: 8303 8304 $ gdb -nw sample 8305 GNU gdb 2002-05-06-cvs 8306 Copyright 2002 Free Software Foundation, Inc. 8307 GDB is free software, ... 8308 (gdb) 8309 8310 We can expand macros and examine their definitions, even when the 8311 program is not running. GDB uses the current listing position to 8312 decide which macro definitions are in scope: 8313 8314 (gdb) list main 8315 3 8316 4 #define M 42 8317 5 #define ADD(x) (M + x) 8318 6 8319 7 main () 8320 8 { 8321 9 #define N 28 8322 10 printf ("Hello, world!\n"); 8323 11 #undef N 8324 12 printf ("We're so creative.\n"); 8325 (gdb) info macro ADD 8326 Defined at /home/jimb/gdb/macros/play/sample.c:5 8327 #define ADD(x) (M + x) 8328 (gdb) info macro Q 8329 Defined at /home/jimb/gdb/macros/play/sample.h:1 8330 included at /home/jimb/gdb/macros/play/sample.c:2 8331 #define Q < 8332 (gdb) macro expand ADD(1) 8333 expands to: (42 + 1) 8334 (gdb) macro expand-once ADD(1) 8335 expands to: once (M + 1) 8336 (gdb) 8337 8338 In the example above, note that `macro expand-once' expands only the 8339 macro invocation explicit in the original text -- the invocation of 8340 `ADD' -- but does not expand the invocation of the macro `M', which was 8341 introduced by `ADD'. 8342 8343 Once the program is running, GDB uses the macro definitions in force 8344 at the source line of the current stack frame: 8345 8346 (gdb) break main 8347 Breakpoint 1 at 0x8048370: file sample.c, line 10. 8348 (gdb) run 8349 Starting program: /home/jimb/gdb/macros/play/sample 8350 8351 Breakpoint 1, main () at sample.c:10 8352 10 printf ("Hello, world!\n"); 8353 (gdb) 8354 8355 At line 10, the definition of the macro `N' at line 9 is in force: 8356 8357 (gdb) info macro N 8358 Defined at /home/jimb/gdb/macros/play/sample.c:9 8359 #define N 28 8360 (gdb) macro expand N Q M 8361 expands to: 28 < 42 8362 (gdb) print N Q M 8363 $1 = 1 8364 (gdb) 8365 8366 As we step over directives that remove `N''s definition, and then 8367 give it a new definition, GDB finds the definition (or lack thereof) in 8368 force at each point: 8369 8370 (gdb) next 8371 Hello, world! 8372 12 printf ("We're so creative.\n"); 8373 (gdb) info macro N 8374 The symbol `N' has no definition as a C/C++ preprocessor macro 8375 at /home/jimb/gdb/macros/play/sample.c:12 8376 (gdb) next 8377 We're so creative. 8378 14 printf ("Goodbye, world!\n"); 8379 (gdb) info macro N 8380 Defined at /home/jimb/gdb/macros/play/sample.c:13 8381 #define N 1729 8382 (gdb) macro expand N Q M 8383 expands to: 1729 < 42 8384 (gdb) print N Q M 8385 $2 = 0 8386 (gdb) 8387 8388 In addition to source files, macros can be defined on the 8389 compilation command line using the `-DNAME=VALUE' syntax. For macros 8390 defined in such a way, GDB displays the location of their definition as 8391 line zero of the source file submitted to the compiler. 8392 8393 (gdb) info macro __STDC__ 8394 Defined at /home/jimb/gdb/macros/play/sample.c:0 8395 -D__STDC__=1 8396 (gdb) 8397 8398 8399 File: gdb.info, Node: Tracepoints, Next: Overlays, Prev: Macros, Up: Top 8400 8401 13 Tracepoints 8402 ************** 8403 8404 In some applications, it is not feasible for the debugger to interrupt 8405 the program's execution long enough for the developer to learn anything 8406 helpful about its behavior. If the program's correctness depends on 8407 its real-time behavior, delays introduced by a debugger might cause the 8408 program to change its behavior drastically, or perhaps fail, even when 8409 the code itself is correct. It is useful to be able to observe the 8410 program's behavior without interrupting it. 8411 8412 Using GDB's `trace' and `collect' commands, you can specify 8413 locations in the program, called "tracepoints", and arbitrary 8414 expressions to evaluate when those tracepoints are reached. Later, 8415 using the `tfind' command, you can examine the values those expressions 8416 had when the program hit the tracepoints. The expressions may also 8417 denote objects in memory--structures or arrays, for example--whose 8418 values GDB should record; while visiting a particular tracepoint, you 8419 may inspect those objects as if they were in memory at that moment. 8420 However, because GDB records these values without interacting with you, 8421 it can do so quickly and unobtrusively, hopefully not disturbing the 8422 program's behavior. 8423 8424 The tracepoint facility is currently available only for remote 8425 targets. *Note Targets::. In addition, your remote target must know 8426 how to collect trace data. This functionality is implemented in the 8427 remote stub; however, none of the stubs distributed with GDB support 8428 tracepoints as of this writing. The format of the remote packets used 8429 to implement tracepoints are described in *note Tracepoint Packets::. 8430 8431 It is also possible to get trace data from a file, in a manner 8432 reminiscent of corefiles; you specify the filename, and use `tfind' to 8433 search through the file. *Note Trace Files::, for more details. 8434 8435 This chapter describes the tracepoint commands and features. 8436 8437 * Menu: 8438 8439 * Set Tracepoints:: 8440 * Analyze Collected Data:: 8441 * Tracepoint Variables:: 8442 * Trace Files:: 8443 8444 8445 File: gdb.info, Node: Set Tracepoints, Next: Analyze Collected Data, Up: Tracepoints 8446 8447 13.1 Commands to Set Tracepoints 8448 ================================ 8449 8450 Before running such a "trace experiment", an arbitrary number of 8451 tracepoints can be set. A tracepoint is actually a special type of 8452 breakpoint (*note Set Breaks::), so you can manipulate it using 8453 standard breakpoint commands. For instance, as with breakpoints, 8454 tracepoint numbers are successive integers starting from one, and many 8455 of the commands associated with tracepoints take the tracepoint number 8456 as their argument, to identify which tracepoint to work on. 8457 8458 For each tracepoint, you can specify, in advance, some arbitrary set 8459 of data that you want the target to collect in the trace buffer when it 8460 hits that tracepoint. The collected data can include registers, local 8461 variables, or global data. Later, you can use GDB commands to examine 8462 the values these data had at the time the tracepoint was hit. 8463 8464 Tracepoints do not support every breakpoint feature. Ignore counts 8465 on tracepoints have no effect, and tracepoints cannot run GDB commands 8466 when they are hit. Tracepoints may not be thread-specific either. 8467 8468 Some targets may support "fast tracepoints", which are inserted in a 8469 different way (such as with a jump instead of a trap), that is faster 8470 but possibly restricted in where they may be installed. 8471 8472 Regular and fast tracepoints are dynamic tracing facilities, meaning 8473 that they can be used to insert tracepoints at (almost) any location in 8474 the target. Some targets may also support controlling "static 8475 tracepoints" from GDB. With static tracing, a set of instrumentation 8476 points, also known as "markers", are embedded in the target program, 8477 and can be activated or deactivated by name or address. These are 8478 usually placed at locations which facilitate investigating what the 8479 target is actually doing. GDB's support for static tracing includes 8480 being able to list instrumentation points, and attach them with GDB 8481 defined high level tracepoints that expose the whole range of 8482 convenience of GDB's tracepoints support. Namely, support for 8483 collecting registers values and values of global or local (to the 8484 instrumentation point) variables; tracepoint conditions and trace state 8485 variables. The act of installing a GDB static tracepoint on an 8486 instrumentation point, or marker, is referred to as "probing" a static 8487 tracepoint marker. 8488 8489 `gdbserver' supports tracepoints on some target systems. *Note 8490 Tracepoints support in `gdbserver': Server. 8491 8492 This section describes commands to set tracepoints and associated 8493 conditions and actions. 8494 8495 * Menu: 8496 8497 * Create and Delete Tracepoints:: 8498 * Enable and Disable Tracepoints:: 8499 * Tracepoint Passcounts:: 8500 * Tracepoint Conditions:: 8501 * Trace State Variables:: 8502 * Tracepoint Actions:: 8503 * Listing Tracepoints:: 8504 * Listing Static Tracepoint Markers:: 8505 * Starting and Stopping Trace Experiments:: 8506 * Tracepoint Restrictions:: 8507 8508 8509 File: gdb.info, Node: Create and Delete Tracepoints, Next: Enable and Disable Tracepoints, Up: Set Tracepoints 8510 8511 13.1.1 Create and Delete Tracepoints 8512 ------------------------------------ 8513 8514 `trace LOCATION' 8515 The `trace' command is very similar to the `break' command. Its 8516 argument LOCATION can be a source line, a function name, or an 8517 address in the target program. *Note Specify Location::. The 8518 `trace' command defines a tracepoint, which is a point in the 8519 target program where the debugger will briefly stop, collect some 8520 data, and then allow the program to continue. Setting a 8521 tracepoint or changing its actions doesn't take effect until the 8522 next `tstart' command, and once a trace experiment is running, 8523 further changes will not have any effect until the next trace 8524 experiment starts. 8525 8526 Here are some examples of using the `trace' command: 8527 8528 (gdb) trace foo.c:121 // a source file and line number 8529 8530 (gdb) trace +2 // 2 lines forward 8531 8532 (gdb) trace my_function // first source line of function 8533 8534 (gdb) trace *my_function // EXACT start address of function 8535 8536 (gdb) trace *0x2117c4 // an address 8537 8538 You can abbreviate `trace' as `tr'. 8539 8540 `trace LOCATION if COND' 8541 Set a tracepoint with condition COND; evaluate the expression COND 8542 each time the tracepoint is reached, and collect data only if the 8543 value is nonzero--that is, if COND evaluates as true. *Note 8544 Tracepoint Conditions: Tracepoint Conditions, for more information 8545 on tracepoint conditions. 8546 8547 `ftrace LOCATION [ if COND ]' 8548 The `ftrace' command sets a fast tracepoint. For targets that 8549 support them, fast tracepoints will use a more efficient but 8550 possibly less general technique to trigger data collection, such 8551 as a jump instruction instead of a trap, or some sort of hardware 8552 support. It may not be possible to create a fast tracepoint at 8553 the desired location, in which case the command will exit with an 8554 explanatory message. 8555 8556 GDB handles arguments to `ftrace' exactly as for `trace'. 8557 8558 `strace LOCATION [ if COND ]' 8559 The `strace' command sets a static tracepoint. For targets that 8560 support it, setting a static tracepoint probes a static 8561 instrumentation point, or marker, found at LOCATION. It may not 8562 be possible to set a static tracepoint at the desired location, in 8563 which case the command will exit with an explanatory message. 8564 8565 GDB handles arguments to `strace' exactly as for `trace', with the 8566 addition that the user can also specify `-m MARKER' as LOCATION. 8567 This probes the marker identified by the MARKER string identifier. 8568 This identifier depends on the static tracepoint backend library 8569 your program is using. You can find all the marker identifiers in 8570 the `ID' field of the `info static-tracepoint-markers' command 8571 output. *Note Listing Static Tracepoint Markers: Listing Static 8572 Tracepoint Markers. For example, in the following small program 8573 using the UST tracing engine: 8574 8575 main () 8576 { 8577 trace_mark(ust, bar33, "str %s", "FOOBAZ"); 8578 } 8579 8580 the marker id is composed of joining the first two arguments to the 8581 `trace_mark' call with a slash, which translates to: 8582 8583 (gdb) info static-tracepoint-markers 8584 Cnt Enb ID Address What 8585 1 n ust/bar33 0x0000000000400ddc in main at stexample.c:22 8586 Data: "str %s" 8587 [etc...] 8588 8589 so you may probe the marker above with: 8590 8591 (gdb) strace -m ust/bar33 8592 8593 Static tracepoints accept an extra collect action -- `collect 8594 $_sdata'. This collects arbitrary user data passed in the probe 8595 point call to the tracing library. In the UST example above, 8596 you'll see that the third argument to `trace_mark' is a 8597 printf-like format string. The user data is then the result of 8598 running that formating string against the following arguments. 8599 Note that `info static-tracepoint-markers' command output lists 8600 that format string in the `Data:' field. 8601 8602 You can inspect this data when analyzing the trace buffer, by 8603 printing the $_sdata variable like any other variable available to 8604 GDB. *Note Tracepoint Action Lists: Tracepoint Actions. 8605 8606 The convenience variable `$tpnum' records the tracepoint number of 8607 the most recently set tracepoint. 8608 8609 `delete tracepoint [NUM]' 8610 Permanently delete one or more tracepoints. With no argument, the 8611 default is to delete all tracepoints. Note that the regular 8612 `delete' command can remove tracepoints also. 8613 8614 Examples: 8615 8616 (gdb) delete trace 1 2 3 // remove three tracepoints 8617 8618 (gdb) delete trace // remove all tracepoints 8619 8620 You can abbreviate this command as `del tr'. 8621 8622 8623 File: gdb.info, Node: Enable and Disable Tracepoints, Next: Tracepoint Passcounts, Prev: Create and Delete Tracepoints, Up: Set Tracepoints 8624 8625 13.1.2 Enable and Disable Tracepoints 8626 ------------------------------------- 8627 8628 These commands are deprecated; they are equivalent to plain `disable' 8629 and `enable'. 8630 8631 `disable tracepoint [NUM]' 8632 Disable tracepoint NUM, or all tracepoints if no argument NUM is 8633 given. A disabled tracepoint will have no effect during the next 8634 trace experiment, but it is not forgotten. You can re-enable a 8635 disabled tracepoint using the `enable tracepoint' command. 8636 8637 `enable tracepoint [NUM]' 8638 Enable tracepoint NUM, or all tracepoints. The enabled 8639 tracepoints will become effective the next time a trace experiment 8640 is run. 8641 8642 8643 File: gdb.info, Node: Tracepoint Passcounts, Next: Tracepoint Conditions, Prev: Enable and Disable Tracepoints, Up: Set Tracepoints 8644 8645 13.1.3 Tracepoint Passcounts 8646 ---------------------------- 8647 8648 `passcount [N [NUM]]' 8649 Set the "passcount" of a tracepoint. The passcount is a way to 8650 automatically stop a trace experiment. If a tracepoint's 8651 passcount is N, then the trace experiment will be automatically 8652 stopped on the N'th time that tracepoint is hit. If the 8653 tracepoint number NUM is not specified, the `passcount' command 8654 sets the passcount of the most recently defined tracepoint. If no 8655 passcount is given, the trace experiment will run until stopped 8656 explicitly by the user. 8657 8658 Examples: 8659 8660 (gdb) passcount 5 2 // Stop on the 5th execution of 8661 `// tracepoint 2' 8662 8663 (gdb) passcount 12 // Stop on the 12th execution of the 8664 `// most recently defined tracepoint.' 8665 (gdb) trace foo 8666 (gdb) pass 3 8667 (gdb) trace bar 8668 (gdb) pass 2 8669 (gdb) trace baz 8670 (gdb) pass 1 // Stop tracing when foo has been 8671 `// executed 3 times OR when bar has' 8672 `// been executed 2 times' 8673 `// OR when baz has been executed 1 time.' 8674 8675 8676 8677 File: gdb.info, Node: Tracepoint Conditions, Next: Trace State Variables, Prev: Tracepoint Passcounts, Up: Set Tracepoints 8678 8679 13.1.4 Tracepoint Conditions 8680 ---------------------------- 8681 8682 The simplest sort of tracepoint collects data every time your program 8683 reaches a specified place. You can also specify a "condition" for a 8684 tracepoint. A condition is just a Boolean expression in your 8685 programming language (*note Expressions: Expressions.). A tracepoint 8686 with a condition evaluates the expression each time your program 8687 reaches it, and data collection happens only if the condition is true. 8688 8689 Tracepoint conditions can be specified when a tracepoint is set, by 8690 using `if' in the arguments to the `trace' command. *Note Setting 8691 Tracepoints: Create and Delete Tracepoints. They can also be set or 8692 changed at any time with the `condition' command, just as with 8693 breakpoints. 8694 8695 Unlike breakpoint conditions, GDB does not actually evaluate the 8696 conditional expression itself. Instead, GDB encodes the expression 8697 into an agent expression (*note Agent Expressions::) suitable for 8698 execution on the target, independently of GDB. Global variables become 8699 raw memory locations, locals become stack accesses, and so forth. 8700 8701 For instance, suppose you have a function that is usually called 8702 frequently, but should not be called after an error has occurred. You 8703 could use the following tracepoint command to collect data about calls 8704 of that function that happen while the error code is propagating 8705 through the program; an unconditional tracepoint could end up 8706 collecting thousands of useless trace frames that you would have to 8707 search through. 8708 8709 (gdb) trace normal_operation if errcode > 0 8710 8711 8712 File: gdb.info, Node: Trace State Variables, Next: Tracepoint Actions, Prev: Tracepoint Conditions, Up: Set Tracepoints 8713 8714 13.1.5 Trace State Variables 8715 ---------------------------- 8716 8717 A "trace state variable" is a special type of variable that is created 8718 and managed by target-side code. The syntax is the same as that for 8719 GDB's convenience variables (a string prefixed with "$"), but they are 8720 stored on the target. They must be created explicitly, using a 8721 `tvariable' command. They are always 64-bit signed integers. 8722 8723 Trace state variables are remembered by GDB, and downloaded to the 8724 target along with tracepoint information when the trace experiment 8725 starts. There are no intrinsic limits on the number of trace state 8726 variables, beyond memory limitations of the target. 8727 8728 Although trace state variables are managed by the target, you can use 8729 them in print commands and expressions as if they were convenience 8730 variables; GDB will get the current value from the target while the 8731 trace experiment is running. Trace state variables share the same 8732 namespace as other "$" variables, which means that you cannot have 8733 trace state variables with names like `$23' or `$pc', nor can you have 8734 a trace state variable and a convenience variable with the same name. 8735 8736 `tvariable $NAME [ = EXPRESSION ]' 8737 The `tvariable' command creates a new trace state variable named 8738 `$NAME', and optionally gives it an initial value of EXPRESSION. 8739 EXPRESSION is evaluated when this command is entered; the result 8740 will be converted to an integer if possible, otherwise GDB will 8741 report an error. A subsequent `tvariable' command specifying the 8742 same name does not create a variable, but instead assigns the 8743 supplied initial value to the existing variable of that name, 8744 overwriting any previous initial value. The default initial value 8745 is 0. 8746 8747 `info tvariables' 8748 List all the trace state variables along with their initial values. 8749 Their current values may also be displayed, if the trace 8750 experiment is currently running. 8751 8752 `delete tvariable [ $NAME ... ]' 8753 Delete the given trace state variables, or all of them if no 8754 arguments are specified. 8755 8756 8757 8758 File: gdb.info, Node: Tracepoint Actions, Next: Listing Tracepoints, Prev: Trace State Variables, Up: Set Tracepoints 8759 8760 13.1.6 Tracepoint Action Lists 8761 ------------------------------ 8762 8763 `actions [NUM]' 8764 This command will prompt for a list of actions to be taken when the 8765 tracepoint is hit. If the tracepoint number NUM is not specified, 8766 this command sets the actions for the one that was most recently 8767 defined (so that you can define a tracepoint and then say 8768 `actions' without bothering about its number). You specify the 8769 actions themselves on the following lines, one action at a time, 8770 and terminate the actions list with a line containing just `end'. 8771 So far, the only defined actions are `collect', `teval', and 8772 `while-stepping'. 8773 8774 `actions' is actually equivalent to `commands' (*note Breakpoint 8775 Command Lists: Break Commands.), except that only the defined 8776 actions are allowed; any other GDB command is rejected. 8777 8778 To remove all actions from a tracepoint, type `actions NUM' and 8779 follow it immediately with `end'. 8780 8781 (gdb) collect DATA // collect some data 8782 8783 (gdb) while-stepping 5 // single-step 5 times, collect data 8784 8785 (gdb) end // signals the end of actions. 8786 8787 In the following example, the action list begins with `collect' 8788 commands indicating the things to be collected when the tracepoint 8789 is hit. Then, in order to single-step and collect additional data 8790 following the tracepoint, a `while-stepping' command is used, 8791 followed by the list of things to be collected after each step in a 8792 sequence of single steps. The `while-stepping' command is 8793 terminated by its own separate `end' command. Lastly, the action 8794 list is terminated by an `end' command. 8795 8796 (gdb) trace foo 8797 (gdb) actions 8798 Enter actions for tracepoint 1, one per line: 8799 > collect bar,baz 8800 > collect $regs 8801 > while-stepping 12 8802 > collect $pc, arr[i] 8803 > end 8804 end 8805 8806 `collect EXPR1, EXPR2, ...' 8807 Collect values of the given expressions when the tracepoint is hit. 8808 This command accepts a comma-separated list of any valid 8809 expressions. In addition to global, static, or local variables, 8810 the following special arguments are supported: 8811 8812 `$regs' 8813 Collect all registers. 8814 8815 `$args' 8816 Collect all function arguments. 8817 8818 `$locals' 8819 Collect all local variables. 8820 8821 `$_sdata' 8822 Collect static tracepoint marker specific data. Only 8823 available for static tracepoints. *Note Tracepoint Action 8824 Lists: Tracepoint Actions. On the UST static tracepoints 8825 library backend, an instrumentation point resembles a 8826 `printf' function call. The tracing library is able to 8827 collect user specified data formatted to a character string 8828 using the format provided by the programmer that instrumented 8829 the program. Other backends have similar mechanisms. Here's 8830 an example of a UST marker call: 8831 8832 const char master_name[] = "$your_name"; 8833 trace_mark(channel1, marker1, "hello %s", master_name) 8834 8835 In this case, collecting `$_sdata' collects the string `hello 8836 $yourname'. When analyzing the trace buffer, you can inspect 8837 `$_sdata' like any other variable available to GDB. 8838 8839 You can give several consecutive `collect' commands, each one with 8840 a single argument, or one `collect' command with several arguments 8841 separated by commas; the effect is the same. 8842 8843 The command `info scope' (*note info scope: Symbols.) is 8844 particularly useful for figuring out what data to collect. 8845 8846 `teval EXPR1, EXPR2, ...' 8847 Evaluate the given expressions when the tracepoint is hit. This 8848 command accepts a comma-separated list of expressions. The results 8849 are discarded, so this is mainly useful for assigning values to 8850 trace state variables (*note Trace State Variables::) without 8851 adding those values to the trace buffer, as would be the case if 8852 the `collect' action were used. 8853 8854 `while-stepping N' 8855 Perform N single-step instruction traces after the tracepoint, 8856 collecting new data after each step. The `while-stepping' command 8857 is followed by the list of what to collect while stepping 8858 (followed by its own `end' command): 8859 8860 > while-stepping 12 8861 > collect $regs, myglobal 8862 > end 8863 > 8864 8865 Note that `$pc' is not automatically collected by 8866 `while-stepping'; you need to explicitly collect that register if 8867 you need it. You may abbreviate `while-stepping' as `ws' or 8868 `stepping'. 8869 8870 `set default-collect EXPR1, EXPR2, ...' 8871 This variable is a list of expressions to collect at each 8872 tracepoint hit. It is effectively an additional `collect' action 8873 prepended to every tracepoint action list. The expressions are 8874 parsed individually for each tracepoint, so for instance a 8875 variable named `xyz' may be interpreted as a global for one 8876 tracepoint, and a local for another, as appropriate to the 8877 tracepoint's location. 8878 8879 `show default-collect' 8880 Show the list of expressions that are collected by default at each 8881 tracepoint hit. 8882 8883 8884 8885 File: gdb.info, Node: Listing Tracepoints, Next: Listing Static Tracepoint Markers, Prev: Tracepoint Actions, Up: Set Tracepoints 8886 8887 13.1.7 Listing Tracepoints 8888 -------------------------- 8889 8890 `info tracepoints [NUM...]' 8891 Display information about the tracepoint NUM. If you don't 8892 specify a tracepoint number, displays information about all the 8893 tracepoints defined so far. The format is similar to that used for 8894 `info breakpoints'; in fact, `info tracepoints' is the same 8895 command, simply restricting itself to tracepoints. 8896 8897 A tracepoint's listing may include additional information specific 8898 to tracing: 8899 8900 * its passcount as given by the `passcount N' command 8901 8902 (gdb) info trace 8903 Num Type Disp Enb Address What 8904 1 tracepoint keep y 0x0804ab57 in foo() at main.cxx:7 8905 while-stepping 20 8906 collect globfoo, $regs 8907 end 8908 collect globfoo2 8909 end 8910 pass count 1200 8911 (gdb) 8912 8913 This command can be abbreviated `info tp'. 8914 8915 8916 File: gdb.info, Node: Listing Static Tracepoint Markers, Next: Starting and Stopping Trace Experiments, Prev: Listing Tracepoints, Up: Set Tracepoints 8917 8918 13.1.8 Listing Static Tracepoint Markers 8919 ---------------------------------------- 8920 8921 `info static-tracepoint-markers' 8922 Display information about all static tracepoint markers defined in 8923 the program. 8924 8925 For each marker, the following columns are printed: 8926 8927 _Count_ 8928 An incrementing counter, output to help readability. This is 8929 not a stable identifier. 8930 8931 _ID_ 8932 The marker ID, as reported by the target. 8933 8934 _Enabled or Disabled_ 8935 Probed markers are tagged with `y'. `n' identifies marks 8936 that are not enabled. 8937 8938 _Address_ 8939 Where the marker is in your program, as a memory address. 8940 8941 _What_ 8942 Where the marker is in the source for your program, as a file 8943 and line number. If the debug information included in the 8944 program does not allow GDB to locate the source of the 8945 marker, this column will be left blank. 8946 8947 In addition, the following information may be printed for each 8948 marker: 8949 8950 _Data_ 8951 User data passed to the tracing library by the marker call. 8952 In the UST backend, this is the format string passed as 8953 argument to the marker call. 8954 8955 _Static tracepoints probing the marker_ 8956 The list of static tracepoints attached to the marker. 8957 8958 (gdb) info static-tracepoint-markers 8959 Cnt ID Enb Address What 8960 1 ust/bar2 y 0x0000000000400e1a in main at stexample.c:25 8961 Data: number1 %d number2 %d 8962 Probed by static tracepoints: #2 8963 2 ust/bar33 n 0x0000000000400c87 in main at stexample.c:24 8964 Data: str %s 8965 (gdb) 8966 8967 8968 File: gdb.info, Node: Starting and Stopping Trace Experiments, Next: Tracepoint Restrictions, Prev: Listing Static Tracepoint Markers, Up: Set Tracepoints 8969 8970 13.1.9 Starting and Stopping Trace Experiments 8971 ---------------------------------------------- 8972 8973 `tstart' 8974 This command takes no arguments. It starts the trace experiment, 8975 and begins collecting data. This has the side effect of 8976 discarding all the data collected in the trace buffer during the 8977 previous trace experiment. 8978 8979 `tstop' 8980 This command takes no arguments. It ends the trace experiment, and 8981 stops collecting data. 8982 8983 *Note*: a trace experiment and data collection may stop 8984 automatically if any tracepoint's passcount is reached (*note 8985 Tracepoint Passcounts::), or if the trace buffer becomes full. 8986 8987 `tstatus' 8988 This command displays the status of the current trace data 8989 collection. 8990 8991 Here is an example of the commands we described so far: 8992 8993 (gdb) trace gdb_c_test 8994 (gdb) actions 8995 Enter actions for tracepoint #1, one per line. 8996 > collect $regs,$locals,$args 8997 > while-stepping 11 8998 > collect $regs 8999 > end 9000 > end 9001 (gdb) tstart 9002 [time passes ...] 9003 (gdb) tstop 9004 9005 You can choose to continue running the trace experiment even if GDB 9006 disconnects from the target, voluntarily or involuntarily. For 9007 commands such as `detach', the debugger will ask what you want to do 9008 with the trace. But for unexpected terminations (GDB crash, network 9009 outage), it would be unfortunate to lose hard-won trace data, so the 9010 variable `disconnected-tracing' lets you decide whether the trace should 9011 continue running without GDB. 9012 9013 `set disconnected-tracing on' 9014 `set disconnected-tracing off' 9015 Choose whether a tracing run should continue to run if GDB has 9016 disconnected from the target. Note that `detach' or `quit' will 9017 ask you directly what to do about a running trace no matter what 9018 this variable's setting, so the variable is mainly useful for 9019 handling unexpected situations, such as loss of the network. 9020 9021 `show disconnected-tracing' 9022 Show the current choice for disconnected tracing. 9023 9024 9025 When you reconnect to the target, the trace experiment may or may not 9026 still be running; it might have filled the trace buffer in the 9027 meantime, or stopped for one of the other reasons. If it is running, 9028 it will continue after reconnection. 9029 9030 Upon reconnection, the target will upload information about the 9031 tracepoints in effect. GDB will then compare that information to the 9032 set of tracepoints currently defined, and attempt to match them up, 9033 allowing for the possibility that the numbers may have changed due to 9034 creation and deletion in the meantime. If one of the target's 9035 tracepoints does not match any in GDB, the debugger will create a new 9036 tracepoint, so that you have a number with which to specify that 9037 tracepoint. This matching-up process is necessarily heuristic, and it 9038 may result in useless tracepoints being created; you may simply delete 9039 them if they are of no use. 9040 9041 If your target agent supports a "circular trace buffer", then you 9042 can run a trace experiment indefinitely without filling the trace 9043 buffer; when space runs out, the agent deletes already-collected trace 9044 frames, oldest first, until there is enough room to continue 9045 collecting. This is especially useful if your tracepoints are being 9046 hit too often, and your trace gets terminated prematurely because the 9047 buffer is full. To ask for a circular trace buffer, simply set 9048 `circular-trace-buffer' to on. You can set this at any time, including 9049 during tracing; if the agent can do it, it will change buffer handling 9050 on the fly, otherwise it will not take effect until the next run. 9051 9052 `set circular-trace-buffer on' 9053 `set circular-trace-buffer off' 9054 Choose whether a tracing run should use a linear or circular buffer 9055 for trace data. A linear buffer will not lose any trace data, but 9056 may fill up prematurely, while a circular buffer will discard old 9057 trace data, but it will have always room for the latest tracepoint 9058 hits. 9059 9060 `show circular-trace-buffer' 9061 Show the current choice for the trace buffer. Note that this may 9062 not match the agent's current buffer handling, nor is it 9063 guaranteed to match the setting that might have been in effect 9064 during a past run, for instance if you are looking at frames from 9065 a trace file. 9066 9067 9068 9069 File: gdb.info, Node: Tracepoint Restrictions, Prev: Starting and Stopping Trace Experiments, Up: Set Tracepoints 9070 9071 13.1.10 Tracepoint Restrictions 9072 ------------------------------- 9073 9074 There are a number of restrictions on the use of tracepoints. As 9075 described above, tracepoint data gathering occurs on the target without 9076 interaction from GDB. Thus the full capabilities of the debugger are 9077 not available during data gathering, and then at data examination time, 9078 you will be limited by only having what was collected. The following 9079 items describe some common problems, but it is not exhaustive, and you 9080 may run into additional difficulties not mentioned here. 9081 9082 * Tracepoint expressions are intended to gather objects (lvalues). 9083 Thus the full flexibility of GDB's expression evaluator is not 9084 available. You cannot call functions, cast objects to aggregate 9085 types, access convenience variables or modify values (except by 9086 assignment to trace state variables). Some language features may 9087 implicitly call functions (for instance Objective-C fields with 9088 accessors), and therefore cannot be collected either. 9089 9090 * Collection of local variables, either individually or in bulk with 9091 `$locals' or `$args', during `while-stepping' may behave 9092 erratically. The stepping action may enter a new scope (for 9093 instance by stepping into a function), or the location of the 9094 variable may change (for instance it is loaded into a register). 9095 The tracepoint data recorded uses the location information for the 9096 variables that is correct for the tracepoint location. When the 9097 tracepoint is created, it is not possible, in general, to determine 9098 where the steps of a `while-stepping' sequence will advance the 9099 program--particularly if a conditional branch is stepped. 9100 9101 * Collection of an incompletely-initialized or partially-destroyed 9102 object may result in something that GDB cannot display, or displays 9103 in a misleading way. 9104 9105 * When GDB displays a pointer to character it automatically 9106 dereferences the pointer to also display characters of the string 9107 being pointed to. However, collecting the pointer during tracing 9108 does not automatically collect the string. You need to explicitly 9109 dereference the pointer and provide size information if you want to 9110 collect not only the pointer, but the memory pointed to. For 9111 example, `*ptr@50' can be used to collect the 50 element array 9112 pointed to by `ptr'. 9113 9114 * It is not possible to collect a complete stack backtrace at a 9115 tracepoint. Instead, you may collect the registers and a few 9116 hundred bytes from the stack pointer with something like 9117 `*$esp@300' (adjust to use the name of the actual stack pointer 9118 register on your target architecture, and the amount of stack you 9119 wish to capture). Then the `backtrace' command will show a 9120 partial backtrace when using a trace frame. The number of stack 9121 frames that can be examined depends on the sizes of the frames in 9122 the collected stack. Note that if you ask for a block so large 9123 that it goes past the bottom of the stack, the target agent may 9124 report an error trying to read from an invalid address. 9125 9126 * If you do not collect registers at a tracepoint, GDB can infer 9127 that the value of `$pc' must be the same as the address of the 9128 tracepoint and use that when you are looking at a trace frame for 9129 that tracepoint. However, this cannot work if the tracepoint has 9130 multiple locations (for instance if it was set in a function that 9131 was inlined), or if it has a `while-stepping' loop. In those cases 9132 GDB will warn you that it can't infer `$pc', and default it to 9133 zero. 9134 9135 9136 9137 File: gdb.info, Node: Analyze Collected Data, Next: Tracepoint Variables, Prev: Set Tracepoints, Up: Tracepoints 9138 9139 13.2 Using the Collected Data 9140 ============================= 9141 9142 After the tracepoint experiment ends, you use GDB commands for 9143 examining the trace data. The basic idea is that each tracepoint 9144 collects a trace "snapshot" every time it is hit and another snapshot 9145 every time it single-steps. All these snapshots are consecutively 9146 numbered from zero and go into a buffer, and you can examine them 9147 later. The way you examine them is to "focus" on a specific trace 9148 snapshot. When the remote stub is focused on a trace snapshot, it will 9149 respond to all GDB requests for memory and registers by reading from 9150 the buffer which belongs to that snapshot, rather than from _real_ 9151 memory or registers of the program being debugged. This means that 9152 *all* GDB commands (`print', `info registers', `backtrace', etc.) will 9153 behave as if we were currently debugging the program state as it was 9154 when the tracepoint occurred. Any requests for data that are not in 9155 the buffer will fail. 9156 9157 * Menu: 9158 9159 * tfind:: How to select a trace snapshot 9160 * tdump:: How to display all data for a snapshot 9161 * save tracepoints:: How to save tracepoints for a future run 9162 9163 9164 File: gdb.info, Node: tfind, Next: tdump, Up: Analyze Collected Data 9165 9166 13.2.1 `tfind N' 9167 ---------------- 9168 9169 The basic command for selecting a trace snapshot from the buffer is 9170 `tfind N', which finds trace snapshot number N, counting from zero. If 9171 no argument N is given, the next snapshot is selected. 9172 9173 Here are the various forms of using the `tfind' command. 9174 9175 `tfind start' 9176 Find the first snapshot in the buffer. This is a synonym for 9177 `tfind 0' (since 0 is the number of the first snapshot). 9178 9179 `tfind none' 9180 Stop debugging trace snapshots, resume _live_ debugging. 9181 9182 `tfind end' 9183 Same as `tfind none'. 9184 9185 `tfind' 9186 No argument means find the next trace snapshot. 9187 9188 `tfind -' 9189 Find the previous trace snapshot before the current one. This 9190 permits retracing earlier steps. 9191 9192 `tfind tracepoint NUM' 9193 Find the next snapshot associated with tracepoint NUM. Search 9194 proceeds forward from the last examined trace snapshot. If no 9195 argument NUM is given, it means find the next snapshot collected 9196 for the same tracepoint as the current snapshot. 9197 9198 `tfind pc ADDR' 9199 Find the next snapshot associated with the value ADDR of the 9200 program counter. Search proceeds forward from the last examined 9201 trace snapshot. If no argument ADDR is given, it means find the 9202 next snapshot with the same value of PC as the current snapshot. 9203 9204 `tfind outside ADDR1, ADDR2' 9205 Find the next snapshot whose PC is outside the given range of 9206 addresses (exclusive). 9207 9208 `tfind range ADDR1, ADDR2' 9209 Find the next snapshot whose PC is between ADDR1 and ADDR2 9210 (inclusive). 9211 9212 `tfind line [FILE:]N' 9213 Find the next snapshot associated with the source line N. If the 9214 optional argument FILE is given, refer to line N in that source 9215 file. Search proceeds forward from the last examined trace 9216 snapshot. If no argument N is given, it means find the next line 9217 other than the one currently being examined; thus saying `tfind 9218 line' repeatedly can appear to have the same effect as stepping 9219 from line to line in a _live_ debugging session. 9220 9221 The default arguments for the `tfind' commands are specifically 9222 designed to make it easy to scan through the trace buffer. For 9223 instance, `tfind' with no argument selects the next trace snapshot, and 9224 `tfind -' with no argument selects the previous trace snapshot. So, by 9225 giving one `tfind' command, and then simply hitting <RET> repeatedly 9226 you can examine all the trace snapshots in order. Or, by saying `tfind 9227 -' and then hitting <RET> repeatedly you can examine the snapshots in 9228 reverse order. The `tfind line' command with no argument selects the 9229 snapshot for the next source line executed. The `tfind pc' command with 9230 no argument selects the next snapshot with the same program counter 9231 (PC) as the current frame. The `tfind tracepoint' command with no 9232 argument selects the next trace snapshot collected by the same 9233 tracepoint as the current one. 9234 9235 In addition to letting you scan through the trace buffer manually, 9236 these commands make it easy to construct GDB scripts that scan through 9237 the trace buffer and print out whatever collected data you are 9238 interested in. Thus, if we want to examine the PC, FP, and SP 9239 registers from each trace frame in the buffer, we can say this: 9240 9241 (gdb) tfind start 9242 (gdb) while ($trace_frame != -1) 9243 > printf "Frame %d, PC = %08X, SP = %08X, FP = %08X\n", \ 9244 $trace_frame, $pc, $sp, $fp 9245 > tfind 9246 > end 9247 9248 Frame 0, PC = 0020DC64, SP = 0030BF3C, FP = 0030BF44 9249 Frame 1, PC = 0020DC6C, SP = 0030BF38, FP = 0030BF44 9250 Frame 2, PC = 0020DC70, SP = 0030BF34, FP = 0030BF44 9251 Frame 3, PC = 0020DC74, SP = 0030BF30, FP = 0030BF44 9252 Frame 4, PC = 0020DC78, SP = 0030BF2C, FP = 0030BF44 9253 Frame 5, PC = 0020DC7C, SP = 0030BF28, FP = 0030BF44 9254 Frame 6, PC = 0020DC80, SP = 0030BF24, FP = 0030BF44 9255 Frame 7, PC = 0020DC84, SP = 0030BF20, FP = 0030BF44 9256 Frame 8, PC = 0020DC88, SP = 0030BF1C, FP = 0030BF44 9257 Frame 9, PC = 0020DC8E, SP = 0030BF18, FP = 0030BF44 9258 Frame 10, PC = 00203F6C, SP = 0030BE3C, FP = 0030BF14 9259 9260 Or, if we want to examine the variable `X' at each source line in 9261 the buffer: 9262 9263 (gdb) tfind start 9264 (gdb) while ($trace_frame != -1) 9265 > printf "Frame %d, X == %d\n", $trace_frame, X 9266 > tfind line 9267 > end 9268 9269 Frame 0, X = 1 9270 Frame 7, X = 2 9271 Frame 13, X = 255 9272 9273 9274 File: gdb.info, Node: tdump, Next: save tracepoints, Prev: tfind, Up: Analyze Collected Data 9275 9276 13.2.2 `tdump' 9277 -------------- 9278 9279 This command takes no arguments. It prints all the data collected at 9280 the current trace snapshot. 9281 9282 (gdb) trace 444 9283 (gdb) actions 9284 Enter actions for tracepoint #2, one per line: 9285 > collect $regs, $locals, $args, gdb_long_test 9286 > end 9287 9288 (gdb) tstart 9289 9290 (gdb) tfind line 444 9291 #0 gdb_test (p1=0x11, p2=0x22, p3=0x33, p4=0x44, p5=0x55, p6=0x66) 9292 at gdb_test.c:444 9293 444 printp( "%s: arguments = 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X\n", ) 9294 9295 (gdb) tdump 9296 Data collected at tracepoint 2, trace frame 1: 9297 d0 0xc4aa0085 -995491707 9298 d1 0x18 24 9299 d2 0x80 128 9300 d3 0x33 51 9301 d4 0x71aea3d 119204413 9302 d5 0x22 34 9303 d6 0xe0 224 9304 d7 0x380035 3670069 9305 a0 0x19e24a 1696330 9306 a1 0x3000668 50333288 9307 a2 0x100 256 9308 a3 0x322000 3284992 9309 a4 0x3000698 50333336 9310 a5 0x1ad3cc 1758156 9311 fp 0x30bf3c 0x30bf3c 9312 sp 0x30bf34 0x30bf34 9313 ps 0x0 0 9314 pc 0x20b2c8 0x20b2c8 9315 fpcontrol 0x0 0 9316 fpstatus 0x0 0 9317 fpiaddr 0x0 0 9318 p = 0x20e5b4 "gdb-test" 9319 p1 = (void *) 0x11 9320 p2 = (void *) 0x22 9321 p3 = (void *) 0x33 9322 p4 = (void *) 0x44 9323 p5 = (void *) 0x55 9324 p6 = (void *) 0x66 9325 gdb_long_test = 17 '\021' 9326 9327 (gdb) 9328 9329 `tdump' works by scanning the tracepoint's current collection 9330 actions and printing the value of each expression listed. So `tdump' 9331 can fail, if after a run, you change the tracepoint's actions to 9332 mention variables that were not collected during the run. 9333 9334 Also, for tracepoints with `while-stepping' loops, `tdump' uses the 9335 collected value of `$pc' to distinguish between trace frames that were 9336 collected at the tracepoint hit, and frames that were collected while 9337 stepping. This allows it to correctly choose whether to display the 9338 basic list of collections, or the collections from the body of the 9339 while-stepping loop. However, if `$pc' was not collected, then `tdump' 9340 will always attempt to dump using the basic collection list, and may 9341 fail if a while-stepping frame does not include all the same data that 9342 is collected at the tracepoint hit. 9343 9344 9345 File: gdb.info, Node: save tracepoints, Prev: tdump, Up: Analyze Collected Data 9346 9347 13.2.3 `save tracepoints FILENAME' 9348 ---------------------------------- 9349 9350 This command saves all current tracepoint definitions together with 9351 their actions and passcounts, into a file `FILENAME' suitable for use 9352 in a later debugging session. To read the saved tracepoint 9353 definitions, use the `source' command (*note Command Files::). The 9354 `save-tracepoints' command is a deprecated alias for `save tracepoints' 9355 9356 9357 File: gdb.info, Node: Tracepoint Variables, Next: Trace Files, Prev: Analyze Collected Data, Up: Tracepoints 9358 9359 13.3 Convenience Variables for Tracepoints 9360 ========================================== 9361 9362 `(int) $trace_frame' 9363 The current trace snapshot (a.k.a. "frame") number, or -1 if no 9364 snapshot is selected. 9365 9366 `(int) $tracepoint' 9367 The tracepoint for the current trace snapshot. 9368 9369 `(int) $trace_line' 9370 The line number for the current trace snapshot. 9371 9372 `(char []) $trace_file' 9373 The source file for the current trace snapshot. 9374 9375 `(char []) $trace_func' 9376 The name of the function containing `$tracepoint'. 9377 9378 Note: `$trace_file' is not suitable for use in `printf', use 9379 `output' instead. 9380 9381 Here's a simple example of using these convenience variables for 9382 stepping through all the trace snapshots and printing some of their 9383 data. Note that these are not the same as trace state variables, which 9384 are managed by the target. 9385 9386 (gdb) tfind start 9387 9388 (gdb) while $trace_frame != -1 9389 > output $trace_file 9390 > printf ", line %d (tracepoint #%d)\n", $trace_line, $tracepoint 9391 > tfind 9392 > end 9393 9394 9395 File: gdb.info, Node: Trace Files, Prev: Tracepoint Variables, Up: Tracepoints 9396 9397 13.4 Using Trace Files 9398 ====================== 9399 9400 In some situations, the target running a trace experiment may no longer 9401 be available; perhaps it crashed, or the hardware was needed for a 9402 different activity. To handle these cases, you can arrange to dump the 9403 trace data into a file, and later use that file as a source of trace 9404 data, via the `target tfile' command. 9405 9406 `tsave [ -r ] FILENAME' 9407 Save the trace data to FILENAME. By default, this command assumes 9408 that FILENAME refers to the host filesystem, so if necessary GDB 9409 will copy raw trace data up from the target and then save it. If 9410 the target supports it, you can also supply the optional argument 9411 `-r' ("remote") to direct the target to save the data directly 9412 into FILENAME in its own filesystem, which may be more efficient 9413 if the trace buffer is very large. (Note, however, that `target 9414 tfile' can only read from files accessible to the host.) 9415 9416 `target tfile FILENAME' 9417 Use the file named FILENAME as a source of trace data. Commands 9418 that examine data work as they do with a live target, but it is not 9419 possible to run any new trace experiments. `tstatus' will report 9420 the state of the trace run at the moment the data was saved, as 9421 well as the current trace frame you are examining. FILENAME must 9422 be on a filesystem accessible to the host. 9423 9424 9425 9426 File: gdb.info, Node: Overlays, Next: Languages, Prev: Tracepoints, Up: Top 9427 9428 14 Debugging Programs That Use Overlays 9429 *************************************** 9430 9431 If your program is too large to fit completely in your target system's 9432 memory, you can sometimes use "overlays" to work around this problem. 9433 GDB provides some support for debugging programs that use overlays. 9434 9435 * Menu: 9436 9437 * How Overlays Work:: A general explanation of overlays. 9438 * Overlay Commands:: Managing overlays in GDB. 9439 * Automatic Overlay Debugging:: GDB can find out which overlays are 9440 mapped by asking the inferior. 9441 * Overlay Sample Program:: A sample program using overlays. 9442 9443 9444 File: gdb.info, Node: How Overlays Work, Next: Overlay Commands, Up: Overlays 9445 9446 14.1 How Overlays Work 9447 ====================== 9448 9449 Suppose you have a computer whose instruction address space is only 64 9450 kilobytes long, but which has much more memory which can be accessed by 9451 other means: special instructions, segment registers, or memory 9452 management hardware, for example. Suppose further that you want to 9453 adapt a program which is larger than 64 kilobytes to run on this system. 9454 9455 One solution is to identify modules of your program which are 9456 relatively independent, and need not call each other directly; call 9457 these modules "overlays". Separate the overlays from the main program, 9458 and place their machine code in the larger memory. Place your main 9459 program in instruction memory, but leave at least enough space there to 9460 hold the largest overlay as well. 9461 9462 Now, to call a function located in an overlay, you must first copy 9463 that overlay's machine code from the large memory into the space set 9464 aside for it in the instruction memory, and then jump to its entry point 9465 there. 9466 9467 Data Instruction Larger 9468 Address Space Address Space Address Space 9469 +-----------+ +-----------+ +-----------+ 9470 | | | | | | 9471 +-----------+ +-----------+ +-----------+<-- overlay 1 9472 | program | | main | .----| overlay 1 | load address 9473 | variables | | program | | +-----------+ 9474 | and heap | | | | | | 9475 +-----------+ | | | +-----------+<-- overlay 2 9476 | | +-----------+ | | | load address 9477 +-----------+ | | | .-| overlay 2 | 9478 | | | | | | 9479 mapped --->+-----------+ | | +-----------+ 9480 address | | | | | | 9481 | overlay | <-' | | | 9482 | area | <---' +-----------+<-- overlay 3 9483 | | <---. | | load address 9484 +-----------+ `--| overlay 3 | 9485 | | | | 9486 +-----------+ | | 9487 +-----------+ 9488 | | 9489 +-----------+ 9490 9491 A code overlay 9492 9493 The diagram (*note A code overlay::) shows a system with separate 9494 data and instruction address spaces. To map an overlay, the program 9495 copies its code from the larger address space to the instruction 9496 address space. Since the overlays shown here all use the same mapped 9497 address, only one may be mapped at a time. For a system with a single 9498 address space for data and instructions, the diagram would be similar, 9499 except that the program variables and heap would share an address space 9500 with the main program and the overlay area. 9501 9502 An overlay loaded into instruction memory and ready for use is 9503 called a "mapped" overlay; its "mapped address" is its address in the 9504 instruction memory. An overlay not present (or only partially present) 9505 in instruction memory is called "unmapped"; its "load address" is its 9506 address in the larger memory. The mapped address is also called the 9507 "virtual memory address", or "VMA"; the load address is also called the 9508 "load memory address", or "LMA". 9509 9510 Unfortunately, overlays are not a completely transparent way to 9511 adapt a program to limited instruction memory. They introduce a new 9512 set of global constraints you must keep in mind as you design your 9513 program: 9514 9515 * Before calling or returning to a function in an overlay, your 9516 program must make sure that overlay is actually mapped. 9517 Otherwise, the call or return will transfer control to the right 9518 address, but in the wrong overlay, and your program will probably 9519 crash. 9520 9521 * If the process of mapping an overlay is expensive on your system, 9522 you will need to choose your overlays carefully to minimize their 9523 effect on your program's performance. 9524 9525 * The executable file you load onto your system must contain each 9526 overlay's instructions, appearing at the overlay's load address, 9527 not its mapped address. However, each overlay's instructions must 9528 be relocated and its symbols defined as if the overlay were at its 9529 mapped address. You can use GNU linker scripts to specify 9530 different load and relocation addresses for pieces of your 9531 program; see *note Overlay Description: (ld.info)Overlay 9532 Description. 9533 9534 * The procedure for loading executable files onto your system must 9535 be able to load their contents into the larger address space as 9536 well as the instruction and data spaces. 9537 9538 9539 The overlay system described above is rather simple, and could be 9540 improved in many ways: 9541 9542 * If your system has suitable bank switch registers or memory 9543 management hardware, you could use those facilities to make an 9544 overlay's load area contents simply appear at their mapped address 9545 in instruction space. This would probably be faster than copying 9546 the overlay to its mapped area in the usual way. 9547 9548 * If your overlays are small enough, you could set aside more than 9549 one overlay area, and have more than one overlay mapped at a time. 9550 9551 * You can use overlays to manage data, as well as instructions. In 9552 general, data overlays are even less transparent to your design 9553 than code overlays: whereas code overlays only require care when 9554 you call or return to functions, data overlays require care every 9555 time you access the data. Also, if you change the contents of a 9556 data overlay, you must copy its contents back out to its load 9557 address before you can copy a different data overlay into the same 9558 mapped area. 9559 9560 9561 9562 File: gdb.info, Node: Overlay Commands, Next: Automatic Overlay Debugging, Prev: How Overlays Work, Up: Overlays 9563 9564 14.2 Overlay Commands 9565 ===================== 9566 9567 To use GDB's overlay support, each overlay in your program must 9568 correspond to a separate section of the executable file. The section's 9569 virtual memory address and load memory address must be the overlay's 9570 mapped and load addresses. Identifying overlays with sections allows 9571 GDB to determine the appropriate address of a function or variable, 9572 depending on whether the overlay is mapped or not. 9573 9574 GDB's overlay commands all start with the word `overlay'; you can 9575 abbreviate this as `ov' or `ovly'. The commands are: 9576 9577 `overlay off' 9578 Disable GDB's overlay support. When overlay support is disabled, 9579 GDB assumes that all functions and variables are always present at 9580 their mapped addresses. By default, GDB's overlay support is 9581 disabled. 9582 9583 `overlay manual' 9584 Enable "manual" overlay debugging. In this mode, GDB relies on 9585 you to tell it which overlays are mapped, and which are not, using 9586 the `overlay map-overlay' and `overlay unmap-overlay' commands 9587 described below. 9588 9589 `overlay map-overlay OVERLAY' 9590 `overlay map OVERLAY' 9591 Tell GDB that OVERLAY is now mapped; OVERLAY must be the name of 9592 the object file section containing the overlay. When an overlay 9593 is mapped, GDB assumes it can find the overlay's functions and 9594 variables at their mapped addresses. GDB assumes that any other 9595 overlays whose mapped ranges overlap that of OVERLAY are now 9596 unmapped. 9597 9598 `overlay unmap-overlay OVERLAY' 9599 `overlay unmap OVERLAY' 9600 Tell GDB that OVERLAY is no longer mapped; OVERLAY must be the 9601 name of the object file section containing the overlay. When an 9602 overlay is unmapped, GDB assumes it can find the overlay's 9603 functions and variables at their load addresses. 9604 9605 `overlay auto' 9606 Enable "automatic" overlay debugging. In this mode, GDB consults 9607 a data structure the overlay manager maintains in the inferior to 9608 see which overlays are mapped. For details, see *note Automatic 9609 Overlay Debugging::. 9610 9611 `overlay load-target' 9612 `overlay load' 9613 Re-read the overlay table from the inferior. Normally, GDB 9614 re-reads the table GDB automatically each time the inferior stops, 9615 so this command should only be necessary if you have changed the 9616 overlay mapping yourself using GDB. This command is only useful 9617 when using automatic overlay debugging. 9618 9619 `overlay list-overlays' 9620 `overlay list' 9621 Display a list of the overlays currently mapped, along with their 9622 mapped addresses, load addresses, and sizes. 9623 9624 9625 Normally, when GDB prints a code address, it includes the name of 9626 the function the address falls in: 9627 9628 (gdb) print main 9629 $3 = {int ()} 0x11a0 <main> 9630 When overlay debugging is enabled, GDB recognizes code in unmapped 9631 overlays, and prints the names of unmapped functions with asterisks 9632 around them. For example, if `foo' is a function in an unmapped 9633 overlay, GDB prints it this way: 9634 9635 (gdb) overlay list 9636 No sections are mapped. 9637 (gdb) print foo 9638 $5 = {int (int)} 0x100000 <*foo*> 9639 When `foo''s overlay is mapped, GDB prints the function's name 9640 normally: 9641 9642 (gdb) overlay list 9643 Section .ov.foo.text, loaded at 0x100000 - 0x100034, 9644 mapped at 0x1016 - 0x104a 9645 (gdb) print foo 9646 $6 = {int (int)} 0x1016 <foo> 9647 9648 When overlay debugging is enabled, GDB can find the correct address 9649 for functions and variables in an overlay, whether or not the overlay 9650 is mapped. This allows most GDB commands, like `break' and 9651 `disassemble', to work normally, even on unmapped code. However, GDB's 9652 breakpoint support has some limitations: 9653 9654 * You can set breakpoints in functions in unmapped overlays, as long 9655 as GDB can write to the overlay at its load address. 9656 9657 * GDB can not set hardware or simulator-based breakpoints in 9658 unmapped overlays. However, if you set a breakpoint at the end of 9659 your overlay manager (and tell GDB which overlays are now mapped, 9660 if you are using manual overlay management), GDB will re-set its 9661 breakpoints properly. 9662 9663 9664 File: gdb.info, Node: Automatic Overlay Debugging, Next: Overlay Sample Program, Prev: Overlay Commands, Up: Overlays 9665 9666 14.3 Automatic Overlay Debugging 9667 ================================ 9668 9669 GDB can automatically track which overlays are mapped and which are 9670 not, given some simple co-operation from the overlay manager in the 9671 inferior. If you enable automatic overlay debugging with the `overlay 9672 auto' command (*note Overlay Commands::), GDB looks in the inferior's 9673 memory for certain variables describing the current state of the 9674 overlays. 9675 9676 Here are the variables your overlay manager must define to support 9677 GDB's automatic overlay debugging: 9678 9679 `_ovly_table': 9680 This variable must be an array of the following structures: 9681 9682 struct 9683 { 9684 /* The overlay's mapped address. */ 9685 unsigned long vma; 9686 9687 /* The size of the overlay, in bytes. */ 9688 unsigned long size; 9689 9690 /* The overlay's load address. */ 9691 unsigned long lma; 9692 9693 /* Non-zero if the overlay is currently mapped; 9694 zero otherwise. */ 9695 unsigned long mapped; 9696 } 9697 9698 `_novlys': 9699 This variable must be a four-byte signed integer, holding the total 9700 number of elements in `_ovly_table'. 9701 9702 9703 To decide whether a particular overlay is mapped or not, GDB looks 9704 for an entry in `_ovly_table' whose `vma' and `lma' members equal the 9705 VMA and LMA of the overlay's section in the executable file. When GDB 9706 finds a matching entry, it consults the entry's `mapped' member to 9707 determine whether the overlay is currently mapped. 9708 9709 In addition, your overlay manager may define a function called 9710 `_ovly_debug_event'. If this function is defined, GDB will silently 9711 set a breakpoint there. If the overlay manager then calls this 9712 function whenever it has changed the overlay table, this will enable 9713 GDB to accurately keep track of which overlays are in program memory, 9714 and update any breakpoints that may be set in overlays. This will 9715 allow breakpoints to work even if the overlays are kept in ROM or other 9716 non-writable memory while they are not being executed. 9717 9718 9719 File: gdb.info, Node: Overlay Sample Program, Prev: Automatic Overlay Debugging, Up: Overlays 9720 9721 14.4 Overlay Sample Program 9722 =========================== 9723 9724 When linking a program which uses overlays, you must place the overlays 9725 at their load addresses, while relocating them to run at their mapped 9726 addresses. To do this, you must write a linker script (*note Overlay 9727 Description: (ld.info)Overlay Description.). Unfortunately, since 9728 linker scripts are specific to a particular host system, target 9729 architecture, and target memory layout, this manual cannot provide 9730 portable sample code demonstrating GDB's overlay support. 9731 9732 However, the GDB source distribution does contain an overlaid 9733 program, with linker scripts for a few systems, as part of its test 9734 suite. The program consists of the following files from 9735 `gdb/testsuite/gdb.base': 9736 9737 `overlays.c' 9738 The main program file. 9739 9740 `ovlymgr.c' 9741 A simple overlay manager, used by `overlays.c'. 9742 9743 `foo.c' 9744 `bar.c' 9745 `baz.c' 9746 `grbx.c' 9747 Overlay modules, loaded and used by `overlays.c'. 9748 9749 `d10v.ld' 9750 `m32r.ld' 9751 Linker scripts for linking the test program on the `d10v-elf' and 9752 `m32r-elf' targets. 9753 9754 You can build the test program using the `d10v-elf' GCC 9755 cross-compiler like this: 9756 9757 $ d10v-elf-gcc -g -c overlays.c 9758 $ d10v-elf-gcc -g -c ovlymgr.c 9759 $ d10v-elf-gcc -g -c foo.c 9760 $ d10v-elf-gcc -g -c bar.c 9761 $ d10v-elf-gcc -g -c baz.c 9762 $ d10v-elf-gcc -g -c grbx.c 9763 $ d10v-elf-gcc -g overlays.o ovlymgr.o foo.o bar.o \ 9764 baz.o grbx.o -Wl,-Td10v.ld -o overlays 9765 9766 The build process is identical for any other architecture, except 9767 that you must substitute the appropriate compiler and linker script for 9768 the target system for `d10v-elf-gcc' and `d10v.ld'. 9769 9770 9771 File: gdb.info, Node: Languages, Next: Symbols, Prev: Overlays, Up: Top 9772 9773 15 Using GDB with Different Languages 9774 ************************************* 9775 9776 Although programming languages generally have common aspects, they are 9777 rarely expressed in the same manner. For instance, in ANSI C, 9778 dereferencing a pointer `p' is accomplished by `*p', but in Modula-2, 9779 it is accomplished by `p^'. Values can also be represented (and 9780 displayed) differently. Hex numbers in C appear as `0x1ae', while in 9781 Modula-2 they appear as `1AEH'. 9782 9783 Language-specific information is built into GDB for some languages, 9784 allowing you to express operations like the above in your program's 9785 native language, and allowing GDB to output values in a manner 9786 consistent with the syntax of your program's native language. The 9787 language you use to build expressions is called the "working language". 9788 9789 * Menu: 9790 9791 * Setting:: Switching between source languages 9792 * Show:: Displaying the language 9793 * Checks:: Type and range checks 9794 * Supported Languages:: Supported languages 9795 * Unsupported Languages:: Unsupported languages 9796 9797 9798 File: gdb.info, Node: Setting, Next: Show, Up: Languages 9799 9800 15.1 Switching Between Source Languages 9801 ======================================= 9802 9803 There are two ways to control the working language--either have GDB set 9804 it automatically, or select it manually yourself. You can use the `set 9805 language' command for either purpose. On startup, GDB defaults to 9806 setting the language automatically. The working language is used to 9807 determine how expressions you type are interpreted, how values are 9808 printed, etc. 9809 9810 In addition to the working language, every source file that GDB 9811 knows about has its own working language. For some object file 9812 formats, the compiler might indicate which language a particular source 9813 file is in. However, most of the time GDB infers the language from the 9814 name of the file. The language of a source file controls whether C++ 9815 names are demangled--this way `backtrace' can show each frame 9816 appropriately for its own language. There is no way to set the 9817 language of a source file from within GDB, but you can set the language 9818 associated with a filename extension. *Note Displaying the Language: 9819 Show. 9820 9821 This is most commonly a problem when you use a program, such as 9822 `cfront' or `f2c', that generates C but is written in another language. 9823 In that case, make the program use `#line' directives in its C output; 9824 that way GDB will know the correct language of the source code of the 9825 original program, and will display that source code, not the generated 9826 C code. 9827 9828 * Menu: 9829 9830 * Filenames:: Filename extensions and languages. 9831 * Manually:: Setting the working language manually 9832 * Automatically:: Having GDB infer the source language 9833 9834 9835 File: gdb.info, Node: Filenames, Next: Manually, Up: Setting 9836 9837 15.1.1 List of Filename Extensions and Languages 9838 ------------------------------------------------ 9839 9840 If a source file name ends in one of the following extensions, then GDB 9841 infers that its language is the one indicated. 9842 9843 `.ada' 9844 `.ads' 9845 `.adb' 9846 `.a' 9847 Ada source file. 9848 9849 `.c' 9850 C source file 9851 9852 `.C' 9853 `.cc' 9854 `.cp' 9855 `.cpp' 9856 `.cxx' 9857 `.c++' 9858 C++ source file 9859 9860 `.d' 9861 D source file 9862 9863 `.m' 9864 Objective-C source file 9865 9866 `.f' 9867 `.F' 9868 Fortran source file 9869 9870 `.mod' 9871 Modula-2 source file 9872 9873 `.s' 9874 `.S' 9875 Assembler source file. This actually behaves almost like C, but 9876 GDB does not skip over function prologues when stepping. 9877 9878 In addition, you may set the language associated with a filename 9879 extension. *Note Displaying the Language: Show. 9880 9881 9882 File: gdb.info, Node: Manually, Next: Automatically, Prev: Filenames, Up: Setting 9883 9884 15.1.2 Setting the Working Language 9885 ----------------------------------- 9886 9887 If you allow GDB to set the language automatically, expressions are 9888 interpreted the same way in your debugging session and your program. 9889 9890 If you wish, you may set the language manually. To do this, issue 9891 the command `set language LANG', where LANG is the name of a language, 9892 such as `c' or `modula-2'. For a list of the supported languages, type 9893 `set language'. 9894 9895 Setting the language manually prevents GDB from updating the working 9896 language automatically. This can lead to confusion if you try to debug 9897 a program when the working language is not the same as the source 9898 language, when an expression is acceptable to both languages--but means 9899 different things. For instance, if the current source file were 9900 written in C, and GDB was parsing Modula-2, a command such as: 9901 9902 print a = b + c 9903 9904 might not have the effect you intended. In C, this means to add `b' 9905 and `c' and place the result in `a'. The result printed would be the 9906 value of `a'. In Modula-2, this means to compare `a' to the result of 9907 `b+c', yielding a `BOOLEAN' value. 9908 9909 9910 File: gdb.info, Node: Automatically, Prev: Manually, Up: Setting 9911 9912 15.1.3 Having GDB Infer the Source Language 9913 ------------------------------------------- 9914 9915 To have GDB set the working language automatically, use `set language 9916 local' or `set language auto'. GDB then infers the working language. 9917 That is, when your program stops in a frame (usually by encountering a 9918 breakpoint), GDB sets the working language to the language recorded for 9919 the function in that frame. If the language for a frame is unknown 9920 (that is, if the function or block corresponding to the frame was 9921 defined in a source file that does not have a recognized extension), 9922 the current working language is not changed, and GDB issues a warning. 9923 9924 This may not seem necessary for most programs, which are written 9925 entirely in one source language. However, program modules and libraries 9926 written in one source language can be used by a main program written in 9927 a different source language. Using `set language auto' in this case 9928 frees you from having to set the working language manually. 9929 9930 9931 File: gdb.info, Node: Show, Next: Checks, Prev: Setting, Up: Languages 9932 9933 15.2 Displaying the Language 9934 ============================ 9935 9936 The following commands help you find out which language is the working 9937 language, and also what language source files were written in. 9938 9939 `show language' 9940 Display the current working language. This is the language you 9941 can use with commands such as `print' to build and compute 9942 expressions that may involve variables in your program. 9943 9944 `info frame' 9945 Display the source language for this frame. This language becomes 9946 the working language if you use an identifier from this frame. 9947 *Note Information about a Frame: Frame Info, to identify the other 9948 information listed here. 9949 9950 `info source' 9951 Display the source language of this source file. *Note Examining 9952 the Symbol Table: Symbols, to identify the other information 9953 listed here. 9954 9955 In unusual circumstances, you may have source files with extensions 9956 not in the standard list. You can then set the extension associated 9957 with a language explicitly: 9958 9959 `set extension-language EXT LANGUAGE' 9960 Tell GDB that source files with extension EXT are to be assumed as 9961 written in the source language LANGUAGE. 9962 9963 `info extensions' 9964 List all the filename extensions and the associated languages. 9965 9966 9967 File: gdb.info, Node: Checks, Next: Supported Languages, Prev: Show, Up: Languages 9968 9969 15.3 Type and Range Checking 9970 ============================ 9971 9972 _Warning:_ In this release, the GDB commands for type and range 9973 checking are included, but they do not yet have any effect. This 9974 section documents the intended facilities. 9975 9976 Some languages are designed to guard you against making seemingly 9977 common errors through a series of compile- and run-time checks. These 9978 include checking the type of arguments to functions and operators, and 9979 making sure mathematical overflows are caught at run time. Checks such 9980 as these help to ensure a program's correctness once it has been 9981 compiled by eliminating type mismatches, and providing active checks 9982 for range errors when your program is running. 9983 9984 GDB can check for conditions like the above if you wish. Although 9985 GDB does not check the statements in your program, it can check 9986 expressions entered directly into GDB for evaluation via the `print' 9987 command, for example. As with the working language, GDB can also 9988 decide whether or not to check automatically based on your program's 9989 source language. *Note Supported Languages: Supported Languages, for 9990 the default settings of supported languages. 9991 9992 * Menu: 9993 9994 * Type Checking:: An overview of type checking 9995 * Range Checking:: An overview of range checking 9996 9997 9998 File: gdb.info, Node: Type Checking, Next: Range Checking, Up: Checks 9999 10000 15.3.1 An Overview of Type Checking 10001 ----------------------------------- 10002 10003 Some languages, such as Modula-2, are strongly typed, meaning that the 10004 arguments to operators and functions have to be of the correct type, 10005 otherwise an error occurs. These checks prevent type mismatch errors 10006 from ever causing any run-time problems. For example, 10007 10008 1 + 2 => 3 10009 but 10010 error--> 1 + 2.3 10011 10012 The second example fails because the `CARDINAL' 1 is not 10013 type-compatible with the `REAL' 2.3. 10014 10015 For the expressions you use in GDB commands, you can tell the GDB 10016 type checker to skip checking; to treat any mismatches as errors and 10017 abandon the expression; or to only issue warnings when type mismatches 10018 occur, but evaluate the expression anyway. When you choose the last of 10019 these, GDB evaluates expressions like the second example above, but 10020 also issues a warning. 10021 10022 Even if you turn type checking off, there may be other reasons 10023 related to type that prevent GDB from evaluating an expression. For 10024 instance, GDB does not know how to add an `int' and a `struct foo'. 10025 These particular type errors have nothing to do with the language in 10026 use, and usually arise from expressions, such as the one described 10027 above, which make little sense to evaluate anyway. 10028 10029 Each language defines to what degree it is strict about type. For 10030 instance, both Modula-2 and C require the arguments to arithmetical 10031 operators to be numbers. In C, enumerated types and pointers can be 10032 represented as numbers, so that they are valid arguments to mathematical 10033 operators. *Note Supported Languages: Supported Languages, for further 10034 details on specific languages. 10035 10036 GDB provides some additional commands for controlling the type 10037 checker: 10038 10039 `set check type auto' 10040 Set type checking on or off based on the current working language. 10041 *Note Supported Languages: Supported Languages, for the default 10042 settings for each language. 10043 10044 `set check type on' 10045 `set check type off' 10046 Set type checking on or off, overriding the default setting for the 10047 current working language. Issue a warning if the setting does not 10048 match the language default. If any type mismatches occur in 10049 evaluating an expression while type checking is on, GDB prints a 10050 message and aborts evaluation of the expression. 10051 10052 `set check type warn' 10053 Cause the type checker to issue warnings, but to always attempt to 10054 evaluate the expression. Evaluating the expression may still be 10055 impossible for other reasons. For example, GDB cannot add numbers 10056 and structures. 10057 10058 `show type' 10059 Show the current setting of the type checker, and whether or not 10060 GDB is setting it automatically. 10061 10062 10063 File: gdb.info, Node: Range Checking, Prev: Type Checking, Up: Checks 10064 10065 15.3.2 An Overview of Range Checking 10066 ------------------------------------ 10067 10068 In some languages (such as Modula-2), it is an error to exceed the 10069 bounds of a type; this is enforced with run-time checks. Such range 10070 checking is meant to ensure program correctness by making sure 10071 computations do not overflow, or indices on an array element access do 10072 not exceed the bounds of the array. 10073 10074 For expressions you use in GDB commands, you can tell GDB to treat 10075 range errors in one of three ways: ignore them, always treat them as 10076 errors and abandon the expression, or issue warnings but evaluate the 10077 expression anyway. 10078 10079 A range error can result from numerical overflow, from exceeding an 10080 array index bound, or when you type a constant that is not a member of 10081 any type. Some languages, however, do not treat overflows as an error. 10082 In many implementations of C, mathematical overflow causes the result 10083 to "wrap around" to lower values--for example, if M is the largest 10084 integer value, and S is the smallest, then 10085 10086 M + 1 => S 10087 10088 This, too, is specific to individual languages, and in some cases 10089 specific to individual compilers or machines. *Note Supported 10090 Languages: Supported Languages, for further details on specific 10091 languages. 10092 10093 GDB provides some additional commands for controlling the range 10094 checker: 10095 10096 `set check range auto' 10097 Set range checking on or off based on the current working language. 10098 *Note Supported Languages: Supported Languages, for the default 10099 settings for each language. 10100 10101 `set check range on' 10102 `set check range off' 10103 Set range checking on or off, overriding the default setting for 10104 the current working language. A warning is issued if the setting 10105 does not match the language default. If a range error occurs and 10106 range checking is on, then a message is printed and evaluation of 10107 the expression is aborted. 10108 10109 `set check range warn' 10110 Output messages when the GDB range checker detects a range error, 10111 but attempt to evaluate the expression anyway. Evaluating the 10112 expression may still be impossible for other reasons, such as 10113 accessing memory that the process does not own (a typical example 10114 from many Unix systems). 10115 10116 `show range' 10117 Show the current setting of the range checker, and whether or not 10118 it is being set automatically by GDB. 10119 10120 10121 File: gdb.info, Node: Supported Languages, Next: Unsupported Languages, Prev: Checks, Up: Languages 10122 10123 15.4 Supported Languages 10124 ======================== 10125 10126 GDB supports C, C++, D, Objective-C, Fortran, Java, OpenCL C, Pascal, 10127 assembly, Modula-2, and Ada. Some GDB features may be used in 10128 expressions regardless of the language you use: the GDB `@' and `::' 10129 operators, and the `{type}addr' construct (*note Expressions: 10130 Expressions.) can be used with the constructs of any supported language. 10131 10132 The following sections detail to what degree each source language is 10133 supported by GDB. These sections are not meant to be language 10134 tutorials or references, but serve only as a reference guide to what the 10135 GDB expression parser accepts, and what input and output formats should 10136 look like for different languages. There are many good books written 10137 on each of these languages; please look to these for a language 10138 reference or tutorial. 10139 10140 * Menu: 10141 10142 * C:: C and C++ 10143 * D:: D 10144 * Objective-C:: Objective-C 10145 * OpenCL C:: OpenCL C 10146 * Fortran:: Fortran 10147 * Pascal:: Pascal 10148 * Modula-2:: Modula-2 10149 * Ada:: Ada 10150 10151 10152 File: gdb.info, Node: C, Next: D, Up: Supported Languages 10153 10154 15.4.1 C and C++ 10155 ---------------- 10156 10157 Since C and C++ are so closely related, many features of GDB apply to 10158 both languages. Whenever this is the case, we discuss those languages 10159 together. 10160 10161 The C++ debugging facilities are jointly implemented by the C++ 10162 compiler and GDB. Therefore, to debug your C++ code effectively, you 10163 must compile your C++ programs with a supported C++ compiler, such as 10164 GNU `g++', or the HP ANSI C++ compiler (`aCC'). 10165 10166 For best results when using GNU C++, use the DWARF 2 debugging 10167 format; if it doesn't work on your system, try the stabs+ debugging 10168 format. You can select those formats explicitly with the `g++' 10169 command-line options `-gdwarf-2' and `-gstabs+'. *Note Options for 10170 Debugging Your Program or GCC: (gcc.info)Debugging Options. 10171 10172 * Menu: 10173 10174 * C Operators:: C and C++ operators 10175 * C Constants:: C and C++ constants 10176 * C Plus Plus Expressions:: C++ expressions 10177 * C Defaults:: Default settings for C and C++ 10178 * C Checks:: C and C++ type and range checks 10179 * Debugging C:: GDB and C 10180 * Debugging C Plus Plus:: GDB features for C++ 10181 * Decimal Floating Point:: Numbers in Decimal Floating Point format 10182 10183 10184 File: gdb.info, Node: C Operators, Next: C Constants, Up: C 10185 10186 15.4.1.1 C and C++ Operators 10187 ............................ 10188 10189 Operators must be defined on values of specific types. For instance, 10190 `+' is defined on numbers, but not on structures. Operators are often 10191 defined on groups of types. 10192 10193 For the purposes of C and C++, the following definitions hold: 10194 10195 * _Integral types_ include `int' with any of its storage-class 10196 specifiers; `char'; `enum'; and, for C++, `bool'. 10197 10198 * _Floating-point types_ include `float', `double', and `long 10199 double' (if supported by the target platform). 10200 10201 * _Pointer types_ include all types defined as `(TYPE *)'. 10202 10203 * _Scalar types_ include all of the above. 10204 10205 10206 The following operators are supported. They are listed here in order 10207 of increasing precedence: 10208 10209 `,' 10210 The comma or sequencing operator. Expressions in a 10211 comma-separated list are evaluated from left to right, with the 10212 result of the entire expression being the last expression 10213 evaluated. 10214 10215 `=' 10216 Assignment. The value of an assignment expression is the value 10217 assigned. Defined on scalar types. 10218 10219 `OP=' 10220 Used in an expression of the form `A OP= B', and translated to 10221 `A = A OP B'. `OP=' and `=' have the same precedence. OP is any 10222 one of the operators `|', `^', `&', `<<', `>>', `+', `-', `*', 10223 `/', `%'. 10224 10225 `?:' 10226 The ternary operator. `A ? B : C' can be thought of as: if A 10227 then B else C. A should be of an integral type. 10228 10229 `||' 10230 Logical OR. Defined on integral types. 10231 10232 `&&' 10233 Logical AND. Defined on integral types. 10234 10235 `|' 10236 Bitwise OR. Defined on integral types. 10237 10238 `^' 10239 Bitwise exclusive-OR. Defined on integral types. 10240 10241 `&' 10242 Bitwise AND. Defined on integral types. 10243 10244 `==, !=' 10245 Equality and inequality. Defined on scalar types. The value of 10246 these expressions is 0 for false and non-zero for true. 10247 10248 `<, >, <=, >=' 10249 Less than, greater than, less than or equal, greater than or equal. 10250 Defined on scalar types. The value of these expressions is 0 for 10251 false and non-zero for true. 10252 10253 `<<, >>' 10254 left shift, and right shift. Defined on integral types. 10255 10256 `@' 10257 The GDB "artificial array" operator (*note Expressions: 10258 Expressions.). 10259 10260 `+, -' 10261 Addition and subtraction. Defined on integral types, 10262 floating-point types and pointer types. 10263 10264 `*, /, %' 10265 Multiplication, division, and modulus. Multiplication and 10266 division are defined on integral and floating-point types. 10267 Modulus is defined on integral types. 10268 10269 `++, --' 10270 Increment and decrement. When appearing before a variable, the 10271 operation is performed before the variable is used in an 10272 expression; when appearing after it, the variable's value is used 10273 before the operation takes place. 10274 10275 `*' 10276 Pointer dereferencing. Defined on pointer types. Same precedence 10277 as `++'. 10278 10279 `&' 10280 Address operator. Defined on variables. Same precedence as `++'. 10281 10282 For debugging C++, GDB implements a use of `&' beyond what is 10283 allowed in the C++ language itself: you can use `&(&REF)' to 10284 examine the address where a C++ reference variable (declared with 10285 `&REF') is stored. 10286 10287 `-' 10288 Negative. Defined on integral and floating-point types. Same 10289 precedence as `++'. 10290 10291 `!' 10292 Logical negation. Defined on integral types. Same precedence as 10293 `++'. 10294 10295 `~' 10296 Bitwise complement operator. Defined on integral types. Same 10297 precedence as `++'. 10298 10299 `., ->' 10300 Structure member, and pointer-to-structure member. For 10301 convenience, GDB regards the two as equivalent, choosing whether 10302 to dereference a pointer based on the stored type information. 10303 Defined on `struct' and `union' data. 10304 10305 `.*, ->*' 10306 Dereferences of pointers to members. 10307 10308 `[]' 10309 Array indexing. `A[I]' is defined as `*(A+I)'. Same precedence 10310 as `->'. 10311 10312 `()' 10313 Function parameter list. Same precedence as `->'. 10314 10315 `::' 10316 C++ scope resolution operator. Defined on `struct', `union', and 10317 `class' types. 10318 10319 `::' 10320 Doubled colons also represent the GDB scope operator (*note 10321 Expressions: Expressions.). Same precedence as `::', above. 10322 10323 If an operator is redefined in the user code, GDB usually attempts 10324 to invoke the redefined version instead of using the operator's 10325 predefined meaning. 10326 10327 10328 File: gdb.info, Node: C Constants, Next: C Plus Plus Expressions, Prev: C Operators, Up: C 10329 10330 15.4.1.2 C and C++ Constants 10331 ............................ 10332 10333 GDB allows you to express the constants of C and C++ in the following 10334 ways: 10335 10336 * Integer constants are a sequence of digits. Octal constants are 10337 specified by a leading `0' (i.e. zero), and hexadecimal constants 10338 by a leading `0x' or `0X'. Constants may also end with a letter 10339 `l', specifying that the constant should be treated as a `long' 10340 value. 10341 10342 * Floating point constants are a sequence of digits, followed by a 10343 decimal point, followed by a sequence of digits, and optionally 10344 followed by an exponent. An exponent is of the form: 10345 `e[[+]|-]NNN', where NNN is another sequence of digits. The `+' 10346 is optional for positive exponents. A floating-point constant may 10347 also end with a letter `f' or `F', specifying that the constant 10348 should be treated as being of the `float' (as opposed to the 10349 default `double') type; or with a letter `l' or `L', which 10350 specifies a `long double' constant. 10351 10352 * Enumerated constants consist of enumerated identifiers, or their 10353 integral equivalents. 10354 10355 * Character constants are a single character surrounded by single 10356 quotes (`''), or a number--the ordinal value of the corresponding 10357 character (usually its ASCII value). Within quotes, the single 10358 character may be represented by a letter or by "escape sequences", 10359 which are of the form `\NNN', where NNN is the octal representation 10360 of the character's ordinal value; or of the form `\X', where `X' 10361 is a predefined special character--for example, `\n' for newline. 10362 10363 * String constants are a sequence of character constants surrounded 10364 by double quotes (`"'). Any valid character constant (as described 10365 above) may appear. Double quotes within the string must be 10366 preceded by a backslash, so for instance `"a\"b'c"' is a string of 10367 five characters. 10368 10369 * Pointer constants are an integral value. You can also write 10370 pointers to constants using the C operator `&'. 10371 10372 * Array constants are comma-separated lists surrounded by braces `{' 10373 and `}'; for example, `{1,2,3}' is a three-element array of 10374 integers, `{{1,2}, {3,4}, {5,6}}' is a three-by-two array, and 10375 `{&"hi", &"there", &"fred"}' is a three-element array of pointers. 10376 10377 10378 File: gdb.info, Node: C Plus Plus Expressions, Next: C Defaults, Prev: C Constants, Up: C 10379 10380 15.4.1.3 C++ Expressions 10381 ........................ 10382 10383 GDB expression handling can interpret most C++ expressions. 10384 10385 _Warning:_ GDB can only debug C++ code if you use the proper 10386 compiler and the proper debug format. Currently, GDB works best 10387 when debugging C++ code that is compiled with GCC 2.95.3 or with 10388 GCC 3.1 or newer, using the options `-gdwarf-2' or `-gstabs+'. 10389 DWARF 2 is preferred over stabs+. Most configurations of GCC emit 10390 either DWARF 2 or stabs+ as their default debug format, so you 10391 usually don't need to specify a debug format explicitly. Other 10392 compilers and/or debug formats are likely to work badly or not at 10393 all when using GDB to debug C++ code. 10394 10395 1. Member function calls are allowed; you can use expressions like 10396 10397 count = aml->GetOriginal(x, y) 10398 10399 2. While a member function is active (in the selected stack frame), 10400 your expressions have the same namespace available as the member 10401 function; that is, GDB allows implicit references to the class 10402 instance pointer `this' following the same rules as C++. 10403 10404 3. You can call overloaded functions; GDB resolves the function call 10405 to the right definition, with some restrictions. GDB does not 10406 perform overload resolution involving user-defined type 10407 conversions, calls to constructors, or instantiations of templates 10408 that do not exist in the program. It also cannot handle ellipsis 10409 argument lists or default arguments. 10410 10411 It does perform integral conversions and promotions, floating-point 10412 promotions, arithmetic conversions, pointer conversions, 10413 conversions of class objects to base classes, and standard 10414 conversions such as those of functions or arrays to pointers; it 10415 requires an exact match on the number of function arguments. 10416 10417 Overload resolution is always performed, unless you have specified 10418 `set overload-resolution off'. *Note GDB Features for C++: 10419 Debugging C Plus Plus. 10420 10421 You must specify `set overload-resolution off' in order to use an 10422 explicit function signature to call an overloaded function, as in 10423 p 'foo(char,int)'('x', 13) 10424 10425 The GDB command-completion facility can simplify this; see *note 10426 Command Completion: Completion. 10427 10428 4. GDB understands variables declared as C++ references; you can use 10429 them in expressions just as you do in C++ source--they are 10430 automatically dereferenced. 10431 10432 In the parameter list shown when GDB displays a frame, the values 10433 of reference variables are not displayed (unlike other variables); 10434 this avoids clutter, since references are often used for large 10435 structures. The _address_ of a reference variable is always 10436 shown, unless you have specified `set print address off'. 10437 10438 5. GDB supports the C++ name resolution operator `::'--your 10439 expressions can use it just as expressions in your program do. 10440 Since one scope may be defined in another, you can use `::' 10441 repeatedly if necessary, for example in an expression like 10442 `SCOPE1::SCOPE2::NAME'. GDB also allows resolving name scope by 10443 reference to source files, in both C and C++ debugging (*note 10444 Program Variables: Variables.). 10445 10446 In addition, when used with HP's C++ compiler, GDB supports calling 10447 virtual functions correctly, printing out virtual bases of objects, 10448 calling functions in a base subobject, casting objects, and invoking 10449 user-defined operators. 10450 10451 10452 File: gdb.info, Node: C Defaults, Next: C Checks, Prev: C Plus Plus Expressions, Up: C 10453 10454 15.4.1.4 C and C++ Defaults 10455 ........................... 10456 10457 If you allow GDB to set type and range checking automatically, they 10458 both default to `off' whenever the working language changes to C or 10459 C++. This happens regardless of whether you or GDB selects the working 10460 language. 10461 10462 If you allow GDB to set the language automatically, it recognizes 10463 source files whose names end with `.c', `.C', or `.cc', etc, and when 10464 GDB enters code compiled from one of these files, it sets the working 10465 language to C or C++. *Note Having GDB Infer the Source Language: 10466 Automatically, for further details. 10467 10468 10469 File: gdb.info, Node: C Checks, Next: Debugging C, Prev: C Defaults, Up: C 10470 10471 15.4.1.5 C and C++ Type and Range Checks 10472 ........................................ 10473 10474 By default, when GDB parses C or C++ expressions, type checking is not 10475 used. However, if you turn type checking on, GDB considers two 10476 variables type equivalent if: 10477 10478 * The two variables are structured and have the same structure, 10479 union, or enumerated tag. 10480 10481 * The two variables have the same type name, or types that have been 10482 declared equivalent through `typedef'. 10483 10484 10485 Range checking, if turned on, is done on mathematical operations. 10486 Array indices are not checked, since they are often used to index a 10487 pointer that is not itself an array. 10488 10489 10490 File: gdb.info, Node: Debugging C, Next: Debugging C Plus Plus, Prev: C Checks, Up: C 10491 10492 15.4.1.6 GDB and C 10493 .................. 10494 10495 The `set print union' and `show print union' commands apply to the 10496 `union' type. When set to `on', any `union' that is inside a `struct' 10497 or `class' is also printed. Otherwise, it appears as `{...}'. 10498 10499 The `@' operator aids in the debugging of dynamic arrays, formed 10500 with pointers and a memory allocation function. *Note Expressions: 10501 Expressions. 10502 10503 10504 File: gdb.info, Node: Debugging C Plus Plus, Next: Decimal Floating Point, Prev: Debugging C, Up: C 10505 10506 15.4.1.7 GDB Features for C++ 10507 ............................. 10508 10509 Some GDB commands are particularly useful with C++, and some are 10510 designed specifically for use with C++. Here is a summary: 10511 10512 `breakpoint menus' 10513 When you want a breakpoint in a function whose name is overloaded, 10514 GDB has the capability to display a menu of possible breakpoint 10515 locations to help you specify which function definition you want. 10516 *Note Ambiguous Expressions: Ambiguous Expressions. 10517 10518 `rbreak REGEX' 10519 Setting breakpoints using regular expressions is helpful for 10520 setting breakpoints on overloaded functions that are not members 10521 of any special classes. *Note Setting Breakpoints: Set Breaks. 10522 10523 `catch throw' 10524 `catch catch' 10525 Debug C++ exception handling using these commands. *Note Setting 10526 Catchpoints: Set Catchpoints. 10527 10528 `ptype TYPENAME' 10529 Print inheritance relationships as well as other information for 10530 type TYPENAME. *Note Examining the Symbol Table: Symbols. 10531 10532 `set print demangle' 10533 `show print demangle' 10534 `set print asm-demangle' 10535 `show print asm-demangle' 10536 Control whether C++ symbols display in their source form, both when 10537 displaying code as C++ source and when displaying disassemblies. 10538 *Note Print Settings: Print Settings. 10539 10540 `set print object' 10541 `show print object' 10542 Choose whether to print derived (actual) or declared types of 10543 objects. *Note Print Settings: Print Settings. 10544 10545 `set print vtbl' 10546 `show print vtbl' 10547 Control the format for printing virtual function tables. *Note 10548 Print Settings: Print Settings. (The `vtbl' commands do not work 10549 on programs compiled with the HP ANSI C++ compiler (`aCC').) 10550 10551 `set overload-resolution on' 10552 Enable overload resolution for C++ expression evaluation. The 10553 default is on. For overloaded functions, GDB evaluates the 10554 arguments and searches for a function whose signature matches the 10555 argument types, using the standard C++ conversion rules (see *note 10556 C++ Expressions: C Plus Plus Expressions, for details). If it 10557 cannot find a match, it emits a message. 10558 10559 `set overload-resolution off' 10560 Disable overload resolution for C++ expression evaluation. For 10561 overloaded functions that are not class member functions, GDB 10562 chooses the first function of the specified name that it finds in 10563 the symbol table, whether or not its arguments are of the correct 10564 type. For overloaded functions that are class member functions, 10565 GDB searches for a function whose signature _exactly_ matches the 10566 argument types. 10567 10568 `show overload-resolution' 10569 Show the current setting of overload resolution. 10570 10571 `Overloaded symbol names' 10572 You can specify a particular definition of an overloaded symbol, 10573 using the same notation that is used to declare such symbols in 10574 C++: type `SYMBOL(TYPES)' rather than just SYMBOL. You can also 10575 use the GDB command-line word completion facilities to list the 10576 available choices, or to finish the type list for you. *Note 10577 Command Completion: Completion, for details on how to do this. 10578 10579 10580 File: gdb.info, Node: Decimal Floating Point, Prev: Debugging C Plus Plus, Up: C 10581 10582 15.4.1.8 Decimal Floating Point format 10583 ...................................... 10584 10585 GDB can examine, set and perform computations with numbers in decimal 10586 floating point format, which in the C language correspond to the 10587 `_Decimal32', `_Decimal64' and `_Decimal128' types as specified by the 10588 extension to support decimal floating-point arithmetic. 10589 10590 There are two encodings in use, depending on the architecture: BID 10591 (Binary Integer Decimal) for x86 and x86-64, and DPD (Densely Packed 10592 Decimal) for PowerPC. GDB will use the appropriate encoding for the 10593 configured target. 10594 10595 Because of a limitation in `libdecnumber', the library used by GDB 10596 to manipulate decimal floating point numbers, it is not possible to 10597 convert (using a cast, for example) integers wider than 32-bit to 10598 decimal float. 10599 10600 In addition, in order to imitate GDB's behaviour with binary floating 10601 point computations, error checking in decimal float operations ignores 10602 underflow, overflow and divide by zero exceptions. 10603 10604 In the PowerPC architecture, GDB provides a set of pseudo-registers 10605 to inspect `_Decimal128' values stored in floating point registers. 10606 See *note PowerPC: PowerPC. for more details. 10607 10608 10609 File: gdb.info, Node: D, Next: Objective-C, Prev: C, Up: Supported Languages 10610 10611 15.4.2 D 10612 -------- 10613 10614 GDB can be used to debug programs written in D and compiled with GDC, 10615 LDC or DMD compilers. Currently GDB supports only one D specific 10616 feature -- dynamic arrays. 10617 10618 10619 File: gdb.info, Node: Objective-C, Next: OpenCL C, Prev: D, Up: Supported Languages 10620 10621 15.4.3 Objective-C 10622 ------------------ 10623 10624 This section provides information about some commands and command 10625 options that are useful for debugging Objective-C code. See also *note 10626 info classes: Symbols, and *note info selectors: Symbols, for a few 10627 more commands specific to Objective-C support. 10628 10629 * Menu: 10630 10631 * Method Names in Commands:: 10632 * The Print Command with Objective-C:: 10633 10634 10635 File: gdb.info, Node: Method Names in Commands, Next: The Print Command with Objective-C, Up: Objective-C 10636 10637 15.4.3.1 Method Names in Commands 10638 ................................. 10639 10640 The following commands have been extended to accept Objective-C method 10641 names as line specifications: 10642 10643 * `clear' 10644 10645 * `break' 10646 10647 * `info line' 10648 10649 * `jump' 10650 10651 * `list' 10652 10653 A fully qualified Objective-C method name is specified as 10654 10655 -[CLASS METHODNAME] 10656 10657 where the minus sign is used to indicate an instance method and a 10658 plus sign (not shown) is used to indicate a class method. The class 10659 name CLASS and method name METHODNAME are enclosed in brackets, similar 10660 to the way messages are specified in Objective-C source code. For 10661 example, to set a breakpoint at the `create' instance method of class 10662 `Fruit' in the program currently being debugged, enter: 10663 10664 break -[Fruit create] 10665 10666 To list ten program lines around the `initialize' class method, 10667 enter: 10668 10669 list +[NSText initialize] 10670 10671 In the current version of GDB, the plus or minus sign is required. 10672 In future versions of GDB, the plus or minus sign will be optional, but 10673 you can use it to narrow the search. It is also possible to specify 10674 just a method name: 10675 10676 break create 10677 10678 You must specify the complete method name, including any colons. If 10679 your program's source files contain more than one `create' method, 10680 you'll be presented with a numbered list of classes that implement that 10681 method. Indicate your choice by number, or type `0' to exit if none 10682 apply. 10683 10684 As another example, to clear a breakpoint established at the 10685 `makeKeyAndOrderFront:' method of the `NSWindow' class, enter: 10686 10687 clear -[NSWindow makeKeyAndOrderFront:] 10688 10689 10690 File: gdb.info, Node: The Print Command with Objective-C, Prev: Method Names in Commands, Up: Objective-C 10691 10692 15.4.3.2 The Print Command With Objective-C 10693 ........................................... 10694 10695 The print command has also been extended to accept methods. For 10696 example: 10697 10698 print -[OBJECT hash] 10699 10700 will tell GDB to send the `hash' message to OBJECT and print the 10701 result. Also, an additional command has been added, `print-object' or 10702 `po' for short, which is meant to print the description of an object. 10703 However, this command may only work with certain Objective-C libraries 10704 that have a particular hook function, `_NSPrintForDebugger', defined. 10705 10706 10707 File: gdb.info, Node: OpenCL C, Next: Fortran, Prev: Objective-C, Up: Supported Languages 10708 10709 15.4.4 OpenCL C 10710 --------------- 10711 10712 This section provides information about GDBs OpenCL C support. 10713 10714 * Menu: 10715 10716 * OpenCL C Datatypes:: 10717 * OpenCL C Expressions:: 10718 * OpenCL C Operators:: 10719 10720 10721 File: gdb.info, Node: OpenCL C Datatypes, Next: OpenCL C Expressions, Up: OpenCL C 10722 10723 15.4.4.1 OpenCL C Datatypes 10724 ........................... 10725 10726 GDB supports the builtin scalar and vector datatypes specified by 10727 OpenCL 1.1. In addition the half- and double-precision floating point 10728 data types of the `cl_khr_fp16' and `cl_khr_fp64' OpenCL extensions are 10729 also known to GDB. 10730 10731 10732 File: gdb.info, Node: OpenCL C Expressions, Next: OpenCL C Operators, Prev: OpenCL C Datatypes, Up: OpenCL C 10733 10734 15.4.4.2 OpenCL C Expressions 10735 ............................. 10736 10737 GDB supports accesses to vector components including the access as 10738 lvalue where possible. Since OpenCL C is based on C99 most C 10739 expressions supported by GDB can be used as well. 10740 10741 10742 File: gdb.info, Node: OpenCL C Operators, Prev: OpenCL C Expressions, Up: OpenCL C 10743 10744 15.4.4.3 OpenCL C Operators 10745 ........................... 10746 10747 GDB supports the operators specified by OpenCL 1.1 for scalar and 10748 vector data types. 10749 10750 10751 File: gdb.info, Node: Fortran, Next: Pascal, Prev: OpenCL C, Up: Supported Languages 10752 10753 15.4.5 Fortran 10754 -------------- 10755 10756 GDB can be used to debug programs written in Fortran, but it currently 10757 supports only the features of Fortran 77 language. 10758 10759 Some Fortran compilers (GNU Fortran 77 and Fortran 95 compilers 10760 among them) append an underscore to the names of variables and 10761 functions. When you debug programs compiled by those compilers, you 10762 will need to refer to variables and functions with a trailing 10763 underscore. 10764 10765 * Menu: 10766 10767 * Fortran Operators:: Fortran operators and expressions 10768 * Fortran Defaults:: Default settings for Fortran 10769 * Special Fortran Commands:: Special GDB commands for Fortran 10770 10771 10772 File: gdb.info, Node: Fortran Operators, Next: Fortran Defaults, Up: Fortran 10773 10774 15.4.5.1 Fortran Operators and Expressions 10775 .......................................... 10776 10777 Operators must be defined on values of specific types. For instance, 10778 `+' is defined on numbers, but not on characters or other non- 10779 arithmetic types. Operators are often defined on groups of types. 10780 10781 `**' 10782 The exponentiation operator. It raises the first operand to the 10783 power of the second one. 10784 10785 `:' 10786 The range operator. Normally used in the form of array(low:high) 10787 to represent a section of array. 10788 10789 `%' 10790 The access component operator. Normally used to access elements 10791 in derived types. Also suitable for unions. As unions aren't 10792 part of regular Fortran, this can only happen when accessing a 10793 register that uses a gdbarch-defined union type. 10794 10795 10796 File: gdb.info, Node: Fortran Defaults, Next: Special Fortran Commands, Prev: Fortran Operators, Up: Fortran 10797 10798 15.4.5.2 Fortran Defaults 10799 ......................... 10800 10801 Fortran symbols are usually case-insensitive, so GDB by default uses 10802 case-insensitive matches for Fortran symbols. You can change that with 10803 the `set case-insensitive' command, see *note Symbols::, for the 10804 details. 10805 10806 10807 File: gdb.info, Node: Special Fortran Commands, Prev: Fortran Defaults, Up: Fortran 10808 10809 15.4.5.3 Special Fortran Commands 10810 ................................. 10811 10812 GDB has some commands to support Fortran-specific features, such as 10813 displaying common blocks. 10814 10815 `info common [COMMON-NAME]' 10816 This command prints the values contained in the Fortran `COMMON' 10817 block whose name is COMMON-NAME. With no argument, the names of 10818 all `COMMON' blocks visible at the current program location are 10819 printed. 10820 10821 10822 File: gdb.info, Node: Pascal, Next: Modula-2, Prev: Fortran, Up: Supported Languages 10823 10824 15.4.6 Pascal 10825 ------------- 10826 10827 Debugging Pascal programs which use sets, subranges, file variables, or 10828 nested functions does not currently work. GDB does not support 10829 entering expressions, printing values, or similar features using Pascal 10830 syntax. 10831 10832 The Pascal-specific command `set print pascal_static-members' 10833 controls whether static members of Pascal objects are displayed. *Note 10834 pascal_static-members: Print Settings. 10835 10836 10837 File: gdb.info, Node: Modula-2, Next: Ada, Prev: Pascal, Up: Supported Languages 10838 10839 15.4.7 Modula-2 10840 --------------- 10841 10842 The extensions made to GDB to support Modula-2 only support output from 10843 the GNU Modula-2 compiler (which is currently being developed). Other 10844 Modula-2 compilers are not currently supported, and attempting to debug 10845 executables produced by them is most likely to give an error as GDB 10846 reads in the executable's symbol table. 10847 10848 * Menu: 10849 10850 * M2 Operators:: Built-in operators 10851 * Built-In Func/Proc:: Built-in functions and procedures 10852 * M2 Constants:: Modula-2 constants 10853 * M2 Types:: Modula-2 types 10854 * M2 Defaults:: Default settings for Modula-2 10855 * Deviations:: Deviations from standard Modula-2 10856 * M2 Checks:: Modula-2 type and range checks 10857 * M2 Scope:: The scope operators `::' and `.' 10858 * GDB/M2:: GDB and Modula-2 10859 10860 10861 File: gdb.info, Node: M2 Operators, Next: Built-In Func/Proc, Up: Modula-2 10862 10863 15.4.7.1 Operators 10864 .................. 10865 10866 Operators must be defined on values of specific types. For instance, 10867 `+' is defined on numbers, but not on structures. Operators are often 10868 defined on groups of types. For the purposes of Modula-2, the 10869 following definitions hold: 10870 10871 * _Integral types_ consist of `INTEGER', `CARDINAL', and their 10872 subranges. 10873 10874 * _Character types_ consist of `CHAR' and its subranges. 10875 10876 * _Floating-point types_ consist of `REAL'. 10877 10878 * _Pointer types_ consist of anything declared as `POINTER TO TYPE'. 10879 10880 * _Scalar types_ consist of all of the above. 10881 10882 * _Set types_ consist of `SET' and `BITSET' types. 10883 10884 * _Boolean types_ consist of `BOOLEAN'. 10885 10886 The following operators are supported, and appear in order of 10887 increasing precedence: 10888 10889 `,' 10890 Function argument or array index separator. 10891 10892 `:=' 10893 Assignment. The value of VAR `:=' VALUE is VALUE. 10894 10895 `<, >' 10896 Less than, greater than on integral, floating-point, or enumerated 10897 types. 10898 10899 `<=, >=' 10900 Less than or equal to, greater than or equal to on integral, 10901 floating-point and enumerated types, or set inclusion on set 10902 types. Same precedence as `<'. 10903 10904 `=, <>, #' 10905 Equality and two ways of expressing inequality, valid on scalar 10906 types. Same precedence as `<'. In GDB scripts, only `<>' is 10907 available for inequality, since `#' conflicts with the script 10908 comment character. 10909 10910 `IN' 10911 Set membership. Defined on set types and the types of their 10912 members. Same precedence as `<'. 10913 10914 `OR' 10915 Boolean disjunction. Defined on boolean types. 10916 10917 `AND, &' 10918 Boolean conjunction. Defined on boolean types. 10919 10920 `@' 10921 The GDB "artificial array" operator (*note Expressions: 10922 Expressions.). 10923 10924 `+, -' 10925 Addition and subtraction on integral and floating-point types, or 10926 union and difference on set types. 10927 10928 `*' 10929 Multiplication on integral and floating-point types, or set 10930 intersection on set types. 10931 10932 `/' 10933 Division on floating-point types, or symmetric set difference on 10934 set types. Same precedence as `*'. 10935 10936 `DIV, MOD' 10937 Integer division and remainder. Defined on integral types. Same 10938 precedence as `*'. 10939 10940 `-' 10941 Negative. Defined on `INTEGER' and `REAL' data. 10942 10943 `^' 10944 Pointer dereferencing. Defined on pointer types. 10945 10946 `NOT' 10947 Boolean negation. Defined on boolean types. Same precedence as 10948 `^'. 10949 10950 `.' 10951 `RECORD' field selector. Defined on `RECORD' data. Same 10952 precedence as `^'. 10953 10954 `[]' 10955 Array indexing. Defined on `ARRAY' data. Same precedence as `^'. 10956 10957 `()' 10958 Procedure argument list. Defined on `PROCEDURE' objects. Same 10959 precedence as `^'. 10960 10961 `::, .' 10962 GDB and Modula-2 scope operators. 10963 10964 _Warning:_ Set expressions and their operations are not yet 10965 supported, so GDB treats the use of the operator `IN', or the use 10966 of operators `+', `-', `*', `/', `=', , `<>', `#', `<=', and `>=' 10967 on sets as an error. 10968 10969 10970 File: gdb.info, Node: Built-In Func/Proc, Next: M2 Constants, Prev: M2 Operators, Up: Modula-2 10971 10972 15.4.7.2 Built-in Functions and Procedures 10973 .......................................... 10974 10975 Modula-2 also makes available several built-in procedures and functions. 10976 In describing these, the following metavariables are used: 10977 10978 A 10979 represents an `ARRAY' variable. 10980 10981 C 10982 represents a `CHAR' constant or variable. 10983 10984 I 10985 represents a variable or constant of integral type. 10986 10987 M 10988 represents an identifier that belongs to a set. Generally used in 10989 the same function with the metavariable S. The type of S should 10990 be `SET OF MTYPE' (where MTYPE is the type of M). 10991 10992 N 10993 represents a variable or constant of integral or floating-point 10994 type. 10995 10996 R 10997 represents a variable or constant of floating-point type. 10998 10999 T 11000 represents a type. 11001 11002 V 11003 represents a variable. 11004 11005 X 11006 represents a variable or constant of one of many types. See the 11007 explanation of the function for details. 11008 11009 All Modula-2 built-in procedures also return a result, described 11010 below. 11011 11012 `ABS(N)' 11013 Returns the absolute value of N. 11014 11015 `CAP(C)' 11016 If C is a lower case letter, it returns its upper case equivalent, 11017 otherwise it returns its argument. 11018 11019 `CHR(I)' 11020 Returns the character whose ordinal value is I. 11021 11022 `DEC(V)' 11023 Decrements the value in the variable V by one. Returns the new 11024 value. 11025 11026 `DEC(V,I)' 11027 Decrements the value in the variable V by I. Returns the new 11028 value. 11029 11030 `EXCL(M,S)' 11031 Removes the element M from the set S. Returns the new set. 11032 11033 `FLOAT(I)' 11034 Returns the floating point equivalent of the integer I. 11035 11036 `HIGH(A)' 11037 Returns the index of the last member of A. 11038 11039 `INC(V)' 11040 Increments the value in the variable V by one. Returns the new 11041 value. 11042 11043 `INC(V,I)' 11044 Increments the value in the variable V by I. Returns the new 11045 value. 11046 11047 `INCL(M,S)' 11048 Adds the element M to the set S if it is not already there. 11049 Returns the new set. 11050 11051 `MAX(T)' 11052 Returns the maximum value of the type T. 11053 11054 `MIN(T)' 11055 Returns the minimum value of the type T. 11056 11057 `ODD(I)' 11058 Returns boolean TRUE if I is an odd number. 11059 11060 `ORD(X)' 11061 Returns the ordinal value of its argument. For example, the 11062 ordinal value of a character is its ASCII value (on machines 11063 supporting the ASCII character set). X must be of an ordered 11064 type, which include integral, character and enumerated types. 11065 11066 `SIZE(X)' 11067 Returns the size of its argument. X can be a variable or a type. 11068 11069 `TRUNC(R)' 11070 Returns the integral part of R. 11071 11072 `TSIZE(X)' 11073 Returns the size of its argument. X can be a variable or a type. 11074 11075 `VAL(T,I)' 11076 Returns the member of the type T whose ordinal value is I. 11077 11078 _Warning:_ Sets and their operations are not yet supported, so 11079 GDB treats the use of procedures `INCL' and `EXCL' as an error. 11080 11081 11082 File: gdb.info, Node: M2 Constants, Next: M2 Types, Prev: Built-In Func/Proc, Up: Modula-2 11083 11084 15.4.7.3 Constants 11085 .................. 11086 11087 GDB allows you to express the constants of Modula-2 in the following 11088 ways: 11089 11090 * Integer constants are simply a sequence of digits. When used in an 11091 expression, a constant is interpreted to be type-compatible with 11092 the rest of the expression. Hexadecimal integers are specified by 11093 a trailing `H', and octal integers by a trailing `B'. 11094 11095 * Floating point constants appear as a sequence of digits, followed 11096 by a decimal point and another sequence of digits. An optional 11097 exponent can then be specified, in the form `E[+|-]NNN', where 11098 `[+|-]NNN' is the desired exponent. All of the digits of the 11099 floating point constant must be valid decimal (base 10) digits. 11100 11101 * Character constants consist of a single character enclosed by a 11102 pair of like quotes, either single (`'') or double (`"'). They may 11103 also be expressed by their ordinal value (their ASCII value, 11104 usually) followed by a `C'. 11105 11106 * String constants consist of a sequence of characters enclosed by a 11107 pair of like quotes, either single (`'') or double (`"'). Escape 11108 sequences in the style of C are also allowed. *Note C and C++ 11109 Constants: C Constants, for a brief explanation of escape 11110 sequences. 11111 11112 * Enumerated constants consist of an enumerated identifier. 11113 11114 * Boolean constants consist of the identifiers `TRUE' and `FALSE'. 11115 11116 * Pointer constants consist of integral values only. 11117 11118 * Set constants are not yet supported. 11119 11120 11121 File: gdb.info, Node: M2 Types, Next: M2 Defaults, Prev: M2 Constants, Up: Modula-2 11122 11123 15.4.7.4 Modula-2 Types 11124 ....................... 11125 11126 Currently GDB can print the following data types in Modula-2 syntax: 11127 array types, record types, set types, pointer types, procedure types, 11128 enumerated types, subrange types and base types. You can also print 11129 the contents of variables declared using these type. This section 11130 gives a number of simple source code examples together with sample GDB 11131 sessions. 11132 11133 The first example contains the following section of code: 11134 11135 VAR 11136 s: SET OF CHAR ; 11137 r: [20..40] ; 11138 11139 and you can request GDB to interrogate the type and value of `r' and 11140 `s'. 11141 11142 (gdb) print s 11143 {'A'..'C', 'Z'} 11144 (gdb) ptype s 11145 SET OF CHAR 11146 (gdb) print r 11147 21 11148 (gdb) ptype r 11149 [20..40] 11150 11151 Likewise if your source code declares `s' as: 11152 11153 VAR 11154 s: SET ['A'..'Z'] ; 11155 11156 then you may query the type of `s' by: 11157 11158 (gdb) ptype s 11159 type = SET ['A'..'Z'] 11160 11161 Note that at present you cannot interactively manipulate set 11162 expressions using the debugger. 11163 11164 The following example shows how you might declare an array in 11165 Modula-2 and how you can interact with GDB to print its type and 11166 contents: 11167 11168 VAR 11169 s: ARRAY [-10..10] OF CHAR ; 11170 11171 (gdb) ptype s 11172 ARRAY [-10..10] OF CHAR 11173 11174 Note that the array handling is not yet complete and although the 11175 type is printed correctly, expression handling still assumes that all 11176 arrays have a lower bound of zero and not `-10' as in the example above. 11177 11178 Here are some more type related Modula-2 examples: 11179 11180 TYPE 11181 colour = (blue, red, yellow, green) ; 11182 t = [blue..yellow] ; 11183 VAR 11184 s: t ; 11185 BEGIN 11186 s := blue ; 11187 11188 The GDB interaction shows how you can query the data type and value of 11189 a variable. 11190 11191 (gdb) print s 11192 $1 = blue 11193 (gdb) ptype t 11194 type = [blue..yellow] 11195 11196 In this example a Modula-2 array is declared and its contents 11197 displayed. Observe that the contents are written in the same way as 11198 their `C' counterparts. 11199 11200 VAR 11201 s: ARRAY [1..5] OF CARDINAL ; 11202 BEGIN 11203 s[1] := 1 ; 11204 11205 (gdb) print s 11206 $1 = {1, 0, 0, 0, 0} 11207 (gdb) ptype s 11208 type = ARRAY [1..5] OF CARDINAL 11209 11210 The Modula-2 language interface to GDB also understands pointer 11211 types as shown in this example: 11212 11213 VAR 11214 s: POINTER TO ARRAY [1..5] OF CARDINAL ; 11215 BEGIN 11216 NEW(s) ; 11217 s^[1] := 1 ; 11218 11219 and you can request that GDB describes the type of `s'. 11220 11221 (gdb) ptype s 11222 type = POINTER TO ARRAY [1..5] OF CARDINAL 11223 11224 GDB handles compound types as we can see in this example. Here we 11225 combine array types, record types, pointer types and subrange types: 11226 11227 TYPE 11228 foo = RECORD 11229 f1: CARDINAL ; 11230 f2: CHAR ; 11231 f3: myarray ; 11232 END ; 11233 11234 myarray = ARRAY myrange OF CARDINAL ; 11235 myrange = [-2..2] ; 11236 VAR 11237 s: POINTER TO ARRAY myrange OF foo ; 11238 11239 and you can ask GDB to describe the type of `s' as shown below. 11240 11241 (gdb) ptype s 11242 type = POINTER TO ARRAY [-2..2] OF foo = RECORD 11243 f1 : CARDINAL; 11244 f2 : CHAR; 11245 f3 : ARRAY [-2..2] OF CARDINAL; 11246 END 11247 11248 11249 File: gdb.info, Node: M2 Defaults, Next: Deviations, Prev: M2 Types, Up: Modula-2 11250 11251 15.4.7.5 Modula-2 Defaults 11252 .......................... 11253 11254 If type and range checking are set automatically by GDB, they both 11255 default to `on' whenever the working language changes to Modula-2. 11256 This happens regardless of whether you or GDB selected the working 11257 language. 11258 11259 If you allow GDB to set the language automatically, then entering 11260 code compiled from a file whose name ends with `.mod' sets the working 11261 language to Modula-2. *Note Having GDB Infer the Source Language: 11262 Automatically, for further details. 11263 11264 11265 File: gdb.info, Node: Deviations, Next: M2 Checks, Prev: M2 Defaults, Up: Modula-2 11266 11267 15.4.7.6 Deviations from Standard Modula-2 11268 .......................................... 11269 11270 A few changes have been made to make Modula-2 programs easier to debug. 11271 This is done primarily via loosening its type strictness: 11272 11273 * Unlike in standard Modula-2, pointer constants can be formed by 11274 integers. This allows you to modify pointer variables during 11275 debugging. (In standard Modula-2, the actual address contained in 11276 a pointer variable is hidden from you; it can only be modified 11277 through direct assignment to another pointer variable or 11278 expression that returned a pointer.) 11279 11280 * C escape sequences can be used in strings and characters to 11281 represent non-printable characters. GDB prints out strings with 11282 these escape sequences embedded. Single non-printable characters 11283 are printed using the `CHR(NNN)' format. 11284 11285 * The assignment operator (`:=') returns the value of its right-hand 11286 argument. 11287 11288 * All built-in procedures both modify _and_ return their argument. 11289 11290 11291 File: gdb.info, Node: M2 Checks, Next: M2 Scope, Prev: Deviations, Up: Modula-2 11292 11293 15.4.7.7 Modula-2 Type and Range Checks 11294 ....................................... 11295 11296 _Warning:_ in this release, GDB does not yet perform type or range 11297 checking. 11298 11299 GDB considers two Modula-2 variables type equivalent if: 11300 11301 * They are of types that have been declared equivalent via a `TYPE 11302 T1 = T2' statement 11303 11304 * They have been declared on the same line. (Note: This is true of 11305 the GNU Modula-2 compiler, but it may not be true of other 11306 compilers.) 11307 11308 As long as type checking is enabled, any attempt to combine variables 11309 whose types are not equivalent is an error. 11310 11311 Range checking is done on all mathematical operations, assignment, 11312 array index bounds, and all built-in functions and procedures. 11313 11314 11315 File: gdb.info, Node: M2 Scope, Next: GDB/M2, Prev: M2 Checks, Up: Modula-2 11316 11317 15.4.7.8 The Scope Operators `::' and `.' 11318 ......................................... 11319 11320 There are a few subtle differences between the Modula-2 scope operator 11321 (`.') and the GDB scope operator (`::'). The two have similar syntax: 11322 11323 11324 MODULE . ID 11325 SCOPE :: ID 11326 11327 where SCOPE is the name of a module or a procedure, MODULE the name of 11328 a module, and ID is any declared identifier within your program, except 11329 another module. 11330 11331 Using the `::' operator makes GDB search the scope specified by 11332 SCOPE for the identifier ID. If it is not found in the specified 11333 scope, then GDB searches all scopes enclosing the one specified by 11334 SCOPE. 11335 11336 Using the `.' operator makes GDB search the current scope for the 11337 identifier specified by ID that was imported from the definition module 11338 specified by MODULE. With this operator, it is an error if the 11339 identifier ID was not imported from definition module MODULE, or if ID 11340 is not an identifier in MODULE. 11341 11342 11343 File: gdb.info, Node: GDB/M2, Prev: M2 Scope, Up: Modula-2 11344 11345 15.4.7.9 GDB and Modula-2 11346 ......................... 11347 11348 Some GDB commands have little use when debugging Modula-2 programs. 11349 Five subcommands of `set print' and `show print' apply specifically to 11350 C and C++: `vtbl', `demangle', `asm-demangle', `object', and `union'. 11351 The first four apply to C++, and the last to the C `union' type, which 11352 has no direct analogue in Modula-2. 11353 11354 The `@' operator (*note Expressions: Expressions.), while available 11355 with any language, is not useful with Modula-2. Its intent is to aid 11356 the debugging of "dynamic arrays", which cannot be created in Modula-2 11357 as they can in C or C++. However, because an address can be specified 11358 by an integral constant, the construct `{TYPE}ADREXP' is still useful. 11359 11360 In GDB scripts, the Modula-2 inequality operator `#' is interpreted 11361 as the beginning of a comment. Use `<>' instead. 11362 11363 11364 File: gdb.info, Node: Ada, Prev: Modula-2, Up: Supported Languages 11365 11366 15.4.8 Ada 11367 ---------- 11368 11369 The extensions made to GDB for Ada only support output from the GNU Ada 11370 (GNAT) compiler. Other Ada compilers are not currently supported, and 11371 attempting to debug executables produced by them is most likely to be 11372 difficult. 11373 11374 * Menu: 11375 11376 * Ada Mode Intro:: General remarks on the Ada syntax 11377 and semantics supported by Ada mode 11378 in GDB. 11379 * Omissions from Ada:: Restrictions on the Ada expression syntax. 11380 * Additions to Ada:: Extensions of the Ada expression syntax. 11381 * Stopping Before Main Program:: Debugging the program during elaboration. 11382 * Ada Tasks:: Listing and setting breakpoints in tasks. 11383 * Ada Tasks and Core Files:: Tasking Support when Debugging Core Files 11384 * Ravenscar Profile:: Tasking Support when using the Ravenscar 11385 Profile 11386 * Ada Glitches:: Known peculiarities of Ada mode. 11387 11388 11389 File: gdb.info, Node: Ada Mode Intro, Next: Omissions from Ada, Up: Ada 11390 11391 15.4.8.1 Introduction 11392 ..................... 11393 11394 The Ada mode of GDB supports a fairly large subset of Ada expression 11395 syntax, with some extensions. The philosophy behind the design of this 11396 subset is 11397 11398 * That GDB should provide basic literals and access to operations for 11399 arithmetic, dereferencing, field selection, indexing, and 11400 subprogram calls, leaving more sophisticated computations to 11401 subprograms written into the program (which therefore may be 11402 called from GDB). 11403 11404 * That type safety and strict adherence to Ada language restrictions 11405 are not particularly important to the GDB user. 11406 11407 * That brevity is important to the GDB user. 11408 11409 Thus, for brevity, the debugger acts as if all names declared in 11410 user-written packages are directly visible, even if they are not visible 11411 according to Ada rules, thus making it unnecessary to fully qualify most 11412 names with their packages, regardless of context. Where this causes 11413 ambiguity, GDB asks the user's intent. 11414 11415 The debugger will start in Ada mode if it detects an Ada main 11416 program. As for other languages, it will enter Ada mode when stopped 11417 in a program that was translated from an Ada source file. 11418 11419 While in Ada mode, you may use `-' for comments. This is useful 11420 mostly for documenting command files. The standard GDB comment (`#') 11421 still works at the beginning of a line in Ada mode, but not in the 11422 middle (to allow based literals). 11423 11424 The debugger supports limited overloading. Given a subprogram call 11425 in which the function symbol has multiple definitions, it will use the 11426 number of actual parameters and some information about their types to 11427 attempt to narrow the set of definitions. It also makes very limited 11428 use of context, preferring procedures to functions in the context of 11429 the `call' command, and functions to procedures elsewhere. 11430 11431 11432 File: gdb.info, Node: Omissions from Ada, Next: Additions to Ada, Prev: Ada Mode Intro, Up: Ada 11433 11434 15.4.8.2 Omissions from Ada 11435 ........................... 11436 11437 Here are the notable omissions from the subset: 11438 11439 * Only a subset of the attributes are supported: 11440 11441 - 'First, 'Last, and 'Length on array objects (not on types 11442 and subtypes). 11443 11444 - 'Min and 'Max. 11445 11446 - 'Pos and 'Val. 11447 11448 - 'Tag. 11449 11450 - 'Range on array objects (not subtypes), but only as the right 11451 operand of the membership (`in') operator. 11452 11453 - 'Access, 'Unchecked_Access, and 'Unrestricted_Access (a GNAT 11454 extension). 11455 11456 - 'Address. 11457 11458 * The names in `Characters.Latin_1' are not available and 11459 concatenation is not implemented. Thus, escape characters in 11460 strings are not currently available. 11461 11462 * Equality tests (`=' and `/=') on arrays test for bitwise equality 11463 of representations. They will generally work correctly for 11464 strings and arrays whose elements have integer or enumeration 11465 types. They may not work correctly for arrays whose element types 11466 have user-defined equality, for arrays of real values (in 11467 particular, IEEE-conformant floating point, because of negative 11468 zeroes and NaNs), and for arrays whose elements contain unused 11469 bits with indeterminate values. 11470 11471 * The other component-by-component array operations (`and', `or', 11472 `xor', `not', and relational tests other than equality) are not 11473 implemented. 11474 11475 * There is limited support for array and record aggregates. They are 11476 permitted only on the right sides of assignments, as in these 11477 examples: 11478 11479 (gdb) set An_Array := (1, 2, 3, 4, 5, 6) 11480 (gdb) set An_Array := (1, others => 0) 11481 (gdb) set An_Array := (0|4 => 1, 1..3 => 2, 5 => 6) 11482 (gdb) set A_2D_Array := ((1, 2, 3), (4, 5, 6), (7, 8, 9)) 11483 (gdb) set A_Record := (1, "Peter", True); 11484 (gdb) set A_Record := (Name => "Peter", Id => 1, Alive => True) 11485 11486 Changing a discriminant's value by assigning an aggregate has an 11487 undefined effect if that discriminant is used within the record. 11488 However, you can first modify discriminants by directly assigning 11489 to them (which normally would not be allowed in Ada), and then 11490 performing an aggregate assignment. For example, given a variable 11491 `A_Rec' declared to have a type such as: 11492 11493 type Rec (Len : Small_Integer := 0) is record 11494 Id : Integer; 11495 Vals : IntArray (1 .. Len); 11496 end record; 11497 11498 you can assign a value with a different size of `Vals' with two 11499 assignments: 11500 11501 (gdb) set A_Rec.Len := 4 11502 (gdb) set A_Rec := (Id => 42, Vals => (1, 2, 3, 4)) 11503 11504 As this example also illustrates, GDB is very loose about the usual 11505 rules concerning aggregates. You may leave out some of the 11506 components of an array or record aggregate (such as the `Len' 11507 component in the assignment to `A_Rec' above); they will retain 11508 their original values upon assignment. You may freely use dynamic 11509 values as indices in component associations. You may even use 11510 overlapping or redundant component associations, although which 11511 component values are assigned in such cases is not defined. 11512 11513 * Calls to dispatching subprograms are not implemented. 11514 11515 * The overloading algorithm is much more limited (i.e., less 11516 selective) than that of real Ada. It makes only limited use of 11517 the context in which a subexpression appears to resolve its 11518 meaning, and it is much looser in its rules for allowing type 11519 matches. As a result, some function calls will be ambiguous, and 11520 the user will be asked to choose the proper resolution. 11521 11522 * The `new' operator is not implemented. 11523 11524 * Entry calls are not implemented. 11525 11526 * Aside from printing, arithmetic operations on the native VAX 11527 floating-point formats are not supported. 11528 11529 * It is not possible to slice a packed array. 11530 11531 * The names `True' and `False', when not part of a qualified name, 11532 are interpreted as if implicitly prefixed by `Standard', 11533 regardless of context. Should your program redefine these names 11534 in a package or procedure (at best a dubious practice), you will 11535 have to use fully qualified names to access their new definitions. 11536 11537 11538 File: gdb.info, Node: Additions to Ada, Next: Stopping Before Main Program, Prev: Omissions from Ada, Up: Ada 11539 11540 15.4.8.3 Additions to Ada 11541 ......................... 11542 11543 As it does for other languages, GDB makes certain generic extensions to 11544 Ada (*note Expressions::): 11545 11546 * If the expression E is a variable residing in memory (typically a 11547 local variable or array element) and N is a positive integer, then 11548 `E@N' displays the values of E and the N-1 adjacent variables 11549 following it in memory as an array. In Ada, this operator is 11550 generally not necessary, since its prime use is in displaying 11551 parts of an array, and slicing will usually do this in Ada. 11552 However, there are occasional uses when debugging programs in 11553 which certain debugging information has been optimized away. 11554 11555 * `B::VAR' means "the variable named VAR that appears in function or 11556 file B." When B is a file name, you must typically surround it in 11557 single quotes. 11558 11559 * The expression `{TYPE} ADDR' means "the variable of type TYPE that 11560 appears at address ADDR." 11561 11562 * A name starting with `$' is a convenience variable (*note 11563 Convenience Vars::) or a machine register (*note Registers::). 11564 11565 In addition, GDB provides a few other shortcuts and outright 11566 additions specific to Ada: 11567 11568 * The assignment statement is allowed as an expression, returning 11569 its right-hand operand as its value. Thus, you may enter 11570 11571 (gdb) set x := y + 3 11572 (gdb) print A(tmp := y + 1) 11573 11574 * The semicolon is allowed as an "operator," returning as its value 11575 the value of its right-hand operand. This allows, for example, 11576 complex conditional breaks: 11577 11578 (gdb) break f 11579 (gdb) condition 1 (report(i); k += 1; A(k) > 100) 11580 11581 * Rather than use catenation and symbolic character names to 11582 introduce special characters into strings, one may instead use a 11583 special bracket notation, which is also used to print strings. A 11584 sequence of characters of the form `["XX"]' within a string or 11585 character literal denotes the (single) character whose numeric 11586 encoding is XX in hexadecimal. The sequence of characters `["""]' 11587 also denotes a single quotation mark in strings. For example, 11588 "One line.["0a"]Next line.["0a"]" 11589 contains an ASCII newline character (`Ada.Characters.Latin_1.LF') 11590 after each period. 11591 11592 * The subtype used as a prefix for the attributes 'Pos, 'Min, and 11593 'Max is optional (and is ignored in any case). For example, it is 11594 valid to write 11595 11596 (gdb) print 'max(x, y) 11597 11598 * When printing arrays, GDB uses positional notation when the array 11599 has a lower bound of 1, and uses a modified named notation 11600 otherwise. For example, a one-dimensional array of three integers 11601 with a lower bound of 3 might print as 11602 11603 (3 => 10, 17, 1) 11604 11605 That is, in contrast to valid Ada, only the first component has a 11606 `=>' clause. 11607 11608 * You may abbreviate attributes in expressions with any unique, 11609 multi-character subsequence of their names (an exact match gets 11610 preference). For example, you may use a'len, a'gth, or a'lh in 11611 place of a'length. 11612 11613 * Since Ada is case-insensitive, the debugger normally maps 11614 identifiers you type to lower case. The GNAT compiler uses 11615 upper-case characters for some of its internal identifiers, which 11616 are normally of no interest to users. For the rare occasions when 11617 you actually have to look at them, enclose them in angle brackets 11618 to avoid the lower-case mapping. For example, 11619 (gdb) print <JMPBUF_SAVE>[0] 11620 11621 * Printing an object of class-wide type or dereferencing an 11622 access-to-class-wide value will display all the components of the 11623 object's specific type (as indicated by its run-time tag). 11624 Likewise, component selection on such a value will operate on the 11625 specific type of the object. 11626 11627 11628 11629 File: gdb.info, Node: Stopping Before Main Program, Next: Ada Tasks, Prev: Additions to Ada, Up: Ada 11630 11631 15.4.8.4 Stopping at the Very Beginning 11632 ....................................... 11633 11634 It is sometimes necessary to debug the program during elaboration, and 11635 before reaching the main procedure. As defined in the Ada Reference 11636 Manual, the elaboration code is invoked from a procedure called 11637 `adainit'. To run your program up to the beginning of elaboration, 11638 simply use the following two commands: `tbreak adainit' and `run'. 11639 11640 11641 File: gdb.info, Node: Ada Tasks, Next: Ada Tasks and Core Files, Prev: Stopping Before Main Program, Up: Ada 11642 11643 15.4.8.5 Extensions for Ada Tasks 11644 ................................. 11645 11646 Support for Ada tasks is analogous to that for threads (*note 11647 Threads::). GDB provides the following task-related commands: 11648 11649 `info tasks' 11650 This command shows a list of current Ada tasks, as in the 11651 following example: 11652 11653 (gdb) info tasks 11654 ID TID P-ID Pri State Name 11655 1 8088000 0 15 Child Activation Wait main_task 11656 2 80a4000 1 15 Accept Statement b 11657 3 809a800 1 15 Child Activation Wait a 11658 * 4 80ae800 3 15 Runnable c 11659 11660 In this listing, the asterisk before the last task indicates it to 11661 be the task currently being inspected. 11662 11663 ID 11664 Represents GDB's internal task number. 11665 11666 TID 11667 The Ada task ID. 11668 11669 P-ID 11670 The parent's task ID (GDB's internal task number). 11671 11672 Pri 11673 The base priority of the task. 11674 11675 State 11676 Current state of the task. 11677 11678 `Unactivated' 11679 The task has been created but has not been activated. 11680 It cannot be executing. 11681 11682 `Runnable' 11683 The task is not blocked for any reason known to Ada. 11684 (It may be waiting for a mutex, though.) It is 11685 conceptually "executing" in normal mode. 11686 11687 `Terminated' 11688 The task is terminated, in the sense of ARM 9.3 (5). 11689 Any dependents that were waiting on terminate 11690 alternatives have been awakened and have terminated 11691 themselves. 11692 11693 `Child Activation Wait' 11694 The task is waiting for created tasks to complete 11695 activation. 11696 11697 `Accept Statement' 11698 The task is waiting on an accept or selective wait 11699 statement. 11700 11701 `Waiting on entry call' 11702 The task is waiting on an entry call. 11703 11704 `Async Select Wait' 11705 The task is waiting to start the abortable part of an 11706 asynchronous select statement. 11707 11708 `Delay Sleep' 11709 The task is waiting on a select statement with only a 11710 delay alternative open. 11711 11712 `Child Termination Wait' 11713 The task is sleeping having completed a master within 11714 itself, and is waiting for the tasks dependent on that 11715 master to become terminated or waiting on a terminate 11716 Phase. 11717 11718 `Wait Child in Term Alt' 11719 The task is sleeping waiting for tasks on terminate 11720 alternatives to finish terminating. 11721 11722 `Accepting RV with TASKNO' 11723 The task is accepting a rendez-vous with the task TASKNO. 11724 11725 Name 11726 Name of the task in the program. 11727 11728 11729 `info task TASKNO' 11730 This command shows detailled informations on the specified task, 11731 as in the following example: 11732 (gdb) info tasks 11733 ID TID P-ID Pri State Name 11734 1 8077880 0 15 Child Activation Wait main_task 11735 * 2 807c468 1 15 Runnable task_1 11736 (gdb) info task 2 11737 Ada Task: 0x807c468 11738 Name: task_1 11739 Thread: 0x807f378 11740 Parent: 1 (main_task) 11741 Base Priority: 15 11742 State: Runnable 11743 11744 `task' 11745 This command prints the ID of the current task. 11746 11747 (gdb) info tasks 11748 ID TID P-ID Pri State Name 11749 1 8077870 0 15 Child Activation Wait main_task 11750 * 2 807c458 1 15 Runnable t 11751 (gdb) task 11752 [Current task is 2] 11753 11754 `task TASKNO' 11755 This command is like the `thread THREADNO' command (*note 11756 Threads::). It switches the context of debugging from the current 11757 task to the given task. 11758 11759 (gdb) info tasks 11760 ID TID P-ID Pri State Name 11761 1 8077870 0 15 Child Activation Wait main_task 11762 * 2 807c458 1 15 Runnable t 11763 (gdb) task 1 11764 [Switching to task 1] 11765 #0 0x8067726 in pthread_cond_wait () 11766 (gdb) bt 11767 #0 0x8067726 in pthread_cond_wait () 11768 #1 0x8056714 in system.os_interface.pthread_cond_wait () 11769 #2 0x805cb63 in system.task_primitives.operations.sleep () 11770 #3 0x806153e in system.tasking.stages.activate_tasks () 11771 #4 0x804aacc in un () at un.adb:5 11772 11773 `break LINESPEC task TASKNO' 11774 `break LINESPEC task TASKNO if ...' 11775 These commands are like the `break ... thread ...' command (*note 11776 Thread Stops::). LINESPEC specifies source lines, as described in 11777 *note Specify Location::. 11778 11779 Use the qualifier `task TASKNO' with a breakpoint command to 11780 specify that you only want GDB to stop the program when a 11781 particular Ada task reaches this breakpoint. TASKNO is one of the 11782 numeric task identifiers assigned by GDB, shown in the first 11783 column of the `info tasks' display. 11784 11785 If you do not specify `task TASKNO' when you set a breakpoint, the 11786 breakpoint applies to _all_ tasks of your program. 11787 11788 You can use the `task' qualifier on conditional breakpoints as 11789 well; in this case, place `task TASKNO' before the breakpoint 11790 condition (before the `if'). 11791 11792 For example, 11793 11794 (gdb) info tasks 11795 ID TID P-ID Pri State Name 11796 1 140022020 0 15 Child Activation Wait main_task 11797 2 140045060 1 15 Accept/Select Wait t2 11798 3 140044840 1 15 Runnable t1 11799 * 4 140056040 1 15 Runnable t3 11800 (gdb) b 15 task 2 11801 Breakpoint 5 at 0x120044cb0: file test_task_debug.adb, line 15. 11802 (gdb) cont 11803 Continuing. 11804 task # 1 running 11805 task # 2 running 11806 11807 Breakpoint 5, test_task_debug () at test_task_debug.adb:15 11808 15 flush; 11809 (gdb) info tasks 11810 ID TID P-ID Pri State Name 11811 1 140022020 0 15 Child Activation Wait main_task 11812 * 2 140045060 1 15 Runnable t2 11813 3 140044840 1 15 Runnable t1 11814 4 140056040 1 15 Delay Sleep t3 11815 11816 11817 File: gdb.info, Node: Ada Tasks and Core Files, Next: Ravenscar Profile, Prev: Ada Tasks, Up: Ada 11818 11819 15.4.8.6 Tasking Support when Debugging Core Files 11820 .................................................. 11821 11822 When inspecting a core file, as opposed to debugging a live program, 11823 tasking support may be limited or even unavailable, depending on the 11824 platform being used. For instance, on x86-linux, the list of tasks is 11825 available, but task switching is not supported. On Tru64, however, 11826 task switching will work as usual. 11827 11828 On certain platforms, including Tru64, the debugger needs to perform 11829 some memory writes in order to provide Ada tasking support. When 11830 inspecting a core file, this means that the core file must be opened 11831 with read-write privileges, using the command `"set write on"' (*note 11832 Patching::). Under these circumstances, you should make a backup copy 11833 of the core file before inspecting it with GDB. 11834 11835 11836 File: gdb.info, Node: Ravenscar Profile, Next: Ada Glitches, Prev: Ada Tasks and Core Files, Up: Ada 11837 11838 15.4.8.7 Tasking Support when using the Ravenscar Profile 11839 ......................................................... 11840 11841 The "Ravenscar Profile" is a subset of the Ada tasking features, 11842 specifically designed for systems with safety-critical real-time 11843 requirements. 11844 11845 `set ravenscar task-switching on' 11846 Allows task switching when debugging a program that uses the 11847 Ravenscar Profile. This is the default. 11848 11849 `set ravenscar task-switching off' 11850 Turn off task switching when debugging a program that uses the 11851 Ravenscar Profile. This is mostly intended to disable the code 11852 that adds support for the Ravenscar Profile, in case a bug in 11853 either GDB or in the Ravenscar runtime is preventing GDB from 11854 working properly. To be effective, this command should be run 11855 before the program is started. 11856 11857 `show ravenscar task-switching' 11858 Show whether it is possible to switch from task to task in a 11859 program using the Ravenscar Profile. 11860 11861 11862 11863 File: gdb.info, Node: Ada Glitches, Prev: Ravenscar Profile, Up: Ada 11864 11865 15.4.8.8 Known Peculiarities of Ada Mode 11866 ........................................ 11867 11868 Besides the omissions listed previously (*note Omissions from Ada::), 11869 we know of several problems with and limitations of Ada mode in GDB, 11870 some of which will be fixed with planned future releases of the debugger 11871 and the GNU Ada compiler. 11872 11873 * Static constants that the compiler chooses not to materialize as 11874 objects in storage are invisible to the debugger. 11875 11876 * Named parameter associations in function argument lists are 11877 ignored (the argument lists are treated as positional). 11878 11879 * Many useful library packages are currently invisible to the 11880 debugger. 11881 11882 * Fixed-point arithmetic, conversions, input, and output is carried 11883 out using floating-point arithmetic, and may give results that 11884 only approximate those on the host machine. 11885 11886 * The GNAT compiler never generates the prefix `Standard' for any of 11887 the standard symbols defined by the Ada language. GDB knows about 11888 this: it will strip the prefix from names when you use it, and 11889 will never look for a name you have so qualified among local 11890 symbols, nor match against symbols in other packages or 11891 subprograms. If you have defined entities anywhere in your 11892 program other than parameters and local variables whose simple 11893 names match names in `Standard', GNAT's lack of qualification here 11894 can cause confusion. When this happens, you can usually resolve 11895 the confusion by qualifying the problematic names with package 11896 `Standard' explicitly. 11897 11898 Older versions of the compiler sometimes generate erroneous debugging 11899 information, resulting in the debugger incorrectly printing the value 11900 of affected entities. In some cases, the debugger is able to work 11901 around an issue automatically. In other cases, the debugger is able to 11902 work around the issue, but the work-around has to be specifically 11903 enabled. 11904 11905 `set ada trust-PAD-over-XVS on' 11906 Configure GDB to strictly follow the GNAT encoding when computing 11907 the value of Ada entities, particularly when `PAD' and `PAD___XVS' 11908 types are involved (see `ada/exp_dbug.ads' in the GCC sources for 11909 a complete description of the encoding used by the GNAT compiler). 11910 This is the default. 11911 11912 `set ada trust-PAD-over-XVS off' 11913 This is related to the encoding using by the GNAT compiler. If 11914 GDB sometimes prints the wrong value for certain entities, 11915 changing `ada trust-PAD-over-XVS' to `off' activates a work-around 11916 which may fix the issue. It is always safe to set `ada 11917 trust-PAD-over-XVS' to `off', but this incurs a slight performance 11918 penalty, so it is recommended to leave this setting to `on' unless 11919 necessary. 11920 11921 11922 11923 File: gdb.info, Node: Unsupported Languages, Prev: Supported Languages, Up: Languages 11924 11925 15.5 Unsupported Languages 11926 ========================== 11927 11928 In addition to the other fully-supported programming languages, GDB 11929 also provides a pseudo-language, called `minimal'. It does not 11930 represent a real programming language, but provides a set of 11931 capabilities close to what the C or assembly languages provide. This 11932 should allow most simple operations to be performed while debugging an 11933 application that uses a language currently not supported by GDB. 11934 11935 If the language is set to `auto', GDB will automatically select this 11936 language if the current frame corresponds to an unsupported language. 11937 11938 11939 File: gdb.info, Node: Symbols, Next: Altering, Prev: Languages, Up: Top 11940 11941 16 Examining the Symbol Table 11942 ***************************** 11943 11944 The commands described in this chapter allow you to inquire about the 11945 symbols (names of variables, functions and types) defined in your 11946 program. This information is inherent in the text of your program and 11947 does not change as your program executes. GDB finds it in your 11948 program's symbol table, in the file indicated when you started GDB 11949 (*note Choosing Files: File Options.), or by one of the file-management 11950 commands (*note Commands to Specify Files: Files.). 11951 11952 Occasionally, you may need to refer to symbols that contain unusual 11953 characters, which GDB ordinarily treats as word delimiters. The most 11954 frequent case is in referring to static variables in other source files 11955 (*note Program Variables: Variables.). File names are recorded in 11956 object files as debugging symbols, but GDB would ordinarily parse a 11957 typical file name, like `foo.c', as the three words `foo' `.' `c'. To 11958 allow GDB to recognize `foo.c' as a single symbol, enclose it in single 11959 quotes; for example, 11960 11961 p 'foo.c'::x 11962 11963 looks up the value of `x' in the scope of the file `foo.c'. 11964 11965 `set case-sensitive on' 11966 `set case-sensitive off' 11967 `set case-sensitive auto' 11968 Normally, when GDB looks up symbols, it matches their names with 11969 case sensitivity determined by the current source language. 11970 Occasionally, you may wish to control that. The command `set 11971 case-sensitive' lets you do that by specifying `on' for 11972 case-sensitive matches or `off' for case-insensitive ones. If you 11973 specify `auto', case sensitivity is reset to the default suitable 11974 for the source language. The default is case-sensitive matches 11975 for all languages except for Fortran, for which the default is 11976 case-insensitive matches. 11977 11978 `show case-sensitive' 11979 This command shows the current setting of case sensitivity for 11980 symbols lookups. 11981 11982 `info address SYMBOL' 11983 Describe where the data for SYMBOL is stored. For a register 11984 variable, this says which register it is kept in. For a 11985 non-register local variable, this prints the stack-frame offset at 11986 which the variable is always stored. 11987 11988 Note the contrast with `print &SYMBOL', which does not work at all 11989 for a register variable, and for a stack local variable prints the 11990 exact address of the current instantiation of the variable. 11991 11992 `info symbol ADDR' 11993 Print the name of a symbol which is stored at the address ADDR. 11994 If no symbol is stored exactly at ADDR, GDB prints the nearest 11995 symbol and an offset from it: 11996 11997 (gdb) info symbol 0x54320 11998 _initialize_vx + 396 in section .text 11999 12000 This is the opposite of the `info address' command. You can use 12001 it to find out the name of a variable or a function given its 12002 address. 12003 12004 For dynamically linked executables, the name of executable or 12005 shared library containing the symbol is also printed: 12006 12007 (gdb) info symbol 0x400225 12008 _start + 5 in section .text of /tmp/a.out 12009 (gdb) info symbol 0x2aaaac2811cf 12010 __read_nocancel + 6 in section .text of /usr/lib64/libc.so.6 12011 12012 `whatis [ARG]' 12013 Print the data type of ARG, which can be either an expression or a 12014 data type. With no argument, print the data type of `$', the last 12015 value in the value history. If ARG is an expression, it is not 12016 actually evaluated, and any side-effecting operations (such as 12017 assignments or function calls) inside it do not take place. If 12018 ARG is a type name, it may be the name of a type or typedef, or 12019 for C code it may have the form `class CLASS-NAME', `struct 12020 STRUCT-TAG', `union UNION-TAG' or `enum ENUM-TAG'. *Note 12021 Expressions: Expressions. 12022 12023 `ptype [ARG]' 12024 `ptype' accepts the same arguments as `whatis', but prints a 12025 detailed description of the type, instead of just the name of the 12026 type. *Note Expressions: Expressions. 12027 12028 For example, for this variable declaration: 12029 12030 struct complex {double real; double imag;} v; 12031 12032 the two commands give this output: 12033 12034 (gdb) whatis v 12035 type = struct complex 12036 (gdb) ptype v 12037 type = struct complex { 12038 double real; 12039 double imag; 12040 } 12041 12042 As with `whatis', using `ptype' without an argument refers to the 12043 type of `$', the last value in the value history. 12044 12045 Sometimes, programs use opaque data types or incomplete 12046 specifications of complex data structure. If the debug 12047 information included in the program does not allow GDB to display 12048 a full declaration of the data type, it will say `<incomplete 12049 type>'. For example, given these declarations: 12050 12051 struct foo; 12052 struct foo *fooptr; 12053 12054 but no definition for `struct foo' itself, GDB will say: 12055 12056 (gdb) ptype foo 12057 $1 = <incomplete type> 12058 12059 "Incomplete type" is C terminology for data types that are not 12060 completely specified. 12061 12062 `info types REGEXP' 12063 `info types' 12064 Print a brief description of all types whose names match the 12065 regular expression REGEXP (or all types in your program, if you 12066 supply no argument). Each complete typename is matched as though 12067 it were a complete line; thus, `i type value' gives information on 12068 all types in your program whose names include the string `value', 12069 but `i type ^value$' gives information only on types whose complete 12070 name is `value'. 12071 12072 This command differs from `ptype' in two ways: first, like 12073 `whatis', it does not print a detailed description; second, it 12074 lists all source files where a type is defined. 12075 12076 `info scope LOCATION' 12077 List all the variables local to a particular scope. This command 12078 accepts a LOCATION argument--a function name, a source line, or an 12079 address preceded by a `*', and prints all the variables local to 12080 the scope defined by that location. (*Note Specify Location::, for 12081 details about supported forms of LOCATION.) For example: 12082 12083 (gdb) info scope command_line_handler 12084 Scope for command_line_handler: 12085 Symbol rl is an argument at stack/frame offset 8, length 4. 12086 Symbol linebuffer is in static storage at address 0x150a18, length 4. 12087 Symbol linelength is in static storage at address 0x150a1c, length 4. 12088 Symbol p is a local variable in register $esi, length 4. 12089 Symbol p1 is a local variable in register $ebx, length 4. 12090 Symbol nline is a local variable in register $edx, length 4. 12091 Symbol repeat is a local variable at frame offset -8, length 4. 12092 12093 This command is especially useful for determining what data to 12094 collect during a "trace experiment", see *note collect: Tracepoint 12095 Actions. 12096 12097 `info source' 12098 Show information about the current source file--that is, the 12099 source file for the function containing the current point of 12100 execution: 12101 * the name of the source file, and the directory containing it, 12102 12103 * the directory it was compiled in, 12104 12105 * its length, in lines, 12106 12107 * which programming language it is written in, 12108 12109 * whether the executable includes debugging information for 12110 that file, and if so, what format the information is in 12111 (e.g., STABS, Dwarf 2, etc.), and 12112 12113 * whether the debugging information includes information about 12114 preprocessor macros. 12115 12116 `info sources' 12117 Print the names of all source files in your program for which 12118 there is debugging information, organized into two lists: files 12119 whose symbols have already been read, and files whose symbols will 12120 be read when needed. 12121 12122 `info functions' 12123 Print the names and data types of all defined functions. 12124 12125 `info functions REGEXP' 12126 Print the names and data types of all defined functions whose 12127 names contain a match for regular expression REGEXP. Thus, `info 12128 fun step' finds all functions whose names include `step'; `info 12129 fun ^step' finds those whose names start with `step'. If a 12130 function name contains characters that conflict with the regular 12131 expression language (e.g. `operator*()'), they may be quoted with 12132 a backslash. 12133 12134 `info variables' 12135 Print the names and data types of all variables that are defined 12136 outside of functions (i.e. excluding local variables). 12137 12138 `info variables REGEXP' 12139 Print the names and data types of all variables (except for local 12140 variables) whose names contain a match for regular expression 12141 REGEXP. 12142 12143 `info classes' 12144 `info classes REGEXP' 12145 Display all Objective-C classes in your program, or (with the 12146 REGEXP argument) all those matching a particular regular 12147 expression. 12148 12149 `info selectors' 12150 `info selectors REGEXP' 12151 Display all Objective-C selectors in your program, or (with the 12152 REGEXP argument) all those matching a particular regular 12153 expression. 12154 12155 Some systems allow individual object files that make up your 12156 program to be replaced without stopping and restarting your 12157 program. For example, in VxWorks you can simply recompile a 12158 defective object file and keep on running. If you are running on 12159 one of these systems, you can allow GDB to reload the symbols for 12160 automatically relinked modules: 12161 12162 `set symbol-reloading on' 12163 Replace symbol definitions for the corresponding source file 12164 when an object file with a particular name is seen again. 12165 12166 `set symbol-reloading off' 12167 Do not replace symbol definitions when encountering object 12168 files of the same name more than once. This is the default 12169 state; if you are not running on a system that permits 12170 automatic relinking of modules, you should leave 12171 `symbol-reloading' off, since otherwise GDB may discard 12172 symbols when linking large programs, that may contain several 12173 modules (from different directories or libraries) with the 12174 same name. 12175 12176 `show symbol-reloading' 12177 Show the current `on' or `off' setting. 12178 12179 `set opaque-type-resolution on' 12180 Tell GDB to resolve opaque types. An opaque type is a type 12181 declared as a pointer to a `struct', `class', or `union'--for 12182 example, `struct MyType *'--that is used in one source file 12183 although the full declaration of `struct MyType' is in another 12184 source file. The default is on. 12185 12186 A change in the setting of this subcommand will not take effect 12187 until the next time symbols for a file are loaded. 12188 12189 `set opaque-type-resolution off' 12190 Tell GDB not to resolve opaque types. In this case, the type is 12191 printed as follows: 12192 {<no data fields>} 12193 12194 `show opaque-type-resolution' 12195 Show whether opaque types are resolved or not. 12196 12197 `set print symbol-loading' 12198 `set print symbol-loading on' 12199 `set print symbol-loading off' 12200 The `set print symbol-loading' command allows you to enable or 12201 disable printing of messages when GDB loads symbols. By default, 12202 these messages will be printed, and normally this is what you 12203 want. Disabling these messages is useful when debugging 12204 applications with lots of shared libraries where the quantity of 12205 output can be more annoying than useful. 12206 12207 `show print symbol-loading' 12208 Show whether messages will be printed when GDB loads symbols. 12209 12210 `maint print symbols FILENAME' 12211 `maint print psymbols FILENAME' 12212 `maint print msymbols FILENAME' 12213 Write a dump of debugging symbol data into the file FILENAME. 12214 These commands are used to debug the GDB symbol-reading code. Only 12215 symbols with debugging data are included. If you use `maint print 12216 symbols', GDB includes all the symbols for which it has already 12217 collected full details: that is, FILENAME reflects symbols for 12218 only those files whose symbols GDB has read. You can use the 12219 command `info sources' to find out which files these are. If you 12220 use `maint print psymbols' instead, the dump shows information 12221 about symbols that GDB only knows partially--that is, symbols 12222 defined in files that GDB has skimmed, but not yet read 12223 completely. Finally, `maint print msymbols' dumps just the 12224 minimal symbol information required for each object file from 12225 which GDB has read some symbols. *Note Commands to Specify Files: 12226 Files, for a discussion of how GDB reads symbols (in the 12227 description of `symbol-file'). 12228 12229 `maint info symtabs [ REGEXP ]' 12230 `maint info psymtabs [ REGEXP ]' 12231 List the `struct symtab' or `struct partial_symtab' structures 12232 whose names match REGEXP. If REGEXP is not given, list them all. 12233 The output includes expressions which you can copy into a GDB 12234 debugging this one to examine a particular structure in more 12235 detail. For example: 12236 12237 (gdb) maint info psymtabs dwarf2read 12238 { objfile /home/gnu/build/gdb/gdb 12239 ((struct objfile *) 0x82e69d0) 12240 { psymtab /home/gnu/src/gdb/dwarf2read.c 12241 ((struct partial_symtab *) 0x8474b10) 12242 readin no 12243 fullname (null) 12244 text addresses 0x814d3c8 -- 0x8158074 12245 globals (* (struct partial_symbol **) 0x8507a08 @ 9) 12246 statics (* (struct partial_symbol **) 0x40e95b78 @ 2882) 12247 dependencies (none) 12248 } 12249 } 12250 (gdb) maint info symtabs 12251 (gdb) 12252 We see that there is one partial symbol table whose filename 12253 contains the string `dwarf2read', belonging to the `gdb' 12254 executable; and we see that GDB has not read in any symtabs yet at 12255 all. If we set a breakpoint on a function, that will cause GDB to 12256 read the symtab for the compilation unit containing that function: 12257 12258 (gdb) break dwarf2_psymtab_to_symtab 12259 Breakpoint 1 at 0x814e5da: file /home/gnu/src/gdb/dwarf2read.c, 12260 line 1574. 12261 (gdb) maint info symtabs 12262 { objfile /home/gnu/build/gdb/gdb 12263 ((struct objfile *) 0x82e69d0) 12264 { symtab /home/gnu/src/gdb/dwarf2read.c 12265 ((struct symtab *) 0x86c1f38) 12266 dirname (null) 12267 fullname (null) 12268 blockvector ((struct blockvector *) 0x86c1bd0) (primary) 12269 linetable ((struct linetable *) 0x8370fa0) 12270 debugformat DWARF 2 12271 } 12272 } 12273 (gdb) 12274 12275 12276 File: gdb.info, Node: Altering, Next: GDB Files, Prev: Symbols, Up: Top 12277 12278 17 Altering Execution 12279 ********************* 12280 12281 Once you think you have found an error in your program, you might want 12282 to find out for certain whether correcting the apparent error would 12283 lead to correct results in the rest of the run. You can find the 12284 answer by experiment, using the GDB features for altering execution of 12285 the program. 12286 12287 For example, you can store new values into variables or memory 12288 locations, give your program a signal, restart it at a different 12289 address, or even return prematurely from a function. 12290 12291 * Menu: 12292 12293 * Assignment:: Assignment to variables 12294 * Jumping:: Continuing at a different address 12295 * Signaling:: Giving your program a signal 12296 * Returning:: Returning from a function 12297 * Calling:: Calling your program's functions 12298 * Patching:: Patching your program 12299 12300 12301 File: gdb.info, Node: Assignment, Next: Jumping, Up: Altering 12302 12303 17.1 Assignment to Variables 12304 ============================ 12305 12306 To alter the value of a variable, evaluate an assignment expression. 12307 *Note Expressions: Expressions. For example, 12308 12309 print x=4 12310 12311 stores the value 4 into the variable `x', and then prints the value of 12312 the assignment expression (which is 4). *Note Using GDB with Different 12313 Languages: Languages, for more information on operators in supported 12314 languages. 12315 12316 If you are not interested in seeing the value of the assignment, use 12317 the `set' command instead of the `print' command. `set' is really the 12318 same as `print' except that the expression's value is not printed and 12319 is not put in the value history (*note Value History: Value History.). 12320 The expression is evaluated only for its effects. 12321 12322 If the beginning of the argument string of the `set' command appears 12323 identical to a `set' subcommand, use the `set variable' command instead 12324 of just `set'. This command is identical to `set' except for its lack 12325 of subcommands. For example, if your program has a variable `width', 12326 you get an error if you try to set a new value with just `set 12327 width=13', because GDB has the command `set width': 12328 12329 (gdb) whatis width 12330 type = double 12331 (gdb) p width 12332 $4 = 13 12333 (gdb) set width=47 12334 Invalid syntax in expression. 12335 12336 The invalid expression, of course, is `=47'. In order to actually set 12337 the program's variable `width', use 12338 12339 (gdb) set var width=47 12340 12341 Because the `set' command has many subcommands that can conflict 12342 with the names of program variables, it is a good idea to use the `set 12343 variable' command instead of just `set'. For example, if your program 12344 has a variable `g', you run into problems if you try to set a new value 12345 with just `set g=4', because GDB has the command `set gnutarget', 12346 abbreviated `set g': 12347 12348 (gdb) whatis g 12349 type = double 12350 (gdb) p g 12351 $1 = 1 12352 (gdb) set g=4 12353 (gdb) p g 12354 $2 = 1 12355 (gdb) r 12356 The program being debugged has been started already. 12357 Start it from the beginning? (y or n) y 12358 Starting program: /home/smith/cc_progs/a.out 12359 "/home/smith/cc_progs/a.out": can't open to read symbols: 12360 Invalid bfd target. 12361 (gdb) show g 12362 The current BFD target is "=4". 12363 12364 The program variable `g' did not change, and you silently set the 12365 `gnutarget' to an invalid value. In order to set the variable `g', use 12366 12367 (gdb) set var g=4 12368 12369 GDB allows more implicit conversions in assignments than C; you can 12370 freely store an integer value into a pointer variable or vice versa, 12371 and you can convert any structure to any other structure that is the 12372 same length or shorter. 12373 12374 To store values into arbitrary places in memory, use the `{...}' 12375 construct to generate a value of specified type at a specified address 12376 (*note Expressions: Expressions.). For example, `{int}0x83040' refers 12377 to memory location `0x83040' as an integer (which implies a certain size 12378 and representation in memory), and 12379 12380 set {int}0x83040 = 4 12381 12382 stores the value 4 into that memory location. 12383 12384 12385 File: gdb.info, Node: Jumping, Next: Signaling, Prev: Assignment, Up: Altering 12386 12387 17.2 Continuing at a Different Address 12388 ====================================== 12389 12390 Ordinarily, when you continue your program, you do so at the place where 12391 it stopped, with the `continue' command. You can instead continue at 12392 an address of your own choosing, with the following commands: 12393 12394 `jump LINESPEC' 12395 `jump LOCATION' 12396 Resume execution at line LINESPEC or at address given by LOCATION. 12397 Execution stops again immediately if there is a breakpoint there. 12398 *Note Specify Location::, for a description of the different forms 12399 of LINESPEC and LOCATION. It is common practice to use the 12400 `tbreak' command in conjunction with `jump'. *Note Setting 12401 Breakpoints: Set Breaks. 12402 12403 The `jump' command does not change the current stack frame, or the 12404 stack pointer, or the contents of any memory location or any 12405 register other than the program counter. If line LINESPEC is in a 12406 different function from the one currently executing, the results 12407 may be bizarre if the two functions expect different patterns of 12408 arguments or of local variables. For this reason, the `jump' 12409 command requests confirmation if the specified line is not in the 12410 function currently executing. However, even bizarre results are 12411 predictable if you are well acquainted with the machine-language 12412 code of your program. 12413 12414 On many systems, you can get much the same effect as the `jump' 12415 command by storing a new value into the register `$pc'. The difference 12416 is that this does not start your program running; it only changes the 12417 address of where it _will_ run when you continue. For example, 12418 12419 set $pc = 0x485 12420 12421 makes the next `continue' command or stepping command execute at 12422 address `0x485', rather than at the address where your program stopped. 12423 *Note Continuing and Stepping: Continuing and Stepping. 12424 12425 The most common occasion to use the `jump' command is to back 12426 up--perhaps with more breakpoints set--over a portion of a program that 12427 has already executed, in order to examine its execution in more detail. 12428 12429 12430 File: gdb.info, Node: Signaling, Next: Returning, Prev: Jumping, Up: Altering 12431 12432 17.3 Giving your Program a Signal 12433 ================================= 12434 12435 `signal SIGNAL' 12436 Resume execution where your program stopped, but immediately give 12437 it the signal SIGNAL. SIGNAL can be the name or the number of a 12438 signal. For example, on many systems `signal 2' and `signal 12439 SIGINT' are both ways of sending an interrupt signal. 12440 12441 Alternatively, if SIGNAL is zero, continue execution without 12442 giving a signal. This is useful when your program stopped on 12443 account of a signal and would ordinary see the signal when resumed 12444 with the `continue' command; `signal 0' causes it to resume 12445 without a signal. 12446 12447 `signal' does not repeat when you press <RET> a second time after 12448 executing the command. 12449 12450 Invoking the `signal' command is not the same as invoking the `kill' 12451 utility from the shell. Sending a signal with `kill' causes GDB to 12452 decide what to do with the signal depending on the signal handling 12453 tables (*note Signals::). The `signal' command passes the signal 12454 directly to your program. 12455 12456 12457 File: gdb.info, Node: Returning, Next: Calling, Prev: Signaling, Up: Altering 12458 12459 17.4 Returning from a Function 12460 ============================== 12461 12462 `return' 12463 `return EXPRESSION' 12464 You can cancel execution of a function call with the `return' 12465 command. If you give an EXPRESSION argument, its value is used as 12466 the function's return value. 12467 12468 When you use `return', GDB discards the selected stack frame (and 12469 all frames within it). You can think of this as making the discarded 12470 frame return prematurely. If you wish to specify a value to be 12471 returned, give that value as the argument to `return'. 12472 12473 This pops the selected stack frame (*note Selecting a Frame: 12474 Selection.), and any other frames inside of it, leaving its caller as 12475 the innermost remaining frame. That frame becomes selected. The 12476 specified value is stored in the registers used for returning values of 12477 functions. 12478 12479 The `return' command does not resume execution; it leaves the 12480 program stopped in the state that would exist if the function had just 12481 returned. In contrast, the `finish' command (*note Continuing and 12482 Stepping: Continuing and Stepping.) resumes execution until the 12483 selected stack frame returns naturally. 12484 12485 GDB needs to know how the EXPRESSION argument should be set for the 12486 inferior. The concrete registers assignment depends on the OS ABI and 12487 the type being returned by the selected stack frame. For example it is 12488 common for OS ABI to return floating point values in FPU registers 12489 while integer values in CPU registers. Still some ABIs return even 12490 floating point values in CPU registers. Larger integer widths (such as 12491 `long long int') also have specific placement rules. GDB already knows 12492 the OS ABI from its current target so it needs to find out also the 12493 type being returned to make the assignment into the right register(s). 12494 12495 Normally, the selected stack frame has debug info. GDB will always 12496 use the debug info instead of the implicit type of EXPRESSION when the 12497 debug info is available. For example, if you type `return -1', and the 12498 function in the current stack frame is declared to return a `long long 12499 int', GDB transparently converts the implicit `int' value of -1 into a 12500 `long long int': 12501 12502 Breakpoint 1, func () at gdb.base/return-nodebug.c:29 12503 29 return 31; 12504 (gdb) return -1 12505 Make func return now? (y or n) y 12506 #0 0x004004f6 in main () at gdb.base/return-nodebug.c:43 12507 43 printf ("result=%lld\n", func ()); 12508 (gdb) 12509 12510 However, if the selected stack frame does not have a debug info, 12511 e.g., if the function was compiled without debug info, GDB has to find 12512 out the type to return from user. Specifying a different type by 12513 mistake may set the value in different inferior registers than the 12514 caller code expects. For example, typing `return -1' with its implicit 12515 type `int' would set only a part of a `long long int' result for a 12516 debug info less function (on 32-bit architectures). Therefore the user 12517 is required to specify the return type by an appropriate cast 12518 explicitly: 12519 12520 Breakpoint 2, 0x0040050b in func () 12521 (gdb) return -1 12522 Return value type not available for selected stack frame. 12523 Please use an explicit cast of the value to return. 12524 (gdb) return (long long int) -1 12525 Make selected stack frame return now? (y or n) y 12526 #0 0x00400526 in main () 12527 (gdb) 12528 12529 12530 File: gdb.info, Node: Calling, Next: Patching, Prev: Returning, Up: Altering 12531 12532 17.5 Calling Program Functions 12533 ============================== 12534 12535 `print EXPR' 12536 Evaluate the expression EXPR and display the resulting value. 12537 EXPR may include calls to functions in the program being debugged. 12538 12539 `call EXPR' 12540 Evaluate the expression EXPR without displaying `void' returned 12541 values. 12542 12543 You can use this variant of the `print' command if you want to 12544 execute a function from your program that does not return anything 12545 (a.k.a. "a void function"), but without cluttering the output with 12546 `void' returned values that GDB will otherwise print. If the 12547 result is not void, it is printed and saved in the value history. 12548 12549 It is possible for the function you call via the `print' or `call' 12550 command to generate a signal (e.g., if there's a bug in the function, 12551 or if you passed it incorrect arguments). What happens in that case is 12552 controlled by the `set unwindonsignal' command. 12553 12554 Similarly, with a C++ program it is possible for the function you 12555 call via the `print' or `call' command to generate an exception that is 12556 not handled due to the constraints of the dummy frame. In this case, 12557 any exception that is raised in the frame, but has an out-of-frame 12558 exception handler will not be found. GDB builds a dummy-frame for the 12559 inferior function call, and the unwinder cannot seek for exception 12560 handlers outside of this dummy-frame. What happens in that case is 12561 controlled by the `set unwind-on-terminating-exception' command. 12562 12563 `set unwindonsignal' 12564 Set unwinding of the stack if a signal is received while in a 12565 function that GDB called in the program being debugged. If set to 12566 on, GDB unwinds the stack it created for the call and restores the 12567 context to what it was before the call. If set to off (the 12568 default), GDB stops in the frame where the signal was received. 12569 12570 `show unwindonsignal' 12571 Show the current setting of stack unwinding in the functions 12572 called by GDB. 12573 12574 `set unwind-on-terminating-exception' 12575 Set unwinding of the stack if a C++ exception is raised, but left 12576 unhandled while in a function that GDB called in the program being 12577 debugged. If set to on (the default), GDB unwinds the stack it 12578 created for the call and restores the context to what it was before 12579 the call. If set to off, GDB the exception is delivered to the 12580 default C++ exception handler and the inferior terminated. 12581 12582 `show unwind-on-terminating-exception' 12583 Show the current setting of stack unwinding in the functions 12584 called by GDB. 12585 12586 12587 Sometimes, a function you wish to call is actually a "weak alias" 12588 for another function. In such case, GDB might not pick up the type 12589 information, including the types of the function arguments, which 12590 causes GDB to call the inferior function incorrectly. As a result, the 12591 called function will function erroneously and may even crash. A 12592 solution to that is to use the name of the aliased function instead. 12593 12594 12595 File: gdb.info, Node: Patching, Prev: Calling, Up: Altering 12596 12597 17.6 Patching Programs 12598 ====================== 12599 12600 By default, GDB opens the file containing your program's executable 12601 code (or the corefile) read-only. This prevents accidental alterations 12602 to machine code; but it also prevents you from intentionally patching 12603 your program's binary. 12604 12605 If you'd like to be able to patch the binary, you can specify that 12606 explicitly with the `set write' command. For example, you might want 12607 to turn on internal debugging flags, or even to make emergency repairs. 12608 12609 `set write on' 12610 `set write off' 12611 If you specify `set write on', GDB opens executable and core files 12612 for both reading and writing; if you specify `set write off' (the 12613 default), GDB opens them read-only. 12614 12615 If you have already loaded a file, you must load it again (using 12616 the `exec-file' or `core-file' command) after changing `set 12617 write', for your new setting to take effect. 12618 12619 `show write' 12620 Display whether executable files and core files are opened for 12621 writing as well as reading. 12622 12623 12624 File: gdb.info, Node: GDB Files, Next: Targets, Prev: Altering, Up: Top 12625 12626 18 GDB Files 12627 ************ 12628 12629 GDB needs to know the file name of the program to be debugged, both in 12630 order to read its symbol table and in order to start your program. To 12631 debug a core dump of a previous run, you must also tell GDB the name of 12632 the core dump file. 12633 12634 * Menu: 12635 12636 * Files:: Commands to specify files 12637 * Separate Debug Files:: Debugging information in separate files 12638 * Index Files:: Index files speed up GDB 12639 * Symbol Errors:: Errors reading symbol files 12640 * Data Files:: GDB data files 12641 12642 12643 File: gdb.info, Node: Files, Next: Separate Debug Files, Up: GDB Files 12644 12645 18.1 Commands to Specify Files 12646 ============================== 12647 12648 You may want to specify executable and core dump file names. The usual 12649 way to do this is at start-up time, using the arguments to GDB's 12650 start-up commands (*note Getting In and Out of GDB: Invocation.). 12651 12652 Occasionally it is necessary to change to a different file during a 12653 GDB session. Or you may run GDB and forget to specify a file you want 12654 to use. Or you are debugging a remote target via `gdbserver' (*note 12655 file: Server.). In these situations the GDB commands to specify new 12656 files are useful. 12657 12658 `file FILENAME' 12659 Use FILENAME as the program to be debugged. It is read for its 12660 symbols and for the contents of pure memory. It is also the 12661 program executed when you use the `run' command. If you do not 12662 specify a directory and the file is not found in the GDB working 12663 directory, GDB uses the environment variable `PATH' as a list of 12664 directories to search, just as the shell does when looking for a 12665 program to run. You can change the value of this variable, for 12666 both GDB and your program, using the `path' command. 12667 12668 You can load unlinked object `.o' files into GDB using the `file' 12669 command. You will not be able to "run" an object file, but you 12670 can disassemble functions and inspect variables. Also, if the 12671 underlying BFD functionality supports it, you could use `gdb 12672 -write' to patch object files using this technique. Note that GDB 12673 can neither interpret nor modify relocations in this case, so 12674 branches and some initialized variables will appear to go to the 12675 wrong place. But this feature is still handy from time to time. 12676 12677 `file' 12678 `file' with no argument makes GDB discard any information it has 12679 on both executable file and the symbol table. 12680 12681 `exec-file [ FILENAME ]' 12682 Specify that the program to be run (but not the symbol table) is 12683 found in FILENAME. GDB searches the environment variable `PATH' 12684 if necessary to locate your program. Omitting FILENAME means to 12685 discard information on the executable file. 12686 12687 `symbol-file [ FILENAME ]' 12688 Read symbol table information from file FILENAME. `PATH' is 12689 searched when necessary. Use the `file' command to get both symbol 12690 table and program to run from the same file. 12691 12692 `symbol-file' with no argument clears out GDB information on your 12693 program's symbol table. 12694 12695 The `symbol-file' command causes GDB to forget the contents of 12696 some breakpoints and auto-display expressions. This is because 12697 they may contain pointers to the internal data recording symbols 12698 and data types, which are part of the old symbol table data being 12699 discarded inside GDB. 12700 12701 `symbol-file' does not repeat if you press <RET> again after 12702 executing it once. 12703 12704 When GDB is configured for a particular environment, it 12705 understands debugging information in whatever format is the 12706 standard generated for that environment; you may use either a GNU 12707 compiler, or other compilers that adhere to the local conventions. 12708 Best results are usually obtained from GNU compilers; for example, 12709 using `GCC' you can generate debugging information for optimized 12710 code. 12711 12712 For most kinds of object files, with the exception of old SVR3 12713 systems using COFF, the `symbol-file' command does not normally 12714 read the symbol table in full right away. Instead, it scans the 12715 symbol table quickly to find which source files and which symbols 12716 are present. The details are read later, one source file at a 12717 time, as they are needed. 12718 12719 The purpose of this two-stage reading strategy is to make GDB 12720 start up faster. For the most part, it is invisible except for 12721 occasional pauses while the symbol table details for a particular 12722 source file are being read. (The `set verbose' command can turn 12723 these pauses into messages if desired. *Note Optional Warnings 12724 and Messages: Messages/Warnings.) 12725 12726 We have not implemented the two-stage strategy for COFF yet. When 12727 the symbol table is stored in COFF format, `symbol-file' reads the 12728 symbol table data in full right away. Note that "stabs-in-COFF" 12729 still does the two-stage strategy, since the debug info is actually 12730 in stabs format. 12731 12732 `symbol-file [ -readnow ] FILENAME' 12733 `file [ -readnow ] FILENAME' 12734 You can override the GDB two-stage strategy for reading symbol 12735 tables by using the `-readnow' option with any of the commands that 12736 load symbol table information, if you want to be sure GDB has the 12737 entire symbol table available. 12738 12739 `core-file [FILENAME]' 12740 `core' 12741 Specify the whereabouts of a core dump file to be used as the 12742 "contents of memory". Traditionally, core files contain only some 12743 parts of the address space of the process that generated them; GDB 12744 can access the executable file itself for other parts. 12745 12746 `core-file' with no argument specifies that no core file is to be 12747 used. 12748 12749 Note that the core file is ignored when your program is actually 12750 running under GDB. So, if you have been running your program and 12751 you wish to debug a core file instead, you must kill the 12752 subprocess in which the program is running. To do this, use the 12753 `kill' command (*note Killing the Child Process: Kill Process.). 12754 12755 `add-symbol-file FILENAME ADDRESS' 12756 `add-symbol-file FILENAME ADDRESS [ -readnow ]' 12757 `add-symbol-file FILENAME -sSECTION ADDRESS ...' 12758 The `add-symbol-file' command reads additional symbol table 12759 information from the file FILENAME. You would use this command 12760 when FILENAME has been dynamically loaded (by some other means) 12761 into the program that is running. ADDRESS should be the memory 12762 address at which the file has been loaded; GDB cannot figure this 12763 out for itself. You can additionally specify an arbitrary number 12764 of `-sSECTION ADDRESS' pairs, to give an explicit section name and 12765 base address for that section. You can specify any ADDRESS as an 12766 expression. 12767 12768 The symbol table of the file FILENAME is added to the symbol table 12769 originally read with the `symbol-file' command. You can use the 12770 `add-symbol-file' command any number of times; the new symbol data 12771 thus read keeps adding to the old. To discard all old symbol data 12772 instead, use the `symbol-file' command without any arguments. 12773 12774 Although FILENAME is typically a shared library file, an 12775 executable file, or some other object file which has been fully 12776 relocated for loading into a process, you can also load symbolic 12777 information from relocatable `.o' files, as long as: 12778 12779 * the file's symbolic information refers only to linker symbols 12780 defined in that file, not to symbols defined by other object 12781 files, 12782 12783 * every section the file's symbolic information refers to has 12784 actually been loaded into the inferior, as it appears in the 12785 file, and 12786 12787 * you can determine the address at which every section was 12788 loaded, and provide these to the `add-symbol-file' command. 12789 12790 Some embedded operating systems, like Sun Chorus and VxWorks, can 12791 load relocatable files into an already running program; such 12792 systems typically make the requirements above easy to meet. 12793 However, it's important to recognize that many native systems use 12794 complex link procedures (`.linkonce' section factoring and C++ 12795 constructor table assembly, for example) that make the 12796 requirements difficult to meet. In general, one cannot assume 12797 that using `add-symbol-file' to read a relocatable object file's 12798 symbolic information will have the same effect as linking the 12799 relocatable object file into the program in the normal way. 12800 12801 `add-symbol-file' does not repeat if you press <RET> after using 12802 it. 12803 12804 `add-symbol-file-from-memory ADDRESS' 12805 Load symbols from the given ADDRESS in a dynamically loaded object 12806 file whose image is mapped directly into the inferior's memory. 12807 For example, the Linux kernel maps a `syscall DSO' into each 12808 process's address space; this DSO provides kernel-specific code for 12809 some system calls. The argument can be any expression whose 12810 evaluation yields the address of the file's shared object file 12811 header. For this command to work, you must have used 12812 `symbol-file' or `exec-file' commands in advance. 12813 12814 `add-shared-symbol-files LIBRARY-FILE' 12815 `assf LIBRARY-FILE' 12816 The `add-shared-symbol-files' command can currently be used only 12817 in the Cygwin build of GDB on MS-Windows OS, where it is an alias 12818 for the `dll-symbols' command (*note Cygwin Native::). GDB 12819 automatically looks for shared libraries, however if GDB does not 12820 find yours, you can invoke `add-shared-symbol-files'. It takes 12821 one argument: the shared library's file name. `assf' is a 12822 shorthand alias for `add-shared-symbol-files'. 12823 12824 `section SECTION ADDR' 12825 The `section' command changes the base address of the named 12826 SECTION of the exec file to ADDR. This can be used if the exec 12827 file does not contain section addresses, (such as in the `a.out' 12828 format), or when the addresses specified in the file itself are 12829 wrong. Each section must be changed separately. The `info files' 12830 command, described below, lists all the sections and their 12831 addresses. 12832 12833 `info files' 12834 `info target' 12835 `info files' and `info target' are synonymous; both print the 12836 current target (*note Specifying a Debugging Target: Targets.), 12837 including the names of the executable and core dump files 12838 currently in use by GDB, and the files from which symbols were 12839 loaded. The command `help target' lists all possible targets 12840 rather than current ones. 12841 12842 `maint info sections' 12843 Another command that can give you extra information about program 12844 sections is `maint info sections'. In addition to the section 12845 information displayed by `info files', this command displays the 12846 flags and file offset of each section in the executable and core 12847 dump files. In addition, `maint info sections' provides the 12848 following command options (which may be arbitrarily combined): 12849 12850 `ALLOBJ' 12851 Display sections for all loaded object files, including 12852 shared libraries. 12853 12854 `SECTIONS' 12855 Display info only for named SECTIONS. 12856 12857 `SECTION-FLAGS' 12858 Display info only for sections for which SECTION-FLAGS are 12859 true. The section flags that GDB currently knows about are: 12860 `ALLOC' 12861 Section will have space allocated in the process when 12862 loaded. Set for all sections except those containing 12863 debug information. 12864 12865 `LOAD' 12866 Section will be loaded from the file into the child 12867 process memory. Set for pre-initialized code and data, 12868 clear for `.bss' sections. 12869 12870 `RELOC' 12871 Section needs to be relocated before loading. 12872 12873 `READONLY' 12874 Section cannot be modified by the child process. 12875 12876 `CODE' 12877 Section contains executable code only. 12878 12879 `DATA' 12880 Section contains data only (no executable code). 12881 12882 `ROM' 12883 Section will reside in ROM. 12884 12885 `CONSTRUCTOR' 12886 Section contains data for constructor/destructor lists. 12887 12888 `HAS_CONTENTS' 12889 Section is not empty. 12890 12891 `NEVER_LOAD' 12892 An instruction to the linker to not output the section. 12893 12894 `COFF_SHARED_LIBRARY' 12895 A notification to the linker that the section contains 12896 COFF shared library information. 12897 12898 `IS_COMMON' 12899 Section contains common symbols. 12900 12901 `set trust-readonly-sections on' 12902 Tell GDB that readonly sections in your object file really are 12903 read-only (i.e. that their contents will not change). In that 12904 case, GDB can fetch values from these sections out of the object 12905 file, rather than from the target program. For some targets 12906 (notably embedded ones), this can be a significant enhancement to 12907 debugging performance. 12908 12909 The default is off. 12910 12911 `set trust-readonly-sections off' 12912 Tell GDB not to trust readonly sections. This means that the 12913 contents of the section might change while the program is running, 12914 and must therefore be fetched from the target when needed. 12915 12916 `show trust-readonly-sections' 12917 Show the current setting of trusting readonly sections. 12918 12919 All file-specifying commands allow both absolute and relative file 12920 names as arguments. GDB always converts the file name to an absolute 12921 file name and remembers it that way. 12922 12923 GDB supports GNU/Linux, MS-Windows, HP-UX, SunOS, SVr4, Irix, and 12924 IBM RS/6000 AIX shared libraries. 12925 12926 On MS-Windows GDB must be linked with the Expat library to support 12927 shared libraries. *Note Expat::. 12928 12929 GDB automatically loads symbol definitions from shared libraries 12930 when you use the `run' command, or when you examine a core file. 12931 (Before you issue the `run' command, GDB does not understand references 12932 to a function in a shared library, however--unless you are debugging a 12933 core file). 12934 12935 On HP-UX, if the program loads a library explicitly, GDB 12936 automatically loads the symbols at the time of the `shl_load' call. 12937 12938 There are times, however, when you may wish to not automatically load 12939 symbol definitions from shared libraries, such as when they are 12940 particularly large or there are many of them. 12941 12942 To control the automatic loading of shared library symbols, use the 12943 commands: 12944 12945 `set auto-solib-add MODE' 12946 If MODE is `on', symbols from all shared object libraries will be 12947 loaded automatically when the inferior begins execution, you 12948 attach to an independently started inferior, or when the dynamic 12949 linker informs GDB that a new library has been loaded. If MODE is 12950 `off', symbols must be loaded manually, using the `sharedlibrary' 12951 command. The default value is `on'. 12952 12953 If your program uses lots of shared libraries with debug info that 12954 takes large amounts of memory, you can decrease the GDB memory 12955 footprint by preventing it from automatically loading the symbols 12956 from shared libraries. To that end, type `set auto-solib-add off' 12957 before running the inferior, then load each library whose debug 12958 symbols you do need with `sharedlibrary REGEXP', where REGEXP is a 12959 regular expression that matches the libraries whose symbols you 12960 want to be loaded. 12961 12962 `show auto-solib-add' 12963 Display the current autoloading mode. 12964 12965 To explicitly load shared library symbols, use the `sharedlibrary' 12966 command: 12967 12968 `info share REGEX' 12969 `info sharedlibrary REGEX' 12970 Print the names of the shared libraries which are currently loaded 12971 that match REGEX. If REGEX is omitted then print all shared 12972 libraries that are loaded. 12973 12974 `sharedlibrary REGEX' 12975 `share REGEX' 12976 Load shared object library symbols for files matching a Unix 12977 regular expression. As with files loaded automatically, it only 12978 loads shared libraries required by your program for a core file or 12979 after typing `run'. If REGEX is omitted all shared libraries 12980 required by your program are loaded. 12981 12982 `nosharedlibrary' 12983 Unload all shared object library symbols. This discards all 12984 symbols that have been loaded from all shared libraries. Symbols 12985 from shared libraries that were loaded by explicit user requests 12986 are not discarded. 12987 12988 Sometimes you may wish that GDB stops and gives you control when any 12989 of shared library events happen. Use the `set stop-on-solib-events' 12990 command for this: 12991 12992 `set stop-on-solib-events' 12993 This command controls whether GDB should give you control when the 12994 dynamic linker notifies it about some shared library event. The 12995 most common event of interest is loading or unloading of a new 12996 shared library. 12997 12998 `show stop-on-solib-events' 12999 Show whether GDB stops and gives you control when shared library 13000 events happen. 13001 13002 Shared libraries are also supported in many cross or remote debugging 13003 configurations. GDB needs to have access to the target's libraries; 13004 this can be accomplished either by providing copies of the libraries on 13005 the host system, or by asking GDB to automatically retrieve the 13006 libraries from the target. If copies of the target libraries are 13007 provided, they need to be the same as the target libraries, although the 13008 copies on the target can be stripped as long as the copies on the host 13009 are not. 13010 13011 For remote debugging, you need to tell GDB where the target 13012 libraries are, so that it can load the correct copies--otherwise, it 13013 may try to load the host's libraries. GDB has two variables to specify 13014 the search directories for target libraries. 13015 13016 `set sysroot PATH' 13017 Use PATH as the system root for the program being debugged. Any 13018 absolute shared library paths will be prefixed with PATH; many 13019 runtime loaders store the absolute paths to the shared library in 13020 the target program's memory. If you use `set sysroot' to find 13021 shared libraries, they need to be laid out in the same way that 13022 they are on the target, with e.g. a `/lib' and `/usr/lib' hierarchy 13023 under PATH. 13024 13025 If PATH starts with the sequence `remote:', GDB will retrieve the 13026 target libraries from the remote system. This is only supported 13027 when using a remote target that supports the `remote get' command 13028 (*note Sending files to a remote system: File Transfer.). The 13029 part of PATH following the initial `remote:' (if present) is used 13030 as system root prefix on the remote file system. (1) 13031 13032 For targets with an MS-DOS based filesystem, such as MS-Windows and 13033 SymbianOS, GDB tries prefixing a few variants of the target 13034 absolute file name with PATH. But first, on Unix hosts, GDB 13035 converts all backslash directory separators into forward slashes, 13036 because the backslash is not a directory separator on Unix: 13037 13038 c:\foo\bar.dll => c:/foo/bar.dll 13039 13040 Then, GDB attempts prefixing the target file name with PATH, and 13041 looks for the resulting file name in the host file system: 13042 13043 c:/foo/bar.dll => /path/to/sysroot/c:/foo/bar.dll 13044 13045 If that does not find the shared library, GDB tries removing the 13046 `:' character from the drive spec, both for convenience, and, for 13047 the case of the host file system not supporting file names with 13048 colons: 13049 13050 c:/foo/bar.dll => /path/to/sysroot/c/foo/bar.dll 13051 13052 This makes it possible to have a system root that mirrors a target 13053 with more than one drive. E.g., you may want to setup your local 13054 copies of the target system shared libraries like so (note `c' vs 13055 `z'): 13056 13057 `/path/to/sysroot/c/sys/bin/foo.dll' 13058 `/path/to/sysroot/c/sys/bin/bar.dll' 13059 `/path/to/sysroot/z/sys/bin/bar.dll' 13060 13061 and point the system root at `/path/to/sysroot', so that GDB can 13062 find the correct copies of both `c:\sys\bin\foo.dll', and 13063 `z:\sys\bin\bar.dll'. 13064 13065 If that still does not find the shared library, GDB tries removing 13066 the whole drive spec from the target file name: 13067 13068 c:/foo/bar.dll => /path/to/sysroot/foo/bar.dll 13069 13070 This last lookup makes it possible to not care about the drive 13071 name, if you don't want or need to. 13072 13073 The `set solib-absolute-prefix' command is an alias for `set 13074 sysroot'. 13075 13076 You can set the default system root by using the configure-time 13077 `--with-sysroot' option. If the system root is inside GDB's 13078 configured binary prefix (set with `--prefix' or `--exec-prefix'), 13079 then the default system root will be updated automatically if the 13080 installed GDB is moved to a new location. 13081 13082 `show sysroot' 13083 Display the current shared library prefix. 13084 13085 `set solib-search-path PATH' 13086 If this variable is set, PATH is a colon-separated list of 13087 directories to search for shared libraries. `solib-search-path' 13088 is used after `sysroot' fails to locate the library, or if the 13089 path to the library is relative instead of absolute. If you want 13090 to use `solib-search-path' instead of `sysroot', be sure to set 13091 `sysroot' to a nonexistent directory to prevent GDB from finding 13092 your host's libraries. `sysroot' is preferred; setting it to a 13093 nonexistent directory may interfere with automatic loading of 13094 shared library symbols. 13095 13096 `show solib-search-path' 13097 Display the current shared library search path. 13098 13099 `set target-file-system-kind KIND' 13100 Set assumed file system kind for target reported file names. 13101 13102 Shared library file names as reported by the target system may not 13103 make sense as is on the system GDB is running on. For example, 13104 when remote debugging a target that has MS-DOS based file system 13105 semantics, from a Unix host, the target may be reporting to GDB a 13106 list of loaded shared libraries with file names such as 13107 `c:\Windows\kernel32.dll'. On Unix hosts, there's no concept of 13108 drive letters, so the `c:\' prefix is not normally understood as 13109 indicating an absolute file name, and neither is the backslash 13110 normally considered a directory separator character. In that case, 13111 the native file system would interpret this whole absolute file 13112 name as a relative file name with no directory components. This 13113 would make it impossible to point GDB at a copy of the remote 13114 target's shared libraries on the host using `set sysroot', and 13115 impractical with `set solib-search-path'. Setting 13116 `target-file-system-kind' to `dos-based' tells GDB to interpret 13117 such file names similarly to how the target would, and to map them 13118 to file names valid on GDB's native file system semantics. The 13119 value of KIND can be `"auto"', in addition to one of the supported 13120 file system kinds. In that case, GDB tries to determine the 13121 appropriate file system variant based on the current target's 13122 operating system (*note Configuring the Current ABI: ABI.). The 13123 supported file system settings are: 13124 13125 `unix' 13126 Instruct GDB to assume the target file system is of Unix 13127 kind. Only file names starting the forward slash (`/') 13128 character are considered absolute, and the directory 13129 separator character is also the forward slash. 13130 13131 `dos-based' 13132 Instruct GDB to assume the target file system is DOS based. 13133 File names starting with either a forward slash, or a drive 13134 letter followed by a colon (e.g., `c:'), are considered 13135 absolute, and both the slash (`/') and the backslash (`\\') 13136 characters are considered directory separators. 13137 13138 `auto' 13139 Instruct GDB to use the file system kind associated with the 13140 target operating system (*note Configuring the Current ABI: 13141 ABI.). This is the default. 13142 13143 When processing file names provided by the user, GDB frequently 13144 needs to compare them to the file names recorded in the program's debug 13145 info. Normally, GDB compares just the "base names" of the files as 13146 strings, which is reasonably fast even for very large programs. (The 13147 base name of a file is the last portion of its name, after stripping 13148 all the leading directories.) This shortcut in comparison is based 13149 upon the assumption that files cannot have more than one base name. 13150 This is usually true, but references to files that use symlinks or 13151 similar filesystem facilities violate that assumption. If your program 13152 records files using such facilities, or if you provide file names to 13153 GDB using symlinks etc., you can set `basenames-may-differ' to `true' 13154 to instruct GDB to completely canonicalize each pair of file names it 13155 needs to compare. This will make file-name comparisons accurate, but 13156 at a price of a significant slowdown. 13157 13158 `set basenames-may-differ' 13159 Set whether a source file may have multiple base names. 13160 13161 `show basenames-may-differ' 13162 Show whether a source file may have multiple base names. 13163 13164 ---------- Footnotes ---------- 13165 13166 (1) If you want to specify a local system root using a directory 13167 that happens to be named `remote:', you need to use some equivalent 13168 variant of the name like `./remote:'. 13169 13170 13171 File: gdb.info, Node: Separate Debug Files, Next: Index Files, Prev: Files, Up: GDB Files 13172 13173 18.2 Debugging Information in Separate Files 13174 ============================================ 13175 13176 GDB allows you to put a program's debugging information in a file 13177 separate from the executable itself, in a way that allows GDB to find 13178 and load the debugging information automatically. Since debugging 13179 information can be very large--sometimes larger than the executable 13180 code itself--some systems distribute debugging information for their 13181 executables in separate files, which users can install only when they 13182 need to debug a problem. 13183 13184 GDB supports two ways of specifying the separate debug info file: 13185 13186 * The executable contains a "debug link" that specifies the name of 13187 the separate debug info file. The separate debug file's name is 13188 usually `EXECUTABLE.debug', where EXECUTABLE is the name of the 13189 corresponding executable file without leading directories (e.g., 13190 `ls.debug' for `/usr/bin/ls'). In addition, the debug link 13191 specifies a 32-bit "Cyclic Redundancy Check" (CRC) checksum for 13192 the debug file, which GDB uses to validate that the executable and 13193 the debug file came from the same build. 13194 13195 * The executable contains a "build ID", a unique bit string that is 13196 also present in the corresponding debug info file. (This is 13197 supported only on some operating systems, notably those which use 13198 the ELF format for binary files and the GNU Binutils.) For more 13199 details about this feature, see the description of the `--build-id' 13200 command-line option in *note Command Line Options: 13201 (ld.info)Options. The debug info file's name is not specified 13202 explicitly by the build ID, but can be computed from the build ID, 13203 see below. 13204 13205 Depending on the way the debug info file is specified, GDB uses two 13206 different methods of looking for the debug file: 13207 13208 * For the "debug link" method, GDB looks up the named file in the 13209 directory of the executable file, then in a subdirectory of that 13210 directory named `.debug', and finally under the global debug 13211 directory, in a subdirectory whose name is identical to the leading 13212 directories of the executable's absolute file name. 13213 13214 * For the "build ID" method, GDB looks in the `.build-id' 13215 subdirectory of the global debug directory for a file named 13216 `NN/NNNNNNNN.debug', where NN are the first 2 hex characters of 13217 the build ID bit string, and NNNNNNNN are the rest of the bit 13218 string. (Real build ID strings are 32 or more hex characters, not 13219 10.) 13220 13221 So, for example, suppose you ask GDB to debug `/usr/bin/ls', which 13222 has a debug link that specifies the file `ls.debug', and a build ID 13223 whose value in hex is `abcdef1234'. If the global debug directory is 13224 `/usr/lib/debug', then GDB will look for the following debug 13225 information files, in the indicated order: 13226 13227 - `/usr/lib/debug/.build-id/ab/cdef1234.debug' 13228 13229 - `/usr/bin/ls.debug' 13230 13231 - `/usr/bin/.debug/ls.debug' 13232 13233 - `/usr/lib/debug/usr/bin/ls.debug'. 13234 13235 You can set the global debugging info directory's name, and view the 13236 name GDB is currently using. 13237 13238 `set debug-file-directory DIRECTORIES' 13239 Set the directories which GDB searches for separate debugging 13240 information files to DIRECTORY. Multiple directory components can 13241 be set concatenating them by a directory separator. 13242 13243 `show debug-file-directory' 13244 Show the directories GDB searches for separate debugging 13245 information files. 13246 13247 13248 A debug link is a special section of the executable file named 13249 `.gnu_debuglink'. The section must contain: 13250 13251 * A filename, with any leading directory components removed, 13252 followed by a zero byte, 13253 13254 * zero to three bytes of padding, as needed to reach the next 13255 four-byte boundary within the section, and 13256 13257 * a four-byte CRC checksum, stored in the same endianness used for 13258 the executable file itself. The checksum is computed on the 13259 debugging information file's full contents by the function given 13260 below, passing zero as the CRC argument. 13261 13262 Any executable file format can carry a debug link, as long as it can 13263 contain a section named `.gnu_debuglink' with the contents described 13264 above. 13265 13266 The build ID is a special section in the executable file (and in 13267 other ELF binary files that GDB may consider). This section is often 13268 named `.note.gnu.build-id', but that name is not mandatory. It 13269 contains unique identification for the built files--the ID remains the 13270 same across multiple builds of the same build tree. The default 13271 algorithm SHA1 produces 160 bits (40 hexadecimal characters) of the 13272 content for the build ID string. The same section with an identical 13273 value is present in the original built binary with symbols, in its 13274 stripped variant, and in the separate debugging information file. 13275 13276 The debugging information file itself should be an ordinary 13277 executable, containing a full set of linker symbols, sections, and 13278 debugging information. The sections of the debugging information file 13279 should have the same names, addresses, and sizes as the original file, 13280 but they need not contain any data--much like a `.bss' section in an 13281 ordinary executable. 13282 13283 The GNU binary utilities (Binutils) package includes the `objcopy' 13284 utility that can produce the separated executable / debugging 13285 information file pairs using the following commands: 13286 13287 objcopy --only-keep-debug foo foo.debug 13288 strip -g foo 13289 13290 These commands remove the debugging information from the executable 13291 file `foo' and place it in the file `foo.debug'. You can use the 13292 first, second or both methods to link the two files: 13293 13294 * The debug link method needs the following additional command to 13295 also leave behind a debug link in `foo': 13296 13297 objcopy --add-gnu-debuglink=foo.debug foo 13298 13299 Ulrich Drepper's `elfutils' package, starting with version 0.53, 13300 contains a version of the `strip' command such that the command 13301 `strip foo -f foo.debug' has the same functionality as the two 13302 `objcopy' commands and the `ln -s' command above, together. 13303 13304 * Build ID gets embedded into the main executable using `ld 13305 --build-id' or the GCC counterpart `gcc -Wl,--build-id'. Build ID 13306 support plus compatibility fixes for debug files separation are 13307 present in GNU binary utilities (Binutils) package since version 13308 2.18. 13309 13310 The CRC used in `.gnu_debuglink' is the CRC-32 defined in IEEE 802.3 13311 using the polynomial: 13312 13313 x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 13314 + x^10 + x^8 + x^7 + x^5 + x^4 + x^2 + x + 1 13315 13316 The function is computed byte at a time, taking the least 13317 significant bit of each byte first. The initial pattern `0xffffffff' 13318 is used, to ensure leading zeros affect the CRC and the final result is 13319 inverted to ensure trailing zeros also affect the CRC. 13320 13321 _Note:_ This is the same CRC polynomial as used in handling the 13322 "Remote Serial Protocol" `qCRC' packet (*note GDB Remote Serial 13323 Protocol: Remote Protocol.). However in the case of the Remote Serial 13324 Protocol, the CRC is computed _most_ significant bit first, and the 13325 result is not inverted, so trailing zeros have no effect on the CRC 13326 value. 13327 13328 To complete the description, we show below the code of the function 13329 which produces the CRC used in `.gnu_debuglink'. Inverting the 13330 initially supplied `crc' argument means that an initial call to this 13331 function passing in zero will start computing the CRC using 13332 `0xffffffff'. 13333 13334 unsigned long 13335 gnu_debuglink_crc32 (unsigned long crc, 13336 unsigned char *buf, size_t len) 13337 { 13338 static const unsigned long crc32_table[256] = 13339 { 13340 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 13341 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 13342 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 13343 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 13344 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 13345 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 13346 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 13347 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 13348 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 13349 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 13350 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 13351 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 13352 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 13353 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 13354 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 13355 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 13356 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 13357 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 13358 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 13359 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 13360 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 13361 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 13362 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 13363 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 13364 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 13365 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 13366 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 13367 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 13368 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 13369 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 13370 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 13371 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 13372 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 13373 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 13374 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 13375 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 13376 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 13377 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 13378 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 13379 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 13380 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 13381 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 13382 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 13383 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 13384 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 13385 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 13386 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 13387 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 13388 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 13389 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 13390 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 13391 0x2d02ef8d 13392 }; 13393 unsigned char *end; 13394 13395 crc = ~crc & 0xffffffff; 13396 for (end = buf + len; buf < end; ++buf) 13397 crc = crc32_table[(crc ^ *buf) & 0xff] ^ (crc >> 8); 13398 return ~crc & 0xffffffff; 13399 } 13400 13401 This computation does not apply to the "build ID" method. 13402 13403 13404 File: gdb.info, Node: Index Files, Next: Symbol Errors, Prev: Separate Debug Files, Up: GDB Files 13405 13406 18.3 Index Files Speed Up GDB 13407 ============================= 13408 13409 When GDB finds a symbol file, it scans the symbols in the file in order 13410 to construct an internal symbol table. This lets most GDB operations 13411 work quickly--at the cost of a delay early on. For large programs, 13412 this delay can be quite lengthy, so GDB provides a way to build an 13413 index, which speeds up startup. 13414 13415 The index is stored as a section in the symbol file. GDB can write 13416 the index to a file, then you can put it into the symbol file using 13417 `objcopy'. 13418 13419 To create an index file, use the `save gdb-index' command: 13420 13421 `save gdb-index DIRECTORY' 13422 Create an index file for each symbol file currently known by GDB. 13423 Each file is named after its corresponding symbol file, with 13424 `.gdb-index' appended, and is written into the given DIRECTORY. 13425 13426 Once you have created an index file you can merge it into your symbol 13427 file, here named `symfile', using `objcopy': 13428 13429 $ objcopy --add-section .gdb_index=symfile.gdb-index \ 13430 --set-section-flags .gdb_index=readonly symfile symfile 13431 13432 There are currently some limitation on indices. They only work when 13433 for DWARF debugging information, not stabs. And, they do not currently 13434 work for programs using Ada. 13435 13436 13437 File: gdb.info, Node: Symbol Errors, Next: Data Files, Prev: Index Files, Up: GDB Files 13438 13439 18.4 Errors Reading Symbol Files 13440 ================================ 13441 13442 While reading a symbol file, GDB occasionally encounters problems, such 13443 as symbol types it does not recognize, or known bugs in compiler 13444 output. By default, GDB does not notify you of such problems, since 13445 they are relatively common and primarily of interest to people 13446 debugging compilers. If you are interested in seeing information about 13447 ill-constructed symbol tables, you can either ask GDB to print only one 13448 message about each such type of problem, no matter how many times the 13449 problem occurs; or you can ask GDB to print more messages, to see how 13450 many times the problems occur, with the `set complaints' command (*note 13451 Optional Warnings and Messages: Messages/Warnings.). 13452 13453 The messages currently printed, and their meanings, include: 13454 13455 `inner block not inside outer block in SYMBOL' 13456 The symbol information shows where symbol scopes begin and end 13457 (such as at the start of a function or a block of statements). 13458 This error indicates that an inner scope block is not fully 13459 contained in its outer scope blocks. 13460 13461 GDB circumvents the problem by treating the inner block as if it 13462 had the same scope as the outer block. In the error message, 13463 SYMBOL may be shown as "`(don't know)'" if the outer block is not a 13464 function. 13465 13466 `block at ADDRESS out of order' 13467 The symbol information for symbol scope blocks should occur in 13468 order of increasing addresses. This error indicates that it does 13469 not do so. 13470 13471 GDB does not circumvent this problem, and has trouble locating 13472 symbols in the source file whose symbols it is reading. (You can 13473 often determine what source file is affected by specifying `set 13474 verbose on'. *Note Optional Warnings and Messages: 13475 Messages/Warnings.) 13476 13477 `bad block start address patched' 13478 The symbol information for a symbol scope block has a start address 13479 smaller than the address of the preceding source line. This is 13480 known to occur in the SunOS 4.1.1 (and earlier) C compiler. 13481 13482 GDB circumvents the problem by treating the symbol scope block as 13483 starting on the previous source line. 13484 13485 `bad string table offset in symbol N' 13486 Symbol number N contains a pointer into the string table which is 13487 larger than the size of the string table. 13488 13489 GDB circumvents the problem by considering the symbol to have the 13490 name `foo', which may cause other problems if many symbols end up 13491 with this name. 13492 13493 `unknown symbol type `0xNN'' 13494 The symbol information contains new data types that GDB does not 13495 yet know how to read. `0xNN' is the symbol type of the 13496 uncomprehended information, in hexadecimal. 13497 13498 GDB circumvents the error by ignoring this symbol information. 13499 This usually allows you to debug your program, though certain 13500 symbols are not accessible. If you encounter such a problem and 13501 feel like debugging it, you can debug `gdb' with itself, breakpoint 13502 on `complain', then go up to the function `read_dbx_symtab' and 13503 examine `*bufp' to see the symbol. 13504 13505 `stub type has NULL name' 13506 GDB could not find the full definition for a struct or class. 13507 13508 `const/volatile indicator missing (ok if using g++ v1.x), got...' 13509 The symbol information for a C++ member function is missing some 13510 information that recent versions of the compiler should have 13511 output for it. 13512 13513 `info mismatch between compiler and debugger' 13514 GDB could not parse a type specification output by the compiler. 13515 13516 13517 13518 File: gdb.info, Node: Data Files, Prev: Symbol Errors, Up: GDB Files 13519 13520 18.5 GDB Data Files 13521 =================== 13522 13523 GDB will sometimes read an auxiliary data file. These files are kept 13524 in a directory known as the "data directory". 13525 13526 You can set the data directory's name, and view the name GDB is 13527 currently using. 13528 13529 `set data-directory DIRECTORY' 13530 Set the directory which GDB searches for auxiliary data files to 13531 DIRECTORY. 13532 13533 `show data-directory' 13534 Show the directory GDB searches for auxiliary data files. 13535 13536 You can set the default data directory by using the configure-time 13537 `--with-gdb-datadir' option. If the data directory is inside GDB's 13538 configured binary prefix (set with `--prefix' or `--exec-prefix'), then 13539 the default data directory will be updated automatically if the 13540 installed GDB is moved to a new location. 13541 13542 The data directory may also be specified with the `--data-directory' 13543 command line option. *Note Mode Options::. 13544 13545 13546 File: gdb.info, Node: Targets, Next: Remote Debugging, Prev: GDB Files, Up: Top 13547 13548 19 Specifying a Debugging Target 13549 ******************************** 13550 13551 A "target" is the execution environment occupied by your program. 13552 13553 Often, GDB runs in the same host environment as your program; in 13554 that case, the debugging target is specified as a side effect when you 13555 use the `file' or `core' commands. When you need more flexibility--for 13556 example, running GDB on a physically separate host, or controlling a 13557 standalone system over a serial port or a realtime system over a TCP/IP 13558 connection--you can use the `target' command to specify one of the 13559 target types configured for GDB (*note Commands for Managing Targets: 13560 Target Commands.). 13561 13562 It is possible to build GDB for several different "target 13563 architectures". When GDB is built like that, you can choose one of the 13564 available architectures with the `set architecture' command. 13565 13566 `set architecture ARCH' 13567 This command sets the current target architecture to ARCH. The 13568 value of ARCH can be `"auto"', in addition to one of the supported 13569 architectures. 13570 13571 `show architecture' 13572 Show the current target architecture. 13573 13574 `set processor' 13575 `processor' 13576 These are alias commands for, respectively, `set architecture' and 13577 `show architecture'. 13578 13579 * Menu: 13580 13581 * Active Targets:: Active targets 13582 * Target Commands:: Commands for managing targets 13583 * Byte Order:: Choosing target byte order 13584 13585 13586 File: gdb.info, Node: Active Targets, Next: Target Commands, Up: Targets 13587 13588 19.1 Active Targets 13589 =================== 13590 13591 There are multiple classes of targets such as: processes, executable 13592 files or recording sessions. Core files belong to the process class, 13593 making core file and process mutually exclusive. Otherwise, GDB can 13594 work concurrently on multiple active targets, one in each class. This 13595 allows you to (for example) start a process and inspect its activity, 13596 while still having access to the executable file after the process 13597 finishes. Or if you start process recording (*note Reverse 13598 Execution::) and `reverse-step' there, you are presented a virtual 13599 layer of the recording target, while the process target remains stopped 13600 at the chronologically last point of the process execution. 13601 13602 Use the `core-file' and `exec-file' commands to select a new core 13603 file or executable target (*note Commands to Specify Files: Files.). To 13604 specify as a target a process that is already running, use the `attach' 13605 command (*note Debugging an Already-running Process: Attach.). 13606 13607 13608 File: gdb.info, Node: Target Commands, Next: Byte Order, Prev: Active Targets, Up: Targets 13609 13610 19.2 Commands for Managing Targets 13611 ================================== 13612 13613 `target TYPE PARAMETERS' 13614 Connects the GDB host environment to a target machine or process. 13615 A target is typically a protocol for talking to debugging 13616 facilities. You use the argument TYPE to specify the type or 13617 protocol of the target machine. 13618 13619 Further PARAMETERS are interpreted by the target protocol, but 13620 typically include things like device names or host names to connect 13621 with, process numbers, and baud rates. 13622 13623 The `target' command does not repeat if you press <RET> again 13624 after executing the command. 13625 13626 `help target' 13627 Displays the names of all targets available. To display targets 13628 currently selected, use either `info target' or `info files' 13629 (*note Commands to Specify Files: Files.). 13630 13631 `help target NAME' 13632 Describe a particular target, including any parameters necessary to 13633 select it. 13634 13635 `set gnutarget ARGS' 13636 GDB uses its own library BFD to read your files. GDB knows 13637 whether it is reading an "executable", a "core", or a ".o" file; 13638 however, you can specify the file format with the `set gnutarget' 13639 command. Unlike most `target' commands, with `gnutarget' the 13640 `target' refers to a program, not a machine. 13641 13642 _Warning:_ To specify a file format with `set gnutarget', you 13643 must know the actual BFD name. 13644 13645 *Note Commands to Specify Files: Files. 13646 13647 `show gnutarget' 13648 Use the `show gnutarget' command to display what file format 13649 `gnutarget' is set to read. If you have not set `gnutarget', GDB 13650 will determine the file format for each file automatically, and 13651 `show gnutarget' displays `The current BDF target is "auto"'. 13652 13653 Here are some common targets (available, or not, depending on the GDB 13654 configuration): 13655 13656 `target exec PROGRAM' 13657 An executable file. `target exec PROGRAM' is the same as 13658 `exec-file PROGRAM'. 13659 13660 `target core FILENAME' 13661 A core dump file. `target core FILENAME' is the same as 13662 `core-file FILENAME'. 13663 13664 `target remote MEDIUM' 13665 A remote system connected to GDB via a serial line or network 13666 connection. This command tells GDB to use its own remote protocol 13667 over MEDIUM for debugging. *Note Remote Debugging::. 13668 13669 For example, if you have a board connected to `/dev/ttya' on the 13670 machine running GDB, you could say: 13671 13672 target remote /dev/ttya 13673 13674 `target remote' supports the `load' command. This is only useful 13675 if you have some other way of getting the stub to the target 13676 system, and you can put it somewhere in memory where it won't get 13677 clobbered by the download. 13678 13679 `target sim [SIMARGS] ...' 13680 Builtin CPU simulator. GDB includes simulators for most 13681 architectures. In general, 13682 target sim 13683 load 13684 run 13685 works; however, you cannot assume that a specific memory map, 13686 device drivers, or even basic I/O is available, although some 13687 simulators do provide these. For info about any 13688 processor-specific simulator details, see the appropriate section 13689 in *note Embedded Processors: Embedded Processors. 13690 13691 13692 Some configurations may include these targets as well: 13693 13694 `target nrom DEV' 13695 NetROM ROM emulator. This target only supports downloading. 13696 13697 13698 Different targets are available on different configurations of GDB; 13699 your configuration may have more or fewer targets. 13700 13701 Many remote targets require you to download the executable's code 13702 once you've successfully established a connection. You may wish to 13703 control various aspects of this process. 13704 13705 `set hash' 13706 This command controls whether a hash mark `#' is displayed while 13707 downloading a file to the remote monitor. If on, a hash mark is 13708 displayed after each S-record is successfully downloaded to the 13709 monitor. 13710 13711 `show hash' 13712 Show the current status of displaying the hash mark. 13713 13714 `set debug monitor' 13715 Enable or disable display of communications messages between GDB 13716 and the remote monitor. 13717 13718 `show debug monitor' 13719 Show the current status of displaying communications between GDB 13720 and the remote monitor. 13721 13722 `load FILENAME' 13723 Depending on what remote debugging facilities are configured into 13724 GDB, the `load' command may be available. Where it exists, it is 13725 meant to make FILENAME (an executable) available for debugging on 13726 the remote system--by downloading, or dynamic linking, for example. 13727 `load' also records the FILENAME symbol table in GDB, like the 13728 `add-symbol-file' command. 13729 13730 If your GDB does not have a `load' command, attempting to execute 13731 it gets the error message "`You can't do that when your target is 13732 ...'" 13733 13734 The file is loaded at whatever address is specified in the 13735 executable. For some object file formats, you can specify the 13736 load address when you link the program; for other formats, like 13737 a.out, the object file format specifies a fixed address. 13738 13739 Depending on the remote side capabilities, GDB may be able to load 13740 programs into flash memory. 13741 13742 `load' does not repeat if you press <RET> again after using it. 13743 13744 13745 File: gdb.info, Node: Byte Order, Prev: Target Commands, Up: Targets 13746 13747 19.3 Choosing Target Byte Order 13748 =============================== 13749 13750 Some types of processors, such as the MIPS, PowerPC, and Renesas SH, 13751 offer the ability to run either big-endian or little-endian byte 13752 orders. Usually the executable or symbol will include a bit to 13753 designate the endian-ness, and you will not need to worry about which 13754 to use. However, you may still find it useful to adjust GDB's idea of 13755 processor endian-ness manually. 13756 13757 `set endian big' 13758 Instruct GDB to assume the target is big-endian. 13759 13760 `set endian little' 13761 Instruct GDB to assume the target is little-endian. 13762 13763 `set endian auto' 13764 Instruct GDB to use the byte order associated with the executable. 13765 13766 `show endian' 13767 Display GDB's current idea of the target byte order. 13768 13769 13770 Note that these commands merely adjust interpretation of symbolic 13771 data on the host, and that they have absolutely no effect on the target 13772 system. 13773 13774 13775 File: gdb.info, Node: Remote Debugging, Next: Configurations, Prev: Targets, Up: Top 13776 13777 20 Debugging Remote Programs 13778 **************************** 13779 13780 If you are trying to debug a program running on a machine that cannot 13781 run GDB in the usual way, it is often useful to use remote debugging. 13782 For example, you might use remote debugging on an operating system 13783 kernel, or on a small system which does not have a general purpose 13784 operating system powerful enough to run a full-featured debugger. 13785 13786 Some configurations of GDB have special serial or TCP/IP interfaces 13787 to make this work with particular debugging targets. In addition, GDB 13788 comes with a generic serial protocol (specific to GDB, but not specific 13789 to any particular target system) which you can use if you write the 13790 remote stubs--the code that runs on the remote system to communicate 13791 with GDB. 13792 13793 Other remote targets may be available in your configuration of GDB; 13794 use `help target' to list them. 13795 13796 * Menu: 13797 13798 * Connecting:: Connecting to a remote target 13799 * File Transfer:: Sending files to a remote system 13800 * Server:: Using the gdbserver program 13801 * Remote Configuration:: Remote configuration 13802 * Remote Stub:: Implementing a remote stub 13803 13804 13805 File: gdb.info, Node: Connecting, Next: File Transfer, Up: Remote Debugging 13806 13807 20.1 Connecting to a Remote Target 13808 ================================== 13809 13810 On the GDB host machine, you will need an unstripped copy of your 13811 program, since GDB needs symbol and debugging information. Start up 13812 GDB as usual, using the name of the local copy of your program as the 13813 first argument. 13814 13815 GDB can communicate with the target over a serial line, or over an 13816 IP network using TCP or UDP. In each case, GDB uses the same protocol 13817 for debugging your program; only the medium carrying the debugging 13818 packets varies. The `target remote' command establishes a connection 13819 to the target. Its arguments indicate which medium to use: 13820 13821 `target remote SERIAL-DEVICE' 13822 Use SERIAL-DEVICE to communicate with the target. For example, to 13823 use a serial line connected to the device named `/dev/ttyb': 13824 13825 target remote /dev/ttyb 13826 13827 If you're using a serial line, you may want to give GDB the 13828 `--baud' option, or use the `set remotebaud' command (*note set 13829 remotebaud: Remote Configuration.) before the `target' command. 13830 13831 `target remote `HOST:PORT'' 13832 `target remote `tcp:HOST:PORT'' 13833 Debug using a TCP connection to PORT on HOST. The HOST may be 13834 either a host name or a numeric IP address; PORT must be a decimal 13835 number. The HOST could be the target machine itself, if it is 13836 directly connected to the net, or it might be a terminal server 13837 which in turn has a serial line to the target. 13838 13839 For example, to connect to port 2828 on a terminal server named 13840 `manyfarms': 13841 13842 target remote manyfarms:2828 13843 13844 If your remote target is actually running on the same machine as 13845 your debugger session (e.g. a simulator for your target running on 13846 the same host), you can omit the hostname. For example, to 13847 connect to port 1234 on your local machine: 13848 13849 target remote :1234 13850 Note that the colon is still required here. 13851 13852 `target remote `udp:HOST:PORT'' 13853 Debug using UDP packets to PORT on HOST. For example, to connect 13854 to UDP port 2828 on a terminal server named `manyfarms': 13855 13856 target remote udp:manyfarms:2828 13857 13858 When using a UDP connection for remote debugging, you should keep 13859 in mind that the `U' stands for "Unreliable". UDP can silently 13860 drop packets on busy or unreliable networks, which will cause 13861 havoc with your debugging session. 13862 13863 `target remote | COMMAND' 13864 Run COMMAND in the background and communicate with it using a 13865 pipe. The COMMAND is a shell command, to be parsed and expanded 13866 by the system's command shell, `/bin/sh'; it should expect remote 13867 protocol packets on its standard input, and send replies on its 13868 standard output. You could use this to run a stand-alone simulator 13869 that speaks the remote debugging protocol, to make net connections 13870 using programs like `ssh', or for other similar tricks. 13871 13872 If COMMAND closes its standard output (perhaps by exiting), GDB 13873 will try to send it a `SIGTERM' signal. (If the program has 13874 already exited, this will have no effect.) 13875 13876 13877 Once the connection has been established, you can use all the usual 13878 commands to examine and change data. The remote program is already 13879 running; you can use `step' and `continue', and you do not need to use 13880 `run'. 13881 13882 Whenever GDB is waiting for the remote program, if you type the 13883 interrupt character (often `Ctrl-c'), GDB attempts to stop the program. 13884 This may or may not succeed, depending in part on the hardware and the 13885 serial drivers the remote system uses. If you type the interrupt 13886 character once again, GDB displays this prompt: 13887 13888 Interrupted while waiting for the program. 13889 Give up (and stop debugging it)? (y or n) 13890 13891 If you type `y', GDB abandons the remote debugging session. (If you 13892 decide you want to try again later, you can use `target remote' again 13893 to connect once more.) If you type `n', GDB goes back to waiting. 13894 13895 `detach' 13896 When you have finished debugging the remote program, you can use 13897 the `detach' command to release it from GDB control. Detaching 13898 from the target normally resumes its execution, but the results 13899 will depend on your particular remote stub. After the `detach' 13900 command, GDB is free to connect to another target. 13901 13902 `disconnect' 13903 The `disconnect' command behaves like `detach', except that the 13904 target is generally not resumed. It will wait for GDB (this 13905 instance or another one) to connect and continue debugging. After 13906 the `disconnect' command, GDB is again free to connect to another 13907 target. 13908 13909 `monitor CMD' 13910 This command allows you to send arbitrary commands directly to the 13911 remote monitor. Since GDB doesn't care about the commands it 13912 sends like this, this command is the way to extend GDB--you can 13913 add new commands that only the external monitor will understand 13914 and implement. 13915 13916 13917 File: gdb.info, Node: File Transfer, Next: Server, Prev: Connecting, Up: Remote Debugging 13918 13919 20.2 Sending files to a remote system 13920 ===================================== 13921 13922 Some remote targets offer the ability to transfer files over the same 13923 connection used to communicate with GDB. This is convenient for 13924 targets accessible through other means, e.g. GNU/Linux systems running 13925 `gdbserver' over a network interface. For other targets, e.g. embedded 13926 devices with only a single serial port, this may be the only way to 13927 upload or download files. 13928 13929 Not all remote targets support these commands. 13930 13931 `remote put HOSTFILE TARGETFILE' 13932 Copy file HOSTFILE from the host system (the machine running GDB) 13933 to TARGETFILE on the target system. 13934 13935 `remote get TARGETFILE HOSTFILE' 13936 Copy file TARGETFILE from the target system to HOSTFILE on the 13937 host system. 13938 13939 `remote delete TARGETFILE' 13940 Delete TARGETFILE from the target system. 13941 13942 13943 13944 File: gdb.info, Node: Server, Next: Remote Configuration, Prev: File Transfer, Up: Remote Debugging 13945 13946 20.3 Using the `gdbserver' Program 13947 ================================== 13948 13949 `gdbserver' is a control program for Unix-like systems, which allows 13950 you to connect your program with a remote GDB via `target remote'--but 13951 without linking in the usual debugging stub. 13952 13953 `gdbserver' is not a complete replacement for the debugging stubs, 13954 because it requires essentially the same operating-system facilities 13955 that GDB itself does. In fact, a system that can run `gdbserver' to 13956 connect to a remote GDB could also run GDB locally! `gdbserver' is 13957 sometimes useful nevertheless, because it is a much smaller program 13958 than GDB itself. It is also easier to port than all of GDB, so you may 13959 be able to get started more quickly on a new system by using 13960 `gdbserver'. Finally, if you develop code for real-time systems, you 13961 may find that the tradeoffs involved in real-time operation make it 13962 more convenient to do as much development work as possible on another 13963 system, for example by cross-compiling. You can use `gdbserver' to 13964 make a similar choice for debugging. 13965 13966 GDB and `gdbserver' communicate via either a serial line or a TCP 13967 connection, using the standard GDB remote serial protocol. 13968 13969 _Warning:_ `gdbserver' does not have any built-in security. Do 13970 not run `gdbserver' connected to any public network; a GDB 13971 connection to `gdbserver' provides access to the target system 13972 with the same privileges as the user running `gdbserver'. 13973 13974 20.3.1 Running `gdbserver' 13975 -------------------------- 13976 13977 Run `gdbserver' on the target system. You need a copy of the program 13978 you want to debug, including any libraries it requires. `gdbserver' 13979 does not need your program's symbol table, so you can strip the program 13980 if necessary to save space. GDB on the host system does all the symbol 13981 handling. 13982 13983 To use the server, you must tell it how to communicate with GDB; the 13984 name of your program; and the arguments for your program. The usual 13985 syntax is: 13986 13987 target> gdbserver COMM PROGRAM [ ARGS ... ] 13988 13989 COMM is either a device name (to use a serial line) or a TCP 13990 hostname and portnumber. For example, to debug Emacs with the argument 13991 `foo.txt' and communicate with GDB over the serial port `/dev/com1': 13992 13993 target> gdbserver /dev/com1 emacs foo.txt 13994 13995 `gdbserver' waits passively for the host GDB to communicate with it. 13996 13997 To use a TCP connection instead of a serial line: 13998 13999 target> gdbserver host:2345 emacs foo.txt 14000 14001 The only difference from the previous example is the first argument, 14002 specifying that you are communicating with the host GDB via TCP. The 14003 `host:2345' argument means that `gdbserver' is to expect a TCP 14004 connection from machine `host' to local TCP port 2345. (Currently, the 14005 `host' part is ignored.) You can choose any number you want for the 14006 port number as long as it does not conflict with any TCP ports already 14007 in use on the target system (for example, `23' is reserved for 14008 `telnet').(1) You must use the same port number with the host GDB 14009 `target remote' command. 14010 14011 20.3.1.1 Attaching to a Running Program 14012 ....................................... 14013 14014 On some targets, `gdbserver' can also attach to running programs. This 14015 is accomplished via the `--attach' argument. The syntax is: 14016 14017 target> gdbserver --attach COMM PID 14018 14019 PID is the process ID of a currently running process. It isn't 14020 necessary to point `gdbserver' at a binary for the running process. 14021 14022 You can debug processes by name instead of process ID if your target 14023 has the `pidof' utility: 14024 14025 target> gdbserver --attach COMM `pidof PROGRAM` 14026 14027 In case more than one copy of PROGRAM is running, or PROGRAM has 14028 multiple threads, most versions of `pidof' support the `-s' option to 14029 only return the first process ID. 14030 14031 20.3.1.2 Multi-Process Mode for `gdbserver' 14032 ........................................... 14033 14034 When you connect to `gdbserver' using `target remote', `gdbserver' 14035 debugs the specified program only once. When the program exits, or you 14036 detach from it, GDB closes the connection and `gdbserver' exits. 14037 14038 If you connect using `target extended-remote', `gdbserver' enters 14039 multi-process mode. When the debugged program exits, or you detach 14040 from it, GDB stays connected to `gdbserver' even though no program is 14041 running. The `run' and `attach' commands instruct `gdbserver' to run 14042 or attach to a new program. The `run' command uses `set remote 14043 exec-file' (*note set remote exec-file::) to select the program to run. 14044 Command line arguments are supported, except for wildcard expansion and 14045 I/O redirection (*note Arguments::). 14046 14047 To start `gdbserver' without supplying an initial command to run or 14048 process ID to attach, use the `--multi' command line option. Then you 14049 can connect using `target extended-remote' and start the program you 14050 want to debug. 14051 14052 `gdbserver' does not automatically exit in multi-process mode. You 14053 can terminate it by using `monitor exit' (*note Monitor Commands for 14054 gdbserver::). 14055 14056 20.3.1.3 Other Command-Line Arguments for `gdbserver' 14057 ..................................................... 14058 14059 The `--debug' option tells `gdbserver' to display extra status 14060 information about the debugging process. The `--remote-debug' option 14061 tells `gdbserver' to display remote protocol debug output. These 14062 options are intended for `gdbserver' development and for bug reports to 14063 the developers. 14064 14065 The `--wrapper' option specifies a wrapper to launch programs for 14066 debugging. The option should be followed by the name of the wrapper, 14067 then any command-line arguments to pass to the wrapper, then `--' 14068 indicating the end of the wrapper arguments. 14069 14070 `gdbserver' runs the specified wrapper program with a combined 14071 command line including the wrapper arguments, then the name of the 14072 program to debug, then any arguments to the program. The wrapper runs 14073 until it executes your program, and then GDB gains control. 14074 14075 You can use any program that eventually calls `execve' with its 14076 arguments as a wrapper. Several standard Unix utilities do this, e.g. 14077 `env' and `nohup'. Any Unix shell script ending with `exec "$@"' will 14078 also work. 14079 14080 For example, you can use `env' to pass an environment variable to 14081 the debugged program, without setting the variable in `gdbserver''s 14082 environment: 14083 14084 $ gdbserver --wrapper env LD_PRELOAD=libtest.so -- :2222 ./testprog 14085 14086 20.3.2 Connecting to `gdbserver' 14087 -------------------------------- 14088 14089 Run GDB on the host system. 14090 14091 First make sure you have the necessary symbol files. Load symbols 14092 for your application using the `file' command before you connect. Use 14093 `set sysroot' to locate target libraries (unless your GDB was compiled 14094 with the correct sysroot using `--with-sysroot'). 14095 14096 The symbol file and target libraries must exactly match the 14097 executable and libraries on the target, with one exception: the files 14098 on the host system should not be stripped, even if the files on the 14099 target system are. Mismatched or missing files will lead to confusing 14100 results during debugging. On GNU/Linux targets, mismatched or missing 14101 files may also prevent `gdbserver' from debugging multi-threaded 14102 programs. 14103 14104 Connect to your target (*note Connecting to a Remote Target: 14105 Connecting.). For TCP connections, you must start up `gdbserver' prior 14106 to using the `target remote' command. Otherwise you may get an error 14107 whose text depends on the host system, but which usually looks 14108 something like `Connection refused'. Don't use the `load' command in 14109 GDB when using `gdbserver', since the program is already on the target. 14110 14111 20.3.3 Monitor Commands for `gdbserver' 14112 --------------------------------------- 14113 14114 During a GDB session using `gdbserver', you can use the `monitor' 14115 command to send special requests to `gdbserver'. Here are the 14116 available commands. 14117 14118 `monitor help' 14119 List the available monitor commands. 14120 14121 `monitor set debug 0' 14122 `monitor set debug 1' 14123 Disable or enable general debugging messages. 14124 14125 `monitor set remote-debug 0' 14126 `monitor set remote-debug 1' 14127 Disable or enable specific debugging messages associated with the 14128 remote protocol (*note Remote Protocol::). 14129 14130 `monitor set libthread-db-search-path [PATH]' 14131 When this command is issued, PATH is a colon-separated list of 14132 directories to search for `libthread_db' (*note set 14133 libthread-db-search-path: Threads.). If you omit PATH, 14134 `libthread-db-search-path' will be reset to its default value. 14135 14136 The special entry `$pdir' for `libthread-db-search-path' is not 14137 supported in `gdbserver'. 14138 14139 `monitor exit' 14140 Tell gdbserver to exit immediately. This command should be 14141 followed by `disconnect' to close the debugging session. 14142 `gdbserver' will detach from any attached processes and kill any 14143 processes it created. Use `monitor exit' to terminate `gdbserver' 14144 at the end of a multi-process mode debug session. 14145 14146 14147 20.3.4 Tracepoints support in `gdbserver' 14148 ----------------------------------------- 14149 14150 On some targets, `gdbserver' supports tracepoints, fast tracepoints and 14151 static tracepoints. 14152 14153 For fast or static tracepoints to work, a special library called the 14154 "in-process agent" (IPA), must be loaded in the inferior process. This 14155 library is built and distributed as an integral part of `gdbserver'. 14156 In addition, support for static tracepoints requires building the 14157 in-process agent library with static tracepoints support. At present, 14158 the UST (LTTng Userspace Tracer, `http://lttng.org/ust') tracing engine 14159 is supported. This support is automatically available if UST 14160 development headers are found in the standard include path when 14161 `gdbserver' is built, or if `gdbserver' was explicitly configured using 14162 `--with-ust' to point at such headers. You can explicitly disable the 14163 support using `--with-ust=no'. 14164 14165 There are several ways to load the in-process agent in your program: 14166 14167 `Specifying it as dependency at link time' 14168 You can link your program dynamically with the in-process agent 14169 library. On most systems, this is accomplished by adding 14170 `-linproctrace' to the link command. 14171 14172 `Using the system's preloading mechanisms' 14173 You can force loading the in-process agent at startup time by using 14174 your system's support for preloading shared libraries. Many Unixes 14175 support the concept of preloading user defined libraries. In most 14176 cases, you do that by specifying `LD_PRELOAD=libinproctrace.so' in 14177 the environment. See also the description of `gdbserver''s 14178 `--wrapper' command line option. 14179 14180 `Using GDB to force loading the agent at run time' 14181 On some systems, you can force the inferior to load a shared 14182 library, by calling a dynamic loader function in the inferior that 14183 takes care of dynamically looking up and loading a shared library. 14184 On most Unix systems, the function is `dlopen'. You'll use the 14185 `call' command for that. For example: 14186 14187 (gdb) call dlopen ("libinproctrace.so", ...) 14188 14189 Note that on most Unix systems, for the `dlopen' function to be 14190 available, the program needs to be linked with `-ldl'. 14191 14192 On systems that have a userspace dynamic loader, like most Unix 14193 systems, when you connect to `gdbserver' using `target remote', you'll 14194 find that the program is stopped at the dynamic loader's entry point, 14195 and no shared library has been loaded in the program's address space 14196 yet, including the in-process agent. In that case, before being able 14197 to use any of the fast or static tracepoints features, you need to let 14198 the loader run and load the shared libraries. The simplest way to do 14199 that is to run the program to the main procedure. E.g., if debugging a 14200 C or C++ program, start `gdbserver' like so: 14201 14202 $ gdbserver :9999 myprogram 14203 14204 Start GDB and connect to `gdbserver' like so, and run to main: 14205 14206 $ gdb myprogram 14207 (gdb) target remote myhost:9999 14208 0x00007f215893ba60 in ?? () from /lib64/ld-linux-x86-64.so.2 14209 (gdb) b main 14210 (gdb) continue 14211 14212 The in-process tracing agent library should now be loaded into the 14213 process; you can confirm it with the `info sharedlibrary' command, 14214 which will list `libinproctrace.so' as loaded in the process. You are 14215 now ready to install fast tracepoints, list static tracepoint markers, 14216 probe static tracepoints markers, and start tracing. 14217 14218 ---------- Footnotes ---------- 14219 14220 (1) If you choose a port number that conflicts with another service, 14221 `gdbserver' prints an error message and exits. 14222 14223 14224 File: gdb.info, Node: Remote Configuration, Next: Remote Stub, Prev: Server, Up: Remote Debugging 14225 14226 20.4 Remote Configuration 14227 ========================= 14228 14229 This section documents the configuration options available when 14230 debugging remote programs. For the options related to the File I/O 14231 extensions of the remote protocol, see *note system-call-allowed: 14232 system. 14233 14234 `set remoteaddresssize BITS' 14235 Set the maximum size of address in a memory packet to the specified 14236 number of bits. GDB will mask off the address bits above that 14237 number, when it passes addresses to the remote target. The 14238 default value is the number of bits in the target's address. 14239 14240 `show remoteaddresssize' 14241 Show the current value of remote address size in bits. 14242 14243 `set remotebaud N' 14244 Set the baud rate for the remote serial I/O to N baud. The value 14245 is used to set the speed of the serial port used for debugging 14246 remote targets. 14247 14248 `show remotebaud' 14249 Show the current speed of the remote connection. 14250 14251 `set remotebreak' 14252 If set to on, GDB sends a `BREAK' signal to the remote when you 14253 type `Ctrl-c' to interrupt the program running on the remote. If 14254 set to off, GDB sends the `Ctrl-C' character instead. The default 14255 is off, since most remote systems expect to see `Ctrl-C' as the 14256 interrupt signal. 14257 14258 `show remotebreak' 14259 Show whether GDB sends `BREAK' or `Ctrl-C' to interrupt the remote 14260 program. 14261 14262 `set remoteflow on' 14263 `set remoteflow off' 14264 Enable or disable hardware flow control (`RTS'/`CTS') on the 14265 serial port used to communicate to the remote target. 14266 14267 `show remoteflow' 14268 Show the current setting of hardware flow control. 14269 14270 `set remotelogbase BASE' 14271 Set the base (a.k.a. radix) of logging serial protocol 14272 communications to BASE. Supported values of BASE are: `ascii', 14273 `octal', and `hex'. The default is `ascii'. 14274 14275 `show remotelogbase' 14276 Show the current setting of the radix for logging remote serial 14277 protocol. 14278 14279 `set remotelogfile FILE' 14280 Record remote serial communications on the named FILE. The 14281 default is not to record at all. 14282 14283 `show remotelogfile.' 14284 Show the current setting of the file name on which to record the 14285 serial communications. 14286 14287 `set remotetimeout NUM' 14288 Set the timeout limit to wait for the remote target to respond to 14289 NUM seconds. The default is 2 seconds. 14290 14291 `show remotetimeout' 14292 Show the current number of seconds to wait for the remote target 14293 responses. 14294 14295 `set remote hardware-watchpoint-limit LIMIT' 14296 `set remote hardware-breakpoint-limit LIMIT' 14297 Restrict GDB to using LIMIT remote hardware breakpoint or 14298 watchpoints. A limit of -1, the default, is treated as unlimited. 14299 14300 `set remote exec-file FILENAME' 14301 `show remote exec-file' 14302 Select the file used for `run' with `target extended-remote'. 14303 This should be set to a filename valid on the target system. If 14304 it is not set, the target will use a default filename (e.g. the 14305 last program run). 14306 14307 `set remote interrupt-sequence' 14308 Allow the user to select one of `Ctrl-C', a `BREAK' or `BREAK-g' 14309 as the sequence to the remote target in order to interrupt the 14310 execution. `Ctrl-C' is a default. Some system prefers `BREAK' 14311 which is high level of serial line for some certain time. Linux 14312 kernel prefers `BREAK-g', a.k.a Magic SysRq g. It is `BREAK' 14313 signal followed by character `g'. 14314 14315 `show interrupt-sequence' 14316 Show which of `Ctrl-C', `BREAK' or `BREAK-g' is sent by GDB to 14317 interrupt the remote program. `BREAK-g' is BREAK signal followed 14318 by `g' and also known as Magic SysRq g. 14319 14320 `set remote interrupt-on-connect' 14321 Specify whether interrupt-sequence is sent to remote target when 14322 GDB connects to it. This is mostly needed when you debug Linux 14323 kernel. Linux kernel expects `BREAK' followed by `g' which is 14324 known as Magic SysRq g in order to connect GDB. 14325 14326 `show interrupt-on-connect' 14327 Show whether interrupt-sequence is sent to remote target when GDB 14328 connects to it. 14329 14330 `set tcp auto-retry on' 14331 Enable auto-retry for remote TCP connections. This is useful if 14332 the remote debugging agent is launched in parallel with GDB; there 14333 is a race condition because the agent may not become ready to 14334 accept the connection before GDB attempts to connect. When 14335 auto-retry is enabled, if the initial attempt to connect fails, 14336 GDB reattempts to establish the connection using the timeout 14337 specified by `set tcp connect-timeout'. 14338 14339 `set tcp auto-retry off' 14340 Do not auto-retry failed TCP connections. 14341 14342 `show tcp auto-retry' 14343 Show the current auto-retry setting. 14344 14345 `set tcp connect-timeout SECONDS' 14346 Set the timeout for establishing a TCP connection to the remote 14347 target to SECONDS. The timeout affects both polling to retry 14348 failed connections (enabled by `set tcp auto-retry on') and 14349 waiting for connections that are merely slow to complete, and 14350 represents an approximate cumulative value. 14351 14352 `show tcp connect-timeout' 14353 Show the current connection timeout setting. 14354 14355 The GDB remote protocol autodetects the packets supported by your 14356 debugging stub. If you need to override the autodetection, you can use 14357 these commands to enable or disable individual packets. Each packet 14358 can be set to `on' (the remote target supports this packet), `off' (the 14359 remote target does not support this packet), or `auto' (detect remote 14360 target support for this packet). They all default to `auto'. For more 14361 information about each packet, see *note Remote Protocol::. 14362 14363 During normal use, you should not have to use any of these commands. 14364 If you do, that may be a bug in your remote debugging stub, or a bug in 14365 GDB. You may want to report the problem to the GDB developers. 14366 14367 For each packet NAME, the command to enable or disable the packet is 14368 `set remote NAME-packet'. The available settings are: 14369 14370 Command Name Remote Packet Related Features 14371 `fetch-register' `p' `info registers' 14372 `set-register' `P' `set' 14373 `binary-download' `X' `load', `set' 14374 `read-aux-vector' `qXfer:auxv:read' `info auxv' 14375 `symbol-lookup' `qSymbol' Detecting 14376 multiple threads 14377 `attach' `vAttach' `attach' 14378 `verbose-resume' `vCont' Stepping or 14379 resuming multiple 14380 threads 14381 `run' `vRun' `run' 14382 `software-breakpoint'`Z0' `break' 14383 `hardware-breakpoint'`Z1' `hbreak' 14384 `write-watchpoint' `Z2' `watch' 14385 `read-watchpoint' `Z3' `rwatch' 14386 `access-watchpoint' `Z4' `awatch' 14387 `target-features' `qXfer:features:read' `set architecture' 14388 `library-info' `qXfer:libraries:read' `info 14389 sharedlibrary' 14390 `memory-map' `qXfer:memory-map:read' `info mem' 14391 `read-sdata-object' `qXfer:sdata:read' `print $_sdata' 14392 `read-spu-object' `qXfer:spu:read' `info spu' 14393 `write-spu-object' `qXfer:spu:write' `info spu' 14394 `read-siginfo-object'`qXfer:siginfo:read' `print $_siginfo' 14395 `write-siginfo-object'`qXfer:siginfo:write' `set $_siginfo' 14396 `threads' `qXfer:threads:read' `info threads' 14397 `get-thread-local- `qGetTLSAddr' Displaying 14398 storage-address' `__thread' 14399 variables 14400 `get-thread-information-block-address'`qGetTIBAddr' Display 14401 MS-Windows Thread 14402 Information Block. 14403 `search-memory' `qSearch:memory' `find' 14404 `supported-packets' `qSupported' Remote 14405 communications 14406 parameters 14407 `pass-signals' `QPassSignals' `handle SIGNAL' 14408 `hostio-close-packet'`vFile:close' `remote get', 14409 `remote put' 14410 `hostio-open-packet' `vFile:open' `remote get', 14411 `remote put' 14412 `hostio-pread-packet'`vFile:pread' `remote get', 14413 `remote put' 14414 `hostio-pwrite-packet'`vFile:pwrite' `remote get', 14415 `remote put' 14416 `hostio-unlink-packet'`vFile:unlink' `remote delete' 14417 `noack-packet' `QStartNoAckMode' Packet 14418 acknowledgment 14419 `osdata' `qXfer:osdata:read' `info os' 14420 `query-attached' `qAttached' Querying remote 14421 process attach 14422 state. 14423 `traceframe-info' `qXfer:traceframe-info:read'Traceframe info 14424 14425 14426 File: gdb.info, Node: Remote Stub, Prev: Remote Configuration, Up: Remote Debugging 14427 14428 20.5 Implementing a Remote Stub 14429 =============================== 14430 14431 The stub files provided with GDB implement the target side of the 14432 communication protocol, and the GDB side is implemented in the GDB 14433 source file `remote.c'. Normally, you can simply allow these 14434 subroutines to communicate, and ignore the details. (If you're 14435 implementing your own stub file, you can still ignore the details: start 14436 with one of the existing stub files. `sparc-stub.c' is the best 14437 organized, and therefore the easiest to read.) 14438 14439 To debug a program running on another machine (the debugging 14440 "target" machine), you must first arrange for all the usual 14441 prerequisites for the program to run by itself. For example, for a C 14442 program, you need: 14443 14444 1. A startup routine to set up the C runtime environment; these 14445 usually have a name like `crt0'. The startup routine may be 14446 supplied by your hardware supplier, or you may have to write your 14447 own. 14448 14449 2. A C subroutine library to support your program's subroutine calls, 14450 notably managing input and output. 14451 14452 3. A way of getting your program to the other machine--for example, a 14453 download program. These are often supplied by the hardware 14454 manufacturer, but you may have to write your own from hardware 14455 documentation. 14456 14457 The next step is to arrange for your program to use a serial port to 14458 communicate with the machine where GDB is running (the "host" machine). 14459 In general terms, the scheme looks like this: 14460 14461 _On the host,_ 14462 GDB already understands how to use this protocol; when everything 14463 else is set up, you can simply use the `target remote' command 14464 (*note Specifying a Debugging Target: Targets.). 14465 14466 _On the target,_ 14467 you must link with your program a few special-purpose subroutines 14468 that implement the GDB remote serial protocol. The file 14469 containing these subroutines is called a "debugging stub". 14470 14471 On certain remote targets, you can use an auxiliary program 14472 `gdbserver' instead of linking a stub into your program. *Note 14473 Using the `gdbserver' Program: Server, for details. 14474 14475 The debugging stub is specific to the architecture of the remote 14476 machine; for example, use `sparc-stub.c' to debug programs on SPARC 14477 boards. 14478 14479 These working remote stubs are distributed with GDB: 14480 14481 `i386-stub.c' 14482 For Intel 386 and compatible architectures. 14483 14484 `m68k-stub.c' 14485 For Motorola 680x0 architectures. 14486 14487 `sh-stub.c' 14488 For Renesas SH architectures. 14489 14490 `sparc-stub.c' 14491 For SPARC architectures. 14492 14493 `sparcl-stub.c' 14494 For Fujitsu SPARCLITE architectures. 14495 14496 14497 The `README' file in the GDB distribution may list other recently 14498 added stubs. 14499 14500 * Menu: 14501 14502 * Stub Contents:: What the stub can do for you 14503 * Bootstrapping:: What you must do for the stub 14504 * Debug Session:: Putting it all together 14505 14506 14507 File: gdb.info, Node: Stub Contents, Next: Bootstrapping, Up: Remote Stub 14508 14509 20.5.1 What the Stub Can Do for You 14510 ----------------------------------- 14511 14512 The debugging stub for your architecture supplies these three 14513 subroutines: 14514 14515 `set_debug_traps' 14516 This routine arranges for `handle_exception' to run when your 14517 program stops. You must call this subroutine explicitly near the 14518 beginning of your program. 14519 14520 `handle_exception' 14521 This is the central workhorse, but your program never calls it 14522 explicitly--the setup code arranges for `handle_exception' to run 14523 when a trap is triggered. 14524 14525 `handle_exception' takes control when your program stops during 14526 execution (for example, on a breakpoint), and mediates 14527 communications with GDB on the host machine. This is where the 14528 communications protocol is implemented; `handle_exception' acts as 14529 the GDB representative on the target machine. It begins by 14530 sending summary information on the state of your program, then 14531 continues to execute, retrieving and transmitting any information 14532 GDB needs, until you execute a GDB command that makes your program 14533 resume; at that point, `handle_exception' returns control to your 14534 own code on the target machine. 14535 14536 `breakpoint' 14537 Use this auxiliary subroutine to make your program contain a 14538 breakpoint. Depending on the particular situation, this may be 14539 the only way for GDB to get control. For instance, if your target 14540 machine has some sort of interrupt button, you won't need to call 14541 this; pressing the interrupt button transfers control to 14542 `handle_exception'--in effect, to GDB. On some machines, simply 14543 receiving characters on the serial port may also trigger a trap; 14544 again, in that situation, you don't need to call `breakpoint' from 14545 your own program--simply running `target remote' from the host GDB 14546 session gets control. 14547 14548 Call `breakpoint' if none of these is true, or if you simply want 14549 to make certain your program stops at a predetermined point for the 14550 start of your debugging session. 14551 14552 14553 File: gdb.info, Node: Bootstrapping, Next: Debug Session, Prev: Stub Contents, Up: Remote Stub 14554 14555 20.5.2 What You Must Do for the Stub 14556 ------------------------------------ 14557 14558 The debugging stubs that come with GDB are set up for a particular chip 14559 architecture, but they have no information about the rest of your 14560 debugging target machine. 14561 14562 First of all you need to tell the stub how to communicate with the 14563 serial port. 14564 14565 `int getDebugChar()' 14566 Write this subroutine to read a single character from the serial 14567 port. It may be identical to `getchar' for your target system; a 14568 different name is used to allow you to distinguish the two if you 14569 wish. 14570 14571 `void putDebugChar(int)' 14572 Write this subroutine to write a single character to the serial 14573 port. It may be identical to `putchar' for your target system; a 14574 different name is used to allow you to distinguish the two if you 14575 wish. 14576 14577 If you want GDB to be able to stop your program while it is running, 14578 you need to use an interrupt-driven serial driver, and arrange for it 14579 to stop when it receives a `^C' (`\003', the control-C character). 14580 That is the character which GDB uses to tell the remote system to stop. 14581 14582 Getting the debugging target to return the proper status to GDB 14583 probably requires changes to the standard stub; one quick and dirty way 14584 is to just execute a breakpoint instruction (the "dirty" part is that 14585 GDB reports a `SIGTRAP' instead of a `SIGINT'). 14586 14587 Other routines you need to supply are: 14588 14589 `void exceptionHandler (int EXCEPTION_NUMBER, void *EXCEPTION_ADDRESS)' 14590 Write this function to install EXCEPTION_ADDRESS in the exception 14591 handling tables. You need to do this because the stub does not 14592 have any way of knowing what the exception handling tables on your 14593 target system are like (for example, the processor's table might 14594 be in ROM, containing entries which point to a table in RAM). 14595 EXCEPTION_NUMBER is the exception number which should be changed; 14596 its meaning is architecture-dependent (for example, different 14597 numbers might represent divide by zero, misaligned access, etc). 14598 When this exception occurs, control should be transferred directly 14599 to EXCEPTION_ADDRESS, and the processor state (stack, registers, 14600 and so on) should be just as it is when a processor exception 14601 occurs. So if you want to use a jump instruction to reach 14602 EXCEPTION_ADDRESS, it should be a simple jump, not a jump to 14603 subroutine. 14604 14605 For the 386, EXCEPTION_ADDRESS should be installed as an interrupt 14606 gate so that interrupts are masked while the handler runs. The 14607 gate should be at privilege level 0 (the most privileged level). 14608 The SPARC and 68k stubs are able to mask interrupts themselves 14609 without help from `exceptionHandler'. 14610 14611 `void flush_i_cache()' 14612 On SPARC and SPARCLITE only, write this subroutine to flush the 14613 instruction cache, if any, on your target machine. If there is no 14614 instruction cache, this subroutine may be a no-op. 14615 14616 On target machines that have instruction caches, GDB requires this 14617 function to make certain that the state of your program is stable. 14618 14619 You must also make sure this library routine is available: 14620 14621 `void *memset(void *, int, int)' 14622 This is the standard library function `memset' that sets an area of 14623 memory to a known value. If you have one of the free versions of 14624 `libc.a', `memset' can be found there; otherwise, you must either 14625 obtain it from your hardware manufacturer, or write your own. 14626 14627 If you do not use the GNU C compiler, you may need other standard 14628 library subroutines as well; this varies from one stub to another, but 14629 in general the stubs are likely to use any of the common library 14630 subroutines which `GCC' generates as inline code. 14631 14632 14633 File: gdb.info, Node: Debug Session, Prev: Bootstrapping, Up: Remote Stub 14634 14635 20.5.3 Putting it All Together 14636 ------------------------------ 14637 14638 In summary, when your program is ready to debug, you must follow these 14639 steps. 14640 14641 1. Make sure you have defined the supporting low-level routines 14642 (*note What You Must Do for the Stub: Bootstrapping.): 14643 `getDebugChar', `putDebugChar', 14644 `flush_i_cache', `memset', `exceptionHandler'. 14645 14646 2. Insert these lines near the top of your program: 14647 14648 set_debug_traps(); 14649 breakpoint(); 14650 14651 3. For the 680x0 stub only, you need to provide a variable called 14652 `exceptionHook'. Normally you just use: 14653 14654 void (*exceptionHook)() = 0; 14655 14656 but if before calling `set_debug_traps', you set it to point to a 14657 function in your program, that function is called when `GDB' 14658 continues after stopping on a trap (for example, bus error). The 14659 function indicated by `exceptionHook' is called with one 14660 parameter: an `int' which is the exception number. 14661 14662 4. Compile and link together: your program, the GDB debugging stub for 14663 your target architecture, and the supporting subroutines. 14664 14665 5. Make sure you have a serial connection between your target machine 14666 and the GDB host, and identify the serial port on the host. 14667 14668 6. Download your program to your target machine (or get it there by 14669 whatever means the manufacturer provides), and start it. 14670 14671 7. Start GDB on the host, and connect to the target (*note Connecting 14672 to a Remote Target: Connecting.). 14673 14674 14675 14676 File: gdb.info, Node: Configurations, Next: Controlling GDB, Prev: Remote Debugging, Up: Top 14677 14678 21 Configuration-Specific Information 14679 ************************************* 14680 14681 While nearly all GDB commands are available for all native and cross 14682 versions of the debugger, there are some exceptions. This chapter 14683 describes things that are only available in certain configurations. 14684 14685 There are three major categories of configurations: native 14686 configurations, where the host and target are the same, embedded 14687 operating system configurations, which are usually the same for several 14688 different processor architectures, and bare embedded processors, which 14689 are quite different from each other. 14690 14691 * Menu: 14692 14693 * Native:: 14694 * Embedded OS:: 14695 * Embedded Processors:: 14696 * Architectures:: 14697 14698 14699 File: gdb.info, Node: Native, Next: Embedded OS, Up: Configurations 14700 14701 21.1 Native 14702 =========== 14703 14704 This section describes details specific to particular native 14705 configurations. 14706 14707 * Menu: 14708 14709 * HP-UX:: HP-UX 14710 * BSD libkvm Interface:: Debugging BSD kernel memory images 14711 * SVR4 Process Information:: SVR4 process information 14712 * DJGPP Native:: Features specific to the DJGPP port 14713 * Cygwin Native:: Features specific to the Cygwin port 14714 * Hurd Native:: Features specific to GNU Hurd 14715 * Neutrino:: Features specific to QNX Neutrino 14716 * Darwin:: Features specific to Darwin 14717 14718 14719 File: gdb.info, Node: HP-UX, Next: BSD libkvm Interface, Up: Native 14720 14721 21.1.1 HP-UX 14722 ------------ 14723 14724 On HP-UX systems, if you refer to a function or variable name that 14725 begins with a dollar sign, GDB searches for a user or system name 14726 first, before it searches for a convenience variable. 14727 14728 14729 File: gdb.info, Node: BSD libkvm Interface, Next: SVR4 Process Information, Prev: HP-UX, Up: Native 14730 14731 21.1.2 BSD libkvm Interface 14732 --------------------------- 14733 14734 BSD-derived systems (FreeBSD/NetBSD/OpenBSD) have a kernel memory 14735 interface that provides a uniform interface for accessing kernel virtual 14736 memory images, including live systems and crash dumps. GDB uses this 14737 interface to allow you to debug live kernels and kernel crash dumps on 14738 many native BSD configurations. This is implemented as a special `kvm' 14739 debugging target. For debugging a live system, load the currently 14740 running kernel into GDB and connect to the `kvm' target: 14741 14742 (gdb) target kvm 14743 14744 For debugging crash dumps, provide the file name of the crash dump 14745 as an argument: 14746 14747 (gdb) target kvm /var/crash/bsd.0 14748 14749 Once connected to the `kvm' target, the following commands are 14750 available: 14751 14752 `kvm pcb' 14753 Set current context from the "Process Control Block" (PCB) address. 14754 14755 `kvm proc' 14756 Set current context from proc address. This command isn't 14757 available on modern FreeBSD systems. 14758 14759 14760 File: gdb.info, Node: SVR4 Process Information, Next: DJGPP Native, Prev: BSD libkvm Interface, Up: Native 14761 14762 21.1.3 SVR4 Process Information 14763 ------------------------------- 14764 14765 Many versions of SVR4 and compatible systems provide a facility called 14766 `/proc' that can be used to examine the image of a running process 14767 using file-system subroutines. If GDB is configured for an operating 14768 system with this facility, the command `info proc' is available to 14769 report information about the process running your program, or about any 14770 process running on your system. `info proc' works only on SVR4 systems 14771 that include the `procfs' code. This includes, as of this writing, 14772 GNU/Linux, OSF/1 (Digital Unix), Solaris, Irix, and Unixware, but not 14773 HP-UX, for example. 14774 14775 `info proc' 14776 `info proc PROCESS-ID' 14777 Summarize available information about any running process. If a 14778 process ID is specified by PROCESS-ID, display information about 14779 that process; otherwise display information about the program being 14780 debugged. The summary includes the debugged process ID, the 14781 command line used to invoke it, its current working directory, and 14782 its executable file's absolute file name. 14783 14784 On some systems, PROCESS-ID can be of the form `[PID]/TID' which 14785 specifies a certain thread ID within a process. If the optional 14786 PID part is missing, it means a thread from the process being 14787 debugged (the leading `/' still needs to be present, or else GDB 14788 will interpret the number as a process ID rather than a thread ID). 14789 14790 `info proc mappings' 14791 Report the memory address space ranges accessible in the program, 14792 with information on whether the process has read, write, or 14793 execute access rights to each range. On GNU/Linux systems, each 14794 memory range includes the object file which is mapped to that 14795 range, instead of the memory access rights to that range. 14796 14797 `info proc stat' 14798 `info proc status' 14799 These subcommands are specific to GNU/Linux systems. They show 14800 the process-related information, including the user ID and group 14801 ID; how many threads are there in the process; its virtual memory 14802 usage; the signals that are pending, blocked, and ignored; its 14803 TTY; its consumption of system and user time; its stack size; its 14804 `nice' value; etc. For more information, see the `proc' man page 14805 (type `man 5 proc' from your shell prompt). 14806 14807 `info proc all' 14808 Show all the information about the process described under all of 14809 the above `info proc' subcommands. 14810 14811 `set procfs-trace' 14812 This command enables and disables tracing of `procfs' API calls. 14813 14814 `show procfs-trace' 14815 Show the current state of `procfs' API call tracing. 14816 14817 `set procfs-file FILE' 14818 Tell GDB to write `procfs' API trace to the named FILE. GDB 14819 appends the trace info to the previous contents of the file. The 14820 default is to display the trace on the standard output. 14821 14822 `show procfs-file' 14823 Show the file to which `procfs' API trace is written. 14824 14825 `proc-trace-entry' 14826 `proc-trace-exit' 14827 `proc-untrace-entry' 14828 `proc-untrace-exit' 14829 These commands enable and disable tracing of entries into and exits 14830 from the `syscall' interface. 14831 14832 `info pidlist' 14833 For QNX Neutrino only, this command displays the list of all the 14834 processes and all the threads within each process. 14835 14836 `info meminfo' 14837 For QNX Neutrino only, this command displays the list of all 14838 mapinfos. 14839 14840 14841 File: gdb.info, Node: DJGPP Native, Next: Cygwin Native, Prev: SVR4 Process Information, Up: Native 14842 14843 21.1.4 Features for Debugging DJGPP Programs 14844 -------------------------------------------- 14845 14846 DJGPP is a port of the GNU development tools to MS-DOS and MS-Windows. 14847 DJGPP programs are 32-bit protected-mode programs that use the "DPMI" 14848 (DOS Protected-Mode Interface) API to run on top of real-mode DOS 14849 systems and their emulations. 14850 14851 GDB supports native debugging of DJGPP programs, and defines a few 14852 commands specific to the DJGPP port. This subsection describes those 14853 commands. 14854 14855 `info dos' 14856 This is a prefix of DJGPP-specific commands which print 14857 information about the target system and important OS structures. 14858 14859 `info dos sysinfo' 14860 This command displays assorted information about the underlying 14861 platform: the CPU type and features, the OS version and flavor, the 14862 DPMI version, and the available conventional and DPMI memory. 14863 14864 `info dos gdt' 14865 `info dos ldt' 14866 `info dos idt' 14867 These 3 commands display entries from, respectively, Global, Local, 14868 and Interrupt Descriptor Tables (GDT, LDT, and IDT). The 14869 descriptor tables are data structures which store a descriptor for 14870 each segment that is currently in use. The segment's selector is 14871 an index into a descriptor table; the table entry for that index 14872 holds the descriptor's base address and limit, and its attributes 14873 and access rights. 14874 14875 A typical DJGPP program uses 3 segments: a code segment, a data 14876 segment (used for both data and the stack), and a DOS segment 14877 (which allows access to DOS/BIOS data structures and absolute 14878 addresses in conventional memory). However, the DPMI host will 14879 usually define additional segments in order to support the DPMI 14880 environment. 14881 14882 These commands allow to display entries from the descriptor tables. 14883 Without an argument, all entries from the specified table are 14884 displayed. An argument, which should be an integer expression, 14885 means display a single entry whose index is given by the argument. 14886 For example, here's a convenient way to display information about 14887 the debugged program's data segment: 14888 14889 `(gdb) info dos ldt $ds' 14890 `0x13f: base=0x11970000 limit=0x0009ffff 32-Bit Data (Read/Write, Exp-up)' 14891 14892 14893 This comes in handy when you want to see whether a pointer is 14894 outside the data segment's limit (i.e. "garbled"). 14895 14896 `info dos pde' 14897 `info dos pte' 14898 These two commands display entries from, respectively, the Page 14899 Directory and the Page Tables. Page Directories and Page Tables 14900 are data structures which control how virtual memory addresses are 14901 mapped into physical addresses. A Page Table includes an entry 14902 for every page of memory that is mapped into the program's address 14903 space; there may be several Page Tables, each one holding up to 14904 4096 entries. A Page Directory has up to 4096 entries, one each 14905 for every Page Table that is currently in use. 14906 14907 Without an argument, `info dos pde' displays the entire Page 14908 Directory, and `info dos pte' displays all the entries in all of 14909 the Page Tables. An argument, an integer expression, given to the 14910 `info dos pde' command means display only that entry from the Page 14911 Directory table. An argument given to the `info dos pte' command 14912 means display entries from a single Page Table, the one pointed to 14913 by the specified entry in the Page Directory. 14914 14915 These commands are useful when your program uses "DMA" (Direct 14916 Memory Access), which needs physical addresses to program the DMA 14917 controller. 14918 14919 These commands are supported only with some DPMI servers. 14920 14921 `info dos address-pte ADDR' 14922 This command displays the Page Table entry for a specified linear 14923 address. The argument ADDR is a linear address which should 14924 already have the appropriate segment's base address added to it, 14925 because this command accepts addresses which may belong to _any_ 14926 segment. For example, here's how to display the Page Table entry 14927 for the page where a variable `i' is stored: 14928 14929 `(gdb) info dos address-pte __djgpp_base_address + (char *)&i' 14930 `Page Table entry for address 0x11a00d30:' 14931 `Base=0x02698000 Dirty Acc. Not-Cached Write-Back Usr Read-Write +0xd30' 14932 14933 14934 This says that `i' is stored at offset `0xd30' from the page whose 14935 physical base address is `0x02698000', and shows all the 14936 attributes of that page. 14937 14938 Note that you must cast the addresses of variables to a `char *', 14939 since otherwise the value of `__djgpp_base_address', the base 14940 address of all variables and functions in a DJGPP program, will be 14941 added using the rules of C pointer arithmetics: if `i' is declared 14942 an `int', GDB will add 4 times the value of `__djgpp_base_address' 14943 to the address of `i'. 14944 14945 Here's another example, it displays the Page Table entry for the 14946 transfer buffer: 14947 14948 `(gdb) info dos address-pte *((unsigned *)&_go32_info_block + 3)' 14949 `Page Table entry for address 0x29110:' 14950 `Base=0x00029000 Dirty Acc. Not-Cached Write-Back Usr Read-Write +0x110' 14951 14952 14953 (The `+ 3' offset is because the transfer buffer's address is the 14954 3rd member of the `_go32_info_block' structure.) The output 14955 clearly shows that this DPMI server maps the addresses in 14956 conventional memory 1:1, i.e. the physical (`0x00029000' + 14957 `0x110') and linear (`0x29110') addresses are identical. 14958 14959 This command is supported only with some DPMI servers. 14960 14961 In addition to native debugging, the DJGPP port supports remote 14962 debugging via a serial data link. The following commands are specific 14963 to remote serial debugging in the DJGPP port of GDB. 14964 14965 `set com1base ADDR' 14966 This command sets the base I/O port address of the `COM1' serial 14967 port. 14968 14969 `set com1irq IRQ' 14970 This command sets the "Interrupt Request" (`IRQ') line to use for 14971 the `COM1' serial port. 14972 14973 There are similar commands `set com2base', `set com3irq', etc. for 14974 setting the port address and the `IRQ' lines for the other 3 COM 14975 ports. 14976 14977 The related commands `show com1base', `show com1irq' etc. display 14978 the current settings of the base address and the `IRQ' lines used 14979 by the COM ports. 14980 14981 `info serial' 14982 This command prints the status of the 4 DOS serial ports. For each 14983 port, it prints whether it's active or not, its I/O base address 14984 and IRQ number, whether it uses a 16550-style FIFO, its baudrate, 14985 and the counts of various errors encountered so far. 14986 14987 14988 File: gdb.info, Node: Cygwin Native, Next: Hurd Native, Prev: DJGPP Native, Up: Native 14989 14990 21.1.5 Features for Debugging MS Windows PE Executables 14991 ------------------------------------------------------- 14992 14993 GDB supports native debugging of MS Windows programs, including DLLs 14994 with and without symbolic debugging information. 14995 14996 MS-Windows programs that call `SetConsoleMode' to switch off the 14997 special meaning of the `Ctrl-C' keystroke cannot be interrupted by 14998 typing `C-c'. For this reason, GDB on MS-Windows supports `C-<BREAK>' 14999 as an alternative interrupt key sequence, which can be used to 15000 interrupt the debuggee even if it ignores `C-c'. 15001 15002 There are various additional Cygwin-specific commands, described in 15003 this section. Working with DLLs that have no debugging symbols is 15004 described in *note Non-debug DLL Symbols::. 15005 15006 `info w32' 15007 This is a prefix of MS Windows-specific commands which print 15008 information about the target system and important OS structures. 15009 15010 `info w32 selector' 15011 This command displays information returned by the Win32 API 15012 `GetThreadSelectorEntry' function. It takes an optional argument 15013 that is evaluated to a long value to give the information about 15014 this given selector. Without argument, this command displays 15015 information about the six segment registers. 15016 15017 `info w32 thread-information-block' 15018 This command displays thread specific information stored in the 15019 Thread Information Block (readable on the X86 CPU family using 15020 `$fs' selector for 32-bit programs and `$gs' for 64-bit programs). 15021 15022 `info dll' 15023 This is a Cygwin-specific alias of `info shared'. 15024 15025 `dll-symbols' 15026 This command loads symbols from a dll similarly to add-sym command 15027 but without the need to specify a base address. 15028 15029 `set cygwin-exceptions MODE' 15030 If MODE is `on', GDB will break on exceptions that happen inside 15031 the Cygwin DLL. If MODE is `off', GDB will delay recognition of 15032 exceptions, and may ignore some exceptions which seem to be caused 15033 by internal Cygwin DLL "bookkeeping". This option is meant 15034 primarily for debugging the Cygwin DLL itself; the default value 15035 is `off' to avoid annoying GDB users with false `SIGSEGV' signals. 15036 15037 `show cygwin-exceptions' 15038 Displays whether GDB will break on exceptions that happen inside 15039 the Cygwin DLL itself. 15040 15041 `set new-console MODE' 15042 If MODE is `on' the debuggee will be started in a new console on 15043 next start. If MODE is `off', the debuggee will be started in the 15044 same console as the debugger. 15045 15046 `show new-console' 15047 Displays whether a new console is used when the debuggee is 15048 started. 15049 15050 `set new-group MODE' 15051 This boolean value controls whether the debuggee should start a 15052 new group or stay in the same group as the debugger. This affects 15053 the way the Windows OS handles `Ctrl-C'. 15054 15055 `show new-group' 15056 Displays current value of new-group boolean. 15057 15058 `set debugevents' 15059 This boolean value adds debug output concerning kernel events 15060 related to the debuggee seen by the debugger. This includes 15061 events that signal thread and process creation and exit, DLL 15062 loading and unloading, console interrupts, and debugging messages 15063 produced by the Windows `OutputDebugString' API call. 15064 15065 `set debugexec' 15066 This boolean value adds debug output concerning execute events 15067 (such as resume thread) seen by the debugger. 15068 15069 `set debugexceptions' 15070 This boolean value adds debug output concerning exceptions in the 15071 debuggee seen by the debugger. 15072 15073 `set debugmemory' 15074 This boolean value adds debug output concerning debuggee memory 15075 reads and writes by the debugger. 15076 15077 `set shell' 15078 This boolean values specifies whether the debuggee is called via a 15079 shell or directly (default value is on). 15080 15081 `show shell' 15082 Displays if the debuggee will be started with a shell. 15083 15084 15085 * Menu: 15086 15087 * Non-debug DLL Symbols:: Support for DLLs without debugging symbols 15088 15089 15090 File: gdb.info, Node: Non-debug DLL Symbols, Up: Cygwin Native 15091 15092 21.1.5.1 Support for DLLs without Debugging Symbols 15093 ................................................... 15094 15095 Very often on windows, some of the DLLs that your program relies on do 15096 not include symbolic debugging information (for example, 15097 `kernel32.dll'). When GDB doesn't recognize any debugging symbols in a 15098 DLL, it relies on the minimal amount of symbolic information contained 15099 in the DLL's export table. This section describes working with such 15100 symbols, known internally to GDB as "minimal symbols". 15101 15102 Note that before the debugged program has started execution, no DLLs 15103 will have been loaded. The easiest way around this problem is simply to 15104 start the program -- either by setting a breakpoint or letting the 15105 program run once to completion. It is also possible to force GDB to 15106 load a particular DLL before starting the executable -- see the shared 15107 library information in *note Files::, or the `dll-symbols' command in 15108 *note Cygwin Native::. Currently, explicitly loading symbols from a 15109 DLL with no debugging information will cause the symbol names to be 15110 duplicated in GDB's lookup table, which may adversely affect symbol 15111 lookup performance. 15112 15113 21.1.5.2 DLL Name Prefixes 15114 .......................... 15115 15116 In keeping with the naming conventions used by the Microsoft debugging 15117 tools, DLL export symbols are made available with a prefix based on the 15118 DLL name, for instance `KERNEL32!CreateFileA'. The plain name is also 15119 entered into the symbol table, so `CreateFileA' is often sufficient. 15120 In some cases there will be name clashes within a program (particularly 15121 if the executable itself includes full debugging symbols) necessitating 15122 the use of the fully qualified name when referring to the contents of 15123 the DLL. Use single-quotes around the name to avoid the exclamation 15124 mark ("!") being interpreted as a language operator. 15125 15126 Note that the internal name of the DLL may be all upper-case, even 15127 though the file name of the DLL is lower-case, or vice-versa. Since 15128 symbols within GDB are _case-sensitive_ this may cause some confusion. 15129 If in doubt, try the `info functions' and `info variables' commands or 15130 even `maint print msymbols' (*note Symbols::). Here's an example: 15131 15132 (gdb) info function CreateFileA 15133 All functions matching regular expression "CreateFileA": 15134 15135 Non-debugging symbols: 15136 0x77e885f4 CreateFileA 15137 0x77e885f4 KERNEL32!CreateFileA 15138 15139 (gdb) info function ! 15140 All functions matching regular expression "!": 15141 15142 Non-debugging symbols: 15143 0x6100114c cygwin1!__assert 15144 0x61004034 cygwin1!_dll_crt0@0 15145 0x61004240 cygwin1!dll_crt0(per_process *) 15146 [etc...] 15147 15148 21.1.5.3 Working with Minimal Symbols 15149 ..................................... 15150 15151 Symbols extracted from a DLL's export table do not contain very much 15152 type information. All that GDB can do is guess whether a symbol refers 15153 to a function or variable depending on the linker section that contains 15154 the symbol. Also note that the actual contents of the memory contained 15155 in a DLL are not available unless the program is running. This means 15156 that you cannot examine the contents of a variable or disassemble a 15157 function within a DLL without a running program. 15158 15159 Variables are generally treated as pointers and dereferenced 15160 automatically. For this reason, it is often necessary to prefix a 15161 variable name with the address-of operator ("&") and provide explicit 15162 type information in the command. Here's an example of the type of 15163 problem: 15164 15165 (gdb) print 'cygwin1!__argv' 15166 $1 = 268572168 15167 15168 (gdb) x 'cygwin1!__argv' 15169 0x10021610: "\230y\"" 15170 15171 And two possible solutions: 15172 15173 (gdb) print ((char **)'cygwin1!__argv')[0] 15174 $2 = 0x22fd98 "/cygdrive/c/mydirectory/myprogram" 15175 15176 (gdb) x/2x &'cygwin1!__argv' 15177 0x610c0aa8 <cygwin1!__argv>: 0x10021608 0x00000000 15178 (gdb) x/x 0x10021608 15179 0x10021608: 0x0022fd98 15180 (gdb) x/s 0x0022fd98 15181 0x22fd98: "/cygdrive/c/mydirectory/myprogram" 15182 15183 Setting a break point within a DLL is possible even before the 15184 program starts execution. However, under these circumstances, GDB can't 15185 examine the initial instructions of the function in order to skip the 15186 function's frame set-up code. You can work around this by using "*&" to 15187 set the breakpoint at a raw memory address: 15188 15189 (gdb) break *&'python22!PyOS_Readline' 15190 Breakpoint 1 at 0x1e04eff0 15191 15192 The author of these extensions is not entirely convinced that 15193 setting a break point within a shared DLL like `kernel32.dll' is 15194 completely safe. 15195 15196 15197 File: gdb.info, Node: Hurd Native, Next: Neutrino, Prev: Cygwin Native, Up: Native 15198 15199 21.1.6 Commands Specific to GNU Hurd Systems 15200 -------------------------------------------- 15201 15202 This subsection describes GDB commands specific to the GNU Hurd native 15203 debugging. 15204 15205 `set signals' 15206 `set sigs' 15207 This command toggles the state of inferior signal interception by 15208 GDB. Mach exceptions, such as breakpoint traps, are not affected 15209 by this command. `sigs' is a shorthand alias for `signals'. 15210 15211 `show signals' 15212 `show sigs' 15213 Show the current state of intercepting inferior's signals. 15214 15215 `set signal-thread' 15216 `set sigthread' 15217 This command tells GDB which thread is the `libc' signal thread. 15218 That thread is run when a signal is delivered to a running 15219 process. `set sigthread' is the shorthand alias of `set 15220 signal-thread'. 15221 15222 `show signal-thread' 15223 `show sigthread' 15224 These two commands show which thread will run when the inferior is 15225 delivered a signal. 15226 15227 `set stopped' 15228 This commands tells GDB that the inferior process is stopped, as 15229 with the `SIGSTOP' signal. The stopped process can be continued 15230 by delivering a signal to it. 15231 15232 `show stopped' 15233 This command shows whether GDB thinks the debuggee is stopped. 15234 15235 `set exceptions' 15236 Use this command to turn off trapping of exceptions in the 15237 inferior. When exception trapping is off, neither breakpoints nor 15238 single-stepping will work. To restore the default, set exception 15239 trapping on. 15240 15241 `show exceptions' 15242 Show the current state of trapping exceptions in the inferior. 15243 15244 `set task pause' 15245 This command toggles task suspension when GDB has control. 15246 Setting it to on takes effect immediately, and the task is 15247 suspended whenever GDB gets control. Setting it to off will take 15248 effect the next time the inferior is continued. If this option is 15249 set to off, you can use `set thread default pause on' or `set 15250 thread pause on' (see below) to pause individual threads. 15251 15252 `show task pause' 15253 Show the current state of task suspension. 15254 15255 `set task detach-suspend-count' 15256 This command sets the suspend count the task will be left with when 15257 GDB detaches from it. 15258 15259 `show task detach-suspend-count' 15260 Show the suspend count the task will be left with when detaching. 15261 15262 `set task exception-port' 15263 `set task excp' 15264 This command sets the task exception port to which GDB will 15265 forward exceptions. The argument should be the value of the "send 15266 rights" of the task. `set task excp' is a shorthand alias. 15267 15268 `set noninvasive' 15269 This command switches GDB to a mode that is the least invasive as 15270 far as interfering with the inferior is concerned. This is the 15271 same as using `set task pause', `set exceptions', and `set 15272 signals' to values opposite to the defaults. 15273 15274 `info send-rights' 15275 `info receive-rights' 15276 `info port-rights' 15277 `info port-sets' 15278 `info dead-names' 15279 `info ports' 15280 `info psets' 15281 These commands display information about, respectively, send 15282 rights, receive rights, port rights, port sets, and dead names of 15283 a task. There are also shorthand aliases: `info ports' for `info 15284 port-rights' and `info psets' for `info port-sets'. 15285 15286 `set thread pause' 15287 This command toggles current thread suspension when GDB has 15288 control. Setting it to on takes effect immediately, and the 15289 current thread is suspended whenever GDB gets control. Setting it 15290 to off will take effect the next time the inferior is continued. 15291 Normally, this command has no effect, since when GDB has control, 15292 the whole task is suspended. However, if you used `set task pause 15293 off' (see above), this command comes in handy to suspend only the 15294 current thread. 15295 15296 `show thread pause' 15297 This command shows the state of current thread suspension. 15298 15299 `set thread run' 15300 This command sets whether the current thread is allowed to run. 15301 15302 `show thread run' 15303 Show whether the current thread is allowed to run. 15304 15305 `set thread detach-suspend-count' 15306 This command sets the suspend count GDB will leave on a thread 15307 when detaching. This number is relative to the suspend count 15308 found by GDB when it notices the thread; use `set thread 15309 takeover-suspend-count' to force it to an absolute value. 15310 15311 `show thread detach-suspend-count' 15312 Show the suspend count GDB will leave on the thread when detaching. 15313 15314 `set thread exception-port' 15315 `set thread excp' 15316 Set the thread exception port to which to forward exceptions. This 15317 overrides the port set by `set task exception-port' (see above). 15318 `set thread excp' is the shorthand alias. 15319 15320 `set thread takeover-suspend-count' 15321 Normally, GDB's thread suspend counts are relative to the value 15322 GDB finds when it notices each thread. This command changes the 15323 suspend counts to be absolute instead. 15324 15325 `set thread default' 15326 `show thread default' 15327 Each of the above `set thread' commands has a `set thread default' 15328 counterpart (e.g., `set thread default pause', `set thread default 15329 exception-port', etc.). The `thread default' variety of commands 15330 sets the default thread properties for all threads; you can then 15331 change the properties of individual threads with the non-default 15332 commands. 15333 15334 15335 File: gdb.info, Node: Neutrino, Next: Darwin, Prev: Hurd Native, Up: Native 15336 15337 21.1.7 QNX Neutrino 15338 ------------------- 15339 15340 GDB provides the following commands specific to the QNX Neutrino target: 15341 15342 `set debug nto-debug' 15343 When set to on, enables debugging messages specific to the QNX 15344 Neutrino support. 15345 15346 `show debug nto-debug' 15347 Show the current state of QNX Neutrino messages. 15348 15349 15350 File: gdb.info, Node: Darwin, Prev: Neutrino, Up: Native 15351 15352 21.1.8 Darwin 15353 ------------- 15354 15355 GDB provides the following commands specific to the Darwin target: 15356 15357 `set debug darwin NUM' 15358 When set to a non zero value, enables debugging messages specific 15359 to the Darwin support. Higher values produce more verbose output. 15360 15361 `show debug darwin' 15362 Show the current state of Darwin messages. 15363 15364 `set debug mach-o NUM' 15365 When set to a non zero value, enables debugging messages while GDB 15366 is reading Darwin object files. ("Mach-O" is the file format used 15367 on Darwin for object and executable files.) Higher values produce 15368 more verbose output. This is a command to diagnose problems 15369 internal to GDB and should not be needed in normal usage. 15370 15371 `show debug mach-o' 15372 Show the current state of Mach-O file messages. 15373 15374 `set mach-exceptions on' 15375 `set mach-exceptions off' 15376 On Darwin, faults are first reported as a Mach exception and are 15377 then mapped to a Posix signal. Use this command to turn on 15378 trapping of Mach exceptions in the inferior. This might be 15379 sometimes useful to better understand the cause of a fault. The 15380 default is off. 15381 15382 `show mach-exceptions' 15383 Show the current state of exceptions trapping. 15384 15385 15386 File: gdb.info, Node: Embedded OS, Next: Embedded Processors, Prev: Native, Up: Configurations 15387 15388 21.2 Embedded Operating Systems 15389 =============================== 15390 15391 This section describes configurations involving the debugging of 15392 embedded operating systems that are available for several different 15393 architectures. 15394 15395 * Menu: 15396 15397 * VxWorks:: Using GDB with VxWorks 15398 15399 GDB includes the ability to debug programs running on various 15400 real-time operating systems. 15401 15402 15403 File: gdb.info, Node: VxWorks, Up: Embedded OS 15404 15405 21.2.1 Using GDB with VxWorks 15406 ----------------------------- 15407 15408 `target vxworks MACHINENAME' 15409 A VxWorks system, attached via TCP/IP. The argument MACHINENAME 15410 is the target system's machine name or IP address. 15411 15412 15413 On VxWorks, `load' links FILENAME dynamically on the current target 15414 system as well as adding its symbols in GDB. 15415 15416 GDB enables developers to spawn and debug tasks running on networked 15417 VxWorks targets from a Unix host. Already-running tasks spawned from 15418 the VxWorks shell can also be debugged. GDB uses code that runs on 15419 both the Unix host and on the VxWorks target. The program `gdb' is 15420 installed and executed on the Unix host. (It may be installed with the 15421 name `vxgdb', to distinguish it from a GDB for debugging programs on 15422 the host itself.) 15423 15424 `VxWorks-timeout ARGS' 15425 All VxWorks-based targets now support the option `vxworks-timeout'. 15426 This option is set by the user, and ARGS represents the number of 15427 seconds GDB waits for responses to rpc's. You might use this if 15428 your VxWorks target is a slow software simulator or is on the far 15429 side of a thin network line. 15430 15431 The following information on connecting to VxWorks was current when 15432 this manual was produced; newer releases of VxWorks may use revised 15433 procedures. 15434 15435 To use GDB with VxWorks, you must rebuild your VxWorks kernel to 15436 include the remote debugging interface routines in the VxWorks library 15437 `rdb.a'. To do this, define `INCLUDE_RDB' in the VxWorks configuration 15438 file `configAll.h' and rebuild your VxWorks kernel. The resulting 15439 kernel contains `rdb.a', and spawns the source debugging task 15440 `tRdbTask' when VxWorks is booted. For more information on configuring 15441 and remaking VxWorks, see the manufacturer's manual. 15442 15443 Once you have included `rdb.a' in your VxWorks system image and set 15444 your Unix execution search path to find GDB, you are ready to run GDB. 15445 From your Unix host, run `gdb' (or `vxgdb', depending on your 15446 installation). 15447 15448 GDB comes up showing the prompt: 15449 15450 (vxgdb) 15451 15452 * Menu: 15453 15454 * VxWorks Connection:: Connecting to VxWorks 15455 * VxWorks Download:: VxWorks download 15456 * VxWorks Attach:: Running tasks 15457 15458 15459 File: gdb.info, Node: VxWorks Connection, Next: VxWorks Download, Up: VxWorks 15460 15461 21.2.1.1 Connecting to VxWorks 15462 .............................. 15463 15464 The GDB command `target' lets you connect to a VxWorks target on the 15465 network. To connect to a target whose host name is "`tt'", type: 15466 15467 (vxgdb) target vxworks tt 15468 15469 GDB displays messages like these: 15470 15471 Attaching remote machine across net... 15472 Connected to tt. 15473 15474 GDB then attempts to read the symbol tables of any object modules 15475 loaded into the VxWorks target since it was last booted. GDB locates 15476 these files by searching the directories listed in the command search 15477 path (*note Your Program's Environment: Environment.); if it fails to 15478 find an object file, it displays a message such as: 15479 15480 prog.o: No such file or directory. 15481 15482 When this happens, add the appropriate directory to the search path 15483 with the GDB command `path', and execute the `target' command again. 15484 15485 15486 File: gdb.info, Node: VxWorks Download, Next: VxWorks Attach, Prev: VxWorks Connection, Up: VxWorks 15487 15488 21.2.1.2 VxWorks Download 15489 ......................... 15490 15491 If you have connected to the VxWorks target and you want to debug an 15492 object that has not yet been loaded, you can use the GDB `load' command 15493 to download a file from Unix to VxWorks incrementally. The object file 15494 given as an argument to the `load' command is actually opened twice: 15495 first by the VxWorks target in order to download the code, then by GDB 15496 in order to read the symbol table. This can lead to problems if the 15497 current working directories on the two systems differ. If both systems 15498 have NFS mounted the same filesystems, you can avoid these problems by 15499 using absolute paths. Otherwise, it is simplest to set the working 15500 directory on both systems to the directory in which the object file 15501 resides, and then to reference the file by its name, without any path. 15502 For instance, a program `prog.o' may reside in `VXPATH/vw/demo/rdb' in 15503 VxWorks and in `HOSTPATH/vw/demo/rdb' on the host. To load this 15504 program, type this on VxWorks: 15505 15506 -> cd "VXPATH/vw/demo/rdb" 15507 15508 Then, in GDB, type: 15509 15510 (vxgdb) cd HOSTPATH/vw/demo/rdb 15511 (vxgdb) load prog.o 15512 15513 GDB displays a response similar to this: 15514 15515 Reading symbol data from wherever/vw/demo/rdb/prog.o... done. 15516 15517 You can also use the `load' command to reload an object module after 15518 editing and recompiling the corresponding source file. Note that this 15519 makes GDB delete all currently-defined breakpoints, auto-displays, and 15520 convenience variables, and to clear the value history. (This is 15521 necessary in order to preserve the integrity of debugger's data 15522 structures that reference the target system's symbol table.) 15523 15524 15525 File: gdb.info, Node: VxWorks Attach, Prev: VxWorks Download, Up: VxWorks 15526 15527 21.2.1.3 Running Tasks 15528 ...................... 15529 15530 You can also attach to an existing task using the `attach' command as 15531 follows: 15532 15533 (vxgdb) attach TASK 15534 15535 where TASK is the VxWorks hexadecimal task ID. The task can be running 15536 or suspended when you attach to it. Running tasks are suspended at the 15537 time of attachment. 15538 15539 15540 File: gdb.info, Node: Embedded Processors, Next: Architectures, Prev: Embedded OS, Up: Configurations 15541 15542 21.3 Embedded Processors 15543 ======================== 15544 15545 This section goes into details specific to particular embedded 15546 configurations. 15547 15548 Whenever a specific embedded processor has a simulator, GDB allows 15549 to send an arbitrary command to the simulator. 15550 15551 `sim COMMAND' 15552 Send an arbitrary COMMAND string to the simulator. Consult the 15553 documentation for the specific simulator in use for information 15554 about acceptable commands. 15555 15556 * Menu: 15557 15558 * ARM:: ARM RDI 15559 * M32R/D:: Renesas M32R/D 15560 * M68K:: Motorola M68K 15561 * MicroBlaze:: Xilinx MicroBlaze 15562 * MIPS Embedded:: MIPS Embedded 15563 * OpenRISC 1000:: OpenRisc 1000 15564 * PA:: HP PA Embedded 15565 * PowerPC Embedded:: PowerPC Embedded 15566 * Sparclet:: Tsqware Sparclet 15567 * Sparclite:: Fujitsu Sparclite 15568 * Z8000:: Zilog Z8000 15569 * AVR:: Atmel AVR 15570 * CRIS:: CRIS 15571 * Super-H:: Renesas Super-H 15572 15573 15574 File: gdb.info, Node: ARM, Next: M32R/D, Up: Embedded Processors 15575 15576 21.3.1 ARM 15577 ---------- 15578 15579 `target rdi DEV' 15580 ARM Angel monitor, via RDI library interface to ADP protocol. You 15581 may use this target to communicate with both boards running the 15582 Angel monitor, or with the EmbeddedICE JTAG debug device. 15583 15584 `target rdp DEV' 15585 ARM Demon monitor. 15586 15587 15588 GDB provides the following ARM-specific commands: 15589 15590 `set arm disassembler' 15591 This commands selects from a list of disassembly styles. The 15592 `"std"' style is the standard style. 15593 15594 `show arm disassembler' 15595 Show the current disassembly style. 15596 15597 `set arm apcs32' 15598 This command toggles ARM operation mode between 32-bit and 26-bit. 15599 15600 `show arm apcs32' 15601 Display the current usage of the ARM 32-bit mode. 15602 15603 `set arm fpu FPUTYPE' 15604 This command sets the ARM floating-point unit (FPU) type. The 15605 argument FPUTYPE can be one of these: 15606 15607 `auto' 15608 Determine the FPU type by querying the OS ABI. 15609 15610 `softfpa' 15611 Software FPU, with mixed-endian doubles on little-endian ARM 15612 processors. 15613 15614 `fpa' 15615 GCC-compiled FPA co-processor. 15616 15617 `softvfp' 15618 Software FPU with pure-endian doubles. 15619 15620 `vfp' 15621 VFP co-processor. 15622 15623 `show arm fpu' 15624 Show the current type of the FPU. 15625 15626 `set arm abi' 15627 This command forces GDB to use the specified ABI. 15628 15629 `show arm abi' 15630 Show the currently used ABI. 15631 15632 `set arm fallback-mode (arm|thumb|auto)' 15633 GDB uses the symbol table, when available, to determine whether 15634 instructions are ARM or Thumb. This command controls GDB's 15635 default behavior when the symbol table is not available. The 15636 default is `auto', which causes GDB to use the current execution 15637 mode (from the `T' bit in the `CPSR' register). 15638 15639 `show arm fallback-mode' 15640 Show the current fallback instruction mode. 15641 15642 `set arm force-mode (arm|thumb|auto)' 15643 This command overrides use of the symbol table to determine whether 15644 instructions are ARM or Thumb. The default is `auto', which 15645 causes GDB to use the symbol table and then the setting of `set 15646 arm fallback-mode'. 15647 15648 `show arm force-mode' 15649 Show the current forced instruction mode. 15650 15651 `set debug arm' 15652 Toggle whether to display ARM-specific debugging messages from the 15653 ARM target support subsystem. 15654 15655 `show debug arm' 15656 Show whether ARM-specific debugging messages are enabled. 15657 15658 The following commands are available when an ARM target is debugged 15659 using the RDI interface: 15660 15661 `rdilogfile [FILE]' 15662 Set the filename for the ADP (Angel Debugger Protocol) packet log. 15663 With an argument, sets the log file to the specified FILE. With 15664 no argument, show the current log file name. The default log file 15665 is `rdi.log'. 15666 15667 `rdilogenable [ARG]' 15668 Control logging of ADP packets. With an argument of 1 or `"yes"' 15669 enables logging, with an argument 0 or `"no"' disables it. With 15670 no arguments displays the current setting. When logging is 15671 enabled, ADP packets exchanged between GDB and the RDI target 15672 device are logged to a file. 15673 15674 `set rdiromatzero' 15675 Tell GDB whether the target has ROM at address 0. If on, vector 15676 catching is disabled, so that zero address can be used. If off 15677 (the default), vector catching is enabled. For this command to 15678 take effect, it needs to be invoked prior to the `target rdi' 15679 command. 15680 15681 `show rdiromatzero' 15682 Show the current setting of ROM at zero address. 15683 15684 `set rdiheartbeat' 15685 Enable or disable RDI heartbeat packets. It is not recommended to 15686 turn on this option, since it confuses ARM and EPI JTAG interface, 15687 as well as the Angel monitor. 15688 15689 `show rdiheartbeat' 15690 Show the setting of RDI heartbeat packets. 15691 15692 `target sim [SIMARGS] ...' 15693 The GDB ARM simulator accepts the following optional arguments. 15694 15695 `--swi-support=TYPE' 15696 Tell the simulator which SWI interfaces to support. TYPE may 15697 be a comma separated list of the following values. The 15698 default value is `all'. 15699 15700 `none' 15701 15702 `demon' 15703 15704 `angel' 15705 15706 `redboot' 15707 15708 `all' 15709 15710 15711 File: gdb.info, Node: M32R/D, Next: M68K, Prev: ARM, Up: Embedded Processors 15712 15713 21.3.2 Renesas M32R/D and M32R/SDI 15714 ---------------------------------- 15715 15716 `target m32r DEV' 15717 Renesas M32R/D ROM monitor. 15718 15719 `target m32rsdi DEV' 15720 Renesas M32R SDI server, connected via parallel port to the board. 15721 15722 The following GDB commands are specific to the M32R monitor: 15723 15724 `set download-path PATH' 15725 Set the default path for finding downloadable SREC files. 15726 15727 `show download-path' 15728 Show the default path for downloadable SREC files. 15729 15730 `set board-address ADDR' 15731 Set the IP address for the M32R-EVA target board. 15732 15733 `show board-address' 15734 Show the current IP address of the target board. 15735 15736 `set server-address ADDR' 15737 Set the IP address for the download server, which is the GDB's 15738 host machine. 15739 15740 `show server-address' 15741 Display the IP address of the download server. 15742 15743 `upload [FILE]' 15744 Upload the specified SREC FILE via the monitor's Ethernet upload 15745 capability. If no FILE argument is given, the current executable 15746 file is uploaded. 15747 15748 `tload [FILE]' 15749 Test the `upload' command. 15750 15751 The following commands are available for M32R/SDI: 15752 15753 `sdireset' 15754 This command resets the SDI connection. 15755 15756 `sdistatus' 15757 This command shows the SDI connection status. 15758 15759 `debug_chaos' 15760 Instructs the remote that M32R/Chaos debugging is to be used. 15761 15762 `use_debug_dma' 15763 Instructs the remote to use the DEBUG_DMA method of accessing 15764 memory. 15765 15766 `use_mon_code' 15767 Instructs the remote to use the MON_CODE method of accessing 15768 memory. 15769 15770 `use_ib_break' 15771 Instructs the remote to set breakpoints by IB break. 15772 15773 `use_dbt_break' 15774 Instructs the remote to set breakpoints by DBT. 15775 15776 15777 File: gdb.info, Node: M68K, Next: MicroBlaze, Prev: M32R/D, Up: Embedded Processors 15778 15779 21.3.3 M68k 15780 ----------- 15781 15782 The Motorola m68k configuration includes ColdFire support, and a target 15783 command for the following ROM monitor. 15784 15785 `target dbug DEV' 15786 dBUG ROM monitor for Motorola ColdFire. 15787 15788 15789 15790 File: gdb.info, Node: MicroBlaze, Next: MIPS Embedded, Prev: M68K, Up: Embedded Processors 15791 15792 21.3.4 MicroBlaze 15793 ----------------- 15794 15795 The MicroBlaze is a soft-core processor supported on various Xilinx 15796 FPGAs, such as Spartan or Virtex series. Boards with these processors 15797 usually have JTAG ports which connect to a host system running the 15798 Xilinx Embedded Development Kit (EDK) or Software Development Kit (SDK). 15799 This host system is used to download the configuration bitstream to the 15800 target FPGA. The Xilinx Microprocessor Debugger (XMD) program 15801 communicates with the target board using the JTAG interface and 15802 presents a `gdbserver' interface to the board. By default `xmd' uses 15803 port `1234'. (While it is possible to change this default port, it 15804 requires the use of undocumented `xmd' commands. Contact Xilinx 15805 support if you need to do this.) 15806 15807 Use these GDB commands to connect to the MicroBlaze target processor. 15808 15809 `target remote :1234' 15810 Use this command to connect to the target if you are running GDB 15811 on the same system as `xmd'. 15812 15813 `target remote XMD-HOST:1234' 15814 Use this command to connect to the target if it is connected to 15815 `xmd' running on a different system named XMD-HOST. 15816 15817 `load' 15818 Use this command to download a program to the MicroBlaze target. 15819 15820 `set debug microblaze N' 15821 Enable MicroBlaze-specific debugging messages if non-zero. 15822 15823 `show debug microblaze N' 15824 Show MicroBlaze-specific debugging level. 15825 15826 15827 File: gdb.info, Node: MIPS Embedded, Next: OpenRISC 1000, Prev: MicroBlaze, Up: Embedded Processors 15828 15829 21.3.5 MIPS Embedded 15830 -------------------- 15831 15832 GDB can use the MIPS remote debugging protocol to talk to a MIPS board 15833 attached to a serial line. This is available when you configure GDB 15834 with `--target=mips-idt-ecoff'. 15835 15836 Use these GDB commands to specify the connection to your target 15837 board: 15838 15839 `target mips PORT' 15840 To run a program on the board, start up `gdb' with the name of 15841 your program as the argument. To connect to the board, use the 15842 command `target mips PORT', where PORT is the name of the serial 15843 port connected to the board. If the program has not already been 15844 downloaded to the board, you may use the `load' command to 15845 download it. You can then use all the usual GDB commands. 15846 15847 For example, this sequence connects to the target board through a 15848 serial port, and loads and runs a program called PROG through the 15849 debugger: 15850 15851 host$ gdb PROG 15852 GDB is free software and ... 15853 (gdb) target mips /dev/ttyb 15854 (gdb) load PROG 15855 (gdb) run 15856 15857 `target mips HOSTNAME:PORTNUMBER' 15858 On some GDB host configurations, you can specify a TCP connection 15859 (for instance, to a serial line managed by a terminal 15860 concentrator) instead of a serial port, using the syntax 15861 `HOSTNAME:PORTNUMBER'. 15862 15863 `target pmon PORT' 15864 PMON ROM monitor. 15865 15866 `target ddb PORT' 15867 NEC's DDB variant of PMON for Vr4300. 15868 15869 `target lsi PORT' 15870 LSI variant of PMON. 15871 15872 `target r3900 DEV' 15873 Densan DVE-R3900 ROM monitor for Toshiba R3900 Mips. 15874 15875 `target array DEV' 15876 Array Tech LSI33K RAID controller board. 15877 15878 15879 GDB also supports these special commands for MIPS targets: 15880 15881 `set mipsfpu double' 15882 `set mipsfpu single' 15883 `set mipsfpu none' 15884 `set mipsfpu auto' 15885 `show mipsfpu' 15886 If your target board does not support the MIPS floating point 15887 coprocessor, you should use the command `set mipsfpu none' (if you 15888 need this, you may wish to put the command in your GDB init file). 15889 This tells GDB how to find the return value of functions which 15890 return floating point values. It also allows GDB to avoid saving 15891 the floating point registers when calling functions on the board. 15892 If you are using a floating point coprocessor with only single 15893 precision floating point support, as on the R4650 processor, use 15894 the command `set mipsfpu single'. The default double precision 15895 floating point coprocessor may be selected using `set mipsfpu 15896 double'. 15897 15898 In previous versions the only choices were double precision or no 15899 floating point, so `set mipsfpu on' will select double precision 15900 and `set mipsfpu off' will select no floating point. 15901 15902 As usual, you can inquire about the `mipsfpu' variable with `show 15903 mipsfpu'. 15904 15905 `set timeout SECONDS' 15906 `set retransmit-timeout SECONDS' 15907 `show timeout' 15908 `show retransmit-timeout' 15909 You can control the timeout used while waiting for a packet, in 15910 the MIPS remote protocol, with the `set timeout SECONDS' command. 15911 The default is 5 seconds. Similarly, you can control the timeout 15912 used while waiting for an acknowledgment of a packet with the `set 15913 retransmit-timeout SECONDS' command. The default is 3 seconds. 15914 You can inspect both values with `show timeout' and `show 15915 retransmit-timeout'. (These commands are _only_ available when 15916 GDB is configured for `--target=mips-idt-ecoff'.) 15917 15918 The timeout set by `set timeout' does not apply when GDB is 15919 waiting for your program to stop. In that case, GDB waits forever 15920 because it has no way of knowing how long the program is going to 15921 run before stopping. 15922 15923 `set syn-garbage-limit NUM' 15924 Limit the maximum number of characters GDB should ignore when it 15925 tries to synchronize with the remote target. The default is 10 15926 characters. Setting the limit to -1 means there's no limit. 15927 15928 `show syn-garbage-limit' 15929 Show the current limit on the number of characters to ignore when 15930 trying to synchronize with the remote system. 15931 15932 `set monitor-prompt PROMPT' 15933 Tell GDB to expect the specified PROMPT string from the remote 15934 monitor. The default depends on the target: 15935 pmon target 15936 `PMON' 15937 15938 ddb target 15939 `NEC010' 15940 15941 lsi target 15942 `PMON>' 15943 15944 `show monitor-prompt' 15945 Show the current strings GDB expects as the prompt from the remote 15946 monitor. 15947 15948 `set monitor-warnings' 15949 Enable or disable monitor warnings about hardware breakpoints. 15950 This has effect only for the `lsi' target. When on, GDB will 15951 display warning messages whose codes are returned by the `lsi' 15952 PMON monitor for breakpoint commands. 15953 15954 `show monitor-warnings' 15955 Show the current setting of printing monitor warnings. 15956 15957 `pmon COMMAND' 15958 This command allows sending an arbitrary COMMAND string to the 15959 monitor. The monitor must be in debug mode for this to work. 15960 15961 15962 File: gdb.info, Node: OpenRISC 1000, Next: PA, Prev: MIPS Embedded, Up: Embedded Processors 15963 15964 21.3.6 OpenRISC 1000 15965 -------------------- 15966 15967 See OR1k Architecture document (`www.opencores.org') for more 15968 information about platform and commands. 15969 15970 `target jtag jtag://HOST:PORT' 15971 Connects to remote JTAG server. JTAG remote server can be either 15972 an or1ksim or JTAG server, connected via parallel port to the 15973 board. 15974 15975 Example: `target jtag jtag://localhost:9999' 15976 15977 `or1ksim COMMAND' 15978 If connected to `or1ksim' OpenRISC 1000 Architectural Simulator, 15979 proprietary commands can be executed. 15980 15981 `info or1k spr' 15982 Displays spr groups. 15983 15984 `info or1k spr GROUP' 15985 `info or1k spr GROUPNO' 15986 Displays register names in selected group. 15987 15988 `info or1k spr GROUP REGISTER' 15989 `info or1k spr REGISTER' 15990 `info or1k spr GROUPNO REGISTERNO' 15991 `info or1k spr REGISTERNO' 15992 Shows information about specified spr register. 15993 15994 `spr GROUP REGISTER VALUE' 15995 `spr REGISTER VALUE' 15996 `spr GROUPNO REGISTERNO VALUE' 15997 `spr REGISTERNO VALUE' 15998 Writes VALUE to specified spr register. 15999 16000 Some implementations of OpenRISC 1000 Architecture also have 16001 hardware trace. It is very similar to GDB trace, except it does not 16002 interfere with normal program execution and is thus much faster. 16003 Hardware breakpoints/watchpoint triggers can be set using: 16004 `$LEA/$LDATA' 16005 Load effective address/data 16006 16007 `$SEA/$SDATA' 16008 Store effective address/data 16009 16010 `$AEA/$ADATA' 16011 Access effective address ($SEA or $LEA) or data ($SDATA/$LDATA) 16012 16013 `$FETCH' 16014 Fetch data 16015 16016 When triggered, it can capture low level data, like: `PC', `LSEA', 16017 `LDATA', `SDATA', `READSPR', `WRITESPR', `INSTR'. 16018 16019 `htrace' commands: 16020 `hwatch CONDITIONAL' 16021 Set hardware watchpoint on combination of Load/Store Effective 16022 Address(es) or Data. For example: 16023 16024 `hwatch ($LEA == my_var) && ($LDATA < 50) || ($SEA == my_var) && 16025 ($SDATA >= 50)' 16026 16027 `hwatch ($LEA == my_var) && ($LDATA < 50) || ($SEA == my_var) && 16028 ($SDATA >= 50)' 16029 16030 `htrace info' 16031 Display information about current HW trace configuration. 16032 16033 `htrace trigger CONDITIONAL' 16034 Set starting criteria for HW trace. 16035 16036 `htrace qualifier CONDITIONAL' 16037 Set acquisition qualifier for HW trace. 16038 16039 `htrace stop CONDITIONAL' 16040 Set HW trace stopping criteria. 16041 16042 `htrace record [DATA]*' 16043 Selects the data to be recorded, when qualifier is met and HW 16044 trace was triggered. 16045 16046 `htrace enable' 16047 `htrace disable' 16048 Enables/disables the HW trace. 16049 16050 `htrace rewind [FILENAME]' 16051 Clears currently recorded trace data. 16052 16053 If filename is specified, new trace file is made and any newly 16054 collected data will be written there. 16055 16056 `htrace print [START [LEN]]' 16057 Prints trace buffer, using current record configuration. 16058 16059 `htrace mode continuous' 16060 Set continuous trace mode. 16061 16062 `htrace mode suspend' 16063 Set suspend trace mode. 16064 16065 16066 16067 File: gdb.info, Node: PowerPC Embedded, Next: Sparclet, Prev: PA, Up: Embedded Processors 16068 16069 21.3.7 PowerPC Embedded 16070 ----------------------- 16071 16072 GDB supports using the DVC (Data Value Compare) register to implement 16073 in hardware simple hardware watchpoint conditions of the form: 16074 16075 (gdb) watch ADDRESS|VARIABLE \ 16076 if ADDRESS|VARIABLE == CONSTANT EXPRESSION 16077 16078 The DVC register will be automatically used when GDB detects such 16079 pattern in a condition expression, and the created watchpoint uses one 16080 debug register (either the `exact-watchpoints' option is on and the 16081 variable is scalar, or the variable has a length of one byte). This 16082 feature is available in native GDB running on a Linux kernel version 16083 2.6.34 or newer. 16084 16085 When running on PowerPC embedded processors, GDB automatically uses 16086 ranged hardware watchpoints, unless the `exact-watchpoints' option is 16087 on, in which case watchpoints using only one debug register are created 16088 when watching variables of scalar types. 16089 16090 You can create an artificial array to watch an arbitrary memory 16091 region using one of the following commands (*note Expressions::): 16092 16093 (gdb) watch *((char *) ADDRESS)@LENGTH 16094 (gdb) watch {char[LENGTH]} ADDRESS 16095 16096 PowerPC embedded processors support hardware accelerated "ranged 16097 breakpoints". A ranged breakpoint stops execution of the inferior 16098 whenever it executes an instruction at any address within the range it 16099 specifies. To set a ranged breakpoint in GDB, use the `break-range' 16100 command. 16101 16102 GDB provides the following PowerPC-specific commands: 16103 16104 `break-range START-LOCATION, END-LOCATION' 16105 Set a breakpoint for an address range. START-LOCATION and 16106 END-LOCATION can specify a function name, a line number, an offset 16107 of lines from the current line or from the start location, or an 16108 address of an instruction (see *note Specify Location::, for a 16109 list of all the possible ways to specify a LOCATION.) The 16110 breakpoint will stop execution of the inferior whenever it 16111 executes an instruction at any address within the specified range, 16112 (including START-LOCATION and END-LOCATION.) 16113 16114 `set powerpc soft-float' 16115 `show powerpc soft-float' 16116 Force GDB to use (or not use) a software floating point calling 16117 convention. By default, GDB selects the calling convention based 16118 on the selected architecture and the provided executable file. 16119 16120 `set powerpc vector-abi' 16121 `show powerpc vector-abi' 16122 Force GDB to use the specified calling convention for vector 16123 arguments and return values. The valid options are `auto'; 16124 `generic', to avoid vector registers even if they are present; 16125 `altivec', to use AltiVec registers; and `spe' to use SPE 16126 registers. By default, GDB selects the calling convention based 16127 on the selected architecture and the provided executable file. 16128 16129 `set powerpc exact-watchpoints' 16130 `show powerpc exact-watchpoints' 16131 Allow GDB to use only one debug register when watching a variable 16132 of scalar type, thus assuming that the variable is accessed 16133 through the address of its first byte. 16134 16135 `target dink32 DEV' 16136 DINK32 ROM monitor. 16137 16138 `target ppcbug DEV' 16139 16140 `target ppcbug1 DEV' 16141 PPCBUG ROM monitor for PowerPC. 16142 16143 `target sds DEV' 16144 SDS monitor, running on a PowerPC board (such as Motorola's ADS). 16145 16146 The following commands specific to the SDS protocol are supported by 16147 GDB: 16148 16149 `set sdstimeout NSEC' 16150 Set the timeout for SDS protocol reads to be NSEC seconds. The 16151 default is 2 seconds. 16152 16153 `show sdstimeout' 16154 Show the current value of the SDS timeout. 16155 16156 `sds COMMAND' 16157 Send the specified COMMAND string to the SDS monitor. 16158 16159 16160 File: gdb.info, Node: PA, Next: PowerPC Embedded, Prev: OpenRISC 1000, Up: Embedded Processors 16161 16162 21.3.8 HP PA Embedded 16163 --------------------- 16164 16165 `target op50n DEV' 16166 OP50N monitor, running on an OKI HPPA board. 16167 16168 `target w89k DEV' 16169 W89K monitor, running on a Winbond HPPA board. 16170 16171 16172 16173 File: gdb.info, Node: Sparclet, Next: Sparclite, Prev: PowerPC Embedded, Up: Embedded Processors 16174 16175 21.3.9 Tsqware Sparclet 16176 ----------------------- 16177 16178 GDB enables developers to debug tasks running on Sparclet targets from 16179 a Unix host. GDB uses code that runs on both the Unix host and on the 16180 Sparclet target. The program `gdb' is installed and executed on the 16181 Unix host. 16182 16183 `remotetimeout ARGS' 16184 GDB supports the option `remotetimeout'. This option is set by 16185 the user, and ARGS represents the number of seconds GDB waits for 16186 responses. 16187 16188 When compiling for debugging, include the options `-g' to get debug 16189 information and `-Ttext' to relocate the program to where you wish to 16190 load it on the target. You may also want to add the options `-n' or 16191 `-N' in order to reduce the size of the sections. Example: 16192 16193 sparclet-aout-gcc prog.c -Ttext 0x12010000 -g -o prog -N 16194 16195 You can use `objdump' to verify that the addresses are what you 16196 intended: 16197 16198 sparclet-aout-objdump --headers --syms prog 16199 16200 Once you have set your Unix execution search path to find GDB, you 16201 are ready to run GDB. From your Unix host, run `gdb' (or 16202 `sparclet-aout-gdb', depending on your installation). 16203 16204 GDB comes up showing the prompt: 16205 16206 (gdbslet) 16207 16208 * Menu: 16209 16210 * Sparclet File:: Setting the file to debug 16211 * Sparclet Connection:: Connecting to Sparclet 16212 * Sparclet Download:: Sparclet download 16213 * Sparclet Execution:: Running and debugging 16214 16215 16216 File: gdb.info, Node: Sparclet File, Next: Sparclet Connection, Up: Sparclet 16217 16218 21.3.9.1 Setting File to Debug 16219 .............................. 16220 16221 The GDB command `file' lets you choose with program to debug. 16222 16223 (gdbslet) file prog 16224 16225 GDB then attempts to read the symbol table of `prog'. GDB locates 16226 the file by searching the directories listed in the command search path. 16227 If the file was compiled with debug information (option `-g'), source 16228 files will be searched as well. GDB locates the source files by 16229 searching the directories listed in the directory search path (*note 16230 Your Program's Environment: Environment.). If it fails to find a file, 16231 it displays a message such as: 16232 16233 prog: No such file or directory. 16234 16235 When this happens, add the appropriate directories to the search 16236 paths with the GDB commands `path' and `dir', and execute the `target' 16237 command again. 16238 16239 16240 File: gdb.info, Node: Sparclet Connection, Next: Sparclet Download, Prev: Sparclet File, Up: Sparclet 16241 16242 21.3.9.2 Connecting to Sparclet 16243 ............................... 16244 16245 The GDB command `target' lets you connect to a Sparclet target. To 16246 connect to a target on serial port "`ttya'", type: 16247 16248 (gdbslet) target sparclet /dev/ttya 16249 Remote target sparclet connected to /dev/ttya 16250 main () at ../prog.c:3 16251 16252 GDB displays messages like these: 16253 16254 Connected to ttya. 16255 16256 16257 File: gdb.info, Node: Sparclet Download, Next: Sparclet Execution, Prev: Sparclet Connection, Up: Sparclet 16258 16259 21.3.9.3 Sparclet Download 16260 .......................... 16261 16262 Once connected to the Sparclet target, you can use the GDB `load' 16263 command to download the file from the host to the target. The file 16264 name and load offset should be given as arguments to the `load' command. 16265 Since the file format is aout, the program must be loaded to the 16266 starting address. You can use `objdump' to find out what this value 16267 is. The load offset is an offset which is added to the VMA (virtual 16268 memory address) of each of the file's sections. For instance, if the 16269 program `prog' was linked to text address 0x1201000, with data at 16270 0x12010160 and bss at 0x12010170, in GDB, type: 16271 16272 (gdbslet) load prog 0x12010000 16273 Loading section .text, size 0xdb0 vma 0x12010000 16274 16275 If the code is loaded at a different address then what the program 16276 was linked to, you may need to use the `section' and `add-symbol-file' 16277 commands to tell GDB where to map the symbol table. 16278 16279 16280 File: gdb.info, Node: Sparclet Execution, Prev: Sparclet Download, Up: Sparclet 16281 16282 21.3.9.4 Running and Debugging 16283 .............................. 16284 16285 You can now begin debugging the task using GDB's execution control 16286 commands, `b', `step', `run', etc. See the GDB manual for the list of 16287 commands. 16288 16289 (gdbslet) b main 16290 Breakpoint 1 at 0x12010000: file prog.c, line 3. 16291 (gdbslet) run 16292 Starting program: prog 16293 Breakpoint 1, main (argc=1, argv=0xeffff21c) at prog.c:3 16294 3 char *symarg = 0; 16295 (gdbslet) step 16296 4 char *execarg = "hello!"; 16297 (gdbslet) 16298 16299 16300 File: gdb.info, Node: Sparclite, Next: Z8000, Prev: Sparclet, Up: Embedded Processors 16301 16302 21.3.10 Fujitsu Sparclite 16303 ------------------------- 16304 16305 `target sparclite DEV' 16306 Fujitsu sparclite boards, used only for the purpose of loading. 16307 You must use an additional command to debug the program. For 16308 example: target remote DEV using GDB standard remote protocol. 16309 16310 16311 16312 File: gdb.info, Node: Z8000, Next: AVR, Prev: Sparclite, Up: Embedded Processors 16313 16314 21.3.11 Zilog Z8000 16315 ------------------- 16316 16317 When configured for debugging Zilog Z8000 targets, GDB includes a Z8000 16318 simulator. 16319 16320 For the Z8000 family, `target sim' simulates either the Z8002 (the 16321 unsegmented variant of the Z8000 architecture) or the Z8001 (the 16322 segmented variant). The simulator recognizes which architecture is 16323 appropriate by inspecting the object code. 16324 16325 `target sim ARGS' 16326 Debug programs on a simulated CPU. If the simulator supports setup 16327 options, specify them via ARGS. 16328 16329 After specifying this target, you can debug programs for the simulated 16330 CPU in the same style as programs for your host computer; use the 16331 `file' command to load a new program image, the `run' command to run 16332 your program, and so on. 16333 16334 As well as making available all the usual machine registers (*note 16335 Registers: Registers.), the Z8000 simulator provides three additional 16336 items of information as specially named registers: 16337 16338 `cycles' 16339 Counts clock-ticks in the simulator. 16340 16341 `insts' 16342 Counts instructions run in the simulator. 16343 16344 `time' 16345 Execution time in 60ths of a second. 16346 16347 16348 You can refer to these values in GDB expressions with the usual 16349 conventions; for example, `b fputc if $cycles>5000' sets a conditional 16350 breakpoint that suspends only after at least 5000 simulated clock ticks. 16351 16352 16353 File: gdb.info, Node: AVR, Next: CRIS, Prev: Z8000, Up: Embedded Processors 16354 16355 21.3.12 Atmel AVR 16356 ----------------- 16357 16358 When configured for debugging the Atmel AVR, GDB supports the following 16359 AVR-specific commands: 16360 16361 `info io_registers' 16362 This command displays information about the AVR I/O registers. For 16363 each register, GDB prints its number and value. 16364 16365 16366 File: gdb.info, Node: CRIS, Next: Super-H, Prev: AVR, Up: Embedded Processors 16367 16368 21.3.13 CRIS 16369 ------------ 16370 16371 When configured for debugging CRIS, GDB provides the following 16372 CRIS-specific commands: 16373 16374 `set cris-version VER' 16375 Set the current CRIS version to VER, either `10' or `32'. The 16376 CRIS version affects register names and sizes. This command is 16377 useful in case autodetection of the CRIS version fails. 16378 16379 `show cris-version' 16380 Show the current CRIS version. 16381 16382 `set cris-dwarf2-cfi' 16383 Set the usage of DWARF-2 CFI for CRIS debugging. The default is 16384 `on'. Change to `off' when using `gcc-cris' whose version is below 16385 `R59'. 16386 16387 `show cris-dwarf2-cfi' 16388 Show the current state of using DWARF-2 CFI. 16389 16390 `set cris-mode MODE' 16391 Set the current CRIS mode to MODE. It should only be changed when 16392 debugging in guru mode, in which case it should be set to `guru' 16393 (the default is `normal'). 16394 16395 `show cris-mode' 16396 Show the current CRIS mode. 16397 16398 16399 File: gdb.info, Node: Super-H, Prev: CRIS, Up: Embedded Processors 16400 16401 21.3.14 Renesas Super-H 16402 ----------------------- 16403 16404 For the Renesas Super-H processor, GDB provides these commands: 16405 16406 `regs' 16407 Show the values of all Super-H registers. 16408 16409 `set sh calling-convention CONVENTION' 16410 Set the calling-convention used when calling functions from GDB. 16411 Allowed values are `gcc', which is the default setting, and 16412 `renesas'. With the `gcc' setting, functions are called using the 16413 GCC calling convention. If the DWARF-2 information of the called 16414 function specifies that the function follows the Renesas calling 16415 convention, the function is called using the Renesas calling 16416 convention. If the calling convention is set to `renesas', the 16417 Renesas calling convention is always used, regardless of the 16418 DWARF-2 information. This can be used to override the default of 16419 `gcc' if debug information is missing, or the compiler does not 16420 emit the DWARF-2 calling convention entry for a function. 16421 16422 `show sh calling-convention' 16423 Show the current calling convention setting. 16424 16425 16426 16427 File: gdb.info, Node: Architectures, Prev: Embedded Processors, Up: Configurations 16428 16429 21.4 Architectures 16430 ================== 16431 16432 This section describes characteristics of architectures that affect all 16433 uses of GDB with the architecture, both native and cross. 16434 16435 * Menu: 16436 16437 * i386:: 16438 * A29K:: 16439 * Alpha:: 16440 * MIPS:: 16441 * HPPA:: HP PA architecture 16442 * SPU:: Cell Broadband Engine SPU architecture 16443 * PowerPC:: 16444 16445 16446 File: gdb.info, Node: i386, Next: A29K, Up: Architectures 16447 16448 21.4.1 x86 Architecture-specific Issues 16449 --------------------------------------- 16450 16451 `set struct-convention MODE' 16452 Set the convention used by the inferior to return `struct's and 16453 `union's from functions to MODE. Possible values of MODE are 16454 `"pcc"', `"reg"', and `"default"' (the default). `"default"' or 16455 `"pcc"' means that `struct's are returned on the stack, while 16456 `"reg"' means that a `struct' or a `union' whose size is 1, 2, 4, 16457 or 8 bytes will be returned in a register. 16458 16459 `show struct-convention' 16460 Show the current setting of the convention to return `struct's 16461 from functions. 16462 16463 16464 File: gdb.info, Node: A29K, Next: Alpha, Prev: i386, Up: Architectures 16465 16466 21.4.2 A29K 16467 ----------- 16468 16469 `set rstack_high_address ADDRESS' 16470 On AMD 29000 family processors, registers are saved in a separate 16471 "register stack". There is no way for GDB to determine the extent 16472 of this stack. Normally, GDB just assumes that the stack is 16473 "large enough". This may result in GDB referencing memory 16474 locations that do not exist. If necessary, you can get around 16475 this problem by specifying the ending address of the register 16476 stack with the `set rstack_high_address' command. The argument 16477 should be an address, which you probably want to precede with `0x' 16478 to specify in hexadecimal. 16479 16480 `show rstack_high_address' 16481 Display the current limit of the register stack, on AMD 29000 16482 family processors. 16483 16484 16485 16486 File: gdb.info, Node: Alpha, Next: MIPS, Prev: A29K, Up: Architectures 16487 16488 21.4.3 Alpha 16489 ------------ 16490 16491 See the following section. 16492 16493 16494 File: gdb.info, Node: MIPS, Next: HPPA, Prev: Alpha, Up: Architectures 16495 16496 21.4.4 MIPS 16497 ----------- 16498 16499 Alpha- and MIPS-based computers use an unusual stack frame, which 16500 sometimes requires GDB to search backward in the object code to find 16501 the beginning of a function. 16502 16503 To improve response time (especially for embedded applications, where 16504 GDB may be restricted to a slow serial line for this search) you may 16505 want to limit the size of this search, using one of these commands: 16506 16507 `set heuristic-fence-post LIMIT' 16508 Restrict GDB to examining at most LIMIT bytes in its search for 16509 the beginning of a function. A value of 0 (the default) means 16510 there is no limit. However, except for 0, the larger the limit 16511 the more bytes `heuristic-fence-post' must search and therefore 16512 the longer it takes to run. You should only need to use this 16513 command when debugging a stripped executable. 16514 16515 `show heuristic-fence-post' 16516 Display the current limit. 16517 16518 These commands are available _only_ when GDB is configured for 16519 debugging programs on Alpha or MIPS processors. 16520 16521 Several MIPS-specific commands are available when debugging MIPS 16522 programs: 16523 16524 `set mips abi ARG' 16525 Tell GDB which MIPS ABI is used by the inferior. Possible values 16526 of ARG are: 16527 16528 `auto' 16529 The default ABI associated with the current binary (this is 16530 the default). 16531 16532 `o32' 16533 16534 `o64' 16535 16536 `n32' 16537 16538 `n64' 16539 16540 `eabi32' 16541 16542 `eabi64' 16543 16544 `auto' 16545 16546 `show mips abi' 16547 Show the MIPS ABI used by GDB to debug the inferior. 16548 16549 `set mipsfpu' 16550 `show mipsfpu' 16551 *Note set mipsfpu: MIPS Embedded. 16552 16553 `set mips mask-address ARG' 16554 This command determines whether the most-significant 32 bits of 16555 64-bit MIPS addresses are masked off. The argument ARG can be 16556 `on', `off', or `auto'. The latter is the default setting, which 16557 lets GDB determine the correct value. 16558 16559 `show mips mask-address' 16560 Show whether the upper 32 bits of MIPS addresses are masked off or 16561 not. 16562 16563 `set remote-mips64-transfers-32bit-regs' 16564 This command controls compatibility with 64-bit MIPS targets that 16565 transfer data in 32-bit quantities. If you have an old MIPS 64 16566 target that transfers 32 bits for some registers, like SR and FSR, 16567 and 64 bits for other registers, set this option to `on'. 16568 16569 `show remote-mips64-transfers-32bit-regs' 16570 Show the current setting of compatibility with older MIPS 64 16571 targets. 16572 16573 `set debug mips' 16574 This command turns on and off debugging messages for the 16575 MIPS-specific target code in GDB. 16576 16577 `show debug mips' 16578 Show the current setting of MIPS debugging messages. 16579 16580 16581 File: gdb.info, Node: HPPA, Next: SPU, Prev: MIPS, Up: Architectures 16582 16583 21.4.5 HPPA 16584 ----------- 16585 16586 When GDB is debugging the HP PA architecture, it provides the following 16587 special commands: 16588 16589 `set debug hppa' 16590 This command determines whether HPPA architecture-specific 16591 debugging messages are to be displayed. 16592 16593 `show debug hppa' 16594 Show whether HPPA debugging messages are displayed. 16595 16596 `maint print unwind ADDRESS' 16597 This command displays the contents of the unwind table entry at the 16598 given ADDRESS. 16599 16600 16601 16602 File: gdb.info, Node: SPU, Next: PowerPC, Prev: HPPA, Up: Architectures 16603 16604 21.4.6 Cell Broadband Engine SPU architecture 16605 --------------------------------------------- 16606 16607 When GDB is debugging the Cell Broadband Engine SPU architecture, it 16608 provides the following special commands: 16609 16610 `info spu event' 16611 Display SPU event facility status. Shows current event mask and 16612 pending event status. 16613 16614 `info spu signal' 16615 Display SPU signal notification facility status. Shows pending 16616 signal-control word and signal notification mode of both signal 16617 notification channels. 16618 16619 `info spu mailbox' 16620 Display SPU mailbox facility status. Shows all pending entries, 16621 in order of processing, in each of the SPU Write Outbound, SPU 16622 Write Outbound Interrupt, and SPU Read Inbound mailboxes. 16623 16624 `info spu dma' 16625 Display MFC DMA status. Shows all pending commands in the MFC DMA 16626 queue. For each entry, opcode, tag, class IDs, effective and 16627 local store addresses and transfer size are shown. 16628 16629 `info spu proxydma' 16630 Display MFC Proxy-DMA status. Shows all pending commands in the 16631 MFC Proxy-DMA queue. For each entry, opcode, tag, class IDs, 16632 effective and local store addresses and transfer size are shown. 16633 16634 16635 When GDB is debugging a combined PowerPC/SPU application on the Cell 16636 Broadband Engine, it provides in addition the following special 16637 commands: 16638 16639 `set spu stop-on-load ARG' 16640 Set whether to stop for new SPE threads. When set to `on', GDB 16641 will give control to the user when a new SPE thread enters its 16642 `main' function. The default is `off'. 16643 16644 `show spu stop-on-load' 16645 Show whether to stop for new SPE threads. 16646 16647 `set spu auto-flush-cache ARG' 16648 Set whether to automatically flush the software-managed cache. 16649 When set to `on', GDB will automatically cause the SPE 16650 software-managed cache to be flushed whenever SPE execution stops. 16651 This provides a consistent view of PowerPC memory that is accessed 16652 via the cache. If an application does not use the 16653 software-managed cache, this option has no effect. 16654 16655 `show spu auto-flush-cache' 16656 Show whether to automatically flush the software-managed cache. 16657 16658 16659 16660 File: gdb.info, Node: PowerPC, Prev: SPU, Up: Architectures 16661 16662 21.4.7 PowerPC 16663 -------------- 16664 16665 When GDB is debugging the PowerPC architecture, it provides a set of 16666 pseudo-registers to enable inspection of 128-bit wide Decimal Floating 16667 Point numbers stored in the floating point registers. These values must 16668 be stored in two consecutive registers, always starting at an even 16669 register like `f0' or `f2'. 16670 16671 The pseudo-registers go from `$dl0' through `$dl15', and are formed 16672 by joining the even/odd register pairs `f0' and `f1' for `$dl0', `f2' 16673 and `f3' for `$dl1' and so on. 16674 16675 For POWER7 processors, GDB provides a set of pseudo-registers, the 16676 64-bit wide Extended Floating Point Registers (`f32' through `f63'). 16677 16678 16679 File: gdb.info, Node: Controlling GDB, Next: Extending GDB, Prev: Configurations, Up: Top 16680 16681 22 Controlling GDB 16682 ****************** 16683 16684 You can alter the way GDB interacts with you by using the `set' 16685 command. For commands controlling how GDB displays data, see *note 16686 Print Settings: Print Settings. Other settings are described here. 16687 16688 * Menu: 16689 16690 * Prompt:: Prompt 16691 * Editing:: Command editing 16692 * Command History:: Command history 16693 * Screen Size:: Screen size 16694 * Numbers:: Numbers 16695 * ABI:: Configuring the current ABI 16696 * Messages/Warnings:: Optional warnings and messages 16697 * Debugging Output:: Optional messages about internal happenings 16698 * Other Misc Settings:: Other Miscellaneous Settings 16699 16700 16701 File: gdb.info, Node: Prompt, Next: Editing, Up: Controlling GDB 16702 16703 22.1 Prompt 16704 =========== 16705 16706 GDB indicates its readiness to read a command by printing a string 16707 called the "prompt". This string is normally `(gdb)'. You can change 16708 the prompt string with the `set prompt' command. For instance, when 16709 debugging GDB with GDB, it is useful to change the prompt in one of the 16710 GDB sessions so that you can always tell which one you are talking to. 16711 16712 _Note:_ `set prompt' does not add a space for you after the prompt 16713 you set. This allows you to set a prompt which ends in a space or a 16714 prompt that does not. 16715 16716 `set prompt NEWPROMPT' 16717 Directs GDB to use NEWPROMPT as its prompt string henceforth. 16718 16719 `show prompt' 16720 Prints a line of the form: `Gdb's prompt is: YOUR-PROMPT' 16721 16722 16723 File: gdb.info, Node: Editing, Next: Command History, Prev: Prompt, Up: Controlling GDB 16724 16725 22.2 Command Editing 16726 ==================== 16727 16728 GDB reads its input commands via the "Readline" interface. This GNU 16729 library provides consistent behavior for programs which provide a 16730 command line interface to the user. Advantages are GNU Emacs-style or 16731 "vi"-style inline editing of commands, `csh'-like history substitution, 16732 and a storage and recall of command history across debugging sessions. 16733 16734 You may control the behavior of command line editing in GDB with the 16735 command `set'. 16736 16737 `set editing' 16738 `set editing on' 16739 Enable command line editing (enabled by default). 16740 16741 `set editing off' 16742 Disable command line editing. 16743 16744 `show editing' 16745 Show whether command line editing is enabled. 16746 16747 *Note Command Line Editing::, for more details about the Readline 16748 interface. Users unfamiliar with GNU Emacs or `vi' are encouraged to 16749 read that chapter. 16750 16751 16752 File: gdb.info, Node: Command History, Next: Screen Size, Prev: Editing, Up: Controlling GDB 16753 16754 22.3 Command History 16755 ==================== 16756 16757 GDB can keep track of the commands you type during your debugging 16758 sessions, so that you can be certain of precisely what happened. Use 16759 these commands to manage the GDB command history facility. 16760 16761 GDB uses the GNU History library, a part of the Readline package, to 16762 provide the history facility. *Note Using History Interactively::, for 16763 the detailed description of the History library. 16764 16765 To issue a command to GDB without affecting certain aspects of the 16766 state which is seen by users, prefix it with `server ' (*note Server 16767 Prefix::). This means that this command will not affect the command 16768 history, nor will it affect GDB's notion of which command to repeat if 16769 <RET> is pressed on a line by itself. 16770 16771 The server prefix does not affect the recording of values into the 16772 value history; to print a value without recording it into the value 16773 history, use the `output' command instead of the `print' command. 16774 16775 Here is the description of GDB commands related to command history. 16776 16777 `set history filename FNAME' 16778 Set the name of the GDB command history file to FNAME. This is 16779 the file where GDB reads an initial command history list, and 16780 where it writes the command history from this session when it 16781 exits. You can access this list through history expansion or 16782 through the history command editing characters listed below. This 16783 file defaults to the value of the environment variable 16784 `GDBHISTFILE', or to `./.gdb_history' (`./_gdb_history' on MS-DOS) 16785 if this variable is not set. 16786 16787 `set history save' 16788 `set history save on' 16789 Record command history in a file, whose name may be specified with 16790 the `set history filename' command. By default, this option is 16791 disabled. 16792 16793 `set history save off' 16794 Stop recording command history in a file. 16795 16796 `set history size SIZE' 16797 Set the number of commands which GDB keeps in its history list. 16798 This defaults to the value of the environment variable `HISTSIZE', 16799 or to 256 if this variable is not set. 16800 16801 History expansion assigns special meaning to the character `!'. 16802 *Note Event Designators::, for more details. 16803 16804 Since `!' is also the logical not operator in C, history expansion 16805 is off by default. If you decide to enable history expansion with the 16806 `set history expansion on' command, you may sometimes need to follow 16807 `!' (when it is used as logical not, in an expression) with a space or 16808 a tab to prevent it from being expanded. The readline history 16809 facilities do not attempt substitution on the strings `!=' and `!(', 16810 even when history expansion is enabled. 16811 16812 The commands to control history expansion are: 16813 16814 `set history expansion on' 16815 `set history expansion' 16816 Enable history expansion. History expansion is off by default. 16817 16818 `set history expansion off' 16819 Disable history expansion. 16820 16821 `show history' 16822 `show history filename' 16823 `show history save' 16824 `show history size' 16825 `show history expansion' 16826 These commands display the state of the GDB history parameters. 16827 `show history' by itself displays all four states. 16828 16829 `show commands' 16830 Display the last ten commands in the command history. 16831 16832 `show commands N' 16833 Print ten commands centered on command number N. 16834 16835 `show commands +' 16836 Print ten commands just after the commands last printed. 16837 16838 16839 File: gdb.info, Node: Screen Size, Next: Numbers, Prev: Command History, Up: Controlling GDB 16840 16841 22.4 Screen Size 16842 ================ 16843 16844 Certain commands to GDB may produce large amounts of information output 16845 to the screen. To help you read all of it, GDB pauses and asks you for 16846 input at the end of each page of output. Type <RET> when you want to 16847 continue the output, or `q' to discard the remaining output. Also, the 16848 screen width setting determines when to wrap lines of output. 16849 Depending on what is being printed, GDB tries to break the line at a 16850 readable place, rather than simply letting it overflow onto the 16851 following line. 16852 16853 Normally GDB knows the size of the screen from the terminal driver 16854 software. For example, on Unix GDB uses the termcap data base together 16855 with the value of the `TERM' environment variable and the `stty rows' 16856 and `stty cols' settings. If this is not correct, you can override it 16857 with the `set height' and `set width' commands: 16858 16859 `set height LPP' 16860 `show height' 16861 `set width CPL' 16862 `show width' 16863 These `set' commands specify a screen height of LPP lines and a 16864 screen width of CPL characters. The associated `show' commands 16865 display the current settings. 16866 16867 If you specify a height of zero lines, GDB does not pause during 16868 output no matter how long the output is. This is useful if output 16869 is to a file or to an editor buffer. 16870 16871 Likewise, you can specify `set width 0' to prevent GDB from 16872 wrapping its output. 16873 16874 `set pagination on' 16875 `set pagination off' 16876 Turn the output pagination on or off; the default is on. Turning 16877 pagination off is the alternative to `set height 0'. Note that 16878 running GDB with the `--batch' option (*note -batch: Mode 16879 Options.) also automatically disables pagination. 16880 16881 `show pagination' 16882 Show the current pagination mode. 16883 16884 16885 File: gdb.info, Node: Numbers, Next: ABI, Prev: Screen Size, Up: Controlling GDB 16886 16887 22.5 Numbers 16888 ============ 16889 16890 You can always enter numbers in octal, decimal, or hexadecimal in GDB 16891 by the usual conventions: octal numbers begin with `0', decimal numbers 16892 end with `.', and hexadecimal numbers begin with `0x'. Numbers that 16893 neither begin with `0' or `0x', nor end with a `.' are, by default, 16894 entered in base 10; likewise, the default display for numbers--when no 16895 particular format is specified--is base 10. You can change the default 16896 base for both input and output with the commands described below. 16897 16898 `set input-radix BASE' 16899 Set the default base for numeric input. Supported choices for 16900 BASE are decimal 8, 10, or 16. BASE must itself be specified 16901 either unambiguously or using the current input radix; for 16902 example, any of 16903 16904 set input-radix 012 16905 set input-radix 10. 16906 set input-radix 0xa 16907 16908 sets the input base to decimal. On the other hand, `set 16909 input-radix 10' leaves the input radix unchanged, no matter what 16910 it was, since `10', being without any leading or trailing signs of 16911 its base, is interpreted in the current radix. Thus, if the 16912 current radix is 16, `10' is interpreted in hex, i.e. as 16 16913 decimal, which doesn't change the radix. 16914 16915 `set output-radix BASE' 16916 Set the default base for numeric display. Supported choices for 16917 BASE are decimal 8, 10, or 16. BASE must itself be specified 16918 either unambiguously or using the current input radix. 16919 16920 `show input-radix' 16921 Display the current default base for numeric input. 16922 16923 `show output-radix' 16924 Display the current default base for numeric display. 16925 16926 `set radix [BASE]' 16927 `show radix' 16928 These commands set and show the default base for both input and 16929 output of numbers. `set radix' sets the radix of input and output 16930 to the same base; without an argument, it resets the radix back to 16931 its default value of 10. 16932 16933 16934 16935 File: gdb.info, Node: ABI, Next: Messages/Warnings, Prev: Numbers, Up: Controlling GDB 16936 16937 22.6 Configuring the Current ABI 16938 ================================ 16939 16940 GDB can determine the "ABI" (Application Binary Interface) of your 16941 application automatically. However, sometimes you need to override its 16942 conclusions. Use these commands to manage GDB's view of the current 16943 ABI. 16944 16945 One GDB configuration can debug binaries for multiple operating 16946 system targets, either via remote debugging or native emulation. GDB 16947 will autodetect the "OS ABI" (Operating System ABI) in use, but you can 16948 override its conclusion using the `set osabi' command. One example 16949 where this is useful is in debugging of binaries which use an alternate 16950 C library (e.g. UCLIBC for GNU/Linux) which does not have the same 16951 identifying marks that the standard C library for your platform 16952 provides. 16953 16954 `show osabi' 16955 Show the OS ABI currently in use. 16956 16957 `set osabi' 16958 With no argument, show the list of registered available OS ABI's. 16959 16960 `set osabi ABI' 16961 Set the current OS ABI to ABI. 16962 16963 Generally, the way that an argument of type `float' is passed to a 16964 function depends on whether the function is prototyped. For a 16965 prototyped (i.e. ANSI/ISO style) function, `float' arguments are passed 16966 unchanged, according to the architecture's convention for `float'. For 16967 unprototyped (i.e. K&R style) functions, `float' arguments are first 16968 promoted to type `double' and then passed. 16969 16970 Unfortunately, some forms of debug information do not reliably 16971 indicate whether a function is prototyped. If GDB calls a function 16972 that is not marked as prototyped, it consults `set 16973 coerce-float-to-double'. 16974 16975 `set coerce-float-to-double' 16976 `set coerce-float-to-double on' 16977 Arguments of type `float' will be promoted to `double' when passed 16978 to an unprototyped function. This is the default setting. 16979 16980 `set coerce-float-to-double off' 16981 Arguments of type `float' will be passed directly to unprototyped 16982 functions. 16983 16984 `show coerce-float-to-double' 16985 Show the current setting of promoting `float' to `double'. 16986 16987 GDB needs to know the ABI used for your program's C++ objects. The 16988 correct C++ ABI depends on which C++ compiler was used to build your 16989 application. GDB only fully supports programs with a single C++ ABI; 16990 if your program contains code using multiple C++ ABI's or if GDB can 16991 not identify your program's ABI correctly, you can tell GDB which ABI 16992 to use. Currently supported ABI's include "gnu-v2", for `g++' versions 16993 before 3.0, "gnu-v3", for `g++' versions 3.0 and later, and "hpaCC" for 16994 the HP ANSI C++ compiler. Other C++ compilers may use the "gnu-v2" or 16995 "gnu-v3" ABI's as well. The default setting is "auto". 16996 16997 `show cp-abi' 16998 Show the C++ ABI currently in use. 16999 17000 `set cp-abi' 17001 With no argument, show the list of supported C++ ABI's. 17002 17003 `set cp-abi ABI' 17004 `set cp-abi auto' 17005 Set the current C++ ABI to ABI, or return to automatic detection. 17006 17007 17008 File: gdb.info, Node: Messages/Warnings, Next: Debugging Output, Prev: ABI, Up: Controlling GDB 17009 17010 22.7 Optional Warnings and Messages 17011 =================================== 17012 17013 By default, GDB is silent about its inner workings. If you are running 17014 on a slow machine, you may want to use the `set verbose' command. This 17015 makes GDB tell you when it does a lengthy internal operation, so you 17016 will not think it has crashed. 17017 17018 Currently, the messages controlled by `set verbose' are those which 17019 announce that the symbol table for a source file is being read; see 17020 `symbol-file' in *note Commands to Specify Files: Files. 17021 17022 `set verbose on' 17023 Enables GDB output of certain informational messages. 17024 17025 `set verbose off' 17026 Disables GDB output of certain informational messages. 17027 17028 `show verbose' 17029 Displays whether `set verbose' is on or off. 17030 17031 By default, if GDB encounters bugs in the symbol table of an object 17032 file, it is silent; but if you are debugging a compiler, you may find 17033 this information useful (*note Errors Reading Symbol Files: Symbol 17034 Errors.). 17035 17036 `set complaints LIMIT' 17037 Permits GDB to output LIMIT complaints about each type of unusual 17038 symbols before becoming silent about the problem. Set LIMIT to 17039 zero to suppress all complaints; set it to a large number to 17040 prevent complaints from being suppressed. 17041 17042 `show complaints' 17043 Displays how many symbol complaints GDB is permitted to produce. 17044 17045 17046 By default, GDB is cautious, and asks what sometimes seems to be a 17047 lot of stupid questions to confirm certain commands. For example, if 17048 you try to run a program which is already running: 17049 17050 (gdb) run 17051 The program being debugged has been started already. 17052 Start it from the beginning? (y or n) 17053 17054 If you are willing to unflinchingly face the consequences of your own 17055 commands, you can disable this "feature": 17056 17057 `set confirm off' 17058 Disables confirmation requests. Note that running GDB with the 17059 `--batch' option (*note -batch: Mode Options.) also automatically 17060 disables confirmation requests. 17061 17062 `set confirm on' 17063 Enables confirmation requests (the default). 17064 17065 `show confirm' 17066 Displays state of confirmation requests. 17067 17068 17069 If you need to debug user-defined commands or sourced files you may 17070 find it useful to enable "command tracing". In this mode each command 17071 will be printed as it is executed, prefixed with one or more `+' 17072 symbols, the quantity denoting the call depth of each command. 17073 17074 `set trace-commands on' 17075 Enable command tracing. 17076 17077 `set trace-commands off' 17078 Disable command tracing. 17079 17080 `show trace-commands' 17081 Display the current state of command tracing. 17082 17083 17084 File: gdb.info, Node: Debugging Output, Next: Other Misc Settings, Prev: Messages/Warnings, Up: Controlling GDB 17085 17086 22.8 Optional Messages about Internal Happenings 17087 ================================================ 17088 17089 GDB has commands that enable optional debugging messages from various 17090 GDB subsystems; normally these commands are of interest to GDB 17091 maintainers, or when reporting a bug. This section documents those 17092 commands. 17093 17094 `set exec-done-display' 17095 Turns on or off the notification of asynchronous commands' 17096 completion. When on, GDB will print a message when an 17097 asynchronous command finishes its execution. The default is off. 17098 17099 `show exec-done-display' 17100 Displays the current setting of asynchronous command completion 17101 notification. 17102 17103 `set debug arch' 17104 Turns on or off display of gdbarch debugging info. The default is 17105 off 17106 17107 `show debug arch' 17108 Displays the current state of displaying gdbarch debugging info. 17109 17110 `set debug aix-thread' 17111 Display debugging messages about inner workings of the AIX thread 17112 module. 17113 17114 `show debug aix-thread' 17115 Show the current state of AIX thread debugging info display. 17116 17117 `set debug check-physname' 17118 Check the results of the "physname" computation. When reading 17119 DWARF debugging information for C++, GDB attempts to compute each 17120 entity's name. GDB can do this computation in two different ways, 17121 depending on exactly what information is present. When enabled, 17122 this setting causes GDB to compute the names both ways and display 17123 any discrepancies. 17124 17125 `show debug check-physname' 17126 Show the current state of "physname" checking. 17127 17128 `set debug dwarf2-die' 17129 Dump DWARF2 DIEs after they are read in. The value is the number 17130 of nesting levels to print. A value of zero turns off the display. 17131 17132 `show debug dwarf2-die' 17133 Show the current state of DWARF2 DIE debugging. 17134 17135 `set debug displaced' 17136 Turns on or off display of GDB debugging info for the displaced 17137 stepping support. The default is off. 17138 17139 `show debug displaced' 17140 Displays the current state of displaying GDB debugging info 17141 related to displaced stepping. 17142 17143 `set debug event' 17144 Turns on or off display of GDB event debugging info. The default 17145 is off. 17146 17147 `show debug event' 17148 Displays the current state of displaying GDB event debugging info. 17149 17150 `set debug expression' 17151 Turns on or off display of debugging info about GDB expression 17152 parsing. The default is off. 17153 17154 `show debug expression' 17155 Displays the current state of displaying debugging info about GDB 17156 expression parsing. 17157 17158 `set debug frame' 17159 Turns on or off display of GDB frame debugging info. The default 17160 is off. 17161 17162 `show debug frame' 17163 Displays the current state of displaying GDB frame debugging info. 17164 17165 `set debug gnu-nat' 17166 Turns on or off debugging messages from the GNU/Hurd debug support. 17167 17168 `show debug gnu-nat' 17169 Show the current state of GNU/Hurd debugging messages. 17170 17171 `set debug infrun' 17172 Turns on or off display of GDB debugging info for running the 17173 inferior. The default is off. `infrun.c' contains GDB's runtime 17174 state machine used for implementing operations such as 17175 single-stepping the inferior. 17176 17177 `show debug infrun' 17178 Displays the current state of GDB inferior debugging. 17179 17180 `set debug jit' 17181 Turns on or off debugging messages from JIT debug support. 17182 17183 `show debug jit' 17184 Displays the current state of GDB JIT debugging. 17185 17186 `set debug lin-lwp' 17187 Turns on or off debugging messages from the Linux LWP debug 17188 support. 17189 17190 `show debug lin-lwp' 17191 Show the current state of Linux LWP debugging messages. 17192 17193 `set debug lin-lwp-async' 17194 Turns on or off debugging messages from the Linux LWP async debug 17195 support. 17196 17197 `show debug lin-lwp-async' 17198 Show the current state of Linux LWP async debugging messages. 17199 17200 `set debug observer' 17201 Turns on or off display of GDB observer debugging. This includes 17202 info such as the notification of observable events. 17203 17204 `show debug observer' 17205 Displays the current state of observer debugging. 17206 17207 `set debug overload' 17208 Turns on or off display of GDB C++ overload debugging info. This 17209 includes info such as ranking of functions, etc. The default is 17210 off. 17211 17212 `show debug overload' 17213 Displays the current state of displaying GDB C++ overload 17214 debugging info. 17215 17216 `set debug parser' 17217 Turns on or off the display of expression parser debugging output. 17218 Internally, this sets the `yydebug' variable in the expression 17219 parser. *Note Tracing Your Parser: (bison)Tracing, for details. 17220 The default is off. 17221 17222 `show debug parser' 17223 Show the current state of expression parser debugging. 17224 17225 `set debug remote' 17226 Turns on or off display of reports on all packets sent back and 17227 forth across the serial line to the remote machine. The info is 17228 printed on the GDB standard output stream. The default is off. 17229 17230 `show debug remote' 17231 Displays the state of display of remote packets. 17232 17233 `set debug serial' 17234 Turns on or off display of GDB serial debugging info. The default 17235 is off. 17236 17237 `show debug serial' 17238 Displays the current state of displaying GDB serial debugging info. 17239 17240 `set debug solib-frv' 17241 Turns on or off debugging messages for FR-V shared-library code. 17242 17243 `show debug solib-frv' 17244 Display the current state of FR-V shared-library code debugging 17245 messages. 17246 17247 `set debug target' 17248 Turns on or off display of GDB target debugging info. This info 17249 includes what is going on at the target level of GDB, as it 17250 happens. The default is 0. Set it to 1 to track events, and to 2 17251 to also track the value of large memory transfers. Changes to 17252 this flag do not take effect until the next time you connect to a 17253 target or use the `run' command. 17254 17255 `show debug target' 17256 Displays the current state of displaying GDB target debugging info. 17257 17258 `set debug timestamp' 17259 Turns on or off display of timestamps with GDB debugging info. 17260 When enabled, seconds and microseconds are displayed before each 17261 debugging message. 17262 17263 `show debug timestamp' 17264 Displays the current state of displaying timestamps with GDB 17265 debugging info. 17266 17267 `set debugvarobj' 17268 Turns on or off display of GDB variable object debugging info. The 17269 default is off. 17270 17271 `show debugvarobj' 17272 Displays the current state of displaying GDB variable object 17273 debugging info. 17274 17275 `set debug xml' 17276 Turns on or off debugging messages for built-in XML parsers. 17277 17278 `show debug xml' 17279 Displays the current state of XML debugging messages. 17280 17281 17282 File: gdb.info, Node: Other Misc Settings, Prev: Debugging Output, Up: Controlling GDB 17283 17284 22.9 Other Miscellaneous Settings 17285 ================================= 17286 17287 `set interactive-mode' 17288 If `on', forces GDB to assume that GDB was started in a terminal. 17289 In practice, this means that GDB should wait for the user to 17290 answer queries generated by commands entered at the command 17291 prompt. If `off', forces GDB to operate in the opposite mode, and 17292 it uses the default answers to all queries. If `auto' (the 17293 default), GDB tries to determine whether its standard input is a 17294 terminal, and works in interactive-mode if it is, 17295 non-interactively otherwise. 17296 17297 In the vast majority of cases, the debugger should be able to guess 17298 correctly which mode should be used. But this setting can be 17299 useful in certain specific cases, such as running a MinGW GDB 17300 inside a cygwin window. 17301 17302 `show interactive-mode' 17303 Displays whether the debugger is operating in interactive mode or 17304 not. 17305 17306 17307 File: gdb.info, Node: Extending GDB, Next: Interpreters, Prev: Controlling GDB, Up: Top 17308 17309 23 Extending GDB 17310 **************** 17311 17312 GDB provides two mechanisms for extension. The first is based on 17313 composition of GDB commands, and the second is based on the Python 17314 scripting language. 17315 17316 To facilitate the use of these extensions, GDB is capable of 17317 evaluating the contents of a file. When doing so, GDB can recognize 17318 which scripting language is being used by looking at the filename 17319 extension. Files with an unrecognized filename extension are always 17320 treated as a GDB Command Files. *Note Command files: Command Files. 17321 17322 You can control how GDB evaluates these files with the following 17323 setting: 17324 17325 `set script-extension off' 17326 All scripts are always evaluated as GDB Command Files. 17327 17328 `set script-extension soft' 17329 The debugger determines the scripting language based on filename 17330 extension. If this scripting language is supported, GDB evaluates 17331 the script using that language. Otherwise, it evaluates the file 17332 as a GDB Command File. 17333 17334 `set script-extension strict' 17335 The debugger determines the scripting language based on filename 17336 extension, and evaluates the script using that language. If the 17337 language is not supported, then the evaluation fails. 17338 17339 `show script-extension' 17340 Display the current value of the `script-extension' option. 17341 17342 17343 * Menu: 17344 17345 * Sequences:: Canned Sequences of Commands 17346 * Python:: Scripting GDB using Python 17347 17348 17349 File: gdb.info, Node: Sequences, Next: Python, Up: Extending GDB 17350 17351 23.1 Canned Sequences of Commands 17352 ================================= 17353 17354 Aside from breakpoint commands (*note Breakpoint Command Lists: Break 17355 Commands.), GDB provides two ways to store sequences of commands for 17356 execution as a unit: user-defined commands and command files. 17357 17358 * Menu: 17359 17360 * Define:: How to define your own commands 17361 * Hooks:: Hooks for user-defined commands 17362 * Command Files:: How to write scripts of commands to be stored in a file 17363 * Output:: Commands for controlled output 17364 17365 17366 File: gdb.info, Node: Define, Next: Hooks, Up: Sequences 17367 17368 23.1.1 User-defined Commands 17369 ---------------------------- 17370 17371 A "user-defined command" is a sequence of GDB commands to which you 17372 assign a new name as a command. This is done with the `define' 17373 command. User commands may accept up to 10 arguments separated by 17374 whitespace. Arguments are accessed within the user command via 17375 `$arg0...$arg9'. A trivial example: 17376 17377 define adder 17378 print $arg0 + $arg1 + $arg2 17379 end 17380 17381 To execute the command use: 17382 17383 adder 1 2 3 17384 17385 This defines the command `adder', which prints the sum of its three 17386 arguments. Note the arguments are text substitutions, so they may 17387 reference variables, use complex expressions, or even perform inferior 17388 functions calls. 17389 17390 In addition, `$argc' may be used to find out how many arguments have 17391 been passed. This expands to a number in the range 0...10. 17392 17393 define adder 17394 if $argc == 2 17395 print $arg0 + $arg1 17396 end 17397 if $argc == 3 17398 print $arg0 + $arg1 + $arg2 17399 end 17400 end 17401 17402 `define COMMANDNAME' 17403 Define a command named COMMANDNAME. If there is already a command 17404 by that name, you are asked to confirm that you want to redefine 17405 it. COMMANDNAME may be a bare command name consisting of letters, 17406 numbers, dashes, and underscores. It may also start with any 17407 predefined prefix command. For example, `define target my-target' 17408 creates a user-defined `target my-target' command. 17409 17410 The definition of the command is made up of other GDB command 17411 lines, which are given following the `define' command. The end of 17412 these commands is marked by a line containing `end'. 17413 17414 `document COMMANDNAME' 17415 Document the user-defined command COMMANDNAME, so that it can be 17416 accessed by `help'. The command COMMANDNAME must already be 17417 defined. This command reads lines of documentation just as 17418 `define' reads the lines of the command definition, ending with 17419 `end'. After the `document' command is finished, `help' on command 17420 COMMANDNAME displays the documentation you have written. 17421 17422 You may use the `document' command again to change the 17423 documentation of a command. Redefining the command with `define' 17424 does not change the documentation. 17425 17426 `dont-repeat' 17427 Used inside a user-defined command, this tells GDB that this 17428 command should not be repeated when the user hits <RET> (*note 17429 repeat last command: Command Syntax.). 17430 17431 `help user-defined' 17432 List all user-defined commands, with the first line of the 17433 documentation (if any) for each. 17434 17435 `show user' 17436 `show user COMMANDNAME' 17437 Display the GDB commands used to define COMMANDNAME (but not its 17438 documentation). If no COMMANDNAME is given, display the 17439 definitions for all user-defined commands. 17440 17441 `show max-user-call-depth' 17442 `set max-user-call-depth' 17443 The value of `max-user-call-depth' controls how many recursion 17444 levels are allowed in user-defined commands before GDB suspects an 17445 infinite recursion and aborts the command. 17446 17447 In addition to the above commands, user-defined commands frequently 17448 use control flow commands, described in *note Command Files::. 17449 17450 When user-defined commands are executed, the commands of the 17451 definition are not printed. An error in any command stops execution of 17452 the user-defined command. 17453 17454 If used interactively, commands that would ask for confirmation 17455 proceed without asking when used inside a user-defined command. Many 17456 GDB commands that normally print messages to say what they are doing 17457 omit the messages when used in a user-defined command. 17458 17459 17460 File: gdb.info, Node: Hooks, Next: Command Files, Prev: Define, Up: Sequences 17461 17462 23.1.2 User-defined Command Hooks 17463 --------------------------------- 17464 17465 You may define "hooks", which are a special kind of user-defined 17466 command. Whenever you run the command `foo', if the user-defined 17467 command `hook-foo' exists, it is executed (with no arguments) before 17468 that command. 17469 17470 A hook may also be defined which is run after the command you 17471 executed. Whenever you run the command `foo', if the user-defined 17472 command `hookpost-foo' exists, it is executed (with no arguments) after 17473 that command. Post-execution hooks may exist simultaneously with 17474 pre-execution hooks, for the same command. 17475 17476 It is valid for a hook to call the command which it hooks. If this 17477 occurs, the hook is not re-executed, thereby avoiding infinite 17478 recursion. 17479 17480 In addition, a pseudo-command, `stop' exists. Defining 17481 (`hook-stop') makes the associated commands execute every time 17482 execution stops in your program: before breakpoint commands are run, 17483 displays are printed, or the stack frame is printed. 17484 17485 For example, to ignore `SIGALRM' signals while single-stepping, but 17486 treat them normally during normal execution, you could define: 17487 17488 define hook-stop 17489 handle SIGALRM nopass 17490 end 17491 17492 define hook-run 17493 handle SIGALRM pass 17494 end 17495 17496 define hook-continue 17497 handle SIGALRM pass 17498 end 17499 17500 As a further example, to hook at the beginning and end of the `echo' 17501 command, and to add extra text to the beginning and end of the message, 17502 you could define: 17503 17504 define hook-echo 17505 echo <<<--- 17506 end 17507 17508 define hookpost-echo 17509 echo --->>>\n 17510 end 17511 17512 (gdb) echo Hello World 17513 <<<---Hello World--->>> 17514 (gdb) 17515 17516 You can define a hook for any single-word command in GDB, but not 17517 for command aliases; you should define a hook for the basic command 17518 name, e.g. `backtrace' rather than `bt'. You can hook a multi-word 17519 command by adding `hook-' or `hookpost-' to the last word of the 17520 command, e.g. `define target hook-remote' to add a hook to `target 17521 remote'. 17522 17523 If an error occurs during the execution of your hook, execution of 17524 GDB commands stops and GDB issues a prompt (before the command that you 17525 actually typed had a chance to run). 17526 17527 If you try to define a hook which does not match any known command, 17528 you get a warning from the `define' command. 17529 17530 17531 File: gdb.info, Node: Command Files, Next: Output, Prev: Hooks, Up: Sequences 17532 17533 23.1.3 Command Files 17534 -------------------- 17535 17536 A command file for GDB is a text file made of lines that are GDB 17537 commands. Comments (lines starting with `#') may also be included. An 17538 empty line in a command file does nothing; it does not mean to repeat 17539 the last command, as it would from the terminal. 17540 17541 You can request the execution of a command file with the `source' 17542 command. Note that the `source' command is also used to evaluate 17543 scripts that are not Command Files. The exact behavior can be 17544 configured using the `script-extension' setting. *Note Extending GDB: 17545 Extending GDB. 17546 17547 `source [-s] [-v] FILENAME' 17548 Execute the command file FILENAME. 17549 17550 The lines in a command file are generally executed sequentially, 17551 unless the order of execution is changed by one of the _flow-control 17552 commands_ described below. The commands are not printed as they are 17553 executed. An error in any command terminates execution of the command 17554 file and control is returned to the console. 17555 17556 GDB first searches for FILENAME in the current directory. If the 17557 file is not found there, and FILENAME does not specify a directory, 17558 then GDB also looks for the file on the source search path (specified 17559 with the `directory' command); except that `$cdir' is not searched 17560 because the compilation directory is not relevant to scripts. 17561 17562 If `-s' is specified, then GDB searches for FILENAME on the search 17563 path even if FILENAME specifies a directory. The search is done by 17564 appending FILENAME to each element of the search path. So, for 17565 example, if FILENAME is `mylib/myscript' and the search path contains 17566 `/home/user' then GDB will look for the script 17567 `/home/user/mylib/myscript'. The search is also done if FILENAME is an 17568 absolute path. For example, if FILENAME is `/tmp/myscript' and the 17569 search path contains `/home/user' then GDB will look for the script 17570 `/home/user/tmp/myscript'. For DOS-like systems, if FILENAME contains 17571 a drive specification, it is stripped before concatenation. For 17572 example, if FILENAME is `d:myscript' and the search path contains 17573 `c:/tmp' then GDB will look for the script `c:/tmp/myscript'. 17574 17575 If `-v', for verbose mode, is given then GDB displays each command 17576 as it is executed. The option must be given before FILENAME, and is 17577 interpreted as part of the filename anywhere else. 17578 17579 Commands that would ask for confirmation if used interactively 17580 proceed without asking when used in a command file. Many GDB commands 17581 that normally print messages to say what they are doing omit the 17582 messages when called from command files. 17583 17584 GDB also accepts command input from standard input. In this mode, 17585 normal output goes to standard output and error output goes to standard 17586 error. Errors in a command file supplied on standard input do not 17587 terminate execution of the command file--execution continues with the 17588 next command. 17589 17590 gdb < cmds > log 2>&1 17591 17592 (The syntax above will vary depending on the shell used.) This 17593 example will execute commands from the file `cmds'. All output and 17594 errors would be directed to `log'. 17595 17596 Since commands stored on command files tend to be more general than 17597 commands typed interactively, they frequently need to deal with 17598 complicated situations, such as different or unexpected values of 17599 variables and symbols, changes in how the program being debugged is 17600 built, etc. GDB provides a set of flow-control commands to deal with 17601 these complexities. Using these commands, you can write complex 17602 scripts that loop over data structures, execute commands conditionally, 17603 etc. 17604 17605 `if' 17606 `else' 17607 This command allows to include in your script conditionally 17608 executed commands. The `if' command takes a single argument, which 17609 is an expression to evaluate. It is followed by a series of 17610 commands that are executed only if the expression is true (its 17611 value is nonzero). There can then optionally be an `else' line, 17612 followed by a series of commands that are only executed if the 17613 expression was false. The end of the list is marked by a line 17614 containing `end'. 17615 17616 `while' 17617 This command allows to write loops. Its syntax is similar to 17618 `if': the command takes a single argument, which is an expression 17619 to evaluate, and must be followed by the commands to execute, one 17620 per line, terminated by an `end'. These commands are called the 17621 "body" of the loop. The commands in the body of `while' are 17622 executed repeatedly as long as the expression evaluates to true. 17623 17624 `loop_break' 17625 This command exits the `while' loop in whose body it is included. 17626 Execution of the script continues after that `while's `end' line. 17627 17628 `loop_continue' 17629 This command skips the execution of the rest of the body of 17630 commands in the `while' loop in whose body it is included. 17631 Execution branches to the beginning of the `while' loop, where it 17632 evaluates the controlling expression. 17633 17634 `end' 17635 Terminate the block of commands that are the body of `if', `else', 17636 or `while' flow-control commands. 17637 17638 17639 File: gdb.info, Node: Output, Prev: Command Files, Up: Sequences 17640 17641 23.1.4 Commands for Controlled Output 17642 ------------------------------------- 17643 17644 During the execution of a command file or a user-defined command, normal 17645 GDB output is suppressed; the only output that appears is what is 17646 explicitly printed by the commands in the definition. This section 17647 describes three commands useful for generating exactly the output you 17648 want. 17649 17650 `echo TEXT' 17651 Print TEXT. Nonprinting characters can be included in TEXT using 17652 C escape sequences, such as `\n' to print a newline. *No newline 17653 is printed unless you specify one.* In addition to the standard C 17654 escape sequences, a backslash followed by a space stands for a 17655 space. This is useful for displaying a string with spaces at the 17656 beginning or the end, since leading and trailing spaces are 17657 otherwise trimmed from all arguments. To print ` and foo = ', use 17658 the command `echo \ and foo = \ '. 17659 17660 A backslash at the end of TEXT can be used, as in C, to continue 17661 the command onto subsequent lines. For example, 17662 17663 echo This is some text\n\ 17664 which is continued\n\ 17665 onto several lines.\n 17666 17667 produces the same output as 17668 17669 echo This is some text\n 17670 echo which is continued\n 17671 echo onto several lines.\n 17672 17673 `output EXPRESSION' 17674 Print the value of EXPRESSION and nothing but that value: no 17675 newlines, no `$NN = '. The value is not entered in the value 17676 history either. *Note Expressions: Expressions, for more 17677 information on expressions. 17678 17679 `output/FMT EXPRESSION' 17680 Print the value of EXPRESSION in format FMT. You can use the same 17681 formats as for `print'. *Note Output Formats: Output Formats, for 17682 more information. 17683 17684 `printf TEMPLATE, EXPRESSIONS...' 17685 Print the values of one or more EXPRESSIONS under the control of 17686 the string TEMPLATE. To print several values, make EXPRESSIONS be 17687 a comma-separated list of individual expressions, which may be 17688 either numbers or pointers. Their values are printed as specified 17689 by TEMPLATE, exactly as a C program would do by executing the code 17690 below: 17691 17692 printf (TEMPLATE, EXPRESSIONS...); 17693 17694 As in `C' `printf', ordinary characters in TEMPLATE are printed 17695 verbatim, while "conversion specification" introduced by the `%' 17696 character cause subsequent EXPRESSIONS to be evaluated, their 17697 values converted and formatted according to type and style 17698 information encoded in the conversion specifications, and then 17699 printed. 17700 17701 For example, you can print two values in hex like this: 17702 17703 printf "foo, bar-foo = 0x%x, 0x%x\n", foo, bar-foo 17704 17705 `printf' supports all the standard `C' conversion specifications, 17706 including the flags and modifiers between the `%' character and 17707 the conversion letter, with the following exceptions: 17708 17709 * The argument-ordering modifiers, such as `2$', are not 17710 supported. 17711 17712 * The modifier `*' is not supported for specifying precision or 17713 width. 17714 17715 * The `'' flag (for separation of digits into groups according 17716 to `LC_NUMERIC'') is not supported. 17717 17718 * The type modifiers `hh', `j', `t', and `z' are not supported. 17719 17720 * The conversion letter `n' (as in `%n') is not supported. 17721 17722 * The conversion letters `a' and `A' are not supported. 17723 17724 Note that the `ll' type modifier is supported only if the 17725 underlying `C' implementation used to build GDB supports the `long 17726 long int' type, and the `L' type modifier is supported only if 17727 `long double' type is available. 17728 17729 As in `C', `printf' supports simple backslash-escape sequences, 17730 such as `\n', `\t', `\\', `\"', `\a', and `\f', that consist of 17731 backslash followed by a single character. Octal and hexadecimal 17732 escape sequences are not supported. 17733 17734 Additionally, `printf' supports conversion specifications for DFP 17735 ("Decimal Floating Point") types using the following length 17736 modifiers together with a floating point specifier. letters: 17737 17738 * `H' for printing `Decimal32' types. 17739 17740 * `D' for printing `Decimal64' types. 17741 17742 * `DD' for printing `Decimal128' types. 17743 17744 If the underlying `C' implementation used to build GDB has support 17745 for the three length modifiers for DFP types, other modifiers such 17746 as width and precision will also be available for GDB to use. 17747 17748 In case there is no such `C' support, no additional modifiers will 17749 be available and the value will be printed in the standard way. 17750 17751 Here's an example of printing DFP types using the above conversion 17752 letters: 17753 printf "D32: %Hf - D64: %Df - D128: %DDf\n",1.2345df,1.2E10dd,1.2E1dl 17754 17755 `eval TEMPLATE, EXPRESSIONS...' 17756 Convert the values of one or more EXPRESSIONS under the control of 17757 the string TEMPLATE to a command line, and call it. 17758 17759 17760 17761 File: gdb.info, Node: Python, Prev: Sequences, Up: Extending GDB 17762 17763 23.2 Scripting GDB using Python 17764 =============================== 17765 17766 You can script GDB using the Python programming language 17767 (http://www.python.org/). This feature is available only if GDB was 17768 configured using `--with-python'. 17769 17770 Python scripts used by GDB should be installed in 17771 `DATA-DIRECTORY/python', where DATA-DIRECTORY is the data directory as 17772 determined at GDB startup (*note Data Files::). This directory, known 17773 as the "python directory", is automatically added to the Python Search 17774 Path in order to allow the Python interpreter to locate all scripts 17775 installed at this location. 17776 17777 * Menu: 17778 17779 * Python Commands:: Accessing Python from GDB. 17780 * Python API:: Accessing GDB from Python. 17781 * Auto-loading:: Automatically loading Python code. 17782 * Python modules:: Python modules provided by GDB. 17783 17784 17785 File: gdb.info, Node: Python Commands, Next: Python API, Up: Python 17786 17787 23.2.1 Python Commands 17788 ---------------------- 17789 17790 GDB provides one command for accessing the Python interpreter, and one 17791 related setting: 17792 17793 `python [CODE]' 17794 The `python' command can be used to evaluate Python code. 17795 17796 If given an argument, the `python' command will evaluate the 17797 argument as a Python command. For example: 17798 17799 (gdb) python print 23 17800 23 17801 17802 If you do not provide an argument to `python', it will act as a 17803 multi-line command, like `define'. In this case, the Python 17804 script is made up of subsequent command lines, given after the 17805 `python' command. This command list is terminated using a line 17806 containing `end'. For example: 17807 17808 (gdb) python 17809 Type python script 17810 End with a line saying just "end". 17811 >print 23 17812 >end 17813 23 17814 17815 `maint set python print-stack' 17816 By default, GDB will print a stack trace when an error occurs in a 17817 Python script. This can be controlled using `maint set python 17818 print-stack': if `on', the default, then Python stack printing is 17819 enabled; if `off', then Python stack printing is disabled. 17820 17821 It is also possible to execute a Python script from the GDB 17822 interpreter: 17823 17824 `source `script-name'' 17825 The script name must end with `.py' and GDB must be configured to 17826 recognize the script language based on filename extension using 17827 the `script-extension' setting. *Note Extending GDB: Extending 17828 GDB. 17829 17830 `python execfile ("script-name")' 17831 This method is based on the `execfile' Python built-in function, 17832 and thus is always available. 17833 17834 17835 File: gdb.info, Node: Python API, Next: Auto-loading, Prev: Python Commands, Up: Python 17836 17837 23.2.2 Python API 17838 ----------------- 17839 17840 At startup, GDB overrides Python's `sys.stdout' and `sys.stderr' to 17841 print using GDB's output-paging streams. A Python program which 17842 outputs to one of these streams may have its output interrupted by the 17843 user (*note Screen Size::). In this situation, a Python 17844 `KeyboardInterrupt' exception is thrown. 17845 17846 * Menu: 17847 17848 * Basic Python:: Basic Python Functions. 17849 * Exception Handling:: How Python exceptions are translated. 17850 * Values From Inferior:: Python representation of values. 17851 * Types In Python:: Python representation of types. 17852 * Pretty Printing API:: Pretty-printing values. 17853 * Selecting Pretty-Printers:: How GDB chooses a pretty-printer. 17854 * Writing a Pretty-Printer:: Writing a Pretty-Printer. 17855 * Inferiors In Python:: Python representation of inferiors (processes) 17856 * Events In Python:: Listening for events from GDB. 17857 * Threads In Python:: Accessing inferior threads from Python. 17858 * Commands In Python:: Implementing new commands in Python. 17859 * Parameters In Python:: Adding new GDB parameters. 17860 * Functions In Python:: Writing new convenience functions. 17861 * Progspaces In Python:: Program spaces. 17862 * Objfiles In Python:: Object files. 17863 * Frames In Python:: Accessing inferior stack frames from Python. 17864 * Blocks In Python:: Accessing frame blocks from Python. 17865 * Symbols In Python:: Python representation of symbols. 17866 * Symbol Tables In Python:: Python representation of symbol tables. 17867 * Lazy Strings In Python:: Python representation of lazy strings. 17868 * Breakpoints In Python:: Manipulating breakpoints using Python. 17869 17870 17871 File: gdb.info, Node: Basic Python, Next: Exception Handling, Up: Python API 17872 17873 23.2.2.1 Basic Python 17874 ..................... 17875 17876 GDB introduces a new Python module, named `gdb'. All methods and 17877 classes added by GDB are placed in this module. GDB automatically 17878 `import's the `gdb' module for use in all scripts evaluated by the 17879 `python' command. 17880 17881 -- Variable: PYTHONDIR 17882 A string containing the python directory (*note Python::). 17883 17884 -- Function: execute command [from_tty] [to_string] 17885 Evaluate COMMAND, a string, as a GDB CLI command. If a GDB 17886 exception happens while COMMAND runs, it is translated as 17887 described in *note Exception Handling: Exception Handling. 17888 17889 FROM_TTY specifies whether GDB ought to consider this command as 17890 having originated from the user invoking it interactively. It 17891 must be a boolean value. If omitted, it defaults to `False'. 17892 17893 By default, any output produced by COMMAND is sent to GDB's 17894 standard output. If the TO_STRING parameter is `True', then 17895 output will be collected by `gdb.execute' and returned as a 17896 string. The default is `False', in which case the return value is 17897 `None'. If TO_STRING is `True', the GDB virtual terminal will be 17898 temporarily set to unlimited width and height, and its pagination 17899 will be disabled; *note Screen Size::. 17900 17901 -- Function: breakpoints 17902 Return a sequence holding all of GDB's breakpoints. *Note 17903 Breakpoints In Python::, for more information. 17904 17905 -- Function: parameter parameter 17906 Return the value of a GDB parameter. PARAMETER is a string naming 17907 the parameter to look up; PARAMETER may contain spaces if the 17908 parameter has a multi-part name. For example, `print object' is a 17909 valid parameter name. 17910 17911 If the named parameter does not exist, this function throws a 17912 `gdb.error' (*note Exception Handling::). Otherwise, the 17913 parameter's value is converted to a Python value of the appropriate 17914 type, and returned. 17915 17916 -- Function: history number 17917 Return a value from GDB's value history (*note Value History::). 17918 NUMBER indicates which history element to return. If NUMBER is 17919 negative, then GDB will take its absolute value and count backward 17920 from the last element (i.e., the most recent element) to find the 17921 value to return. If NUMBER is zero, then GDB will return the most 17922 recent element. If the element specified by NUMBER doesn't exist 17923 in the value history, a `gdb.error' exception will be raised. 17924 17925 If no exception is raised, the return value is always an instance 17926 of `gdb.Value' (*note Values From Inferior::). 17927 17928 -- Function: parse_and_eval expression 17929 Parse EXPRESSION as an expression in the current language, 17930 evaluate it, and return the result as a `gdb.Value'. EXPRESSION 17931 must be a string. 17932 17933 This function can be useful when implementing a new command (*note 17934 Commands In Python::), as it provides a way to parse the command's 17935 argument as an expression. It is also useful simply to compute 17936 values, for example, it is the only way to get the value of a 17937 convenience variable (*note Convenience Vars::) as a `gdb.Value'. 17938 17939 -- Function: post_event event 17940 Put EVENT, a callable object taking no arguments, into GDB's 17941 internal event queue. This callable will be invoked at some later 17942 point, during GDB's event processing. Events posted using 17943 `post_event' will be run in the order in which they were posted; 17944 however, there is no way to know when they will be processed 17945 relative to other events inside GDB. 17946 17947 GDB is not thread-safe. If your Python program uses multiple 17948 threads, you must be careful to only call GDB-specific functions 17949 in the main GDB thread. `post_event' ensures this. For example: 17950 17951 (gdb) python 17952 >import threading 17953 > 17954 >class Writer(): 17955 > def __init__(self, message): 17956 > self.message = message; 17957 > def __call__(self): 17958 > gdb.write(self.message) 17959 > 17960 >class MyThread1 (threading.Thread): 17961 > def run (self): 17962 > gdb.post_event(Writer("Hello ")) 17963 > 17964 >class MyThread2 (threading.Thread): 17965 > def run (self): 17966 > gdb.post_event(Writer("World\n")) 17967 > 17968 >MyThread1().start() 17969 >MyThread2().start() 17970 >end 17971 (gdb) Hello World 17972 17973 -- Function: write string [stream] 17974 Print a string to GDB's paginated output stream. The optional 17975 STREAM determines the stream to print to. The default stream is 17976 GDB's standard output stream. Possible stream values are: 17977 17978 `STDOUT' 17979 GDB's standard output stream. 17980 17981 `STDERR' 17982 GDB's standard error stream. 17983 17984 `STDLOG' 17985 GDB's log stream (*note Logging Output::). 17986 17987 Writing to `sys.stdout' or `sys.stderr' will automatically call 17988 this function and will automatically direct the output to the 17989 relevant stream. 17990 17991 -- Function: flush 17992 Flush the buffer of a GDB paginated stream so that the contents 17993 are displayed immediately. GDB will flush the contents of a 17994 stream automatically when it encounters a newline in the buffer. 17995 The optional STREAM determines the stream to flush. The default 17996 stream is GDB's standard output stream. Possible stream values 17997 are: 17998 17999 `STDOUT' 18000 GDB's standard output stream. 18001 18002 `STDERR' 18003 GDB's standard error stream. 18004 18005 `STDLOG' 18006 GDB's log stream (*note Logging Output::). 18007 18008 18009 Flushing `sys.stdout' or `sys.stderr' will automatically call this 18010 function for the relevant stream. 18011 18012 -- Function: target_charset 18013 Return the name of the current target character set (*note 18014 Character Sets::). This differs from 18015 `gdb.parameter('target-charset')' in that `auto' is never returned. 18016 18017 -- Function: target_wide_charset 18018 Return the name of the current target wide character set (*note 18019 Character Sets::). This differs from 18020 `gdb.parameter('target-wide-charset')' in that `auto' is never 18021 returned. 18022 18023 -- Function: solib_name address 18024 Return the name of the shared library holding the given ADDRESS as 18025 a string, or `None'. 18026 18027 -- Function: decode_line [expression] 18028 Return locations of the line specified by EXPRESSION, or of the 18029 current line if no argument was given. This function returns a 18030 Python tuple containing two elements. The first element contains 18031 a string holding any unparsed section of EXPRESSION (or `None' if 18032 the expression has been fully parsed). The second element contains 18033 either `None' or another tuple that contains all the locations 18034 that match the expression represented as `gdb.Symtab_and_line' 18035 objects (*note Symbol Tables In Python::). If EXPRESSION is 18036 provided, it is decoded the way that GDB's inbuilt `break' or 18037 `edit' commands do (*note Specify Location::). 18038 18039 18040 File: gdb.info, Node: Exception Handling, Next: Values From Inferior, Prev: Basic Python, Up: Python API 18041 18042 23.2.2.2 Exception Handling 18043 ........................... 18044 18045 When executing the `python' command, Python exceptions uncaught within 18046 the Python code are translated to calls to GDB error-reporting 18047 mechanism. If the command that called `python' does not handle the 18048 error, GDB will terminate it and print an error message containing the 18049 Python exception name, the associated value, and the Python call stack 18050 backtrace at the point where the exception was raised. Example: 18051 18052 (gdb) python print foo 18053 Traceback (most recent call last): 18054 File "<string>", line 1, in <module> 18055 NameError: name 'foo' is not defined 18056 18057 GDB errors that happen in GDB commands invoked by Python code are 18058 converted to Python exceptions. The type of the Python exception 18059 depends on the error. 18060 18061 `gdb.error' 18062 This is the base class for most exceptions generated by GDB. It 18063 is derived from `RuntimeError', for compatibility with earlier 18064 versions of GDB. 18065 18066 If an error occurring in GDB does not fit into some more specific 18067 category, then the generated exception will have this type. 18068 18069 `gdb.MemoryError' 18070 This is a subclass of `gdb.error' which is thrown when an 18071 operation tried to access invalid memory in the inferior. 18072 18073 `KeyboardInterrupt' 18074 User interrupt (via `C-c' or by typing `q' at a pagination prompt) 18075 is translated to a Python `KeyboardInterrupt' exception. 18076 18077 In all cases, your exception handler will see the GDB error message 18078 as its value and the Python call stack backtrace at the Python 18079 statement closest to where the GDB error occured as the traceback. 18080 18081 When implementing GDB commands in Python via `gdb.Command', it is 18082 useful to be able to throw an exception that doesn't cause a traceback 18083 to be printed. For example, the user may have invoked the command 18084 incorrectly. Use the `gdb.GdbError' exception to handle this case. 18085 Example: 18086 18087 (gdb) python 18088 >class HelloWorld (gdb.Command): 18089 > """Greet the whole world.""" 18090 > def __init__ (self): 18091 > super (HelloWorld, self).__init__ ("hello-world", gdb.COMMAND_OBSCURE) 18092 > def invoke (self, args, from_tty): 18093 > argv = gdb.string_to_argv (args) 18094 > if len (argv) != 0: 18095 > raise gdb.GdbError ("hello-world takes no arguments") 18096 > print "Hello, World!" 18097 >HelloWorld () 18098 >end 18099 (gdb) hello-world 42 18100 hello-world takes no arguments 18101 18102 18103 File: gdb.info, Node: Values From Inferior, Next: Types In Python, Prev: Exception Handling, Up: Python API 18104 18105 23.2.2.3 Values From Inferior 18106 ............................. 18107 18108 GDB provides values it obtains from the inferior program in an object 18109 of type `gdb.Value'. GDB uses this object for its internal bookkeeping 18110 of the inferior's values, and for fetching values when necessary. 18111 18112 Inferior values that are simple scalars can be used directly in 18113 Python expressions that are valid for the value's data type. Here's an 18114 example for an integer or floating-point value `some_val': 18115 18116 bar = some_val + 2 18117 18118 As result of this, `bar' will also be a `gdb.Value' object whose values 18119 are of the same type as those of `some_val'. 18120 18121 Inferior values that are structures or instances of some class can 18122 be accessed using the Python "dictionary syntax". For example, if 18123 `some_val' is a `gdb.Value' instance holding a structure, you can 18124 access its `foo' element with: 18125 18126 bar = some_val['foo'] 18127 18128 Again, `bar' will also be a `gdb.Value' object. 18129 18130 A `gdb.Value' that represents a function can be executed via 18131 inferior function call. Any arguments provided to the call must match 18132 the function's prototype, and must be provided in the order specified 18133 by that prototype. 18134 18135 For example, `some_val' is a `gdb.Value' instance representing a 18136 function that takes two integers as arguments. To execute this 18137 function, call it like so: 18138 18139 result = some_val (10,20) 18140 18141 Any values returned from a function call will be stored as a 18142 `gdb.Value'. 18143 18144 The following attributes are provided: 18145 18146 -- Instance Variable of Value: address 18147 If this object is addressable, this read-only attribute holds 18148 a `gdb.Value' object representing the address. Otherwise, 18149 this attribute holds `None'. 18150 18151 -- Instance Variable of Value: is_optimized_out 18152 This read-only boolean attribute is true if the compiler 18153 optimized out this value, thus it is not available for 18154 fetching from the inferior. 18155 18156 -- Instance Variable of Value: type 18157 The type of this `gdb.Value'. The value of this attribute is 18158 a `gdb.Type' object (*note Types In Python::). 18159 18160 -- Instance Variable of Value: dynamic_type 18161 The dynamic type of this `gdb.Value'. This uses C++ run-time 18162 type information (RTTI) to determine the dynamic type of the 18163 value. If this value is of class type, it will return the 18164 class in which the value is embedded, if any. If this value 18165 is of pointer or reference to a class type, it will compute 18166 the dynamic type of the referenced object, and return a 18167 pointer or reference to that type, respectively. In all 18168 other cases, it will return the value's static type. 18169 18170 Note that this feature will only work when debugging a C++ 18171 program that includes RTTI for the object in question. 18172 Otherwise, it will just return the static type of the value 18173 as in `ptype foo' (*note ptype: Symbols.). 18174 18175 The following methods are provided: 18176 18177 -- Method on Value: __init__ VAL 18178 Many Python values can be converted directly to a `gdb.Value' 18179 via this object initializer. Specifically: 18180 18181 Python boolean 18182 A Python boolean is converted to the boolean type from 18183 the current language. 18184 18185 Python integer 18186 A Python integer is converted to the C `long' type for 18187 the current architecture. 18188 18189 Python long 18190 A Python long is converted to the C `long long' type for 18191 the current architecture. 18192 18193 Python float 18194 A Python float is converted to the C `double' type for 18195 the current architecture. 18196 18197 Python string 18198 A Python string is converted to a target string, using 18199 the current target encoding. 18200 18201 `gdb.Value' 18202 If `val' is a `gdb.Value', then a copy of the value is 18203 made. 18204 18205 `gdb.LazyString' 18206 If `val' is a `gdb.LazyString' (*note Lazy Strings In 18207 Python::), then the lazy string's `value' method is 18208 called, and its result is used. 18209 18210 -- Method on Value: cast type 18211 Return a new instance of `gdb.Value' that is the result of 18212 casting this instance to the type described by TYPE, which 18213 must be a `gdb.Type' object. If the cast cannot be performed 18214 for some reason, this method throws an exception. 18215 18216 -- Method on Value: dereference 18217 For pointer data types, this method returns a new `gdb.Value' 18218 object whose contents is the object pointed to by the 18219 pointer. For example, if `foo' is a C pointer to an `int', 18220 declared in your C program as 18221 18222 int *foo; 18223 18224 then you can use the corresponding `gdb.Value' to access what 18225 `foo' points to like this: 18226 18227 bar = foo.dereference () 18228 18229 The result `bar' will be a `gdb.Value' object holding the 18230 value pointed to by `foo'. 18231 18232 -- Method on Value: dynamic_cast type 18233 Like `Value.cast', but works as if the C++ `dynamic_cast' 18234 operator were used. Consult a C++ reference for details. 18235 18236 -- Method on Value: reinterpret_cast type 18237 Like `Value.cast', but works as if the C++ `reinterpret_cast' 18238 operator were used. Consult a C++ reference for details. 18239 18240 -- Method on Value: string [encoding] [errors] [length] 18241 If this `gdb.Value' represents a string, then this method 18242 converts the contents to a Python string. Otherwise, this 18243 method will throw an exception. 18244 18245 Strings are recognized in a language-specific way; whether a 18246 given `gdb.Value' represents a string is determined by the 18247 current language. 18248 18249 For C-like languages, a value is a string if it is a pointer 18250 to or an array of characters or ints. The string is assumed 18251 to be terminated by a zero of the appropriate width. However 18252 if the optional length argument is given, the string will be 18253 converted to that given length, ignoring any embedded zeros 18254 that the string may contain. 18255 18256 If the optional ENCODING argument is given, it must be a 18257 string naming the encoding of the string in the `gdb.Value', 18258 such as `"ascii"', `"iso-8859-6"' or `"utf-8"'. It accepts 18259 the same encodings as the corresponding argument to Python's 18260 `string.decode' method, and the Python codec machinery will 18261 be used to convert the string. If ENCODING is not given, or 18262 if ENCODING is the empty string, then either the 18263 `target-charset' (*note Character Sets::) will be used, or a 18264 language-specific encoding will be used, if the current 18265 language is able to supply one. 18266 18267 The optional ERRORS argument is the same as the corresponding 18268 argument to Python's `string.decode' method. 18269 18270 If the optional LENGTH argument is given, the string will be 18271 fetched and converted to the given length. 18272 18273 -- Method on Value: lazy_string [encoding] [length] 18274 If this `gdb.Value' represents a string, then this method 18275 converts the contents to a `gdb.LazyString' (*note Lazy 18276 Strings In Python::). Otherwise, this method will throw an 18277 exception. 18278 18279 If the optional ENCODING argument is given, it must be a 18280 string naming the encoding of the `gdb.LazyString'. Some 18281 examples are: `ascii', `iso-8859-6' or `utf-8'. If the 18282 ENCODING argument is an encoding that GDB does recognize, GDB 18283 will raise an error. 18284 18285 When a lazy string is printed, the GDB encoding machinery is 18286 used to convert the string during printing. If the optional 18287 ENCODING argument is not provided, or is an empty string, GDB 18288 will automatically select the encoding most suitable for the 18289 string type. For further information on encoding in GDB 18290 please see *note Character Sets::. 18291 18292 If the optional LENGTH argument is given, the string will be 18293 fetched and encoded to the length of characters specified. If 18294 the LENGTH argument is not provided, the string will be 18295 fetched and encoded until a null of appropriate width is 18296 found. 18297 18298 18299 File: gdb.info, Node: Types In Python, Next: Pretty Printing API, Prev: Values From Inferior, Up: Python API 18300 18301 23.2.2.4 Types In Python 18302 ........................ 18303 18304 GDB represents types from the inferior using the class `gdb.Type'. 18305 18306 The following type-related functions are available in the `gdb' 18307 module: 18308 18309 -- Function: lookup_type name [block] 18310 This function looks up a type by name. NAME is the name of the 18311 type to look up. It must be a string. 18312 18313 If BLOCK is given, then NAME is looked up in that scope. 18314 Otherwise, it is searched for globally. 18315 18316 Ordinarily, this function will return an instance of `gdb.Type'. 18317 If the named type cannot be found, it will throw an exception. 18318 18319 An instance of `Type' has the following attributes: 18320 18321 -- Instance Variable of Type: code 18322 The type code for this type. The type code will be one of the 18323 `TYPE_CODE_' constants defined below. 18324 18325 -- Instance Variable of Type: sizeof 18326 The size of this type, in target `char' units. Usually, a 18327 target's `char' type will be an 8-bit byte. However, on some 18328 unusual platforms, this type may have a different size. 18329 18330 -- Instance Variable of Type: tag 18331 The tag name for this type. The tag name is the name after 18332 `struct', `union', or `enum' in C and C++; not all languages 18333 have this concept. If this type has no tag name, then `None' 18334 is returned. 18335 18336 The following methods are provided: 18337 18338 -- Method on Type: fields 18339 For structure and union types, this method returns the 18340 fields. Range types have two fields, the minimum and maximum 18341 values. Enum types have one field per enum constant. 18342 Function and method types have one field per parameter. The 18343 base types of C++ classes are also represented as fields. If 18344 the type has no fields, or does not fit into one of these 18345 categories, an empty sequence will be returned. 18346 18347 Each field is an object, with some pre-defined attributes: 18348 `bitpos' 18349 This attribute is not available for `static' fields (as 18350 in C++ or Java). For non-`static' fields, the value is 18351 the bit position of the field. 18352 18353 `name' 18354 The name of the field, or `None' for anonymous fields. 18355 18356 `artificial' 18357 This is `True' if the field is artificial, usually 18358 meaning that it was provided by the compiler and not the 18359 user. This attribute is always provided, and is `False' 18360 if the field is not artificial. 18361 18362 `is_base_class' 18363 This is `True' if the field represents a base class of a 18364 C++ structure. This attribute is always provided, and 18365 is `False' if the field is not a base class of the type 18366 that is the argument of `fields', or if that type was 18367 not a C++ class. 18368 18369 `bitsize' 18370 If the field is packed, or is a bitfield, then this will 18371 have a non-zero value, which is the size of the field in 18372 bits. Otherwise, this will be zero; in this case the 18373 field's size is given by its type. 18374 18375 `type' 18376 The type of the field. This is usually an instance of 18377 `Type', but it can be `None' in some situations. 18378 18379 -- Method on Type: array N1 [N2] 18380 Return a new `gdb.Type' object which represents an array of 18381 this type. If one argument is given, it is the inclusive 18382 upper bound of the array; in this case the lower bound is 18383 zero. If two arguments are given, the first argument is the 18384 lower bound of the array, and the second argument is the 18385 upper bound of the array. An array's length must not be 18386 negative, but the bounds can be. 18387 18388 -- Method on Type: const 18389 Return a new `gdb.Type' object which represents a 18390 `const'-qualified variant of this type. 18391 18392 -- Method on Type: volatile 18393 Return a new `gdb.Type' object which represents a 18394 `volatile'-qualified variant of this type. 18395 18396 -- Method on Type: unqualified 18397 Return a new `gdb.Type' object which represents an unqualified 18398 variant of this type. That is, the result is neither `const' 18399 nor `volatile'. 18400 18401 -- Method on Type: range 18402 Return a Python `Tuple' object that contains two elements: the 18403 low bound of the argument type and the high bound of that 18404 type. If the type does not have a range, GDB will raise a 18405 `gdb.error' exception (*note Exception Handling::). 18406 18407 -- Method on Type: reference 18408 Return a new `gdb.Type' object which represents a reference 18409 to this type. 18410 18411 -- Method on Type: pointer 18412 Return a new `gdb.Type' object which represents a pointer to 18413 this type. 18414 18415 -- Method on Type: strip_typedefs 18416 Return a new `gdb.Type' that represents the real type, after 18417 removing all layers of typedefs. 18418 18419 -- Method on Type: target 18420 Return a new `gdb.Type' object which represents the target 18421 type of this type. 18422 18423 For a pointer type, the target type is the type of the 18424 pointed-to object. For an array type (meaning C-like 18425 arrays), the target type is the type of the elements of the 18426 array. For a function or method type, the target type is the 18427 type of the return value. For a complex type, the target 18428 type is the type of the elements. For a typedef, the target 18429 type is the aliased type. 18430 18431 If the type does not have a target, this method will throw an 18432 exception. 18433 18434 -- Method on Type: template_argument n [block] 18435 If this `gdb.Type' is an instantiation of a template, this 18436 will return a new `gdb.Type' which represents the type of the 18437 Nth template argument. 18438 18439 If this `gdb.Type' is not a template type, this will throw an 18440 exception. Ordinarily, only C++ code will have template 18441 types. 18442 18443 If BLOCK is given, then NAME is looked up in that scope. 18444 Otherwise, it is searched for globally. 18445 18446 Each type has a code, which indicates what category this type falls 18447 into. The available type categories are represented by constants 18448 defined in the `gdb' module: 18449 18450 `TYPE_CODE_PTR' 18451 The type is a pointer. 18452 18453 `TYPE_CODE_ARRAY' 18454 The type is an array. 18455 18456 `TYPE_CODE_STRUCT' 18457 The type is a structure. 18458 18459 `TYPE_CODE_UNION' 18460 The type is a union. 18461 18462 `TYPE_CODE_ENUM' 18463 The type is an enum. 18464 18465 `TYPE_CODE_FLAGS' 18466 A bit flags type, used for things such as status registers. 18467 18468 `TYPE_CODE_FUNC' 18469 The type is a function. 18470 18471 `TYPE_CODE_INT' 18472 The type is an integer type. 18473 18474 `TYPE_CODE_FLT' 18475 A floating point type. 18476 18477 `TYPE_CODE_VOID' 18478 The special type `void'. 18479 18480 `TYPE_CODE_SET' 18481 A Pascal set type. 18482 18483 `TYPE_CODE_RANGE' 18484 A range type, that is, an integer type with bounds. 18485 18486 `TYPE_CODE_STRING' 18487 A string type. Note that this is only used for certain languages 18488 with language-defined string types; C strings are not represented 18489 this way. 18490 18491 `TYPE_CODE_BITSTRING' 18492 A string of bits. 18493 18494 `TYPE_CODE_ERROR' 18495 An unknown or erroneous type. 18496 18497 `TYPE_CODE_METHOD' 18498 A method type, as found in C++ or Java. 18499 18500 `TYPE_CODE_METHODPTR' 18501 A pointer-to-member-function. 18502 18503 `TYPE_CODE_MEMBERPTR' 18504 A pointer-to-member. 18505 18506 `TYPE_CODE_REF' 18507 A reference type. 18508 18509 `TYPE_CODE_CHAR' 18510 A character type. 18511 18512 `TYPE_CODE_BOOL' 18513 A boolean type. 18514 18515 `TYPE_CODE_COMPLEX' 18516 A complex float type. 18517 18518 `TYPE_CODE_TYPEDEF' 18519 A typedef to some other type. 18520 18521 `TYPE_CODE_NAMESPACE' 18522 A C++ namespace. 18523 18524 `TYPE_CODE_DECFLOAT' 18525 A decimal floating point type. 18526 18527 `TYPE_CODE_INTERNAL_FUNCTION' 18528 A function internal to GDB. This is the type used to represent 18529 convenience functions. 18530 18531 Further support for types is provided in the `gdb.types' Python 18532 module (*note gdb.types::). 18533 18534 18535 File: gdb.info, Node: Pretty Printing API, Next: Selecting Pretty-Printers, Prev: Types In Python, Up: Python API 18536 18537 23.2.2.5 Pretty Printing API 18538 ............................ 18539 18540 An example output is provided (*note Pretty Printing::). 18541 18542 A pretty-printer is just an object that holds a value and implements 18543 a specific interface, defined here. 18544 18545 -- Operation on pretty printer: children (self) 18546 GDB will call this method on a pretty-printer to compute the 18547 children of the pretty-printer's value. 18548 18549 This method must return an object conforming to the Python iterator 18550 protocol. Each item returned by the iterator must be a tuple 18551 holding two elements. The first element is the "name" of the 18552 child; the second element is the child's value. The value can be 18553 any Python object which is convertible to a GDB value. 18554 18555 This method is optional. If it does not exist, GDB will act as 18556 though the value has no children. 18557 18558 -- Operation on pretty printer: display_hint (self) 18559 The CLI may call this method and use its result to change the 18560 formatting of a value. The result will also be supplied to an MI 18561 consumer as a `displayhint' attribute of the variable being 18562 printed. 18563 18564 This method is optional. If it does exist, this method must 18565 return a string. 18566 18567 Some display hints are predefined by GDB: 18568 18569 `array' 18570 Indicate that the object being printed is "array-like". The 18571 CLI uses this to respect parameters such as `set print 18572 elements' and `set print array'. 18573 18574 `map' 18575 Indicate that the object being printed is "map-like", and 18576 that the children of this value can be assumed to alternate 18577 between keys and values. 18578 18579 `string' 18580 Indicate that the object being printed is "string-like". If 18581 the printer's `to_string' method returns a Python string of 18582 some kind, then GDB will call its internal language-specific 18583 string-printing function to format the string. For the CLI 18584 this means adding quotation marks, possibly escaping some 18585 characters, respecting `set print elements', and the like. 18586 18587 -- Operation on pretty printer: to_string (self) 18588 GDB will call this method to display the string representation of 18589 the value passed to the object's constructor. 18590 18591 When printing from the CLI, if the `to_string' method exists, then 18592 GDB will prepend its result to the values returned by `children'. 18593 Exactly how this formatting is done is dependent on the display 18594 hint, and may change as more hints are added. Also, depending on 18595 the print settings (*note Print Settings::), the CLI may print 18596 just the result of `to_string' in a stack trace, omitting the 18597 result of `children'. 18598 18599 If this method returns a string, it is printed verbatim. 18600 18601 Otherwise, if this method returns an instance of `gdb.Value', then 18602 GDB prints this value. This may result in a call to another 18603 pretty-printer. 18604 18605 If instead the method returns a Python value which is convertible 18606 to a `gdb.Value', then GDB performs the conversion and prints the 18607 resulting value. Again, this may result in a call to another 18608 pretty-printer. Python scalars (integers, floats, and booleans) 18609 and strings are convertible to `gdb.Value'; other types are not. 18610 18611 Finally, if this method returns `None' then no further operations 18612 are peformed in this method and nothing is printed. 18613 18614 If the result is not one of these types, an exception is raised. 18615 18616 GDB provides a function which can be used to look up the default 18617 pretty-printer for a `gdb.Value': 18618 18619 -- Function: default_visualizer value 18620 This function takes a `gdb.Value' object as an argument. If a 18621 pretty-printer for this value exists, then it is returned. If no 18622 such printer exists, then this returns `None'. 18623 18624 18625 File: gdb.info, Node: Selecting Pretty-Printers, Next: Writing a Pretty-Printer, Prev: Pretty Printing API, Up: Python API 18626 18627 23.2.2.6 Selecting Pretty-Printers 18628 .................................. 18629 18630 The Python list `gdb.pretty_printers' contains an array of functions or 18631 callable objects that have been registered via addition as a 18632 pretty-printer. Printers in this list are called `global' printers, 18633 they're available when debugging all inferiors. Each `gdb.Progspace' 18634 contains a `pretty_printers' attribute. Each `gdb.Objfile' also 18635 contains a `pretty_printers' attribute. 18636 18637 Each function on these lists is passed a single `gdb.Value' argument 18638 and should return a pretty-printer object conforming to the interface 18639 definition above (*note Pretty Printing API::). If a function cannot 18640 create a pretty-printer for the value, it should return `None'. 18641 18642 GDB first checks the `pretty_printers' attribute of each 18643 `gdb.Objfile' in the current program space and iteratively calls each 18644 enabled lookup routine in the list for that `gdb.Objfile' until it 18645 receives a pretty-printer object. If no pretty-printer is found in the 18646 objfile lists, GDB then searches the pretty-printer list of the current 18647 program space, calling each enabled function until an object is 18648 returned. After these lists have been exhausted, it tries the global 18649 `gdb.pretty_printers' list, again calling each enabled function until an 18650 object is returned. 18651 18652 The order in which the objfiles are searched is not specified. For a 18653 given list, functions are always invoked from the head of the list, and 18654 iterated over sequentially until the end of the list, or a printer 18655 object is returned. 18656 18657 For various reasons a pretty-printer may not work. For example, the 18658 underlying data structure may have changed and the pretty-printer is 18659 out of date. 18660 18661 The consequences of a broken pretty-printer are severe enough that 18662 GDB provides support for enabling and disabling individual printers. 18663 For example, if `print frame-arguments' is on, a backtrace can become 18664 highly illegible if any argument is printed with a broken printer. 18665 18666 Pretty-printers are enabled and disabled by attaching an `enabled' 18667 attribute to the registered function or callable object. If this 18668 attribute is present and its value is `False', the printer is disabled, 18669 otherwise the printer is enabled. 18670 18671 18672 File: gdb.info, Node: Writing a Pretty-Printer, Next: Inferiors In Python, Prev: Selecting Pretty-Printers, Up: Python API 18673 18674 23.2.2.7 Writing a Pretty-Printer 18675 ................................. 18676 18677 A pretty-printer consists of two parts: a lookup function to detect if 18678 the type is supported, and the printer itself. 18679 18680 Here is an example showing how a `std::string' printer might be 18681 written. *Note Pretty Printing API::, for details on the API this class 18682 must provide. 18683 18684 class StdStringPrinter(object): 18685 "Print a std::string" 18686 18687 def __init__(self, val): 18688 self.val = val 18689 18690 def to_string(self): 18691 return self.val['_M_dataplus']['_M_p'] 18692 18693 def display_hint(self): 18694 return 'string' 18695 18696 And here is an example showing how a lookup function for the printer 18697 example above might be written. 18698 18699 def str_lookup_function(val): 18700 lookup_tag = val.type.tag 18701 if lookup_tag == None: 18702 return None 18703 regex = re.compile("^std::basic_string<char,.*>$") 18704 if regex.match(lookup_tag): 18705 return StdStringPrinter(val) 18706 return None 18707 18708 The example lookup function extracts the value's type, and attempts 18709 to match it to a type that it can pretty-print. If it is a type the 18710 printer can pretty-print, it will return a printer object. If not, it 18711 returns `None'. 18712 18713 We recommend that you put your core pretty-printers into a Python 18714 package. If your pretty-printers are for use with a library, we 18715 further recommend embedding a version number into the package name. 18716 This practice will enable GDB to load multiple versions of your 18717 pretty-printers at the same time, because they will have different 18718 names. 18719 18720 You should write auto-loaded code (*note Auto-loading::) such that it 18721 can be evaluated multiple times without changing its meaning. An ideal 18722 auto-load file will consist solely of `import's of your printer 18723 modules, followed by a call to a register pretty-printers with the 18724 current objfile. 18725 18726 Taken as a whole, this approach will scale nicely to multiple 18727 inferiors, each potentially using a different library version. 18728 Embedding a version number in the Python package name will ensure that 18729 GDB is able to load both sets of printers simultaneously. Then, 18730 because the search for pretty-printers is done by objfile, and because 18731 your auto-loaded code took care to register your library's printers 18732 with a specific objfile, GDB will find the correct printers for the 18733 specific version of the library used by each inferior. 18734 18735 To continue the `std::string' example (*note Pretty Printing API::), 18736 this code might appear in `gdb.libstdcxx.v6': 18737 18738 def register_printers(objfile): 18739 objfile.pretty_printers.add(str_lookup_function) 18740 18741 And then the corresponding contents of the auto-load file would be: 18742 18743 import gdb.libstdcxx.v6 18744 gdb.libstdcxx.v6.register_printers(gdb.current_objfile()) 18745 18746 The previous example illustrates a basic pretty-printer. There are 18747 a few things that can be improved on. The printer doesn't have a name, 18748 making it hard to identify in a list of installed printers. The lookup 18749 function has a name, but lookup functions can have arbitrary, even 18750 identical, names. 18751 18752 Second, the printer only handles one type, whereas a library 18753 typically has several types. One could install a lookup function for 18754 each desired type in the library, but one could also have a single 18755 lookup function recognize several types. The latter is the 18756 conventional way this is handled. If a pretty-printer can handle 18757 multiple data types, then its "subprinters" are the printers for the 18758 individual data types. 18759 18760 The `gdb.printing' module provides a formal way of solving these 18761 problems (*note gdb.printing::). Here is another example that handles 18762 multiple types. 18763 18764 These are the types we are going to pretty-print: 18765 18766 struct foo { int a, b; }; 18767 struct bar { struct foo x, y; }; 18768 18769 Here are the printers: 18770 18771 class fooPrinter: 18772 """Print a foo object.""" 18773 18774 def __init__(self, val): 18775 self.val = val 18776 18777 def to_string(self): 18778 return ("a=<" + str(self.val["a"]) + 18779 "> b=<" + str(self.val["b"]) + ">") 18780 18781 class barPrinter: 18782 """Print a bar object.""" 18783 18784 def __init__(self, val): 18785 self.val = val 18786 18787 def to_string(self): 18788 return ("x=<" + str(self.val["x"]) + 18789 "> y=<" + str(self.val["y"]) + ">") 18790 18791 This example doesn't need a lookup function, that is handled by the 18792 `gdb.printing' module. Instead a function is provided to build up the 18793 object that handles the lookup. 18794 18795 import gdb.printing 18796 18797 def build_pretty_printer(): 18798 pp = gdb.printing.RegexpCollectionPrettyPrinter( 18799 "my_library") 18800 pp.add_printer('foo', '^foo$', fooPrinter) 18801 pp.add_printer('bar', '^bar$', barPrinter) 18802 return pp 18803 18804 And here is the autoload support: 18805 18806 import gdb.printing 18807 import my_library 18808 gdb.printing.register_pretty_printer( 18809 gdb.current_objfile(), 18810 my_library.build_pretty_printer()) 18811 18812 Finally, when this printer is loaded into GDB, here is the 18813 corresponding output of `info pretty-printer': 18814 18815 (gdb) info pretty-printer 18816 my_library.so: 18817 my_library 18818 foo 18819 bar 18820 18821 18822 File: gdb.info, Node: Inferiors In Python, Next: Events In Python, Prev: Writing a Pretty-Printer, Up: Python API 18823 18824 23.2.2.8 Inferiors In Python 18825 ............................ 18826 18827 Programs which are being run under GDB are called inferiors (*note 18828 Inferiors and Programs::). Python scripts can access information about 18829 and manipulate inferiors controlled by GDB via objects of the 18830 `gdb.Inferior' class. 18831 18832 The following inferior-related functions are available in the `gdb' 18833 module: 18834 18835 -- Function: inferiors 18836 Return a tuple containing all inferior objects. 18837 18838 A `gdb.Inferior' object has the following attributes: 18839 18840 -- Instance Variable of Inferior: num 18841 ID of inferior, as assigned by GDB. 18842 18843 -- Instance Variable of Inferior: pid 18844 Process ID of the inferior, as assigned by the underlying 18845 operating system. 18846 18847 -- Instance Variable of Inferior: was_attached 18848 Boolean signaling whether the inferior was created using 18849 `attach', or started by GDB itself. 18850 18851 A `gdb.Inferior' object has the following methods: 18852 18853 -- Method on Inferior: is_valid 18854 Returns `True' if the `gdb.Inferior' object is valid, `False' 18855 if not. A `gdb.Inferior' object will become invalid if the 18856 inferior no longer exists within GDB. All other 18857 `gdb.Inferior' methods will throw an exception if it is 18858 invalid at the time the method is called. 18859 18860 -- Method on Inferior: threads 18861 This method returns a tuple holding all the threads which are 18862 valid when it is called. If there are no valid threads, the 18863 method will return an empty tuple. 18864 18865 -- Method on Inferior: read_memory address length 18866 Read LENGTH bytes of memory from the inferior, starting at 18867 ADDRESS. Returns a buffer object, which behaves much like an 18868 array or a string. It can be modified and given to the 18869 `gdb.write_memory' function. 18870 18871 -- Method on Inferior: write_memory address buffer [length] 18872 Write the contents of BUFFER to the inferior, starting at 18873 ADDRESS. The BUFFER parameter must be a Python object which 18874 supports the buffer protocol, i.e., a string, an array or the 18875 object returned from `gdb.read_memory'. If given, LENGTH 18876 determines the number of bytes from BUFFER to be written. 18877 18878 -- Method on Inferior: search_memory address length pattern 18879 Search a region of the inferior memory starting at ADDRESS 18880 with the given LENGTH using the search pattern supplied in 18881 PATTERN. The PATTERN parameter must be a Python object which 18882 supports the buffer protocol, i.e., a string, an array or the 18883 object returned from `gdb.read_memory'. Returns a Python 18884 `Long' containing the address where the pattern was found, or 18885 `None' if the pattern could not be found. 18886 18887 18888 File: gdb.info, Node: Events In Python, Next: Threads In Python, Prev: Inferiors In Python, Up: Python API 18889 18890 23.2.2.9 Events In Python 18891 ......................... 18892 18893 GDB provides a general event facility so that Python code can be 18894 notified of various state changes, particularly changes that occur in 18895 the inferior. 18896 18897 An "event" is just an object that describes some state change. The 18898 type of the object and its attributes will vary depending on the details 18899 of the change. All the existing events are described below. 18900 18901 In order to be notified of an event, you must register an event 18902 handler with an "event registry". An event registry is an object in the 18903 `gdb.events' module which dispatches particular events. A registry 18904 provides methods to register and unregister event handlers: 18905 18906 -- Method on EventRegistry: connect object 18907 Add the given callable OBJECT to the registry. This object 18908 will be called when an event corresponding to this registry 18909 occurs. 18910 18911 -- Method on EventRegistry: disconnect object 18912 Remove the given OBJECT from the registry. Once removed, the 18913 object will no longer receive notifications of events. 18914 18915 Here is an example: 18916 18917 def exit_handler (event): 18918 print "event type: exit" 18919 print "exit code: %d" % (event.exit_code) 18920 18921 gdb.events.exited.connect (exit_handler) 18922 18923 In the above example we connect our handler `exit_handler' to the 18924 registry `events.exited'. Once connected, `exit_handler' gets called 18925 when the inferior exits. The argument "event" in this example is of 18926 type `gdb.ExitedEvent'. As you can see in the example the 18927 `ExitedEvent' object has an attribute which indicates the exit code of 18928 the inferior. 18929 18930 The following is a listing of the event registries that are 18931 available and details of the events they emit: 18932 18933 `events.cont' 18934 Emits `gdb.ThreadEvent'. 18935 18936 Some events can be thread specific when GDB is running in non-stop 18937 mode. When represented in Python, these events all extend 18938 `gdb.ThreadEvent'. Note, this event is not emitted directly; 18939 instead, events which are emitted by this or other modules might 18940 extend this event. Examples of these events are 18941 `gdb.BreakpointEvent' and `gdb.ContinueEvent'. 18942 18943 -- Instance Variable of ThreadEvent: inferior_thread 18944 In non-stop mode this attribute will be set to the 18945 specific thread which was involved in the emitted event. 18946 Otherwise, it will be set to `None'. 18947 18948 Emits `gdb.ContinueEvent' which extends `gdb.ThreadEvent'. 18949 18950 This event indicates that the inferior has been continued after a 18951 stop. For inherited attribute refer to `gdb.ThreadEvent' above. 18952 18953 `events.exited' 18954 Emits `events.ExitedEvent' which indicates that the inferior has 18955 exited. `events.ExitedEvent' has one optional attribute. This 18956 attribute will exist only in the case that the inferior exited 18957 with some status. 18958 -- Instance Variable of ExitedEvent: exit_code 18959 An integer representing the exit code which the inferior 18960 has returned. 18961 18962 `events.stop' 18963 Emits `gdb.StopEvent' which extends `gdb.ThreadEvent'. 18964 18965 Indicates that the inferior has stopped. All events emitted by 18966 this registry extend StopEvent. As a child of `gdb.ThreadEvent', 18967 `gdb.StopEvent' will indicate the stopped thread when GDB is 18968 running in non-stop mode. Refer to `gdb.ThreadEvent' above for 18969 more details. 18970 18971 Emits `gdb.SignalEvent' which extends `gdb.StopEvent'. 18972 18973 This event indicates that the inferior or one of its threads has 18974 received as signal. `gdb.SignalEvent' has the following 18975 attributes: 18976 18977 -- Instance Variable of SignalEvent: stop_signal 18978 A string representing the signal received by the 18979 inferior. A list of possible signal values can be 18980 obtained by running the command `info signals' in the 18981 GDB command prompt. 18982 18983 Also emits `gdb.BreakpointEvent' which extends `gdb.StopEvent'. 18984 18985 `gdb.BreakpointEvent' event indicates that a breakpoint has been 18986 hit, and has the following attributes: 18987 18988 -- Instance Variable of BreakpointEvent: breakpoint 18989 A reference to the breakpoint that was hit of type 18990 `gdb.Breakpoint'. *Note Breakpoints In Python::, for 18991 details of the `gdb.Breakpoint' object. 18992 18993 18994 18995 File: gdb.info, Node: Threads In Python, Next: Commands In Python, Prev: Events In Python, Up: Python API 18996 18997 23.2.2.10 Threads In Python 18998 ........................... 18999 19000 Python scripts can access information about, and manipulate inferior 19001 threads controlled by GDB, via objects of the `gdb.InferiorThread' 19002 class. 19003 19004 The following thread-related functions are available in the `gdb' 19005 module: 19006 19007 -- Function: selected_thread 19008 This function returns the thread object for the selected thread. 19009 If there is no selected thread, this will return `None'. 19010 19011 A `gdb.InferiorThread' object has the following attributes: 19012 19013 -- Instance Variable of InferiorThread: name 19014 The name of the thread. If the user specified a name using 19015 `thread name', then this returns that name. Otherwise, if an 19016 OS-supplied name is available, then it is returned. 19017 Otherwise, this returns `None'. 19018 19019 This attribute can be assigned to. The new value must be a 19020 string object, which sets the new name, or `None', which 19021 removes any user-specified thread name. 19022 19023 -- Instance Variable of InferiorThread: num 19024 ID of the thread, as assigned by GDB. 19025 19026 -- Instance Variable of InferiorThread: ptid 19027 ID of the thread, as assigned by the operating system. This 19028 attribute is a tuple containing three integers. The first is 19029 the Process ID (PID); the second is the Lightweight Process 19030 ID (LWPID), and the third is the Thread ID (TID). Either the 19031 LWPID or TID may be 0, which indicates that the operating 19032 system does not use that identifier. 19033 19034 A `gdb.InferiorThread' object has the following methods: 19035 19036 -- Method on InferiorThread: is_valid 19037 Returns `True' if the `gdb.InferiorThread' object is valid, 19038 `False' if not. A `gdb.InferiorThread' object will become 19039 invalid if the thread exits, or the inferior that the thread 19040 belongs is deleted. All other `gdb.InferiorThread' methods 19041 will throw an exception if it is invalid at the time the 19042 method is called. 19043 19044 -- Method on InferiorThread: switch 19045 This changes GDB's currently selected thread to the one 19046 represented by this object. 19047 19048 -- Method on InferiorThread: is_stopped 19049 Return a Boolean indicating whether the thread is stopped. 19050 19051 -- Method on InferiorThread: is_running 19052 Return a Boolean indicating whether the thread is running. 19053 19054 -- Method on InferiorThread: is_exited 19055 Return a Boolean indicating whether the thread is exited. 19056 19057 19058 File: gdb.info, Node: Commands In Python, Next: Parameters In Python, Prev: Threads In Python, Up: Python API 19059 19060 23.2.2.11 Commands In Python 19061 ............................ 19062 19063 You can implement new GDB CLI commands in Python. A CLI command is 19064 implemented using an instance of the `gdb.Command' class, most commonly 19065 using a subclass. 19066 19067 -- Method on Command: __init__ name COMMAND_CLASS [COMPLETER_CLASS] 19068 [PREFIX] 19069 The object initializer for `Command' registers the new command 19070 with GDB. This initializer is normally invoked from the subclass' 19071 own `__init__' method. 19072 19073 NAME is the name of the command. If NAME consists of multiple 19074 words, then the initial words are looked for as prefix commands. 19075 In this case, if one of the prefix commands does not exist, an 19076 exception is raised. 19077 19078 There is no support for multi-line commands. 19079 19080 COMMAND_CLASS should be one of the `COMMAND_' constants defined 19081 below. This argument tells GDB how to categorize the new command 19082 in the help system. 19083 19084 COMPLETER_CLASS is an optional argument. If given, it should be 19085 one of the `COMPLETE_' constants defined below. This argument 19086 tells GDB how to perform completion for this command. If not 19087 given, GDB will attempt to complete using the object's `complete' 19088 method (see below); if no such method is found, an error will 19089 occur when completion is attempted. 19090 19091 PREFIX is an optional argument. If `True', then the new command 19092 is a prefix command; sub-commands of this command may be 19093 registered. 19094 19095 The help text for the new command is taken from the Python 19096 documentation string for the command's class, if there is one. If 19097 no documentation string is provided, the default value "This 19098 command is not documented." is used. 19099 19100 -- Method on Command: dont_repeat 19101 By default, a GDB command is repeated when the user enters a blank 19102 line at the command prompt. A command can suppress this behavior 19103 by invoking the `dont_repeat' method. This is similar to the user 19104 command `dont-repeat', see *note dont-repeat: Define. 19105 19106 -- Method on Command: invoke argument from_tty 19107 This method is called by GDB when this command is invoked. 19108 19109 ARGUMENT is a string. It is the argument to the command, after 19110 leading and trailing whitespace has been stripped. 19111 19112 FROM_TTY is a boolean argument. When true, this means that the 19113 command was entered by the user at the terminal; when false it 19114 means that the command came from elsewhere. 19115 19116 If this method throws an exception, it is turned into a GDB 19117 `error' call. Otherwise, the return value is ignored. 19118 19119 To break ARGUMENT up into an argv-like string use 19120 `gdb.string_to_argv'. This function behaves identically to GDB's 19121 internal argument lexer `buildargv'. It is recommended to use 19122 this for consistency. Arguments are separated by spaces and may 19123 be quoted. Example: 19124 19125 print gdb.string_to_argv ("1 2\ \\\"3 '4 \"5' \"6 '7\"") 19126 ['1', '2 "3', '4 "5', "6 '7"] 19127 19128 19129 -- Method on Command: complete text word 19130 This method is called by GDB when the user attempts completion on 19131 this command. All forms of completion are handled by this method, 19132 that is, the <TAB> and <M-?> key bindings (*note Completion::), 19133 and the `complete' command (*note complete: Help.). 19134 19135 The arguments TEXT and WORD are both strings. TEXT holds the 19136 complete command line up to the cursor's location. WORD holds the 19137 last word of the command line; this is computed using a 19138 word-breaking heuristic. 19139 19140 The `complete' method can return several values: 19141 * If the return value is a sequence, the contents of the 19142 sequence are used as the completions. It is up to `complete' 19143 to ensure that the contents actually do complete the word. A 19144 zero-length sequence is allowed, it means that there were no 19145 completions available. Only string elements of the sequence 19146 are used; other elements in the sequence are ignored. 19147 19148 * If the return value is one of the `COMPLETE_' constants 19149 defined below, then the corresponding GDB-internal completion 19150 function is invoked, and its result is used. 19151 19152 * All other results are treated as though there were no 19153 available completions. 19154 19155 When a new command is registered, it must be declared as a member of 19156 some general class of commands. This is used to classify top-level 19157 commands in the on-line help system; note that prefix commands are not 19158 listed under their own category but rather that of their top-level 19159 command. The available classifications are represented by constants 19160 defined in the `gdb' module: 19161 19162 `COMMAND_NONE' 19163 The command does not belong to any particular class. A command in 19164 this category will not be displayed in any of the help categories. 19165 19166 `COMMAND_RUNNING' 19167 The command is related to running the inferior. For example, 19168 `start', `step', and `continue' are in this category. Type `help 19169 running' at the GDB prompt to see a list of commands in this 19170 category. 19171 19172 `COMMAND_DATA' 19173 The command is related to data or variables. For example, `call', 19174 `find', and `print' are in this category. Type `help data' at the 19175 GDB prompt to see a list of commands in this category. 19176 19177 `COMMAND_STACK' 19178 The command has to do with manipulation of the stack. For example, 19179 `backtrace', `frame', and `return' are in this category. Type 19180 `help stack' at the GDB prompt to see a list of commands in this 19181 category. 19182 19183 `COMMAND_FILES' 19184 This class is used for file-related commands. For example, 19185 `file', `list' and `section' are in this category. Type `help 19186 files' at the GDB prompt to see a list of commands in this 19187 category. 19188 19189 `COMMAND_SUPPORT' 19190 This should be used for "support facilities", generally meaning 19191 things that are useful to the user when interacting with GDB, but 19192 not related to the state of the inferior. For example, `help', 19193 `make', and `shell' are in this category. Type `help support' at 19194 the GDB prompt to see a list of commands in this category. 19195 19196 `COMMAND_STATUS' 19197 The command is an `info'-related command, that is, related to the 19198 state of GDB itself. For example, `info', `macro', and `show' are 19199 in this category. Type `help status' at the GDB prompt to see a 19200 list of commands in this category. 19201 19202 `COMMAND_BREAKPOINTS' 19203 The command has to do with breakpoints. For example, `break', 19204 `clear', and `delete' are in this category. Type `help 19205 breakpoints' at the GDB prompt to see a list of commands in this 19206 category. 19207 19208 `COMMAND_TRACEPOINTS' 19209 The command has to do with tracepoints. For example, `trace', 19210 `actions', and `tfind' are in this category. Type `help 19211 tracepoints' at the GDB prompt to see a list of commands in this 19212 category. 19213 19214 `COMMAND_OBSCURE' 19215 The command is only used in unusual circumstances, or is not of 19216 general interest to users. For example, `checkpoint', `fork', and 19217 `stop' are in this category. Type `help obscure' at the GDB 19218 prompt to see a list of commands in this category. 19219 19220 `COMMAND_MAINTENANCE' 19221 The command is only useful to GDB maintainers. The `maintenance' 19222 and `flushregs' commands are in this category. Type `help 19223 internals' at the GDB prompt to see a list of commands in this 19224 category. 19225 19226 A new command can use a predefined completion function, either by 19227 specifying it via an argument at initialization, or by returning it 19228 from the `complete' method. These predefined completion constants are 19229 all defined in the `gdb' module: 19230 19231 `COMPLETE_NONE' 19232 This constant means that no completion should be done. 19233 19234 `COMPLETE_FILENAME' 19235 This constant means that filename completion should be performed. 19236 19237 `COMPLETE_LOCATION' 19238 This constant means that location completion should be done. 19239 *Note Specify Location::. 19240 19241 `COMPLETE_COMMAND' 19242 This constant means that completion should examine GDB command 19243 names. 19244 19245 `COMPLETE_SYMBOL' 19246 This constant means that completion should be done using symbol 19247 names as the source. 19248 19249 The following code snippet shows how a trivial CLI command can be 19250 implemented in Python: 19251 19252 class HelloWorld (gdb.Command): 19253 """Greet the whole world.""" 19254 19255 def __init__ (self): 19256 super (HelloWorld, self).__init__ ("hello-world", gdb.COMMAND_OBSCURE) 19257 19258 def invoke (self, arg, from_tty): 19259 print "Hello, World!" 19260 19261 HelloWorld () 19262 19263 The last line instantiates the class, and is necessary to trigger the 19264 registration of the command with GDB. Depending on how the Python code 19265 is read into GDB, you may need to import the `gdb' module explicitly. 19266 19267 19268 File: gdb.info, Node: Parameters In Python, Next: Functions In Python, Prev: Commands In Python, Up: Python API 19269 19270 23.2.2.12 Parameters In Python 19271 .............................. 19272 19273 You can implement new GDB parameters using Python. A new parameter is 19274 implemented as an instance of the `gdb.Parameter' class. 19275 19276 Parameters are exposed to the user via the `set' and `show' 19277 commands. *Note Help::. 19278 19279 There are many parameters that already exist and can be set in GDB. 19280 Two examples are: `set follow fork' and `set charset'. Setting these 19281 parameters influences certain behavior in GDB. Similarly, you can 19282 define parameters that can be used to influence behavior in custom 19283 Python scripts and commands. 19284 19285 -- Method on Parameter: __init__ name COMMAND-CLASS PARAMETER-CLASS 19286 [ENUM-SEQUENCE] 19287 The object initializer for `Parameter' registers the new parameter 19288 with GDB. This initializer is normally invoked from the subclass' 19289 own `__init__' method. 19290 19291 NAME is the name of the new parameter. If NAME consists of 19292 multiple words, then the initial words are looked for as prefix 19293 parameters. An example of this can be illustrated with the `set 19294 print' set of parameters. If NAME is `print foo', then `print' 19295 will be searched as the prefix parameter. In this case the 19296 parameter can subsequently be accessed in GDB as `set print foo'. 19297 19298 If NAME consists of multiple words, and no prefix parameter group 19299 can be found, an exception is raised. 19300 19301 COMMAND-CLASS should be one of the `COMMAND_' constants (*note 19302 Commands In Python::). This argument tells GDB how to categorize 19303 the new parameter in the help system. 19304 19305 PARAMETER-CLASS should be one of the `PARAM_' constants defined 19306 below. This argument tells GDB the type of the new parameter; 19307 this information is used for input validation and completion. 19308 19309 If PARAMETER-CLASS is `PARAM_ENUM', then ENUM-SEQUENCE must be a 19310 sequence of strings. These strings represent the possible values 19311 for the parameter. 19312 19313 If PARAMETER-CLASS is not `PARAM_ENUM', then the presence of a 19314 fourth argument will cause an exception to be thrown. 19315 19316 The help text for the new parameter is taken from the Python 19317 documentation string for the parameter's class, if there is one. 19318 If there is no documentation string, a default value is used. 19319 19320 -- Instance Variable of Parameter: set_doc 19321 If this attribute exists, and is a string, then its value is used 19322 as the help text for this parameter's `set' command. The value is 19323 examined when `Parameter.__init__' is invoked; subsequent changes 19324 have no effect. 19325 19326 -- Instance Variable of Parameter: show_doc 19327 If this attribute exists, and is a string, then its value is used 19328 as the help text for this parameter's `show' command. The value is 19329 examined when `Parameter.__init__' is invoked; subsequent changes 19330 have no effect. 19331 19332 -- Instance Variable of Parameter: value 19333 The `value' attribute holds the underlying value of the parameter. 19334 It can be read and assigned to just as any other attribute. GDB 19335 does validation when assignments are made. 19336 19337 There are two methods that should be implemented in any `Parameter' 19338 class. These are: 19339 19340 -- Operation on parameter: get_set_string self 19341 GDB will call this method when a PARAMETER's value has been 19342 changed via the `set' API (for example, `set foo off'). The 19343 `value' attribute has already been populated with the new value 19344 and may be used in output. This method must return a string. 19345 19346 -- Operation on parameter: get_show_string self svalue 19347 GDB will call this method when a PARAMETER's `show' API has been 19348 invoked (for example, `show foo'). The argument `svalue' receives 19349 the string representation of the current value. This method must 19350 return a string. 19351 19352 When a new parameter is defined, its type must be specified. The 19353 available types are represented by constants defined in the `gdb' 19354 module: 19355 19356 `PARAM_BOOLEAN' 19357 The value is a plain boolean. The Python boolean values, `True' 19358 and `False' are the only valid values. 19359 19360 `PARAM_AUTO_BOOLEAN' 19361 The value has three possible states: true, false, and `auto'. In 19362 Python, true and false are represented using boolean constants, and 19363 `auto' is represented using `None'. 19364 19365 `PARAM_UINTEGER' 19366 The value is an unsigned integer. The value of 0 should be 19367 interpreted to mean "unlimited". 19368 19369 `PARAM_INTEGER' 19370 The value is a signed integer. The value of 0 should be 19371 interpreted to mean "unlimited". 19372 19373 `PARAM_STRING' 19374 The value is a string. When the user modifies the string, any 19375 escape sequences, such as `\t', `\f', and octal escapes, are 19376 translated into corresponding characters and encoded into the 19377 current host charset. 19378 19379 `PARAM_STRING_NOESCAPE' 19380 The value is a string. When the user modifies the string, escapes 19381 are passed through untranslated. 19382 19383 `PARAM_OPTIONAL_FILENAME' 19384 The value is a either a filename (a string), or `None'. 19385 19386 `PARAM_FILENAME' 19387 The value is a filename. This is just like 19388 `PARAM_STRING_NOESCAPE', but uses file names for completion. 19389 19390 `PARAM_ZINTEGER' 19391 The value is an integer. This is like `PARAM_INTEGER', except 0 19392 is interpreted as itself. 19393 19394 `PARAM_ENUM' 19395 The value is a string, which must be one of a collection string 19396 constants provided when the parameter is created. 19397 19398 19399 File: gdb.info, Node: Functions In Python, Next: Progspaces In Python, Prev: Parameters In Python, Up: Python API 19400 19401 23.2.2.13 Writing new convenience functions 19402 ........................................... 19403 19404 You can implement new convenience functions (*note Convenience Vars::) 19405 in Python. A convenience function is an instance of a subclass of the 19406 class `gdb.Function'. 19407 19408 -- Method on Function: __init__ name 19409 The initializer for `Function' registers the new function with 19410 GDB. The argument NAME is the name of the function, a string. 19411 The function will be visible to the user as a convenience variable 19412 of type `internal function', whose name is the same as the given 19413 NAME. 19414 19415 The documentation for the new function is taken from the 19416 documentation string for the new class. 19417 19418 -- Method on Function: invoke *ARGS 19419 When a convenience function is evaluated, its arguments are 19420 converted to instances of `gdb.Value', and then the function's 19421 `invoke' method is called. Note that GDB does not predetermine 19422 the arity of convenience functions. Instead, all available 19423 arguments are passed to `invoke', following the standard Python 19424 calling convention. In particular, a convenience function can 19425 have default values for parameters without ill effect. 19426 19427 The return value of this method is used as its value in the 19428 enclosing expression. If an ordinary Python value is returned, it 19429 is converted to a `gdb.Value' following the usual rules. 19430 19431 The following code snippet shows how a trivial convenience function 19432 can be implemented in Python: 19433 19434 class Greet (gdb.Function): 19435 """Return string to greet someone. 19436 Takes a name as argument.""" 19437 19438 def __init__ (self): 19439 super (Greet, self).__init__ ("greet") 19440 19441 def invoke (self, name): 19442 return "Hello, %s!" % name.string () 19443 19444 Greet () 19445 19446 The last line instantiates the class, and is necessary to trigger the 19447 registration of the function with GDB. Depending on how the Python 19448 code is read into GDB, you may need to import the `gdb' module 19449 explicitly. 19450 19451 19452 File: gdb.info, Node: Progspaces In Python, Next: Objfiles In Python, Prev: Functions In Python, Up: Python API 19453 19454 23.2.2.14 Program Spaces In Python 19455 .................................. 19456 19457 A program space, or "progspace", represents a symbolic view of an 19458 address space. It consists of all of the objfiles of the program. 19459 *Note Objfiles In Python::. *Note program spaces: Inferiors and 19460 Programs, for more details about program spaces. 19461 19462 The following progspace-related functions are available in the `gdb' 19463 module: 19464 19465 -- Function: current_progspace 19466 This function returns the program space of the currently selected 19467 inferior. *Note Inferiors and Programs::. 19468 19469 -- Function: progspaces 19470 Return a sequence of all the progspaces currently known to GDB. 19471 19472 Each progspace is represented by an instance of the `gdb.Progspace' 19473 class. 19474 19475 -- Instance Variable of Progspace: filename 19476 The file name of the progspace as a string. 19477 19478 -- Instance Variable of Progspace: pretty_printers 19479 The `pretty_printers' attribute is a list of functions. It is 19480 used to look up pretty-printers. A `Value' is passed to each 19481 function in order; if the function returns `None', then the search 19482 continues. Otherwise, the return value should be an object which 19483 is used to format the value. *Note Pretty Printing API::, for more 19484 information. 19485 19486 19487 File: gdb.info, Node: Objfiles In Python, Next: Frames In Python, Prev: Progspaces In Python, Up: Python API 19488 19489 23.2.2.15 Objfiles In Python 19490 ............................ 19491 19492 GDB loads symbols for an inferior from various symbol-containing files 19493 (*note Files::). These include the primary executable file, any shared 19494 libraries used by the inferior, and any separate debug info files 19495 (*note Separate Debug Files::). GDB calls these symbol-containing 19496 files "objfiles". 19497 19498 The following objfile-related functions are available in the `gdb' 19499 module: 19500 19501 -- Function: current_objfile 19502 When auto-loading a Python script (*note Auto-loading::), GDB sets 19503 the "current objfile" to the corresponding objfile. This function 19504 returns the current objfile. If there is no current objfile, this 19505 function returns `None'. 19506 19507 -- Function: objfiles 19508 Return a sequence of all the objfiles current known to GDB. *Note 19509 Objfiles In Python::. 19510 19511 Each objfile is represented by an instance of the `gdb.Objfile' 19512 class. 19513 19514 -- Instance Variable of Objfile: filename 19515 The file name of the objfile as a string. 19516 19517 -- Instance Variable of Objfile: pretty_printers 19518 The `pretty_printers' attribute is a list of functions. It is 19519 used to look up pretty-printers. A `Value' is passed to each 19520 function in order; if the function returns `None', then the search 19521 continues. Otherwise, the return value should be an object which 19522 is used to format the value. *Note Pretty Printing API::, for more 19523 information. 19524 19525 A `gdb.Objfile' object has the following methods: 19526 19527 -- Method on Objfile: is_valid 19528 Returns `True' if the `gdb.Objfile' object is valid, `False' if 19529 not. A `gdb.Objfile' object can become invalid if the object file 19530 it refers to is not loaded in GDB any longer. All other 19531 `gdb.Objfile' methods will throw an exception if it is invalid at 19532 the time the method is called. 19533 19534 19535 File: gdb.info, Node: Frames In Python, Next: Blocks In Python, Prev: Objfiles In Python, Up: Python API 19536 19537 23.2.2.16 Accessing inferior stack frames from Python. 19538 ...................................................... 19539 19540 When the debugged program stops, GDB is able to analyze its call stack 19541 (*note Stack frames: Frames.). The `gdb.Frame' class represents a 19542 frame in the stack. A `gdb.Frame' object is only valid while its 19543 corresponding frame exists in the inferior's stack. If you try to use 19544 an invalid frame object, GDB will throw a `gdb.error' exception (*note 19545 Exception Handling::). 19546 19547 Two `gdb.Frame' objects can be compared for equality with the `==' 19548 operator, like: 19549 19550 (gdb) python print gdb.newest_frame() == gdb.selected_frame () 19551 True 19552 19553 The following frame-related functions are available in the `gdb' 19554 module: 19555 19556 -- Function: selected_frame 19557 Return the selected frame object. (*note Selecting a Frame: 19558 Selection.). 19559 19560 -- Function: newest_frame 19561 Return the newest frame object for the selected thread. 19562 19563 -- Function: frame_stop_reason_string reason 19564 Return a string explaining the reason why GDB stopped unwinding 19565 frames, as expressed by the given REASON code (an integer, see the 19566 `unwind_stop_reason' method further down in this section). 19567 19568 A `gdb.Frame' object has the following methods: 19569 19570 -- Method on Frame: is_valid 19571 Returns true if the `gdb.Frame' object is valid, false if not. 19572 A frame object can become invalid if the frame it refers to 19573 doesn't exist anymore in the inferior. All `gdb.Frame' 19574 methods will throw an exception if it is invalid at the time 19575 the method is called. 19576 19577 -- Method on Frame: name 19578 Returns the function name of the frame, or `None' if it can't 19579 be obtained. 19580 19581 -- Method on Frame: type 19582 Returns the type of the frame. The value can be one of: 19583 `gdb.NORMAL_FRAME' 19584 An ordinary stack frame. 19585 19586 `gdb.DUMMY_FRAME' 19587 A fake stack frame that was created by GDB when 19588 performing an inferior function call. 19589 19590 `gdb.INLINE_FRAME' 19591 A frame representing an inlined function. The function 19592 was inlined into a `gdb.NORMAL_FRAME' that is older than 19593 this one. 19594 19595 `gdb.SIGTRAMP_FRAME' 19596 A signal trampoline frame. This is the frame created by 19597 the OS when it calls into a signal handler. 19598 19599 `gdb.ARCH_FRAME' 19600 A fake stack frame representing a cross-architecture 19601 call. 19602 19603 `gdb.SENTINEL_FRAME' 19604 This is like `gdb.NORMAL_FRAME', but it is only used for 19605 the newest frame. 19606 19607 -- Method on Frame: unwind_stop_reason 19608 Return an integer representing the reason why it's not 19609 possible to find more frames toward the outermost frame. Use 19610 `gdb.frame_stop_reason_string' to convert the value returned 19611 by this function to a string. 19612 19613 -- Method on Frame: pc 19614 Returns the frame's resume address. 19615 19616 -- Method on Frame: block 19617 Return the frame's code block. *Note Blocks In Python::. 19618 19619 -- Method on Frame: function 19620 Return the symbol for the function corresponding to this 19621 frame. *Note Symbols In Python::. 19622 19623 -- Method on Frame: older 19624 Return the frame that called this frame. 19625 19626 -- Method on Frame: newer 19627 Return the frame called by this frame. 19628 19629 -- Method on Frame: find_sal 19630 Return the frame's symtab and line object. *Note Symbol 19631 Tables In Python::. 19632 19633 -- Method on Frame: read_var variable [block] 19634 Return the value of VARIABLE in this frame. If the optional 19635 argument BLOCK is provided, search for the variable from that 19636 block; otherwise start at the frame's current block (which is 19637 determined by the frame's current program counter). VARIABLE 19638 must be a string or a `gdb.Symbol' object. BLOCK must be a 19639 `gdb.Block' object. 19640 19641 -- Method on Frame: select 19642 Set this frame to be the selected frame. *Note Examining the 19643 Stack: Stack. 19644 19645 19646 File: gdb.info, Node: Blocks In Python, Next: Symbols In Python, Prev: Frames In Python, Up: Python API 19647 19648 23.2.2.17 Accessing frame blocks from Python. 19649 ............................................. 19650 19651 Within each frame, GDB maintains information on each block stored in 19652 that frame. These blocks are organized hierarchically, and are 19653 represented individually in Python as a `gdb.Block'. Please see *note 19654 Frames In Python::, for a more in-depth discussion on frames. 19655 Furthermore, see *note Examining the Stack: Stack, for more detailed 19656 technical information on GDB's book-keeping of the stack. 19657 19658 The following block-related functions are available in the `gdb' 19659 module: 19660 19661 -- Function: block_for_pc pc 19662 Return the `gdb.Block' containing the given PC value. If the 19663 block cannot be found for the PC value specified, the function 19664 will return `None'. 19665 19666 A `gdb.Block' object has the following methods: 19667 19668 -- Method on Block: is_valid 19669 Returns `True' if the `gdb.Block' object is valid, `False' if 19670 not. A block object can become invalid if the block it 19671 refers to doesn't exist anymore in the inferior. All other 19672 `gdb.Block' methods will throw an exception if it is invalid 19673 at the time the method is called. This method is also made 19674 available to the Python iterator object that `gdb.Block' 19675 provides in an iteration context and via the Python `iter' 19676 built-in function. 19677 19678 A `gdb.Block' object has the following attributes: 19679 19680 -- Instance Variable of Block: start 19681 The start address of the block. This attribute is not 19682 writable. 19683 19684 -- Instance Variable of Block: end 19685 The end address of the block. This attribute is not writable. 19686 19687 -- Instance Variable of Block: function 19688 The name of the block represented as a `gdb.Symbol'. If the 19689 block is not named, then this attribute holds `None'. This 19690 attribute is not writable. 19691 19692 -- Instance Variable of Block: superblock 19693 The block containing this block. If this parent block does 19694 not exist, this attribute holds `None'. This attribute is 19695 not writable. 19696 19697 19698 File: gdb.info, Node: Symbols In Python, Next: Symbol Tables In Python, Prev: Blocks In Python, Up: Python API 19699 19700 23.2.2.18 Python representation of Symbols. 19701 ........................................... 19702 19703 GDB represents every variable, function and type as an entry in a 19704 symbol table. *Note Examining the Symbol Table: Symbols. Similarly, 19705 Python represents these symbols in GDB with the `gdb.Symbol' object. 19706 19707 The following symbol-related functions are available in the `gdb' 19708 module: 19709 19710 -- Function: lookup_symbol name [block] [domain] 19711 This function searches for a symbol by name. The search scope can 19712 be restricted to the parameters defined in the optional domain and 19713 block arguments. 19714 19715 NAME is the name of the symbol. It must be a string. The 19716 optional BLOCK argument restricts the search to symbols visible in 19717 that BLOCK. The BLOCK argument must be a `gdb.Block' object. If 19718 omitted, the block for the current frame is used. The optional 19719 DOMAIN argument restricts the search to the domain type. The 19720 DOMAIN argument must be a domain constant defined in the `gdb' 19721 module and described later in this chapter. 19722 19723 The result is a tuple of two elements. The first element is a 19724 `gdb.Symbol' object or `None' if the symbol is not found. If the 19725 symbol is found, the second element is `True' if the symbol is a 19726 field of a method's object (e.g., `this' in C++), otherwise it is 19727 `False'. If the symbol is not found, the second element is 19728 `False'. 19729 19730 -- Function: lookup_global_symbol name [domain] 19731 This function searches for a global symbol by name. The search 19732 scope can be restricted to by the domain argument. 19733 19734 NAME is the name of the symbol. It must be a string. The 19735 optional DOMAIN argument restricts the search to the domain type. 19736 The DOMAIN argument must be a domain constant defined in the `gdb' 19737 module and described later in this chapter. 19738 19739 The result is a `gdb.Symbol' object or `None' if the symbol is not 19740 found. 19741 19742 A `gdb.Symbol' object has the following attributes: 19743 19744 -- Instance Variable of Symbol: type 19745 The type of the symbol or `None' if no type is recorded. 19746 This attribute is represented as a `gdb.Type' object. *Note 19747 Types In Python::. This attribute is not writable. 19748 19749 -- Instance Variable of Symbol: symtab 19750 The symbol table in which the symbol appears. This attribute 19751 is represented as a `gdb.Symtab' object. *Note Symbol Tables 19752 In Python::. This attribute is not writable. 19753 19754 -- Instance Variable of Symbol: name 19755 The name of the symbol as a string. This attribute is not 19756 writable. 19757 19758 -- Instance Variable of Symbol: linkage_name 19759 The name of the symbol, as used by the linker (i.e., may be 19760 mangled). This attribute is not writable. 19761 19762 -- Instance Variable of Symbol: print_name 19763 The name of the symbol in a form suitable for output. This 19764 is either `name' or `linkage_name', depending on whether the 19765 user asked GDB to display demangled or mangled names. 19766 19767 -- Instance Variable of Symbol: addr_class 19768 The address class of the symbol. This classifies how to find 19769 the value of a symbol. Each address class is a constant 19770 defined in the `gdb' module and described later in this 19771 chapter. 19772 19773 -- Instance Variable of Symbol: is_argument 19774 `True' if the symbol is an argument of a function. 19775 19776 -- Instance Variable of Symbol: is_constant 19777 `True' if the symbol is a constant. 19778 19779 -- Instance Variable of Symbol: is_function 19780 `True' if the symbol is a function or a method. 19781 19782 -- Instance Variable of Symbol: is_variable 19783 `True' if the symbol is a variable. 19784 19785 A `gdb.Symbol' object has the following methods: 19786 19787 -- Method on Symbol: is_valid 19788 Returns `True' if the `gdb.Symbol' object is valid, `False' 19789 if not. A `gdb.Symbol' object can become invalid if the 19790 symbol it refers to does not exist in GDB any longer. All 19791 other `gdb.Symbol' methods will throw an exception if it is 19792 invalid at the time the method is called. 19793 19794 The available domain categories in `gdb.Symbol' are represented as 19795 constants in the `gdb' module: 19796 19797 `SYMBOL_UNDEF_DOMAIN' 19798 This is used when a domain has not been discovered or none of the 19799 following domains apply. This usually indicates an error either 19800 in the symbol information or in GDB's handling of symbols. 19801 19802 `SYMBOL_VAR_DOMAIN' 19803 This domain contains variables, function names, typedef names and 19804 enum type values. 19805 19806 `SYMBOL_STRUCT_DOMAIN' 19807 This domain holds struct, union and enum type names. 19808 19809 `SYMBOL_LABEL_DOMAIN' 19810 This domain contains names of labels (for gotos). 19811 19812 `SYMBOL_VARIABLES_DOMAIN' 19813 This domain holds a subset of the `SYMBOLS_VAR_DOMAIN'; it 19814 contains everything minus functions and types. 19815 19816 `SYMBOL_FUNCTION_DOMAIN' 19817 This domain contains all functions. 19818 19819 `SYMBOL_TYPES_DOMAIN' 19820 This domain contains all types. 19821 19822 The available address class categories in `gdb.Symbol' are 19823 represented as constants in the `gdb' module: 19824 19825 `SYMBOL_LOC_UNDEF' 19826 If this is returned by address class, it indicates an error either 19827 in the symbol information or in GDB's handling of symbols. 19828 19829 `SYMBOL_LOC_CONST' 19830 Value is constant int. 19831 19832 `SYMBOL_LOC_STATIC' 19833 Value is at a fixed address. 19834 19835 `SYMBOL_LOC_REGISTER' 19836 Value is in a register. 19837 19838 `SYMBOL_LOC_ARG' 19839 Value is an argument. This value is at the offset stored within 19840 the symbol inside the frame's argument list. 19841 19842 `SYMBOL_LOC_REF_ARG' 19843 Value address is stored in the frame's argument list. Just like 19844 `LOC_ARG' except that the value's address is stored at the offset, 19845 not the value itself. 19846 19847 `SYMBOL_LOC_REGPARM_ADDR' 19848 Value is a specified register. Just like `LOC_REGISTER' except 19849 the register holds the address of the argument instead of the 19850 argument itself. 19851 19852 `SYMBOL_LOC_LOCAL' 19853 Value is a local variable. 19854 19855 `SYMBOL_LOC_TYPEDEF' 19856 Value not used. Symbols in the domain `SYMBOL_STRUCT_DOMAIN' all 19857 have this class. 19858 19859 `SYMBOL_LOC_BLOCK' 19860 Value is a block. 19861 19862 `SYMBOL_LOC_CONST_BYTES' 19863 Value is a byte-sequence. 19864 19865 `SYMBOL_LOC_UNRESOLVED' 19866 Value is at a fixed address, but the address of the variable has 19867 to be determined from the minimal symbol table whenever the 19868 variable is referenced. 19869 19870 `SYMBOL_LOC_OPTIMIZED_OUT' 19871 The value does not actually exist in the program. 19872 19873 `SYMBOL_LOC_COMPUTED' 19874 The value's address is a computed location. 19875 19876 19877 File: gdb.info, Node: Symbol Tables In Python, Next: Lazy Strings In Python, Prev: Symbols In Python, Up: Python API 19878 19879 23.2.2.19 Symbol table representation in Python. 19880 ................................................ 19881 19882 Access to symbol table data maintained by GDB on the inferior is 19883 exposed to Python via two objects: `gdb.Symtab_and_line' and 19884 `gdb.Symtab'. Symbol table and line data for a frame is returned from 19885 the `find_sal' method in `gdb.Frame' object. *Note Frames In Python::. 19886 19887 For more information on GDB's symbol table management, see *note 19888 Examining the Symbol Table: Symbols, for more information. 19889 19890 A `gdb.Symtab_and_line' object has the following attributes: 19891 19892 -- Instance Variable of Symtab_and_line: symtab 19893 The symbol table object (`gdb.Symtab') for this frame. This 19894 attribute is not writable. 19895 19896 -- Instance Variable of Symtab_and_line: pc 19897 Indicates the current program counter address. This 19898 attribute is not writable. 19899 19900 -- Instance Variable of Symtab_and_line: line 19901 Indicates the current line number for this object. This 19902 attribute is not writable. 19903 19904 A `gdb.Symtab_and_line' object has the following methods: 19905 19906 -- Method on Symtab_and_line: is_valid 19907 Returns `True' if the `gdb.Symtab_and_line' object is valid, 19908 `False' if not. A `gdb.Symtab_and_line' object can become 19909 invalid if the Symbol table and line object it refers to does 19910 not exist in GDB any longer. All other `gdb.Symtab_and_line' 19911 methods will throw an exception if it is invalid at the time 19912 the method is called. 19913 19914 A `gdb.Symtab' object has the following attributes: 19915 19916 -- Instance Variable of Symtab: filename 19917 The symbol table's source filename. This attribute is not 19918 writable. 19919 19920 -- Instance Variable of Symtab: objfile 19921 The symbol table's backing object file. *Note Objfiles In 19922 Python::. This attribute is not writable. 19923 19924 A `gdb.Symtab' object has the following methods: 19925 19926 -- Method on Symtab: is_valid 19927 Returns `True' if the `gdb.Symtab' object is valid, `False' 19928 if not. A `gdb.Symtab' object can become invalid if the 19929 symbol table it refers to does not exist in GDB any longer. 19930 All other `gdb.Symtab' methods will throw an exception if it 19931 is invalid at the time the method is called. 19932 19933 -- Method on Symtab: fullname 19934 Return the symbol table's source absolute file name. 19935 19936 19937 File: gdb.info, Node: Breakpoints In Python, Prev: Lazy Strings In Python, Up: Python API 19938 19939 23.2.2.20 Manipulating breakpoints using Python 19940 ............................................... 19941 19942 Python code can manipulate breakpoints via the `gdb.Breakpoint' class. 19943 19944 -- Method on Breakpoint: __init__ spec [type] [wp_class] [internal] 19945 Create a new breakpoint. SPEC is a string naming the location of 19946 the breakpoint, or an expression that defines a watchpoint. The 19947 contents can be any location recognized by the `break' command, or 19948 in the case of a watchpoint, by the `watch' command. The optional 19949 TYPE denotes the breakpoint to create from the types defined later 19950 in this chapter. This argument can be either: `BP_BREAKPOINT' or 19951 `BP_WATCHPOINT'. TYPE defaults to `BP_BREAKPOINT'. The optional 19952 INTERNAL argument allows the breakpoint to become invisible to the 19953 user. The breakpoint will neither be reported when created, nor 19954 will it be listed in the output from `info breakpoints' (but will 19955 be listed with the `maint info breakpoints' command). The 19956 optional WP_CLASS argument defines the class of watchpoint to 19957 create, if TYPE is `BP_WATCHPOINT'. If a watchpoint class is not 19958 provided, it is assumed to be a WP_WRITE class. 19959 19960 -- Operation on gdb.Breakpoint: stop (self) 19961 The `gdb.Breakpoint' class can be sub-classed and, in particular, 19962 you may choose to implement the `stop' method. If this method is 19963 defined as a sub-class of `gdb.Breakpoint', it will be called when 19964 the inferior reaches any location of a breakpoint which 19965 instantiates that sub-class. If the method returns `True', the 19966 inferior will be stopped at the location of the breakpoint, 19967 otherwise the inferior will continue. 19968 19969 If there are multiple breakpoints at the same location with a 19970 `stop' method, each one will be called regardless of the return 19971 status of the previous. This ensures that all `stop' methods have 19972 a chance to execute at that location. In this scenario if one of 19973 the methods returns `True' but the others return `False', the 19974 inferior will still be stopped. 19975 19976 Example `stop' implementation: 19977 19978 class MyBreakpoint (gdb.Breakpoint): 19979 def stop (self): 19980 inf_val = gdb.parse_and_eval("foo") 19981 if inf_val == 3: 19982 return True 19983 return False 19984 19985 The available watchpoint types represented by constants are defined 19986 in the `gdb' module: 19987 19988 `WP_READ' 19989 Read only watchpoint. 19990 19991 `WP_WRITE' 19992 Write only watchpoint. 19993 19994 `WP_ACCESS' 19995 Read/Write watchpoint. 19996 19997 -- Method on Breakpoint: is_valid 19998 Return `True' if this `Breakpoint' object is valid, `False' 19999 otherwise. A `Breakpoint' object can become invalid if the user 20000 deletes the breakpoint. In this case, the object still exists, 20001 but the underlying breakpoint does not. In the cases of 20002 watchpoint scope, the watchpoint remains valid even if execution 20003 of the inferior leaves the scope of that watchpoint. 20004 20005 -- Method on Breakpoint: delete 20006 Permanently deletes the GDB breakpoint. This also invalidates the 20007 Python `Breakpoint' object. Any further access to this object's 20008 attributes or methods will raise an error. 20009 20010 -- Instance Variable of Breakpoint: enabled 20011 This attribute is `True' if the breakpoint is enabled, and `False' 20012 otherwise. This attribute is writable. 20013 20014 -- Instance Variable of Breakpoint: silent 20015 This attribute is `True' if the breakpoint is silent, and `False' 20016 otherwise. This attribute is writable. 20017 20018 Note that a breakpoint can also be silent if it has commands and 20019 the first command is `silent'. This is not reported by the 20020 `silent' attribute. 20021 20022 -- Instance Variable of Breakpoint: thread 20023 If the breakpoint is thread-specific, this attribute holds the 20024 thread id. If the breakpoint is not thread-specific, this 20025 attribute is `None'. This attribute is writable. 20026 20027 -- Instance Variable of Breakpoint: task 20028 If the breakpoint is Ada task-specific, this attribute holds the 20029 Ada task id. If the breakpoint is not task-specific (or the 20030 underlying language is not Ada), this attribute is `None'. This 20031 attribute is writable. 20032 20033 -- Instance Variable of Breakpoint: ignore_count 20034 This attribute holds the ignore count for the breakpoint, an 20035 integer. This attribute is writable. 20036 20037 -- Instance Variable of Breakpoint: number 20038 This attribute holds the breakpoint's number -- the identifier 20039 used by the user to manipulate the breakpoint. This attribute is 20040 not writable. 20041 20042 -- Instance Variable of Breakpoint: type 20043 This attribute holds the breakpoint's type -- the identifier used 20044 to determine the actual breakpoint type or use-case. This 20045 attribute is not writable. 20046 20047 -- Instance Variable of Breakpoint: visible 20048 This attribute tells whether the breakpoint is visible to the user 20049 when set, or when the `info breakpoints' command is run. This 20050 attribute is not writable. 20051 20052 The available types are represented by constants defined in the `gdb' 20053 module: 20054 20055 `BP_BREAKPOINT' 20056 Normal code breakpoint. 20057 20058 `BP_WATCHPOINT' 20059 Watchpoint breakpoint. 20060 20061 `BP_HARDWARE_WATCHPOINT' 20062 Hardware assisted watchpoint. 20063 20064 `BP_READ_WATCHPOINT' 20065 Hardware assisted read watchpoint. 20066 20067 `BP_ACCESS_WATCHPOINT' 20068 Hardware assisted access watchpoint. 20069 20070 -- Instance Variable of Breakpoint: hit_count 20071 This attribute holds the hit count for the breakpoint, an integer. 20072 This attribute is writable, but currently it can only be set to 20073 zero. 20074 20075 -- Instance Variable of Breakpoint: location 20076 This attribute holds the location of the breakpoint, as specified 20077 by the user. It is a string. If the breakpoint does not have a 20078 location (that is, it is a watchpoint) the attribute's value is 20079 `None'. This attribute is not writable. 20080 20081 -- Instance Variable of Breakpoint: expression 20082 This attribute holds a breakpoint expression, as specified by the 20083 user. It is a string. If the breakpoint does not have an 20084 expression (the breakpoint is not a watchpoint) the attribute's 20085 value is `None'. This attribute is not writable. 20086 20087 -- Instance Variable of Breakpoint: condition 20088 This attribute holds the condition of the breakpoint, as specified 20089 by the user. It is a string. If there is no condition, this 20090 attribute's value is `None'. This attribute is writable. 20091 20092 -- Instance Variable of Breakpoint: commands 20093 This attribute holds the commands attached to the breakpoint. If 20094 there are commands, this attribute's value is a string holding all 20095 the commands, separated by newlines. If there are no commands, 20096 this attribute is `None'. This attribute is not writable. 20097 20098 20099 File: gdb.info, Node: Lazy Strings In Python, Next: Breakpoints In Python, Prev: Symbol Tables In Python, Up: Python API 20100 20101 23.2.2.21 Python representation of lazy strings. 20102 ................................................ 20103 20104 A "lazy string" is a string whose contents is not retrieved or encoded 20105 until it is needed. 20106 20107 A `gdb.LazyString' is represented in GDB as an `address' that points 20108 to a region of memory, an `encoding' that will be used to encode that 20109 region of memory, and a `length' to delimit the region of memory that 20110 represents the string. The difference between a `gdb.LazyString' and a 20111 string wrapped within a `gdb.Value' is that a `gdb.LazyString' will be 20112 treated differently by GDB when printing. A `gdb.LazyString' is 20113 retrieved and encoded during printing, while a `gdb.Value' wrapping a 20114 string is immediately retrieved and encoded on creation. 20115 20116 A `gdb.LazyString' object has the following functions: 20117 20118 -- Method on LazyString: value 20119 Convert the `gdb.LazyString' to a `gdb.Value'. This value will 20120 point to the string in memory, but will lose all the delayed 20121 retrieval, encoding and handling that GDB applies to a 20122 `gdb.LazyString'. 20123 20124 -- Instance Variable of LazyString: address 20125 This attribute holds the address of the string. This attribute is 20126 not writable. 20127 20128 -- Instance Variable of LazyString: length 20129 This attribute holds the length of the string in characters. If 20130 the length is -1, then the string will be fetched and encoded up 20131 to the first null of appropriate width. This attribute is not 20132 writable. 20133 20134 -- Instance Variable of LazyString: encoding 20135 This attribute holds the encoding that will be applied to the 20136 string when the string is printed by GDB. If the encoding is not 20137 set, or contains an empty string, then GDB will select the most 20138 appropriate encoding when the string is printed. This attribute 20139 is not writable. 20140 20141 -- Instance Variable of LazyString: type 20142 This attribute holds the type that is represented by the lazy 20143 string's type. For a lazy string this will always be a pointer 20144 type. To resolve this to the lazy string's character type, use 20145 the type's `target' method. *Note Types In Python::. This 20146 attribute is not writable. 20147 20148 20149 File: gdb.info, Node: Auto-loading, Next: Python modules, Prev: Python API, Up: Python 20150 20151 23.2.3 Auto-loading 20152 ------------------- 20153 20154 When a new object file is read (for example, due to the `file' command, 20155 or because the inferior has loaded a shared library), GDB will look for 20156 Python support scripts in several ways: `OBJFILE-gdb.py' and 20157 `.debug_gdb_scripts' section. 20158 20159 * Menu: 20160 20161 * objfile-gdb.py file:: The `OBJFILE-gdb.py' file 20162 * .debug_gdb_scripts section:: The `.debug_gdb_scripts' section 20163 * Which flavor to choose?:: 20164 20165 The auto-loading feature is useful for supplying application-specific 20166 debugging commands and scripts. 20167 20168 Auto-loading can be enabled or disabled, and the list of auto-loaded 20169 scripts can be printed. 20170 20171 `set auto-load-scripts [yes|no]' 20172 Enable or disable the auto-loading of Python scripts. 20173 20174 `show auto-load-scripts' 20175 Show whether auto-loading of Python scripts is enabled or disabled. 20176 20177 `info auto-load-scripts [REGEXP]' 20178 Print the list of all scripts that GDB auto-loaded. 20179 20180 Also printed is the list of scripts that were mentioned in the 20181 `.debug_gdb_scripts' section and were not found (*note 20182 .debug_gdb_scripts section::). This is useful because their names 20183 are not printed when GDB tries to load them and fails. There may 20184 be many of them, and printing an error message for each one is 20185 problematic. 20186 20187 If REGEXP is supplied only scripts with matching names are printed. 20188 20189 Example: 20190 20191 (gdb) info auto-load-scripts 20192 Loaded Script 20193 Yes py-section-script.py 20194 full name: /tmp/py-section-script.py 20195 Missing my-foo-pretty-printers.py 20196 20197 When reading an auto-loaded file, GDB sets the "current objfile". 20198 This is available via the `gdb.current_objfile' function (*note 20199 Objfiles In Python::). This can be useful for registering 20200 objfile-specific pretty-printers. 20201 20202 20203 File: gdb.info, Node: objfile-gdb.py file, Next: .debug_gdb_scripts section, Up: Auto-loading 20204 20205 23.2.3.1 The `OBJFILE-gdb.py' file 20206 .................................. 20207 20208 When a new object file is read, GDB looks for a file named 20209 `OBJFILE-gdb.py', where OBJFILE is the object file's real name, formed 20210 by ensuring that the file name is absolute, following all symlinks, and 20211 resolving `.' and `..' components. If this file exists and is 20212 readable, GDB will evaluate it as a Python script. 20213 20214 If this file does not exist, and if the parameter 20215 `debug-file-directory' is set (*note Separate Debug Files::), then GDB 20216 will look for REAL-NAME in all of the directories mentioned in the 20217 value of `debug-file-directory'. 20218 20219 Finally, if this file does not exist, then GDB will look for a file 20220 named `DATA-DIRECTORY/python/auto-load/REAL-NAME', where DATA-DIRECTORY 20221 is GDB's data directory (available via `show data-directory', *note 20222 Data Files::), and REAL-NAME is the object file's real name, as 20223 described above. 20224 20225 GDB does not track which files it has already auto-loaded this way. 20226 GDB will load the associated script every time the corresponding 20227 OBJFILE is opened. So your `-gdb.py' file should be careful to avoid 20228 errors if it is evaluated more than once. 20229 20230 20231 File: gdb.info, Node: .debug_gdb_scripts section, Next: Which flavor to choose?, Prev: objfile-gdb.py file, Up: Auto-loading 20232 20233 23.2.3.2 The `.debug_gdb_scripts' section 20234 ......................................... 20235 20236 For systems using file formats like ELF and COFF, when GDB loads a new 20237 object file it will look for a special section named 20238 `.debug_gdb_scripts'. If this section exists, its contents is a list 20239 of names of scripts to load. 20240 20241 GDB will look for each specified script file first in the current 20242 directory and then along the source search path (*note Specifying 20243 Source Directories: Source Path.), except that `$cdir' is not searched, 20244 since the compilation directory is not relevant to scripts. 20245 20246 Entries can be placed in section `.debug_gdb_scripts' with, for 20247 example, this GCC macro: 20248 20249 /* Note: The "MS" section flags are to remove duplicates. */ 20250 #define DEFINE_GDB_SCRIPT(script_name) \ 20251 asm("\ 20252 .pushsection \".debug_gdb_scripts\", \"MS\",@progbits,1\n\ 20253 .byte 1\n\ 20254 .asciz \"" script_name "\"\n\ 20255 .popsection \n\ 20256 "); 20257 20258 Then one can reference the macro in a header or source file like this: 20259 20260 DEFINE_GDB_SCRIPT ("my-app-scripts.py") 20261 20262 The script name may include directories if desired. 20263 20264 If the macro is put in a header, any application or library using 20265 this header will get a reference to the specified script. 20266 20267 20268 File: gdb.info, Node: Which flavor to choose?, Prev: .debug_gdb_scripts section, Up: Auto-loading 20269 20270 23.2.3.3 Which flavor to choose? 20271 ................................ 20272 20273 Given the multiple ways of auto-loading Python scripts, it might not 20274 always be clear which one to choose. This section provides some 20275 guidance. 20276 20277 Benefits of the `-gdb.py' way: 20278 20279 * Can be used with file formats that don't support multiple sections. 20280 20281 * Ease of finding scripts for public libraries. 20282 20283 Scripts specified in the `.debug_gdb_scripts' section are searched 20284 for in the source search path. For publicly installed libraries, 20285 e.g., `libstdc++', there typically isn't a source directory in 20286 which to find the script. 20287 20288 * Doesn't require source code additions. 20289 20290 Benefits of the `.debug_gdb_scripts' way: 20291 20292 * Works with static linking. 20293 20294 Scripts for libraries done the `-gdb.py' way require an objfile to 20295 trigger their loading. When an application is statically linked 20296 the only objfile available is the executable, and it is cumbersome 20297 to attach all the scripts from all the input libraries to the 20298 executable's `-gdb.py' script. 20299 20300 * Works with classes that are entirely inlined. 20301 20302 Some classes can be entirely inlined, and thus there may not be an 20303 associated shared library to attach a `-gdb.py' script to. 20304 20305 * Scripts needn't be copied out of the source tree. 20306 20307 In some circumstances, apps can be built out of large collections 20308 of internal libraries, and the build infrastructure necessary to 20309 install the `-gdb.py' scripts in a place where GDB can find them is 20310 cumbersome. It may be easier to specify the scripts in the 20311 `.debug_gdb_scripts' section as relative paths, and add a path to 20312 the top of the source tree to the source search path. 20313 20314 20315 File: gdb.info, Node: Python modules, Prev: Auto-loading, Up: Python 20316 20317 23.2.4 Python modules 20318 --------------------- 20319 20320 GDB comes with a module to assist writing Python code. 20321 20322 * Menu: 20323 20324 * gdb.printing:: Building and registering pretty-printers. 20325 * gdb.types:: Utilities for working with types. 20326 20327 20328 File: gdb.info, Node: gdb.printing, Next: gdb.types, Up: Python modules 20329 20330 23.2.4.1 gdb.printing 20331 ..................... 20332 20333 This module provides a collection of utilities for working with 20334 pretty-printers. 20335 20336 `PrettyPrinter (NAME, SUBPRINTERS=None)' 20337 This class specifies the API that makes `info pretty-printer', 20338 `enable pretty-printer' and `disable pretty-printer' work. 20339 Pretty-printers should generally inherit from this class. 20340 20341 `SubPrettyPrinter (NAME)' 20342 For printers that handle multiple types, this class specifies the 20343 corresponding API for the subprinters. 20344 20345 `RegexpCollectionPrettyPrinter (NAME)' 20346 Utility class for handling multiple printers, all recognized via 20347 regular expressions. *Note Writing a Pretty-Printer::, for an 20348 example. 20349 20350 `register_pretty_printer (OBJ, PRINTER, REPLACE=False)' 20351 Register PRINTER with the pretty-printer list of OBJ. If REPLACE 20352 is `True' then any existing copy of the printer is replaced. 20353 Otherwise a `RuntimeError' exception is raised if a printer with 20354 the same name already exists. 20355 20356 20357 File: gdb.info, Node: gdb.types, Prev: gdb.printing, Up: Python modules 20358 20359 23.2.4.2 gdb.types 20360 .................. 20361 20362 This module provides a collection of utilities for working with 20363 `gdb.Types' objects. 20364 20365 `get_basic_type (TYPE)' 20366 Return TYPE with const and volatile qualifiers stripped, and with 20367 typedefs and C++ references converted to the underlying type. 20368 20369 C++ example: 20370 20371 typedef const int const_int; 20372 const_int foo (3); 20373 const_int& foo_ref (foo); 20374 int main () { return 0; } 20375 20376 Then in gdb: 20377 20378 (gdb) start 20379 (gdb) python import gdb.types 20380 (gdb) python foo_ref = gdb.parse_and_eval("foo_ref") 20381 (gdb) python print gdb.types.get_basic_type(foo_ref.type) 20382 int 20383 20384 `has_field (TYPE, FIELD)' 20385 Return `True' if TYPE, assumed to be a type with fields (e.g., a 20386 structure or union), has field FIELD. 20387 20388 `make_enum_dict (ENUM_TYPE)' 20389 Return a Python `dictionary' type produced from ENUM_TYPE. 20390 20391 20392 File: gdb.info, Node: Interpreters, Next: TUI, Prev: Extending GDB, Up: Top 20393 20394 24 Command Interpreters 20395 *********************** 20396 20397 GDB supports multiple command interpreters, and some command 20398 infrastructure to allow users or user interface writers to switch 20399 between interpreters or run commands in other interpreters. 20400 20401 GDB currently supports two command interpreters, the console 20402 interpreter (sometimes called the command-line interpreter or CLI) and 20403 the machine interface interpreter (or GDB/MI). This manual describes 20404 both of these interfaces in great detail. 20405 20406 By default, GDB will start with the console interpreter. However, 20407 the user may choose to start GDB with another interpreter by specifying 20408 the `-i' or `--interpreter' startup options. Defined interpreters 20409 include: 20410 20411 `console' 20412 The traditional console or command-line interpreter. This is the 20413 most often used interpreter with GDB. With no interpreter 20414 specified at runtime, GDB will use this interpreter. 20415 20416 `mi' 20417 The newest GDB/MI interface (currently `mi2'). Used primarily by 20418 programs wishing to use GDB as a backend for a debugger GUI or an 20419 IDE. For more information, see *note The GDB/MI Interface: GDB/MI. 20420 20421 `mi2' 20422 The current GDB/MI interface. 20423 20424 `mi1' 20425 The GDB/MI interface included in GDB 5.1, 5.2, and 5.3. 20426 20427 20428 The interpreter being used by GDB may not be dynamically switched at 20429 runtime. Although possible, this could lead to a very precarious 20430 situation. Consider an IDE using GDB/MI. If a user enters the command 20431 "interpreter-set console" in a console view, GDB would switch to using 20432 the console interpreter, rendering the IDE inoperable! 20433 20434 Although you may only choose a single interpreter at startup, you 20435 may execute commands in any interpreter from the current interpreter 20436 using the appropriate command. If you are running the console 20437 interpreter, simply use the `interpreter-exec' command: 20438 20439 interpreter-exec mi "-data-list-register-names" 20440 20441 GDB/MI has a similar command, although it is only available in 20442 versions of GDB which support GDB/MI version 2 (or greater). 20443 20444 20445 File: gdb.info, Node: TUI, Next: Emacs, Prev: Interpreters, Up: Top 20446 20447 25 GDB Text User Interface 20448 ************************** 20449 20450 * Menu: 20451 20452 * TUI Overview:: TUI overview 20453 * TUI Keys:: TUI key bindings 20454 * TUI Single Key Mode:: TUI single key mode 20455 * TUI Commands:: TUI-specific commands 20456 * TUI Configuration:: TUI configuration variables 20457 20458 The GDB Text User Interface (TUI) is a terminal interface which uses 20459 the `curses' library to show the source file, the assembly output, the 20460 program registers and GDB commands in separate text windows. The TUI 20461 mode is supported only on platforms where a suitable version of the 20462 `curses' library is available. 20463 20464 The TUI mode is enabled by default when you invoke GDB as either 20465 `gdbtui' or `gdb -tui'. You can also switch in and out of TUI mode 20466 while GDB runs by using various TUI commands and key bindings, such as 20467 `C-x C-a'. *Note TUI Key Bindings: TUI Keys. 20468 20469 20470 File: gdb.info, Node: TUI Overview, Next: TUI Keys, Up: TUI 20471 20472 25.1 TUI Overview 20473 ================= 20474 20475 In TUI mode, GDB can display several text windows: 20476 20477 _command_ 20478 This window is the GDB command window with the GDB prompt and the 20479 GDB output. The GDB input is still managed using readline. 20480 20481 _source_ 20482 The source window shows the source file of the program. The 20483 current line and active breakpoints are displayed in this window. 20484 20485 _assembly_ 20486 The assembly window shows the disassembly output of the program. 20487 20488 _register_ 20489 This window shows the processor registers. Registers are 20490 highlighted when their values change. 20491 20492 The source and assembly windows show the current program position by 20493 highlighting the current line and marking it with a `>' marker. 20494 Breakpoints are indicated with two markers. The first marker indicates 20495 the breakpoint type: 20496 20497 `B' 20498 Breakpoint which was hit at least once. 20499 20500 `b' 20501 Breakpoint which was never hit. 20502 20503 `H' 20504 Hardware breakpoint which was hit at least once. 20505 20506 `h' 20507 Hardware breakpoint which was never hit. 20508 20509 The second marker indicates whether the breakpoint is enabled or not: 20510 20511 `+' 20512 Breakpoint is enabled. 20513 20514 `-' 20515 Breakpoint is disabled. 20516 20517 The source, assembly and register windows are updated when the 20518 current thread changes, when the frame changes, or when the program 20519 counter changes. 20520 20521 These windows are not all visible at the same time. The command 20522 window is always visible. The others can be arranged in several 20523 layouts: 20524 20525 * source only, 20526 20527 * assembly only, 20528 20529 * source and assembly, 20530 20531 * source and registers, or 20532 20533 * assembly and registers. 20534 20535 A status line above the command window shows the following 20536 information: 20537 20538 _target_ 20539 Indicates the current GDB target. (*note Specifying a Debugging 20540 Target: Targets.). 20541 20542 _process_ 20543 Gives the current process or thread number. When no process is 20544 being debugged, this field is set to `No process'. 20545 20546 _function_ 20547 Gives the current function name for the selected frame. The name 20548 is demangled if demangling is turned on (*note Print Settings::). 20549 When there is no symbol corresponding to the current program 20550 counter, the string `??' is displayed. 20551 20552 _line_ 20553 Indicates the current line number for the selected frame. When 20554 the current line number is not known, the string `??' is displayed. 20555 20556 _pc_ 20557 Indicates the current program counter address. 20558 20559 20560 File: gdb.info, Node: TUI Keys, Next: TUI Single Key Mode, Prev: TUI Overview, Up: TUI 20561 20562 25.2 TUI Key Bindings 20563 ===================== 20564 20565 The TUI installs several key bindings in the readline keymaps (*note 20566 Command Line Editing::). The following key bindings are installed for 20567 both TUI mode and the GDB standard mode. 20568 20569 `C-x C-a' 20570 `C-x a' 20571 `C-x A' 20572 Enter or leave the TUI mode. When leaving the TUI mode, the 20573 curses window management stops and GDB operates using its standard 20574 mode, writing on the terminal directly. When reentering the TUI 20575 mode, control is given back to the curses windows. The screen is 20576 then refreshed. 20577 20578 `C-x 1' 20579 Use a TUI layout with only one window. The layout will either be 20580 `source' or `assembly'. When the TUI mode is not active, it will 20581 switch to the TUI mode. 20582 20583 Think of this key binding as the Emacs `C-x 1' binding. 20584 20585 `C-x 2' 20586 Use a TUI layout with at least two windows. When the current 20587 layout already has two windows, the next layout with two windows 20588 is used. When a new layout is chosen, one window will always be 20589 common to the previous layout and the new one. 20590 20591 Think of it as the Emacs `C-x 2' binding. 20592 20593 `C-x o' 20594 Change the active window. The TUI associates several key bindings 20595 (like scrolling and arrow keys) with the active window. This 20596 command gives the focus to the next TUI window. 20597 20598 Think of it as the Emacs `C-x o' binding. 20599 20600 `C-x s' 20601 Switch in and out of the TUI SingleKey mode that binds single keys 20602 to GDB commands (*note TUI Single Key Mode::). 20603 20604 The following key bindings only work in the TUI mode: 20605 20606 <PgUp> 20607 Scroll the active window one page up. 20608 20609 <PgDn> 20610 Scroll the active window one page down. 20611 20612 <Up> 20613 Scroll the active window one line up. 20614 20615 <Down> 20616 Scroll the active window one line down. 20617 20618 <Left> 20619 Scroll the active window one column left. 20620 20621 <Right> 20622 Scroll the active window one column right. 20623 20624 `C-L' 20625 Refresh the screen. 20626 20627 Because the arrow keys scroll the active window in the TUI mode, they 20628 are not available for their normal use by readline unless the command 20629 window has the focus. When another window is active, you must use 20630 other readline key bindings such as `C-p', `C-n', `C-b' and `C-f' to 20631 control the command window. 20632 20633 20634 File: gdb.info, Node: TUI Single Key Mode, Next: TUI Commands, Prev: TUI Keys, Up: TUI 20635 20636 25.3 TUI Single Key Mode 20637 ======================== 20638 20639 The TUI also provides a "SingleKey" mode, which binds several 20640 frequently used GDB commands to single keys. Type `C-x s' to switch 20641 into this mode, where the following key bindings are used: 20642 20643 `c' 20644 continue 20645 20646 `d' 20647 down 20648 20649 `f' 20650 finish 20651 20652 `n' 20653 next 20654 20655 `q' 20656 exit the SingleKey mode. 20657 20658 `r' 20659 run 20660 20661 `s' 20662 step 20663 20664 `u' 20665 up 20666 20667 `v' 20668 info locals 20669 20670 `w' 20671 where 20672 20673 Other keys temporarily switch to the GDB command prompt. The key 20674 that was pressed is inserted in the editing buffer so that it is 20675 possible to type most GDB commands without interaction with the TUI 20676 SingleKey mode. Once the command is entered the TUI SingleKey mode is 20677 restored. The only way to permanently leave this mode is by typing `q' 20678 or `C-x s'. 20679 20680 20681 File: gdb.info, Node: TUI Commands, Next: TUI Configuration, Prev: TUI Single Key Mode, Up: TUI 20682 20683 25.4 TUI-specific Commands 20684 ========================== 20685 20686 The TUI has specific commands to control the text windows. These 20687 commands are always available, even when GDB is not in the TUI mode. 20688 When GDB is in the standard mode, most of these commands will 20689 automatically switch to the TUI mode. 20690 20691 Note that if GDB's `stdout' is not connected to a terminal, or GDB 20692 has been started with the machine interface interpreter (*note The 20693 GDB/MI Interface: GDB/MI.), most of these commands will fail with an 20694 error, because it would not be possible or desirable to enable curses 20695 window management. 20696 20697 `info win' 20698 List and give the size of all displayed windows. 20699 20700 `layout next' 20701 Display the next layout. 20702 20703 `layout prev' 20704 Display the previous layout. 20705 20706 `layout src' 20707 Display the source window only. 20708 20709 `layout asm' 20710 Display the assembly window only. 20711 20712 `layout split' 20713 Display the source and assembly window. 20714 20715 `layout regs' 20716 Display the register window together with the source or assembly 20717 window. 20718 20719 `focus next' 20720 Make the next window active for scrolling. 20721 20722 `focus prev' 20723 Make the previous window active for scrolling. 20724 20725 `focus src' 20726 Make the source window active for scrolling. 20727 20728 `focus asm' 20729 Make the assembly window active for scrolling. 20730 20731 `focus regs' 20732 Make the register window active for scrolling. 20733 20734 `focus cmd' 20735 Make the command window active for scrolling. 20736 20737 `refresh' 20738 Refresh the screen. This is similar to typing `C-L'. 20739 20740 `tui reg float' 20741 Show the floating point registers in the register window. 20742 20743 `tui reg general' 20744 Show the general registers in the register window. 20745 20746 `tui reg next' 20747 Show the next register group. The list of register groups as well 20748 as their order is target specific. The predefined register groups 20749 are the following: `general', `float', `system', `vector', `all', 20750 `save', `restore'. 20751 20752 `tui reg system' 20753 Show the system registers in the register window. 20754 20755 `update' 20756 Update the source window and the current execution point. 20757 20758 `winheight NAME +COUNT' 20759 `winheight NAME -COUNT' 20760 Change the height of the window NAME by COUNT lines. Positive 20761 counts increase the height, while negative counts decrease it. 20762 20763 `tabset NCHARS' 20764 Set the width of tab stops to be NCHARS characters. 20765 20766 20767 File: gdb.info, Node: TUI Configuration, Prev: TUI Commands, Up: TUI 20768 20769 25.5 TUI Configuration Variables 20770 ================================ 20771 20772 Several configuration variables control the appearance of TUI windows. 20773 20774 `set tui border-kind KIND' 20775 Select the border appearance for the source, assembly and register 20776 windows. The possible values are the following: 20777 `space' 20778 Use a space character to draw the border. 20779 20780 `ascii' 20781 Use ASCII characters `+', `-' and `|' to draw the border. 20782 20783 `acs' 20784 Use the Alternate Character Set to draw the border. The 20785 border is drawn using character line graphics if the terminal 20786 supports them. 20787 20788 `set tui border-mode MODE' 20789 `set tui active-border-mode MODE' 20790 Select the display attributes for the borders of the inactive 20791 windows or the active window. The MODE can be one of the 20792 following: 20793 `normal' 20794 Use normal attributes to display the border. 20795 20796 `standout' 20797 Use standout mode. 20798 20799 `reverse' 20800 Use reverse video mode. 20801 20802 `half' 20803 Use half bright mode. 20804 20805 `half-standout' 20806 Use half bright and standout mode. 20807 20808 `bold' 20809 Use extra bright or bold mode. 20810 20811 `bold-standout' 20812 Use extra bright or bold and standout mode. 20813 20814 20815 File: gdb.info, Node: Emacs, Next: GDB/MI, Prev: TUI, Up: Top 20816 20817 26 Using GDB under GNU Emacs 20818 **************************** 20819 20820 A special interface allows you to use GNU Emacs to view (and edit) the 20821 source files for the program you are debugging with GDB. 20822 20823 To use this interface, use the command `M-x gdb' in Emacs. Give the 20824 executable file you want to debug as an argument. This command starts 20825 GDB as a subprocess of Emacs, with input and output through a newly 20826 created Emacs buffer. 20827 20828 Running GDB under Emacs can be just like running GDB normally except 20829 for two things: 20830 20831 * All "terminal" input and output goes through an Emacs buffer, 20832 called the GUD buffer. 20833 20834 This applies both to GDB commands and their output, and to the 20835 input and output done by the program you are debugging. 20836 20837 This is useful because it means that you can copy the text of 20838 previous commands and input them again; you can even use parts of 20839 the output in this way. 20840 20841 All the facilities of Emacs' Shell mode are available for 20842 interacting with your program. In particular, you can send 20843 signals the usual way--for example, `C-c C-c' for an interrupt, 20844 `C-c C-z' for a stop. 20845 20846 * GDB displays source code through Emacs. 20847 20848 Each time GDB displays a stack frame, Emacs automatically finds the 20849 source file for that frame and puts an arrow (`=>') at the left 20850 margin of the current line. Emacs uses a separate buffer for 20851 source display, and splits the screen to show both your GDB session 20852 and the source. 20853 20854 Explicit GDB `list' or search commands still produce output as 20855 usual, but you probably have no reason to use them from Emacs. 20856 20857 We call this "text command mode". Emacs 22.1, and later, also uses 20858 a graphical mode, enabled by default, which provides further buffers 20859 that can control the execution and describe the state of your program. 20860 *Note GDB Graphical Interface: (Emacs)GDB Graphical Interface. 20861 20862 If you specify an absolute file name when prompted for the `M-x gdb' 20863 argument, then Emacs sets your current working directory to where your 20864 program resides. If you only specify the file name, then Emacs sets 20865 your current working directory to to the directory associated with the 20866 previous buffer. In this case, GDB may find your program by searching 20867 your environment's `PATH' variable, but on some operating systems it 20868 might not find the source. So, although the GDB input and output 20869 session proceeds normally, the auxiliary buffer does not display the 20870 current source and line of execution. 20871 20872 The initial working directory of GDB is printed on the top line of 20873 the GUD buffer and this serves as a default for the commands that 20874 specify files for GDB to operate on. *Note Commands to Specify Files: 20875 Files. 20876 20877 By default, `M-x gdb' calls the program called `gdb'. If you need 20878 to call GDB by a different name (for example, if you keep several 20879 configurations around, with different names) you can customize the 20880 Emacs variable `gud-gdb-command-name' to run the one you want. 20881 20882 In the GUD buffer, you can use these special Emacs commands in 20883 addition to the standard Shell mode commands: 20884 20885 `C-h m' 20886 Describe the features of Emacs' GUD Mode. 20887 20888 `C-c C-s' 20889 Execute to another source line, like the GDB `step' command; also 20890 update the display window to show the current file and location. 20891 20892 `C-c C-n' 20893 Execute to next source line in this function, skipping all function 20894 calls, like the GDB `next' command. Then update the display window 20895 to show the current file and location. 20896 20897 `C-c C-i' 20898 Execute one instruction, like the GDB `stepi' command; update 20899 display window accordingly. 20900 20901 `C-c C-f' 20902 Execute until exit from the selected stack frame, like the GDB 20903 `finish' command. 20904 20905 `C-c C-r' 20906 Continue execution of your program, like the GDB `continue' 20907 command. 20908 20909 `C-c <' 20910 Go up the number of frames indicated by the numeric argument 20911 (*note Numeric Arguments: (Emacs)Arguments.), like the GDB `up' 20912 command. 20913 20914 `C-c >' 20915 Go down the number of frames indicated by the numeric argument, 20916 like the GDB `down' command. 20917 20918 In any source file, the Emacs command `C-x <SPC>' (`gud-break') 20919 tells GDB to set a breakpoint on the source line point is on. 20920 20921 In text command mode, if you type `M-x speedbar', Emacs displays a 20922 separate frame which shows a backtrace when the GUD buffer is current. 20923 Move point to any frame in the stack and type <RET> to make it become 20924 the current frame and display the associated source in the source 20925 buffer. Alternatively, click `Mouse-2' to make the selected frame 20926 become the current one. In graphical mode, the speedbar displays watch 20927 expressions. 20928 20929 If you accidentally delete the source-display buffer, an easy way to 20930 get it back is to type the command `f' in the GDB buffer, to request a 20931 frame display; when you run under Emacs, this recreates the source 20932 buffer if necessary to show you the context of the current frame. 20933 20934 The source files displayed in Emacs are in ordinary Emacs buffers 20935 which are visiting the source files in the usual way. You can edit the 20936 files with these buffers if you wish; but keep in mind that GDB 20937 communicates with Emacs in terms of line numbers. If you add or delete 20938 lines from the text, the line numbers that GDB knows cease to 20939 correspond properly with the code. 20940 20941 A more detailed description of Emacs' interaction with GDB is given 20942 in the Emacs manual (*note Debuggers: (Emacs)Debuggers.). 20943 20944 20945 File: gdb.info, Node: GDB/MI, Next: Annotations, Prev: Emacs, Up: Top 20946 20947 27 The GDB/MI Interface 20948 *********************** 20949 20950 Function and Purpose 20951 ==================== 20952 20953 GDB/MI is a line based machine oriented text interface to GDB and is 20954 activated by specifying using the `--interpreter' command line option 20955 (*note Mode Options::). It is specifically intended to support the 20956 development of systems which use the debugger as just one small 20957 component of a larger system. 20958 20959 This chapter is a specification of the GDB/MI interface. It is 20960 written in the form of a reference manual. 20961 20962 Note that GDB/MI is still under construction, so some of the 20963 features described below are incomplete and subject to change (*note 20964 GDB/MI Development and Front Ends: GDB/MI Development and Front Ends.). 20965 20966 Notation and Terminology 20967 ======================== 20968 20969 This chapter uses the following notation: 20970 20971 * `|' separates two alternatives. 20972 20973 * `[ SOMETHING ]' indicates that SOMETHING is optional: it may or 20974 may not be given. 20975 20976 * `( GROUP )*' means that GROUP inside the parentheses may repeat 20977 zero or more times. 20978 20979 * `( GROUP )+' means that GROUP inside the parentheses may repeat 20980 one or more times. 20981 20982 * `"STRING"' means a literal STRING. 20983 20984 * Menu: 20985 20986 * GDB/MI General Design:: 20987 * GDB/MI Command Syntax:: 20988 * GDB/MI Compatibility with CLI:: 20989 * GDB/MI Development and Front Ends:: 20990 * GDB/MI Output Records:: 20991 * GDB/MI Simple Examples:: 20992 * GDB/MI Command Description Format:: 20993 * GDB/MI Breakpoint Commands:: 20994 * GDB/MI Program Context:: 20995 * GDB/MI Thread Commands:: 20996 * GDB/MI Program Execution:: 20997 * GDB/MI Stack Manipulation:: 20998 * GDB/MI Variable Objects:: 20999 * GDB/MI Data Manipulation:: 21000 * GDB/MI Tracepoint Commands:: 21001 * GDB/MI Symbol Query:: 21002 * GDB/MI File Commands:: 21003 * GDB/MI Target Manipulation:: 21004 * GDB/MI File Transfer Commands:: 21005 * GDB/MI Miscellaneous Commands:: 21006 21007 21008 File: gdb.info, Node: GDB/MI General Design, Next: GDB/MI Command Syntax, Up: GDB/MI 21009 21010 27.1 GDB/MI General Design 21011 ========================== 21012 21013 Interaction of a GDB/MI frontend with GDB involves three 21014 parts--commands sent to GDB, responses to those commands and 21015 notifications. Each command results in exactly one response, 21016 indicating either successful completion of the command, or an error. 21017 For the commands that do not resume the target, the response contains 21018 the requested information. For the commands that resume the target, the 21019 response only indicates whether the target was successfully resumed. 21020 Notifications is the mechanism for reporting changes in the state of the 21021 target, or in GDB state, that cannot conveniently be associated with a 21022 command and reported as part of that command response. 21023 21024 The important examples of notifications are: 21025 * Exec notifications. These are used to report changes in target 21026 state--when a target is resumed, or stopped. It would not be 21027 feasible to include this information in response of resuming 21028 commands, because one resume commands can result in multiple 21029 events in different threads. Also, quite some time may pass 21030 before any event happens in the target, while a frontend needs to 21031 know whether the resuming command itself was successfully executed. 21032 21033 * Console output, and status notifications. Console output 21034 notifications are used to report output of CLI commands, as well as 21035 diagnostics for other commands. Status notifications are used to 21036 report the progress of a long-running operation. Naturally, 21037 including this information in command response would mean no 21038 output is produced until the command is finished, which is 21039 undesirable. 21040 21041 * General notifications. Commands may have various side effects on 21042 the GDB or target state beyond their official purpose. For 21043 example, a command may change the selected thread. Although such 21044 changes can be included in command response, using notification 21045 allows for more orthogonal frontend design. 21046 21047 21048 There's no guarantee that whenever an MI command reports an error, 21049 GDB or the target are in any specific state, and especially, the state 21050 is not reverted to the state before the MI command was processed. 21051 Therefore, whenever an MI command results in an error, we recommend 21052 that the frontend refreshes all the information shown in the user 21053 interface. 21054 21055 * Menu: 21056 21057 * Context management:: 21058 * Asynchronous and non-stop modes:: 21059 * Thread groups:: 21060 21061 21062 File: gdb.info, Node: Context management, Next: Asynchronous and non-stop modes, Up: GDB/MI General Design 21063 21064 27.1.1 Context management 21065 ------------------------- 21066 21067 In most cases when GDB accesses the target, this access is done in 21068 context of a specific thread and frame (*note Frames::). Often, even 21069 when accessing global data, the target requires that a thread be 21070 specified. The CLI interface maintains the selected thread and frame, 21071 and supplies them to target on each command. This is convenient, 21072 because a command line user would not want to specify that information 21073 explicitly on each command, and because user interacts with GDB via a 21074 single terminal, so no confusion is possible as to what thread and 21075 frame are the current ones. 21076 21077 In the case of MI, the concept of selected thread and frame is less 21078 useful. First, a frontend can easily remember this information itself. 21079 Second, a graphical frontend can have more than one window, each one 21080 used for debugging a different thread, and the frontend might want to 21081 access additional threads for internal purposes. This increases the 21082 risk that by relying on implicitly selected thread, the frontend may be 21083 operating on a wrong one. Therefore, each MI command should explicitly 21084 specify which thread and frame to operate on. To make it possible, 21085 each MI command accepts the `--thread' and `--frame' options, the value 21086 to each is GDB identifier for thread and frame to operate on. 21087 21088 Usually, each top-level window in a frontend allows the user to 21089 select a thread and a frame, and remembers the user selection for 21090 further operations. However, in some cases GDB may suggest that the 21091 current thread be changed. For example, when stopping on a breakpoint 21092 it is reasonable to switch to the thread where breakpoint is hit. For 21093 another example, if the user issues the CLI `thread' command via the 21094 frontend, it is desirable to change the frontend's selected thread to 21095 the one specified by user. GDB communicates the suggestion to change 21096 current thread using the `=thread-selected' notification. No such 21097 notification is available for the selected frame at the moment. 21098 21099 Note that historically, MI shares the selected thread with CLI, so 21100 frontends used the `-thread-select' to execute commands in the right 21101 context. However, getting this to work right is cumbersome. The 21102 simplest way is for frontend to emit `-thread-select' command before 21103 every command. This doubles the number of commands that need to be 21104 sent. The alternative approach is to suppress `-thread-select' if the 21105 selected thread in GDB is supposed to be identical to the thread the 21106 frontend wants to operate on. However, getting this optimization right 21107 can be tricky. In particular, if the frontend sends several commands 21108 to GDB, and one of the commands changes the selected thread, then the 21109 behaviour of subsequent commands will change. So, a frontend should 21110 either wait for response from such problematic commands, or explicitly 21111 add `-thread-select' for all subsequent commands. No frontend is known 21112 to do this exactly right, so it is suggested to just always pass the 21113 `--thread' and `--frame' options. 21114 21115 21116 File: gdb.info, Node: Asynchronous and non-stop modes, Next: Thread groups, Prev: Context management, Up: GDB/MI General Design 21117 21118 27.1.2 Asynchronous command execution and non-stop mode 21119 ------------------------------------------------------- 21120 21121 On some targets, GDB is capable of processing MI commands even while 21122 the target is running. This is called "asynchronous command execution" 21123 (*note Background Execution::). The frontend may specify a preferrence 21124 for asynchronous execution using the `-gdb-set target-async 1' command, 21125 which should be emitted before either running the executable or 21126 attaching to the target. After the frontend has started the executable 21127 or attached to the target, it can find if asynchronous execution is 21128 enabled using the `-list-target-features' command. 21129 21130 Even if GDB can accept a command while target is running, many 21131 commands that access the target do not work when the target is running. 21132 Therefore, asynchronous command execution is most useful when combined 21133 with non-stop mode (*note Non-Stop Mode::). Then, it is possible to 21134 examine the state of one thread, while other threads are running. 21135 21136 When a given thread is running, MI commands that try to access the 21137 target in the context of that thread may not work, or may work only on 21138 some targets. In particular, commands that try to operate on thread's 21139 stack will not work, on any target. Commands that read memory, or 21140 modify breakpoints, may work or not work, depending on the target. Note 21141 that even commands that operate on global state, such as `print', 21142 `set', and breakpoint commands, still access the target in the context 21143 of a specific thread, so frontend should try to find a stopped thread 21144 and perform the operation on that thread (using the `--thread' option). 21145 21146 Which commands will work in the context of a running thread is 21147 highly target dependent. However, the two commands `-exec-interrupt', 21148 to stop a thread, and `-thread-info', to find the state of a thread, 21149 will always work. 21150 21151 21152 File: gdb.info, Node: Thread groups, Prev: Asynchronous and non-stop modes, Up: GDB/MI General Design 21153 21154 27.1.3 Thread groups 21155 -------------------- 21156 21157 GDB may be used to debug several processes at the same time. On some 21158 platfroms, GDB may support debugging of several hardware systems, each 21159 one having several cores with several different processes running on 21160 each core. This section describes the MI mechanism to support such 21161 debugging scenarios. 21162 21163 The key observation is that regardless of the structure of the 21164 target, MI can have a global list of threads, because most commands that 21165 accept the `--thread' option do not need to know what process that 21166 thread belongs to. Therefore, it is not necessary to introduce neither 21167 additional `--process' option, nor an notion of the current process in 21168 the MI interface. The only strictly new feature that is required is 21169 the ability to find how the threads are grouped into processes. 21170 21171 To allow the user to discover such grouping, and to support arbitrary 21172 hierarchy of machines/cores/processes, MI introduces the concept of a 21173 "thread group". Thread group is a collection of threads and other 21174 thread groups. A thread group always has a string identifier, a type, 21175 and may have additional attributes specific to the type. A new 21176 command, `-list-thread-groups', returns the list of top-level thread 21177 groups, which correspond to processes that GDB is debugging at the 21178 moment. By passing an identifier of a thread group to the 21179 `-list-thread-groups' command, it is possible to obtain the members of 21180 specific thread group. 21181 21182 To allow the user to easily discover processes, and other objects, he 21183 wishes to debug, a concept of "available thread group" is introduced. 21184 Available thread group is an thread group that GDB is not debugging, 21185 but that can be attached to, using the `-target-attach' command. The 21186 list of available top-level thread groups can be obtained using 21187 `-list-thread-groups --available'. In general, the content of a thread 21188 group may be only retrieved only after attaching to that thread group. 21189 21190 Thread groups are related to inferiors (*note Inferiors and 21191 Programs::). Each inferior corresponds to a thread group of a special 21192 type `process', and some additional operations are permitted on such 21193 thread groups. 21194 21195 21196 File: gdb.info, Node: GDB/MI Command Syntax, Next: GDB/MI Compatibility with CLI, Prev: GDB/MI General Design, Up: GDB/MI 21197 21198 27.2 GDB/MI Command Syntax 21199 ========================== 21200 21201 * Menu: 21202 21203 * GDB/MI Input Syntax:: 21204 * GDB/MI Output Syntax:: 21205 21206 21207 File: gdb.info, Node: GDB/MI Input Syntax, Next: GDB/MI Output Syntax, Up: GDB/MI Command Syntax 21208 21209 27.2.1 GDB/MI Input Syntax 21210 -------------------------- 21211 21212 `COMMAND ==>' 21213 `CLI-COMMAND | MI-COMMAND' 21214 21215 `CLI-COMMAND ==>' 21216 `[ TOKEN ] CLI-COMMAND NL', where CLI-COMMAND is any existing GDB 21217 CLI command. 21218 21219 `MI-COMMAND ==>' 21220 `[ TOKEN ] "-" OPERATION ( " " OPTION )* `[' " --" `]' ( " " 21221 PARAMETER )* NL' 21222 21223 `TOKEN ==>' 21224 "any sequence of digits" 21225 21226 `OPTION ==>' 21227 `"-" PARAMETER [ " " PARAMETER ]' 21228 21229 `PARAMETER ==>' 21230 `NON-BLANK-SEQUENCE | C-STRING' 21231 21232 `OPERATION ==>' 21233 _any of the operations described in this chapter_ 21234 21235 `NON-BLANK-SEQUENCE ==>' 21236 _anything, provided it doesn't contain special characters such as 21237 "-", NL, """ and of course " "_ 21238 21239 `C-STRING ==>' 21240 `""" SEVEN-BIT-ISO-C-STRING-CONTENT """' 21241 21242 `NL ==>' 21243 `CR | CR-LF' 21244 21245 Notes: 21246 21247 * The CLI commands are still handled by the MI interpreter; their 21248 output is described below. 21249 21250 * The `TOKEN', when present, is passed back when the command 21251 finishes. 21252 21253 * Some MI commands accept optional arguments as part of the parameter 21254 list. Each option is identified by a leading `-' (dash) and may be 21255 followed by an optional argument parameter. Options occur first 21256 in the parameter list and can be delimited from normal parameters 21257 using `--' (this is useful when some parameters begin with a dash). 21258 21259 Pragmatics: 21260 21261 * We want easy access to the existing CLI syntax (for debugging). 21262 21263 * We want it to be easy to spot a MI operation. 21264 21265 21266 File: gdb.info, Node: GDB/MI Output Syntax, Prev: GDB/MI Input Syntax, Up: GDB/MI Command Syntax 21267 21268 27.2.2 GDB/MI Output Syntax 21269 --------------------------- 21270 21271 The output from GDB/MI consists of zero or more out-of-band records 21272 followed, optionally, by a single result record. This result record is 21273 for the most recent command. The sequence of output records is 21274 terminated by `(gdb)'. 21275 21276 If an input command was prefixed with a `TOKEN' then the 21277 corresponding output for that command will also be prefixed by that same 21278 TOKEN. 21279 21280 `OUTPUT ==>' 21281 `( OUT-OF-BAND-RECORD )* [ RESULT-RECORD ] "(gdb)" NL' 21282 21283 `RESULT-RECORD ==>' 21284 ` [ TOKEN ] "^" RESULT-CLASS ( "," RESULT )* NL' 21285 21286 `OUT-OF-BAND-RECORD ==>' 21287 `ASYNC-RECORD | STREAM-RECORD' 21288 21289 `ASYNC-RECORD ==>' 21290 `EXEC-ASYNC-OUTPUT | STATUS-ASYNC-OUTPUT | NOTIFY-ASYNC-OUTPUT' 21291 21292 `EXEC-ASYNC-OUTPUT ==>' 21293 `[ TOKEN ] "*" ASYNC-OUTPUT' 21294 21295 `STATUS-ASYNC-OUTPUT ==>' 21296 `[ TOKEN ] "+" ASYNC-OUTPUT' 21297 21298 `NOTIFY-ASYNC-OUTPUT ==>' 21299 `[ TOKEN ] "=" ASYNC-OUTPUT' 21300 21301 `ASYNC-OUTPUT ==>' 21302 `ASYNC-CLASS ( "," RESULT )* NL' 21303 21304 `RESULT-CLASS ==>' 21305 `"done" | "running" | "connected" | "error" | "exit"' 21306 21307 `ASYNC-CLASS ==>' 21308 `"stopped" | OTHERS' (where OTHERS will be added depending on the 21309 needs--this is still in development). 21310 21311 `RESULT ==>' 21312 ` VARIABLE "=" VALUE' 21313 21314 `VARIABLE ==>' 21315 ` STRING ' 21316 21317 `VALUE ==>' 21318 ` CONST | TUPLE | LIST ' 21319 21320 `CONST ==>' 21321 `C-STRING' 21322 21323 `TUPLE ==>' 21324 ` "{}" | "{" RESULT ( "," RESULT )* "}" ' 21325 21326 `LIST ==>' 21327 ` "[]" | "[" VALUE ( "," VALUE )* "]" | "[" RESULT ( "," RESULT )* 21328 "]" ' 21329 21330 `STREAM-RECORD ==>' 21331 `CONSOLE-STREAM-OUTPUT | TARGET-STREAM-OUTPUT | LOG-STREAM-OUTPUT' 21332 21333 `CONSOLE-STREAM-OUTPUT ==>' 21334 `"~" C-STRING' 21335 21336 `TARGET-STREAM-OUTPUT ==>' 21337 `"@" C-STRING' 21338 21339 `LOG-STREAM-OUTPUT ==>' 21340 `"&" C-STRING' 21341 21342 `NL ==>' 21343 `CR | CR-LF' 21344 21345 `TOKEN ==>' 21346 _any sequence of digits_. 21347 21348 Notes: 21349 21350 * All output sequences end in a single line containing a period. 21351 21352 * The `TOKEN' is from the corresponding request. Note that for all 21353 async output, while the token is allowed by the grammar and may be 21354 output by future versions of GDB for select async output messages, 21355 it is generally omitted. Frontends should treat all async output 21356 as reporting general changes in the state of the target and there 21357 should be no need to associate async output to any prior command. 21358 21359 * STATUS-ASYNC-OUTPUT contains on-going status information about the 21360 progress of a slow operation. It can be discarded. All status 21361 output is prefixed by `+'. 21362 21363 * EXEC-ASYNC-OUTPUT contains asynchronous state change on the target 21364 (stopped, started, disappeared). All async output is prefixed by 21365 `*'. 21366 21367 * NOTIFY-ASYNC-OUTPUT contains supplementary information that the 21368 client should handle (e.g., a new breakpoint information). All 21369 notify output is prefixed by `='. 21370 21371 * CONSOLE-STREAM-OUTPUT is output that should be displayed as is in 21372 the console. It is the textual response to a CLI command. All 21373 the console output is prefixed by `~'. 21374 21375 * TARGET-STREAM-OUTPUT is the output produced by the target program. 21376 All the target output is prefixed by `@'. 21377 21378 * LOG-STREAM-OUTPUT is output text coming from GDB's internals, for 21379 instance messages that should be displayed as part of an error 21380 log. All the log output is prefixed by `&'. 21381 21382 * New GDB/MI commands should only output LISTS containing VALUES. 21383 21384 21385 *Note GDB/MI Stream Records: GDB/MI Stream Records, for more details 21386 about the various output records. 21387 21388 21389 File: gdb.info, Node: GDB/MI Compatibility with CLI, Next: GDB/MI Development and Front Ends, Prev: GDB/MI Command Syntax, Up: GDB/MI 21390 21391 27.3 GDB/MI Compatibility with CLI 21392 ================================== 21393 21394 For the developers convenience CLI commands can be entered directly, 21395 but there may be some unexpected behaviour. For example, commands that 21396 query the user will behave as if the user replied yes, breakpoint 21397 command lists are not executed and some CLI commands, such as `if', 21398 `when' and `define', prompt for further input with `>', which is not 21399 valid MI output. 21400 21401 This feature may be removed at some stage in the future and it is 21402 recommended that front ends use the `-interpreter-exec' command (*note 21403 -interpreter-exec::). 21404 21405 21406 File: gdb.info, Node: GDB/MI Development and Front Ends, Next: GDB/MI Output Records, Prev: GDB/MI Compatibility with CLI, Up: GDB/MI 21407 21408 27.4 GDB/MI Development and Front Ends 21409 ====================================== 21410 21411 The application which takes the MI output and presents the state of the 21412 program being debugged to the user is called a "front end". 21413 21414 Although GDB/MI is still incomplete, it is currently being used by a 21415 variety of front ends to GDB. This makes it difficult to introduce new 21416 functionality without breaking existing usage. This section tries to 21417 minimize the problems by describing how the protocol might change. 21418 21419 Some changes in MI need not break a carefully designed front end, and 21420 for these the MI version will remain unchanged. The following is a 21421 list of changes that may occur within one level, so front ends should 21422 parse MI output in a way that can handle them: 21423 21424 * New MI commands may be added. 21425 21426 * New fields may be added to the output of any MI command. 21427 21428 * The range of values for fields with specified values, e.g., 21429 `in_scope' (*note -var-update::) may be extended. 21430 21431 21432 If the changes are likely to break front ends, the MI version level 21433 will be increased by one. This will allow the front end to parse the 21434 output according to the MI version. Apart from mi0, new versions of 21435 GDB will not support old versions of MI and it will be the 21436 responsibility of the front end to work with the new one. 21437 21438 The best way to avoid unexpected changes in MI that might break your 21439 front end is to make your project known to GDB developers and follow 21440 development on <gdb (a] sourceware.org> and <gdb-patches (a] sourceware.org>. 21441 21442 21443 File: gdb.info, Node: GDB/MI Output Records, Next: GDB/MI Simple Examples, Prev: GDB/MI Development and Front Ends, Up: GDB/MI 21444 21445 27.5 GDB/MI Output Records 21446 ========================== 21447 21448 * Menu: 21449 21450 * GDB/MI Result Records:: 21451 * GDB/MI Stream Records:: 21452 * GDB/MI Async Records:: 21453 * GDB/MI Frame Information:: 21454 * GDB/MI Thread Information:: 21455 * GDB/MI Ada Exception Information:: 21456 21457 21458 File: gdb.info, Node: GDB/MI Result Records, Next: GDB/MI Stream Records, Up: GDB/MI Output Records 21459 21460 27.5.1 GDB/MI Result Records 21461 ---------------------------- 21462 21463 In addition to a number of out-of-band notifications, the response to a 21464 GDB/MI command includes one of the following result indications: 21465 21466 `"^done" [ "," RESULTS ]' 21467 The synchronous operation was successful, `RESULTS' are the return 21468 values. 21469 21470 `"^running"' 21471 This result record is equivalent to `^done'. Historically, it was 21472 output instead of `^done' if the command has resumed the target. 21473 This behaviour is maintained for backward compatibility, but all 21474 frontends should treat `^done' and `^running' identically and rely 21475 on the `*running' output record to determine which threads are 21476 resumed. 21477 21478 `"^connected"' 21479 GDB has connected to a remote target. 21480 21481 `"^error" "," C-STRING' 21482 The operation failed. The `C-STRING' contains the corresponding 21483 error message. 21484 21485 `"^exit"' 21486 GDB has terminated. 21487 21488 21489 21490 File: gdb.info, Node: GDB/MI Stream Records, Next: GDB/MI Async Records, Prev: GDB/MI Result Records, Up: GDB/MI Output Records 21491 21492 27.5.2 GDB/MI Stream Records 21493 ---------------------------- 21494 21495 GDB internally maintains a number of output streams: the console, the 21496 target, and the log. The output intended for each of these streams is 21497 funneled through the GDB/MI interface using "stream records". 21498 21499 Each stream record begins with a unique "prefix character" which 21500 identifies its stream (*note GDB/MI Output Syntax: GDB/MI Output 21501 Syntax.). In addition to the prefix, each stream record contains a 21502 `STRING-OUTPUT'. This is either raw text (with an implicit new line) 21503 or a quoted C string (which does not contain an implicit newline). 21504 21505 `"~" STRING-OUTPUT' 21506 The console output stream contains text that should be displayed 21507 in the CLI console window. It contains the textual responses to 21508 CLI commands. 21509 21510 `"@" STRING-OUTPUT' 21511 The target output stream contains any textual output from the 21512 running target. This is only present when GDB's event loop is 21513 truly asynchronous, which is currently only the case for remote 21514 targets. 21515 21516 `"&" STRING-OUTPUT' 21517 The log stream contains debugging messages being produced by GDB's 21518 internals. 21519 21520 21521 File: gdb.info, Node: GDB/MI Async Records, Next: GDB/MI Frame Information, Prev: GDB/MI Stream Records, Up: GDB/MI Output Records 21522 21523 27.5.3 GDB/MI Async Records 21524 --------------------------- 21525 21526 "Async" records are used to notify the GDB/MI client of additional 21527 changes that have occurred. Those changes can either be a consequence 21528 of GDB/MI commands (e.g., a breakpoint modified) or a result of target 21529 activity (e.g., target stopped). 21530 21531 The following is the list of possible async records: 21532 21533 `*running,thread-id="THREAD"' 21534 The target is now running. The THREAD field tells which specific 21535 thread is now running, and can be `all' if all threads are 21536 running. The frontend should assume that no interaction with a 21537 running thread is possible after this notification is produced. 21538 The frontend should not assume that this notification is output 21539 only once for any command. GDB may emit this notification several 21540 times, either for different threads, because it cannot resume all 21541 threads together, or even for a single thread, if the thread must 21542 be stepped though some code before letting it run freely. 21543 21544 `*stopped,reason="REASON",thread-id="ID",stopped-threads="STOPPED",core="CORE"' 21545 The target has stopped. The REASON field can have one of the 21546 following values: 21547 21548 `breakpoint-hit' 21549 A breakpoint was reached. 21550 21551 `watchpoint-trigger' 21552 A watchpoint was triggered. 21553 21554 `read-watchpoint-trigger' 21555 A read watchpoint was triggered. 21556 21557 `access-watchpoint-trigger' 21558 An access watchpoint was triggered. 21559 21560 `function-finished' 21561 An -exec-finish or similar CLI command was accomplished. 21562 21563 `location-reached' 21564 An -exec-until or similar CLI command was accomplished. 21565 21566 `watchpoint-scope' 21567 A watchpoint has gone out of scope. 21568 21569 `end-stepping-range' 21570 An -exec-next, -exec-next-instruction, -exec-step, 21571 -exec-step-instruction or similar CLI command was 21572 accomplished. 21573 21574 `exited-signalled' 21575 The inferior exited because of a signal. 21576 21577 `exited' 21578 The inferior exited. 21579 21580 `exited-normally' 21581 The inferior exited normally. 21582 21583 `signal-received' 21584 A signal was received by the inferior. 21585 21586 The ID field identifies the thread that directly caused the stop - 21587 for example by hitting a breakpoint. Depending on whether all-stop 21588 mode is in effect (*note All-Stop Mode::), GDB may either stop all 21589 threads, or only the thread that directly triggered the stop. If 21590 all threads are stopped, the STOPPED field will have the value of 21591 `"all"'. Otherwise, the value of the STOPPED field will be a list 21592 of thread identifiers. Presently, this list will always include a 21593 single thread, but frontend should be prepared to see several 21594 threads in the list. The CORE field reports the processor core on 21595 which the stop event has happened. This field may be absent if 21596 such information is not available. 21597 21598 `=thread-group-added,id="ID"' 21599 `=thread-group-removed,id="ID"' 21600 A thread group was either added or removed. The ID field contains 21601 the GDB identifier of the thread group. When a thread group is 21602 added, it generally might not be associated with a running 21603 process. When a thread group is removed, its id becomes invalid 21604 and cannot be used in any way. 21605 21606 `=thread-group-started,id="ID",pid="PID"' 21607 A thread group became associated with a running program, either 21608 because the program was just started or the thread group was 21609 attached to a program. The ID field contains the GDB identifier 21610 of the thread group. The PID field contains process identifier, 21611 specific to the operating system. 21612 21613 `=thread-group-exited,id="ID"[,exit-code="CODE"]' 21614 A thread group is no longer associated with a running program, 21615 either because the program has exited, or because it was detached 21616 from. The ID field contains the GDB identifier of the thread 21617 group. CODE is the exit code of the inferior; it exists only when 21618 the inferior exited with some code. 21619 21620 `=thread-created,id="ID",group-id="GID"' 21621 `=thread-exited,id="ID",group-id="GID"' 21622 A thread either was created, or has exited. The ID field contains 21623 the GDB identifier of the thread. The GID field identifies the 21624 thread group this thread belongs to. 21625 21626 `=thread-selected,id="ID"' 21627 Informs that the selected thread was changed as result of the last 21628 command. This notification is not emitted as result of 21629 `-thread-select' command but is emitted whenever an MI command 21630 that is not documented to change the selected thread actually 21631 changes it. In particular, invoking, directly or indirectly (via 21632 user-defined command), the CLI `thread' command, will generate 21633 this notification. 21634 21635 We suggest that in response to this notification, front ends 21636 highlight the selected thread and cause subsequent commands to 21637 apply to that thread. 21638 21639 `=library-loaded,...' 21640 Reports that a new library file was loaded by the program. This 21641 notification has 4 fields--ID, TARGET-NAME, HOST-NAME, and 21642 SYMBOLS-LOADED. The ID field is an opaque identifier of the 21643 library. For remote debugging case, TARGET-NAME and HOST-NAME 21644 fields give the name of the library file on the target, and on the 21645 host respectively. For native debugging, both those fields have 21646 the same value. The SYMBOLS-LOADED field is emitted only for 21647 backward compatibility and should not be relied on to convey any 21648 useful information. The THREAD-GROUP field, if present, specifies 21649 the id of the thread group in whose context the library was 21650 loaded. If the field is absent, it means the library was loaded 21651 in the context of all present thread groups. 21652 21653 `=library-unloaded,...' 21654 Reports that a library was unloaded by the program. This 21655 notification has 3 fields--ID, TARGET-NAME and HOST-NAME with the 21656 same meaning as for the `=library-loaded' notification. The 21657 THREAD-GROUP field, if present, specifies the id of the thread 21658 group in whose context the library was unloaded. If the field is 21659 absent, it means the library was unloaded in the context of all 21660 present thread groups. 21661 21662 21663 21664 File: gdb.info, Node: GDB/MI Frame Information, Next: GDB/MI Thread Information, Prev: GDB/MI Async Records, Up: GDB/MI Output Records 21665 21666 27.5.4 GDB/MI Frame Information 21667 ------------------------------- 21668 21669 Response from many MI commands includes an information about stack 21670 frame. This information is a tuple that may have the following fields: 21671 21672 `level' 21673 The level of the stack frame. The innermost frame has the level of 21674 zero. This field is always present. 21675 21676 `func' 21677 The name of the function corresponding to the frame. This field 21678 may be absent if GDB is unable to determine the function name. 21679 21680 `addr' 21681 The code address for the frame. This field is always present. 21682 21683 `file' 21684 The name of the source files that correspond to the frame's code 21685 address. This field may be absent. 21686 21687 `line' 21688 The source line corresponding to the frames' code address. This 21689 field may be absent. 21690 21691 `from' 21692 The name of the binary file (either executable or shared library) 21693 the corresponds to the frame's code address. This field may be 21694 absent. 21695 21696 21697 21698 File: gdb.info, Node: GDB/MI Thread Information, Next: GDB/MI Ada Exception Information, Prev: GDB/MI Frame Information, Up: GDB/MI Output Records 21699 21700 27.5.5 GDB/MI Thread Information 21701 -------------------------------- 21702 21703 Whenever GDB has to report an information about a thread, it uses a 21704 tuple with the following fields: 21705 21706 `id' 21707 The numeric id assigned to the thread by GDB. This field is 21708 always present. 21709 21710 `target-id' 21711 Target-specific string identifying the thread. This field is 21712 always present. 21713 21714 `details' 21715 Additional information about the thread provided by the target. 21716 It is supposed to be human-readable and not interpreted by the 21717 frontend. This field is optional. 21718 21719 `state' 21720 Either `stopped' or `running', depending on whether the thread is 21721 presently running. This field is always present. 21722 21723 `core' 21724 The value of this field is an integer number of the processor core 21725 the thread was last seen on. This field is optional. 21726 21727 21728 File: gdb.info, Node: GDB/MI Ada Exception Information, Prev: GDB/MI Thread Information, Up: GDB/MI Output Records 21729 21730 27.5.6 GDB/MI Ada Exception Information 21731 --------------------------------------- 21732 21733 Whenever a `*stopped' record is emitted because the program stopped 21734 after hitting an exception catchpoint (*note Set Catchpoints::), GDB 21735 provides the name of the exception that was raised via the 21736 `exception-name' field. 21737 21738 21739 File: gdb.info, Node: GDB/MI Simple Examples, Next: GDB/MI Command Description Format, Prev: GDB/MI Output Records, Up: GDB/MI 21740 21741 27.6 Simple Examples of GDB/MI Interaction 21742 ========================================== 21743 21744 This subsection presents several simple examples of interaction using 21745 the GDB/MI interface. In these examples, `->' means that the following 21746 line is passed to GDB/MI as input, while `<-' means the output received 21747 from GDB/MI. 21748 21749 Note the line breaks shown in the examples are here only for 21750 readability, they don't appear in the real output. 21751 21752 Setting a Breakpoint 21753 -------------------- 21754 21755 Setting a breakpoint generates synchronous output which contains 21756 detailed information of the breakpoint. 21757 21758 -> -break-insert main 21759 <- ^done,bkpt={number="1",type="breakpoint",disp="keep", 21760 enabled="y",addr="0x08048564",func="main",file="myprog.c", 21761 fullname="/home/nickrob/myprog.c",line="68",times="0"} 21762 <- (gdb) 21763 21764 Program Execution 21765 ----------------- 21766 21767 Program execution generates asynchronous records and MI gives the 21768 reason that execution stopped. 21769 21770 -> -exec-run 21771 <- ^running 21772 <- (gdb) 21773 <- *stopped,reason="breakpoint-hit",disp="keep",bkptno="1",thread-id="0", 21774 frame={addr="0x08048564",func="main", 21775 args=[{name="argc",value="1"},{name="argv",value="0xbfc4d4d4"}], 21776 file="myprog.c",fullname="/home/nickrob/myprog.c",line="68"} 21777 <- (gdb) 21778 -> -exec-continue 21779 <- ^running 21780 <- (gdb) 21781 <- *stopped,reason="exited-normally" 21782 <- (gdb) 21783 21784 Quitting GDB 21785 ------------ 21786 21787 Quitting GDB just prints the result class `^exit'. 21788 21789 -> (gdb) 21790 <- -gdb-exit 21791 <- ^exit 21792 21793 Please note that `^exit' is printed immediately, but it might take 21794 some time for GDB to actually exit. During that time, GDB performs 21795 necessary cleanups, including killing programs being debugged or 21796 disconnecting from debug hardware, so the frontend should wait till GDB 21797 exits and should only forcibly kill GDB if it fails to exit in 21798 reasonable time. 21799 21800 A Bad Command 21801 ------------- 21802 21803 Here's what happens if you pass a non-existent command: 21804 21805 -> -rubbish 21806 <- ^error,msg="Undefined MI command: rubbish" 21807 <- (gdb) 21808 21809 21810 File: gdb.info, Node: GDB/MI Command Description Format, Next: GDB/MI Breakpoint Commands, Prev: GDB/MI Simple Examples, Up: GDB/MI 21811 21812 27.7 GDB/MI Command Description Format 21813 ====================================== 21814 21815 The remaining sections describe blocks of commands. Each block of 21816 commands is laid out in a fashion similar to this section. 21817 21818 Motivation 21819 ---------- 21820 21821 The motivation for this collection of commands. 21822 21823 Introduction 21824 ------------ 21825 21826 A brief introduction to this collection of commands as a whole. 21827 21828 Commands 21829 -------- 21830 21831 For each command in the block, the following is described: 21832 21833 Synopsis 21834 ........ 21835 21836 -command ARGS... 21837 21838 Result 21839 ...... 21840 21841 GDB Command 21842 ........... 21843 21844 The corresponding GDB CLI command(s), if any. 21845 21846 Example 21847 ....... 21848 21849 Example(s) formatted for readability. Some of the described commands 21850 have not been implemented yet and these are labeled N.A. (not 21851 available). 21852 21853 21854 File: gdb.info, Node: GDB/MI Breakpoint Commands, Next: GDB/MI Program Context, Prev: GDB/MI Command Description Format, Up: GDB/MI 21855 21856 27.8 GDB/MI Breakpoint Commands 21857 =============================== 21858 21859 This section documents GDB/MI commands for manipulating breakpoints. 21860 21861 The `-break-after' Command 21862 -------------------------- 21863 21864 Synopsis 21865 ........ 21866 21867 -break-after NUMBER COUNT 21868 21869 The breakpoint number NUMBER is not in effect until it has been hit 21870 COUNT times. To see how this is reflected in the output of the 21871 `-break-list' command, see the description of the `-break-list' command 21872 below. 21873 21874 GDB Command 21875 ........... 21876 21877 The corresponding GDB command is `ignore'. 21878 21879 Example 21880 ....... 21881 21882 (gdb) 21883 -break-insert main 21884 ^done,bkpt={number="1",type="breakpoint",disp="keep", 21885 enabled="y",addr="0x000100d0",func="main",file="hello.c", 21886 fullname="/home/foo/hello.c",line="5",times="0"} 21887 (gdb) 21888 -break-after 1 3 21889 ~ 21890 ^done 21891 (gdb) 21892 -break-list 21893 ^done,BreakpointTable={nr_rows="1",nr_cols="6", 21894 hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"}, 21895 {width="14",alignment="-1",col_name="type",colhdr="Type"}, 21896 {width="4",alignment="-1",col_name="disp",colhdr="Disp"}, 21897 {width="3",alignment="-1",col_name="enabled",colhdr="Enb"}, 21898 {width="10",alignment="-1",col_name="addr",colhdr="Address"}, 21899 {width="40",alignment="2",col_name="what",colhdr="What"}], 21900 body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y", 21901 addr="0x000100d0",func="main",file="hello.c",fullname="/home/foo/hello.c", 21902 line="5",times="0",ignore="3"}]} 21903 (gdb) 21904 21905 The `-break-commands' Command 21906 ----------------------------- 21907 21908 Synopsis 21909 ........ 21910 21911 -break-commands NUMBER [ COMMAND1 ... COMMANDN ] 21912 21913 Specifies the CLI commands that should be executed when breakpoint 21914 NUMBER is hit. The parameters COMMAND1 to COMMANDN are the commands. 21915 If no command is specified, any previously-set commands are cleared. 21916 *Note Break Commands::. Typical use of this functionality is tracing a 21917 program, that is, printing of values of some variables whenever 21918 breakpoint is hit and then continuing. 21919 21920 GDB Command 21921 ........... 21922 21923 The corresponding GDB command is `commands'. 21924 21925 Example 21926 ....... 21927 21928 (gdb) 21929 -break-insert main 21930 ^done,bkpt={number="1",type="breakpoint",disp="keep", 21931 enabled="y",addr="0x000100d0",func="main",file="hello.c", 21932 fullname="/home/foo/hello.c",line="5",times="0"} 21933 (gdb) 21934 -break-commands 1 "print v" "continue" 21935 ^done 21936 (gdb) 21937 21938 The `-break-condition' Command 21939 ------------------------------ 21940 21941 Synopsis 21942 ........ 21943 21944 -break-condition NUMBER EXPR 21945 21946 Breakpoint NUMBER will stop the program only if the condition in 21947 EXPR is true. The condition becomes part of the `-break-list' output 21948 (see the description of the `-break-list' command below). 21949 21950 GDB Command 21951 ........... 21952 21953 The corresponding GDB command is `condition'. 21954 21955 Example 21956 ....... 21957 21958 (gdb) 21959 -break-condition 1 1 21960 ^done 21961 (gdb) 21962 -break-list 21963 ^done,BreakpointTable={nr_rows="1",nr_cols="6", 21964 hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"}, 21965 {width="14",alignment="-1",col_name="type",colhdr="Type"}, 21966 {width="4",alignment="-1",col_name="disp",colhdr="Disp"}, 21967 {width="3",alignment="-1",col_name="enabled",colhdr="Enb"}, 21968 {width="10",alignment="-1",col_name="addr",colhdr="Address"}, 21969 {width="40",alignment="2",col_name="what",colhdr="What"}], 21970 body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y", 21971 addr="0x000100d0",func="main",file="hello.c",fullname="/home/foo/hello.c", 21972 line="5",cond="1",times="0",ignore="3"}]} 21973 (gdb) 21974 21975 The `-break-delete' Command 21976 --------------------------- 21977 21978 Synopsis 21979 ........ 21980 21981 -break-delete ( BREAKPOINT )+ 21982 21983 Delete the breakpoint(s) whose number(s) are specified in the 21984 argument list. This is obviously reflected in the breakpoint list. 21985 21986 GDB Command 21987 ........... 21988 21989 The corresponding GDB command is `delete'. 21990 21991 Example 21992 ....... 21993 21994 (gdb) 21995 -break-delete 1 21996 ^done 21997 (gdb) 21998 -break-list 21999 ^done,BreakpointTable={nr_rows="0",nr_cols="6", 22000 hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"}, 22001 {width="14",alignment="-1",col_name="type",colhdr="Type"}, 22002 {width="4",alignment="-1",col_name="disp",colhdr="Disp"}, 22003 {width="3",alignment="-1",col_name="enabled",colhdr="Enb"}, 22004 {width="10",alignment="-1",col_name="addr",colhdr="Address"}, 22005 {width="40",alignment="2",col_name="what",colhdr="What"}], 22006 body=[]} 22007 (gdb) 22008 22009 The `-break-disable' Command 22010 ---------------------------- 22011 22012 Synopsis 22013 ........ 22014 22015 -break-disable ( BREAKPOINT )+ 22016 22017 Disable the named BREAKPOINT(s). The field `enabled' in the break 22018 list is now set to `n' for the named BREAKPOINT(s). 22019 22020 GDB Command 22021 ........... 22022 22023 The corresponding GDB command is `disable'. 22024 22025 Example 22026 ....... 22027 22028 (gdb) 22029 -break-disable 2 22030 ^done 22031 (gdb) 22032 -break-list 22033 ^done,BreakpointTable={nr_rows="1",nr_cols="6", 22034 hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"}, 22035 {width="14",alignment="-1",col_name="type",colhdr="Type"}, 22036 {width="4",alignment="-1",col_name="disp",colhdr="Disp"}, 22037 {width="3",alignment="-1",col_name="enabled",colhdr="Enb"}, 22038 {width="10",alignment="-1",col_name="addr",colhdr="Address"}, 22039 {width="40",alignment="2",col_name="what",colhdr="What"}], 22040 body=[bkpt={number="2",type="breakpoint",disp="keep",enabled="n", 22041 addr="0x000100d0",func="main",file="hello.c",fullname="/home/foo/hello.c", 22042 line="5",times="0"}]} 22043 (gdb) 22044 22045 The `-break-enable' Command 22046 --------------------------- 22047 22048 Synopsis 22049 ........ 22050 22051 -break-enable ( BREAKPOINT )+ 22052 22053 Enable (previously disabled) BREAKPOINT(s). 22054 22055 GDB Command 22056 ........... 22057 22058 The corresponding GDB command is `enable'. 22059 22060 Example 22061 ....... 22062 22063 (gdb) 22064 -break-enable 2 22065 ^done 22066 (gdb) 22067 -break-list 22068 ^done,BreakpointTable={nr_rows="1",nr_cols="6", 22069 hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"}, 22070 {width="14",alignment="-1",col_name="type",colhdr="Type"}, 22071 {width="4",alignment="-1",col_name="disp",colhdr="Disp"}, 22072 {width="3",alignment="-1",col_name="enabled",colhdr="Enb"}, 22073 {width="10",alignment="-1",col_name="addr",colhdr="Address"}, 22074 {width="40",alignment="2",col_name="what",colhdr="What"}], 22075 body=[bkpt={number="2",type="breakpoint",disp="keep",enabled="y", 22076 addr="0x000100d0",func="main",file="hello.c",fullname="/home/foo/hello.c", 22077 line="5",times="0"}]} 22078 (gdb) 22079 22080 The `-break-info' Command 22081 ------------------------- 22082 22083 Synopsis 22084 ........ 22085 22086 -break-info BREAKPOINT 22087 22088 Get information about a single breakpoint. 22089 22090 GDB Command 22091 ........... 22092 22093 The corresponding GDB command is `info break BREAKPOINT'. 22094 22095 Example 22096 ....... 22097 22098 N.A. 22099 22100 The `-break-insert' Command 22101 --------------------------- 22102 22103 Synopsis 22104 ........ 22105 22106 -break-insert [ -t ] [ -h ] [ -f ] [ -d ] [ -a ] 22107 [ -c CONDITION ] [ -i IGNORE-COUNT ] 22108 [ -p THREAD ] [ LOCATION ] 22109 22110 If specified, LOCATION, can be one of: 22111 22112 * function 22113 22114 * filename:linenum 22115 22116 * filename:function 22117 22118 * *address 22119 22120 The possible optional parameters of this command are: 22121 22122 `-t' 22123 Insert a temporary breakpoint. 22124 22125 `-h' 22126 Insert a hardware breakpoint. 22127 22128 `-c CONDITION' 22129 Make the breakpoint conditional on CONDITION. 22130 22131 `-i IGNORE-COUNT' 22132 Initialize the IGNORE-COUNT. 22133 22134 `-f' 22135 If LOCATION cannot be parsed (for example if it refers to unknown 22136 files or functions), create a pending breakpoint. Without this 22137 flag, GDB will report an error, and won't create a breakpoint, if 22138 LOCATION cannot be parsed. 22139 22140 `-d' 22141 Create a disabled breakpoint. 22142 22143 `-a' 22144 Create a tracepoint. *Note Tracepoints::. When this parameter is 22145 used together with `-h', a fast tracepoint is created. 22146 22147 Result 22148 ...... 22149 22150 The result is in the form: 22151 22152 ^done,bkpt={number="NUMBER",type="TYPE",disp="del"|"keep", 22153 enabled="y"|"n",addr="HEX",func="FUNCNAME",file="FILENAME", 22154 fullname="FULL_FILENAME",line="LINENO",[thread="THREADNO,] 22155 times="TIMES"} 22156 22157 where NUMBER is the GDB number for this breakpoint, FUNCNAME is the 22158 name of the function where the breakpoint was inserted, FILENAME is the 22159 name of the source file which contains this function, LINENO is the 22160 source line number within that file and TIMES the number of times that 22161 the breakpoint has been hit (always 0 for -break-insert but may be 22162 greater for -break-info or -break-list which use the same output). 22163 22164 Note: this format is open to change. 22165 22166 GDB Command 22167 ........... 22168 22169 The corresponding GDB commands are `break', `tbreak', `hbreak', 22170 `thbreak', and `rbreak'. 22171 22172 Example 22173 ....... 22174 22175 (gdb) 22176 -break-insert main 22177 ^done,bkpt={number="1",addr="0x0001072c",file="recursive2.c", 22178 fullname="/home/foo/recursive2.c,line="4",times="0"} 22179 (gdb) 22180 -break-insert -t foo 22181 ^done,bkpt={number="2",addr="0x00010774",file="recursive2.c", 22182 fullname="/home/foo/recursive2.c,line="11",times="0"} 22183 (gdb) 22184 -break-list 22185 ^done,BreakpointTable={nr_rows="2",nr_cols="6", 22186 hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"}, 22187 {width="14",alignment="-1",col_name="type",colhdr="Type"}, 22188 {width="4",alignment="-1",col_name="disp",colhdr="Disp"}, 22189 {width="3",alignment="-1",col_name="enabled",colhdr="Enb"}, 22190 {width="10",alignment="-1",col_name="addr",colhdr="Address"}, 22191 {width="40",alignment="2",col_name="what",colhdr="What"}], 22192 body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y", 22193 addr="0x0001072c", func="main",file="recursive2.c", 22194 fullname="/home/foo/recursive2.c,"line="4",times="0"}, 22195 bkpt={number="2",type="breakpoint",disp="del",enabled="y", 22196 addr="0x00010774",func="foo",file="recursive2.c", 22197 fullname="/home/foo/recursive2.c",line="11",times="0"}]} 22198 (gdb) 22199 -break-insert -r foo.* 22200 ~int foo(int, int); 22201 ^done,bkpt={number="3",addr="0x00010774",file="recursive2.c, 22202 "fullname="/home/foo/recursive2.c",line="11",times="0"} 22203 (gdb) 22204 22205 The `-break-list' Command 22206 ------------------------- 22207 22208 Synopsis 22209 ........ 22210 22211 -break-list 22212 22213 Displays the list of inserted breakpoints, showing the following 22214 fields: 22215 22216 `Number' 22217 number of the breakpoint 22218 22219 `Type' 22220 type of the breakpoint: `breakpoint' or `watchpoint' 22221 22222 `Disposition' 22223 should the breakpoint be deleted or disabled when it is hit: `keep' 22224 or `nokeep' 22225 22226 `Enabled' 22227 is the breakpoint enabled or no: `y' or `n' 22228 22229 `Address' 22230 memory location at which the breakpoint is set 22231 22232 `What' 22233 logical location of the breakpoint, expressed by function name, 22234 file name, line number 22235 22236 `Times' 22237 number of times the breakpoint has been hit 22238 22239 If there are no breakpoints or watchpoints, the `BreakpointTable' 22240 `body' field is an empty list. 22241 22242 GDB Command 22243 ........... 22244 22245 The corresponding GDB command is `info break'. 22246 22247 Example 22248 ....... 22249 22250 (gdb) 22251 -break-list 22252 ^done,BreakpointTable={nr_rows="2",nr_cols="6", 22253 hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"}, 22254 {width="14",alignment="-1",col_name="type",colhdr="Type"}, 22255 {width="4",alignment="-1",col_name="disp",colhdr="Disp"}, 22256 {width="3",alignment="-1",col_name="enabled",colhdr="Enb"}, 22257 {width="10",alignment="-1",col_name="addr",colhdr="Address"}, 22258 {width="40",alignment="2",col_name="what",colhdr="What"}], 22259 body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y", 22260 addr="0x000100d0",func="main",file="hello.c",line="5",times="0"}, 22261 bkpt={number="2",type="breakpoint",disp="keep",enabled="y", 22262 addr="0x00010114",func="foo",file="hello.c",fullname="/home/foo/hello.c", 22263 line="13",times="0"}]} 22264 (gdb) 22265 22266 Here's an example of the result when there are no breakpoints: 22267 22268 (gdb) 22269 -break-list 22270 ^done,BreakpointTable={nr_rows="0",nr_cols="6", 22271 hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"}, 22272 {width="14",alignment="-1",col_name="type",colhdr="Type"}, 22273 {width="4",alignment="-1",col_name="disp",colhdr="Disp"}, 22274 {width="3",alignment="-1",col_name="enabled",colhdr="Enb"}, 22275 {width="10",alignment="-1",col_name="addr",colhdr="Address"}, 22276 {width="40",alignment="2",col_name="what",colhdr="What"}], 22277 body=[]} 22278 (gdb) 22279 22280 The `-break-passcount' Command 22281 ------------------------------ 22282 22283 Synopsis 22284 ........ 22285 22286 -break-passcount TRACEPOINT-NUMBER PASSCOUNT 22287 22288 Set the passcount for tracepoint TRACEPOINT-NUMBER to PASSCOUNT. If 22289 the breakpoint referred to by TRACEPOINT-NUMBER is not a tracepoint, 22290 error is emitted. This corresponds to CLI command `passcount'. 22291 22292 The `-break-watch' Command 22293 -------------------------- 22294 22295 Synopsis 22296 ........ 22297 22298 -break-watch [ -a | -r ] 22299 22300 Create a watchpoint. With the `-a' option it will create an 22301 "access" watchpoint, i.e., a watchpoint that triggers either on a read 22302 from or on a write to the memory location. With the `-r' option, the 22303 watchpoint created is a "read" watchpoint, i.e., it will trigger only 22304 when the memory location is accessed for reading. Without either of 22305 the options, the watchpoint created is a regular watchpoint, i.e., it 22306 will trigger when the memory location is accessed for writing. *Note 22307 Setting Watchpoints: Set Watchpoints. 22308 22309 Note that `-break-list' will report a single list of watchpoints and 22310 breakpoints inserted. 22311 22312 GDB Command 22313 ........... 22314 22315 The corresponding GDB commands are `watch', `awatch', and `rwatch'. 22316 22317 Example 22318 ....... 22319 22320 Setting a watchpoint on a variable in the `main' function: 22321 22322 (gdb) 22323 -break-watch x 22324 ^done,wpt={number="2",exp="x"} 22325 (gdb) 22326 -exec-continue 22327 ^running 22328 (gdb) 22329 *stopped,reason="watchpoint-trigger",wpt={number="2",exp="x"}, 22330 value={old="-268439212",new="55"}, 22331 frame={func="main",args=[],file="recursive2.c", 22332 fullname="/home/foo/bar/recursive2.c",line="5"} 22333 (gdb) 22334 22335 Setting a watchpoint on a variable local to a function. GDB will 22336 stop the program execution twice: first for the variable changing 22337 value, then for the watchpoint going out of scope. 22338 22339 (gdb) 22340 -break-watch C 22341 ^done,wpt={number="5",exp="C"} 22342 (gdb) 22343 -exec-continue 22344 ^running 22345 (gdb) 22346 *stopped,reason="watchpoint-trigger", 22347 wpt={number="5",exp="C"},value={old="-276895068",new="3"}, 22348 frame={func="callee4",args=[], 22349 file="../../../devo/gdb/testsuite/gdb.mi/basics.c", 22350 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="13"} 22351 (gdb) 22352 -exec-continue 22353 ^running 22354 (gdb) 22355 *stopped,reason="watchpoint-scope",wpnum="5", 22356 frame={func="callee3",args=[{name="strarg", 22357 value="0x11940 \"A string argument.\""}], 22358 file="../../../devo/gdb/testsuite/gdb.mi/basics.c", 22359 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="18"} 22360 (gdb) 22361 22362 Listing breakpoints and watchpoints, at different points in the 22363 program execution. Note that once the watchpoint goes out of scope, it 22364 is deleted. 22365 22366 (gdb) 22367 -break-watch C 22368 ^done,wpt={number="2",exp="C"} 22369 (gdb) 22370 -break-list 22371 ^done,BreakpointTable={nr_rows="2",nr_cols="6", 22372 hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"}, 22373 {width="14",alignment="-1",col_name="type",colhdr="Type"}, 22374 {width="4",alignment="-1",col_name="disp",colhdr="Disp"}, 22375 {width="3",alignment="-1",col_name="enabled",colhdr="Enb"}, 22376 {width="10",alignment="-1",col_name="addr",colhdr="Address"}, 22377 {width="40",alignment="2",col_name="what",colhdr="What"}], 22378 body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y", 22379 addr="0x00010734",func="callee4", 22380 file="../../../devo/gdb/testsuite/gdb.mi/basics.c", 22381 fullname="/home/foo/devo/gdb/testsuite/gdb.mi/basics.c"line="8",times="1"}, 22382 bkpt={number="2",type="watchpoint",disp="keep", 22383 enabled="y",addr="",what="C",times="0"}]} 22384 (gdb) 22385 -exec-continue 22386 ^running 22387 (gdb) 22388 *stopped,reason="watchpoint-trigger",wpt={number="2",exp="C"}, 22389 value={old="-276895068",new="3"}, 22390 frame={func="callee4",args=[], 22391 file="../../../devo/gdb/testsuite/gdb.mi/basics.c", 22392 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="13"} 22393 (gdb) 22394 -break-list 22395 ^done,BreakpointTable={nr_rows="2",nr_cols="6", 22396 hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"}, 22397 {width="14",alignment="-1",col_name="type",colhdr="Type"}, 22398 {width="4",alignment="-1",col_name="disp",colhdr="Disp"}, 22399 {width="3",alignment="-1",col_name="enabled",colhdr="Enb"}, 22400 {width="10",alignment="-1",col_name="addr",colhdr="Address"}, 22401 {width="40",alignment="2",col_name="what",colhdr="What"}], 22402 body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y", 22403 addr="0x00010734",func="callee4", 22404 file="../../../devo/gdb/testsuite/gdb.mi/basics.c", 22405 fullname="/home/foo/devo/gdb/testsuite/gdb.mi/basics.c",line="8",times="1"}, 22406 bkpt={number="2",type="watchpoint",disp="keep", 22407 enabled="y",addr="",what="C",times="-5"}]} 22408 (gdb) 22409 -exec-continue 22410 ^running 22411 ^done,reason="watchpoint-scope",wpnum="2", 22412 frame={func="callee3",args=[{name="strarg", 22413 value="0x11940 \"A string argument.\""}], 22414 file="../../../devo/gdb/testsuite/gdb.mi/basics.c", 22415 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="18"} 22416 (gdb) 22417 -break-list 22418 ^done,BreakpointTable={nr_rows="1",nr_cols="6", 22419 hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"}, 22420 {width="14",alignment="-1",col_name="type",colhdr="Type"}, 22421 {width="4",alignment="-1",col_name="disp",colhdr="Disp"}, 22422 {width="3",alignment="-1",col_name="enabled",colhdr="Enb"}, 22423 {width="10",alignment="-1",col_name="addr",colhdr="Address"}, 22424 {width="40",alignment="2",col_name="what",colhdr="What"}], 22425 body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y", 22426 addr="0x00010734",func="callee4", 22427 file="../../../devo/gdb/testsuite/gdb.mi/basics.c", 22428 fullname="/home/foo/devo/gdb/testsuite/gdb.mi/basics.c",line="8", 22429 times="1"}]} 22430 (gdb) 22431 22432 22433 File: gdb.info, Node: GDB/MI Program Context, Next: GDB/MI Thread Commands, Prev: GDB/MI Breakpoint Commands, Up: GDB/MI 22434 22435 27.9 GDB/MI Program Context 22436 ============================ 22437 22438 The `-exec-arguments' Command 22439 ----------------------------- 22440 22441 Synopsis 22442 ........ 22443 22444 -exec-arguments ARGS 22445 22446 Set the inferior program arguments, to be used in the next 22447 `-exec-run'. 22448 22449 GDB Command 22450 ........... 22451 22452 The corresponding GDB command is `set args'. 22453 22454 Example 22455 ....... 22456 22457 (gdb) 22458 -exec-arguments -v word 22459 ^done 22460 (gdb) 22461 22462 The `-environment-cd' Command 22463 ----------------------------- 22464 22465 Synopsis 22466 ........ 22467 22468 -environment-cd PATHDIR 22469 22470 Set GDB's working directory. 22471 22472 GDB Command 22473 ........... 22474 22475 The corresponding GDB command is `cd'. 22476 22477 Example 22478 ....... 22479 22480 (gdb) 22481 -environment-cd /kwikemart/marge/ezannoni/flathead-dev/devo/gdb 22482 ^done 22483 (gdb) 22484 22485 The `-environment-directory' Command 22486 ------------------------------------ 22487 22488 Synopsis 22489 ........ 22490 22491 -environment-directory [ -r ] [ PATHDIR ]+ 22492 22493 Add directories PATHDIR to beginning of search path for source files. 22494 If the `-r' option is used, the search path is reset to the default 22495 search path. If directories PATHDIR are supplied in addition to the 22496 `-r' option, the search path is first reset and then addition occurs as 22497 normal. Multiple directories may be specified, separated by blanks. 22498 Specifying multiple directories in a single command results in the 22499 directories added to the beginning of the search path in the same order 22500 they were presented in the command. If blanks are needed as part of a 22501 directory name, double-quotes should be used around the name. In the 22502 command output, the path will show up separated by the system 22503 directory-separator character. The directory-separator character must 22504 not be used in any directory name. If no directories are specified, 22505 the current search path is displayed. 22506 22507 GDB Command 22508 ........... 22509 22510 The corresponding GDB command is `dir'. 22511 22512 Example 22513 ....... 22514 22515 (gdb) 22516 -environment-directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb 22517 ^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd" 22518 (gdb) 22519 -environment-directory "" 22520 ^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd" 22521 (gdb) 22522 -environment-directory -r /home/jjohnstn/src/gdb /usr/src 22523 ^done,source-path="/home/jjohnstn/src/gdb:/usr/src:$cdir:$cwd" 22524 (gdb) 22525 -environment-directory -r 22526 ^done,source-path="$cdir:$cwd" 22527 (gdb) 22528 22529 The `-environment-path' Command 22530 ------------------------------- 22531 22532 Synopsis 22533 ........ 22534 22535 -environment-path [ -r ] [ PATHDIR ]+ 22536 22537 Add directories PATHDIR to beginning of search path for object files. 22538 If the `-r' option is used, the search path is reset to the original 22539 search path that existed at gdb start-up. If directories PATHDIR are 22540 supplied in addition to the `-r' option, the search path is first reset 22541 and then addition occurs as normal. Multiple directories may be 22542 specified, separated by blanks. Specifying multiple directories in a 22543 single command results in the directories added to the beginning of the 22544 search path in the same order they were presented in the command. If 22545 blanks are needed as part of a directory name, double-quotes should be 22546 used around the name. In the command output, the path will show up 22547 separated by the system directory-separator character. The 22548 directory-separator character must not be used in any directory name. 22549 If no directories are specified, the current path is displayed. 22550 22551 GDB Command 22552 ........... 22553 22554 The corresponding GDB command is `path'. 22555 22556 Example 22557 ....... 22558 22559 (gdb) 22560 -environment-path 22561 ^done,path="/usr/bin" 22562 (gdb) 22563 -environment-path /kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb /bin 22564 ^done,path="/kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb:/bin:/usr/bin" 22565 (gdb) 22566 -environment-path -r /usr/local/bin 22567 ^done,path="/usr/local/bin:/usr/bin" 22568 (gdb) 22569 22570 The `-environment-pwd' Command 22571 ------------------------------ 22572 22573 Synopsis 22574 ........ 22575 22576 -environment-pwd 22577 22578 Show the current working directory. 22579 22580 GDB Command 22581 ........... 22582 22583 The corresponding GDB command is `pwd'. 22584 22585 Example 22586 ....... 22587 22588 (gdb) 22589 -environment-pwd 22590 ^done,cwd="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb" 22591 (gdb) 22592 22593 22594 File: gdb.info, Node: GDB/MI Thread Commands, Next: GDB/MI Program Execution, Prev: GDB/MI Program Context, Up: GDB/MI 22595 22596 27.10 GDB/MI Thread Commands 22597 ============================ 22598 22599 The `-thread-info' Command 22600 -------------------------- 22601 22602 Synopsis 22603 ........ 22604 22605 -thread-info [ THREAD-ID ] 22606 22607 Reports information about either a specific thread, if the THREAD-ID 22608 parameter is present, or about all threads. When printing information 22609 about all threads, also reports the current thread. 22610 22611 GDB Command 22612 ........... 22613 22614 The `info thread' command prints the same information about all threads. 22615 22616 Result 22617 ...... 22618 22619 The result is a list of threads. The following attributes are defined 22620 for a given thread: 22621 22622 `current' 22623 This field exists only for the current thread. It has the value 22624 `*'. 22625 22626 `id' 22627 The identifier that GDB uses to refer to the thread. 22628 22629 `target-id' 22630 The identifier that the target uses to refer to the thread. 22631 22632 `details' 22633 Extra information about the thread, in a target-specific format. 22634 This field is optional. 22635 22636 `name' 22637 The name of the thread. If the user specified a name using the 22638 `thread name' command, then this name is given. Otherwise, if GDB 22639 can extract the thread name from the target, then that name is 22640 given. If GDB cannot find the thread name, then this field is 22641 omitted. 22642 22643 `frame' 22644 The stack frame currently executing in the thread. 22645 22646 `state' 22647 The thread's state. The `state' field may have the following 22648 values: 22649 22650 `stopped' 22651 The thread is stopped. Frame information is available for 22652 stopped threads. 22653 22654 `running' 22655 The thread is running. There's no frame information for 22656 running threads. 22657 22658 22659 `core' 22660 If GDB can find the CPU core on which this thread is running, then 22661 this field is the core identifier. This field is optional. 22662 22663 22664 Example 22665 ....... 22666 22667 -thread-info 22668 ^done,threads=[ 22669 {id="2",target-id="Thread 0xb7e14b90 (LWP 21257)", 22670 frame={level="0",addr="0xffffe410",func="__kernel_vsyscall", 22671 args=[]},state="running"}, 22672 {id="1",target-id="Thread 0xb7e156b0 (LWP 21254)", 22673 frame={level="0",addr="0x0804891f",func="foo", 22674 args=[{name="i",value="10"}], 22675 file="/tmp/a.c",fullname="/tmp/a.c",line="158"}, 22676 state="running"}], 22677 current-thread-id="1" 22678 (gdb) 22679 22680 The `-thread-list-ids' Command 22681 ------------------------------ 22682 22683 Synopsis 22684 ........ 22685 22686 -thread-list-ids 22687 22688 Produces a list of the currently known GDB thread ids. At the end 22689 of the list it also prints the total number of such threads. 22690 22691 This command is retained for historical reasons, the `-thread-info' 22692 command should be used instead. 22693 22694 GDB Command 22695 ........... 22696 22697 Part of `info threads' supplies the same information. 22698 22699 Example 22700 ....... 22701 22702 (gdb) 22703 -thread-list-ids 22704 ^done,thread-ids={thread-id="3",thread-id="2",thread-id="1"}, 22705 current-thread-id="1",number-of-threads="3" 22706 (gdb) 22707 22708 The `-thread-select' Command 22709 ---------------------------- 22710 22711 Synopsis 22712 ........ 22713 22714 -thread-select THREADNUM 22715 22716 Make THREADNUM the current thread. It prints the number of the new 22717 current thread, and the topmost frame for that thread. 22718 22719 This command is deprecated in favor of explicitly using the 22720 `--thread' option to each command. 22721 22722 GDB Command 22723 ........... 22724 22725 The corresponding GDB command is `thread'. 22726 22727 Example 22728 ....... 22729 22730 (gdb) 22731 -exec-next 22732 ^running 22733 (gdb) 22734 *stopped,reason="end-stepping-range",thread-id="2",line="187", 22735 file="../../../devo/gdb/testsuite/gdb.threads/linux-dp.c" 22736 (gdb) 22737 -thread-list-ids 22738 ^done, 22739 thread-ids={thread-id="3",thread-id="2",thread-id="1"}, 22740 number-of-threads="3" 22741 (gdb) 22742 -thread-select 3 22743 ^done,new-thread-id="3", 22744 frame={level="0",func="vprintf", 22745 args=[{name="format",value="0x8048e9c \"%*s%c %d %c\\n\""}, 22746 {name="arg",value="0x2"}],file="vprintf.c",line="31"} 22747 (gdb) 22748 22749 22750 File: gdb.info, Node: GDB/MI Program Execution, Next: GDB/MI Stack Manipulation, Prev: GDB/MI Thread Commands, Up: GDB/MI 22751 22752 27.11 GDB/MI Program Execution 22753 ============================== 22754 22755 These are the asynchronous commands which generate the out-of-band 22756 record `*stopped'. Currently GDB only really executes asynchronously 22757 with remote targets and this interaction is mimicked in other cases. 22758 22759 The `-exec-continue' Command 22760 ---------------------------- 22761 22762 Synopsis 22763 ........ 22764 22765 -exec-continue [--reverse] [--all|--thread-group N] 22766 22767 Resumes the execution of the inferior program, which will continue 22768 to execute until it reaches a debugger stop event. If the `--reverse' 22769 option is specified, execution resumes in reverse until it reaches a 22770 stop event. Stop events may include 22771 * breakpoints or watchpoints 22772 22773 * signals or exceptions 22774 22775 * the end of the process (or its beginning under `--reverse') 22776 22777 * the end or beginning of a replay log if one is being used. 22778 In all-stop mode (*note All-Stop Mode::), may resume only one 22779 thread, or all threads, depending on the value of the 22780 `scheduler-locking' variable. If `--all' is specified, all threads (in 22781 all inferiors) will be resumed. The `--all' option is ignored in 22782 all-stop mode. If the `--thread-group' options is specified, then all 22783 threads in that thread group are resumed. 22784 22785 GDB Command 22786 ........... 22787 22788 The corresponding GDB corresponding is `continue'. 22789 22790 Example 22791 ....... 22792 22793 -exec-continue 22794 ^running 22795 (gdb) 22796 @Hello world 22797 *stopped,reason="breakpoint-hit",disp="keep",bkptno="2",frame={ 22798 func="foo",args=[],file="hello.c",fullname="/home/foo/bar/hello.c", 22799 line="13"} 22800 (gdb) 22801 22802 The `-exec-finish' Command 22803 -------------------------- 22804 22805 Synopsis 22806 ........ 22807 22808 -exec-finish [--reverse] 22809 22810 Resumes the execution of the inferior program until the current 22811 function is exited. Displays the results returned by the function. If 22812 the `--reverse' option is specified, resumes the reverse execution of 22813 the inferior program until the point where current function was called. 22814 22815 GDB Command 22816 ........... 22817 22818 The corresponding GDB command is `finish'. 22819 22820 Example 22821 ....... 22822 22823 Function returning `void'. 22824 22825 -exec-finish 22826 ^running 22827 (gdb) 22828 @hello from foo 22829 *stopped,reason="function-finished",frame={func="main",args=[], 22830 file="hello.c",fullname="/home/foo/bar/hello.c",line="7"} 22831 (gdb) 22832 22833 Function returning other than `void'. The name of the internal GDB 22834 variable storing the result is printed, together with the value itself. 22835 22836 -exec-finish 22837 ^running 22838 (gdb) 22839 *stopped,reason="function-finished",frame={addr="0x000107b0",func="foo", 22840 args=[{name="a",value="1"],{name="b",value="9"}}, 22841 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}, 22842 gdb-result-var="$1",return-value="0" 22843 (gdb) 22844 22845 The `-exec-interrupt' Command 22846 ----------------------------- 22847 22848 Synopsis 22849 ........ 22850 22851 -exec-interrupt [--all|--thread-group N] 22852 22853 Interrupts the background execution of the target. Note how the 22854 token associated with the stop message is the one for the execution 22855 command that has been interrupted. The token for the interrupt itself 22856 only appears in the `^done' output. If the user is trying to interrupt 22857 a non-running program, an error message will be printed. 22858 22859 Note that when asynchronous execution is enabled, this command is 22860 asynchronous just like other execution commands. That is, first the 22861 `^done' response will be printed, and the target stop will be reported 22862 after that using the `*stopped' notification. 22863 22864 In non-stop mode, only the context thread is interrupted by default. 22865 All threads (in all inferiors) will be interrupted if the `--all' 22866 option is specified. If the `--thread-group' option is specified, all 22867 threads in that group will be interrupted. 22868 22869 GDB Command 22870 ........... 22871 22872 The corresponding GDB command is `interrupt'. 22873 22874 Example 22875 ....... 22876 22877 (gdb) 22878 111-exec-continue 22879 111^running 22880 22881 (gdb) 22882 222-exec-interrupt 22883 222^done 22884 (gdb) 22885 111*stopped,signal-name="SIGINT",signal-meaning="Interrupt", 22886 frame={addr="0x00010140",func="foo",args=[],file="try.c", 22887 fullname="/home/foo/bar/try.c",line="13"} 22888 (gdb) 22889 22890 (gdb) 22891 -exec-interrupt 22892 ^error,msg="mi_cmd_exec_interrupt: Inferior not executing." 22893 (gdb) 22894 22895 The `-exec-jump' Command 22896 ------------------------ 22897 22898 Synopsis 22899 ........ 22900 22901 -exec-jump LOCATION 22902 22903 Resumes execution of the inferior program at the location specified 22904 by parameter. *Note Specify Location::, for a description of the 22905 different forms of LOCATION. 22906 22907 GDB Command 22908 ........... 22909 22910 The corresponding GDB command is `jump'. 22911 22912 Example 22913 ....... 22914 22915 -exec-jump foo.c:10 22916 *running,thread-id="all" 22917 ^running 22918 22919 The `-exec-next' Command 22920 ------------------------ 22921 22922 Synopsis 22923 ........ 22924 22925 -exec-next [--reverse] 22926 22927 Resumes execution of the inferior program, stopping when the 22928 beginning of the next source line is reached. 22929 22930 If the `--reverse' option is specified, resumes reverse execution of 22931 the inferior program, stopping at the beginning of the previous source 22932 line. If you issue this command on the first line of a function, it 22933 will take you back to the caller of that function, to the source line 22934 where the function was called. 22935 22936 GDB Command 22937 ........... 22938 22939 The corresponding GDB command is `next'. 22940 22941 Example 22942 ....... 22943 22944 -exec-next 22945 ^running 22946 (gdb) 22947 *stopped,reason="end-stepping-range",line="8",file="hello.c" 22948 (gdb) 22949 22950 The `-exec-next-instruction' Command 22951 ------------------------------------ 22952 22953 Synopsis 22954 ........ 22955 22956 -exec-next-instruction [--reverse] 22957 22958 Executes one machine instruction. If the instruction is a function 22959 call, continues until the function returns. If the program stops at an 22960 instruction in the middle of a source line, the address will be printed 22961 as well. 22962 22963 If the `--reverse' option is specified, resumes reverse execution of 22964 the inferior program, stopping at the previous instruction. If the 22965 previously executed instruction was a return from another function, it 22966 will continue to execute in reverse until the call to that function 22967 (from the current stack frame) is reached. 22968 22969 GDB Command 22970 ........... 22971 22972 The corresponding GDB command is `nexti'. 22973 22974 Example 22975 ....... 22976 22977 (gdb) 22978 -exec-next-instruction 22979 ^running 22980 22981 (gdb) 22982 *stopped,reason="end-stepping-range", 22983 addr="0x000100d4",line="5",file="hello.c" 22984 (gdb) 22985 22986 The `-exec-return' Command 22987 -------------------------- 22988 22989 Synopsis 22990 ........ 22991 22992 -exec-return 22993 22994 Makes current function return immediately. Doesn't execute the 22995 inferior. Displays the new current frame. 22996 22997 GDB Command 22998 ........... 22999 23000 The corresponding GDB command is `return'. 23001 23002 Example 23003 ....... 23004 23005 (gdb) 23006 200-break-insert callee4 23007 200^done,bkpt={number="1",addr="0x00010734", 23008 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="8"} 23009 (gdb) 23010 000-exec-run 23011 000^running 23012 (gdb) 23013 000*stopped,reason="breakpoint-hit",disp="keep",bkptno="1", 23014 frame={func="callee4",args=[], 23015 file="../../../devo/gdb/testsuite/gdb.mi/basics.c", 23016 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="8"} 23017 (gdb) 23018 205-break-delete 23019 205^done 23020 (gdb) 23021 111-exec-return 23022 111^done,frame={level="0",func="callee3", 23023 args=[{name="strarg", 23024 value="0x11940 \"A string argument.\""}], 23025 file="../../../devo/gdb/testsuite/gdb.mi/basics.c", 23026 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="18"} 23027 (gdb) 23028 23029 The `-exec-run' Command 23030 ----------------------- 23031 23032 Synopsis 23033 ........ 23034 23035 -exec-run [--all | --thread-group N] 23036 23037 Starts execution of the inferior from the beginning. The inferior 23038 executes until either a breakpoint is encountered or the program exits. 23039 In the latter case the output will include an exit code, if the program 23040 has exited exceptionally. 23041 23042 When no option is specified, the current inferior is started. If the 23043 `--thread-group' option is specified, it should refer to a thread group 23044 of type `process', and that thread group will be started. If the 23045 `--all' option is specified, then all inferiors will be started. 23046 23047 GDB Command 23048 ........... 23049 23050 The corresponding GDB command is `run'. 23051 23052 Examples 23053 ........ 23054 23055 (gdb) 23056 -break-insert main 23057 ^done,bkpt={number="1",addr="0x0001072c",file="recursive2.c",line="4"} 23058 (gdb) 23059 -exec-run 23060 ^running 23061 (gdb) 23062 *stopped,reason="breakpoint-hit",disp="keep",bkptno="1", 23063 frame={func="main",args=[],file="recursive2.c", 23064 fullname="/home/foo/bar/recursive2.c",line="4"} 23065 (gdb) 23066 23067 Program exited normally: 23068 23069 (gdb) 23070 -exec-run 23071 ^running 23072 (gdb) 23073 x = 55 23074 *stopped,reason="exited-normally" 23075 (gdb) 23076 23077 Program exited exceptionally: 23078 23079 (gdb) 23080 -exec-run 23081 ^running 23082 (gdb) 23083 x = 55 23084 *stopped,reason="exited",exit-code="01" 23085 (gdb) 23086 23087 Another way the program can terminate is if it receives a signal 23088 such as `SIGINT'. In this case, GDB/MI displays this: 23089 23090 (gdb) 23091 *stopped,reason="exited-signalled",signal-name="SIGINT", 23092 signal-meaning="Interrupt" 23093 23094 The `-exec-step' Command 23095 ------------------------ 23096 23097 Synopsis 23098 ........ 23099 23100 -exec-step [--reverse] 23101 23102 Resumes execution of the inferior program, stopping when the 23103 beginning of the next source line is reached, if the next source line 23104 is not a function call. If it is, stop at the first instruction of the 23105 called function. If the `--reverse' option is specified, resumes 23106 reverse execution of the inferior program, stopping at the beginning of 23107 the previously executed source line. 23108 23109 GDB Command 23110 ........... 23111 23112 The corresponding GDB command is `step'. 23113 23114 Example 23115 ....... 23116 23117 Stepping into a function: 23118 23119 -exec-step 23120 ^running 23121 (gdb) 23122 *stopped,reason="end-stepping-range", 23123 frame={func="foo",args=[{name="a",value="10"}, 23124 {name="b",value="0"}],file="recursive2.c", 23125 fullname="/home/foo/bar/recursive2.c",line="11"} 23126 (gdb) 23127 23128 Regular stepping: 23129 23130 -exec-step 23131 ^running 23132 (gdb) 23133 *stopped,reason="end-stepping-range",line="14",file="recursive2.c" 23134 (gdb) 23135 23136 The `-exec-step-instruction' Command 23137 ------------------------------------ 23138 23139 Synopsis 23140 ........ 23141 23142 -exec-step-instruction [--reverse] 23143 23144 Resumes the inferior which executes one machine instruction. If the 23145 `--reverse' option is specified, resumes reverse execution of the 23146 inferior program, stopping at the previously executed instruction. The 23147 output, once GDB has stopped, will vary depending on whether we have 23148 stopped in the middle of a source line or not. In the former case, the 23149 address at which the program stopped will be printed as well. 23150 23151 GDB Command 23152 ........... 23153 23154 The corresponding GDB command is `stepi'. 23155 23156 Example 23157 ....... 23158 23159 (gdb) 23160 -exec-step-instruction 23161 ^running 23162 23163 (gdb) 23164 *stopped,reason="end-stepping-range", 23165 frame={func="foo",args=[],file="try.c", 23166 fullname="/home/foo/bar/try.c",line="10"} 23167 (gdb) 23168 -exec-step-instruction 23169 ^running 23170 23171 (gdb) 23172 *stopped,reason="end-stepping-range", 23173 frame={addr="0x000100f4",func="foo",args=[],file="try.c", 23174 fullname="/home/foo/bar/try.c",line="10"} 23175 (gdb) 23176 23177 The `-exec-until' Command 23178 ------------------------- 23179 23180 Synopsis 23181 ........ 23182 23183 -exec-until [ LOCATION ] 23184 23185 Executes the inferior until the LOCATION specified in the argument 23186 is reached. If there is no argument, the inferior executes until a 23187 source line greater than the current one is reached. The reason for 23188 stopping in this case will be `location-reached'. 23189 23190 GDB Command 23191 ........... 23192 23193 The corresponding GDB command is `until'. 23194 23195 Example 23196 ....... 23197 23198 (gdb) 23199 -exec-until recursive2.c:6 23200 ^running 23201 (gdb) 23202 x = 55 23203 *stopped,reason="location-reached",frame={func="main",args=[], 23204 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="6"} 23205 (gdb) 23206 23207 23208 File: gdb.info, Node: GDB/MI Stack Manipulation, Next: GDB/MI Variable Objects, Prev: GDB/MI Program Execution, Up: GDB/MI 23209 23210 27.12 GDB/MI Stack Manipulation Commands 23211 ======================================== 23212 23213 The `-stack-info-frame' Command 23214 ------------------------------- 23215 23216 Synopsis 23217 ........ 23218 23219 -stack-info-frame 23220 23221 Get info on the selected frame. 23222 23223 GDB Command 23224 ........... 23225 23226 The corresponding GDB command is `info frame' or `frame' (without 23227 arguments). 23228 23229 Example 23230 ....... 23231 23232 (gdb) 23233 -stack-info-frame 23234 ^done,frame={level="1",addr="0x0001076c",func="callee3", 23235 file="../../../devo/gdb/testsuite/gdb.mi/basics.c", 23236 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="17"} 23237 (gdb) 23238 23239 The `-stack-info-depth' Command 23240 ------------------------------- 23241 23242 Synopsis 23243 ........ 23244 23245 -stack-info-depth [ MAX-DEPTH ] 23246 23247 Return the depth of the stack. If the integer argument MAX-DEPTH is 23248 specified, do not count beyond MAX-DEPTH frames. 23249 23250 GDB Command 23251 ........... 23252 23253 There's no equivalent GDB command. 23254 23255 Example 23256 ....... 23257 23258 For a stack with frame levels 0 through 11: 23259 23260 (gdb) 23261 -stack-info-depth 23262 ^done,depth="12" 23263 (gdb) 23264 -stack-info-depth 4 23265 ^done,depth="4" 23266 (gdb) 23267 -stack-info-depth 12 23268 ^done,depth="12" 23269 (gdb) 23270 -stack-info-depth 11 23271 ^done,depth="11" 23272 (gdb) 23273 -stack-info-depth 13 23274 ^done,depth="12" 23275 (gdb) 23276 23277 The `-stack-list-arguments' Command 23278 ----------------------------------- 23279 23280 Synopsis 23281 ........ 23282 23283 -stack-list-arguments PRINT-VALUES 23284 [ LOW-FRAME HIGH-FRAME ] 23285 23286 Display a list of the arguments for the frames between LOW-FRAME and 23287 HIGH-FRAME (inclusive). If LOW-FRAME and HIGH-FRAME are not provided, 23288 list the arguments for the whole call stack. If the two arguments are 23289 equal, show the single frame at the corresponding level. It is an 23290 error if LOW-FRAME is larger than the actual number of frames. On the 23291 other hand, HIGH-FRAME may be larger than the actual number of frames, 23292 in which case only existing frames will be returned. 23293 23294 If PRINT-VALUES is 0 or `--no-values', print only the names of the 23295 variables; if it is 1 or `--all-values', print also their values; and 23296 if it is 2 or `--simple-values', print the name, type and value for 23297 simple data types, and the name and type for arrays, structures and 23298 unions. 23299 23300 Use of this command to obtain arguments in a single frame is 23301 deprecated in favor of the `-stack-list-variables' command. 23302 23303 GDB Command 23304 ........... 23305 23306 GDB does not have an equivalent command. `gdbtk' has a `gdb_get_args' 23307 command which partially overlaps with the functionality of 23308 `-stack-list-arguments'. 23309 23310 Example 23311 ....... 23312 23313 (gdb) 23314 -stack-list-frames 23315 ^done, 23316 stack=[ 23317 frame={level="0",addr="0x00010734",func="callee4", 23318 file="../../../devo/gdb/testsuite/gdb.mi/basics.c", 23319 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="8"}, 23320 frame={level="1",addr="0x0001076c",func="callee3", 23321 file="../../../devo/gdb/testsuite/gdb.mi/basics.c", 23322 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="17"}, 23323 frame={level="2",addr="0x0001078c",func="callee2", 23324 file="../../../devo/gdb/testsuite/gdb.mi/basics.c", 23325 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="22"}, 23326 frame={level="3",addr="0x000107b4",func="callee1", 23327 file="../../../devo/gdb/testsuite/gdb.mi/basics.c", 23328 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="27"}, 23329 frame={level="4",addr="0x000107e0",func="main", 23330 file="../../../devo/gdb/testsuite/gdb.mi/basics.c", 23331 fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="32"}] 23332 (gdb) 23333 -stack-list-arguments 0 23334 ^done, 23335 stack-args=[ 23336 frame={level="0",args=[]}, 23337 frame={level="1",args=[name="strarg"]}, 23338 frame={level="2",args=[name="intarg",name="strarg"]}, 23339 frame={level="3",args=[name="intarg",name="strarg",name="fltarg"]}, 23340 frame={level="4",args=[]}] 23341 (gdb) 23342 -stack-list-arguments 1 23343 ^done, 23344 stack-args=[ 23345 frame={level="0",args=[]}, 23346 frame={level="1", 23347 args=[{name="strarg",value="0x11940 \"A string argument.\""}]}, 23348 frame={level="2",args=[ 23349 {name="intarg",value="2"}, 23350 {name="strarg",value="0x11940 \"A string argument.\""}]}, 23351 {frame={level="3",args=[ 23352 {name="intarg",value="2"}, 23353 {name="strarg",value="0x11940 \"A string argument.\""}, 23354 {name="fltarg",value="3.5"}]}, 23355 frame={level="4",args=[]}] 23356 (gdb) 23357 -stack-list-arguments 0 2 2 23358 ^done,stack-args=[frame={level="2",args=[name="intarg",name="strarg"]}] 23359 (gdb) 23360 -stack-list-arguments 1 2 2 23361 ^done,stack-args=[frame={level="2", 23362 args=[{name="intarg",value="2"}, 23363 {name="strarg",value="0x11940 \"A string argument.\""}]}] 23364 (gdb) 23365 23366 The `-stack-list-frames' Command 23367 -------------------------------- 23368 23369 Synopsis 23370 ........ 23371 23372 -stack-list-frames [ LOW-FRAME HIGH-FRAME ] 23373 23374 List the frames currently on the stack. For each frame it displays 23375 the following info: 23376 23377 `LEVEL' 23378 The frame number, 0 being the topmost frame, i.e., the innermost 23379 function. 23380 23381 `ADDR' 23382 The `$pc' value for that frame. 23383 23384 `FUNC' 23385 Function name. 23386 23387 `FILE' 23388 File name of the source file where the function lives. 23389 23390 `FULLNAME' 23391 The full file name of the source file where the function lives. 23392 23393 `LINE' 23394 Line number corresponding to the `$pc'. 23395 23396 `FROM' 23397 The shared library where this function is defined. This is only 23398 given if the frame's function is not known. 23399 23400 If invoked without arguments, this command prints a backtrace for the 23401 whole stack. If given two integer arguments, it shows the frames whose 23402 levels are between the two arguments (inclusive). If the two arguments 23403 are equal, it shows the single frame at the corresponding level. It is 23404 an error if LOW-FRAME is larger than the actual number of frames. On 23405 the other hand, HIGH-FRAME may be larger than the actual number of 23406 frames, in which case only existing frames will be returned. 23407 23408 GDB Command 23409 ........... 23410 23411 The corresponding GDB commands are `backtrace' and `where'. 23412 23413 Example 23414 ....... 23415 23416 Full stack backtrace: 23417 23418 (gdb) 23419 -stack-list-frames 23420 ^done,stack= 23421 [frame={level="0",addr="0x0001076c",func="foo", 23422 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="11"}, 23423 frame={level="1",addr="0x000107a4",func="foo", 23424 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}, 23425 frame={level="2",addr="0x000107a4",func="foo", 23426 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}, 23427 frame={level="3",addr="0x000107a4",func="foo", 23428 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}, 23429 frame={level="4",addr="0x000107a4",func="foo", 23430 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}, 23431 frame={level="5",addr="0x000107a4",func="foo", 23432 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}, 23433 frame={level="6",addr="0x000107a4",func="foo", 23434 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}, 23435 frame={level="7",addr="0x000107a4",func="foo", 23436 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}, 23437 frame={level="8",addr="0x000107a4",func="foo", 23438 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}, 23439 frame={level="9",addr="0x000107a4",func="foo", 23440 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}, 23441 frame={level="10",addr="0x000107a4",func="foo", 23442 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}, 23443 frame={level="11",addr="0x00010738",func="main", 23444 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="4"}] 23445 (gdb) 23446 23447 Show frames between LOW_FRAME and HIGH_FRAME: 23448 23449 (gdb) 23450 -stack-list-frames 3 5 23451 ^done,stack= 23452 [frame={level="3",addr="0x000107a4",func="foo", 23453 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}, 23454 frame={level="4",addr="0x000107a4",func="foo", 23455 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}, 23456 frame={level="5",addr="0x000107a4",func="foo", 23457 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}] 23458 (gdb) 23459 23460 Show a single frame: 23461 23462 (gdb) 23463 -stack-list-frames 3 3 23464 ^done,stack= 23465 [frame={level="3",addr="0x000107a4",func="foo", 23466 file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14"}] 23467 (gdb) 23468 23469 The `-stack-list-locals' Command 23470 -------------------------------- 23471 23472 Synopsis 23473 ........ 23474 23475 -stack-list-locals PRINT-VALUES 23476 23477 Display the local variable names for the selected frame. If 23478 PRINT-VALUES is 0 or `--no-values', print only the names of the 23479 variables; if it is 1 or `--all-values', print also their values; and 23480 if it is 2 or `--simple-values', print the name, type and value for 23481 simple data types, and the name and type for arrays, structures and 23482 unions. In this last case, a frontend can immediately display the 23483 value of simple data types and create variable objects for other data 23484 types when the user wishes to explore their values in more detail. 23485 23486 This command is deprecated in favor of the `-stack-list-variables' 23487 command. 23488 23489 GDB Command 23490 ........... 23491 23492 `info locals' in GDB, `gdb_get_locals' in `gdbtk'. 23493 23494 Example 23495 ....... 23496 23497 (gdb) 23498 -stack-list-locals 0 23499 ^done,locals=[name="A",name="B",name="C"] 23500 (gdb) 23501 -stack-list-locals --all-values 23502 ^done,locals=[{name="A",value="1"},{name="B",value="2"}, 23503 {name="C",value="{1, 2, 3}"}] 23504 -stack-list-locals --simple-values 23505 ^done,locals=[{name="A",type="int",value="1"}, 23506 {name="B",type="int",value="2"},{name="C",type="int [3]"}] 23507 (gdb) 23508 23509 The `-stack-list-variables' Command 23510 ----------------------------------- 23511 23512 Synopsis 23513 ........ 23514 23515 -stack-list-variables PRINT-VALUES 23516 23517 Display the names of local variables and function arguments for the 23518 selected frame. If PRINT-VALUES is 0 or `--no-values', print only the 23519 names of the variables; if it is 1 or `--all-values', print also their 23520 values; and if it is 2 or `--simple-values', print the name, type and 23521 value for simple data types, and the name and type for arrays, 23522 structures and unions. 23523 23524 Example 23525 ....... 23526 23527 (gdb) 23528 -stack-list-variables --thread 1 --frame 0 --all-values 23529 ^done,variables=[{name="x",value="11"},{name="s",value="{a = 1, b = 2}"}] 23530 (gdb) 23531 23532 The `-stack-select-frame' Command 23533 --------------------------------- 23534 23535 Synopsis 23536 ........ 23537 23538 -stack-select-frame FRAMENUM 23539 23540 Change the selected frame. Select a different frame FRAMENUM on the 23541 stack. 23542 23543 This command in deprecated in favor of passing the `--frame' option 23544 to every command. 23545 23546 GDB Command 23547 ........... 23548 23549 The corresponding GDB commands are `frame', `up', `down', 23550 `select-frame', `up-silent', and `down-silent'. 23551 23552 Example 23553 ....... 23554 23555 (gdb) 23556 -stack-select-frame 2 23557 ^done 23558 (gdb) 23559 23560 23561 File: gdb.info, Node: GDB/MI Variable Objects, Next: GDB/MI Data Manipulation, Prev: GDB/MI Stack Manipulation, Up: GDB/MI 23562 23563 27.13 GDB/MI Variable Objects 23564 ============================= 23565 23566 Introduction to Variable Objects 23567 -------------------------------- 23568 23569 Variable objects are "object-oriented" MI interface for examining and 23570 changing values of expressions. Unlike some other MI interfaces that 23571 work with expressions, variable objects are specifically designed for 23572 simple and efficient presentation in the frontend. A variable object 23573 is identified by string name. When a variable object is created, the 23574 frontend specifies the expression for that variable object. The 23575 expression can be a simple variable, or it can be an arbitrary complex 23576 expression, and can even involve CPU registers. After creating a 23577 variable object, the frontend can invoke other variable object 23578 operations--for example to obtain or change the value of a variable 23579 object, or to change display format. 23580 23581 Variable objects have hierarchical tree structure. Any variable 23582 object that corresponds to a composite type, such as structure in C, has 23583 a number of child variable objects, for example corresponding to each 23584 element of a structure. A child variable object can itself have 23585 children, recursively. Recursion ends when we reach leaf variable 23586 objects, which always have built-in types. Child variable objects are 23587 created only by explicit request, so if a frontend is not interested in 23588 the children of a particular variable object, no child will be created. 23589 23590 For a leaf variable object it is possible to obtain its value as a 23591 string, or set the value from a string. String value can be also 23592 obtained for a non-leaf variable object, but it's generally a string 23593 that only indicates the type of the object, and does not list its 23594 contents. Assignment to a non-leaf variable object is not allowed. 23595 23596 A frontend does not need to read the values of all variable objects 23597 each time the program stops. Instead, MI provides an update command 23598 that lists all variable objects whose values has changed since the last 23599 update operation. This considerably reduces the amount of data that 23600 must be transferred to the frontend. As noted above, children variable 23601 objects are created on demand, and only leaf variable objects have a 23602 real value. As result, gdb will read target memory only for leaf 23603 variables that frontend has created. 23604 23605 The automatic update is not always desirable. For example, a 23606 frontend might want to keep a value of some expression for future 23607 reference, and never update it. For another example, fetching memory 23608 is relatively slow for embedded targets, so a frontend might want to 23609 disable automatic update for the variables that are either not visible 23610 on the screen, or "closed". This is possible using so called "frozen 23611 variable objects". Such variable objects are never implicitly updated. 23612 23613 Variable objects can be either "fixed" or "floating". For the fixed 23614 variable object, the expression is parsed when the variable object is 23615 created, including associating identifiers to specific variables. The 23616 meaning of expression never changes. For a floating variable object 23617 the values of variables whose names appear in the expressions are 23618 re-evaluated every time in the context of the current frame. Consider 23619 this example: 23620 23621 void do_work(...) 23622 { 23623 struct work_state state; 23624 23625 if (...) 23626 do_work(...); 23627 } 23628 23629 If a fixed variable object for the `state' variable is created in 23630 this function, and we enter the recursive call, the the variable object 23631 will report the value of `state' in the top-level `do_work' invocation. 23632 On the other hand, a floating variable object will report the value of 23633 `state' in the current frame. 23634 23635 If an expression specified when creating a fixed variable object 23636 refers to a local variable, the variable object becomes bound to the 23637 thread and frame in which the variable object is created. When such 23638 variable object is updated, GDB makes sure that the thread/frame 23639 combination the variable object is bound to still exists, and 23640 re-evaluates the variable object in context of that thread/frame. 23641 23642 The following is the complete set of GDB/MI operations defined to 23643 access this functionality: 23644 23645 *Operation* *Description* 23646 `-enable-pretty-printing' enable Python-based pretty-printing 23647 `-var-create' create a variable object 23648 `-var-delete' delete the variable object and/or its 23649 children 23650 `-var-set-format' set the display format of this variable 23651 `-var-show-format' show the display format of this variable 23652 `-var-info-num-children' tells how many children this object has 23653 `-var-list-children' return a list of the object's children 23654 `-var-info-type' show the type of this variable object 23655 `-var-info-expression' print parent-relative expression that this 23656 variable object represents 23657 `-var-info-path-expression' print full expression that this variable 23658 object represents 23659 `-var-show-attributes' is this variable editable? does it exist 23660 here? 23661 `-var-evaluate-expression' get the value of this variable 23662 `-var-assign' set the value of this variable 23663 `-var-update' update the variable and its children 23664 `-var-set-frozen' set frozeness attribute 23665 `-var-set-update-range' set range of children to display on update 23666 23667 In the next subsection we describe each operation in detail and 23668 suggest how it can be used. 23669 23670 Description And Use of Operations on Variable Objects 23671 ----------------------------------------------------- 23672 23673 The `-enable-pretty-printing' Command 23674 ------------------------------------- 23675 23676 -enable-pretty-printing 23677 23678 GDB allows Python-based visualizers to affect the output of the MI 23679 variable object commands. However, because there was no way to 23680 implement this in a fully backward-compatible way, a front end must 23681 request that this functionality be enabled. 23682 23683 Once enabled, this feature cannot be disabled. 23684 23685 Note that if Python support has not been compiled into GDB, this 23686 command will still succeed (and do nothing). 23687 23688 This feature is currently (as of GDB 7.0) experimental, and may work 23689 differently in future versions of GDB. 23690 23691 The `-var-create' Command 23692 ------------------------- 23693 23694 Synopsis 23695 ........ 23696 23697 -var-create {NAME | "-"} 23698 {FRAME-ADDR | "*" | "@"} EXPRESSION 23699 23700 This operation creates a variable object, which allows the 23701 monitoring of a variable, the result of an expression, a memory cell or 23702 a CPU register. 23703 23704 The NAME parameter is the string by which the object can be 23705 referenced. It must be unique. If `-' is specified, the varobj system 23706 will generate a string "varNNNNNN" automatically. It will be unique 23707 provided that one does not specify NAME of that format. The command 23708 fails if a duplicate name is found. 23709 23710 The frame under which the expression should be evaluated can be 23711 specified by FRAME-ADDR. A `*' indicates that the current frame should 23712 be used. A `@' indicates that a floating variable object must be 23713 created. 23714 23715 EXPRESSION is any expression valid on the current language set (must 23716 not begin with a `*'), or one of the following: 23717 23718 * `*ADDR', where ADDR is the address of a memory cell 23719 23720 * `*ADDR-ADDR' -- a memory address range (TBD) 23721 23722 * `$REGNAME' -- a CPU register name 23723 23724 A varobj's contents may be provided by a Python-based 23725 pretty-printer. In this case the varobj is known as a "dynamic 23726 varobj". Dynamic varobjs have slightly different semantics in some 23727 cases. If the `-enable-pretty-printing' command is not sent, then GDB 23728 will never create a dynamic varobj. This ensures backward 23729 compatibility for existing clients. 23730 23731 Result 23732 ...... 23733 23734 This operation returns attributes of the newly-created varobj. These 23735 are: 23736 23737 `name' 23738 The name of the varobj. 23739 23740 `numchild' 23741 The number of children of the varobj. This number is not 23742 necessarily reliable for a dynamic varobj. Instead, you must 23743 examine the `has_more' attribute. 23744 23745 `value' 23746 The varobj's scalar value. For a varobj whose type is some sort of 23747 aggregate (e.g., a `struct'), or for a dynamic varobj, this value 23748 will not be interesting. 23749 23750 `type' 23751 The varobj's type. This is a string representation of the type, as 23752 would be printed by the GDB CLI. 23753 23754 `thread-id' 23755 If a variable object is bound to a specific thread, then this is 23756 the thread's identifier. 23757 23758 `has_more' 23759 For a dynamic varobj, this indicates whether there appear to be any 23760 children available. For a non-dynamic varobj, this will be 0. 23761 23762 `dynamic' 23763 This attribute will be present and have the value `1' if the 23764 varobj is a dynamic varobj. If the varobj is not a dynamic varobj, 23765 then this attribute will not be present. 23766 23767 `displayhint' 23768 A dynamic varobj can supply a display hint to the front end. The 23769 value comes directly from the Python pretty-printer object's 23770 `display_hint' method. *Note Pretty Printing API::. 23771 23772 Typical output will look like this: 23773 23774 name="NAME",numchild="N",type="TYPE",thread-id="M", 23775 has_more="HAS_MORE" 23776 23777 The `-var-delete' Command 23778 ------------------------- 23779 23780 Synopsis 23781 ........ 23782 23783 -var-delete [ -c ] NAME 23784 23785 Deletes a previously created variable object and all of its children. 23786 With the `-c' option, just deletes the children. 23787 23788 Returns an error if the object NAME is not found. 23789 23790 The `-var-set-format' Command 23791 ----------------------------- 23792 23793 Synopsis 23794 ........ 23795 23796 -var-set-format NAME FORMAT-SPEC 23797 23798 Sets the output format for the value of the object NAME to be 23799 FORMAT-SPEC. 23800 23801 The syntax for the FORMAT-SPEC is as follows: 23802 23803 FORMAT-SPEC ==> 23804 {binary | decimal | hexadecimal | octal | natural} 23805 23806 The natural format is the default format choosen automatically based 23807 on the variable type (like decimal for an `int', hex for pointers, 23808 etc.). 23809 23810 For a variable with children, the format is set only on the variable 23811 itself, and the children are not affected. 23812 23813 The `-var-show-format' Command 23814 ------------------------------ 23815 23816 Synopsis 23817 ........ 23818 23819 -var-show-format NAME 23820 23821 Returns the format used to display the value of the object NAME. 23822 23823 FORMAT ==> 23824 FORMAT-SPEC 23825 23826 The `-var-info-num-children' Command 23827 ------------------------------------ 23828 23829 Synopsis 23830 ........ 23831 23832 -var-info-num-children NAME 23833 23834 Returns the number of children of a variable object NAME: 23835 23836 numchild=N 23837 23838 Note that this number is not completely reliable for a dynamic 23839 varobj. It will return the current number of children, but more 23840 children may be available. 23841 23842 The `-var-list-children' Command 23843 -------------------------------- 23844 23845 Synopsis 23846 ........ 23847 23848 -var-list-children [PRINT-VALUES] NAME [FROM TO] 23849 Return a list of the children of the specified variable object and 23850 create variable objects for them, if they do not already exist. With a 23851 single argument or if PRINT-VALUES has a value of 0 or `--no-values', 23852 print only the names of the variables; if PRINT-VALUES is 1 or 23853 `--all-values', also print their values; and if it is 2 or 23854 `--simple-values' print the name and value for simple data types and 23855 just the name for arrays, structures and unions. 23856 23857 FROM and TO, if specified, indicate the range of children to report. 23858 If FROM or TO is less than zero, the range is reset and all children 23859 will be reported. Otherwise, children starting at FROM (zero-based) 23860 and up to and excluding TO will be reported. 23861 23862 If a child range is requested, it will only affect the current call 23863 to `-var-list-children', but not future calls to `-var-update'. For 23864 this, you must instead use `-var-set-update-range'. The intent of this 23865 approach is to enable a front end to implement any update approach it 23866 likes; for example, scrolling a view may cause the front end to request 23867 more children with `-var-list-children', and then the front end could 23868 call `-var-set-update-range' with a different range to ensure that 23869 future updates are restricted to just the visible items. 23870 23871 For each child the following results are returned: 23872 23873 NAME 23874 Name of the variable object created for this child. 23875 23876 EXP 23877 The expression to be shown to the user by the front end to 23878 designate this child. For example this may be the name of a 23879 structure member. 23880 23881 For a dynamic varobj, this value cannot be used to form an 23882 expression. There is no way to do this at all with a dynamic 23883 varobj. 23884 23885 For C/C++ structures there are several pseudo children returned to 23886 designate access qualifiers. For these pseudo children EXP is 23887 `public', `private', or `protected'. In this case the type and 23888 value are not present. 23889 23890 A dynamic varobj will not report the access qualifying 23891 pseudo-children, regardless of the language. This information is 23892 not available at all with a dynamic varobj. 23893 23894 NUMCHILD 23895 Number of children this child has. For a dynamic varobj, this 23896 will be 0. 23897 23898 TYPE 23899 The type of the child. 23900 23901 VALUE 23902 If values were requested, this is the value. 23903 23904 THREAD-ID 23905 If this variable object is associated with a thread, this is the 23906 thread id. Otherwise this result is not present. 23907 23908 FROZEN 23909 If the variable object is frozen, this variable will be present 23910 with a value of 1. 23911 23912 The result may have its own attributes: 23913 23914 `displayhint' 23915 A dynamic varobj can supply a display hint to the front end. The 23916 value comes directly from the Python pretty-printer object's 23917 `display_hint' method. *Note Pretty Printing API::. 23918 23919 `has_more' 23920 This is an integer attribute which is nonzero if there are children 23921 remaining after the end of the selected range. 23922 23923 Example 23924 ....... 23925 23926 (gdb) 23927 -var-list-children n 23928 ^done,numchild=N,children=[child={name=NAME,exp=EXP, 23929 numchild=N,type=TYPE},(repeats N times)] 23930 (gdb) 23931 -var-list-children --all-values n 23932 ^done,numchild=N,children=[child={name=NAME,exp=EXP, 23933 numchild=N,value=VALUE,type=TYPE},(repeats N times)] 23934 23935 The `-var-info-type' Command 23936 ---------------------------- 23937 23938 Synopsis 23939 ........ 23940 23941 -var-info-type NAME 23942 23943 Returns the type of the specified variable NAME. The type is 23944 returned as a string in the same format as it is output by the GDB CLI: 23945 23946 type=TYPENAME 23947 23948 The `-var-info-expression' Command 23949 ---------------------------------- 23950 23951 Synopsis 23952 ........ 23953 23954 -var-info-expression NAME 23955 23956 Returns a string that is suitable for presenting this variable 23957 object in user interface. The string is generally not valid expression 23958 in the current language, and cannot be evaluated. 23959 23960 For example, if `a' is an array, and variable object `A' was created 23961 for `a', then we'll get this output: 23962 23963 (gdb) -var-info-expression A.1 23964 ^done,lang="C",exp="1" 23965 23966 Here, the values of `lang' can be `{"C" | "C++" | "Java"}'. 23967 23968 Note that the output of the `-var-list-children' command also 23969 includes those expressions, so the `-var-info-expression' command is of 23970 limited use. 23971 23972 The `-var-info-path-expression' Command 23973 --------------------------------------- 23974 23975 Synopsis 23976 ........ 23977 23978 -var-info-path-expression NAME 23979 23980 Returns an expression that can be evaluated in the current context 23981 and will yield the same value that a variable object has. Compare this 23982 with the `-var-info-expression' command, which result can be used only 23983 for UI presentation. Typical use of the `-var-info-path-expression' 23984 command is creating a watchpoint from a variable object. 23985 23986 This command is currently not valid for children of a dynamic varobj, 23987 and will give an error when invoked on one. 23988 23989 For example, suppose `C' is a C++ class, derived from class `Base', 23990 and that the `Base' class has a member called `m_size'. Assume a 23991 variable `c' is has the type of `C' and a variable object `C' was 23992 created for variable `c'. Then, we'll get this output: 23993 (gdb) -var-info-path-expression C.Base.public.m_size 23994 ^done,path_expr=((Base)c).m_size) 23995 23996 The `-var-show-attributes' Command 23997 ---------------------------------- 23998 23999 Synopsis 24000 ........ 24001 24002 -var-show-attributes NAME 24003 24004 List attributes of the specified variable object NAME: 24005 24006 status=ATTR [ ( ,ATTR )* ] 24007 24008 where ATTR is `{ { editable | noneditable } | TBD }'. 24009 24010 The `-var-evaluate-expression' Command 24011 -------------------------------------- 24012 24013 Synopsis 24014 ........ 24015 24016 -var-evaluate-expression [-f FORMAT-SPEC] NAME 24017 24018 Evaluates the expression that is represented by the specified 24019 variable object and returns its value as a string. The format of the 24020 string can be specified with the `-f' option. The possible values of 24021 this option are the same as for `-var-set-format' (*note 24022 -var-set-format::). If the `-f' option is not specified, the current 24023 display format will be used. The current display format can be changed 24024 using the `-var-set-format' command. 24025 24026 value=VALUE 24027 24028 Note that one must invoke `-var-list-children' for a variable before 24029 the value of a child variable can be evaluated. 24030 24031 The `-var-assign' Command 24032 ------------------------- 24033 24034 Synopsis 24035 ........ 24036 24037 -var-assign NAME EXPRESSION 24038 24039 Assigns the value of EXPRESSION to the variable object specified by 24040 NAME. The object must be `editable'. If the variable's value is 24041 altered by the assign, the variable will show up in any subsequent 24042 `-var-update' list. 24043 24044 Example 24045 ....... 24046 24047 (gdb) 24048 -var-assign var1 3 24049 ^done,value="3" 24050 (gdb) 24051 -var-update * 24052 ^done,changelist=[{name="var1",in_scope="true",type_changed="false"}] 24053 (gdb) 24054 24055 The `-var-update' Command 24056 ------------------------- 24057 24058 Synopsis 24059 ........ 24060 24061 -var-update [PRINT-VALUES] {NAME | "*"} 24062 24063 Reevaluate the expressions corresponding to the variable object NAME 24064 and all its direct and indirect children, and return the list of 24065 variable objects whose values have changed; NAME must be a root 24066 variable object. Here, "changed" means that the result of 24067 `-var-evaluate-expression' before and after the `-var-update' is 24068 different. If `*' is used as the variable object names, all existing 24069 variable objects are updated, except for frozen ones (*note 24070 -var-set-frozen::). The option PRINT-VALUES determines whether both 24071 names and values, or just names are printed. The possible values of 24072 this option are the same as for `-var-list-children' (*note 24073 -var-list-children::). It is recommended to use the `--all-values' 24074 option, to reduce the number of MI commands needed on each program stop. 24075 24076 With the `*' parameter, if a variable object is bound to a currently 24077 running thread, it will not be updated, without any diagnostic. 24078 24079 If `-var-set-update-range' was previously used on a varobj, then 24080 only the selected range of children will be reported. 24081 24082 `-var-update' reports all the changed varobjs in a tuple named 24083 `changelist'. 24084 24085 Each item in the change list is itself a tuple holding: 24086 24087 `name' 24088 The name of the varobj. 24089 24090 `value' 24091 If values were requested for this update, then this field will be 24092 present and will hold the value of the varobj. 24093 24094 `in_scope' 24095 This field is a string which may take one of three values: 24096 24097 `"true"' 24098 The variable object's current value is valid. 24099 24100 `"false"' 24101 The variable object does not currently hold a valid value but 24102 it may hold one in the future if its associated expression 24103 comes back into scope. 24104 24105 `"invalid"' 24106 The variable object no longer holds a valid value. This can 24107 occur when the executable file being debugged has changed, 24108 either through recompilation or by using the GDB `file' 24109 command. The front end should normally choose to delete 24110 these variable objects. 24111 24112 In the future new values may be added to this list so the front 24113 should be prepared for this possibility. *Note GDB/MI Development 24114 and Front Ends: GDB/MI Development and Front Ends. 24115 24116 `type_changed' 24117 This is only present if the varobj is still valid. If the type 24118 changed, then this will be the string `true'; otherwise it will be 24119 `false'. 24120 24121 `new_type' 24122 If the varobj's type changed, then this field will be present and 24123 will hold the new type. 24124 24125 `new_num_children' 24126 For a dynamic varobj, if the number of children changed, or if the 24127 type changed, this will be the new number of children. 24128 24129 The `numchild' field in other varobj responses is generally not 24130 valid for a dynamic varobj - it will show the number of children 24131 that GDB knows about, but because dynamic varobjs lazily 24132 instantiate their children, this will not reflect the number of 24133 children which may be available. 24134 24135 The `new_num_children' attribute only reports changes to the 24136 number of children known by GDB. This is the only way to detect 24137 whether an update has removed children (which necessarily can only 24138 happen at the end of the update range). 24139 24140 `displayhint' 24141 The display hint, if any. 24142 24143 `has_more' 24144 This is an integer value, which will be 1 if there are more 24145 children available outside the varobj's update range. 24146 24147 `dynamic' 24148 This attribute will be present and have the value `1' if the 24149 varobj is a dynamic varobj. If the varobj is not a dynamic varobj, 24150 then this attribute will not be present. 24151 24152 `new_children' 24153 If new children were added to a dynamic varobj within the selected 24154 update range (as set by `-var-set-update-range'), then they will 24155 be listed in this attribute. 24156 24157 Example 24158 ....... 24159 24160 (gdb) 24161 -var-assign var1 3 24162 ^done,value="3" 24163 (gdb) 24164 -var-update --all-values var1 24165 ^done,changelist=[{name="var1",value="3",in_scope="true", 24166 type_changed="false"}] 24167 (gdb) 24168 24169 The `-var-set-frozen' Command 24170 ----------------------------- 24171 24172 Synopsis 24173 ........ 24174 24175 -var-set-frozen NAME FLAG 24176 24177 Set the frozenness flag on the variable object NAME. The FLAG 24178 parameter should be either `1' to make the variable frozen or `0' to 24179 make it unfrozen. If a variable object is frozen, then neither itself, 24180 nor any of its children, are implicitly updated by `-var-update' of a 24181 parent variable or by `-var-update *'. Only `-var-update' of the 24182 variable itself will update its value and values of its children. 24183 After a variable object is unfrozen, it is implicitly updated by all 24184 subsequent `-var-update' operations. Unfreezing a variable does not 24185 update it, only subsequent `-var-update' does. 24186 24187 Example 24188 ....... 24189 24190 (gdb) 24191 -var-set-frozen V 1 24192 ^done 24193 (gdb) 24194 24195 The `-var-set-update-range' command 24196 ----------------------------------- 24197 24198 Synopsis 24199 ........ 24200 24201 -var-set-update-range NAME FROM TO 24202 24203 Set the range of children to be returned by future invocations of 24204 `-var-update'. 24205 24206 FROM and TO indicate the range of children to report. If FROM or TO 24207 is less than zero, the range is reset and all children will be 24208 reported. Otherwise, children starting at FROM (zero-based) and up to 24209 and excluding TO will be reported. 24210 24211 Example 24212 ....... 24213 24214 (gdb) 24215 -var-set-update-range V 1 2 24216 ^done 24217 24218 The `-var-set-visualizer' command 24219 --------------------------------- 24220 24221 Synopsis 24222 ........ 24223 24224 -var-set-visualizer NAME VISUALIZER 24225 24226 Set a visualizer for the variable object NAME. 24227 24228 VISUALIZER is the visualizer to use. The special value `None' means 24229 to disable any visualizer in use. 24230 24231 If not `None', VISUALIZER must be a Python expression. This 24232 expression must evaluate to a callable object which accepts a single 24233 argument. GDB will call this object with the value of the varobj NAME 24234 as an argument (this is done so that the same Python pretty-printing 24235 code can be used for both the CLI and MI). When called, this object 24236 must return an object which conforms to the pretty-printing interface 24237 (*note Pretty Printing API::). 24238 24239 The pre-defined function `gdb.default_visualizer' may be used to 24240 select a visualizer by following the built-in process (*note Selecting 24241 Pretty-Printers::). This is done automatically when a varobj is 24242 created, and so ordinarily is not needed. 24243 24244 This feature is only available if Python support is enabled. The MI 24245 command `-list-features' (*note GDB/MI Miscellaneous Commands::) can be 24246 used to check this. 24247 24248 Example 24249 ....... 24250 24251 Resetting the visualizer: 24252 24253 (gdb) 24254 -var-set-visualizer V None 24255 ^done 24256 24257 Reselecting the default (type-based) visualizer: 24258 24259 (gdb) 24260 -var-set-visualizer V gdb.default_visualizer 24261 ^done 24262 24263 Suppose `SomeClass' is a visualizer class. A lambda expression can 24264 be used to instantiate this class for a varobj: 24265 24266 (gdb) 24267 -var-set-visualizer V "lambda val: SomeClass()" 24268 ^done 24269 24270 24271 File: gdb.info, Node: GDB/MI Data Manipulation, Next: GDB/MI Tracepoint Commands, Prev: GDB/MI Variable Objects, Up: GDB/MI 24272 24273 27.14 GDB/MI Data Manipulation 24274 ============================== 24275 24276 This section describes the GDB/MI commands that manipulate data: 24277 examine memory and registers, evaluate expressions, etc. 24278 24279 The `-data-disassemble' Command 24280 ------------------------------- 24281 24282 Synopsis 24283 ........ 24284 24285 -data-disassemble 24286 [ -s START-ADDR -e END-ADDR ] 24287 | [ -f FILENAME -l LINENUM [ -n LINES ] ] 24288 -- MODE 24289 24290 Where: 24291 24292 `START-ADDR' 24293 is the beginning address (or `$pc') 24294 24295 `END-ADDR' 24296 is the end address 24297 24298 `FILENAME' 24299 is the name of the file to disassemble 24300 24301 `LINENUM' 24302 is the line number to disassemble around 24303 24304 `LINES' 24305 is the number of disassembly lines to be produced. If it is -1, 24306 the whole function will be disassembled, in case no END-ADDR is 24307 specified. If END-ADDR is specified as a non-zero value, and 24308 LINES is lower than the number of disassembly lines between 24309 START-ADDR and END-ADDR, only LINES lines are displayed; if LINES 24310 is higher than the number of lines between START-ADDR and 24311 END-ADDR, only the lines up to END-ADDR are displayed. 24312 24313 `MODE' 24314 is either 0 (meaning only disassembly), 1 (meaning mixed source and 24315 disassembly), 2 (meaning disassembly with raw opcodes), or 3 24316 (meaning mixed source and disassembly with raw opcodes). 24317 24318 Result 24319 ...... 24320 24321 The output for each instruction is composed of four fields: 24322 24323 * Address 24324 24325 * Func-name 24326 24327 * Offset 24328 24329 * Instruction 24330 24331 Note that whatever included in the instruction field, is not 24332 manipulated directly by GDB/MI, i.e., it is not possible to adjust its 24333 format. 24334 24335 GDB Command 24336 ........... 24337 24338 There's no direct mapping from this command to the CLI. 24339 24340 Example 24341 ....... 24342 24343 Disassemble from the current value of `$pc' to `$pc + 20': 24344 24345 (gdb) 24346 -data-disassemble -s $pc -e "$pc + 20" -- 0 24347 ^done, 24348 asm_insns=[ 24349 {address="0x000107c0",func-name="main",offset="4", 24350 inst="mov 2, %o0"}, 24351 {address="0x000107c4",func-name="main",offset="8", 24352 inst="sethi %hi(0x11800), %o2"}, 24353 {address="0x000107c8",func-name="main",offset="12", 24354 inst="or %o2, 0x140, %o1\t! 0x11940 <_lib_version+8>"}, 24355 {address="0x000107cc",func-name="main",offset="16", 24356 inst="sethi %hi(0x11800), %o2"}, 24357 {address="0x000107d0",func-name="main",offset="20", 24358 inst="or %o2, 0x168, %o4\t! 0x11968 <_lib_version+48>"}] 24359 (gdb) 24360 24361 Disassemble the whole `main' function. Line 32 is part of `main'. 24362 24363 -data-disassemble -f basics.c -l 32 -- 0 24364 ^done,asm_insns=[ 24365 {address="0x000107bc",func-name="main",offset="0", 24366 inst="save %sp, -112, %sp"}, 24367 {address="0x000107c0",func-name="main",offset="4", 24368 inst="mov 2, %o0"}, 24369 {address="0x000107c4",func-name="main",offset="8", 24370 inst="sethi %hi(0x11800), %o2"}, 24371 [...] 24372 {address="0x0001081c",func-name="main",offset="96",inst="ret "}, 24373 {address="0x00010820",func-name="main",offset="100",inst="restore "}] 24374 (gdb) 24375 24376 Disassemble 3 instructions from the start of `main': 24377 24378 (gdb) 24379 -data-disassemble -f basics.c -l 32 -n 3 -- 0 24380 ^done,asm_insns=[ 24381 {address="0x000107bc",func-name="main",offset="0", 24382 inst="save %sp, -112, %sp"}, 24383 {address="0x000107c0",func-name="main",offset="4", 24384 inst="mov 2, %o0"}, 24385 {address="0x000107c4",func-name="main",offset="8", 24386 inst="sethi %hi(0x11800), %o2"}] 24387 (gdb) 24388 24389 Disassemble 3 instructions from the start of `main' in mixed mode: 24390 24391 (gdb) 24392 -data-disassemble -f basics.c -l 32 -n 3 -- 1 24393 ^done,asm_insns=[ 24394 src_and_asm_line={line="31", 24395 file="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb/ \ 24396 testsuite/gdb.mi/basics.c",line_asm_insn=[ 24397 {address="0x000107bc",func-name="main",offset="0", 24398 inst="save %sp, -112, %sp"}]}, 24399 src_and_asm_line={line="32", 24400 file="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb/ \ 24401 testsuite/gdb.mi/basics.c",line_asm_insn=[ 24402 {address="0x000107c0",func-name="main",offset="4", 24403 inst="mov 2, %o0"}, 24404 {address="0x000107c4",func-name="main",offset="8", 24405 inst="sethi %hi(0x11800), %o2"}]}] 24406 (gdb) 24407 24408 The `-data-evaluate-expression' Command 24409 --------------------------------------- 24410 24411 Synopsis 24412 ........ 24413 24414 -data-evaluate-expression EXPR 24415 24416 Evaluate EXPR as an expression. The expression could contain an 24417 inferior function call. The function call will execute synchronously. 24418 If the expression contains spaces, it must be enclosed in double quotes. 24419 24420 GDB Command 24421 ........... 24422 24423 The corresponding GDB commands are `print', `output', and `call'. In 24424 `gdbtk' only, there's a corresponding `gdb_eval' command. 24425 24426 Example 24427 ....... 24428 24429 In the following example, the numbers that precede the commands are the 24430 "tokens" described in *note GDB/MI Command Syntax: GDB/MI Command 24431 Syntax. Notice how GDB/MI returns the same tokens in its output. 24432 24433 211-data-evaluate-expression A 24434 211^done,value="1" 24435 (gdb) 24436 311-data-evaluate-expression &A 24437 311^done,value="0xefffeb7c" 24438 (gdb) 24439 411-data-evaluate-expression A+3 24440 411^done,value="4" 24441 (gdb) 24442 511-data-evaluate-expression "A + 3" 24443 511^done,value="4" 24444 (gdb) 24445 24446 The `-data-list-changed-registers' Command 24447 ------------------------------------------ 24448 24449 Synopsis 24450 ........ 24451 24452 -data-list-changed-registers 24453 24454 Display a list of the registers that have changed. 24455 24456 GDB Command 24457 ........... 24458 24459 GDB doesn't have a direct analog for this command; `gdbtk' has the 24460 corresponding command `gdb_changed_register_list'. 24461 24462 Example 24463 ....... 24464 24465 On a PPC MBX board: 24466 24467 (gdb) 24468 -exec-continue 24469 ^running 24470 24471 (gdb) 24472 *stopped,reason="breakpoint-hit",disp="keep",bkptno="1",frame={ 24473 func="main",args=[],file="try.c",fullname="/home/foo/bar/try.c", 24474 line="5"} 24475 (gdb) 24476 -data-list-changed-registers 24477 ^done,changed-registers=["0","1","2","4","5","6","7","8","9", 24478 "10","11","13","14","15","16","17","18","19","20","21","22","23", 24479 "24","25","26","27","28","30","31","64","65","66","67","69"] 24480 (gdb) 24481 24482 The `-data-list-register-names' Command 24483 --------------------------------------- 24484 24485 Synopsis 24486 ........ 24487 24488 -data-list-register-names [ ( REGNO )+ ] 24489 24490 Show a list of register names for the current target. If no 24491 arguments are given, it shows a list of the names of all the registers. 24492 If integer numbers are given as arguments, it will print a list of the 24493 names of the registers corresponding to the arguments. To ensure 24494 consistency between a register name and its number, the output list may 24495 include empty register names. 24496 24497 GDB Command 24498 ........... 24499 24500 GDB does not have a command which corresponds to 24501 `-data-list-register-names'. In `gdbtk' there is a corresponding 24502 command `gdb_regnames'. 24503 24504 Example 24505 ....... 24506 24507 For the PPC MBX board: 24508 (gdb) 24509 -data-list-register-names 24510 ^done,register-names=["r0","r1","r2","r3","r4","r5","r6","r7", 24511 "r8","r9","r10","r11","r12","r13","r14","r15","r16","r17","r18", 24512 "r19","r20","r21","r22","r23","r24","r25","r26","r27","r28","r29", 24513 "r30","r31","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9", 24514 "f10","f11","f12","f13","f14","f15","f16","f17","f18","f19","f20", 24515 "f21","f22","f23","f24","f25","f26","f27","f28","f29","f30","f31", 24516 "", "pc","ps","cr","lr","ctr","xer"] 24517 (gdb) 24518 -data-list-register-names 1 2 3 24519 ^done,register-names=["r1","r2","r3"] 24520 (gdb) 24521 24522 The `-data-list-register-values' Command 24523 ---------------------------------------- 24524 24525 Synopsis 24526 ........ 24527 24528 -data-list-register-values FMT [ ( REGNO )*] 24529 24530 Display the registers' contents. FMT is the format according to 24531 which the registers' contents are to be returned, followed by an 24532 optional list of numbers specifying the registers to display. A 24533 missing list of numbers indicates that the contents of all the 24534 registers must be returned. 24535 24536 Allowed formats for FMT are: 24537 24538 `x' 24539 Hexadecimal 24540 24541 `o' 24542 Octal 24543 24544 `t' 24545 Binary 24546 24547 `d' 24548 Decimal 24549 24550 `r' 24551 Raw 24552 24553 `N' 24554 Natural 24555 24556 GDB Command 24557 ........... 24558 24559 The corresponding GDB commands are `info reg', `info all-reg', and (in 24560 `gdbtk') `gdb_fetch_registers'. 24561 24562 Example 24563 ....... 24564 24565 For a PPC MBX board (note: line breaks are for readability only, they 24566 don't appear in the actual output): 24567 24568 (gdb) 24569 -data-list-register-values r 64 65 24570 ^done,register-values=[{number="64",value="0xfe00a300"}, 24571 {number="65",value="0x00029002"}] 24572 (gdb) 24573 -data-list-register-values x 24574 ^done,register-values=[{number="0",value="0xfe0043c8"}, 24575 {number="1",value="0x3fff88"},{number="2",value="0xfffffffe"}, 24576 {number="3",value="0x0"},{number="4",value="0xa"}, 24577 {number="5",value="0x3fff68"},{number="6",value="0x3fff58"}, 24578 {number="7",value="0xfe011e98"},{number="8",value="0x2"}, 24579 {number="9",value="0xfa202820"},{number="10",value="0xfa202808"}, 24580 {number="11",value="0x1"},{number="12",value="0x0"}, 24581 {number="13",value="0x4544"},{number="14",value="0xffdfffff"}, 24582 {number="15",value="0xffffffff"},{number="16",value="0xfffffeff"}, 24583 {number="17",value="0xefffffed"},{number="18",value="0xfffffffe"}, 24584 {number="19",value="0xffffffff"},{number="20",value="0xffffffff"}, 24585 {number="21",value="0xffffffff"},{number="22",value="0xfffffff7"}, 24586 {number="23",value="0xffffffff"},{number="24",value="0xffffffff"}, 24587 {number="25",value="0xffffffff"},{number="26",value="0xfffffffb"}, 24588 {number="27",value="0xffffffff"},{number="28",value="0xf7bfffff"}, 24589 {number="29",value="0x0"},{number="30",value="0xfe010000"}, 24590 {number="31",value="0x0"},{number="32",value="0x0"}, 24591 {number="33",value="0x0"},{number="34",value="0x0"}, 24592 {number="35",value="0x0"},{number="36",value="0x0"}, 24593 {number="37",value="0x0"},{number="38",value="0x0"}, 24594 {number="39",value="0x0"},{number="40",value="0x0"}, 24595 {number="41",value="0x0"},{number="42",value="0x0"}, 24596 {number="43",value="0x0"},{number="44",value="0x0"}, 24597 {number="45",value="0x0"},{number="46",value="0x0"}, 24598 {number="47",value="0x0"},{number="48",value="0x0"}, 24599 {number="49",value="0x0"},{number="50",value="0x0"}, 24600 {number="51",value="0x0"},{number="52",value="0x0"}, 24601 {number="53",value="0x0"},{number="54",value="0x0"}, 24602 {number="55",value="0x0"},{number="56",value="0x0"}, 24603 {number="57",value="0x0"},{number="58",value="0x0"}, 24604 {number="59",value="0x0"},{number="60",value="0x0"}, 24605 {number="61",value="0x0"},{number="62",value="0x0"}, 24606 {number="63",value="0x0"},{number="64",value="0xfe00a300"}, 24607 {number="65",value="0x29002"},{number="66",value="0x202f04b5"}, 24608 {number="67",value="0xfe0043b0"},{number="68",value="0xfe00b3e4"}, 24609 {number="69",value="0x20002b03"}] 24610 (gdb) 24611 24612 The `-data-read-memory' Command 24613 ------------------------------- 24614 24615 This command is deprecated, use `-data-read-memory-bytes' instead. 24616 24617 Synopsis 24618 ........ 24619 24620 -data-read-memory [ -o BYTE-OFFSET ] 24621 ADDRESS WORD-FORMAT WORD-SIZE 24622 NR-ROWS NR-COLS [ ASCHAR ] 24623 24624 where: 24625 24626 `ADDRESS' 24627 An expression specifying the address of the first memory word to be 24628 read. Complex expressions containing embedded white space should 24629 be quoted using the C convention. 24630 24631 `WORD-FORMAT' 24632 The format to be used to print the memory words. The notation is 24633 the same as for GDB's `print' command (*note Output Formats: 24634 Output Formats.). 24635 24636 `WORD-SIZE' 24637 The size of each memory word in bytes. 24638 24639 `NR-ROWS' 24640 The number of rows in the output table. 24641 24642 `NR-COLS' 24643 The number of columns in the output table. 24644 24645 `ASCHAR' 24646 If present, indicates that each row should include an ASCII dump. 24647 The value of ASCHAR is used as a padding character when a byte is 24648 not a member of the printable ASCII character set (printable ASCII 24649 characters are those whose code is between 32 and 126, 24650 inclusively). 24651 24652 `BYTE-OFFSET' 24653 An offset to add to the ADDRESS before fetching memory. 24654 24655 This command displays memory contents as a table of NR-ROWS by 24656 NR-COLS words, each word being WORD-SIZE bytes. In total, `NR-ROWS * 24657 NR-COLS * WORD-SIZE' bytes are read (returned as `total-bytes'). 24658 Should less than the requested number of bytes be returned by the 24659 target, the missing words are identified using `N/A'. The number of 24660 bytes read from the target is returned in `nr-bytes' and the starting 24661 address used to read memory in `addr'. 24662 24663 The address of the next/previous row or page is available in 24664 `next-row' and `prev-row', `next-page' and `prev-page'. 24665 24666 GDB Command 24667 ........... 24668 24669 The corresponding GDB command is `x'. `gdbtk' has `gdb_get_mem' memory 24670 read command. 24671 24672 Example 24673 ....... 24674 24675 Read six bytes of memory starting at `bytes+6' but then offset by `-6' 24676 bytes. Format as three rows of two columns. One byte per word. 24677 Display each word in hex. 24678 24679 (gdb) 24680 9-data-read-memory -o -6 -- bytes+6 x 1 3 2 24681 9^done,addr="0x00001390",nr-bytes="6",total-bytes="6", 24682 next-row="0x00001396",prev-row="0x0000138e",next-page="0x00001396", 24683 prev-page="0x0000138a",memory=[ 24684 {addr="0x00001390",data=["0x00","0x01"]}, 24685 {addr="0x00001392",data=["0x02","0x03"]}, 24686 {addr="0x00001394",data=["0x04","0x05"]}] 24687 (gdb) 24688 24689 Read two bytes of memory starting at address `shorts + 64' and 24690 display as a single word formatted in decimal. 24691 24692 (gdb) 24693 5-data-read-memory shorts+64 d 2 1 1 24694 5^done,addr="0x00001510",nr-bytes="2",total-bytes="2", 24695 next-row="0x00001512",prev-row="0x0000150e", 24696 next-page="0x00001512",prev-page="0x0000150e",memory=[ 24697 {addr="0x00001510",data=["128"]}] 24698 (gdb) 24699 24700 Read thirty two bytes of memory starting at `bytes+16' and format as 24701 eight rows of four columns. Include a string encoding with `x' used as 24702 the non-printable character. 24703 24704 (gdb) 24705 4-data-read-memory bytes+16 x 1 8 4 x 24706 4^done,addr="0x000013a0",nr-bytes="32",total-bytes="32", 24707 next-row="0x000013c0",prev-row="0x0000139c", 24708 next-page="0x000013c0",prev-page="0x00001380",memory=[ 24709 {addr="0x000013a0",data=["0x10","0x11","0x12","0x13"],ascii="xxxx"}, 24710 {addr="0x000013a4",data=["0x14","0x15","0x16","0x17"],ascii="xxxx"}, 24711 {addr="0x000013a8",data=["0x18","0x19","0x1a","0x1b"],ascii="xxxx"}, 24712 {addr="0x000013ac",data=["0x1c","0x1d","0x1e","0x1f"],ascii="xxxx"}, 24713 {addr="0x000013b0",data=["0x20","0x21","0x22","0x23"],ascii=" !\"#"}, 24714 {addr="0x000013b4",data=["0x24","0x25","0x26","0x27"],ascii="$%&'"}, 24715 {addr="0x000013b8",data=["0x28","0x29","0x2a","0x2b"],ascii="()*+"}, 24716 {addr="0x000013bc",data=["0x2c","0x2d","0x2e","0x2f"],ascii=",-./"}] 24717 (gdb) 24718 24719 The `-data-read-memory-bytes' Command 24720 ------------------------------------- 24721 24722 Synopsis 24723 ........ 24724 24725 -data-read-memory-bytes [ -o BYTE-OFFSET ] 24726 ADDRESS COUNT 24727 24728 where: 24729 24730 `ADDRESS' 24731 An expression specifying the address of the first memory word to be 24732 read. Complex expressions containing embedded white space should 24733 be quoted using the C convention. 24734 24735 `COUNT' 24736 The number of bytes to read. This should be an integer literal. 24737 24738 `BYTE-OFFSET' 24739 The offsets in bytes relative to ADDRESS at which to start 24740 reading. This should be an integer literal. This option is 24741 provided so that a frontend is not required to first evaluate 24742 address and then perform address arithmetics itself. 24743 24744 24745 This command attempts to read all accessible memory regions in the 24746 specified range. First, all regions marked as unreadable in the memory 24747 map (if one is defined) will be skipped. *Note Memory Region 24748 Attributes::. Second, GDB will attempt to read the remaining regions. 24749 For each one, if reading full region results in an errors, GDB will try 24750 to read a subset of the region. 24751 24752 In general, every single byte in the region may be readable or not, 24753 and the only way to read every readable byte is to try a read at every 24754 address, which is not practical. Therefore, GDB will attempt to read 24755 all accessible bytes at either beginning or the end of the region, 24756 using a binary division scheme. This heuristic works well for reading 24757 accross a memory map boundary. Note that if a region has a readable 24758 range that is neither at the beginning or the end, GDB will not read it. 24759 24760 The result record (*note GDB/MI Result Records::) that is output of 24761 the command includes a field named `memory' whose content is a list of 24762 tuples. Each tuple represent a successfully read memory block and has 24763 the following fields: 24764 24765 `begin' 24766 The start address of the memory block, as hexadecimal literal. 24767 24768 `end' 24769 The end address of the memory block, as hexadecimal literal. 24770 24771 `offset' 24772 The offset of the memory block, as hexadecimal literal, relative to 24773 the start address passed to `-data-read-memory-bytes'. 24774 24775 `contents' 24776 The contents of the memory block, in hex. 24777 24778 24779 GDB Command 24780 ........... 24781 24782 The corresponding GDB command is `x'. 24783 24784 Example 24785 ....... 24786 24787 (gdb) 24788 -data-read-memory-bytes &a 10 24789 ^done,memory=[{begin="0xbffff154",offset="0x00000000", 24790 end="0xbffff15e", 24791 contents="01000000020000000300"}] 24792 (gdb) 24793 24794 The `-data-write-memory-bytes' Command 24795 -------------------------------------- 24796 24797 Synopsis 24798 ........ 24799 24800 -data-write-memory-bytes ADDRESS CONTENTS 24801 24802 where: 24803 24804 `ADDRESS' 24805 An expression specifying the address of the first memory word to be 24806 read. Complex expressions containing embedded white space should 24807 be quoted using the C convention. 24808 24809 `CONTENTS' 24810 The hex-encoded bytes to write. 24811 24812 24813 GDB Command 24814 ........... 24815 24816 There's no corresponding GDB command. 24817 24818 Example 24819 ....... 24820 24821 (gdb) 24822 -data-write-memory-bytes &a "aabbccdd" 24823 ^done 24824 (gdb) 24825 24826 24827 File: gdb.info, Node: GDB/MI Tracepoint Commands, Next: GDB/MI Symbol Query, Prev: GDB/MI Data Manipulation, Up: GDB/MI 24828 24829 27.15 GDB/MI Tracepoint Commands 24830 ================================ 24831 24832 The commands defined in this section implement MI support for 24833 tracepoints. For detailed introduction, see *note Tracepoints::. 24834 24835 The `-trace-find' Command 24836 ------------------------- 24837 24838 Synopsis 24839 ........ 24840 24841 -trace-find MODE [PARAMETERS...] 24842 24843 Find a trace frame using criteria defined by MODE and PARAMETERS. 24844 The following table lists permissible modes and their parameters. For 24845 details of operation, see *note tfind::. 24846 24847 `none' 24848 No parameters are required. Stops examining trace frames. 24849 24850 `frame-number' 24851 An integer is required as parameter. Selects tracepoint frame with 24852 that index. 24853 24854 `tracepoint-number' 24855 An integer is required as parameter. Finds next trace frame that 24856 corresponds to tracepoint with the specified number. 24857 24858 `pc' 24859 An address is required as parameter. Finds next trace frame that 24860 corresponds to any tracepoint at the specified address. 24861 24862 `pc-inside-range' 24863 Two addresses are required as parameters. Finds next trace frame 24864 that corresponds to a tracepoint at an address inside the 24865 specified range. Both bounds are considered to be inside the 24866 range. 24867 24868 `pc-outside-range' 24869 Two addresses are required as parameters. Finds next trace frame 24870 that corresponds to a tracepoint at an address outside the 24871 specified range. Both bounds are considered to be inside the 24872 range. 24873 24874 `line' 24875 Line specification is required as parameter. *Note Specify 24876 Location::. Finds next trace frame that corresponds to a 24877 tracepoint at the specified location. 24878 24879 24880 If `none' was passed as MODE, the response does not have fields. 24881 Otherwise, the response may have the following fields: 24882 24883 `found' 24884 This field has either `0' or `1' as the value, depending on 24885 whether a matching tracepoint was found. 24886 24887 `traceframe' 24888 The index of the found traceframe. This field is present iff the 24889 `found' field has value of `1'. 24890 24891 `tracepoint' 24892 The index of the found tracepoint. This field is present iff the 24893 `found' field has value of `1'. 24894 24895 `frame' 24896 The information about the frame corresponding to the found trace 24897 frame. This field is present only if a trace frame was found. 24898 *Note GDB/MI Frame Information::, for description of this field. 24899 24900 24901 GDB Command 24902 ........... 24903 24904 The corresponding GDB command is `tfind'. 24905 24906 -trace-define-variable 24907 ---------------------- 24908 24909 Synopsis 24910 ........ 24911 24912 -trace-define-variable NAME [ VALUE ] 24913 24914 Create trace variable NAME if it does not exist. If VALUE is 24915 specified, sets the initial value of the specified trace variable to 24916 that value. Note that the NAME should start with the `$' character. 24917 24918 GDB Command 24919 ........... 24920 24921 The corresponding GDB command is `tvariable'. 24922 24923 -trace-list-variables 24924 --------------------- 24925 24926 Synopsis 24927 ........ 24928 24929 -trace-list-variables 24930 24931 Return a table of all defined trace variables. Each element of the 24932 table has the following fields: 24933 24934 `name' 24935 The name of the trace variable. This field is always present. 24936 24937 `initial' 24938 The initial value. This is a 64-bit signed integer. This field 24939 is always present. 24940 24941 `current' 24942 The value the trace variable has at the moment. This is a 64-bit 24943 signed integer. This field is absent iff current value is not 24944 defined, for example if the trace was never run, or is presently 24945 running. 24946 24947 24948 GDB Command 24949 ........... 24950 24951 The corresponding GDB command is `tvariables'. 24952 24953 Example 24954 ....... 24955 24956 (gdb) 24957 -trace-list-variables 24958 ^done,trace-variables={nr_rows="1",nr_cols="3", 24959 hdr=[{width="15",alignment="-1",col_name="name",colhdr="Name"}, 24960 {width="11",alignment="-1",col_name="initial",colhdr="Initial"}, 24961 {width="11",alignment="-1",col_name="current",colhdr="Current"}], 24962 body=[variable={name="$trace_timestamp",initial="0"} 24963 variable={name="$foo",initial="10",current="15"}]} 24964 (gdb) 24965 24966 -trace-save 24967 ----------- 24968 24969 Synopsis 24970 ........ 24971 24972 -trace-save [-r ] FILENAME 24973 24974 Saves the collected trace data to FILENAME. Without the `-r' 24975 option, the data is downloaded from the target and saved in a local 24976 file. With the `-r' option the target is asked to perform the save. 24977 24978 GDB Command 24979 ........... 24980 24981 The corresponding GDB command is `tsave'. 24982 24983 -trace-start 24984 ------------ 24985 24986 Synopsis 24987 ........ 24988 24989 -trace-start 24990 24991 Starts a tracing experiments. The result of this command does not 24992 have any fields. 24993 24994 GDB Command 24995 ........... 24996 24997 The corresponding GDB command is `tstart'. 24998 24999 -trace-status 25000 ------------- 25001 25002 Synopsis 25003 ........ 25004 25005 -trace-status 25006 25007 Obtains the status of a tracing experiment. The result may include 25008 the following fields: 25009 25010 `supported' 25011 May have a value of either `0', when no tracing operations are 25012 supported, `1', when all tracing operations are supported, or 25013 `file' when examining trace file. In the latter case, examining 25014 of trace frame is possible but new tracing experiement cannot be 25015 started. This field is always present. 25016 25017 `running' 25018 May have a value of either `0' or `1' depending on whether tracing 25019 experiement is in progress on target. This field is present if 25020 `supported' field is not `0'. 25021 25022 `stop-reason' 25023 Report the reason why the tracing was stopped last time. This 25024 field may be absent iff tracing was never stopped on target yet. 25025 The value of `request' means the tracing was stopped as result of 25026 the `-trace-stop' command. The value of `overflow' means the 25027 tracing buffer is full. The value of `disconnection' means 25028 tracing was automatically stopped when GDB has disconnected. The 25029 value of `passcount' means tracing was stopped when a tracepoint 25030 was passed a maximal number of times for that tracepoint. This 25031 field is present if `supported' field is not `0'. 25032 25033 `stopping-tracepoint' 25034 The number of tracepoint whose passcount as exceeded. This field 25035 is present iff the `stop-reason' field has the value of 25036 `passcount'. 25037 25038 `frames' 25039 `frames-created' 25040 The `frames' field is a count of the total number of trace frames 25041 in the trace buffer, while `frames-created' is the total created 25042 during the run, including ones that were discarded, such as when a 25043 circular trace buffer filled up. Both fields are optional. 25044 25045 `buffer-size' 25046 `buffer-free' 25047 These fields tell the current size of the tracing buffer and the 25048 remaining space. These fields are optional. 25049 25050 `circular' 25051 The value of the circular trace buffer flag. `1' means that the 25052 trace buffer is circular and old trace frames will be discarded if 25053 necessary to make room, `0' means that the trace buffer is linear 25054 and may fill up. 25055 25056 `disconnected' 25057 The value of the disconnected tracing flag. `1' means that 25058 tracing will continue after GDB disconnects, `0' means that the 25059 trace run will stop. 25060 25061 25062 GDB Command 25063 ........... 25064 25065 The corresponding GDB command is `tstatus'. 25066 25067 -trace-stop 25068 ----------- 25069 25070 Synopsis 25071 ........ 25072 25073 -trace-stop 25074 25075 Stops a tracing experiment. The result of this command has the same 25076 fields as `-trace-status', except that the `supported' and `running' 25077 fields are not output. 25078 25079 GDB Command 25080 ........... 25081 25082 The corresponding GDB command is `tstop'. 25083 25084 25085 File: gdb.info, Node: GDB/MI Symbol Query, Next: GDB/MI File Commands, Prev: GDB/MI Tracepoint Commands, Up: GDB/MI 25086 25087 27.16 GDB/MI Symbol Query Commands 25088 ================================== 25089 25090 The `-symbol-list-lines' Command 25091 -------------------------------- 25092 25093 Synopsis 25094 ........ 25095 25096 -symbol-list-lines FILENAME 25097 25098 Print the list of lines that contain code and their associated 25099 program addresses for the given source filename. The entries are 25100 sorted in ascending PC order. 25101 25102 GDB Command 25103 ........... 25104 25105 There is no corresponding GDB command. 25106 25107 Example 25108 ....... 25109 25110 (gdb) 25111 -symbol-list-lines basics.c 25112 ^done,lines=[{pc="0x08048554",line="7"},{pc="0x0804855a",line="8"}] 25113 (gdb) 25114 25115 25116 File: gdb.info, Node: GDB/MI File Commands, Next: GDB/MI Target Manipulation, Prev: GDB/MI Symbol Query, Up: GDB/MI 25117 25118 27.17 GDB/MI File Commands 25119 ========================== 25120 25121 This section describes the GDB/MI commands to specify executable file 25122 names and to read in and obtain symbol table information. 25123 25124 The `-file-exec-and-symbols' Command 25125 ------------------------------------ 25126 25127 Synopsis 25128 ........ 25129 25130 -file-exec-and-symbols FILE 25131 25132 Specify the executable file to be debugged. This file is the one 25133 from which the symbol table is also read. If no file is specified, the 25134 command clears the executable and symbol information. If breakpoints 25135 are set when using this command with no arguments, GDB will produce 25136 error messages. Otherwise, no output is produced, except a completion 25137 notification. 25138 25139 GDB Command 25140 ........... 25141 25142 The corresponding GDB command is `file'. 25143 25144 Example 25145 ....... 25146 25147 (gdb) 25148 -file-exec-and-symbols /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx 25149 ^done 25150 (gdb) 25151 25152 The `-file-exec-file' Command 25153 ----------------------------- 25154 25155 Synopsis 25156 ........ 25157 25158 -file-exec-file FILE 25159 25160 Specify the executable file to be debugged. Unlike 25161 `-file-exec-and-symbols', the symbol table is _not_ read from this 25162 file. If used without argument, GDB clears the information about the 25163 executable file. No output is produced, except a completion 25164 notification. 25165 25166 GDB Command 25167 ........... 25168 25169 The corresponding GDB command is `exec-file'. 25170 25171 Example 25172 ....... 25173 25174 (gdb) 25175 -file-exec-file /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx 25176 ^done 25177 (gdb) 25178 25179 The `-file-list-exec-source-file' Command 25180 ----------------------------------------- 25181 25182 Synopsis 25183 ........ 25184 25185 -file-list-exec-source-file 25186 25187 List the line number, the current source file, and the absolute path 25188 to the current source file for the current executable. The macro 25189 information field has a value of `1' or `0' depending on whether or not 25190 the file includes preprocessor macro information. 25191 25192 GDB Command 25193 ........... 25194 25195 The GDB equivalent is `info source' 25196 25197 Example 25198 ....... 25199 25200 (gdb) 25201 123-file-list-exec-source-file 25202 123^done,line="1",file="foo.c",fullname="/home/bar/foo.c,macro-info="1" 25203 (gdb) 25204 25205 The `-file-list-exec-source-files' Command 25206 ------------------------------------------ 25207 25208 Synopsis 25209 ........ 25210 25211 -file-list-exec-source-files 25212 25213 List the source files for the current executable. 25214 25215 It will always output the filename, but only when GDB can find the 25216 absolute file name of a source file, will it output the fullname. 25217 25218 GDB Command 25219 ........... 25220 25221 The GDB equivalent is `info sources'. `gdbtk' has an analogous command 25222 `gdb_listfiles'. 25223 25224 Example 25225 ....... 25226 25227 (gdb) 25228 -file-list-exec-source-files 25229 ^done,files=[ 25230 {file=foo.c,fullname=/home/foo.c}, 25231 {file=/home/bar.c,fullname=/home/bar.c}, 25232 {file=gdb_could_not_find_fullpath.c}] 25233 (gdb) 25234 25235 The `-file-symbol-file' Command 25236 ------------------------------- 25237 25238 Synopsis 25239 ........ 25240 25241 -file-symbol-file FILE 25242 25243 Read symbol table info from the specified FILE argument. When used 25244 without arguments, clears GDB's symbol table info. No output is 25245 produced, except for a completion notification. 25246 25247 GDB Command 25248 ........... 25249 25250 The corresponding GDB command is `symbol-file'. 25251 25252 Example 25253 ....... 25254 25255 (gdb) 25256 -file-symbol-file /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx 25257 ^done 25258 (gdb) 25259 25260 25261 File: gdb.info, Node: GDB/MI Target Manipulation, Next: GDB/MI File Transfer Commands, Prev: GDB/MI File Commands, Up: GDB/MI 25262 25263 27.18 GDB/MI Target Manipulation Commands 25264 ========================================= 25265 25266 The `-target-attach' Command 25267 ---------------------------- 25268 25269 Synopsis 25270 ........ 25271 25272 -target-attach PID | GID | FILE 25273 25274 Attach to a process PID or a file FILE outside of GDB, or a thread 25275 group GID. If attaching to a thread group, the id previously returned 25276 by `-list-thread-groups --available' must be used. 25277 25278 GDB Command 25279 ........... 25280 25281 The corresponding GDB command is `attach'. 25282 25283 Example 25284 ....... 25285 25286 (gdb) 25287 -target-attach 34 25288 =thread-created,id="1" 25289 *stopped,thread-id="1",frame={addr="0xb7f7e410",func="bar",args=[]} 25290 ^done 25291 (gdb) 25292 25293 The `-target-detach' Command 25294 ---------------------------- 25295 25296 Synopsis 25297 ........ 25298 25299 -target-detach [ PID | GID ] 25300 25301 Detach from the remote target which normally resumes its execution. 25302 If either PID or GID is specified, detaches from either the specified 25303 process, or specified thread group. There's no output. 25304 25305 GDB Command 25306 ........... 25307 25308 The corresponding GDB command is `detach'. 25309 25310 Example 25311 ....... 25312 25313 (gdb) 25314 -target-detach 25315 ^done 25316 (gdb) 25317 25318 The `-target-disconnect' Command 25319 -------------------------------- 25320 25321 Synopsis 25322 ........ 25323 25324 -target-disconnect 25325 25326 Disconnect from the remote target. There's no output and the target 25327 is generally not resumed. 25328 25329 GDB Command 25330 ........... 25331 25332 The corresponding GDB command is `disconnect'. 25333 25334 Example 25335 ....... 25336 25337 (gdb) 25338 -target-disconnect 25339 ^done 25340 (gdb) 25341 25342 The `-target-download' Command 25343 ------------------------------ 25344 25345 Synopsis 25346 ........ 25347 25348 -target-download 25349 25350 Loads the executable onto the remote target. It prints out an 25351 update message every half second, which includes the fields: 25352 25353 `section' 25354 The name of the section. 25355 25356 `section-sent' 25357 The size of what has been sent so far for that section. 25358 25359 `section-size' 25360 The size of the section. 25361 25362 `total-sent' 25363 The total size of what was sent so far (the current and the 25364 previous sections). 25365 25366 `total-size' 25367 The size of the overall executable to download. 25368 25369 Each message is sent as status record (*note GDB/MI Output Syntax: 25370 GDB/MI Output Syntax.). 25371 25372 In addition, it prints the name and size of the sections, as they are 25373 downloaded. These messages include the following fields: 25374 25375 `section' 25376 The name of the section. 25377 25378 `section-size' 25379 The size of the section. 25380 25381 `total-size' 25382 The size of the overall executable to download. 25383 25384 At the end, a summary is printed. 25385 25386 GDB Command 25387 ........... 25388 25389 The corresponding GDB command is `load'. 25390 25391 Example 25392 ....... 25393 25394 Note: each status message appears on a single line. Here the messages 25395 have been broken down so that they can fit onto a page. 25396 25397 (gdb) 25398 -target-download 25399 +download,{section=".text",section-size="6668",total-size="9880"} 25400 +download,{section=".text",section-sent="512",section-size="6668", 25401 total-sent="512",total-size="9880"} 25402 +download,{section=".text",section-sent="1024",section-size="6668", 25403 total-sent="1024",total-size="9880"} 25404 +download,{section=".text",section-sent="1536",section-size="6668", 25405 total-sent="1536",total-size="9880"} 25406 +download,{section=".text",section-sent="2048",section-size="6668", 25407 total-sent="2048",total-size="9880"} 25408 +download,{section=".text",section-sent="2560",section-size="6668", 25409 total-sent="2560",total-size="9880"} 25410 +download,{section=".text",section-sent="3072",section-size="6668", 25411 total-sent="3072",total-size="9880"} 25412 +download,{section=".text",section-sent="3584",section-size="6668", 25413 total-sent="3584",total-size="9880"} 25414 +download,{section=".text",section-sent="4096",section-size="6668", 25415 total-sent="4096",total-size="9880"} 25416 +download,{section=".text",section-sent="4608",section-size="6668", 25417 total-sent="4608",total-size="9880"} 25418 +download,{section=".text",section-sent="5120",section-size="6668", 25419 total-sent="5120",total-size="9880"} 25420 +download,{section=".text",section-sent="5632",section-size="6668", 25421 total-sent="5632",total-size="9880"} 25422 +download,{section=".text",section-sent="6144",section-size="6668", 25423 total-sent="6144",total-size="9880"} 25424 +download,{section=".text",section-sent="6656",section-size="6668", 25425 total-sent="6656",total-size="9880"} 25426 +download,{section=".init",section-size="28",total-size="9880"} 25427 +download,{section=".fini",section-size="28",total-size="9880"} 25428 +download,{section=".data",section-size="3156",total-size="9880"} 25429 +download,{section=".data",section-sent="512",section-size="3156", 25430 total-sent="7236",total-size="9880"} 25431 +download,{section=".data",section-sent="1024",section-size="3156", 25432 total-sent="7748",total-size="9880"} 25433 +download,{section=".data",section-sent="1536",section-size="3156", 25434 total-sent="8260",total-size="9880"} 25435 +download,{section=".data",section-sent="2048",section-size="3156", 25436 total-sent="8772",total-size="9880"} 25437 +download,{section=".data",section-sent="2560",section-size="3156", 25438 total-sent="9284",total-size="9880"} 25439 +download,{section=".data",section-sent="3072",section-size="3156", 25440 total-sent="9796",total-size="9880"} 25441 ^done,address="0x10004",load-size="9880",transfer-rate="6586", 25442 write-rate="429" 25443 (gdb) 25444 25445 GDB Command 25446 ........... 25447 25448 No equivalent. 25449 25450 Example 25451 ....... 25452 25453 N.A. 25454 25455 The `-target-select' Command 25456 ---------------------------- 25457 25458 Synopsis 25459 ........ 25460 25461 -target-select TYPE PARAMETERS ... 25462 25463 Connect GDB to the remote target. This command takes two args: 25464 25465 `TYPE' 25466 The type of target, for instance `remote', etc. 25467 25468 `PARAMETERS' 25469 Device names, host names and the like. *Note Commands for 25470 Managing Targets: Target Commands, for more details. 25471 25472 The output is a connection notification, followed by the address at 25473 which the target program is, in the following form: 25474 25475 ^connected,addr="ADDRESS",func="FUNCTION NAME", 25476 args=[ARG LIST] 25477 25478 GDB Command 25479 ........... 25480 25481 The corresponding GDB command is `target'. 25482 25483 Example 25484 ....... 25485 25486 (gdb) 25487 -target-select remote /dev/ttya 25488 ^connected,addr="0xfe00a300",func="??",args=[] 25489 (gdb) 25490 25491 25492 File: gdb.info, Node: GDB/MI File Transfer Commands, Next: GDB/MI Miscellaneous Commands, Prev: GDB/MI Target Manipulation, Up: GDB/MI 25493 25494 27.19 GDB/MI File Transfer Commands 25495 =================================== 25496 25497 The `-target-file-put' Command 25498 ------------------------------ 25499 25500 Synopsis 25501 ........ 25502 25503 -target-file-put HOSTFILE TARGETFILE 25504 25505 Copy file HOSTFILE from the host system (the machine running GDB) to 25506 TARGETFILE on the target system. 25507 25508 GDB Command 25509 ........... 25510 25511 The corresponding GDB command is `remote put'. 25512 25513 Example 25514 ....... 25515 25516 (gdb) 25517 -target-file-put localfile remotefile 25518 ^done 25519 (gdb) 25520 25521 The `-target-file-get' Command 25522 ------------------------------ 25523 25524 Synopsis 25525 ........ 25526 25527 -target-file-get TARGETFILE HOSTFILE 25528 25529 Copy file TARGETFILE from the target system to HOSTFILE on the host 25530 system. 25531 25532 GDB Command 25533 ........... 25534 25535 The corresponding GDB command is `remote get'. 25536 25537 Example 25538 ....... 25539 25540 (gdb) 25541 -target-file-get remotefile localfile 25542 ^done 25543 (gdb) 25544 25545 The `-target-file-delete' Command 25546 --------------------------------- 25547 25548 Synopsis 25549 ........ 25550 25551 -target-file-delete TARGETFILE 25552 25553 Delete TARGETFILE from the target system. 25554 25555 GDB Command 25556 ........... 25557 25558 The corresponding GDB command is `remote delete'. 25559 25560 Example 25561 ....... 25562 25563 (gdb) 25564 -target-file-delete remotefile 25565 ^done 25566 (gdb) 25567 25568 25569 File: gdb.info, Node: GDB/MI Miscellaneous Commands, Prev: GDB/MI File Transfer Commands, Up: GDB/MI 25570 25571 27.20 Miscellaneous GDB/MI Commands 25572 =================================== 25573 25574 The `-gdb-exit' Command 25575 ----------------------- 25576 25577 Synopsis 25578 ........ 25579 25580 -gdb-exit 25581 25582 Exit GDB immediately. 25583 25584 GDB Command 25585 ........... 25586 25587 Approximately corresponds to `quit'. 25588 25589 Example 25590 ....... 25591 25592 (gdb) 25593 -gdb-exit 25594 ^exit 25595 25596 The `-gdb-set' Command 25597 ---------------------- 25598 25599 Synopsis 25600 ........ 25601 25602 -gdb-set 25603 25604 Set an internal GDB variable. 25605 25606 GDB Command 25607 ........... 25608 25609 The corresponding GDB command is `set'. 25610 25611 Example 25612 ....... 25613 25614 (gdb) 25615 -gdb-set $foo=3 25616 ^done 25617 (gdb) 25618 25619 The `-gdb-show' Command 25620 ----------------------- 25621 25622 Synopsis 25623 ........ 25624 25625 -gdb-show 25626 25627 Show the current value of a GDB variable. 25628 25629 GDB Command 25630 ........... 25631 25632 The corresponding GDB command is `show'. 25633 25634 Example 25635 ....... 25636 25637 (gdb) 25638 -gdb-show annotate 25639 ^done,value="0" 25640 (gdb) 25641 25642 The `-gdb-version' Command 25643 -------------------------- 25644 25645 Synopsis 25646 ........ 25647 25648 -gdb-version 25649 25650 Show version information for GDB. Used mostly in testing. 25651 25652 GDB Command 25653 ........... 25654 25655 The GDB equivalent is `show version'. GDB by default shows this 25656 information when you start an interactive session. 25657 25658 Example 25659 ....... 25660 25661 (gdb) 25662 -gdb-version 25663 ~GNU gdb 5.2.1 25664 ~Copyright 2000 Free Software Foundation, Inc. 25665 ~GDB is free software, covered by the GNU General Public License, and 25666 ~you are welcome to change it and/or distribute copies of it under 25667 ~ certain conditions. 25668 ~Type "show copying" to see the conditions. 25669 ~There is absolutely no warranty for GDB. Type "show warranty" for 25670 ~ details. 25671 ~This GDB was configured as 25672 "--host=sparc-sun-solaris2.5.1 --target=ppc-eabi". 25673 ^done 25674 (gdb) 25675 25676 The `-list-features' Command 25677 ---------------------------- 25678 25679 Returns a list of particular features of the MI protocol that this 25680 version of gdb implements. A feature can be a command, or a new field 25681 in an output of some command, or even an important bugfix. While a 25682 frontend can sometimes detect presence of a feature at runtime, it is 25683 easier to perform detection at debugger startup. 25684 25685 The command returns a list of strings, with each string naming an 25686 available feature. Each returned string is just a name, it does not 25687 have any internal structure. The list of possible feature names is 25688 given below. 25689 25690 Example output: 25691 25692 (gdb) -list-features 25693 ^done,result=["feature1","feature2"] 25694 25695 The current list of features is: 25696 25697 `frozen-varobjs' 25698 Indicates presence of the `-var-set-frozen' command, as well as 25699 possible presense of the `frozen' field in the output of 25700 `-varobj-create'. 25701 25702 `pending-breakpoints' 25703 Indicates presence of the `-f' option to the `-break-insert' 25704 command. 25705 25706 `python' 25707 Indicates presence of Python scripting support, Python-based 25708 pretty-printing commands, and possible presence of the 25709 `display_hint' field in the output of `-var-list-children' 25710 25711 `thread-info' 25712 Indicates presence of the `-thread-info' command. 25713 25714 `data-read-memory-bytes' 25715 Indicates presense of the `-data-read-memory-bytes' and the 25716 `-data-write-memory-bytes' commands. 25717 25718 25719 The `-list-target-features' Command 25720 ----------------------------------- 25721 25722 Returns a list of particular features that are supported by the target. 25723 Those features affect the permitted MI commands, but unlike the 25724 features reported by the `-list-features' command, the features depend 25725 on which target GDB is using at the moment. Whenever a target can 25726 change, due to commands such as `-target-select', `-target-attach' or 25727 `-exec-run', the list of target features may change, and the frontend 25728 should obtain it again. Example output: 25729 25730 (gdb) -list-features 25731 ^done,result=["async"] 25732 25733 The current list of features is: 25734 25735 `async' 25736 Indicates that the target is capable of asynchronous command 25737 execution, which means that GDB will accept further commands while 25738 the target is running. 25739 25740 `reverse' 25741 Indicates that the target is capable of reverse execution. *Note 25742 Reverse Execution::, for more information. 25743 25744 25745 The `-list-thread-groups' Command 25746 --------------------------------- 25747 25748 Synopsis 25749 -------- 25750 25751 -list-thread-groups [ --available ] [ --recurse 1 ] [ GROUP ... ] 25752 25753 Lists thread groups (*note Thread groups::). When a single thread 25754 group is passed as the argument, lists the children of that group. 25755 When several thread group are passed, lists information about those 25756 thread groups. Without any parameters, lists information about all 25757 top-level thread groups. 25758 25759 Normally, thread groups that are being debugged are reported. With 25760 the `--available' option, GDB reports thread groups available on the 25761 target. 25762 25763 The output of this command may have either a `threads' result or a 25764 `groups' result. The `thread' result has a list of tuples as value, 25765 with each tuple describing a thread (*note GDB/MI Thread 25766 Information::). The `groups' result has a list of tuples as value, 25767 each tuple describing a thread group. If top-level groups are 25768 requested (that is, no parameter is passed), or when several groups are 25769 passed, the output always has a `groups' result. The format of the 25770 `group' result is described below. 25771 25772 To reduce the number of roundtrips it's possible to list thread 25773 groups together with their children, by passing the `--recurse' option 25774 and the recursion depth. Presently, only recursion depth of 1 is 25775 permitted. If this option is present, then every reported thread group 25776 will also include its children, either as `group' or `threads' field. 25777 25778 In general, any combination of option and parameters is permitted, 25779 with the following caveats: 25780 25781 * When a single thread group is passed, the output will typically be 25782 the `threads' result. Because threads may not contain anything, 25783 the `recurse' option will be ignored. 25784 25785 * When the `--available' option is passed, limited information may 25786 be available. In particular, the list of threads of a process 25787 might be inaccessible. Further, specifying specific thread groups 25788 might not give any performance advantage over listing all thread 25789 groups. The frontend should assume that `-list-thread-groups 25790 --available' is always an expensive operation and cache the 25791 results. 25792 25793 25794 The `groups' result is a list of tuples, where each tuple may have 25795 the following fields: 25796 25797 `id' 25798 Identifier of the thread group. This field is always present. 25799 The identifier is an opaque string; frontends should not try to 25800 convert it to an integer, even though it might look like one. 25801 25802 `type' 25803 The type of the thread group. At present, only `process' is a 25804 valid type. 25805 25806 `pid' 25807 The target-specific process identifier. This field is only present 25808 for thread groups of type `process' and only if the process exists. 25809 25810 `num_children' 25811 The number of children this thread group has. This field may be 25812 absent for an available thread group. 25813 25814 `threads' 25815 This field has a list of tuples as value, each tuple describing a 25816 thread. It may be present if the `--recurse' option is specified, 25817 and it's actually possible to obtain the threads. 25818 25819 `cores' 25820 This field is a list of integers, each identifying a core that one 25821 thread of the group is running on. This field may be absent if 25822 such information is not available. 25823 25824 `executable' 25825 The name of the executable file that corresponds to this thread 25826 group. The field is only present for thread groups of type 25827 `process', and only if there is a corresponding executable file. 25828 25829 25830 Example 25831 ------- 25832 25833 gdb 25834 -list-thread-groups 25835 ^done,groups=[{id="17",type="process",pid="yyy",num_children="2"}] 25836 -list-thread-groups 17 25837 ^done,threads=[{id="2",target-id="Thread 0xb7e14b90 (LWP 21257)", 25838 frame={level="0",addr="0xffffe410",func="__kernel_vsyscall",args=[]},state="running"}, 25839 {id="1",target-id="Thread 0xb7e156b0 (LWP 21254)", 25840 frame={level="0",addr="0x0804891f",func="foo",args=[{name="i",value="10"}], 25841 file="/tmp/a.c",fullname="/tmp/a.c",line="158"},state="running"}]] 25842 -list-thread-groups --available 25843 ^done,groups=[{id="17",type="process",pid="yyy",num_children="2",cores=[1,2]}] 25844 -list-thread-groups --available --recurse 1 25845 ^done,groups=[{id="17", types="process",pid="yyy",num_children="2",cores=[1,2], 25846 threads=[{id="1",target-id="Thread 0xb7e14b90",cores=[1]}, 25847 {id="2",target-id="Thread 0xb7e14b90",cores=[2]}]},..] 25848 -list-thread-groups --available --recurse 1 17 18 25849 ^done,groups=[{id="17", types="process",pid="yyy",num_children="2",cores=[1,2], 25850 threads=[{id="1",target-id="Thread 0xb7e14b90",cores=[1]}, 25851 {id="2",target-id="Thread 0xb7e14b90",cores=[2]}]},...] 25852 25853 The `-add-inferior' Command 25854 --------------------------- 25855 25856 Synopsis 25857 -------- 25858 25859 -add-inferior 25860 25861 Creates a new inferior (*note Inferiors and Programs::). The created 25862 inferior is not associated with any executable. Such association may 25863 be established with the `-file-exec-and-symbols' command (*note GDB/MI 25864 File Commands::). The command response has a single field, 25865 `thread-group', whose value is the identifier of the thread group 25866 corresponding to the new inferior. 25867 25868 Example 25869 ------- 25870 25871 gdb 25872 -add-inferior 25873 ^done,thread-group="i3" 25874 25875 The `-interpreter-exec' Command 25876 ------------------------------- 25877 25878 Synopsis 25879 -------- 25880 25881 -interpreter-exec INTERPRETER COMMAND 25882 Execute the specified COMMAND in the given INTERPRETER. 25883 25884 GDB Command 25885 ----------- 25886 25887 The corresponding GDB command is `interpreter-exec'. 25888 25889 Example 25890 ------- 25891 25892 (gdb) 25893 -interpreter-exec console "break main" 25894 &"During symbol reading, couldn't parse type; debugger out of date?.\n" 25895 &"During symbol reading, bad structure-type format.\n" 25896 ~"Breakpoint 1 at 0x8074fc6: file ../../src/gdb/main.c, line 743.\n" 25897 ^done 25898 (gdb) 25899 25900 The `-inferior-tty-set' Command 25901 ------------------------------- 25902 25903 Synopsis 25904 -------- 25905 25906 -inferior-tty-set /dev/pts/1 25907 25908 Set terminal for future runs of the program being debugged. 25909 25910 GDB Command 25911 ----------- 25912 25913 The corresponding GDB command is `set inferior-tty' /dev/pts/1. 25914 25915 Example 25916 ------- 25917 25918 (gdb) 25919 -inferior-tty-set /dev/pts/1 25920 ^done 25921 (gdb) 25922 25923 The `-inferior-tty-show' Command 25924 -------------------------------- 25925 25926 Synopsis 25927 -------- 25928 25929 -inferior-tty-show 25930 25931 Show terminal for future runs of program being debugged. 25932 25933 GDB Command 25934 ----------- 25935 25936 The corresponding GDB command is `show inferior-tty'. 25937 25938 Example 25939 ------- 25940 25941 (gdb) 25942 -inferior-tty-set /dev/pts/1 25943 ^done 25944 (gdb) 25945 -inferior-tty-show 25946 ^done,inferior_tty_terminal="/dev/pts/1" 25947 (gdb) 25948 25949 The `-enable-timings' Command 25950 ----------------------------- 25951 25952 Synopsis 25953 -------- 25954 25955 -enable-timings [yes | no] 25956 25957 Toggle the printing of the wallclock, user and system times for an MI 25958 command as a field in its output. This command is to help frontend 25959 developers optimize the performance of their code. No argument is 25960 equivalent to `yes'. 25961 25962 GDB Command 25963 ----------- 25964 25965 No equivalent. 25966 25967 Example 25968 ------- 25969 25970 (gdb) 25971 -enable-timings 25972 ^done 25973 (gdb) 25974 -break-insert main 25975 ^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y", 25976 addr="0x080484ed",func="main",file="myprog.c", 25977 fullname="/home/nickrob/myprog.c",line="73",times="0"}, 25978 time={wallclock="0.05185",user="0.00800",system="0.00000"} 25979 (gdb) 25980 -enable-timings no 25981 ^done 25982 (gdb) 25983 -exec-run 25984 ^running 25985 (gdb) 25986 *stopped,reason="breakpoint-hit",disp="keep",bkptno="1",thread-id="0", 25987 frame={addr="0x080484ed",func="main",args=[{name="argc",value="1"}, 25988 {name="argv",value="0xbfb60364"}],file="myprog.c", 25989 fullname="/home/nickrob/myprog.c",line="73"} 25990 (gdb) 25991 25992 25993 File: gdb.info, Node: Annotations, Next: JIT Interface, Prev: GDB/MI, Up: Top 25994 25995 28 GDB Annotations 25996 ****************** 25997 25998 This chapter describes annotations in GDB. Annotations were designed 25999 to interface GDB to graphical user interfaces or other similar programs 26000 which want to interact with GDB at a relatively high level. 26001 26002 The annotation mechanism has largely been superseded by GDB/MI 26003 (*note GDB/MI::). 26004 26005 * Menu: 26006 26007 * Annotations Overview:: What annotations are; the general syntax. 26008 * Server Prefix:: Issuing a command without affecting user state. 26009 * Prompting:: Annotations marking GDB's need for input. 26010 * Errors:: Annotations for error messages. 26011 * Invalidation:: Some annotations describe things now invalid. 26012 * Annotations for Running:: 26013 Whether the program is running, how it stopped, etc. 26014 * Source Annotations:: Annotations describing source code. 26015 26016 26017 File: gdb.info, Node: Annotations Overview, Next: Server Prefix, Up: Annotations 26018 26019 28.1 What is an Annotation? 26020 =========================== 26021 26022 Annotations start with a newline character, two `control-z' characters, 26023 and the name of the annotation. If there is no additional information 26024 associated with this annotation, the name of the annotation is followed 26025 immediately by a newline. If there is additional information, the name 26026 of the annotation is followed by a space, the additional information, 26027 and a newline. The additional information cannot contain newline 26028 characters. 26029 26030 Any output not beginning with a newline and two `control-z' 26031 characters denotes literal output from GDB. Currently there is no need 26032 for GDB to output a newline followed by two `control-z' characters, but 26033 if there was such a need, the annotations could be extended with an 26034 `escape' annotation which means those three characters as output. 26035 26036 The annotation LEVEL, which is specified using the `--annotate' 26037 command line option (*note Mode Options::), controls how much 26038 information GDB prints together with its prompt, values of expressions, 26039 source lines, and other types of output. Level 0 is for no 26040 annotations, level 1 is for use when GDB is run as a subprocess of GNU 26041 Emacs, level 3 is the maximum annotation suitable for programs that 26042 control GDB, and level 2 annotations have been made obsolete (*note 26043 Limitations of the Annotation Interface: (annotate)Limitations.). 26044 26045 `set annotate LEVEL' 26046 The GDB command `set annotate' sets the level of annotations to 26047 the specified LEVEL. 26048 26049 `show annotate' 26050 Show the current annotation level. 26051 26052 This chapter describes level 3 annotations. 26053 26054 A simple example of starting up GDB with annotations is: 26055 26056 $ gdb --annotate=3 26057 GNU gdb 6.0 26058 Copyright 2003 Free Software Foundation, Inc. 26059 GDB is free software, covered by the GNU General Public License, 26060 and you are welcome to change it and/or distribute copies of it 26061 under certain conditions. 26062 Type "show copying" to see the conditions. 26063 There is absolutely no warranty for GDB. Type "show warranty" 26064 for details. 26065 This GDB was configured as "i386-pc-linux-gnu" 26066 26067 ^Z^Zpre-prompt 26068 (gdb) 26069 ^Z^Zprompt 26070 quit 26071 26072 ^Z^Zpost-prompt 26073 $ 26074 26075 Here `quit' is input to GDB; the rest is output from GDB. The three 26076 lines beginning `^Z^Z' (where `^Z' denotes a `control-z' character) are 26077 annotations; the rest is output from GDB. 26078 26079 26080 File: gdb.info, Node: Server Prefix, Next: Prompting, Prev: Annotations Overview, Up: Annotations 26081 26082 28.2 The Server Prefix 26083 ====================== 26084 26085 If you prefix a command with `server ' then it will not affect the 26086 command history, nor will it affect GDB's notion of which command to 26087 repeat if <RET> is pressed on a line by itself. This means that 26088 commands can be run behind a user's back by a front-end in a 26089 transparent manner. 26090 26091 The `server ' prefix does not affect the recording of values into 26092 the value history; to print a value without recording it into the value 26093 history, use the `output' command instead of the `print' command. 26094 26095 Using this prefix also disables confirmation requests (*note 26096 confirmation requests::). 26097 26098 26099 File: gdb.info, Node: Prompting, Next: Errors, Prev: Server Prefix, Up: Annotations 26100 26101 28.3 Annotation for GDB Input 26102 ============================= 26103 26104 When GDB prompts for input, it annotates this fact so it is possible to 26105 know when to send output, when the output from a given command is over, 26106 etc. 26107 26108 Different kinds of input each have a different "input type". Each 26109 input type has three annotations: a `pre-' annotation, which denotes 26110 the beginning of any prompt which is being output, a plain annotation, 26111 which denotes the end of the prompt, and then a `post-' annotation 26112 which denotes the end of any echo which may (or may not) be associated 26113 with the input. For example, the `prompt' input type features the 26114 following annotations: 26115 26116 ^Z^Zpre-prompt 26117 ^Z^Zprompt 26118 ^Z^Zpost-prompt 26119 26120 The input types are 26121 26122 `prompt' 26123 When GDB is prompting for a command (the main GDB prompt). 26124 26125 `commands' 26126 When GDB prompts for a set of commands, like in the `commands' 26127 command. The annotations are repeated for each command which is 26128 input. 26129 26130 `overload-choice' 26131 When GDB wants the user to select between various overloaded 26132 functions. 26133 26134 `query' 26135 When GDB wants the user to confirm a potentially dangerous 26136 operation. 26137 26138 `prompt-for-continue' 26139 When GDB is asking the user to press return to continue. Note: 26140 Don't expect this to work well; instead use `set height 0' to 26141 disable prompting. This is because the counting of lines is buggy 26142 in the presence of annotations. 26143 26144 26145 File: gdb.info, Node: Errors, Next: Invalidation, Prev: Prompting, Up: Annotations 26146 26147 28.4 Errors 26148 =========== 26149 26150 ^Z^Zquit 26151 26152 This annotation occurs right before GDB responds to an interrupt. 26153 26154 ^Z^Zerror 26155 26156 This annotation occurs right before GDB responds to an error. 26157 26158 Quit and error annotations indicate that any annotations which GDB 26159 was in the middle of may end abruptly. For example, if a 26160 `value-history-begin' annotation is followed by a `error', one cannot 26161 expect to receive the matching `value-history-end'. One cannot expect 26162 not to receive it either, however; an error annotation does not 26163 necessarily mean that GDB is immediately returning all the way to the 26164 top level. 26165 26166 A quit or error annotation may be preceded by 26167 26168 ^Z^Zerror-begin 26169 26170 Any output between that and the quit or error annotation is the error 26171 message. 26172 26173 Warning messages are not yet annotated. 26174 26175 26176 File: gdb.info, Node: Invalidation, Next: Annotations for Running, Prev: Errors, Up: Annotations 26177 26178 28.5 Invalidation Notices 26179 ========================= 26180 26181 The following annotations say that certain pieces of state may have 26182 changed. 26183 26184 `^Z^Zframes-invalid' 26185 The frames (for example, output from the `backtrace' command) may 26186 have changed. 26187 26188 `^Z^Zbreakpoints-invalid' 26189 The breakpoints may have changed. For example, the user just 26190 added or deleted a breakpoint. 26191 26192 26193 File: gdb.info, Node: Annotations for Running, Next: Source Annotations, Prev: Invalidation, Up: Annotations 26194 26195 28.6 Running the Program 26196 ======================== 26197 26198 When the program starts executing due to a GDB command such as `step' 26199 or `continue', 26200 26201 ^Z^Zstarting 26202 26203 is output. When the program stops, 26204 26205 ^Z^Zstopped 26206 26207 is output. Before the `stopped' annotation, a variety of 26208 annotations describe how the program stopped. 26209 26210 `^Z^Zexited EXIT-STATUS' 26211 The program exited, and EXIT-STATUS is the exit status (zero for 26212 successful exit, otherwise nonzero). 26213 26214 `^Z^Zsignalled' 26215 The program exited with a signal. After the `^Z^Zsignalled', the 26216 annotation continues: 26217 26218 INTRO-TEXT 26219 ^Z^Zsignal-name 26220 NAME 26221 ^Z^Zsignal-name-end 26222 MIDDLE-TEXT 26223 ^Z^Zsignal-string 26224 STRING 26225 ^Z^Zsignal-string-end 26226 END-TEXT 26227 26228 where NAME is the name of the signal, such as `SIGILL' or 26229 `SIGSEGV', and STRING is the explanation of the signal, such as 26230 `Illegal Instruction' or `Segmentation fault'. INTRO-TEXT, 26231 MIDDLE-TEXT, and END-TEXT are for the user's benefit and have no 26232 particular format. 26233 26234 `^Z^Zsignal' 26235 The syntax of this annotation is just like `signalled', but GDB is 26236 just saying that the program received the signal, not that it was 26237 terminated with it. 26238 26239 `^Z^Zbreakpoint NUMBER' 26240 The program hit breakpoint number NUMBER. 26241 26242 `^Z^Zwatchpoint NUMBER' 26243 The program hit watchpoint number NUMBER. 26244 26245 26246 File: gdb.info, Node: Source Annotations, Prev: Annotations for Running, Up: Annotations 26247 26248 28.7 Displaying Source 26249 ====================== 26250 26251 The following annotation is used instead of displaying source code: 26252 26253 ^Z^Zsource FILENAME:LINE:CHARACTER:MIDDLE:ADDR 26254 26255 where FILENAME is an absolute file name indicating which source 26256 file, LINE is the line number within that file (where 1 is the first 26257 line in the file), CHARACTER is the character position within the file 26258 (where 0 is the first character in the file) (for most debug formats 26259 this will necessarily point to the beginning of a line), MIDDLE is 26260 `middle' if ADDR is in the middle of the line, or `beg' if ADDR is at 26261 the beginning of the line, and ADDR is the address in the target 26262 program associated with the source which is being displayed. ADDR is 26263 in the form `0x' followed by one or more lowercase hex digits (note 26264 that this does not depend on the language). 26265 26266 26267 File: gdb.info, Node: JIT Interface, Next: GDB Bugs, Prev: Annotations, Up: Top 26268 26269 29 JIT Compilation Interface 26270 **************************** 26271 26272 This chapter documents GDB's "just-in-time" (JIT) compilation 26273 interface. A JIT compiler is a program or library that generates native 26274 executable code at runtime and executes it, usually in order to achieve 26275 good performance while maintaining platform independence. 26276 26277 Programs that use JIT compilation are normally difficult to debug 26278 because portions of their code are generated at runtime, instead of 26279 being loaded from object files, which is where GDB normally finds the 26280 program's symbols and debug information. In order to debug programs 26281 that use JIT compilation, GDB has an interface that allows the program 26282 to register in-memory symbol files with GDB at runtime. 26283 26284 If you are using GDB to debug a program that uses this interface, 26285 then it should work transparently so long as you have not stripped the 26286 binary. If you are developing a JIT compiler, then the interface is 26287 documented in the rest of this chapter. At this time, the only known 26288 client of this interface is the LLVM JIT. 26289 26290 Broadly speaking, the JIT interface mirrors the dynamic loader 26291 interface. The JIT compiler communicates with GDB by writing data into 26292 a global variable and calling a fuction at a well-known symbol. When 26293 GDB attaches, it reads a linked list of symbol files from the global 26294 variable to find existing code, and puts a breakpoint in the function 26295 so that it can find out about additional code. 26296 26297 * Menu: 26298 26299 * Declarations:: Relevant C struct declarations 26300 * Registering Code:: Steps to register code 26301 * Unregistering Code:: Steps to unregister code 26302 26303 26304 File: gdb.info, Node: Declarations, Next: Registering Code, Up: JIT Interface 26305 26306 29.1 JIT Declarations 26307 ===================== 26308 26309 These are the relevant struct declarations that a C program should 26310 include to implement the interface: 26311 26312 typedef enum 26313 { 26314 JIT_NOACTION = 0, 26315 JIT_REGISTER_FN, 26316 JIT_UNREGISTER_FN 26317 } jit_actions_t; 26318 26319 struct jit_code_entry 26320 { 26321 struct jit_code_entry *next_entry; 26322 struct jit_code_entry *prev_entry; 26323 const char *symfile_addr; 26324 uint64_t symfile_size; 26325 }; 26326 26327 struct jit_descriptor 26328 { 26329 uint32_t version; 26330 /* This type should be jit_actions_t, but we use uint32_t 26331 to be explicit about the bitwidth. */ 26332 uint32_t action_flag; 26333 struct jit_code_entry *relevant_entry; 26334 struct jit_code_entry *first_entry; 26335 }; 26336 26337 /* GDB puts a breakpoint in this function. */ 26338 void __attribute__((noinline)) __jit_debug_register_code() { }; 26339 26340 /* Make sure to specify the version statically, because the 26341 debugger may check the version before we can set it. */ 26342 struct jit_descriptor __jit_debug_descriptor = { 1, 0, 0, 0 }; 26343 26344 If the JIT is multi-threaded, then it is important that the JIT 26345 synchronize any modifications to this global data properly, which can 26346 easily be done by putting a global mutex around modifications to these 26347 structures. 26348 26349 26350 File: gdb.info, Node: Registering Code, Next: Unregistering Code, Prev: Declarations, Up: JIT Interface 26351 26352 29.2 Registering Code 26353 ===================== 26354 26355 To register code with GDB, the JIT should follow this protocol: 26356 26357 * Generate an object file in memory with symbols and other desired 26358 debug information. The file must include the virtual addresses of 26359 the sections. 26360 26361 * Create a code entry for the file, which gives the start and size 26362 of the symbol file. 26363 26364 * Add it to the linked list in the JIT descriptor. 26365 26366 * Point the relevant_entry field of the descriptor at the entry. 26367 26368 * Set `action_flag' to `JIT_REGISTER' and call 26369 `__jit_debug_register_code'. 26370 26371 When GDB is attached and the breakpoint fires, GDB uses the 26372 `relevant_entry' pointer so it doesn't have to walk the list looking for 26373 new code. However, the linked list must still be maintained in order 26374 to allow GDB to attach to a running process and still find the symbol 26375 files. 26376 26377 26378 File: gdb.info, Node: Unregistering Code, Prev: Registering Code, Up: JIT Interface 26379 26380 29.3 Unregistering Code 26381 ======================= 26382 26383 If code is freed, then the JIT should use the following protocol: 26384 26385 * Remove the code entry corresponding to the code from the linked 26386 list. 26387 26388 * Point the `relevant_entry' field of the descriptor at the code 26389 entry. 26390 26391 * Set `action_flag' to `JIT_UNREGISTER' and call 26392 `__jit_debug_register_code'. 26393 26394 If the JIT frees or recompiles code without unregistering it, then 26395 GDB and the JIT will leak the memory used for the associated symbol 26396 files. 26397 26398 26399 File: gdb.info, Node: GDB Bugs, Next: Command Line Editing, Prev: JIT Interface, Up: Top 26400 26401 30 Reporting Bugs in GDB 26402 ************************ 26403 26404 Your bug reports play an essential role in making GDB reliable. 26405 26406 Reporting a bug may help you by bringing a solution to your problem, 26407 or it may not. But in any case the principal function of a bug report 26408 is to help the entire community by making the next version of GDB work 26409 better. Bug reports are your contribution to the maintenance of GDB. 26410 26411 In order for a bug report to serve its purpose, you must include the 26412 information that enables us to fix the bug. 26413 26414 * Menu: 26415 26416 * Bug Criteria:: Have you found a bug? 26417 * Bug Reporting:: How to report bugs 26418 26419 26420 File: gdb.info, Node: Bug Criteria, Next: Bug Reporting, Up: GDB Bugs 26421 26422 30.1 Have You Found a Bug? 26423 ========================== 26424 26425 If you are not sure whether you have found a bug, here are some 26426 guidelines: 26427 26428 * If the debugger gets a fatal signal, for any input whatever, that 26429 is a GDB bug. Reliable debuggers never crash. 26430 26431 * If GDB produces an error message for valid input, that is a bug. 26432 (Note that if you're cross debugging, the problem may also be 26433 somewhere in the connection to the target.) 26434 26435 * If GDB does not produce an error message for invalid input, that 26436 is a bug. However, you should note that your idea of "invalid 26437 input" might be our idea of "an extension" or "support for 26438 traditional practice". 26439 26440 * If you are an experienced user of debugging tools, your suggestions 26441 for improvement of GDB are welcome in any case. 26442 26443 26444 File: gdb.info, Node: Bug Reporting, Prev: Bug Criteria, Up: GDB Bugs 26445 26446 30.2 How to Report Bugs 26447 ======================= 26448 26449 A number of companies and individuals offer support for GNU products. 26450 If you obtained GDB from a support organization, we recommend you 26451 contact that organization first. 26452 26453 You can find contact information for many support companies and 26454 individuals in the file `etc/SERVICE' in the GNU Emacs distribution. 26455 26456 In any event, we also recommend that you submit bug reports for GDB. 26457 The preferred method is to submit them directly using GDB's Bugs web 26458 page (http://www.gnu.org/software/gdb/bugs/). Alternatively, the 26459 e-mail gateway <bug-gdb (a] gnu.org> can be used. 26460 26461 *Do not send bug reports to `info-gdb', or to `help-gdb', or to any 26462 newsgroups.* Most users of GDB do not want to receive bug reports. 26463 Those that do have arranged to receive `bug-gdb'. 26464 26465 The mailing list `bug-gdb' has a newsgroup `gnu.gdb.bug' which 26466 serves as a repeater. The mailing list and the newsgroup carry exactly 26467 the same messages. Often people think of posting bug reports to the 26468 newsgroup instead of mailing them. This appears to work, but it has one 26469 problem which can be crucial: a newsgroup posting often lacks a mail 26470 path back to the sender. Thus, if we need to ask for more information, 26471 we may be unable to reach you. For this reason, it is better to send 26472 bug reports to the mailing list. 26473 26474 The fundamental principle of reporting bugs usefully is this: 26475 *report all the facts*. If you are not sure whether to state a fact or 26476 leave it out, state it! 26477 26478 Often people omit facts because they think they know what causes the 26479 problem and assume that some details do not matter. Thus, you might 26480 assume that the name of the variable you use in an example does not 26481 matter. Well, probably it does not, but one cannot be sure. Perhaps 26482 the bug is a stray memory reference which happens to fetch from the 26483 location where that name is stored in memory; perhaps, if the name were 26484 different, the contents of that location would fool the debugger into 26485 doing the right thing despite the bug. Play it safe and give a 26486 specific, complete example. That is the easiest thing for you to do, 26487 and the most helpful. 26488 26489 Keep in mind that the purpose of a bug report is to enable us to fix 26490 the bug. It may be that the bug has been reported previously, but 26491 neither you nor we can know that unless your bug report is complete and 26492 self-contained. 26493 26494 Sometimes people give a few sketchy facts and ask, "Does this ring a 26495 bell?" Those bug reports are useless, and we urge everyone to _refuse 26496 to respond to them_ except to chide the sender to report bugs properly. 26497 26498 To enable us to fix the bug, you should include all these things: 26499 26500 * The version of GDB. GDB announces it if you start with no 26501 arguments; you can also print it at any time using `show version'. 26502 26503 Without this, we will not know whether there is any point in 26504 looking for the bug in the current version of GDB. 26505 26506 * The type of machine you are using, and the operating system name 26507 and version number. 26508 26509 * What compiler (and its version) was used to compile GDB--e.g. 26510 "gcc-2.8.1". 26511 26512 * What compiler (and its version) was used to compile the program 26513 you are debugging--e.g. "gcc-2.8.1", or "HP92453-01 A.10.32.03 HP 26514 C Compiler". For GCC, you can say `gcc --version' to get this 26515 information; for other compilers, see the documentation for those 26516 compilers. 26517 26518 * The command arguments you gave the compiler to compile your 26519 example and observe the bug. For example, did you use `-O'? To 26520 guarantee you will not omit something important, list them all. A 26521 copy of the Makefile (or the output from make) is sufficient. 26522 26523 If we were to try to guess the arguments, we would probably guess 26524 wrong and then we might not encounter the bug. 26525 26526 * A complete input script, and all necessary source files, that will 26527 reproduce the bug. 26528 26529 * A description of what behavior you observe that you believe is 26530 incorrect. For example, "It gets a fatal signal." 26531 26532 Of course, if the bug is that GDB gets a fatal signal, then we 26533 will certainly notice it. But if the bug is incorrect output, we 26534 might not notice unless it is glaringly wrong. You might as well 26535 not give us a chance to make a mistake. 26536 26537 Even if the problem you experience is a fatal signal, you should 26538 still say so explicitly. Suppose something strange is going on, 26539 such as, your copy of GDB is out of synch, or you have encountered 26540 a bug in the C library on your system. (This has happened!) Your 26541 copy might crash and ours would not. If you told us to expect a 26542 crash, then when ours fails to crash, we would know that the bug 26543 was not happening for us. If you had not told us to expect a 26544 crash, then we would not be able to draw any conclusion from our 26545 observations. 26546 26547 To collect all this information, you can use a session recording 26548 program such as `script', which is available on many Unix systems. 26549 Just run your GDB session inside `script' and then include the 26550 `typescript' file with your bug report. 26551 26552 Another way to record a GDB session is to run GDB inside Emacs and 26553 then save the entire buffer to a file. 26554 26555 * If you wish to suggest changes to the GDB source, send us context 26556 diffs. If you even discuss something in the GDB source, refer to 26557 it by context, not by line number. 26558 26559 The line numbers in our development sources will not match those 26560 in your sources. Your line numbers would convey no useful 26561 information to us. 26562 26563 26564 Here are some things that are not necessary: 26565 26566 * A description of the envelope of the bug. 26567 26568 Often people who encounter a bug spend a lot of time investigating 26569 which changes to the input file will make the bug go away and which 26570 changes will not affect it. 26571 26572 This is often time consuming and not very useful, because the way 26573 we will find the bug is by running a single example under the 26574 debugger with breakpoints, not by pure deduction from a series of 26575 examples. We recommend that you save your time for something else. 26576 26577 Of course, if you can find a simpler example to report _instead_ 26578 of the original one, that is a convenience for us. Errors in the 26579 output will be easier to spot, running under the debugger will take 26580 less time, and so on. 26581 26582 However, simplification is not vital; if you do not want to do 26583 this, report the bug anyway and send us the entire test case you 26584 used. 26585 26586 * A patch for the bug. 26587 26588 A patch for the bug does help us if it is a good one. But do not 26589 omit the necessary information, such as the test case, on the 26590 assumption that a patch is all we need. We might see problems 26591 with your patch and decide to fix the problem another way, or we 26592 might not understand it at all. 26593 26594 Sometimes with a program as complicated as GDB it is very hard to 26595 construct an example that will make the program follow a certain 26596 path through the code. If you do not send us the example, we will 26597 not be able to construct one, so we will not be able to verify 26598 that the bug is fixed. 26599 26600 And if we cannot understand what bug you are trying to fix, or why 26601 your patch should be an improvement, we will not install it. A 26602 test case will help us to understand. 26603 26604 * A guess about what the bug is or what it depends on. 26605 26606 Such guesses are usually wrong. Even we cannot guess right about 26607 such things without first using the debugger to find the facts. 26608 26609 26610 File: gdb.info, Node: Command Line Editing, Next: Using History Interactively, Prev: GDB Bugs, Up: Top 26611 26612 31 Command Line Editing 26613 *********************** 26614 26615 This chapter describes the basic features of the GNU command line 26616 editing interface. 26617 26618 * Menu: 26619 26620 * Introduction and Notation:: Notation used in this text. 26621 * Readline Interaction:: The minimum set of commands for editing a line. 26622 * Readline Init File:: Customizing Readline from a user's view. 26623 * Bindable Readline Commands:: A description of most of the Readline commands 26624 available for binding 26625 * Readline vi Mode:: A short description of how to make Readline 26626 behave like the vi editor. 26627 26628 26629 File: gdb.info, Node: Introduction and Notation, Next: Readline Interaction, Up: Command Line Editing 26630 26631 31.1 Introduction to Line Editing 26632 ================================= 26633 26634 The following paragraphs describe the notation used to represent 26635 keystrokes. 26636 26637 The text `C-k' is read as `Control-K' and describes the character 26638 produced when the <k> key is pressed while the Control key is depressed. 26639 26640 The text `M-k' is read as `Meta-K' and describes the character 26641 produced when the Meta key (if you have one) is depressed, and the <k> 26642 key is pressed. The Meta key is labeled <ALT> on many keyboards. On 26643 keyboards with two keys labeled <ALT> (usually to either side of the 26644 space bar), the <ALT> on the left side is generally set to work as a 26645 Meta key. The <ALT> key on the right may also be configured to work as 26646 a Meta key or may be configured as some other modifier, such as a 26647 Compose key for typing accented characters. 26648 26649 If you do not have a Meta or <ALT> key, or another key working as a 26650 Meta key, the identical keystroke can be generated by typing <ESC> 26651 _first_, and then typing <k>. Either process is known as "metafying" 26652 the <k> key. 26653 26654 The text `M-C-k' is read as `Meta-Control-k' and describes the 26655 character produced by "metafying" `C-k'. 26656 26657 In addition, several keys have their own names. Specifically, 26658 <DEL>, <ESC>, <LFD>, <SPC>, <RET>, and <TAB> all stand for themselves 26659 when seen in this text, or in an init file (*note Readline Init File::). 26660 If your keyboard lacks a <LFD> key, typing <C-j> will produce the 26661 desired character. The <RET> key may be labeled <Return> or <Enter> on 26662 some keyboards. 26663 26664 26665 File: gdb.info, Node: Readline Interaction, Next: Readline Init File, Prev: Introduction and Notation, Up: Command Line Editing 26666 26667 31.2 Readline Interaction 26668 ========================= 26669 26670 Often during an interactive session you type in a long line of text, 26671 only to notice that the first word on the line is misspelled. The 26672 Readline library gives you a set of commands for manipulating the text 26673 as you type it in, allowing you to just fix your typo, and not forcing 26674 you to retype the majority of the line. Using these editing commands, 26675 you move the cursor to the place that needs correction, and delete or 26676 insert the text of the corrections. Then, when you are satisfied with 26677 the line, you simply press <RET>. You do not have to be at the end of 26678 the line to press <RET>; the entire line is accepted regardless of the 26679 location of the cursor within the line. 26680 26681 * Menu: 26682 26683 * Readline Bare Essentials:: The least you need to know about Readline. 26684 * Readline Movement Commands:: Moving about the input line. 26685 * Readline Killing Commands:: How to delete text, and how to get it back! 26686 * Readline Arguments:: Giving numeric arguments to commands. 26687 * Searching:: Searching through previous lines. 26688 26689 26690 File: gdb.info, Node: Readline Bare Essentials, Next: Readline Movement Commands, Up: Readline Interaction 26691 26692 31.2.1 Readline Bare Essentials 26693 ------------------------------- 26694 26695 In order to enter characters into the line, simply type them. The typed 26696 character appears where the cursor was, and then the cursor moves one 26697 space to the right. If you mistype a character, you can use your erase 26698 character to back up and delete the mistyped character. 26699 26700 Sometimes you may mistype a character, and not notice the error 26701 until you have typed several other characters. In that case, you can 26702 type `C-b' to move the cursor to the left, and then correct your 26703 mistake. Afterwards, you can move the cursor to the right with `C-f'. 26704 26705 When you add text in the middle of a line, you will notice that 26706 characters to the right of the cursor are `pushed over' to make room 26707 for the text that you have inserted. Likewise, when you delete text 26708 behind the cursor, characters to the right of the cursor are `pulled 26709 back' to fill in the blank space created by the removal of the text. A 26710 list of the bare essentials for editing the text of an input line 26711 follows. 26712 26713 `C-b' 26714 Move back one character. 26715 26716 `C-f' 26717 Move forward one character. 26718 26719 <DEL> or <Backspace> 26720 Delete the character to the left of the cursor. 26721 26722 `C-d' 26723 Delete the character underneath the cursor. 26724 26725 Printing characters 26726 Insert the character into the line at the cursor. 26727 26728 `C-_' or `C-x C-u' 26729 Undo the last editing command. You can undo all the way back to an 26730 empty line. 26731 26732 (Depending on your configuration, the <Backspace> key be set to delete 26733 the character to the left of the cursor and the <DEL> key set to delete 26734 the character underneath the cursor, like `C-d', rather than the 26735 character to the left of the cursor.) 26736 26737 26738 File: gdb.info, Node: Readline Movement Commands, Next: Readline Killing Commands, Prev: Readline Bare Essentials, Up: Readline Interaction 26739 26740 31.2.2 Readline Movement Commands 26741 --------------------------------- 26742 26743 The above table describes the most basic keystrokes that you need in 26744 order to do editing of the input line. For your convenience, many 26745 other commands have been added in addition to `C-b', `C-f', `C-d', and 26746 <DEL>. Here are some commands for moving more rapidly about the line. 26747 26748 `C-a' 26749 Move to the start of the line. 26750 26751 `C-e' 26752 Move to the end of the line. 26753 26754 `M-f' 26755 Move forward a word, where a word is composed of letters and 26756 digits. 26757 26758 `M-b' 26759 Move backward a word. 26760 26761 `C-l' 26762 Clear the screen, reprinting the current line at the top. 26763 26764 Notice how `C-f' moves forward a character, while `M-f' moves 26765 forward a word. It is a loose convention that control keystrokes 26766 operate on characters while meta keystrokes operate on words. 26767 26768 26769 File: gdb.info, Node: Readline Killing Commands, Next: Readline Arguments, Prev: Readline Movement Commands, Up: Readline Interaction 26770 26771 31.2.3 Readline Killing Commands 26772 -------------------------------- 26773 26774 "Killing" text means to delete the text from the line, but to save it 26775 away for later use, usually by "yanking" (re-inserting) it back into 26776 the line. (`Cut' and `paste' are more recent jargon for `kill' and 26777 `yank'.) 26778 26779 If the description for a command says that it `kills' text, then you 26780 can be sure that you can get the text back in a different (or the same) 26781 place later. 26782 26783 When you use a kill command, the text is saved in a "kill-ring". 26784 Any number of consecutive kills save all of the killed text together, so 26785 that when you yank it back, you get it all. The kill ring is not line 26786 specific; the text that you killed on a previously typed line is 26787 available to be yanked back later, when you are typing another line. 26788 26789 Here is the list of commands for killing text. 26790 26791 `C-k' 26792 Kill the text from the current cursor position to the end of the 26793 line. 26794 26795 `M-d' 26796 Kill from the cursor to the end of the current word, or, if between 26797 words, to the end of the next word. Word boundaries are the same 26798 as those used by `M-f'. 26799 26800 `M-<DEL>' 26801 Kill from the cursor the start of the current word, or, if between 26802 words, to the start of the previous word. Word boundaries are the 26803 same as those used by `M-b'. 26804 26805 `C-w' 26806 Kill from the cursor to the previous whitespace. This is 26807 different than `M-<DEL>' because the word boundaries differ. 26808 26809 26810 Here is how to "yank" the text back into the line. Yanking means to 26811 copy the most-recently-killed text from the kill buffer. 26812 26813 `C-y' 26814 Yank the most recently killed text back into the buffer at the 26815 cursor. 26816 26817 `M-y' 26818 Rotate the kill-ring, and yank the new top. You can only do this 26819 if the prior command is `C-y' or `M-y'. 26820 26821 26822 File: gdb.info, Node: Readline Arguments, Next: Searching, Prev: Readline Killing Commands, Up: Readline Interaction 26823 26824 31.2.4 Readline Arguments 26825 ------------------------- 26826 26827 You can pass numeric arguments to Readline commands. Sometimes the 26828 argument acts as a repeat count, other times it is the sign of the 26829 argument that is significant. If you pass a negative argument to a 26830 command which normally acts in a forward direction, that command will 26831 act in a backward direction. For example, to kill text back to the 26832 start of the line, you might type `M-- C-k'. 26833 26834 The general way to pass numeric arguments to a command is to type 26835 meta digits before the command. If the first `digit' typed is a minus 26836 sign (`-'), then the sign of the argument will be negative. Once you 26837 have typed one meta digit to get the argument started, you can type the 26838 remainder of the digits, and then the command. For example, to give 26839 the `C-d' command an argument of 10, you could type `M-1 0 C-d', which 26840 will delete the next ten characters on the input line. 26841 26842 26843 File: gdb.info, Node: Searching, Prev: Readline Arguments, Up: Readline Interaction 26844 26845 31.2.5 Searching for Commands in the History 26846 -------------------------------------------- 26847 26848 Readline provides commands for searching through the command history 26849 for lines containing a specified string. There are two search modes: 26850 "incremental" and "non-incremental". 26851 26852 Incremental searches begin before the user has finished typing the 26853 search string. As each character of the search string is typed, 26854 Readline displays the next entry from the history matching the string 26855 typed so far. An incremental search requires only as many characters 26856 as needed to find the desired history entry. To search backward in the 26857 history for a particular string, type `C-r'. Typing `C-s' searches 26858 forward through the history. The characters present in the value of 26859 the `isearch-terminators' variable are used to terminate an incremental 26860 search. If that variable has not been assigned a value, the <ESC> and 26861 `C-J' characters will terminate an incremental search. `C-g' will 26862 abort an incremental search and restore the original line. When the 26863 search is terminated, the history entry containing the search string 26864 becomes the current line. 26865 26866 To find other matching entries in the history list, type `C-r' or 26867 `C-s' as appropriate. This will search backward or forward in the 26868 history for the next entry matching the search string typed so far. 26869 Any other key sequence bound to a Readline command will terminate the 26870 search and execute that command. For instance, a <RET> will terminate 26871 the search and accept the line, thereby executing the command from the 26872 history list. A movement command will terminate the search, make the 26873 last line found the current line, and begin editing. 26874 26875 Readline remembers the last incremental search string. If two 26876 `C-r's are typed without any intervening characters defining a new 26877 search string, any remembered search string is used. 26878 26879 Non-incremental searches read the entire search string before 26880 starting to search for matching history lines. The search string may be 26881 typed by the user or be part of the contents of the current line. 26882 26883 26884 File: gdb.info, Node: Readline Init File, Next: Bindable Readline Commands, Prev: Readline Interaction, Up: Command Line Editing 26885 26886 31.3 Readline Init File 26887 ======================= 26888 26889 Although the Readline library comes with a set of Emacs-like 26890 keybindings installed by default, it is possible to use a different set 26891 of keybindings. Any user can customize programs that use Readline by 26892 putting commands in an "inputrc" file, conventionally in his home 26893 directory. The name of this file is taken from the value of the 26894 environment variable `INPUTRC'. If that variable is unset, the default 26895 is `~/.inputrc'. 26896 26897 When a program which uses the Readline library starts up, the init 26898 file is read, and the key bindings are set. 26899 26900 In addition, the `C-x C-r' command re-reads this init file, thus 26901 incorporating any changes that you might have made to it. 26902 26903 * Menu: 26904 26905 * Readline Init File Syntax:: Syntax for the commands in the inputrc file. 26906 26907 * Conditional Init Constructs:: Conditional key bindings in the inputrc file. 26908 26909 * Sample Init File:: An example inputrc file. 26910 26911 26912 File: gdb.info, Node: Readline Init File Syntax, Next: Conditional Init Constructs, Up: Readline Init File 26913 26914 31.3.1 Readline Init File Syntax 26915 -------------------------------- 26916 26917 There are only a few basic constructs allowed in the Readline init 26918 file. Blank lines are ignored. Lines beginning with a `#' are 26919 comments. Lines beginning with a `$' indicate conditional constructs 26920 (*note Conditional Init Constructs::). Other lines denote variable 26921 settings and key bindings. 26922 26923 Variable Settings 26924 You can modify the run-time behavior of Readline by altering the 26925 values of variables in Readline using the `set' command within the 26926 init file. The syntax is simple: 26927 26928 set VARIABLE VALUE 26929 26930 Here, for example, is how to change from the default Emacs-like 26931 key binding to use `vi' line editing commands: 26932 26933 set editing-mode vi 26934 26935 Variable names and values, where appropriate, are recognized 26936 without regard to case. Unrecognized variable names are ignored. 26937 26938 Boolean variables (those that can be set to on or off) are set to 26939 on if the value is null or empty, ON (case-insensitive), or 1. 26940 Any other value results in the variable being set to off. 26941 26942 A great deal of run-time behavior is changeable with the following 26943 variables. 26944 26945 `bell-style' 26946 Controls what happens when Readline wants to ring the 26947 terminal bell. If set to `none', Readline never rings the 26948 bell. If set to `visible', Readline uses a visible bell if 26949 one is available. If set to `audible' (the default), 26950 Readline attempts to ring the terminal's bell. 26951 26952 `bind-tty-special-chars' 26953 If set to `on', Readline attempts to bind the control 26954 characters treated specially by the kernel's terminal driver 26955 to their Readline equivalents. 26956 26957 `comment-begin' 26958 The string to insert at the beginning of the line when the 26959 `insert-comment' command is executed. The default value is 26960 `"#"'. 26961 26962 `completion-ignore-case' 26963 If set to `on', Readline performs filename matching and 26964 completion in a case-insensitive fashion. The default value 26965 is `off'. 26966 26967 `completion-query-items' 26968 The number of possible completions that determines when the 26969 user is asked whether the list of possibilities should be 26970 displayed. If the number of possible completions is greater 26971 than this value, Readline will ask the user whether or not he 26972 wishes to view them; otherwise, they are simply listed. This 26973 variable must be set to an integer value greater than or 26974 equal to 0. A negative value means Readline should never ask. 26975 The default limit is `100'. 26976 26977 `convert-meta' 26978 If set to `on', Readline will convert characters with the 26979 eighth bit set to an ASCII key sequence by stripping the 26980 eighth bit and prefixing an <ESC> character, converting them 26981 to a meta-prefixed key sequence. The default value is `on'. 26982 26983 `disable-completion' 26984 If set to `On', Readline will inhibit word completion. 26985 Completion characters will be inserted into the line as if 26986 they had been mapped to `self-insert'. The default is `off'. 26987 26988 `editing-mode' 26989 The `editing-mode' variable controls which default set of key 26990 bindings is used. By default, Readline starts up in Emacs 26991 editing mode, where the keystrokes are most similar to Emacs. 26992 This variable can be set to either `emacs' or `vi'. 26993 26994 `enable-keypad' 26995 When set to `on', Readline will try to enable the application 26996 keypad when it is called. Some systems need this to enable 26997 the arrow keys. The default is `off'. 26998 26999 `expand-tilde' 27000 If set to `on', tilde expansion is performed when Readline 27001 attempts word completion. The default is `off'. 27002 27003 `history-preserve-point' 27004 If set to `on', the history code attempts to place point at 27005 the same location on each history line retrieved with 27006 `previous-history' or `next-history'. The default is `off'. 27007 27008 `horizontal-scroll-mode' 27009 This variable can be set to either `on' or `off'. Setting it 27010 to `on' means that the text of the lines being edited will 27011 scroll horizontally on a single screen line when they are 27012 longer than the width of the screen, instead of wrapping onto 27013 a new screen line. By default, this variable is set to `off'. 27014 27015 `input-meta' 27016 If set to `on', Readline will enable eight-bit input (it will 27017 not clear the eighth bit in the characters it reads), 27018 regardless of what the terminal claims it can support. The 27019 default value is `off'. The name `meta-flag' is a synonym 27020 for this variable. 27021 27022 `isearch-terminators' 27023 The string of characters that should terminate an incremental 27024 search without subsequently executing the character as a 27025 command (*note Searching::). If this variable has not been 27026 given a value, the characters <ESC> and `C-J' will terminate 27027 an incremental search. 27028 27029 `keymap' 27030 Sets Readline's idea of the current keymap for key binding 27031 commands. Acceptable `keymap' names are `emacs', 27032 `emacs-standard', `emacs-meta', `emacs-ctlx', `vi', `vi-move', 27033 `vi-command', and `vi-insert'. `vi' is equivalent to 27034 `vi-command'; `emacs' is equivalent to `emacs-standard'. The 27035 default value is `emacs'. The value of the `editing-mode' 27036 variable also affects the default keymap. 27037 27038 `mark-directories' 27039 If set to `on', completed directory names have a slash 27040 appended. The default is `on'. 27041 27042 `mark-modified-lines' 27043 This variable, when set to `on', causes Readline to display an 27044 asterisk (`*') at the start of history lines which have been 27045 modified. This variable is `off' by default. 27046 27047 `mark-symlinked-directories' 27048 If set to `on', completed names which are symbolic links to 27049 directories have a slash appended (subject to the value of 27050 `mark-directories'). The default is `off'. 27051 27052 `match-hidden-files' 27053 This variable, when set to `on', causes Readline to match 27054 files whose names begin with a `.' (hidden files) when 27055 performing filename completion, unless the leading `.' is 27056 supplied by the user in the filename to be completed. This 27057 variable is `on' by default. 27058 27059 `output-meta' 27060 If set to `on', Readline will display characters with the 27061 eighth bit set directly rather than as a meta-prefixed escape 27062 sequence. The default is `off'. 27063 27064 `page-completions' 27065 If set to `on', Readline uses an internal `more'-like pager 27066 to display a screenful of possible completions at a time. 27067 This variable is `on' by default. 27068 27069 `print-completions-horizontally' 27070 If set to `on', Readline will display completions with matches 27071 sorted horizontally in alphabetical order, rather than down 27072 the screen. The default is `off'. 27073 27074 `show-all-if-ambiguous' 27075 This alters the default behavior of the completion functions. 27076 If set to `on', words which have more than one possible 27077 completion cause the matches to be listed immediately instead 27078 of ringing the bell. The default value is `off'. 27079 27080 `show-all-if-unmodified' 27081 This alters the default behavior of the completion functions 27082 in a fashion similar to SHOW-ALL-IF-AMBIGUOUS. If set to 27083 `on', words which have more than one possible completion 27084 without any possible partial completion (the possible 27085 completions don't share a common prefix) cause the matches to 27086 be listed immediately instead of ringing the bell. The 27087 default value is `off'. 27088 27089 `visible-stats' 27090 If set to `on', a character denoting a file's type is 27091 appended to the filename when listing possible completions. 27092 The default is `off'. 27093 27094 27095 Key Bindings 27096 The syntax for controlling key bindings in the init file is 27097 simple. First you need to find the name of the command that you 27098 want to change. The following sections contain tables of the 27099 command name, the default keybinding, if any, and a short 27100 description of what the command does. 27101 27102 Once you know the name of the command, simply place on a line in 27103 the init file the name of the key you wish to bind the command to, 27104 a colon, and then the name of the command. The name of the key 27105 can be expressed in different ways, depending on what you find most 27106 comfortable. 27107 27108 In addition to command names, readline allows keys to be bound to 27109 a string that is inserted when the key is pressed (a MACRO). 27110 27111 KEYNAME: FUNCTION-NAME or MACRO 27112 KEYNAME is the name of a key spelled out in English. For 27113 example: 27114 Control-u: universal-argument 27115 Meta-Rubout: backward-kill-word 27116 Control-o: "> output" 27117 27118 In the above example, `C-u' is bound to the function 27119 `universal-argument', `M-DEL' is bound to the function 27120 `backward-kill-word', and `C-o' is bound to run the macro 27121 expressed on the right hand side (that is, to insert the text 27122 `> output' into the line). 27123 27124 A number of symbolic character names are recognized while 27125 processing this key binding syntax: DEL, ESC, ESCAPE, LFD, 27126 NEWLINE, RET, RETURN, RUBOUT, SPACE, SPC, and TAB. 27127 27128 "KEYSEQ": FUNCTION-NAME or MACRO 27129 KEYSEQ differs from KEYNAME above in that strings denoting an 27130 entire key sequence can be specified, by placing the key 27131 sequence in double quotes. Some GNU Emacs style key escapes 27132 can be used, as in the following example, but the special 27133 character names are not recognized. 27134 27135 "\C-u": universal-argument 27136 "\C-x\C-r": re-read-init-file 27137 "\e[11~": "Function Key 1" 27138 27139 In the above example, `C-u' is again bound to the function 27140 `universal-argument' (just as it was in the first example), 27141 `C-x C-r' is bound to the function `re-read-init-file', and 27142 `<ESC> <[> <1> <1> <~>' is bound to insert the text `Function 27143 Key 1'. 27144 27145 27146 The following GNU Emacs style escape sequences are available when 27147 specifying key sequences: 27148 27149 `\C-' 27150 control prefix 27151 27152 `\M-' 27153 meta prefix 27154 27155 `\e' 27156 an escape character 27157 27158 `\\' 27159 backslash 27160 27161 `\"' 27162 <">, a double quotation mark 27163 27164 `\'' 27165 <'>, a single quote or apostrophe 27166 27167 In addition to the GNU Emacs style escape sequences, a second set 27168 of backslash escapes is available: 27169 27170 `\a' 27171 alert (bell) 27172 27173 `\b' 27174 backspace 27175 27176 `\d' 27177 delete 27178 27179 `\f' 27180 form feed 27181 27182 `\n' 27183 newline 27184 27185 `\r' 27186 carriage return 27187 27188 `\t' 27189 horizontal tab 27190 27191 `\v' 27192 vertical tab 27193 27194 `\NNN' 27195 the eight-bit character whose value is the octal value NNN 27196 (one to three digits) 27197 27198 `\xHH' 27199 the eight-bit character whose value is the hexadecimal value 27200 HH (one or two hex digits) 27201 27202 When entering the text of a macro, single or double quotes must be 27203 used to indicate a macro definition. Unquoted text is assumed to 27204 be a function name. In the macro body, the backslash escapes 27205 described above are expanded. Backslash will quote any other 27206 character in the macro text, including `"' and `''. For example, 27207 the following binding will make `C-x \' insert a single `\' into 27208 the line: 27209 "\C-x\\": "\\" 27210 27211 27212 27213 File: gdb.info, Node: Conditional Init Constructs, Next: Sample Init File, Prev: Readline Init File Syntax, Up: Readline Init File 27214 27215 31.3.2 Conditional Init Constructs 27216 ---------------------------------- 27217 27218 Readline implements a facility similar in spirit to the conditional 27219 compilation features of the C preprocessor which allows key bindings 27220 and variable settings to be performed as the result of tests. There 27221 are four parser directives used. 27222 27223 `$if' 27224 The `$if' construct allows bindings to be made based on the 27225 editing mode, the terminal being used, or the application using 27226 Readline. The text of the test extends to the end of the line; no 27227 characters are required to isolate it. 27228 27229 `mode' 27230 The `mode=' form of the `$if' directive is used to test 27231 whether Readline is in `emacs' or `vi' mode. This may be 27232 used in conjunction with the `set keymap' command, for 27233 instance, to set bindings in the `emacs-standard' and 27234 `emacs-ctlx' keymaps only if Readline is starting out in 27235 `emacs' mode. 27236 27237 `term' 27238 The `term=' form may be used to include terminal-specific key 27239 bindings, perhaps to bind the key sequences output by the 27240 terminal's function keys. The word on the right side of the 27241 `=' is tested against both the full name of the terminal and 27242 the portion of the terminal name before the first `-'. This 27243 allows `sun' to match both `sun' and `sun-cmd', for instance. 27244 27245 `application' 27246 The APPLICATION construct is used to include 27247 application-specific settings. Each program using the 27248 Readline library sets the APPLICATION NAME, and you can test 27249 for a particular value. This could be used to bind key 27250 sequences to functions useful for a specific program. For 27251 instance, the following command adds a key sequence that 27252 quotes the current or previous word in Bash: 27253 $if Bash 27254 # Quote the current or previous word 27255 "\C-xq": "\eb\"\ef\"" 27256 $endif 27257 27258 `$endif' 27259 This command, as seen in the previous example, terminates an `$if' 27260 command. 27261 27262 `$else' 27263 Commands in this branch of the `$if' directive are executed if the 27264 test fails. 27265 27266 `$include' 27267 This directive takes a single filename as an argument and reads 27268 commands and bindings from that file. For example, the following 27269 directive reads from `/etc/inputrc': 27270 $include /etc/inputrc 27271 27272 27273 File: gdb.info, Node: Sample Init File, Prev: Conditional Init Constructs, Up: Readline Init File 27274 27275 31.3.3 Sample Init File 27276 ----------------------- 27277 27278 Here is an example of an INPUTRC file. This illustrates key binding, 27279 variable assignment, and conditional syntax. 27280 27281 27282 # This file controls the behaviour of line input editing for 27283 # programs that use the GNU Readline library. Existing 27284 # programs include FTP, Bash, and GDB. 27285 # 27286 # You can re-read the inputrc file with C-x C-r. 27287 # Lines beginning with '#' are comments. 27288 # 27289 # First, include any systemwide bindings and variable 27290 # assignments from /etc/Inputrc 27291 $include /etc/Inputrc 27292 27293 # 27294 # Set various bindings for emacs mode. 27295 27296 set editing-mode emacs 27297 27298 $if mode=emacs 27299 27300 Meta-Control-h: backward-kill-word Text after the function name is ignored 27301 27302 # 27303 # Arrow keys in keypad mode 27304 # 27305 #"\M-OD": backward-char 27306 #"\M-OC": forward-char 27307 #"\M-OA": previous-history 27308 #"\M-OB": next-history 27309 # 27310 # Arrow keys in ANSI mode 27311 # 27312 "\M-[D": backward-char 27313 "\M-[C": forward-char 27314 "\M-[A": previous-history 27315 "\M-[B": next-history 27316 # 27317 # Arrow keys in 8 bit keypad mode 27318 # 27319 #"\M-\C-OD": backward-char 27320 #"\M-\C-OC": forward-char 27321 #"\M-\C-OA": previous-history 27322 #"\M-\C-OB": next-history 27323 # 27324 # Arrow keys in 8 bit ANSI mode 27325 # 27326 #"\M-\C-[D": backward-char 27327 #"\M-\C-[C": forward-char 27328 #"\M-\C-[A": previous-history 27329 #"\M-\C-[B": next-history 27330 27331 C-q: quoted-insert 27332 27333 $endif 27334 27335 # An old-style binding. This happens to be the default. 27336 TAB: complete 27337 27338 # Macros that are convenient for shell interaction 27339 $if Bash 27340 # edit the path 27341 "\C-xp": "PATH=${PATH}\e\C-e\C-a\ef\C-f" 27342 # prepare to type a quoted word -- 27343 # insert open and close double quotes 27344 # and move to just after the open quote 27345 "\C-x\"": "\"\"\C-b" 27346 # insert a backslash (testing backslash escapes 27347 # in sequences and macros) 27348 "\C-x\\": "\\" 27349 # Quote the current or previous word 27350 "\C-xq": "\eb\"\ef\"" 27351 # Add a binding to refresh the line, which is unbound 27352 "\C-xr": redraw-current-line 27353 # Edit variable on current line. 27354 "\M-\C-v": "\C-a\C-k$\C-y\M-\C-e\C-a\C-y=" 27355 $endif 27356 27357 # use a visible bell if one is available 27358 set bell-style visible 27359 27360 # don't strip characters to 7 bits when reading 27361 set input-meta on 27362 27363 # allow iso-latin1 characters to be inserted rather 27364 # than converted to prefix-meta sequences 27365 set convert-meta off 27366 27367 # display characters with the eighth bit set directly 27368 # rather than as meta-prefixed characters 27369 set output-meta on 27370 27371 # if there are more than 150 possible completions for 27372 # a word, ask the user if he wants to see all of them 27373 set completion-query-items 150 27374 27375 # For FTP 27376 $if Ftp 27377 "\C-xg": "get \M-?" 27378 "\C-xt": "put \M-?" 27379 "\M-.": yank-last-arg 27380 $endif 27381 27382 27383 File: gdb.info, Node: Bindable Readline Commands, Next: Readline vi Mode, Prev: Readline Init File, Up: Command Line Editing 27384 27385 31.4 Bindable Readline Commands 27386 =============================== 27387 27388 * Menu: 27389 27390 * Commands For Moving:: Moving about the line. 27391 * Commands For History:: Getting at previous lines. 27392 * Commands For Text:: Commands for changing text. 27393 * Commands For Killing:: Commands for killing and yanking. 27394 * Numeric Arguments:: Specifying numeric arguments, repeat counts. 27395 * Commands For Completion:: Getting Readline to do the typing for you. 27396 * Keyboard Macros:: Saving and re-executing typed characters 27397 * Miscellaneous Commands:: Other miscellaneous commands. 27398 27399 This section describes Readline commands that may be bound to key 27400 sequences. Command names without an accompanying key sequence are 27401 unbound by default. 27402 27403 In the following descriptions, "point" refers to the current cursor 27404 position, and "mark" refers to a cursor position saved by the 27405 `set-mark' command. The text between the point and mark is referred to 27406 as the "region". 27407 27408 27409 File: gdb.info, Node: Commands For Moving, Next: Commands For History, Up: Bindable Readline Commands 27410 27411 31.4.1 Commands For Moving 27412 -------------------------- 27413 27414 `beginning-of-line (C-a)' 27415 Move to the start of the current line. 27416 27417 `end-of-line (C-e)' 27418 Move to the end of the line. 27419 27420 `forward-char (C-f)' 27421 Move forward a character. 27422 27423 `backward-char (C-b)' 27424 Move back a character. 27425 27426 `forward-word (M-f)' 27427 Move forward to the end of the next word. Words are composed of 27428 letters and digits. 27429 27430 `backward-word (M-b)' 27431 Move back to the start of the current or previous word. Words are 27432 composed of letters and digits. 27433 27434 `clear-screen (C-l)' 27435 Clear the screen and redraw the current line, leaving the current 27436 line at the top of the screen. 27437 27438 `redraw-current-line ()' 27439 Refresh the current line. By default, this is unbound. 27440 27441 27442 27443 File: gdb.info, Node: Commands For History, Next: Commands For Text, Prev: Commands For Moving, Up: Bindable Readline Commands 27444 27445 31.4.2 Commands For Manipulating The History 27446 -------------------------------------------- 27447 27448 `accept-line (Newline or Return)' 27449 Accept the line regardless of where the cursor is. If this line is 27450 non-empty, it may be added to the history list for future recall 27451 with `add_history()'. If this line is a modified history line, 27452 the history line is restored to its original state. 27453 27454 `previous-history (C-p)' 27455 Move `back' through the history list, fetching the previous 27456 command. 27457 27458 `next-history (C-n)' 27459 Move `forward' through the history list, fetching the next command. 27460 27461 `beginning-of-history (M-<)' 27462 Move to the first line in the history. 27463 27464 `end-of-history (M->)' 27465 Move to the end of the input history, i.e., the line currently 27466 being entered. 27467 27468 `reverse-search-history (C-r)' 27469 Search backward starting at the current line and moving `up' 27470 through the history as necessary. This is an incremental search. 27471 27472 `forward-search-history (C-s)' 27473 Search forward starting at the current line and moving `down' 27474 through the the history as necessary. This is an incremental 27475 search. 27476 27477 `non-incremental-reverse-search-history (M-p)' 27478 Search backward starting at the current line and moving `up' 27479 through the history as necessary using a non-incremental search 27480 for a string supplied by the user. 27481 27482 `non-incremental-forward-search-history (M-n)' 27483 Search forward starting at the current line and moving `down' 27484 through the the history as necessary using a non-incremental search 27485 for a string supplied by the user. 27486 27487 `history-search-forward ()' 27488 Search forward through the history for the string of characters 27489 between the start of the current line and the point. This is a 27490 non-incremental search. By default, this command is unbound. 27491 27492 `history-search-backward ()' 27493 Search backward through the history for the string of characters 27494 between the start of the current line and the point. This is a 27495 non-incremental search. By default, this command is unbound. 27496 27497 `yank-nth-arg (M-C-y)' 27498 Insert the first argument to the previous command (usually the 27499 second word on the previous line) at point. With an argument N, 27500 insert the Nth word from the previous command (the words in the 27501 previous command begin with word 0). A negative argument inserts 27502 the Nth word from the end of the previous command. Once the 27503 argument N is computed, the argument is extracted as if the `!N' 27504 history expansion had been specified. 27505 27506 `yank-last-arg (M-. or M-_)' 27507 Insert last argument to the previous command (the last word of the 27508 previous history entry). With an argument, behave exactly like 27509 `yank-nth-arg'. Successive calls to `yank-last-arg' move back 27510 through the history list, inserting the last argument of each line 27511 in turn. The history expansion facilities are used to extract the 27512 last argument, as if the `!$' history expansion had been specified. 27513 27514 27515 27516 File: gdb.info, Node: Commands For Text, Next: Commands For Killing, Prev: Commands For History, Up: Bindable Readline Commands 27517 27518 31.4.3 Commands For Changing Text 27519 --------------------------------- 27520 27521 `delete-char (C-d)' 27522 Delete the character at point. If point is at the beginning of 27523 the line, there are no characters in the line, and the last 27524 character typed was not bound to `delete-char', then return EOF. 27525 27526 `backward-delete-char (Rubout)' 27527 Delete the character behind the cursor. A numeric argument means 27528 to kill the characters instead of deleting them. 27529 27530 `forward-backward-delete-char ()' 27531 Delete the character under the cursor, unless the cursor is at the 27532 end of the line, in which case the character behind the cursor is 27533 deleted. By default, this is not bound to a key. 27534 27535 `quoted-insert (C-q or C-v)' 27536 Add the next character typed to the line verbatim. This is how to 27537 insert key sequences like `C-q', for example. 27538 27539 `tab-insert (M-<TAB>)' 27540 Insert a tab character. 27541 27542 `self-insert (a, b, A, 1, !, ...)' 27543 Insert yourself. 27544 27545 `transpose-chars (C-t)' 27546 Drag the character before the cursor forward over the character at 27547 the cursor, moving the cursor forward as well. If the insertion 27548 point is at the end of the line, then this transposes the last two 27549 characters of the line. Negative arguments have no effect. 27550 27551 `transpose-words (M-t)' 27552 Drag the word before point past the word after point, moving point 27553 past that word as well. If the insertion point is at the end of 27554 the line, this transposes the last two words on the line. 27555 27556 `upcase-word (M-u)' 27557 Uppercase the current (or following) word. With a negative 27558 argument, uppercase the previous word, but do not move the cursor. 27559 27560 `downcase-word (M-l)' 27561 Lowercase the current (or following) word. With a negative 27562 argument, lowercase the previous word, but do not move the cursor. 27563 27564 `capitalize-word (M-c)' 27565 Capitalize the current (or following) word. With a negative 27566 argument, capitalize the previous word, but do not move the cursor. 27567 27568 `overwrite-mode ()' 27569 Toggle overwrite mode. With an explicit positive numeric argument, 27570 switches to overwrite mode. With an explicit non-positive numeric 27571 argument, switches to insert mode. This command affects only 27572 `emacs' mode; `vi' mode does overwrite differently. Each call to 27573 `readline()' starts in insert mode. 27574 27575 In overwrite mode, characters bound to `self-insert' replace the 27576 text at point rather than pushing the text to the right. 27577 Characters bound to `backward-delete-char' replace the character 27578 before point with a space. 27579 27580 By default, this command is unbound. 27581 27582 27583 27584 File: gdb.info, Node: Commands For Killing, Next: Numeric Arguments, Prev: Commands For Text, Up: Bindable Readline Commands 27585 27586 31.4.4 Killing And Yanking 27587 -------------------------- 27588 27589 `kill-line (C-k)' 27590 Kill the text from point to the end of the line. 27591 27592 `backward-kill-line (C-x Rubout)' 27593 Kill backward to the beginning of the line. 27594 27595 `unix-line-discard (C-u)' 27596 Kill backward from the cursor to the beginning of the current line. 27597 27598 `kill-whole-line ()' 27599 Kill all characters on the current line, no matter where point is. 27600 By default, this is unbound. 27601 27602 `kill-word (M-d)' 27603 Kill from point to the end of the current word, or if between 27604 words, to the end of the next word. Word boundaries are the same 27605 as `forward-word'. 27606 27607 `backward-kill-word (M-<DEL>)' 27608 Kill the word behind point. Word boundaries are the same as 27609 `backward-word'. 27610 27611 `unix-word-rubout (C-w)' 27612 Kill the word behind point, using white space as a word boundary. 27613 The killed text is saved on the kill-ring. 27614 27615 `unix-filename-rubout ()' 27616 Kill the word behind point, using white space and the slash 27617 character as the word boundaries. The killed text is saved on the 27618 kill-ring. 27619 27620 `delete-horizontal-space ()' 27621 Delete all spaces and tabs around point. By default, this is 27622 unbound. 27623 27624 `kill-region ()' 27625 Kill the text in the current region. By default, this command is 27626 unbound. 27627 27628 `copy-region-as-kill ()' 27629 Copy the text in the region to the kill buffer, so it can be yanked 27630 right away. By default, this command is unbound. 27631 27632 `copy-backward-word ()' 27633 Copy the word before point to the kill buffer. The word 27634 boundaries are the same as `backward-word'. By default, this 27635 command is unbound. 27636 27637 `copy-forward-word ()' 27638 Copy the word following point to the kill buffer. The word 27639 boundaries are the same as `forward-word'. By default, this 27640 command is unbound. 27641 27642 `yank (C-y)' 27643 Yank the top of the kill ring into the buffer at point. 27644 27645 `yank-pop (M-y)' 27646 Rotate the kill-ring, and yank the new top. You can only do this 27647 if the prior command is `yank' or `yank-pop'. 27648 27649 27650 File: gdb.info, Node: Numeric Arguments, Next: Commands For Completion, Prev: Commands For Killing, Up: Bindable Readline Commands 27651 27652 31.4.5 Specifying Numeric Arguments 27653 ----------------------------------- 27654 27655 `digit-argument (M-0, M-1, ... M--)' 27656 Add this digit to the argument already accumulating, or start a new 27657 argument. `M--' starts a negative argument. 27658 27659 `universal-argument ()' 27660 This is another way to specify an argument. If this command is 27661 followed by one or more digits, optionally with a leading minus 27662 sign, those digits define the argument. If the command is 27663 followed by digits, executing `universal-argument' again ends the 27664 numeric argument, but is otherwise ignored. As a special case, if 27665 this command is immediately followed by a character that is 27666 neither a digit or minus sign, the argument count for the next 27667 command is multiplied by four. The argument count is initially 27668 one, so executing this function the first time makes the argument 27669 count four, a second time makes the argument count sixteen, and so 27670 on. By default, this is not bound to a key. 27671 27672 27673 File: gdb.info, Node: Commands For Completion, Next: Keyboard Macros, Prev: Numeric Arguments, Up: Bindable Readline Commands 27674 27675 31.4.6 Letting Readline Type For You 27676 ------------------------------------ 27677 27678 `complete (<TAB>)' 27679 Attempt to perform completion on the text before point. The 27680 actual completion performed is application-specific. The default 27681 is filename completion. 27682 27683 `possible-completions (M-?)' 27684 List the possible completions of the text before point. 27685 27686 `insert-completions (M-*)' 27687 Insert all completions of the text before point that would have 27688 been generated by `possible-completions'. 27689 27690 `menu-complete ()' 27691 Similar to `complete', but replaces the word to be completed with 27692 a single match from the list of possible completions. Repeated 27693 execution of `menu-complete' steps through the list of possible 27694 completions, inserting each match in turn. At the end of the list 27695 of completions, the bell is rung (subject to the setting of 27696 `bell-style') and the original text is restored. An argument of N 27697 moves N positions forward in the list of matches; a negative 27698 argument may be used to move backward through the list. This 27699 command is intended to be bound to <TAB>, but is unbound by 27700 default. 27701 27702 `delete-char-or-list ()' 27703 Deletes the character under the cursor if not at the beginning or 27704 end of the line (like `delete-char'). If at the end of the line, 27705 behaves identically to `possible-completions'. This command is 27706 unbound by default. 27707 27708 27709 27710 File: gdb.info, Node: Keyboard Macros, Next: Miscellaneous Commands, Prev: Commands For Completion, Up: Bindable Readline Commands 27711 27712 31.4.7 Keyboard Macros 27713 ---------------------- 27714 27715 `start-kbd-macro (C-x ()' 27716 Begin saving the characters typed into the current keyboard macro. 27717 27718 `end-kbd-macro (C-x ))' 27719 Stop saving the characters typed into the current keyboard macro 27720 and save the definition. 27721 27722 `call-last-kbd-macro (C-x e)' 27723 Re-execute the last keyboard macro defined, by making the 27724 characters in the macro appear as if typed at the keyboard. 27725 27726 27727 27728 File: gdb.info, Node: Miscellaneous Commands, Prev: Keyboard Macros, Up: Bindable Readline Commands 27729 27730 31.4.8 Some Miscellaneous Commands 27731 ---------------------------------- 27732 27733 `re-read-init-file (C-x C-r)' 27734 Read in the contents of the INPUTRC file, and incorporate any 27735 bindings or variable assignments found there. 27736 27737 `abort (C-g)' 27738 Abort the current editing command and ring the terminal's bell 27739 (subject to the setting of `bell-style'). 27740 27741 `do-uppercase-version (M-a, M-b, M-X, ...)' 27742 If the metafied character X is lowercase, run the command that is 27743 bound to the corresponding uppercase character. 27744 27745 `prefix-meta (<ESC>)' 27746 Metafy the next character typed. This is for keyboards without a 27747 meta key. Typing `<ESC> f' is equivalent to typing `M-f'. 27748 27749 `undo (C-_ or C-x C-u)' 27750 Incremental undo, separately remembered for each line. 27751 27752 `revert-line (M-r)' 27753 Undo all changes made to this line. This is like executing the 27754 `undo' command enough times to get back to the beginning. 27755 27756 `tilde-expand (M-~)' 27757 Perform tilde expansion on the current word. 27758 27759 `set-mark (C-@)' 27760 Set the mark to the point. If a numeric argument is supplied, the 27761 mark is set to that position. 27762 27763 `exchange-point-and-mark (C-x C-x)' 27764 Swap the point with the mark. The current cursor position is set 27765 to the saved position, and the old cursor position is saved as the 27766 mark. 27767 27768 `character-search (C-])' 27769 A character is read and point is moved to the next occurrence of 27770 that character. A negative count searches for previous 27771 occurrences. 27772 27773 `character-search-backward (M-C-])' 27774 A character is read and point is moved to the previous occurrence 27775 of that character. A negative count searches for subsequent 27776 occurrences. 27777 27778 `insert-comment (M-#)' 27779 Without a numeric argument, the value of the `comment-begin' 27780 variable is inserted at the beginning of the current line. If a 27781 numeric argument is supplied, this command acts as a toggle: if 27782 the characters at the beginning of the line do not match the value 27783 of `comment-begin', the value is inserted, otherwise the 27784 characters in `comment-begin' are deleted from the beginning of 27785 the line. In either case, the line is accepted as if a newline 27786 had been typed. 27787 27788 `dump-functions ()' 27789 Print all of the functions and their key bindings to the Readline 27790 output stream. If a numeric argument is supplied, the output is 27791 formatted in such a way that it can be made part of an INPUTRC 27792 file. This command is unbound by default. 27793 27794 `dump-variables ()' 27795 Print all of the settable variables and their values to the 27796 Readline output stream. If a numeric argument is supplied, the 27797 output is formatted in such a way that it can be made part of an 27798 INPUTRC file. This command is unbound by default. 27799 27800 `dump-macros ()' 27801 Print all of the Readline key sequences bound to macros and the 27802 strings they output. If a numeric argument is supplied, the 27803 output is formatted in such a way that it can be made part of an 27804 INPUTRC file. This command is unbound by default. 27805 27806 `emacs-editing-mode (C-e)' 27807 When in `vi' command mode, this causes a switch to `emacs' editing 27808 mode. 27809 27810 `vi-editing-mode (M-C-j)' 27811 When in `emacs' editing mode, this causes a switch to `vi' editing 27812 mode. 27813 27814 27815 27816 File: gdb.info, Node: Readline vi Mode, Prev: Bindable Readline Commands, Up: Command Line Editing 27817 27818 31.5 Readline vi Mode 27819 ===================== 27820 27821 While the Readline library does not have a full set of `vi' editing 27822 functions, it does contain enough to allow simple editing of the line. 27823 The Readline `vi' mode behaves as specified in the POSIX 1003.2 27824 standard. 27825 27826 In order to switch interactively between `emacs' and `vi' editing 27827 modes, use the command `M-C-j' (bound to emacs-editing-mode when in 27828 `vi' mode and to vi-editing-mode in `emacs' mode). The Readline 27829 default is `emacs' mode. 27830 27831 When you enter a line in `vi' mode, you are already placed in 27832 `insertion' mode, as if you had typed an `i'. Pressing <ESC> switches 27833 you into `command' mode, where you can edit the text of the line with 27834 the standard `vi' movement keys, move to previous history lines with 27835 `k' and subsequent lines with `j', and so forth. 27836 27837 27838 File: gdb.info, Node: Using History Interactively, Next: In Memoriam, Prev: Command Line Editing, Up: Top 27839 27840 32 Using History Interactively 27841 ****************************** 27842 27843 This chapter describes how to use the GNU History Library interactively, 27844 from a user's standpoint. It should be considered a user's guide. For 27845 information on using the GNU History Library in other programs, see the 27846 GNU Readline Library Manual. 27847 27848 * Menu: 27849 27850 * History Interaction:: What it feels like using History as a user. 27851 27852 27853 File: gdb.info, Node: History Interaction, Up: Using History Interactively 27854 27855 32.1 History Expansion 27856 ====================== 27857 27858 The History library provides a history expansion feature that is similar 27859 to the history expansion provided by `csh'. This section describes the 27860 syntax used to manipulate the history information. 27861 27862 History expansions introduce words from the history list into the 27863 input stream, making it easy to repeat commands, insert the arguments 27864 to a previous command into the current input line, or fix errors in 27865 previous commands quickly. 27866 27867 History expansion takes place in two parts. The first is to 27868 determine which line from the history list should be used during 27869 substitution. The second is to select portions of that line for 27870 inclusion into the current one. The line selected from the history is 27871 called the "event", and the portions of that line that are acted upon 27872 are called "words". Various "modifiers" are available to manipulate 27873 the selected words. The line is broken into words in the same fashion 27874 that Bash does, so that several words surrounded by quotes are 27875 considered one word. History expansions are introduced by the 27876 appearance of the history expansion character, which is `!' by default. 27877 27878 * Menu: 27879 27880 * Event Designators:: How to specify which history line to use. 27881 * Word Designators:: Specifying which words are of interest. 27882 * Modifiers:: Modifying the results of substitution. 27883 27884 27885 File: gdb.info, Node: Event Designators, Next: Word Designators, Up: History Interaction 27886 27887 32.1.1 Event Designators 27888 ------------------------ 27889 27890 An event designator is a reference to a command line entry in the 27891 history list. 27892 27893 `!' 27894 Start a history substitution, except when followed by a space, tab, 27895 the end of the line, or `='. 27896 27897 `!N' 27898 Refer to command line N. 27899 27900 `!-N' 27901 Refer to the command N lines back. 27902 27903 `!!' 27904 Refer to the previous command. This is a synonym for `!-1'. 27905 27906 `!STRING' 27907 Refer to the most recent command starting with STRING. 27908 27909 `!?STRING[?]' 27910 Refer to the most recent command containing STRING. The trailing 27911 `?' may be omitted if the STRING is followed immediately by a 27912 newline. 27913 27914 `^STRING1^STRING2^' 27915 Quick Substitution. Repeat the last command, replacing STRING1 27916 with STRING2. Equivalent to `!!:s/STRING1/STRING2/'. 27917 27918 `!#' 27919 The entire command line typed so far. 27920 27921 27922 27923 File: gdb.info, Node: Word Designators, Next: Modifiers, Prev: Event Designators, Up: History Interaction 27924 27925 32.1.2 Word Designators 27926 ----------------------- 27927 27928 Word designators are used to select desired words from the event. A 27929 `:' separates the event specification from the word designator. It may 27930 be omitted if the word designator begins with a `^', `$', `*', `-', or 27931 `%'. Words are numbered from the beginning of the line, with the first 27932 word being denoted by 0 (zero). Words are inserted into the current 27933 line separated by single spaces. 27934 27935 For example, 27936 27937 `!!' 27938 designates the preceding command. When you type this, the 27939 preceding command is repeated in toto. 27940 27941 `!!:$' 27942 designates the last argument of the preceding command. This may be 27943 shortened to `!$'. 27944 27945 `!fi:2' 27946 designates the second argument of the most recent command starting 27947 with the letters `fi'. 27948 27949 Here are the word designators: 27950 27951 `0 (zero)' 27952 The `0'th word. For many applications, this is the command word. 27953 27954 `N' 27955 The Nth word. 27956 27957 `^' 27958 The first argument; that is, word 1. 27959 27960 `$' 27961 The last argument. 27962 27963 `%' 27964 The word matched by the most recent `?STRING?' search. 27965 27966 `X-Y' 27967 A range of words; `-Y' abbreviates `0-Y'. 27968 27969 `*' 27970 All of the words, except the `0'th. This is a synonym for `1-$'. 27971 It is not an error to use `*' if there is just one word in the 27972 event; the empty string is returned in that case. 27973 27974 `X*' 27975 Abbreviates `X-$' 27976 27977 `X-' 27978 Abbreviates `X-$' like `X*', but omits the last word. 27979 27980 27981 If a word designator is supplied without an event specification, the 27982 previous command is used as the event. 27983 27984 27985 File: gdb.info, Node: Modifiers, Prev: Word Designators, Up: History Interaction 27986 27987 32.1.3 Modifiers 27988 ---------------- 27989 27990 After the optional word designator, you can add a sequence of one or 27991 more of the following modifiers, each preceded by a `:'. 27992 27993 `h' 27994 Remove a trailing pathname component, leaving only the head. 27995 27996 `t' 27997 Remove all leading pathname components, leaving the tail. 27998 27999 `r' 28000 Remove a trailing suffix of the form `.SUFFIX', leaving the 28001 basename. 28002 28003 `e' 28004 Remove all but the trailing suffix. 28005 28006 `p' 28007 Print the new command but do not execute it. 28008 28009 `s/OLD/NEW/' 28010 Substitute NEW for the first occurrence of OLD in the event line. 28011 Any delimiter may be used in place of `/'. The delimiter may be 28012 quoted in OLD and NEW with a single backslash. If `&' appears in 28013 NEW, it is replaced by OLD. A single backslash will quote the 28014 `&'. The final delimiter is optional if it is the last character 28015 on the input line. 28016 28017 `&' 28018 Repeat the previous substitution. 28019 28020 `g' 28021 `a' 28022 Cause changes to be applied over the entire event line. Used in 28023 conjunction with `s', as in `gs/OLD/NEW/', or with `&'. 28024 28025 `G' 28026 Apply the following `s' modifier once to each word in the event. 28027 28028 28029 28030 File: gdb.info, Node: In Memoriam, Next: Formatting Documentation, Prev: Using History Interactively, Up: Top 28031 28032 Appendix A In Memoriam 28033 ********************** 28034 28035 The GDB project mourns the loss of the following long-time contributors: 28036 28037 `Fred Fish' 28038 Fred was a long-standing contributor to GDB (1991-2006), and to 28039 Free Software in general. Outside of GDB, he was known in the 28040 Amiga world for his series of Fish Disks, and the GeekGadget 28041 project. 28042 28043 `Michael Snyder' 28044 Michael was one of the Global Maintainers of the GDB project, with 28045 contributions recorded as early as 1996, until 2011. In addition 28046 to his day to day participation, he was a large driving force 28047 behind adding Reverse Debugging to GDB. 28048 28049 Beyond their technical contributions to the project, they were also 28050 enjoyable members of the Free Software Community. We will miss them. 28051 28052 28053 File: gdb.info, Node: Formatting Documentation, Next: Installing GDB, Prev: In Memoriam, Up: Top 28054 28055 Appendix B Formatting Documentation 28056 *********************************** 28057 28058 The GDB 4 release includes an already-formatted reference card, ready 28059 for printing with PostScript or Ghostscript, in the `gdb' subdirectory 28060 of the main source directory(1). If you can use PostScript or 28061 Ghostscript with your printer, you can print the reference card 28062 immediately with `refcard.ps'. 28063 28064 The release also includes the source for the reference card. You 28065 can format it, using TeX, by typing: 28066 28067 make refcard.dvi 28068 28069 The GDB reference card is designed to print in "landscape" mode on 28070 US "letter" size paper; that is, on a sheet 11 inches wide by 8.5 inches 28071 high. You will need to specify this form of printing as an option to 28072 your DVI output program. 28073 28074 All the documentation for GDB comes as part of the machine-readable 28075 distribution. The documentation is written in Texinfo format, which is 28076 a documentation system that uses a single source file to produce both 28077 on-line information and a printed manual. You can use one of the Info 28078 formatting commands to create the on-line version of the documentation 28079 and TeX (or `texi2roff') to typeset the printed version. 28080 28081 GDB includes an already formatted copy of the on-line Info version 28082 of this manual in the `gdb' subdirectory. The main Info file is 28083 `gdb-7.3.1-gg2/gdb/gdb.info', and it refers to subordinate files 28084 matching `gdb.info*' in the same directory. If necessary, you can 28085 print out these files, or read them with any editor; but they are 28086 easier to read using the `info' subsystem in GNU Emacs or the 28087 standalone `info' program, available as part of the GNU Texinfo 28088 distribution. 28089 28090 If you want to format these Info files yourself, you need one of the 28091 Info formatting programs, such as `texinfo-format-buffer' or `makeinfo'. 28092 28093 If you have `makeinfo' installed, and are in the top level GDB 28094 source directory (`gdb-7.3.1-gg2', in the case of version 7.3.1-gg2), 28095 you can make the Info file by typing: 28096 28097 cd gdb 28098 make gdb.info 28099 28100 If you want to typeset and print copies of this manual, you need TeX, 28101 a program to print its DVI output files, and `texinfo.tex', the Texinfo 28102 definitions file. 28103 28104 TeX is a typesetting program; it does not print files directly, but 28105 produces output files called DVI files. To print a typeset document, 28106 you need a program to print DVI files. If your system has TeX 28107 installed, chances are it has such a program. The precise command to 28108 use depends on your system; `lpr -d' is common; another (for PostScript 28109 devices) is `dvips'. The DVI print command may require a file name 28110 without any extension or a `.dvi' extension. 28111 28112 TeX also requires a macro definitions file called `texinfo.tex'. 28113 This file tells TeX how to typeset a document written in Texinfo 28114 format. On its own, TeX cannot either read or typeset a Texinfo file. 28115 `texinfo.tex' is distributed with GDB and is located in the 28116 `gdb-VERSION-NUMBER/texinfo' directory. 28117 28118 If you have TeX and a DVI printer program installed, you can typeset 28119 and print this manual. First switch to the `gdb' subdirectory of the 28120 main source directory (for example, to `gdb-7.3.1-gg2/gdb') and type: 28121 28122 make gdb.dvi 28123 28124 Then give `gdb.dvi' to your DVI printing program. 28125 28126 ---------- Footnotes ---------- 28127 28128 (1) In `gdb-7.3.1-gg2/gdb/refcard.ps' of the version 7.3.1-gg2 28129 release. 28130 28131 28132 File: gdb.info, Node: Installing GDB, Next: Maintenance Commands, Prev: Formatting Documentation, Up: Top 28133 28134 Appendix C Installing GDB 28135 ************************* 28136 28137 * Menu: 28138 28139 * Requirements:: Requirements for building GDB 28140 * Running Configure:: Invoking the GDB `configure' script 28141 * Separate Objdir:: Compiling GDB in another directory 28142 * Config Names:: Specifying names for hosts and targets 28143 * Configure Options:: Summary of options for configure 28144 * System-wide configuration:: Having a system-wide init file 28145 28146 28147 File: gdb.info, Node: Requirements, Next: Running Configure, Up: Installing GDB 28148 28149 C.1 Requirements for Building GDB 28150 ================================= 28151 28152 Building GDB requires various tools and packages to be available. 28153 Other packages will be used only if they are found. 28154 28155 Tools/Packages Necessary for Building GDB 28156 ========================================= 28157 28158 ISO C90 compiler 28159 GDB is written in ISO C90. It should be buildable with any 28160 working C90 compiler, e.g. GCC. 28161 28162 28163 Tools/Packages Optional for Building GDB 28164 ======================================== 28165 28166 Expat 28167 GDB can use the Expat XML parsing library. This library may be 28168 included with your operating system distribution; if it is not, you 28169 can get the latest version from `http://expat.sourceforge.net'. 28170 The `configure' script will search for this library in several 28171 standard locations; if it is installed in an unusual path, you can 28172 use the `--with-libexpat-prefix' option to specify its location. 28173 28174 Expat is used for: 28175 28176 * Remote protocol memory maps (*note Memory Map Format::) 28177 28178 * Target descriptions (*note Target Descriptions::) 28179 28180 * Remote shared library lists (*note Library List Format::) 28181 28182 * MS-Windows shared libraries (*note Shared Libraries::) 28183 28184 * Traceframe info (*note Traceframe Info Format::) 28185 28186 zlib 28187 GDB will use the `zlib' library, if available, to read compressed 28188 debug sections. Some linkers, such as GNU gold, are capable of 28189 producing binaries with compressed debug sections. If GDB is 28190 compiled with `zlib', it will be able to read the debug 28191 information in such binaries. 28192 28193 The `zlib' library is likely included with your operating system 28194 distribution; if it is not, you can get the latest version from 28195 `http://zlib.net'. 28196 28197 iconv 28198 GDB's features related to character sets (*note Character Sets::) 28199 require a functioning `iconv' implementation. If you are on a GNU 28200 system, then this is provided by the GNU C Library. Some other 28201 systems also provide a working `iconv'. 28202 28203 If GDB is using the `iconv' program which is installed in a 28204 non-standard place, you will need to tell GDB where to find it. 28205 This is done with `--with-iconv-bin' which specifies the directory 28206 that contains the `iconv' program. 28207 28208 On systems without `iconv', you can install GNU Libiconv. If you 28209 have previously installed Libiconv, you can use the 28210 `--with-libiconv-prefix' option to configure. 28211 28212 GDB's top-level `configure' and `Makefile' will arrange to build 28213 Libiconv if a directory named `libiconv' appears in the top-most 28214 source directory. If Libiconv is built this way, and if the 28215 operating system does not provide a suitable `iconv' 28216 implementation, then the just-built library will automatically be 28217 used by GDB. One easy way to set this up is to download GNU 28218 Libiconv, unpack it, and then rename the directory holding the 28219 Libiconv source code to `libiconv'. 28220 28221 28222 File: gdb.info, Node: Running Configure, Next: Separate Objdir, Prev: Requirements, Up: Installing GDB 28223 28224 C.2 Invoking the GDB `configure' Script 28225 ======================================= 28226 28227 GDB comes with a `configure' script that automates the process of 28228 preparing GDB for installation; you can then use `make' to build the 28229 `gdb' program. 28230 28231 The GDB distribution includes all the source code you need for GDB 28232 in a single directory, whose name is usually composed by appending the 28233 version number to `gdb'. 28234 28235 For example, the GDB version 7.3.1-gg2 distribution is in the 28236 `gdb-7.3.1-gg2' directory. That directory contains: 28237 28238 `gdb-7.3.1-gg2/configure (and supporting files)' 28239 script for configuring GDB and all its supporting libraries 28240 28241 `gdb-7.3.1-gg2/gdb' 28242 the source specific to GDB itself 28243 28244 `gdb-7.3.1-gg2/bfd' 28245 source for the Binary File Descriptor library 28246 28247 `gdb-7.3.1-gg2/include' 28248 GNU include files 28249 28250 `gdb-7.3.1-gg2/libiberty' 28251 source for the `-liberty' free software library 28252 28253 `gdb-7.3.1-gg2/opcodes' 28254 source for the library of opcode tables and disassemblers 28255 28256 `gdb-7.3.1-gg2/readline' 28257 source for the GNU command-line interface 28258 28259 `gdb-7.3.1-gg2/glob' 28260 source for the GNU filename pattern-matching subroutine 28261 28262 `gdb-7.3.1-gg2/mmalloc' 28263 source for the GNU memory-mapped malloc package 28264 28265 The simplest way to configure and build GDB is to run `configure' 28266 from the `gdb-VERSION-NUMBER' source directory, which in this example 28267 is the `gdb-7.3.1-gg2' directory. 28268 28269 First switch to the `gdb-VERSION-NUMBER' source directory if you are 28270 not already in it; then run `configure'. Pass the identifier for the 28271 platform on which GDB will run as an argument. 28272 28273 For example: 28274 28275 cd gdb-7.3.1-gg2 28276 ./configure HOST 28277 make 28278 28279 where HOST is an identifier such as `sun4' or `decstation', that 28280 identifies the platform where GDB will run. (You can often leave off 28281 HOST; `configure' tries to guess the correct value by examining your 28282 system.) 28283 28284 Running `configure HOST' and then running `make' builds the `bfd', 28285 `readline', `mmalloc', and `libiberty' libraries, then `gdb' itself. 28286 The configured source files, and the binaries, are left in the 28287 corresponding source directories. 28288 28289 `configure' is a Bourne-shell (`/bin/sh') script; if your system 28290 does not recognize this automatically when you run a different shell, 28291 you may need to run `sh' on it explicitly: 28292 28293 sh configure HOST 28294 28295 If you run `configure' from a directory that contains source 28296 directories for multiple libraries or programs, such as the 28297 `gdb-7.3.1-gg2' source directory for version 7.3.1-gg2, `configure' 28298 creates configuration files for every directory level underneath (unless 28299 you tell it not to, with the `--norecursion' option). 28300 28301 You should run the `configure' script from the top directory in the 28302 source tree, the `gdb-VERSION-NUMBER' directory. If you run 28303 `configure' from one of the subdirectories, you will configure only 28304 that subdirectory. That is usually not what you want. In particular, 28305 if you run the first `configure' from the `gdb' subdirectory of the 28306 `gdb-VERSION-NUMBER' directory, you will omit the configuration of 28307 `bfd', `readline', and other sibling directories of the `gdb' 28308 subdirectory. This leads to build errors about missing include files 28309 such as `bfd/bfd.h'. 28310 28311 You can install `gdb' anywhere; it has no hardwired paths. However, 28312 you should make sure that the shell on your path (named by the `SHELL' 28313 environment variable) is publicly readable. Remember that GDB uses the 28314 shell to start your program--some systems refuse to let GDB debug child 28315 processes whose programs are not readable. 28316 28317 28318 File: gdb.info, Node: Separate Objdir, Next: Config Names, Prev: Running Configure, Up: Installing GDB 28319 28320 C.3 Compiling GDB in Another Directory 28321 ====================================== 28322 28323 If you want to run GDB versions for several host or target machines, 28324 you need a different `gdb' compiled for each combination of host and 28325 target. `configure' is designed to make this easy by allowing you to 28326 generate each configuration in a separate subdirectory, rather than in 28327 the source directory. If your `make' program handles the `VPATH' 28328 feature (GNU `make' does), running `make' in each of these directories 28329 builds the `gdb' program specified there. 28330 28331 To build `gdb' in a separate directory, run `configure' with the 28332 `--srcdir' option to specify where to find the source. (You also need 28333 to specify a path to find `configure' itself from your working 28334 directory. If the path to `configure' would be the same as the 28335 argument to `--srcdir', you can leave out the `--srcdir' option; it is 28336 assumed.) 28337 28338 For example, with version 7.3.1-gg2, you can build GDB in a separate 28339 directory for a Sun 4 like this: 28340 28341 cd gdb-7.3.1-gg2 28342 mkdir ../gdb-sun4 28343 cd ../gdb-sun4 28344 ../gdb-7.3.1-gg2/configure sun4 28345 make 28346 28347 When `configure' builds a configuration using a remote source 28348 directory, it creates a tree for the binaries with the same structure 28349 (and using the same names) as the tree under the source directory. In 28350 the example, you'd find the Sun 4 library `libiberty.a' in the 28351 directory `gdb-sun4/libiberty', and GDB itself in `gdb-sun4/gdb'. 28352 28353 Make sure that your path to the `configure' script has just one 28354 instance of `gdb' in it. If your path to `configure' looks like 28355 `../gdb-7.3.1-gg2/gdb/configure', you are configuring only one 28356 subdirectory of GDB, not the whole package. This leads to build errors 28357 about missing include files such as `bfd/bfd.h'. 28358 28359 One popular reason to build several GDB configurations in separate 28360 directories is to configure GDB for cross-compiling (where GDB runs on 28361 one machine--the "host"--while debugging programs that run on another 28362 machine--the "target"). You specify a cross-debugging target by giving 28363 the `--target=TARGET' option to `configure'. 28364 28365 When you run `make' to build a program or library, you must run it 28366 in a configured directory--whatever directory you were in when you 28367 called `configure' (or one of its subdirectories). 28368 28369 The `Makefile' that `configure' generates in each source directory 28370 also runs recursively. If you type `make' in a source directory such 28371 as `gdb-7.3.1-gg2' (or in a separate configured directory configured 28372 with `--srcdir=DIRNAME/gdb-7.3.1-gg2'), you will build all the required 28373 libraries, and then build GDB. 28374 28375 When you have multiple hosts or targets configured in separate 28376 directories, you can run `make' on them in parallel (for example, if 28377 they are NFS-mounted on each of the hosts); they will not interfere 28378 with each other. 28379 28380 28381 File: gdb.info, Node: Config Names, Next: Configure Options, Prev: Separate Objdir, Up: Installing GDB 28382 28383 C.4 Specifying Names for Hosts and Targets 28384 ========================================== 28385 28386 The specifications used for hosts and targets in the `configure' script 28387 are based on a three-part naming scheme, but some short predefined 28388 aliases are also supported. The full naming scheme encodes three pieces 28389 of information in the following pattern: 28390 28391 ARCHITECTURE-VENDOR-OS 28392 28393 For example, you can use the alias `sun4' as a HOST argument, or as 28394 the value for TARGET in a `--target=TARGET' option. The equivalent 28395 full name is `sparc-sun-sunos4'. 28396 28397 The `configure' script accompanying GDB does not provide any query 28398 facility to list all supported host and target names or aliases. 28399 `configure' calls the Bourne shell script `config.sub' to map 28400 abbreviations to full names; you can read the script, if you wish, or 28401 you can use it to test your guesses on abbreviations--for example: 28402 28403 % sh config.sub i386-linux 28404 i386-pc-linux-gnu 28405 % sh config.sub alpha-linux 28406 alpha-unknown-linux-gnu 28407 % sh config.sub hp9k700 28408 hppa1.1-hp-hpux 28409 % sh config.sub sun4 28410 sparc-sun-sunos4.1.1 28411 % sh config.sub sun3 28412 m68k-sun-sunos4.1.1 28413 % sh config.sub i986v 28414 Invalid configuration `i986v': machine `i986v' not recognized 28415 28416 `config.sub' is also distributed in the GDB source directory 28417 (`gdb-7.3.1-gg2', for version 7.3.1-gg2). 28418 28419 28420 File: gdb.info, Node: Configure Options, Next: System-wide configuration, Prev: Config Names, Up: Installing GDB 28421 28422 C.5 `configure' Options 28423 ======================= 28424 28425 Here is a summary of the `configure' options and arguments that are 28426 most often useful for building GDB. `configure' also has several other 28427 options not listed here. *note (configure.info)What Configure Does::, 28428 for a full explanation of `configure'. 28429 28430 configure [--help] 28431 [--prefix=DIR] 28432 [--exec-prefix=DIR] 28433 [--srcdir=DIRNAME] 28434 [--norecursion] [--rm] 28435 [--target=TARGET] 28436 HOST 28437 28438 You may introduce options with a single `-' rather than `--' if you 28439 prefer; but you may abbreviate option names if you use `--'. 28440 28441 `--help' 28442 Display a quick summary of how to invoke `configure'. 28443 28444 `--prefix=DIR' 28445 Configure the source to install programs and files under directory 28446 `DIR'. 28447 28448 `--exec-prefix=DIR' 28449 Configure the source to install programs under directory `DIR'. 28450 28451 `--srcdir=DIRNAME' 28452 *Warning: using this option requires GNU `make', or another `make' 28453 that implements the `VPATH' feature.* 28454 Use this option to make configurations in directories separate 28455 from the GDB source directories. Among other things, you can use 28456 this to build (or maintain) several configurations simultaneously, 28457 in separate directories. `configure' writes 28458 configuration-specific files in the current directory, but 28459 arranges for them to use the source in the directory DIRNAME. 28460 `configure' creates directories under the working directory in 28461 parallel to the source directories below DIRNAME. 28462 28463 `--norecursion' 28464 Configure only the directory level where `configure' is executed; 28465 do not propagate configuration to subdirectories. 28466 28467 `--target=TARGET' 28468 Configure GDB for cross-debugging programs running on the specified 28469 TARGET. Without this option, GDB is configured to debug programs 28470 that run on the same machine (HOST) as GDB itself. 28471 28472 There is no convenient way to generate a list of all available 28473 targets. 28474 28475 `HOST ...' 28476 Configure GDB to run on the specified HOST. 28477 28478 There is no convenient way to generate a list of all available 28479 hosts. 28480 28481 There are many other options available as well, but they are 28482 generally needed for special purposes only. 28483 28484 28485 File: gdb.info, Node: System-wide configuration, Prev: Configure Options, Up: Installing GDB 28486 28487 C.6 System-wide configuration and settings 28488 ========================================== 28489 28490 GDB can be configured to have a system-wide init file; this file will 28491 be read and executed at startup (*note What GDB does during startup: 28492 Startup.). 28493 28494 Here is the corresponding configure option: 28495 28496 `--with-system-gdbinit=FILE' 28497 Specify that the default location of the system-wide init file is 28498 FILE. 28499 28500 If GDB has been configured with the option `--prefix=$prefix', it 28501 may be subject to relocation. Two possible cases: 28502 28503 * If the default location of this init file contains `$prefix', it 28504 will be subject to relocation. Suppose that the configure options 28505 are `--prefix=$prefix --with-system-gdbinit=$prefix/etc/gdbinit'; 28506 if GDB is moved from `$prefix' to `$install', the system init file 28507 is looked for as `$install/etc/gdbinit' instead of 28508 `$prefix/etc/gdbinit'. 28509 28510 * By contrast, if the default location does not contain the prefix, 28511 it will not be relocated. E.g. if GDB has been configured with 28512 `--prefix=/usr/local --with-system-gdbinit=/usr/share/gdb/gdbinit', 28513 then GDB will always look for `/usr/share/gdb/gdbinit', wherever 28514 GDB is installed. 28515 28516 28517 File: gdb.info, Node: Maintenance Commands, Next: Remote Protocol, Prev: Installing GDB, Up: Top 28518 28519 Appendix D Maintenance Commands 28520 ******************************* 28521 28522 In addition to commands intended for GDB users, GDB includes a number 28523 of commands intended for GDB developers, that are not documented 28524 elsewhere in this manual. These commands are provided here for 28525 reference. (For commands that turn on debugging messages, see *note 28526 Debugging Output::.) 28527 28528 `maint agent EXPRESSION' 28529 `maint agent-eval EXPRESSION' 28530 Translate the given EXPRESSION into remote agent bytecodes. This 28531 command is useful for debugging the Agent Expression mechanism 28532 (*note Agent Expressions::). The `agent' version produces an 28533 expression useful for data collection, such as by tracepoints, 28534 while `maint agent-eval' produces an expression that evaluates 28535 directly to a result. For instance, a collection expression for 28536 `globa + globb' will include bytecodes to record four bytes of 28537 memory at each of the addresses of `globa' and `globb', while 28538 discarding the result of the addition, while an evaluation 28539 expression will do the addition and return the sum. 28540 28541 `maint info breakpoints' 28542 Using the same format as `info breakpoints', display both the 28543 breakpoints you've set explicitly, and those GDB is using for 28544 internal purposes. Internal breakpoints are shown with negative 28545 breakpoint numbers. The type column identifies what kind of 28546 breakpoint is shown: 28547 28548 `breakpoint' 28549 Normal, explicitly set breakpoint. 28550 28551 `watchpoint' 28552 Normal, explicitly set watchpoint. 28553 28554 `longjmp' 28555 Internal breakpoint, used to handle correctly stepping through 28556 `longjmp' calls. 28557 28558 `longjmp resume' 28559 Internal breakpoint at the target of a `longjmp'. 28560 28561 `until' 28562 Temporary internal breakpoint used by the GDB `until' command. 28563 28564 `finish' 28565 Temporary internal breakpoint used by the GDB `finish' 28566 command. 28567 28568 `shlib events' 28569 Shared library events. 28570 28571 28572 `set displaced-stepping' 28573 `show displaced-stepping' 28574 Control whether or not GDB will do "displaced stepping" if the 28575 target supports it. Displaced stepping is a way to single-step 28576 over breakpoints without removing them from the inferior, by 28577 executing an out-of-line copy of the instruction that was 28578 originally at the breakpoint location. It is also known as 28579 out-of-line single-stepping. 28580 28581 `set displaced-stepping on' 28582 If the target architecture supports it, GDB will use 28583 displaced stepping to step over breakpoints. 28584 28585 `set displaced-stepping off' 28586 GDB will not use displaced stepping to step over breakpoints, 28587 even if such is supported by the target architecture. 28588 28589 `set displaced-stepping auto' 28590 This is the default mode. GDB will use displaced stepping 28591 only if non-stop mode is active (*note Non-Stop Mode::) and 28592 the target architecture supports displaced stepping. 28593 28594 `maint check-symtabs' 28595 Check the consistency of psymtabs and symtabs. 28596 28597 `maint cplus first_component NAME' 28598 Print the first C++ class/namespace component of NAME. 28599 28600 `maint cplus namespace' 28601 Print the list of possible C++ namespaces. 28602 28603 `maint demangle NAME' 28604 Demangle a C++ or Objective-C mangled NAME. 28605 28606 `maint deprecate COMMAND [REPLACEMENT]' 28607 `maint undeprecate COMMAND' 28608 Deprecate or undeprecate the named COMMAND. Deprecated commands 28609 cause GDB to issue a warning when you use them. The optional 28610 argument REPLACEMENT says which newer command should be used in 28611 favor of the deprecated one; if it is given, GDB will mention the 28612 replacement as part of the warning. 28613 28614 `maint dump-me' 28615 Cause a fatal signal in the debugger and force it to dump its core. 28616 This is supported only on systems which support aborting a program 28617 with the `SIGQUIT' signal. 28618 28619 `maint internal-error [MESSAGE-TEXT]' 28620 `maint internal-warning [MESSAGE-TEXT]' 28621 Cause GDB to call the internal function `internal_error' or 28622 `internal_warning' and hence behave as though an internal error or 28623 internal warning has been detected. In addition to reporting the 28624 internal problem, these functions give the user the opportunity to 28625 either quit GDB or create a core file of the current GDB session. 28626 28627 These commands take an optional parameter MESSAGE-TEXT that is 28628 used as the text of the error or warning message. 28629 28630 Here's an example of using `internal-error': 28631 28632 (gdb) maint internal-error testing, 1, 2 28633 .../maint.c:121: internal-error: testing, 1, 2 28634 A problem internal to GDB has been detected. Further 28635 debugging may prove unreliable. 28636 Quit this debugging session? (y or n) n 28637 Create a core file? (y or n) n 28638 (gdb) 28639 28640 `maint set internal-error ACTION [ask|yes|no]' 28641 `maint show internal-error ACTION' 28642 `maint set internal-warning ACTION [ask|yes|no]' 28643 `maint show internal-warning ACTION' 28644 When GDB reports an internal problem (error or warning) it gives 28645 the user the opportunity to both quit GDB and create a core file 28646 of the current GDB session. These commands let you override the 28647 default behaviour for each particular ACTION, described in the 28648 table below. 28649 28650 `quit' 28651 You can specify that GDB should always (yes) or never (no) 28652 quit. The default is to ask the user what to do. 28653 28654 `corefile' 28655 You can specify that GDB should always (yes) or never (no) 28656 create a core file. The default is to ask the user what to 28657 do. 28658 28659 `maint packet TEXT' 28660 If GDB is talking to an inferior via the serial protocol, then 28661 this command sends the string TEXT to the inferior, and displays 28662 the response packet. GDB supplies the initial `$' character, the 28663 terminating `#' character, and the checksum. 28664 28665 `maint print architecture [FILE]' 28666 Print the entire architecture configuration. The optional argument 28667 FILE names the file where the output goes. 28668 28669 `maint print c-tdesc' 28670 Print the current target description (*note Target Descriptions::) 28671 as a C source file. The created source file can be used in GDB 28672 when an XML parser is not available to parse the description. 28673 28674 `maint print dummy-frames' 28675 Prints the contents of GDB's internal dummy-frame stack. 28676 28677 (gdb) b add 28678 ... 28679 (gdb) print add(2,3) 28680 Breakpoint 2, add (a=2, b=3) at ... 28681 58 return (a + b); 28682 The program being debugged stopped while in a function called from GDB. 28683 ... 28684 (gdb) maint print dummy-frames 28685 0x1a57c80: pc=0x01014068 fp=0x0200bddc sp=0x0200bdd6 28686 top=0x0200bdd4 id={stack=0x200bddc,code=0x101405c} 28687 call_lo=0x01014000 call_hi=0x01014001 28688 (gdb) 28689 28690 Takes an optional file parameter. 28691 28692 `maint print registers [FILE]' 28693 `maint print raw-registers [FILE]' 28694 `maint print cooked-registers [FILE]' 28695 `maint print register-groups [FILE]' 28696 Print GDB's internal register data structures. 28697 28698 The command `maint print raw-registers' includes the contents of 28699 the raw register cache; the command `maint print cooked-registers' 28700 includes the (cooked) value of all registers, including registers 28701 which aren't available on the target nor visible to user; and the 28702 command `maint print register-groups' includes the groups that each 28703 register is a member of. *Note Registers: (gdbint)Registers. 28704 28705 These commands take an optional parameter, a file name to which to 28706 write the information. 28707 28708 `maint print reggroups [FILE]' 28709 Print GDB's internal register group data structures. The optional 28710 argument FILE tells to what file to write the information. 28711 28712 The register groups info looks like this: 28713 28714 (gdb) maint print reggroups 28715 Group Type 28716 general user 28717 float user 28718 all user 28719 vector user 28720 system user 28721 save internal 28722 restore internal 28723 28724 `flushregs' 28725 This command forces GDB to flush its internal register cache. 28726 28727 `maint print objfiles' 28728 Print a dump of all known object files. For each object file, this 28729 command prints its name, address in memory, and all of its psymtabs 28730 and symtabs. 28731 28732 `maint print section-scripts [REGEXP]' 28733 Print a dump of scripts specified in the `.debug_gdb_section' 28734 section. If REGEXP is specified, only print scripts loaded by 28735 object files matching REGEXP. For each script, this command 28736 prints its name as specified in the objfile, and the full path if 28737 known. *Note .debug_gdb_scripts section::. 28738 28739 `maint print statistics' 28740 This command prints, for each object file in the program, various 28741 data about that object file followed by the byte cache ("bcache") 28742 statistics for the object file. The objfile data includes the 28743 number of minimal, partial, full, and stabs symbols, the number of 28744 types defined by the objfile, the number of as yet unexpanded psym 28745 tables, the number of line tables and string tables, and the 28746 amount of memory used by the various tables. The bcache 28747 statistics include the counts, sizes, and counts of duplicates of 28748 all and unique objects, max, average, and median entry size, total 28749 memory used and its overhead and savings, and various measures of 28750 the hash table size and chain lengths. 28751 28752 `maint print target-stack' 28753 A "target" is an interface between the debugger and a particular 28754 kind of file or process. Targets can be stacked in "strata", so 28755 that more than one target can potentially respond to a request. 28756 In particular, memory accesses will walk down the stack of targets 28757 until they find a target that is interested in handling that 28758 particular address. 28759 28760 This command prints a short description of each layer that was 28761 pushed on the "target stack", starting from the top layer down to 28762 the bottom one. 28763 28764 `maint print type EXPR' 28765 Print the type chain for a type specified by EXPR. The argument 28766 can be either a type name or a symbol. If it is a symbol, the 28767 type of that symbol is described. The type chain produced by this 28768 command is a recursive definition of the data type as stored in 28769 GDB's data structures, including its flags and contained types. 28770 28771 `maint set dwarf2 always-disassemble' 28772 28773 `maint show dwarf2 always-disassemble' 28774 Control the behavior of `info address' when using DWARF debugging 28775 information. 28776 28777 The default is `off', which means that GDB should try to describe 28778 a variable's location in an easily readable format. When `on', 28779 GDB will instead display the DWARF location expression in an 28780 assembly-like format. Note that some locations are too complex 28781 for GDB to describe simply; in this case you will always see the 28782 disassembly form. 28783 28784 Here is an example of the resulting disassembly: 28785 28786 (gdb) info addr argc 28787 Symbol "argc" is a complex DWARF expression: 28788 1: DW_OP_fbreg 0 28789 28790 For more information on these expressions, see the DWARF standard 28791 (http://www.dwarfstd.org/). 28792 28793 `maint set dwarf2 max-cache-age' 28794 `maint show dwarf2 max-cache-age' 28795 Control the DWARF 2 compilation unit cache. 28796 28797 In object files with inter-compilation-unit references, such as 28798 those produced by the GCC option `-feliminate-dwarf2-dups', the 28799 DWARF 2 reader needs to frequently refer to previously read 28800 compilation units. This setting controls how long a compilation 28801 unit will remain in the cache if it is not referenced. A higher 28802 limit means that cached compilation units will be stored in memory 28803 longer, and more total memory will be used. Setting it to zero 28804 disables caching, which will slow down GDB startup, but reduce 28805 memory consumption. 28806 28807 `maint set profile' 28808 `maint show profile' 28809 Control profiling of GDB. 28810 28811 Profiling will be disabled until you use the `maint set profile' 28812 command to enable it. When you enable profiling, the system will 28813 begin collecting timing and execution count data; when you disable 28814 profiling or exit GDB, the results will be written to a log file. 28815 Remember that if you use profiling, GDB will overwrite the 28816 profiling log file (often called `gmon.out'). If you have a 28817 record of important profiling data in a `gmon.out' file, be sure 28818 to move it to a safe location. 28819 28820 Configuring with `--enable-profiling' arranges for GDB to be 28821 compiled with the `-pg' compiler option. 28822 28823 `maint set show-debug-regs' 28824 `maint show show-debug-regs' 28825 Control whether to show variables that mirror the hardware debug 28826 registers. Use `ON' to enable, `OFF' to disable. If enabled, the 28827 debug registers values are shown when GDB inserts or removes a 28828 hardware breakpoint or watchpoint, and when the inferior triggers 28829 a hardware-assisted breakpoint or watchpoint. 28830 28831 `maint set show-all-tib' 28832 `maint show show-all-tib' 28833 Control whether to show all non zero areas within a 1k block 28834 starting at thread local base, when using the `info w32 28835 thread-information-block' command. 28836 28837 `maint space' 28838 Control whether to display memory usage for each command. If set 28839 to a nonzero value, GDB will display how much memory each command 28840 took, following the command's own output. This can also be 28841 requested by invoking GDB with the `--statistics' command-line 28842 switch (*note Mode Options::). 28843 28844 `maint time' 28845 Control whether to display the execution time for each command. If 28846 set to a nonzero value, GDB will display how much time it took to 28847 execute each command, following the command's own output. The 28848 time is not printed for the commands that run the target, since 28849 there's no mechanism currently to compute how much time was spend 28850 by GDB and how much time was spend by the program been debugged. 28851 it's not possibly currently This can also be requested by invoking 28852 GDB with the `--statistics' command-line switch (*note Mode 28853 Options::). 28854 28855 `maint translate-address [SECTION] ADDR' 28856 Find the symbol stored at the location specified by the address 28857 ADDR and an optional section name SECTION. If found, GDB prints 28858 the name of the closest symbol and an offset from the symbol's 28859 location to the specified address. This is similar to the `info 28860 address' command (*note Symbols::), except that this command also 28861 allows to find symbols in other sections. 28862 28863 If section was not specified, the section in which the symbol was 28864 found is also printed. For dynamically linked executables, the 28865 name of executable or shared library containing the symbol is 28866 printed as well. 28867 28868 28869 The following command is useful for non-interactive invocations of 28870 GDB, such as in the test suite. 28871 28872 `set watchdog NSEC' 28873 Set the maximum number of seconds GDB will wait for the target 28874 operation to finish. If this time expires, GDB reports and error 28875 and the command is aborted. 28876 28877 `show watchdog' 28878 Show the current setting of the target wait timeout. 28879 28880 28881 File: gdb.info, Node: Remote Protocol, Next: Agent Expressions, Prev: Maintenance Commands, Up: Top 28882 28883 Appendix E GDB Remote Serial Protocol 28884 ************************************* 28885 28886 * Menu: 28887 28888 * Overview:: 28889 * Packets:: 28890 * Stop Reply Packets:: 28891 * General Query Packets:: 28892 * Architecture-Specific Protocol Details:: 28893 * Tracepoint Packets:: 28894 * Host I/O Packets:: 28895 * Interrupts:: 28896 * Notification Packets:: 28897 * Remote Non-Stop:: 28898 * Packet Acknowledgment:: 28899 * Examples:: 28900 * File-I/O Remote Protocol Extension:: 28901 * Library List Format:: 28902 * Memory Map Format:: 28903 * Thread List Format:: 28904 * Traceframe Info Format:: 28905 28906 28907 File: gdb.info, Node: Overview, Next: Packets, Up: Remote Protocol 28908 28909 E.1 Overview 28910 ============ 28911 28912 There may be occasions when you need to know something about the 28913 protocol--for example, if there is only one serial port to your target 28914 machine, you might want your program to do something special if it 28915 recognizes a packet meant for GDB. 28916 28917 In the examples below, `->' and `<-' are used to indicate 28918 transmitted and received data, respectively. 28919 28920 All GDB commands and responses (other than acknowledgments and 28921 notifications, see *note Notification Packets::) are sent as a PACKET. 28922 A PACKET is introduced with the character `$', the actual PACKET-DATA, 28923 and the terminating character `#' followed by a two-digit CHECKSUM: 28924 28925 `$'PACKET-DATA`#'CHECKSUM 28926 The two-digit CHECKSUM is computed as the modulo 256 sum of all 28927 characters between the leading `$' and the trailing `#' (an eight bit 28928 unsigned checksum). 28929 28930 Implementors should note that prior to GDB 5.0 the protocol 28931 specification also included an optional two-digit SEQUENCE-ID: 28932 28933 `$'SEQUENCE-ID`:'PACKET-DATA`#'CHECKSUM 28934 28935 That SEQUENCE-ID was appended to the acknowledgment. GDB has never 28936 output SEQUENCE-IDs. Stubs that handle packets added since GDB 5.0 28937 must not accept SEQUENCE-ID. 28938 28939 When either the host or the target machine receives a packet, the 28940 first response expected is an acknowledgment: either `+' (to indicate 28941 the package was received correctly) or `-' (to request retransmission): 28942 28943 -> `$'PACKET-DATA`#'CHECKSUM 28944 <- `+' 28945 The `+'/`-' acknowledgments can be disabled once a connection is 28946 established. *Note Packet Acknowledgment::, for details. 28947 28948 The host (GDB) sends COMMANDs, and the target (the debugging stub 28949 incorporated in your program) sends a RESPONSE. In the case of step 28950 and continue COMMANDs, the response is only sent when the operation has 28951 completed, and the target has again stopped all threads in all attached 28952 processes. This is the default all-stop mode behavior, but the remote 28953 protocol also supports GDB's non-stop execution mode; see *note Remote 28954 Non-Stop::, for details. 28955 28956 PACKET-DATA consists of a sequence of characters with the exception 28957 of `#' and `$' (see `X' packet for additional exceptions). 28958 28959 Fields within the packet should be separated using `,' `;' or `:'. 28960 Except where otherwise noted all numbers are represented in HEX with 28961 leading zeros suppressed. 28962 28963 Implementors should note that prior to GDB 5.0, the character `:' 28964 could not appear as the third character in a packet (as it would 28965 potentially conflict with the SEQUENCE-ID). 28966 28967 Binary data in most packets is encoded either as two hexadecimal 28968 digits per byte of binary data. This allowed the traditional remote 28969 protocol to work over connections which were only seven-bit clean. 28970 Some packets designed more recently assume an eight-bit clean 28971 connection, and use a more efficient encoding to send and receive 28972 binary data. 28973 28974 The binary data representation uses `7d' (ASCII `}') as an escape 28975 character. Any escaped byte is transmitted as the escape character 28976 followed by the original character XORed with `0x20'. For example, the 28977 byte `0x7d' would be transmitted as the two bytes `0x7d 0x5d'. The 28978 bytes `0x23' (ASCII `#'), `0x24' (ASCII `$'), and `0x7d' (ASCII `}') 28979 must always be escaped. Responses sent by the stub must also escape 28980 `0x2a' (ASCII `*'), so that it is not interpreted as the start of a 28981 run-length encoded sequence (described next). 28982 28983 Response DATA can be run-length encoded to save space. Run-length 28984 encoding replaces runs of identical characters with one instance of the 28985 repeated character, followed by a `*' and a repeat count. The repeat 28986 count is itself sent encoded, to avoid binary characters in DATA: a 28987 value of N is sent as `N+29'. For a repeat count greater or equal to 28988 3, this produces a printable ASCII character, e.g. a space (ASCII code 28989 32) for a repeat count of 3. (This is because run-length encoding 28990 starts to win for counts 3 or more.) Thus, for example, `0* ' is a 28991 run-length encoding of "0000": the space character after `*' means 28992 repeat the leading `0' `32 - 29 = 3' more times. 28993 28994 The printable characters `#' and `$' or with a numeric value greater 28995 than 126 must not be used. Runs of six repeats (`#') or seven repeats 28996 (`$') can be expanded using a repeat count of only five (`"'). For 28997 example, `00000000' can be encoded as `0*"00'. 28998 28999 The error response returned for some packets includes a two character 29000 error number. That number is not well defined. 29001 29002 For any COMMAND not supported by the stub, an empty response 29003 (`$#00') should be returned. That way it is possible to extend the 29004 protocol. A newer GDB can tell if a packet is supported based on that 29005 response. 29006 29007 A stub is required to support the `g', `G', `m', `M', `c', and `s' 29008 COMMANDs. All other COMMANDs are optional. 29009 29010 29011 File: gdb.info, Node: Packets, Next: Stop Reply Packets, Prev: Overview, Up: Remote Protocol 29012 29013 E.2 Packets 29014 =========== 29015 29016 The following table provides a complete list of all currently defined 29017 COMMANDs and their corresponding response DATA. *Note File-I/O Remote 29018 Protocol Extension::, for details about the File I/O extension of the 29019 remote protocol. 29020 29021 Each packet's description has a template showing the packet's overall 29022 syntax, followed by an explanation of the packet's meaning. We include 29023 spaces in some of the templates for clarity; these are not part of the 29024 packet's syntax. No GDB packet uses spaces to separate its components. 29025 For example, a template like `foo BAR BAZ' describes a packet beginning 29026 with the three ASCII bytes `foo', followed by a BAR, followed directly 29027 by a BAZ. GDB does not transmit a space character between the `foo' 29028 and the BAR, or between the BAR and the BAZ. 29029 29030 Several packets and replies include a THREAD-ID field to identify a 29031 thread. Normally these are positive numbers with a target-specific 29032 interpretation, formatted as big-endian hex strings. A THREAD-ID can 29033 also be a literal `-1' to indicate all threads, or `0' to pick any 29034 thread. 29035 29036 In addition, the remote protocol supports a multiprocess feature in 29037 which the THREAD-ID syntax is extended to optionally include both 29038 process and thread ID fields, as `pPID.TID'. The PID (process) and TID 29039 (thread) components each have the format described above: a positive 29040 number with target-specific interpretation formatted as a big-endian 29041 hex string, literal `-1' to indicate all processes or threads 29042 (respectively), or `0' to indicate an arbitrary process or thread. 29043 Specifying just a process, as `pPID', is equivalent to `pPID.-1'. It 29044 is an error to specify all processes but a specific thread, such as 29045 `p-1.TID'. Note that the `p' prefix is _not_ used for those packets 29046 and replies explicitly documented to include a process ID, rather than 29047 a THREAD-ID. 29048 29049 The multiprocess THREAD-ID syntax extensions are only used if both 29050 GDB and the stub report support for the `multiprocess' feature using 29051 `qSupported'. *Note multiprocess extensions::, for more information. 29052 29053 Note that all packet forms beginning with an upper- or lower-case 29054 letter, other than those described here, are reserved for future use. 29055 29056 Here are the packet descriptions. 29057 29058 `!' 29059 Enable extended mode. In extended mode, the remote server is made 29060 persistent. The `R' packet is used to restart the program being 29061 debugged. 29062 29063 Reply: 29064 `OK' 29065 The remote target both supports and has enabled extended mode. 29066 29067 `?' 29068 Indicate the reason the target halted. The reply is the same as 29069 for step and continue. This packet has a special interpretation 29070 when the target is in non-stop mode; see *note Remote Non-Stop::. 29071 29072 Reply: *Note Stop Reply Packets::, for the reply specifications. 29073 29074 `A ARGLEN,ARGNUM,ARG,...' 29075 Initialized `argv[]' array passed into program. ARGLEN specifies 29076 the number of bytes in the hex encoded byte stream ARG. See 29077 `gdbserver' for more details. 29078 29079 Reply: 29080 `OK' 29081 The arguments were set. 29082 29083 `E NN' 29084 An error occurred. 29085 29086 `b BAUD' 29087 (Don't use this packet; its behavior is not well-defined.) Change 29088 the serial line speed to BAUD. 29089 29090 JTC: _When does the transport layer state change? When it's 29091 received, or after the ACK is transmitted. In either case, there 29092 are problems if the command or the acknowledgment packet is 29093 dropped._ 29094 29095 Stan: _If people really wanted to add something like this, and get 29096 it working for the first time, they ought to modify ser-unix.c to 29097 send some kind of out-of-band message to a specially-setup stub 29098 and have the switch happen "in between" packets, so that from 29099 remote protocol's point of view, nothing actually happened._ 29100 29101 `B ADDR,MODE' 29102 Set (MODE is `S') or clear (MODE is `C') a breakpoint at ADDR. 29103 29104 Don't use this packet. Use the `Z' and `z' packets instead (*note 29105 insert breakpoint or watchpoint packet::). 29106 29107 `bc' 29108 Backward continue. Execute the target system in reverse. No 29109 parameter. *Note Reverse Execution::, for more information. 29110 29111 Reply: *Note Stop Reply Packets::, for the reply specifications. 29112 29113 `bs' 29114 Backward single step. Execute one instruction in reverse. No 29115 parameter. *Note Reverse Execution::, for more information. 29116 29117 Reply: *Note Stop Reply Packets::, for the reply specifications. 29118 29119 `c [ADDR]' 29120 Continue. ADDR is address to resume. If ADDR is omitted, resume 29121 at current address. 29122 29123 Reply: *Note Stop Reply Packets::, for the reply specifications. 29124 29125 `C SIG[;ADDR]' 29126 Continue with signal SIG (hex signal number). If `;ADDR' is 29127 omitted, resume at same address. 29128 29129 Reply: *Note Stop Reply Packets::, for the reply specifications. 29130 29131 `d' 29132 Toggle debug flag. 29133 29134 Don't use this packet; instead, define a general set packet (*note 29135 General Query Packets::). 29136 29137 `D' 29138 `D;PID' 29139 The first form of the packet is used to detach GDB from the remote 29140 system. It is sent to the remote target before GDB disconnects 29141 via the `detach' command. 29142 29143 The second form, including a process ID, is used when multiprocess 29144 protocol extensions are enabled (*note multiprocess extensions::), 29145 to detach only a specific process. The PID is specified as a 29146 big-endian hex string. 29147 29148 Reply: 29149 `OK' 29150 for success 29151 29152 `E NN' 29153 for an error 29154 29155 `F RC,EE,CF;XX' 29156 A reply from GDB to an `F' packet sent by the target. This is 29157 part of the File-I/O protocol extension. *Note File-I/O Remote 29158 Protocol Extension::, for the specification. 29159 29160 `g' 29161 Read general registers. 29162 29163 Reply: 29164 `XX...' 29165 Each byte of register data is described by two hex digits. 29166 The bytes with the register are transmitted in target byte 29167 order. The size of each register and their position within 29168 the `g' packet are determined by the GDB internal gdbarch 29169 functions `DEPRECATED_REGISTER_RAW_SIZE' and 29170 `gdbarch_register_name'. The specification of several 29171 standard `g' packets is specified below. 29172 29173 When reading registers from a trace frame (*note Using the 29174 Collected Data: Analyze Collected Data.), the stub may also 29175 return a string of literal `x''s in place of the register 29176 data digits, to indicate that the corresponding register has 29177 not been collected, thus its value is unavailable. For 29178 example, for an architecture with 4 registers of 4 bytes 29179 each, the following reply indicates to GDB that registers 0 29180 and 2 have not been collected, while registers 1 and 3 have 29181 been collected, and both have zero value: 29182 29183 -> `g' 29184 <- `xxxxxxxx00000000xxxxxxxx00000000' 29185 29186 `E NN' 29187 for an error. 29188 29189 `G XX...' 29190 Write general registers. *Note read registers packet::, for a 29191 description of the XX... data. 29192 29193 Reply: 29194 `OK' 29195 for success 29196 29197 `E NN' 29198 for an error 29199 29200 `H C THREAD-ID' 29201 Set thread for subsequent operations (`m', `M', `g', `G', et.al.). 29202 C depends on the operation to be performed: it should be `c' for 29203 step and continue operations, `g' for other operations. The 29204 thread designator THREAD-ID has the format and interpretation 29205 described in *note thread-id syntax::. 29206 29207 Reply: 29208 `OK' 29209 for success 29210 29211 `E NN' 29212 for an error 29213 29214 `i [ADDR[,NNN]]' 29215 Step the remote target by a single clock cycle. If `,NNN' is 29216 present, cycle step NNN cycles. If ADDR is present, cycle step 29217 starting at that address. 29218 29219 `I' 29220 Signal, then cycle step. *Note step with signal packet::. *Note 29221 cycle step packet::. 29222 29223 `k' 29224 Kill request. 29225 29226 FIXME: _There is no description of how to operate when a specific 29227 thread context has been selected (i.e. does 'k' kill only that 29228 thread?)_. 29229 29230 `m ADDR,LENGTH' 29231 Read LENGTH bytes of memory starting at address ADDR. Note that 29232 ADDR may not be aligned to any particular boundary. 29233 29234 The stub need not use any particular size or alignment when 29235 gathering data from memory for the response; even if ADDR is 29236 word-aligned and LENGTH is a multiple of the word size, the stub 29237 is free to use byte accesses, or not. For this reason, this 29238 packet may not be suitable for accessing memory-mapped I/O devices. 29239 29240 Reply: 29241 `XX...' 29242 Memory contents; each byte is transmitted as a two-digit 29243 hexadecimal number. The reply may contain fewer bytes than 29244 requested if the server was able to read only part of the 29245 region of memory. 29246 29247 `E NN' 29248 NN is errno 29249 29250 `M ADDR,LENGTH:XX...' 29251 Write LENGTH bytes of memory starting at address ADDR. XX... is 29252 the data; each byte is transmitted as a two-digit hexadecimal 29253 number. 29254 29255 Reply: 29256 `OK' 29257 for success 29258 29259 `E NN' 29260 for an error (this includes the case where only part of the 29261 data was written). 29262 29263 `p N' 29264 Read the value of register N; N is in hex. *Note read registers 29265 packet::, for a description of how the returned register value is 29266 encoded. 29267 29268 Reply: 29269 `XX...' 29270 the register's value 29271 29272 `E NN' 29273 for an error 29274 29275 `' 29276 Indicating an unrecognized QUERY. 29277 29278 `P N...=R...' 29279 Write register N... with value R.... The register number N is in 29280 hexadecimal, and R... contains two hex digits for each byte in the 29281 register (target byte order). 29282 29283 Reply: 29284 `OK' 29285 for success 29286 29287 `E NN' 29288 for an error 29289 29290 `q NAME PARAMS...' 29291 `Q NAME PARAMS...' 29292 General query (`q') and set (`Q'). These packets are described 29293 fully in *note General Query Packets::. 29294 29295 `r' 29296 Reset the entire system. 29297 29298 Don't use this packet; use the `R' packet instead. 29299 29300 `R XX' 29301 Restart the program being debugged. XX, while needed, is ignored. 29302 This packet is only available in extended mode (*note extended 29303 mode::). 29304 29305 The `R' packet has no reply. 29306 29307 `s [ADDR]' 29308 Single step. ADDR is the address at which to resume. If ADDR is 29309 omitted, resume at same address. 29310 29311 Reply: *Note Stop Reply Packets::, for the reply specifications. 29312 29313 `S SIG[;ADDR]' 29314 Step with signal. This is analogous to the `C' packet, but 29315 requests a single-step, rather than a normal resumption of 29316 execution. 29317 29318 Reply: *Note Stop Reply Packets::, for the reply specifications. 29319 29320 `t ADDR:PP,MM' 29321 Search backwards starting at address ADDR for a match with pattern 29322 PP and mask MM. PP and MM are 4 bytes. ADDR must be at least 3 29323 digits. 29324 29325 `T THREAD-ID' 29326 Find out if the thread THREAD-ID is alive. *Note thread-id 29327 syntax::. 29328 29329 Reply: 29330 `OK' 29331 thread is still alive 29332 29333 `E NN' 29334 thread is dead 29335 29336 `v' 29337 Packets starting with `v' are identified by a multi-letter name, 29338 up to the first `;' or `?' (or the end of the packet). 29339 29340 `vAttach;PID' 29341 Attach to a new process with the specified process ID PID. The 29342 process ID is a hexadecimal integer identifying the process. In 29343 all-stop mode, all threads in the attached process are stopped; in 29344 non-stop mode, it may be attached without being stopped if that is 29345 supported by the target. 29346 29347 This packet is only available in extended mode (*note extended 29348 mode::). 29349 29350 Reply: 29351 `E NN' 29352 for an error 29353 29354 `Any stop packet' 29355 for success in all-stop mode (*note Stop Reply Packets::) 29356 29357 `OK' 29358 for success in non-stop mode (*note Remote Non-Stop::) 29359 29360 `vCont[;ACTION[:THREAD-ID]]...' 29361 Resume the inferior, specifying different actions for each thread. 29362 If an action is specified with no THREAD-ID, then it is applied to 29363 any threads that don't have a specific action specified; if no 29364 default action is specified then other threads should remain 29365 stopped in all-stop mode and in their current state in non-stop 29366 mode. Specifying multiple default actions is an error; specifying 29367 no actions is also an error. Thread IDs are specified using the 29368 syntax described in *note thread-id syntax::. 29369 29370 Currently supported actions are: 29371 29372 `c' 29373 Continue. 29374 29375 `C SIG' 29376 Continue with signal SIG. The signal SIG should be two hex 29377 digits. 29378 29379 `s' 29380 Step. 29381 29382 `S SIG' 29383 Step with signal SIG. The signal SIG should be two hex 29384 digits. 29385 29386 `t' 29387 Stop. 29388 29389 The optional argument ADDR normally associated with the `c', `C', 29390 `s', and `S' packets is not supported in `vCont'. 29391 29392 The `t' action is only relevant in non-stop mode (*note Remote 29393 Non-Stop::) and may be ignored by the stub otherwise. A stop 29394 reply should be generated for any affected thread not already 29395 stopped. When a thread is stopped by means of a `t' action, the 29396 corresponding stop reply should indicate that the thread has 29397 stopped with signal `0', regardless of whether the target uses 29398 some other signal as an implementation detail. 29399 29400 Reply: *Note Stop Reply Packets::, for the reply specifications. 29401 29402 `vCont?' 29403 Request a list of actions supported by the `vCont' packet. 29404 29405 Reply: 29406 `vCont[;ACTION...]' 29407 The `vCont' packet is supported. Each ACTION is a supported 29408 command in the `vCont' packet. 29409 29410 `' 29411 The `vCont' packet is not supported. 29412 29413 `vFile:OPERATION:PARAMETER...' 29414 Perform a file operation on the target system. For details, see 29415 *note Host I/O Packets::. 29416 29417 `vFlashErase:ADDR,LENGTH' 29418 Direct the stub to erase LENGTH bytes of flash starting at ADDR. 29419 The region may enclose any number of flash blocks, but its start 29420 and end must fall on block boundaries, as indicated by the flash 29421 block size appearing in the memory map (*note Memory Map 29422 Format::). GDB groups flash memory programming operations 29423 together, and sends a `vFlashDone' request after each group; the 29424 stub is allowed to delay erase operation until the `vFlashDone' 29425 packet is received. 29426 29427 The stub must support `vCont' if it reports support for 29428 multiprocess extensions (*note multiprocess extensions::). Note 29429 that in this case `vCont' actions can be specified to apply to all 29430 threads in a process by using the `pPID.-1' form of the THREAD-ID. 29431 29432 Reply: 29433 `OK' 29434 for success 29435 29436 `E NN' 29437 for an error 29438 29439 `vFlashWrite:ADDR:XX...' 29440 Direct the stub to write data to flash address ADDR. The data is 29441 passed in binary form using the same encoding as for the `X' 29442 packet (*note Binary Data::). The memory ranges specified by 29443 `vFlashWrite' packets preceding a `vFlashDone' packet must not 29444 overlap, and must appear in order of increasing addresses 29445 (although `vFlashErase' packets for higher addresses may already 29446 have been received; the ordering is guaranteed only between 29447 `vFlashWrite' packets). If a packet writes to an address that was 29448 neither erased by a preceding `vFlashErase' packet nor by some 29449 other target-specific method, the results are unpredictable. 29450 29451 Reply: 29452 `OK' 29453 for success 29454 29455 `E.memtype' 29456 for vFlashWrite addressing non-flash memory 29457 29458 `E NN' 29459 for an error 29460 29461 `vFlashDone' 29462 Indicate to the stub that flash programming operation is finished. 29463 The stub is permitted to delay or batch the effects of a group of 29464 `vFlashErase' and `vFlashWrite' packets until a `vFlashDone' 29465 packet is received. The contents of the affected regions of flash 29466 memory are unpredictable until the `vFlashDone' request is 29467 completed. 29468 29469 `vKill;PID' 29470 Kill the process with the specified process ID. PID is a 29471 hexadecimal integer identifying the process. This packet is used 29472 in preference to `k' when multiprocess protocol extensions are 29473 supported; see *note multiprocess extensions::. 29474 29475 Reply: 29476 `E NN' 29477 for an error 29478 29479 `OK' 29480 for success 29481 29482 `vRun;FILENAME[;ARGUMENT]...' 29483 Run the program FILENAME, passing it each ARGUMENT on its command 29484 line. The file and arguments are hex-encoded strings. If 29485 FILENAME is an empty string, the stub may use a default program 29486 (e.g. the last program run). The program is created in the stopped 29487 state. 29488 29489 This packet is only available in extended mode (*note extended 29490 mode::). 29491 29492 Reply: 29493 `E NN' 29494 for an error 29495 29496 `Any stop packet' 29497 for success (*note Stop Reply Packets::) 29498 29499 `vStopped' 29500 In non-stop mode (*note Remote Non-Stop::), acknowledge a previous 29501 stop reply and prompt for the stub to report another one. 29502 29503 Reply: 29504 `Any stop packet' 29505 if there is another unreported stop event (*note Stop Reply 29506 Packets::) 29507 29508 `OK' 29509 if there are no unreported stop events 29510 29511 `X ADDR,LENGTH:XX...' 29512 Write data to memory, where the data is transmitted in binary. 29513 ADDR is address, LENGTH is number of bytes, `XX...' is binary data 29514 (*note Binary Data::). 29515 29516 Reply: 29517 `OK' 29518 for success 29519 29520 `E NN' 29521 for an error 29522 29523 `z TYPE,ADDR,KIND' 29524 `Z TYPE,ADDR,KIND' 29525 Insert (`Z') or remove (`z') a TYPE breakpoint or watchpoint 29526 starting at address ADDRESS of kind KIND. 29527 29528 Each breakpoint and watchpoint packet TYPE is documented 29529 separately. 29530 29531 _Implementation notes: A remote target shall return an empty string 29532 for an unrecognized breakpoint or watchpoint packet TYPE. A 29533 remote target shall support either both or neither of a given 29534 `ZTYPE...' and `zTYPE...' packet pair. To avoid potential 29535 problems with duplicate packets, the operations should be 29536 implemented in an idempotent way._ 29537 29538 `z0,ADDR,KIND' 29539 `Z0,ADDR,KIND' 29540 Insert (`Z0') or remove (`z0') a memory breakpoint at address ADDR 29541 of type KIND. 29542 29543 A memory breakpoint is implemented by replacing the instruction at 29544 ADDR with a software breakpoint or trap instruction. The KIND is 29545 target-specific and typically indicates the size of the breakpoint 29546 in bytes that should be inserted. E.g., the ARM and MIPS can 29547 insert either a 2 or 4 byte breakpoint. Some architectures have 29548 additional meanings for KIND; see *note Architecture-Specific 29549 Protocol Details::. 29550 29551 _Implementation note: It is possible for a target to copy or move 29552 code that contains memory breakpoints (e.g., when implementing 29553 overlays). The behavior of this packet, in the presence of such a 29554 target, is not defined._ 29555 29556 Reply: 29557 `OK' 29558 success 29559 29560 `' 29561 not supported 29562 29563 `E NN' 29564 for an error 29565 29566 `z1,ADDR,KIND' 29567 `Z1,ADDR,KIND' 29568 Insert (`Z1') or remove (`z1') a hardware breakpoint at address 29569 ADDR. 29570 29571 A hardware breakpoint is implemented using a mechanism that is not 29572 dependant on being able to modify the target's memory. KIND has 29573 the same meaning as in `Z0' packets. 29574 29575 _Implementation note: A hardware breakpoint is not affected by code 29576 movement._ 29577 29578 Reply: 29579 `OK' 29580 success 29581 29582 `' 29583 not supported 29584 29585 `E NN' 29586 for an error 29587 29588 `z2,ADDR,KIND' 29589 `Z2,ADDR,KIND' 29590 Insert (`Z2') or remove (`z2') a write watchpoint at ADDR. KIND 29591 is interpreted as the number of bytes to watch. 29592 29593 Reply: 29594 `OK' 29595 success 29596 29597 `' 29598 not supported 29599 29600 `E NN' 29601 for an error 29602 29603 `z3,ADDR,KIND' 29604 `Z3,ADDR,KIND' 29605 Insert (`Z3') or remove (`z3') a read watchpoint at ADDR. KIND is 29606 interpreted as the number of bytes to watch. 29607 29608 Reply: 29609 `OK' 29610 success 29611 29612 `' 29613 not supported 29614 29615 `E NN' 29616 for an error 29617 29618 `z4,ADDR,KIND' 29619 `Z4,ADDR,KIND' 29620 Insert (`Z4') or remove (`z4') an access watchpoint at ADDR. KIND 29621 is interpreted as the number of bytes to watch. 29622 29623 Reply: 29624 `OK' 29625 success 29626 29627 `' 29628 not supported 29629 29630 `E NN' 29631 for an error 29632 29633 29634 29635 File: gdb.info, Node: Stop Reply Packets, Next: General Query Packets, Prev: Packets, Up: Remote Protocol 29636 29637 E.3 Stop Reply Packets 29638 ====================== 29639 29640 The `C', `c', `S', `s', `vCont', `vAttach', `vRun', `vStopped', and `?' 29641 packets can receive any of the below as a reply. Except for `?' and 29642 `vStopped', that reply is only returned when the target halts. In the 29643 below the exact meaning of "signal number" is defined by the header 29644 `include/gdb/signals.h' in the GDB source code. 29645 29646 As in the description of request packets, we include spaces in the 29647 reply templates for clarity; these are not part of the reply packet's 29648 syntax. No GDB stop reply packet uses spaces to separate its 29649 components. 29650 29651 `S AA' 29652 The program received signal number AA (a two-digit hexadecimal 29653 number). This is equivalent to a `T' response with no N:R pairs. 29654 29655 `T AA N1:R1;N2:R2;...' 29656 The program received signal number AA (a two-digit hexadecimal 29657 number). This is equivalent to an `S' response, except that the 29658 `N:R' pairs can carry values of important registers and other 29659 information directly in the stop reply packet, reducing round-trip 29660 latency. Single-step and breakpoint traps are reported this way. 29661 Each `N:R' pair is interpreted as follows: 29662 29663 * If N is a hexadecimal number, it is a register number, and the 29664 corresponding R gives that register's value. R is a series 29665 of bytes in target byte order, with each byte given by a 29666 two-digit hex number. 29667 29668 * If N is `thread', then R is the THREAD-ID of the stopped 29669 thread, as specified in *note thread-id syntax::. 29670 29671 * If N is `core', then R is the hexadecimal number of the core 29672 on which the stop event was detected. 29673 29674 * If N is a recognized "stop reason", it describes a more 29675 specific event that stopped the target. The currently 29676 defined stop reasons are listed below. AA should be `05', 29677 the trap signal. At most one stop reason should be present. 29678 29679 * Otherwise, GDB should ignore this `N:R' pair and go on to the 29680 next; this allows us to extend the protocol in the future. 29681 29682 The currently defined stop reasons are: 29683 29684 `watch' 29685 `rwatch' 29686 `awatch' 29687 The packet indicates a watchpoint hit, and R is the data 29688 address, in hex. 29689 29690 `library' 29691 The packet indicates that the loaded libraries have changed. 29692 GDB should use `qXfer:libraries:read' to fetch a new list of 29693 loaded libraries. R is ignored. 29694 29695 `replaylog' 29696 The packet indicates that the target cannot continue replaying 29697 logged execution events, because it has reached the end (or 29698 the beginning when executing backward) of the log. The value 29699 of R will be either `begin' or `end'. *Note Reverse 29700 Execution::, for more information. 29701 29702 `W AA' 29703 `W AA ; process:PID' 29704 The process exited, and AA is the exit status. This is only 29705 applicable to certain targets. 29706 29707 The second form of the response, including the process ID of the 29708 exited process, can be used only when GDB has reported support for 29709 multiprocess protocol extensions; see *note multiprocess 29710 extensions::. The PID is formatted as a big-endian hex string. 29711 29712 `X AA' 29713 `X AA ; process:PID' 29714 The process terminated with signal AA. 29715 29716 The second form of the response, including the process ID of the 29717 terminated process, can be used only when GDB has reported support 29718 for multiprocess protocol extensions; see *note multiprocess 29719 extensions::. The PID is formatted as a big-endian hex string. 29720 29721 `O XX...' 29722 `XX...' is hex encoding of ASCII data, to be written as the 29723 program's console output. This can happen at any time while the 29724 program is running and the debugger should continue to wait for 29725 `W', `T', etc. This reply is not permitted in non-stop mode. 29726 29727 `F CALL-ID,PARAMETER...' 29728 CALL-ID is the identifier which says which host system call should 29729 be called. This is just the name of the function. Translation 29730 into the correct system call is only applicable as it's defined in 29731 GDB. *Note File-I/O Remote Protocol Extension::, for a list of 29732 implemented system calls. 29733 29734 `PARAMETER...' is a list of parameters as defined for this very 29735 system call. 29736 29737 The target replies with this packet when it expects GDB to call a 29738 host system call on behalf of the target. GDB replies with an 29739 appropriate `F' packet and keeps up waiting for the next reply 29740 packet from the target. The latest `C', `c', `S' or `s' action is 29741 expected to be continued. *Note File-I/O Remote Protocol 29742 Extension::, for more details. 29743 29744 29745 29746 File: gdb.info, Node: General Query Packets, Next: Architecture-Specific Protocol Details, Prev: Stop Reply Packets, Up: Remote Protocol 29747 29748 E.4 General Query Packets 29749 ========================= 29750 29751 Packets starting with `q' are "general query packets"; packets starting 29752 with `Q' are "general set packets". General query and set packets are 29753 a semi-unified form for retrieving and sending information to and from 29754 the stub. 29755 29756 The initial letter of a query or set packet is followed by a name 29757 indicating what sort of thing the packet applies to. For example, GDB 29758 may use a `qSymbol' packet to exchange symbol definitions with the 29759 stub. These packet names follow some conventions: 29760 29761 * The name must not contain commas, colons or semicolons. 29762 29763 * Most GDB query and set packets have a leading upper case letter. 29764 29765 * The names of custom vendor packets should use a company prefix, in 29766 lower case, followed by a period. For example, packets designed at 29767 the Acme Corporation might begin with `qacme.foo' (for querying 29768 foos) or `Qacme.bar' (for setting bars). 29769 29770 The name of a query or set packet should be separated from any 29771 parameters by a `:'; the parameters themselves should be separated by 29772 `,' or `;'. Stubs must be careful to match the full packet name, and 29773 check for a separator or the end of the packet, in case two packet 29774 names share a common prefix. New packets should not begin with `qC', 29775 `qP', or `qL'(1). 29776 29777 Like the descriptions of the other packets, each description here 29778 has a template showing the packet's overall syntax, followed by an 29779 explanation of the packet's meaning. We include spaces in some of the 29780 templates for clarity; these are not part of the packet's syntax. No 29781 GDB packet uses spaces to separate its components. 29782 29783 Here are the currently defined query and set packets: 29784 29785 `QAllow:OP:VAL...' 29786 Specify which operations GDB expects to request of the target, as 29787 a semicolon-separated list of operation name and value pairs. 29788 Possible values for OP include `WriteReg', `WriteMem', 29789 `InsertBreak', `InsertTrace', `InsertFastTrace', and `Stop'. VAL 29790 is either 0, indicating that GDB will not request the operation, 29791 or 1, indicating that it may. (The target can then use this to 29792 set up its own internals optimally, for instance if the debugger 29793 never expects to insert breakpoints, it may not need to install 29794 its own trap handler.) 29795 29796 `qC' 29797 Return the current thread ID. 29798 29799 Reply: 29800 `QC THREAD-ID' 29801 Where THREAD-ID is a thread ID as documented in *note 29802 thread-id syntax::. 29803 29804 `(anything else)' 29805 Any other reply implies the old thread ID. 29806 29807 `qCRC:ADDR,LENGTH' 29808 Compute the CRC checksum of a block of memory using CRC-32 defined 29809 in IEEE 802.3. The CRC is computed byte at a time, taking the most 29810 significant bit of each byte first. The initial pattern code 29811 `0xffffffff' is used to ensure leading zeros affect the CRC. 29812 29813 _Note:_ This is the same CRC used in validating separate debug 29814 files (*note Debugging Information in Separate Files: Separate 29815 Debug Files.). However the algorithm is slightly different. When 29816 validating separate debug files, the CRC is computed taking the 29817 _least_ significant bit of each byte first, and the final result 29818 is inverted to detect trailing zeros. 29819 29820 Reply: 29821 `E NN' 29822 An error (such as memory fault) 29823 29824 `C CRC32' 29825 The specified memory region's checksum is CRC32. 29826 29827 `qfThreadInfo' 29828 `qsThreadInfo' 29829 Obtain a list of all active thread IDs from the target (OS). 29830 Since there may be too many active threads to fit into one reply 29831 packet, this query works iteratively: it may require more than one 29832 query/reply sequence to obtain the entire list of threads. The 29833 first query of the sequence will be the `qfThreadInfo' query; 29834 subsequent queries in the sequence will be the `qsThreadInfo' 29835 query. 29836 29837 NOTE: This packet replaces the `qL' query (see below). 29838 29839 Reply: 29840 `m THREAD-ID' 29841 A single thread ID 29842 29843 `m THREAD-ID,THREAD-ID...' 29844 a comma-separated list of thread IDs 29845 29846 `l' 29847 (lower case letter `L') denotes end of list. 29848 29849 In response to each query, the target will reply with a list of 29850 one or more thread IDs, separated by commas. GDB will respond to 29851 each reply with a request for more thread ids (using the `qs' form 29852 of the query), until the target responds with `l' (lower-case ell, 29853 for "last"). Refer to *note thread-id syntax::, for the format of 29854 the THREAD-ID fields. 29855 29856 `qGetTLSAddr:THREAD-ID,OFFSET,LM' 29857 Fetch the address associated with thread local storage specified 29858 by THREAD-ID, OFFSET, and LM. 29859 29860 THREAD-ID is the thread ID associated with the thread for which to 29861 fetch the TLS address. *Note thread-id syntax::. 29862 29863 OFFSET is the (big endian, hex encoded) offset associated with the 29864 thread local variable. (This offset is obtained from the debug 29865 information associated with the variable.) 29866 29867 LM is the (big endian, hex encoded) OS/ABI-specific encoding of the 29868 the load module associated with the thread local storage. For 29869 example, a GNU/Linux system will pass the link map address of the 29870 shared object associated with the thread local storage under 29871 consideration. Other operating environments may choose to 29872 represent the load module differently, so the precise meaning of 29873 this parameter will vary. 29874 29875 Reply: 29876 `XX...' 29877 Hex encoded (big endian) bytes representing the address of 29878 the thread local storage requested. 29879 29880 `E NN' 29881 An error occurred. NN are hex digits. 29882 29883 `' 29884 An empty reply indicates that `qGetTLSAddr' is not supported 29885 by the stub. 29886 29887 `qGetTIBAddr:THREAD-ID' 29888 Fetch address of the Windows OS specific Thread Information Block. 29889 29890 THREAD-ID is the thread ID associated with the thread. 29891 29892 Reply: 29893 `XX...' 29894 Hex encoded (big endian) bytes representing the linear 29895 address of the thread information block. 29896 29897 `E NN' 29898 An error occured. This means that either the thread was not 29899 found, or the address could not be retrieved. 29900 29901 `' 29902 An empty reply indicates that `qGetTIBAddr' is not supported 29903 by the stub. 29904 29905 `qL STARTFLAG THREADCOUNT NEXTTHREAD' 29906 Obtain thread information from RTOS. Where: STARTFLAG (one hex 29907 digit) is one to indicate the first query and zero to indicate a 29908 subsequent query; THREADCOUNT (two hex digits) is the maximum 29909 number of threads the response packet can contain; and NEXTTHREAD 29910 (eight hex digits), for subsequent queries (STARTFLAG is zero), is 29911 returned in the response as ARGTHREAD. 29912 29913 Don't use this packet; use the `qfThreadInfo' query instead (see 29914 above). 29915 29916 Reply: 29917 `qM COUNT DONE ARGTHREAD THREAD...' 29918 Where: COUNT (two hex digits) is the number of threads being 29919 returned; DONE (one hex digit) is zero to indicate more 29920 threads and one indicates no further threads; ARGTHREADID 29921 (eight hex digits) is NEXTTHREAD from the request packet; 29922 THREAD... is a sequence of thread IDs from the target. 29923 THREADID (eight hex digits). See 29924 `remote.c:parse_threadlist_response()'. 29925 29926 `qOffsets' 29927 Get section offsets that the target used when relocating the 29928 downloaded image. 29929 29930 Reply: 29931 `Text=XXX;Data=YYY[;Bss=ZZZ]' 29932 Relocate the `Text' section by XXX from its original address. 29933 Relocate the `Data' section by YYY from its original address. 29934 If the object file format provides segment information (e.g. 29935 ELF `PT_LOAD' program headers), GDB will relocate entire 29936 segments by the supplied offsets. 29937 29938 _Note: while a `Bss' offset may be included in the response, 29939 GDB ignores this and instead applies the `Data' offset to the 29940 `Bss' section._ 29941 29942 `TextSeg=XXX[;DataSeg=YYY]' 29943 Relocate the first segment of the object file, which 29944 conventionally contains program code, to a starting address 29945 of XXX. If `DataSeg' is specified, relocate the second 29946 segment, which conventionally contains modifiable data, to a 29947 starting address of YYY. GDB will report an error if the 29948 object file does not contain segment information, or does not 29949 contain at least as many segments as mentioned in the reply. 29950 Extra segments are kept at fixed offsets relative to the last 29951 relocated segment. 29952 29953 `qP MODE THREAD-ID' 29954 Returns information on THREAD-ID. Where: MODE is a hex encoded 32 29955 bit mode; THREAD-ID is a thread ID (*note thread-id syntax::). 29956 29957 Don't use this packet; use the `qThreadExtraInfo' query instead 29958 (see below). 29959 29960 Reply: see `remote.c:remote_unpack_thread_info_response()'. 29961 29962 `QNonStop:1' 29963 29964 `QNonStop:0' 29965 Enter non-stop (`QNonStop:1') or all-stop (`QNonStop:0') mode. 29966 *Note Remote Non-Stop::, for more information. 29967 29968 Reply: 29969 `OK' 29970 The request succeeded. 29971 29972 `E NN' 29973 An error occurred. NN are hex digits. 29974 29975 `' 29976 An empty reply indicates that `QNonStop' is not supported by 29977 the stub. 29978 29979 This packet is not probed by default; the remote stub must request 29980 it, by supplying an appropriate `qSupported' response (*note 29981 qSupported::). Use of this packet is controlled by the `set 29982 non-stop' command; *note Non-Stop Mode::. 29983 29984 `QPassSignals: SIGNAL [;SIGNAL]...' 29985 Each listed SIGNAL should be passed directly to the inferior 29986 process. Signals are numbered identically to continue packets and 29987 stop replies (*note Stop Reply Packets::). Each SIGNAL list item 29988 should be strictly greater than the previous item. These signals 29989 do not need to stop the inferior, or be reported to GDB. All 29990 other signals should be reported to GDB. Multiple `QPassSignals' 29991 packets do not combine; any earlier `QPassSignals' list is 29992 completely replaced by the new list. This packet improves 29993 performance when using `handle SIGNAL nostop noprint pass'. 29994 29995 Reply: 29996 `OK' 29997 The request succeeded. 29998 29999 `E NN' 30000 An error occurred. NN are hex digits. 30001 30002 `' 30003 An empty reply indicates that `QPassSignals' is not supported 30004 by the stub. 30005 30006 Use of this packet is controlled by the `set remote pass-signals' 30007 command (*note set remote pass-signals: Remote Configuration.). 30008 This packet is not probed by default; the remote stub must request 30009 it, by supplying an appropriate `qSupported' response (*note 30010 qSupported::). 30011 30012 `qRcmd,COMMAND' 30013 COMMAND (hex encoded) is passed to the local interpreter for 30014 execution. Invalid commands should be reported using the output 30015 string. Before the final result packet, the target may also 30016 respond with a number of intermediate `OOUTPUT' console output 30017 packets. _Implementors should note that providing access to a 30018 stubs's interpreter may have security implications_. 30019 30020 Reply: 30021 `OK' 30022 A command response with no output. 30023 30024 `OUTPUT' 30025 A command response with the hex encoded output string OUTPUT. 30026 30027 `E NN' 30028 Indicate a badly formed request. 30029 30030 `' 30031 An empty reply indicates that `qRcmd' is not recognized. 30032 30033 (Note that the `qRcmd' packet's name is separated from the command 30034 by a `,', not a `:', contrary to the naming conventions above. 30035 Please don't use this packet as a model for new packets.) 30036 30037 `qSearch:memory:ADDRESS;LENGTH;SEARCH-PATTERN' 30038 Search LENGTH bytes at ADDRESS for SEARCH-PATTERN. ADDRESS and 30039 LENGTH are encoded in hex. SEARCH-PATTERN is a sequence of bytes, 30040 hex encoded. 30041 30042 Reply: 30043 `0' 30044 The pattern was not found. 30045 30046 `1,address' 30047 The pattern was found at ADDRESS. 30048 30049 `E NN' 30050 A badly formed request or an error was encountered while 30051 searching memory. 30052 30053 `' 30054 An empty reply indicates that `qSearch:memory' is not 30055 recognized. 30056 30057 `QStartNoAckMode' 30058 Request that the remote stub disable the normal `+'/`-' protocol 30059 acknowledgments (*note Packet Acknowledgment::). 30060 30061 Reply: 30062 `OK' 30063 The stub has switched to no-acknowledgment mode. GDB 30064 acknowledges this reponse, but neither the stub nor GDB shall 30065 send or expect further `+'/`-' acknowledgments in the current 30066 connection. 30067 30068 `' 30069 An empty reply indicates that the stub does not support 30070 no-acknowledgment mode. 30071 30072 `qSupported [:GDBFEATURE [;GDBFEATURE]... ]' 30073 Tell the remote stub about features supported by GDB, and query 30074 the stub for features it supports. This packet allows GDB and the 30075 remote stub to take advantage of each others' features. 30076 `qSupported' also consolidates multiple feature probes at startup, 30077 to improve GDB performance--a single larger packet performs better 30078 than multiple smaller probe packets on high-latency links. Some 30079 features may enable behavior which must not be on by default, e.g. 30080 because it would confuse older clients or stubs. Other features 30081 may describe packets which could be automatically probed for, but 30082 are not. These features must be reported before GDB will use 30083 them. This "default unsupported" behavior is not appropriate for 30084 all packets, but it helps to keep the initial connection time 30085 under control with new versions of GDB which support increasing 30086 numbers of packets. 30087 30088 Reply: 30089 `STUBFEATURE [;STUBFEATURE]...' 30090 The stub supports or does not support each returned 30091 STUBFEATURE, depending on the form of each STUBFEATURE (see 30092 below for the possible forms). 30093 30094 `' 30095 An empty reply indicates that `qSupported' is not recognized, 30096 or that no features needed to be reported to GDB. 30097 30098 The allowed forms for each feature (either a GDBFEATURE in the 30099 `qSupported' packet, or a STUBFEATURE in the response) are: 30100 30101 `NAME=VALUE' 30102 The remote protocol feature NAME is supported, and associated 30103 with the specified VALUE. The format of VALUE depends on the 30104 feature, but it must not include a semicolon. 30105 30106 `NAME+' 30107 The remote protocol feature NAME is supported, and does not 30108 need an associated value. 30109 30110 `NAME-' 30111 The remote protocol feature NAME is not supported. 30112 30113 `NAME?' 30114 The remote protocol feature NAME may be supported, and GDB 30115 should auto-detect support in some other way when it is 30116 needed. This form will not be used for GDBFEATURE 30117 notifications, but may be used for STUBFEATURE responses. 30118 30119 Whenever the stub receives a `qSupported' request, the supplied 30120 set of GDB features should override any previous request. This 30121 allows GDB to put the stub in a known state, even if the stub had 30122 previously been communicating with a different version of GDB. 30123 30124 The following values of GDBFEATURE (for the packet sent by GDB) 30125 are defined: 30126 30127 `multiprocess' 30128 This feature indicates whether GDB supports multiprocess 30129 extensions to the remote protocol. GDB does not use such 30130 extensions unless the stub also reports that it supports them 30131 by including `multiprocess+' in its `qSupported' reply. 30132 *Note multiprocess extensions::, for details. 30133 30134 `xmlRegisters' 30135 This feature indicates that GDB supports the XML target 30136 description. If the stub sees `xmlRegisters=' with target 30137 specific strings separated by a comma, it will report register 30138 description. 30139 30140 `qRelocInsn' 30141 This feature indicates whether GDB supports the `qRelocInsn' 30142 packet (*note Relocate instruction reply packet: Tracepoint 30143 Packets.). 30144 30145 Stubs should ignore any unknown values for GDBFEATURE. Any GDB 30146 which sends a `qSupported' packet supports receiving packets of 30147 unlimited length (earlier versions of GDB may reject overly long 30148 responses). Additional values for GDBFEATURE may be defined in 30149 the future to let the stub take advantage of new features in GDB, 30150 e.g. incompatible improvements in the remote protocol--the 30151 `multiprocess' feature is an example of such a feature. The 30152 stub's reply should be independent of the GDBFEATURE entries sent 30153 by GDB; first GDB describes all the features it supports, and then 30154 the stub replies with all the features it supports. 30155 30156 Similarly, GDB will silently ignore unrecognized stub feature 30157 responses, as long as each response uses one of the standard forms. 30158 30159 Some features are flags. A stub which supports a flag feature 30160 should respond with a `+' form response. Other features require 30161 values, and the stub should respond with an `=' form response. 30162 30163 Each feature has a default value, which GDB will use if 30164 `qSupported' is not available or if the feature is not mentioned 30165 in the `qSupported' response. The default values are fixed; a 30166 stub is free to omit any feature responses that match the defaults. 30167 30168 Not all features can be probed, but for those which can, the 30169 probing mechanism is useful: in some cases, a stub's internal 30170 architecture may not allow the protocol layer to know some 30171 information about the underlying target in advance. This is 30172 especially common in stubs which may be configured for multiple 30173 targets. 30174 30175 These are the currently defined stub features and their properties: 30176 30177 Feature Name Value Default Probe Allowed 30178 Required 30179 `PacketSize' Yes `-' No 30180 `qXfer:auxv:read' No `-' Yes 30181 `qXfer:features:read' No `-' Yes 30182 `qXfer:libraries:read' No `-' Yes 30183 `qXfer:memory-map:read' No `-' Yes 30184 `qXfer:sdata:read' No `-' Yes 30185 `qXfer:spu:read' No `-' Yes 30186 `qXfer:spu:write' No `-' Yes 30187 `qXfer:siginfo:read' No `-' Yes 30188 `qXfer:siginfo:write' No `-' Yes 30189 `qXfer:threads:read' No `-' Yes 30190 `qXfer:traceframe-info:read'No `-' Yes 30191 `QNonStop' No `-' Yes 30192 `QPassSignals' No `-' Yes 30193 `QStartNoAckMode' No `-' Yes 30194 `multiprocess' No `-' No 30195 `ConditionalTracepoints'No `-' No 30196 `ReverseContinue' No `-' No 30197 `ReverseStep' No `-' No 30198 `TracepointSource' No `-' No 30199 `QAllow' No `-' No 30200 30201 These are the currently defined stub features, in more detail: 30202 30203 `PacketSize=BYTES' 30204 The remote stub can accept packets up to at least BYTES in 30205 length. GDB will send packets up to this size for bulk 30206 transfers, and will never send larger packets. This is a 30207 limit on the data characters in the packet, including the 30208 frame and checksum. There is no trailing NUL byte in a 30209 remote protocol packet; if the stub stores packets in a 30210 NUL-terminated format, it should allow an extra byte in its 30211 buffer for the NUL. If this stub feature is not supported, 30212 GDB guesses based on the size of the `g' packet response. 30213 30214 `qXfer:auxv:read' 30215 The remote stub understands the `qXfer:auxv:read' packet 30216 (*note qXfer auxiliary vector read::). 30217 30218 `qXfer:features:read' 30219 The remote stub understands the `qXfer:features:read' packet 30220 (*note qXfer target description read::). 30221 30222 `qXfer:libraries:read' 30223 The remote stub understands the `qXfer:libraries:read' packet 30224 (*note qXfer library list read::). 30225 30226 `qXfer:memory-map:read' 30227 The remote stub understands the `qXfer:memory-map:read' packet 30228 (*note qXfer memory map read::). 30229 30230 `qXfer:sdata:read' 30231 The remote stub understands the `qXfer:sdata:read' packet 30232 (*note qXfer sdata read::). 30233 30234 `qXfer:spu:read' 30235 The remote stub understands the `qXfer:spu:read' packet 30236 (*note qXfer spu read::). 30237 30238 `qXfer:spu:write' 30239 The remote stub understands the `qXfer:spu:write' packet 30240 (*note qXfer spu write::). 30241 30242 `qXfer:siginfo:read' 30243 The remote stub understands the `qXfer:siginfo:read' packet 30244 (*note qXfer siginfo read::). 30245 30246 `qXfer:siginfo:write' 30247 The remote stub understands the `qXfer:siginfo:write' packet 30248 (*note qXfer siginfo write::). 30249 30250 `qXfer:threads:read' 30251 The remote stub understands the `qXfer:threads:read' packet 30252 (*note qXfer threads read::). 30253 30254 `qXfer:traceframe-info:read' 30255 The remote stub understands the `qXfer:traceframe-info:read' 30256 packet (*note qXfer traceframe info read::). 30257 30258 `QNonStop' 30259 The remote stub understands the `QNonStop' packet (*note 30260 QNonStop::). 30261 30262 `QPassSignals' 30263 The remote stub understands the `QPassSignals' packet (*note 30264 QPassSignals::). 30265 30266 `QStartNoAckMode' 30267 The remote stub understands the `QStartNoAckMode' packet and 30268 prefers to operate in no-acknowledgment mode. *Note Packet 30269 Acknowledgment::. 30270 30271 `multiprocess' 30272 The remote stub understands the multiprocess extensions to 30273 the remote protocol syntax. The multiprocess extensions 30274 affect the syntax of thread IDs in both packets and replies 30275 (*note thread-id syntax::), and add process IDs to the `D' 30276 packet and `W' and `X' replies. Note that reporting this 30277 feature indicates support for the syntactic extensions only, 30278 not that the stub necessarily supports debugging of more than 30279 one process at a time. The stub must not use multiprocess 30280 extensions in packet replies unless GDB has also indicated it 30281 supports them in its `qSupported' request. 30282 30283 `qXfer:osdata:read' 30284 The remote stub understands the `qXfer:osdata:read' packet 30285 ((*note qXfer osdata read::). 30286 30287 `ConditionalTracepoints' 30288 The remote stub accepts and implements conditional 30289 expressions defined for tracepoints (*note Tracepoint 30290 Conditions::). 30291 30292 `ReverseContinue' 30293 The remote stub accepts and implements the reverse continue 30294 packet (*note bc::). 30295 30296 `ReverseStep' 30297 The remote stub accepts and implements the reverse step packet 30298 (*note bs::). 30299 30300 `TracepointSource' 30301 The remote stub understands the `QTDPsrc' packet that supplies 30302 the source form of tracepoint definitions. 30303 30304 `QAllow' 30305 The remote stub understands the `QAllow' packet. 30306 30307 `StaticTracepoint' 30308 The remote stub supports static tracepoints. 30309 30310 30311 `qSymbol::' 30312 Notify the target that GDB is prepared to serve symbol lookup 30313 requests. Accept requests from the target for the values of 30314 symbols. 30315 30316 Reply: 30317 `OK' 30318 The target does not need to look up any (more) symbols. 30319 30320 `qSymbol:SYM_NAME' 30321 The target requests the value of symbol SYM_NAME (hex 30322 encoded). GDB may provide the value by using the 30323 `qSymbol:SYM_VALUE:SYM_NAME' message, described below. 30324 30325 `qSymbol:SYM_VALUE:SYM_NAME' 30326 Set the value of SYM_NAME to SYM_VALUE. 30327 30328 SYM_NAME (hex encoded) is the name of a symbol whose value the 30329 target has previously requested. 30330 30331 SYM_VALUE (hex) is the value for symbol SYM_NAME. If GDB cannot 30332 supply a value for SYM_NAME, then this field will be empty. 30333 30334 Reply: 30335 `OK' 30336 The target does not need to look up any (more) symbols. 30337 30338 `qSymbol:SYM_NAME' 30339 The target requests the value of a new symbol SYM_NAME (hex 30340 encoded). GDB will continue to supply the values of symbols 30341 (if available), until the target ceases to request them. 30342 30343 `qTBuffer' 30344 30345 `QTBuffer' 30346 30347 `QTDisconnected' 30348 `QTDP' 30349 `QTDPsrc' 30350 `QTDV' 30351 `qTfP' 30352 `qTfV' 30353 `QTFrame' 30354 *Note Tracepoint Packets::. 30355 30356 `qThreadExtraInfo,THREAD-ID' 30357 Obtain a printable string description of a thread's attributes from 30358 the target OS. THREAD-ID is a thread ID; see *note thread-id 30359 syntax::. This string may contain anything that the target OS 30360 thinks is interesting for GDB to tell the user about the thread. 30361 The string is displayed in GDB's `info threads' display. Some 30362 examples of possible thread extra info strings are `Runnable', or 30363 `Blocked on Mutex'. 30364 30365 Reply: 30366 `XX...' 30367 Where `XX...' is a hex encoding of ASCII data, comprising the 30368 printable string containing the extra information about the 30369 thread's attributes. 30370 30371 (Note that the `qThreadExtraInfo' packet's name is separated from 30372 the command by a `,', not a `:', contrary to the naming 30373 conventions above. Please don't use this packet as a model for new 30374 packets.) 30375 30376 `QTSave' 30377 30378 `qTsP' 30379 30380 `qTsV' 30381 `QTStart' 30382 `QTStop' 30383 `QTinit' 30384 `QTro' 30385 `qTStatus' 30386 `qTV' 30387 `qTfSTM' 30388 `qTsSTM' 30389 `qTSTMat' 30390 *Note Tracepoint Packets::. 30391 30392 `qXfer:OBJECT:read:ANNEX:OFFSET,LENGTH' 30393 Read uninterpreted bytes from the target's special data area 30394 identified by the keyword OBJECT. Request LENGTH bytes starting 30395 at OFFSET bytes into the data. The content and encoding of ANNEX 30396 is specific to OBJECT; it can supply additional details about what 30397 data to access. 30398 30399 Here are the specific requests of this form defined so far. All 30400 `qXfer:OBJECT:read:...' requests use the same reply formats, 30401 listed below. 30402 30403 `qXfer:auxv:read::OFFSET,LENGTH' 30404 Access the target's "auxiliary vector". *Note auxiliary 30405 vector: OS Information. Note ANNEX must be empty. 30406 30407 This packet is not probed by default; the remote stub must 30408 request it, by supplying an appropriate `qSupported' response 30409 (*note qSupported::). 30410 30411 `qXfer:features:read:ANNEX:OFFSET,LENGTH' 30412 Access the "target description". *Note Target 30413 Descriptions::. The annex specifies which XML document to 30414 access. The main description is always loaded from the 30415 `target.xml' annex. 30416 30417 This packet is not probed by default; the remote stub must 30418 request it, by supplying an appropriate `qSupported' response 30419 (*note qSupported::). 30420 30421 `qXfer:libraries:read:ANNEX:OFFSET,LENGTH' 30422 Access the target's list of loaded libraries. *Note Library 30423 List Format::. The annex part of the generic `qXfer' packet 30424 must be empty (*note qXfer read::). 30425 30426 Targets which maintain a list of libraries in the program's 30427 memory do not need to implement this packet; it is designed 30428 for platforms where the operating system manages the list of 30429 loaded libraries. 30430 30431 This packet is not probed by default; the remote stub must 30432 request it, by supplying an appropriate `qSupported' response 30433 (*note qSupported::). 30434 30435 `qXfer:memory-map:read::OFFSET,LENGTH' 30436 Access the target's "memory-map". *Note Memory Map Format::. 30437 The annex part of the generic `qXfer' packet must be empty 30438 (*note qXfer read::). 30439 30440 This packet is not probed by default; the remote stub must 30441 request it, by supplying an appropriate `qSupported' response 30442 (*note qSupported::). 30443 30444 `qXfer:sdata:read::OFFSET,LENGTH' 30445 Read contents of the extra collected static tracepoint marker 30446 information. The annex part of the generic `qXfer' packet 30447 must be empty (*note qXfer read::). *Note Tracepoint Action 30448 Lists: Tracepoint Actions. 30449 30450 This packet is not probed by default; the remote stub must 30451 request it, by supplying an appropriate `qSupported' response 30452 (*note qSupported::). 30453 30454 `qXfer:siginfo:read::OFFSET,LENGTH' 30455 Read contents of the extra signal information on the target 30456 system. The annex part of the generic `qXfer' packet must be 30457 empty (*note qXfer read::). 30458 30459 This packet is not probed by default; the remote stub must 30460 request it, by supplying an appropriate `qSupported' response 30461 (*note qSupported::). 30462 30463 `qXfer:spu:read:ANNEX:OFFSET,LENGTH' 30464 Read contents of an `spufs' file on the target system. The 30465 annex specifies which file to read; it must be of the form 30466 `ID/NAME', where ID specifies an SPU context ID in the target 30467 process, and NAME identifes the `spufs' file in that context 30468 to be accessed. 30469 30470 This packet is not probed by default; the remote stub must 30471 request it, by supplying an appropriate `qSupported' response 30472 (*note qSupported::). 30473 30474 `qXfer:threads:read::OFFSET,LENGTH' 30475 Access the list of threads on target. *Note Thread List 30476 Format::. The annex part of the generic `qXfer' packet must 30477 be empty (*note qXfer read::). 30478 30479 This packet is not probed by default; the remote stub must 30480 request it, by supplying an appropriate `qSupported' response 30481 (*note qSupported::). 30482 30483 `qXfer:traceframe-info:read::OFFSET,LENGTH' 30484 Return a description of the current traceframe's contents. 30485 *Note Traceframe Info Format::. The annex part of the generic 30486 `qXfer' packet must be empty (*note qXfer read::). 30487 30488 This packet is not probed by default; the remote stub must 30489 request it, by supplying an appropriate `qSupported' response 30490 (*note qSupported::). 30491 30492 `qXfer:osdata:read::OFFSET,LENGTH' 30493 Access the target's "operating system information". *Note 30494 Operating System Information::. 30495 30496 30497 Reply: 30498 `m DATA' 30499 Data DATA (*note Binary Data::) has been read from the 30500 target. There may be more data at a higher address (although 30501 it is permitted to return `m' even for the last valid block 30502 of data, as long as at least one byte of data was read). 30503 DATA may have fewer bytes than the LENGTH in the request. 30504 30505 `l DATA' 30506 Data DATA (*note Binary Data::) has been read from the target. 30507 There is no more data to be read. DATA may have fewer bytes 30508 than the LENGTH in the request. 30509 30510 `l' 30511 The OFFSET in the request is at the end of the data. There 30512 is no more data to be read. 30513 30514 `E00' 30515 The request was malformed, or ANNEX was invalid. 30516 30517 `E NN' 30518 The offset was invalid, or there was an error encountered 30519 reading the data. NN is a hex-encoded `errno' value. 30520 30521 `' 30522 An empty reply indicates the OBJECT string was not recognized 30523 by the stub, or that the object does not support reading. 30524 30525 `qXfer:OBJECT:write:ANNEX:OFFSET:DATA...' 30526 Write uninterpreted bytes into the target's special data area 30527 identified by the keyword OBJECT, starting at OFFSET bytes into 30528 the data. DATA... is the binary-encoded data (*note Binary 30529 Data::) to be written. The content and encoding of ANNEX is 30530 specific to OBJECT; it can supply additional details about what 30531 data to access. 30532 30533 Here are the specific requests of this form defined so far. All 30534 `qXfer:OBJECT:write:...' requests use the same reply formats, 30535 listed below. 30536 30537 `qXfer:siginfo:write::OFFSET:DATA...' 30538 Write DATA to the extra signal information on the target 30539 system. The annex part of the generic `qXfer' packet must be 30540 empty (*note qXfer write::). 30541 30542 This packet is not probed by default; the remote stub must 30543 request it, by supplying an appropriate `qSupported' response 30544 (*note qSupported::). 30545 30546 `qXfer:spu:write:ANNEX:OFFSET:DATA...' 30547 Write DATA to an `spufs' file on the target system. The 30548 annex specifies which file to write; it must be of the form 30549 `ID/NAME', where ID specifies an SPU context ID in the target 30550 process, and NAME identifes the `spufs' file in that context 30551 to be accessed. 30552 30553 This packet is not probed by default; the remote stub must 30554 request it, by supplying an appropriate `qSupported' response 30555 (*note qSupported::). 30556 30557 Reply: 30558 `NN' 30559 NN (hex encoded) is the number of bytes written. This may be 30560 fewer bytes than supplied in the request. 30561 30562 `E00' 30563 The request was malformed, or ANNEX was invalid. 30564 30565 `E NN' 30566 The offset was invalid, or there was an error encountered 30567 writing the data. NN is a hex-encoded `errno' value. 30568 30569 `' 30570 An empty reply indicates the OBJECT string was not recognized 30571 by the stub, or that the object does not support writing. 30572 30573 `qXfer:OBJECT:OPERATION:...' 30574 Requests of this form may be added in the future. When a stub does 30575 not recognize the OBJECT keyword, or its support for OBJECT does 30576 not recognize the OPERATION keyword, the stub must respond with an 30577 empty packet. 30578 30579 `qAttached:PID' 30580 Return an indication of whether the remote server attached to an 30581 existing process or created a new process. When the multiprocess 30582 protocol extensions are supported (*note multiprocess 30583 extensions::), PID is an integer in hexadecimal format identifying 30584 the target process. Otherwise, GDB will omit the PID field and 30585 the query packet will be simplified as `qAttached'. 30586 30587 This query is used, for example, to know whether the remote process 30588 should be detached or killed when a GDB session is ended with the 30589 `quit' command. 30590 30591 Reply: 30592 `1' 30593 The remote server attached to an existing process. 30594 30595 `0' 30596 The remote server created a new process. 30597 30598 `E NN' 30599 A badly formed request or an error was encountered. 30600 30601 30602 ---------- Footnotes ---------- 30603 30604 (1) The `qP' and `qL' packets predate these conventions, and have 30605 arguments without any terminator for the packet name; we suspect they 30606 are in widespread use in places that are difficult to upgrade. The 30607 `qC' packet has no arguments, but some existing stubs (e.g. RedBoot) 30608 are known to not check for the end of the packet. 30609 30610 30611 File: gdb.info, Node: Architecture-Specific Protocol Details, Next: Tracepoint Packets, Prev: General Query Packets, Up: Remote Protocol 30612 30613 E.5 Architecture-Specific Protocol Details 30614 ========================================== 30615 30616 This section describes how the remote protocol is applied to specific 30617 target architectures. Also see *note Standard Target Features::, for 30618 details of XML target descriptions for each architecture. 30619 30620 E.5.1 ARM 30621 --------- 30622 30623 E.5.1.1 Breakpoint Kinds 30624 ........................ 30625 30626 These breakpoint kinds are defined for the `Z0' and `Z1' packets. 30627 30628 2 30629 16-bit Thumb mode breakpoint. 30630 30631 3 30632 32-bit Thumb mode (Thumb-2) breakpoint. 30633 30634 4 30635 32-bit ARM mode breakpoint. 30636 30637 30638 E.5.2 MIPS 30639 ---------- 30640 30641 E.5.2.1 Register Packet Format 30642 .............................. 30643 30644 The following `g'/`G' packets have previously been defined. In the 30645 below, some thirty-two bit registers are transferred as sixty-four 30646 bits. Those registers should be zero/sign extended (which?) to fill 30647 the space allocated. Register bytes are transferred in target byte 30648 order. The two nibbles within a register byte are transferred 30649 most-significant - least-significant. 30650 30651 MIPS32 30652 All registers are transferred as thirty-two bit quantities in the 30653 order: 32 general-purpose; sr; lo; hi; bad; cause; pc; 32 30654 floating-point registers; fsr; fir; fp. 30655 30656 MIPS64 30657 All registers are transferred as sixty-four bit quantities 30658 (including thirty-two bit registers such as `sr'). The ordering 30659 is the same as `MIPS32'. 30660 30661 30662 30663 File: gdb.info, Node: Tracepoint Packets, Next: Host I/O Packets, Prev: Architecture-Specific Protocol Details, Up: Remote Protocol 30664 30665 E.6 Tracepoint Packets 30666 ====================== 30667 30668 Here we describe the packets GDB uses to implement tracepoints (*note 30669 Tracepoints::). 30670 30671 `QTDP:N:ADDR:ENA:STEP:PASS[:FFLEN][:XLEN,BYTES][-]' 30672 Create a new tracepoint, number N, at ADDR. If ENA is `E', then 30673 the tracepoint is enabled; if it is `D', then the tracepoint is 30674 disabled. STEP is the tracepoint's step count, and PASS is its 30675 pass count. If an `F' is present, then the tracepoint is to be a 30676 fast tracepoint, and the FLEN is the number of bytes that the 30677 target should copy elsewhere to make room for the tracepoint. If 30678 an `X' is present, it introduces a tracepoint condition, which 30679 consists of a hexadecimal length, followed by a comma and 30680 hex-encoded bytes, in a manner similar to action encodings as 30681 described below. If the trailing `-' is present, further `QTDP' 30682 packets will follow to specify this tracepoint's actions. 30683 30684 Replies: 30685 `OK' 30686 The packet was understood and carried out. 30687 30688 `qRelocInsn' 30689 *Note Relocate instruction reply packet: Tracepoint Packets. 30690 30691 `' 30692 The packet was not recognized. 30693 30694 `QTDP:-N:ADDR:[S]ACTION...[-]' 30695 Define actions to be taken when a tracepoint is hit. N and ADDR 30696 must be the same as in the initial `QTDP' packet for this 30697 tracepoint. This packet may only be sent immediately after 30698 another `QTDP' packet that ended with a `-'. If the trailing `-' 30699 is present, further `QTDP' packets will follow, specifying more 30700 actions for this tracepoint. 30701 30702 In the series of action packets for a given tracepoint, at most one 30703 can have an `S' before its first ACTION. If such a packet is 30704 sent, it and the following packets define "while-stepping" 30705 actions. Any prior packets define ordinary actions -- that is, 30706 those taken when the tracepoint is first hit. If no action packet 30707 has an `S', then all the packets in the series specify ordinary 30708 tracepoint actions. 30709 30710 The `ACTION...' portion of the packet is a series of actions, 30711 concatenated without separators. Each action has one of the 30712 following forms: 30713 30714 `R MASK' 30715 Collect the registers whose bits are set in MASK. MASK is a 30716 hexadecimal number whose I'th bit is set if register number I 30717 should be collected. (The least significant bit is numbered 30718 zero.) Note that MASK may be any number of digits long; it 30719 may not fit in a 32-bit word. 30720 30721 `M BASEREG,OFFSET,LEN' 30722 Collect LEN bytes of memory starting at the address in 30723 register number BASEREG, plus OFFSET. If BASEREG is `-1', 30724 then the range has a fixed address: OFFSET is the address of 30725 the lowest byte to collect. The BASEREG, OFFSET, and LEN 30726 parameters are all unsigned hexadecimal values (the `-1' 30727 value for BASEREG is a special case). 30728 30729 `X LEN,EXPR' 30730 Evaluate EXPR, whose length is LEN, and collect memory as it 30731 directs. EXPR is an agent expression, as described in *note 30732 Agent Expressions::. Each byte of the expression is encoded 30733 as a two-digit hex number in the packet; LEN is the number of 30734 bytes in the expression (and thus one-half the number of hex 30735 digits in the packet). 30736 30737 30738 Any number of actions may be packed together in a single `QTDP' 30739 packet, as long as the packet does not exceed the maximum packet 30740 length (400 bytes, for many stubs). There may be only one `R' 30741 action per tracepoint, and it must precede any `M' or `X' actions. 30742 Any registers referred to by `M' and `X' actions must be collected 30743 by a preceding `R' action. (The "while-stepping" actions are 30744 treated as if they were attached to a separate tracepoint, as far 30745 as these restrictions are concerned.) 30746 30747 Replies: 30748 `OK' 30749 The packet was understood and carried out. 30750 30751 `qRelocInsn' 30752 *Note Relocate instruction reply packet: Tracepoint Packets. 30753 30754 `' 30755 The packet was not recognized. 30756 30757 `QTDPsrc:N:ADDR:TYPE:START:SLEN:BYTES' 30758 Specify a source string of tracepoint N at address ADDR. This is 30759 useful to get accurate reproduction of the tracepoints originally 30760 downloaded at the beginning of the trace run. TYPE is the name of 30761 the tracepoint part, such as `cond' for the tracepoint's 30762 conditional expression (see below for a list of types), while 30763 BYTES is the string, encoded in hexadecimal. 30764 30765 START is the offset of the BYTES within the overall source string, 30766 while SLEN is the total length of the source string. This is 30767 intended for handling source strings that are longer than will fit 30768 in a single packet. 30769 30770 The available string types are `at' for the location, `cond' for 30771 the conditional, and `cmd' for an action command. GDB sends a 30772 separate packet for each command in the action list, in the same 30773 order in which the commands are stored in the list. 30774 30775 The target does not need to do anything with source strings except 30776 report them back as part of the replies to the `qTfP'/`qTsP' query 30777 packets. 30778 30779 Although this packet is optional, and GDB will only send it if the 30780 target replies with `TracepointSource' *Note General Query 30781 Packets::, it makes both disconnected tracing and trace files much 30782 easier to use. Otherwise the user must be careful that the 30783 tracepoints in effect while looking at trace frames are identical 30784 to the ones in effect during the trace run; even a small 30785 discrepancy could cause `tdump' not to work, or a particular trace 30786 frame not be found. 30787 30788 `QTDV:N:VALUE' 30789 Create a new trace state variable, number N, with an initial value 30790 of VALUE, which is a 64-bit signed integer. Both N and VALUE are 30791 encoded as hexadecimal values. GDB has the option of not using 30792 this packet for initial values of zero; the target should simply 30793 create the trace state variables as they are mentioned in 30794 expressions. 30795 30796 `QTFrame:N' 30797 Select the N'th tracepoint frame from the buffer, and use the 30798 register and memory contents recorded there to answer subsequent 30799 request packets from GDB. 30800 30801 A successful reply from the stub indicates that the stub has found 30802 the requested frame. The response is a series of parts, 30803 concatenated without separators, describing the frame we selected. 30804 Each part has one of the following forms: 30805 30806 `F F' 30807 The selected frame is number N in the trace frame buffer; F 30808 is a hexadecimal number. If F is `-1', then there was no 30809 frame matching the criteria in the request packet. 30810 30811 `T T' 30812 The selected trace frame records a hit of tracepoint number T; 30813 T is a hexadecimal number. 30814 30815 30816 `QTFrame:pc:ADDR' 30817 Like `QTFrame:N', but select the first tracepoint frame after the 30818 currently selected frame whose PC is ADDR; ADDR is a hexadecimal 30819 number. 30820 30821 `QTFrame:tdp:T' 30822 Like `QTFrame:N', but select the first tracepoint frame after the 30823 currently selected frame that is a hit of tracepoint T; T is a 30824 hexadecimal number. 30825 30826 `QTFrame:range:START:END' 30827 Like `QTFrame:N', but select the first tracepoint frame after the 30828 currently selected frame whose PC is between START (inclusive) and 30829 END (inclusive); START and END are hexadecimal numbers. 30830 30831 `QTFrame:outside:START:END' 30832 Like `QTFrame:range:START:END', but select the first frame 30833 _outside_ the given range of addresses (exclusive). 30834 30835 `QTStart' 30836 Begin the tracepoint experiment. Begin collecting data from 30837 tracepoint hits in the trace frame buffer. This packet supports 30838 the `qRelocInsn' reply (*note Relocate instruction reply packet: 30839 Tracepoint Packets.). 30840 30841 `QTStop' 30842 End the tracepoint experiment. Stop collecting trace frames. 30843 30844 `QTinit' 30845 Clear the table of tracepoints, and empty the trace frame buffer. 30846 30847 `QTro:START1,END1:START2,END2:...' 30848 Establish the given ranges of memory as "transparent". The stub 30849 will answer requests for these ranges from memory's current 30850 contents, if they were not collected as part of the tracepoint hit. 30851 30852 GDB uses this to mark read-only regions of memory, like those 30853 containing program code. Since these areas never change, they 30854 should still have the same contents they did when the tracepoint 30855 was hit, so there's no reason for the stub to refuse to provide 30856 their contents. 30857 30858 `QTDisconnected:VALUE' 30859 Set the choice to what to do with the tracing run when GDB 30860 disconnects from the target. A VALUE of 1 directs the target to 30861 continue the tracing run, while 0 tells the target to stop tracing 30862 if GDB is no longer in the picture. 30863 30864 `qTStatus' 30865 Ask the stub if there is a trace experiment running right now. 30866 30867 The reply has the form: 30868 30869 `TRUNNING[;FIELD]...' 30870 RUNNING is a single digit `1' if the trace is presently 30871 running, or `0' if not. It is followed by semicolon-separated 30872 optional fields that an agent may use to report additional 30873 status. 30874 30875 30876 If the trace is not running, the agent may report any of several 30877 explanations as one of the optional fields: 30878 30879 `tnotrun:0' 30880 No trace has been run yet. 30881 30882 `tstop:0' 30883 The trace was stopped by a user-originated stop command. 30884 30885 `tfull:0' 30886 The trace stopped because the trace buffer filled up. 30887 30888 `tdisconnected:0' 30889 The trace stopped because GDB disconnected from the target. 30890 30891 `tpasscount:TPNUM' 30892 The trace stopped because tracepoint TPNUM exceeded its pass 30893 count. 30894 30895 `terror:TEXT:TPNUM' 30896 The trace stopped because tracepoint TPNUM had an error. The 30897 string TEXT is available to describe the nature of the error 30898 (for instance, a divide by zero in the condition expression). 30899 TEXT is hex encoded. 30900 30901 `tunknown:0' 30902 The trace stopped for some other reason. 30903 30904 30905 Additional optional fields supply statistical and other 30906 information. Although not required, they are extremely useful for 30907 users monitoring the progress of a trace run. If a trace has 30908 stopped, and these numbers are reported, they must reflect the 30909 state of the just-stopped trace. 30910 30911 `tframes:N' 30912 The number of trace frames in the buffer. 30913 30914 `tcreated:N' 30915 The total number of trace frames created during the run. This 30916 may be larger than the trace frame count, if the buffer is 30917 circular. 30918 30919 `tsize:N' 30920 The total size of the trace buffer, in bytes. 30921 30922 `tfree:N' 30923 The number of bytes still unused in the buffer. 30924 30925 `circular:N' 30926 The value of the circular trace buffer flag. `1' means that 30927 the trace buffer is circular and old trace frames will be 30928 discarded if necessary to make room, `0' means that the trace 30929 buffer is linear and may fill up. 30930 30931 `disconn:N' 30932 The value of the disconnected tracing flag. `1' means that 30933 tracing will continue after GDB disconnects, `0' means that 30934 the trace run will stop. 30935 30936 30937 `qTV:VAR' 30938 Ask the stub for the value of the trace state variable number VAR. 30939 30940 Replies: 30941 `VVALUE' 30942 The value of the variable is VALUE. This will be the current 30943 value of the variable if the user is examining a running 30944 target, or a saved value if the variable was collected in the 30945 trace frame that the user is looking at. Note that multiple 30946 requests may result in different reply values, such as when 30947 requesting values while the program is running. 30948 30949 `U' 30950 The value of the variable is unknown. This would occur, for 30951 example, if the user is examining a trace frame in which the 30952 requested variable was not collected. 30953 30954 `qTfP' 30955 `qTsP' 30956 These packets request data about tracepoints that are being used by 30957 the target. GDB sends `qTfP' to get the first piece of data, and 30958 multiple `qTsP' to get additional pieces. Replies to these 30959 packets generally take the form of the `QTDP' packets that define 30960 tracepoints. (FIXME add detailed syntax) 30961 30962 `qTfV' 30963 `qTsV' 30964 These packets request data about trace state variables that are on 30965 the target. GDB sends `qTfV' to get the first vari of data, and 30966 multiple `qTsV' to get additional variables. Replies to these 30967 packets follow the syntax of the `QTDV' packets that define trace 30968 state variables. 30969 30970 `qTfSTM' 30971 `qTsSTM' 30972 These packets request data about static tracepoint markers that 30973 exist in the target program. GDB sends `qTfSTM' to get the first 30974 piece of data, and multiple `qTsSTM' to get additional pieces. 30975 Replies to these packets take the following form: 30976 30977 Reply: 30978 `m ADDRESS:ID:EXTRA' 30979 A single marker 30980 30981 `m ADDRESS:ID:EXTRA,ADDRESS:ID:EXTRA...' 30982 a comma-separated list of markers 30983 30984 `l' 30985 (lower case letter `L') denotes end of list. 30986 30987 `E NN' 30988 An error occurred. NN are hex digits. 30989 30990 `' 30991 An empty reply indicates that the request is not supported by 30992 the stub. 30993 30994 ADDRESS is encoded in hex. ID and EXTRA are strings encoded in 30995 hex. 30996 30997 In response to each query, the target will reply with a list of 30998 one or more markers, separated by commas. GDB will respond to each 30999 reply with a request for more markers (using the `qs' form of the 31000 query), until the target responds with `l' (lower-case ell, for 31001 "last"). 31002 31003 `qTSTMat:ADDRESS' 31004 This packets requests data about static tracepoint markers in the 31005 target program at ADDRESS. Replies to this packet follow the 31006 syntax of the `qTfSTM' and `qTsSTM' packets that list static 31007 tracepoint markers. 31008 31009 `QTSave:FILENAME' 31010 This packet directs the target to save trace data to the file name 31011 FILENAME in the target's filesystem. FILENAME is encoded as a hex 31012 string; the interpretation of the file name (relative vs absolute, 31013 wild cards, etc) is up to the target. 31014 31015 `qTBuffer:OFFSET,LEN' 31016 Return up to LEN bytes of the current contents of trace buffer, 31017 starting at OFFSET. The trace buffer is treated as if it were a 31018 contiguous collection of traceframes, as per the trace file format. 31019 The reply consists as many hex-encoded bytes as the target can 31020 deliver in a packet; it is not an error to return fewer than were 31021 asked for. A reply consisting of just `l' indicates that no bytes 31022 are available. 31023 31024 `QTBuffer:circular:VALUE' 31025 This packet directs the target to use a circular trace buffer if 31026 VALUE is 1, or a linear buffer if the value is 0. 31027 31028 31029 E.6.1 Relocate instruction reply packet 31030 --------------------------------------- 31031 31032 When installing fast tracepoints in memory, the target may need to 31033 relocate the instruction currently at the tracepoint address to a 31034 different address in memory. For most instructions, a simple copy is 31035 enough, but, for example, call instructions that implicitly push the 31036 return address on the stack, and relative branches or other PC-relative 31037 instructions require offset adjustment, so that the effect of executing 31038 the instruction at a different address is the same as if it had 31039 executed in the original location. 31040 31041 In response to several of the tracepoint packets, the target may also 31042 respond with a number of intermediate `qRelocInsn' request packets 31043 before the final result packet, to have GDB handle this relocation 31044 operation. If a packet supports this mechanism, its documentation will 31045 explicitly say so. See for example the above descriptions for the 31046 `QTStart' and `QTDP' packets. The format of the request is: 31047 31048 `qRelocInsn:FROM;TO' 31049 This requests GDB to copy instruction at address FROM to address 31050 TO, possibly adjusted so that executing the instruction at TO has 31051 the same effect as executing it at FROM. GDB writes the adjusted 31052 instruction to target memory starting at TO. 31053 31054 Replies: 31055 `qRelocInsn:ADJUSTED_SIZE' 31056 Informs the stub the relocation is complete. ADJUSTED_SIZE is the 31057 length in bytes of resulting relocated instruction sequence. 31058 31059 `E NN' 31060 A badly formed request was detected, or an error was encountered 31061 while relocating the instruction. 31062 31063 31064 File: gdb.info, Node: Host I/O Packets, Next: Interrupts, Prev: Tracepoint Packets, Up: Remote Protocol 31065 31066 E.7 Host I/O Packets 31067 ==================== 31068 31069 The "Host I/O" packets allow GDB to perform I/O operations on the far 31070 side of a remote link. For example, Host I/O is used to upload and 31071 download files to a remote target with its own filesystem. Host I/O 31072 uses the same constant values and data structure layout as the 31073 target-initiated File-I/O protocol. However, the Host I/O packets are 31074 structured differently. The target-initiated protocol relies on target 31075 memory to store parameters and buffers. Host I/O requests are 31076 initiated by GDB, and the target's memory is not involved. *Note 31077 File-I/O Remote Protocol Extension::, for more details on the 31078 target-initiated protocol. 31079 31080 The Host I/O request packets all encode a single operation along with 31081 its arguments. They have this format: 31082 31083 `vFile:OPERATION: PARAMETER...' 31084 OPERATION is the name of the particular request; the target should 31085 compare the entire packet name up to the second colon when checking 31086 for a supported operation. The format of PARAMETER depends on the 31087 operation. Numbers are always passed in hexadecimal. Negative 31088 numbers have an explicit minus sign (i.e. two's complement is not 31089 used). Strings (e.g. filenames) are encoded as a series of 31090 hexadecimal bytes. The last argument to a system call may be a 31091 buffer of escaped binary data (*note Binary Data::). 31092 31093 31094 The valid responses to Host I/O packets are: 31095 31096 `F RESULT [, ERRNO] [; ATTACHMENT]' 31097 RESULT is the integer value returned by this operation, usually 31098 non-negative for success and -1 for errors. If an error has 31099 occured, ERRNO will be included in the result. ERRNO will have a 31100 value defined by the File-I/O protocol (*note Errno Values::). For 31101 operations which return data, ATTACHMENT supplies the data as a 31102 binary buffer. Binary buffers in response packets are escaped in 31103 the normal way (*note Binary Data::). See the individual packet 31104 documentation for the interpretation of RESULT and ATTACHMENT. 31105 31106 `' 31107 An empty response indicates that this operation is not recognized. 31108 31109 31110 These are the supported Host I/O operations: 31111 31112 `vFile:open: PATHNAME, FLAGS, MODE' 31113 Open a file at PATHNAME and return a file descriptor for it, or 31114 return -1 if an error occurs. PATHNAME is a string, FLAGS is an 31115 integer indicating a mask of open flags (*note Open Flags::), and 31116 MODE is an integer indicating a mask of mode bits to use if the 31117 file is created (*note mode_t Values::). *Note open::, for 31118 details of the open flags and mode values. 31119 31120 `vFile:close: FD' 31121 Close the open file corresponding to FD and return 0, or -1 if an 31122 error occurs. 31123 31124 `vFile:pread: FD, COUNT, OFFSET' 31125 Read data from the open file corresponding to FD. Up to COUNT 31126 bytes will be read from the file, starting at OFFSET relative to 31127 the start of the file. The target may read fewer bytes; common 31128 reasons include packet size limits and an end-of-file condition. 31129 The number of bytes read is returned. Zero should only be 31130 returned for a successful read at the end of the file, or if COUNT 31131 was zero. 31132 31133 The data read should be returned as a binary attachment on success. 31134 If zero bytes were read, the response should include an empty 31135 binary attachment (i.e. a trailing semicolon). The return value 31136 is the number of target bytes read; the binary attachment may be 31137 longer if some characters were escaped. 31138 31139 `vFile:pwrite: FD, OFFSET, DATA' 31140 Write DATA (a binary buffer) to the open file corresponding to FD. 31141 Start the write at OFFSET from the start of the file. Unlike many 31142 `write' system calls, there is no separate COUNT argument; the 31143 length of DATA in the packet is used. `vFile:write' returns the 31144 number of bytes written, which may be shorter than the length of 31145 DATA, or -1 if an error occurred. 31146 31147 `vFile:unlink: PATHNAME' 31148 Delete the file at PATHNAME on the target. Return 0, or -1 if an 31149 error occurs. PATHNAME is a string. 31150 31151 31152 31153 File: gdb.info, Node: Interrupts, Next: Notification Packets, Prev: Host I/O Packets, Up: Remote Protocol 31154 31155 E.8 Interrupts 31156 ============== 31157 31158 When a program on the remote target is running, GDB may attempt to 31159 interrupt it by sending a `Ctrl-C', `BREAK' or a `BREAK' followed by 31160 `g', control of which is specified via GDB's `interrupt-sequence'. 31161 31162 The precise meaning of `BREAK' is defined by the transport mechanism 31163 and may, in fact, be undefined. GDB does not currently define a 31164 `BREAK' mechanism for any of the network interfaces except for TCP, in 31165 which case GDB sends the `telnet' BREAK sequence. 31166 31167 `Ctrl-C', on the other hand, is defined and implemented for all 31168 transport mechanisms. It is represented by sending the single byte 31169 `0x03' without any of the usual packet overhead described in the 31170 Overview section (*note Overview::). When a `0x03' byte is transmitted 31171 as part of a packet, it is considered to be packet data and does _not_ 31172 represent an interrupt. E.g., an `X' packet (*note X packet::), used 31173 for binary downloads, may include an unescaped `0x03' as part of its 31174 packet. 31175 31176 `BREAK' followed by `g' is also known as Magic SysRq g. When Linux 31177 kernel receives this sequence from serial port, it stops execution and 31178 connects to gdb. 31179 31180 Stubs are not required to recognize these interrupt mechanisms and 31181 the precise meaning associated with receipt of the interrupt is 31182 implementation defined. If the target supports debugging of multiple 31183 threads and/or processes, it should attempt to interrupt all 31184 currently-executing threads and processes. If the stub is successful 31185 at interrupting the running program, it should send one of the stop 31186 reply packets (*note Stop Reply Packets::) to GDB as a result of 31187 successfully stopping the program in all-stop mode, and a stop reply 31188 for each stopped thread in non-stop mode. Interrupts received while the 31189 program is stopped are discarded. 31190 31191 31192 File: gdb.info, Node: Notification Packets, Next: Remote Non-Stop, Prev: Interrupts, Up: Remote Protocol 31193 31194 E.9 Notification Packets 31195 ======================== 31196 31197 The GDB remote serial protocol includes "notifications", packets that 31198 require no acknowledgment. Both the GDB and the stub may send 31199 notifications (although the only notifications defined at present are 31200 sent by the stub). Notifications carry information without incurring 31201 the round-trip latency of an acknowledgment, and so are useful for 31202 low-impact communications where occasional packet loss is not a problem. 31203 31204 A notification packet has the form `% DATA # CHECKSUM', where DATA 31205 is the content of the notification, and CHECKSUM is a checksum of DATA, 31206 computed and formatted as for ordinary GDB packets. A notification's 31207 DATA never contains `$', `%' or `#' characters. Upon receiving a 31208 notification, the recipient sends no `+' or `-' to acknowledge the 31209 notification's receipt or to report its corruption. 31210 31211 Every notification's DATA begins with a name, which contains no 31212 colon characters, followed by a colon character. 31213 31214 Recipients should silently ignore corrupted notifications and 31215 notifications they do not understand. Recipients should restart 31216 timeout periods on receipt of a well-formed notification, whether or 31217 not they understand it. 31218 31219 Senders should only send the notifications described here when this 31220 protocol description specifies that they are permitted. In the future, 31221 we may extend the protocol to permit existing notifications in new 31222 contexts; this rule helps older senders avoid confusing newer 31223 recipients. 31224 31225 (Older versions of GDB ignore bytes received until they see the `$' 31226 byte that begins an ordinary packet, so new stubs may transmit 31227 notifications without fear of confusing older clients. There are no 31228 notifications defined for GDB to send at the moment, but we assume that 31229 most older stubs would ignore them, as well.) 31230 31231 The following notification packets from the stub to GDB are defined: 31232 31233 `Stop: REPLY' 31234 Report an asynchronous stop event in non-stop mode. The REPLY has 31235 the form of a stop reply, as described in *note Stop Reply 31236 Packets::. Refer to *note Remote Non-Stop::, for information on 31237 how these notifications are acknowledged by GDB. 31238 31239 31240 File: gdb.info, Node: Remote Non-Stop, Next: Packet Acknowledgment, Prev: Notification Packets, Up: Remote Protocol 31241 31242 E.10 Remote Protocol Support for Non-Stop Mode 31243 ============================================== 31244 31245 GDB's remote protocol supports non-stop debugging of multi-threaded 31246 programs, as described in *note Non-Stop Mode::. If the stub supports 31247 non-stop mode, it should report that to GDB by including `QNonStop+' in 31248 its `qSupported' response (*note qSupported::). 31249 31250 GDB typically sends a `QNonStop' packet only when establishing a new 31251 connection with the stub. Entering non-stop mode does not alter the 31252 state of any currently-running threads, but targets must stop all 31253 threads in any already-attached processes when entering all-stop mode. 31254 GDB uses the `?' packet as necessary to probe the target state after a 31255 mode change. 31256 31257 In non-stop mode, when an attached process encounters an event that 31258 would otherwise be reported with a stop reply, it uses the asynchronous 31259 notification mechanism (*note Notification Packets::) to inform GDB. 31260 In contrast to all-stop mode, where all threads in all processes are 31261 stopped when a stop reply is sent, in non-stop mode only the thread 31262 reporting the stop event is stopped. That is, when reporting a `S' or 31263 `T' response to indicate completion of a step operation, hitting a 31264 breakpoint, or a fault, only the affected thread is stopped; any other 31265 still-running threads continue to run. When reporting a `W' or `X' 31266 response, all running threads belonging to other attached processes 31267 continue to run. 31268 31269 Only one stop reply notification at a time may be pending; if 31270 additional stop events occur before GDB has acknowledged the previous 31271 notification, they must be queued by the stub for later synchronous 31272 transmission in response to `vStopped' packets from GDB. Because the 31273 notification mechanism is unreliable, the stub is permitted to resend a 31274 stop reply notification if it believes GDB may not have received it. 31275 GDB ignores additional stop reply notifications received before it has 31276 finished processing a previous notification and the stub has completed 31277 sending any queued stop events. 31278 31279 Otherwise, GDB must be prepared to receive a stop reply notification 31280 at any time. Specifically, they may appear when GDB is not otherwise 31281 reading input from the stub, or when GDB is expecting to read a normal 31282 synchronous response or a `+'/`-' acknowledgment to a packet it has 31283 sent. Notification packets are distinct from any other communication 31284 from the stub so there is no ambiguity. 31285 31286 After receiving a stop reply notification, GDB shall acknowledge it 31287 by sending a `vStopped' packet (*note vStopped packet::) as a regular, 31288 synchronous request to the stub. Such acknowledgment is not required 31289 to happen immediately, as GDB is permitted to send other, unrelated 31290 packets to the stub first, which the stub should process normally. 31291 31292 Upon receiving a `vStopped' packet, if the stub has other queued 31293 stop events to report to GDB, it shall respond by sending a normal stop 31294 reply response. GDB shall then send another `vStopped' packet to 31295 solicit further responses; again, it is permitted to send other, 31296 unrelated packets as well which the stub should process normally. 31297 31298 If the stub receives a `vStopped' packet and there are no additional 31299 stop events to report, the stub shall return an `OK' response. At this 31300 point, if further stop events occur, the stub shall send a new stop 31301 reply notification, GDB shall accept the notification, and the process 31302 shall be repeated. 31303 31304 In non-stop mode, the target shall respond to the `?' packet as 31305 follows. First, any incomplete stop reply notification/`vStopped' 31306 sequence in progress is abandoned. The target must begin a new 31307 sequence reporting stop events for all stopped threads, whether or not 31308 it has previously reported those events to GDB. The first stop reply 31309 is sent as a synchronous reply to the `?' packet, and subsequent stop 31310 replies are sent as responses to `vStopped' packets using the mechanism 31311 described above. The target must not send asynchronous stop reply 31312 notifications until the sequence is complete. If all threads are 31313 running when the target receives the `?' packet, or if the target is 31314 not attached to any process, it shall respond `OK'. 31315 31316 31317 File: gdb.info, Node: Packet Acknowledgment, Next: Examples, Prev: Remote Non-Stop, Up: Remote Protocol 31318 31319 E.11 Packet Acknowledgment 31320 ========================== 31321 31322 By default, when either the host or the target machine receives a 31323 packet, the first response expected is an acknowledgment: either `+' 31324 (to indicate the package was received correctly) or `-' (to request 31325 retransmission). This mechanism allows the GDB remote protocol to 31326 operate over unreliable transport mechanisms, such as a serial line. 31327 31328 In cases where the transport mechanism is itself reliable (such as a 31329 pipe or TCP connection), the `+'/`-' acknowledgments are redundant. It 31330 may be desirable to disable them in that case to reduce communication 31331 overhead, or for other reasons. This can be accomplished by means of 31332 the `QStartNoAckMode' packet; *note QStartNoAckMode::. 31333 31334 When in no-acknowledgment mode, neither the stub nor GDB shall send 31335 or expect `+'/`-' protocol acknowledgments. The packet and response 31336 format still includes the normal checksum, as described in *note 31337 Overview::, but the checksum may be ignored by the receiver. 31338 31339 If the stub supports `QStartNoAckMode' and prefers to operate in 31340 no-acknowledgment mode, it should report that to GDB by including 31341 `QStartNoAckMode+' in its response to `qSupported'; *note qSupported::. 31342 If GDB also supports `QStartNoAckMode' and it has not been disabled via 31343 the `set remote noack-packet off' command (*note Remote 31344 Configuration::), GDB may then send a `QStartNoAckMode' packet to the 31345 stub. Only then may the stub actually turn off packet acknowledgments. 31346 GDB sends a final `+' acknowledgment of the stub's `OK' response, which 31347 can be safely ignored by the stub. 31348 31349 Note that `set remote noack-packet' command only affects negotiation 31350 between GDB and the stub when subsequent connections are made; it does 31351 not affect the protocol acknowledgment state for any current connection. 31352 Since `+'/`-' acknowledgments are enabled by default when a new 31353 connection is established, there is also no protocol request to 31354 re-enable the acknowledgments for the current connection, once disabled. 31355 31356 31357 File: gdb.info, Node: Examples, Next: File-I/O Remote Protocol Extension, Prev: Packet Acknowledgment, Up: Remote Protocol 31358 31359 E.12 Examples 31360 ============= 31361 31362 Example sequence of a target being re-started. Notice how the restart 31363 does not get any direct output: 31364 31365 -> `R00' 31366 <- `+' 31367 _target restarts_ 31368 -> `?' 31369 <- `+' 31370 <- `T001:1234123412341234' 31371 -> `+' 31372 31373 Example sequence of a target being stepped by a single instruction: 31374 31375 -> `G1445...' 31376 <- `+' 31377 -> `s' 31378 <- `+' 31379 _time passes_ 31380 <- `T001:1234123412341234' 31381 -> `+' 31382 -> `g' 31383 <- `+' 31384 <- `1455...' 31385 -> `+' 31386 31387 31388 File: gdb.info, Node: File-I/O Remote Protocol Extension, Next: Library List Format, Prev: Examples, Up: Remote Protocol 31389 31390 E.13 File-I/O Remote Protocol Extension 31391 ======================================= 31392 31393 * Menu: 31394 31395 * File-I/O Overview:: 31396 * Protocol Basics:: 31397 * The F Request Packet:: 31398 * The F Reply Packet:: 31399 * The Ctrl-C Message:: 31400 * Console I/O:: 31401 * List of Supported Calls:: 31402 * Protocol-specific Representation of Datatypes:: 31403 * Constants:: 31404 * File-I/O Examples:: 31405 31406 31407 File: gdb.info, Node: File-I/O Overview, Next: Protocol Basics, Up: File-I/O Remote Protocol Extension 31408 31409 E.13.1 File-I/O Overview 31410 ------------------------ 31411 31412 The "File I/O remote protocol extension" (short: File-I/O) allows the 31413 target to use the host's file system and console I/O to perform various 31414 system calls. System calls on the target system are translated into a 31415 remote protocol packet to the host system, which then performs the 31416 needed actions and returns a response packet to the target system. 31417 This simulates file system operations even on targets that lack file 31418 systems. 31419 31420 The protocol is defined to be independent of both the host and 31421 target systems. It uses its own internal representation of datatypes 31422 and values. Both GDB and the target's GDB stub are responsible for 31423 translating the system-dependent value representations into the internal 31424 protocol representations when data is transmitted. 31425 31426 The communication is synchronous. A system call is possible only 31427 when GDB is waiting for a response from the `C', `c', `S' or `s' 31428 packets. While GDB handles the request for a system call, the target 31429 is stopped to allow deterministic access to the target's memory. 31430 Therefore File-I/O is not interruptible by target signals. On the 31431 other hand, it is possible to interrupt File-I/O by a user interrupt 31432 (`Ctrl-C') within GDB. 31433 31434 The target's request to perform a host system call does not finish 31435 the latest `C', `c', `S' or `s' action. That means, after finishing 31436 the system call, the target returns to continuing the previous activity 31437 (continue, step). No additional continue or step request from GDB is 31438 required. 31439 31440 (gdb) continue 31441 <- target requests 'system call X' 31442 target is stopped, GDB executes system call 31443 -> GDB returns result 31444 ... target continues, GDB returns to wait for the target 31445 <- target hits breakpoint and sends a Txx packet 31446 31447 The protocol only supports I/O on the console and to regular files on 31448 the host file system. Character or block special devices, pipes, named 31449 pipes, sockets or any other communication method on the host system are 31450 not supported by this protocol. 31451 31452 File I/O is not supported in non-stop mode. 31453 31454 31455 File: gdb.info, Node: Protocol Basics, Next: The F Request Packet, Prev: File-I/O Overview, Up: File-I/O Remote Protocol Extension 31456 31457 E.13.2 Protocol Basics 31458 ---------------------- 31459 31460 The File-I/O protocol uses the `F' packet as the request as well as 31461 reply packet. Since a File-I/O system call can only occur when GDB is 31462 waiting for a response from the continuing or stepping target, the 31463 File-I/O request is a reply that GDB has to expect as a result of a 31464 previous `C', `c', `S' or `s' packet. This `F' packet contains all 31465 information needed to allow GDB to call the appropriate host system 31466 call: 31467 31468 * A unique identifier for the requested system call. 31469 31470 * All parameters to the system call. Pointers are given as addresses 31471 in the target memory address space. Pointers to strings are given 31472 as pointer/length pair. Numerical values are given as they are. 31473 Numerical control flags are given in a protocol-specific 31474 representation. 31475 31476 31477 At this point, GDB has to perform the following actions. 31478 31479 * If the parameters include pointer values to data needed as input 31480 to a system call, GDB requests this data from the target with a 31481 standard `m' packet request. This additional communication has to 31482 be expected by the target implementation and is handled as any 31483 other `m' packet. 31484 31485 * GDB translates all value from protocol representation to host 31486 representation as needed. Datatypes are coerced into the host 31487 types. 31488 31489 * GDB calls the system call. 31490 31491 * It then coerces datatypes back to protocol representation. 31492 31493 * If the system call is expected to return data in buffer space 31494 specified by pointer parameters to the call, the data is 31495 transmitted to the target using a `M' or `X' packet. This packet 31496 has to be expected by the target implementation and is handled as 31497 any other `M' or `X' packet. 31498 31499 31500 Eventually GDB replies with another `F' packet which contains all 31501 necessary information for the target to continue. This at least 31502 contains 31503 31504 * Return value. 31505 31506 * `errno', if has been changed by the system call. 31507 31508 * "Ctrl-C" flag. 31509 31510 31511 After having done the needed type and value coercion, the target 31512 continues the latest continue or step action. 31513 31514 31515 File: gdb.info, Node: The F Request Packet, Next: The F Reply Packet, Prev: Protocol Basics, Up: File-I/O Remote Protocol Extension 31516 31517 E.13.3 The `F' Request Packet 31518 ----------------------------- 31519 31520 The `F' request packet has the following format: 31521 31522 `FCALL-ID,PARAMETER...' 31523 CALL-ID is the identifier to indicate the host system call to be 31524 called. This is just the name of the function. 31525 31526 PARAMETER... are the parameters to the system call. Parameters 31527 are hexadecimal integer values, either the actual values in case 31528 of scalar datatypes, pointers to target buffer space in case of 31529 compound datatypes and unspecified memory areas, or pointer/length 31530 pairs in case of string parameters. These are appended to the 31531 CALL-ID as a comma-delimited list. All values are transmitted in 31532 ASCII string representation, pointer/length pairs separated by a 31533 slash. 31534 31535 31536 31537 File: gdb.info, Node: The F Reply Packet, Next: The Ctrl-C Message, Prev: The F Request Packet, Up: File-I/O Remote Protocol Extension 31538 31539 E.13.4 The `F' Reply Packet 31540 --------------------------- 31541 31542 The `F' reply packet has the following format: 31543 31544 `FRETCODE,ERRNO,CTRL-C FLAG;CALL-SPECIFIC ATTACHMENT' 31545 RETCODE is the return code of the system call as hexadecimal value. 31546 31547 ERRNO is the `errno' set by the call, in protocol-specific 31548 representation. This parameter can be omitted if the call was 31549 successful. 31550 31551 CTRL-C FLAG is only sent if the user requested a break. In this 31552 case, ERRNO must be sent as well, even if the call was successful. 31553 The CTRL-C FLAG itself consists of the character `C': 31554 31555 F0,0,C 31556 31557 or, if the call was interrupted before the host call has been 31558 performed: 31559 31560 F-1,4,C 31561 31562 assuming 4 is the protocol-specific representation of `EINTR'. 31563 31564 31565 31566 File: gdb.info, Node: The Ctrl-C Message, Next: Console I/O, Prev: The F Reply Packet, Up: File-I/O Remote Protocol Extension 31567 31568 E.13.5 The `Ctrl-C' Message 31569 --------------------------- 31570 31571 If the `Ctrl-C' flag is set in the GDB reply packet (*note The F Reply 31572 Packet::), the target should behave as if it had gotten a break 31573 message. The meaning for the target is "system call interrupted by 31574 `SIGINT'". Consequentially, the target should actually stop (as with a 31575 break message) and return to GDB with a `T02' packet. 31576 31577 It's important for the target to know in which state the system call 31578 was interrupted. There are two possible cases: 31579 31580 * The system call hasn't been performed on the host yet. 31581 31582 * The system call on the host has been finished. 31583 31584 31585 These two states can be distinguished by the target by the value of 31586 the returned `errno'. If it's the protocol representation of `EINTR', 31587 the system call hasn't been performed. This is equivalent to the 31588 `EINTR' handling on POSIX systems. In any other case, the target may 31589 presume that the system call has been finished -- successfully or not 31590 -- and should behave as if the break message arrived right after the 31591 system call. 31592 31593 GDB must behave reliably. If the system call has not been called 31594 yet, GDB may send the `F' reply immediately, setting `EINTR' as `errno' 31595 in the packet. If the system call on the host has been finished before 31596 the user requests a break, the full action must be finished by GDB. 31597 This requires sending `M' or `X' packets as necessary. The `F' packet 31598 may only be sent when either nothing has happened or the full action 31599 has been completed. 31600 31601 31602 File: gdb.info, Node: Console I/O, Next: List of Supported Calls, Prev: The Ctrl-C Message, Up: File-I/O Remote Protocol Extension 31603 31604 E.13.6 Console I/O 31605 ------------------ 31606 31607 By default and if not explicitly closed by the target system, the file 31608 descriptors 0, 1 and 2 are connected to the GDB console. Output on the 31609 GDB console is handled as any other file output operation (`write(1, 31610 ...)' or `write(2, ...)'). Console input is handled by GDB so that 31611 after the target read request from file descriptor 0 all following 31612 typing is buffered until either one of the following conditions is met: 31613 31614 * The user types `Ctrl-c'. The behaviour is as explained above, and 31615 the `read' system call is treated as finished. 31616 31617 * The user presses <RET>. This is treated as end of input with a 31618 trailing newline. 31619 31620 * The user types `Ctrl-d'. This is treated as end of input. No 31621 trailing character (neither newline nor `Ctrl-D') is appended to 31622 the input. 31623 31624 31625 If the user has typed more characters than fit in the buffer given to 31626 the `read' call, the trailing characters are buffered in GDB until 31627 either another `read(0, ...)' is requested by the target, or debugging 31628 is stopped at the user's request. 31629 31630 31631 File: gdb.info, Node: List of Supported Calls, Next: Protocol-specific Representation of Datatypes, Prev: Console I/O, Up: File-I/O Remote Protocol Extension 31632 31633 E.13.7 List of Supported Calls 31634 ------------------------------ 31635 31636 * Menu: 31637 31638 * open:: 31639 * close:: 31640 * read:: 31641 * write:: 31642 * lseek:: 31643 * rename:: 31644 * unlink:: 31645 * stat/fstat:: 31646 * gettimeofday:: 31647 * isatty:: 31648 * system:: 31649 31650 31651 File: gdb.info, Node: open, Next: close, Up: List of Supported Calls 31652 31653 open 31654 .... 31655 31656 Synopsis: 31657 int open(const char *pathname, int flags); 31658 int open(const char *pathname, int flags, mode_t mode); 31659 31660 Request: 31661 `Fopen,PATHPTR/LEN,FLAGS,MODE' 31662 31663 FLAGS is the bitwise `OR' of the following values: 31664 31665 `O_CREAT' 31666 If the file does not exist it will be created. The host 31667 rules apply as far as file ownership and time stamps are 31668 concerned. 31669 31670 `O_EXCL' 31671 When used with `O_CREAT', if the file already exists it is an 31672 error and open() fails. 31673 31674 `O_TRUNC' 31675 If the file already exists and the open mode allows writing 31676 (`O_RDWR' or `O_WRONLY' is given) it will be truncated to 31677 zero length. 31678 31679 `O_APPEND' 31680 The file is opened in append mode. 31681 31682 `O_RDONLY' 31683 The file is opened for reading only. 31684 31685 `O_WRONLY' 31686 The file is opened for writing only. 31687 31688 `O_RDWR' 31689 The file is opened for reading and writing. 31690 31691 Other bits are silently ignored. 31692 31693 MODE is the bitwise `OR' of the following values: 31694 31695 `S_IRUSR' 31696 User has read permission. 31697 31698 `S_IWUSR' 31699 User has write permission. 31700 31701 `S_IRGRP' 31702 Group has read permission. 31703 31704 `S_IWGRP' 31705 Group has write permission. 31706 31707 `S_IROTH' 31708 Others have read permission. 31709 31710 `S_IWOTH' 31711 Others have write permission. 31712 31713 Other bits are silently ignored. 31714 31715 Return value: 31716 `open' returns the new file descriptor or -1 if an error occurred. 31717 31718 Errors: 31719 31720 `EEXIST' 31721 PATHNAME already exists and `O_CREAT' and `O_EXCL' were used. 31722 31723 `EISDIR' 31724 PATHNAME refers to a directory. 31725 31726 `EACCES' 31727 The requested access is not allowed. 31728 31729 `ENAMETOOLONG' 31730 PATHNAME was too long. 31731 31732 `ENOENT' 31733 A directory component in PATHNAME does not exist. 31734 31735 `ENODEV' 31736 PATHNAME refers to a device, pipe, named pipe or socket. 31737 31738 `EROFS' 31739 PATHNAME refers to a file on a read-only filesystem and write 31740 access was requested. 31741 31742 `EFAULT' 31743 PATHNAME is an invalid pointer value. 31744 31745 `ENOSPC' 31746 No space on device to create the file. 31747 31748 `EMFILE' 31749 The process already has the maximum number of files open. 31750 31751 `ENFILE' 31752 The limit on the total number of files open on the system has 31753 been reached. 31754 31755 `EINTR' 31756 The call was interrupted by the user. 31757 31758 31759 31760 File: gdb.info, Node: close, Next: read, Prev: open, Up: List of Supported Calls 31761 31762 close 31763 ..... 31764 31765 Synopsis: 31766 int close(int fd); 31767 31768 Request: 31769 `Fclose,FD' 31770 31771 Return value: 31772 `close' returns zero on success, or -1 if an error occurred. 31773 31774 Errors: 31775 31776 `EBADF' 31777 FD isn't a valid open file descriptor. 31778 31779 `EINTR' 31780 The call was interrupted by the user. 31781 31782 31783 31784 File: gdb.info, Node: read, Next: write, Prev: close, Up: List of Supported Calls 31785 31786 read 31787 .... 31788 31789 Synopsis: 31790 int read(int fd, void *buf, unsigned int count); 31791 31792 Request: 31793 `Fread,FD,BUFPTR,COUNT' 31794 31795 Return value: 31796 On success, the number of bytes read is returned. Zero indicates 31797 end of file. If count is zero, read returns zero as well. On 31798 error, -1 is returned. 31799 31800 Errors: 31801 31802 `EBADF' 31803 FD is not a valid file descriptor or is not open for reading. 31804 31805 `EFAULT' 31806 BUFPTR is an invalid pointer value. 31807 31808 `EINTR' 31809 The call was interrupted by the user. 31810 31811 31812 31813 File: gdb.info, Node: write, Next: lseek, Prev: read, Up: List of Supported Calls 31814 31815 write 31816 ..... 31817 31818 Synopsis: 31819 int write(int fd, const void *buf, unsigned int count); 31820 31821 Request: 31822 `Fwrite,FD,BUFPTR,COUNT' 31823 31824 Return value: 31825 On success, the number of bytes written are returned. Zero 31826 indicates nothing was written. On error, -1 is returned. 31827 31828 Errors: 31829 31830 `EBADF' 31831 FD is not a valid file descriptor or is not open for writing. 31832 31833 `EFAULT' 31834 BUFPTR is an invalid pointer value. 31835 31836 `EFBIG' 31837 An attempt was made to write a file that exceeds the 31838 host-specific maximum file size allowed. 31839 31840 `ENOSPC' 31841 No space on device to write the data. 31842 31843 `EINTR' 31844 The call was interrupted by the user. 31845 31846 31847 31848 File: gdb.info, Node: lseek, Next: rename, Prev: write, Up: List of Supported Calls 31849 31850 lseek 31851 ..... 31852 31853 Synopsis: 31854 long lseek (int fd, long offset, int flag); 31855 31856 Request: 31857 `Flseek,FD,OFFSET,FLAG' 31858 31859 FLAG is one of: 31860 31861 `SEEK_SET' 31862 The offset is set to OFFSET bytes. 31863 31864 `SEEK_CUR' 31865 The offset is set to its current location plus OFFSET bytes. 31866 31867 `SEEK_END' 31868 The offset is set to the size of the file plus OFFSET bytes. 31869 31870 Return value: 31871 On success, the resulting unsigned offset in bytes from the 31872 beginning of the file is returned. Otherwise, a value of -1 is 31873 returned. 31874 31875 Errors: 31876 31877 `EBADF' 31878 FD is not a valid open file descriptor. 31879 31880 `ESPIPE' 31881 FD is associated with the GDB console. 31882 31883 `EINVAL' 31884 FLAG is not a proper value. 31885 31886 `EINTR' 31887 The call was interrupted by the user. 31888 31889 31890 31891 File: gdb.info, Node: rename, Next: unlink, Prev: lseek, Up: List of Supported Calls 31892 31893 rename 31894 ...... 31895 31896 Synopsis: 31897 int rename(const char *oldpath, const char *newpath); 31898 31899 Request: 31900 `Frename,OLDPATHPTR/LEN,NEWPATHPTR/LEN' 31901 31902 Return value: 31903 On success, zero is returned. On error, -1 is returned. 31904 31905 Errors: 31906 31907 `EISDIR' 31908 NEWPATH is an existing directory, but OLDPATH is not a 31909 directory. 31910 31911 `EEXIST' 31912 NEWPATH is a non-empty directory. 31913 31914 `EBUSY' 31915 OLDPATH or NEWPATH is a directory that is in use by some 31916 process. 31917 31918 `EINVAL' 31919 An attempt was made to make a directory a subdirectory of 31920 itself. 31921 31922 `ENOTDIR' 31923 A component used as a directory in OLDPATH or new path is 31924 not a directory. Or OLDPATH is a directory and NEWPATH 31925 exists but is not a directory. 31926 31927 `EFAULT' 31928 OLDPATHPTR or NEWPATHPTR are invalid pointer values. 31929 31930 `EACCES' 31931 No access to the file or the path of the file. 31932 31933 `ENAMETOOLONG' 31934 OLDPATH or NEWPATH was too long. 31935 31936 `ENOENT' 31937 A directory component in OLDPATH or NEWPATH does not exist. 31938 31939 `EROFS' 31940 The file is on a read-only filesystem. 31941 31942 `ENOSPC' 31943 The device containing the file has no room for the new 31944 directory entry. 31945 31946 `EINTR' 31947 The call was interrupted by the user. 31948 31949 31950 31951 File: gdb.info, Node: unlink, Next: stat/fstat, Prev: rename, Up: List of Supported Calls 31952 31953 unlink 31954 ...... 31955 31956 Synopsis: 31957 int unlink(const char *pathname); 31958 31959 Request: 31960 `Funlink,PATHNAMEPTR/LEN' 31961 31962 Return value: 31963 On success, zero is returned. On error, -1 is returned. 31964 31965 Errors: 31966 31967 `EACCES' 31968 No access to the file or the path of the file. 31969 31970 `EPERM' 31971 The system does not allow unlinking of directories. 31972 31973 `EBUSY' 31974 The file PATHNAME cannot be unlinked because it's being used 31975 by another process. 31976 31977 `EFAULT' 31978 PATHNAMEPTR is an invalid pointer value. 31979 31980 `ENAMETOOLONG' 31981 PATHNAME was too long. 31982 31983 `ENOENT' 31984 A directory component in PATHNAME does not exist. 31985 31986 `ENOTDIR' 31987 A component of the path is not a directory. 31988 31989 `EROFS' 31990 The file is on a read-only filesystem. 31991 31992 `EINTR' 31993 The call was interrupted by the user. 31994 31995 31996 31997 File: gdb.info, Node: stat/fstat, Next: gettimeofday, Prev: unlink, Up: List of Supported Calls 31998 31999 stat/fstat 32000 .......... 32001 32002 Synopsis: 32003 int stat(const char *pathname, struct stat *buf); 32004 int fstat(int fd, struct stat *buf); 32005 32006 Request: 32007 `Fstat,PATHNAMEPTR/LEN,BUFPTR' 32008 `Ffstat,FD,BUFPTR' 32009 32010 Return value: 32011 On success, zero is returned. On error, -1 is returned. 32012 32013 Errors: 32014 32015 `EBADF' 32016 FD is not a valid open file. 32017 32018 `ENOENT' 32019 A directory component in PATHNAME does not exist or the path 32020 is an empty string. 32021 32022 `ENOTDIR' 32023 A component of the path is not a directory. 32024 32025 `EFAULT' 32026 PATHNAMEPTR is an invalid pointer value. 32027 32028 `EACCES' 32029 No access to the file or the path of the file. 32030 32031 `ENAMETOOLONG' 32032 PATHNAME was too long. 32033 32034 `EINTR' 32035 The call was interrupted by the user. 32036 32037 32038 32039 File: gdb.info, Node: gettimeofday, Next: isatty, Prev: stat/fstat, Up: List of Supported Calls 32040 32041 gettimeofday 32042 ............ 32043 32044 Synopsis: 32045 int gettimeofday(struct timeval *tv, void *tz); 32046 32047 Request: 32048 `Fgettimeofday,TVPTR,TZPTR' 32049 32050 Return value: 32051 On success, 0 is returned, -1 otherwise. 32052 32053 Errors: 32054 32055 `EINVAL' 32056 TZ is a non-NULL pointer. 32057 32058 `EFAULT' 32059 TVPTR and/or TZPTR is an invalid pointer value. 32060 32061 32062 32063 File: gdb.info, Node: isatty, Next: system, Prev: gettimeofday, Up: List of Supported Calls 32064 32065 isatty 32066 ...... 32067 32068 Synopsis: 32069 int isatty(int fd); 32070 32071 Request: 32072 `Fisatty,FD' 32073 32074 Return value: 32075 Returns 1 if FD refers to the GDB console, 0 otherwise. 32076 32077 Errors: 32078 32079 `EINTR' 32080 The call was interrupted by the user. 32081 32082 32083 Note that the `isatty' call is treated as a special case: it returns 32084 1 to the target if the file descriptor is attached to the GDB console, 32085 0 otherwise. Implementing through system calls would require 32086 implementing `ioctl' and would be more complex than needed. 32087 32088 32089 File: gdb.info, Node: system, Prev: isatty, Up: List of Supported Calls 32090 32091 system 32092 ...... 32093 32094 Synopsis: 32095 int system(const char *command); 32096 32097 Request: 32098 `Fsystem,COMMANDPTR/LEN' 32099 32100 Return value: 32101 If LEN is zero, the return value indicates whether a shell is 32102 available. A zero return value indicates a shell is not available. 32103 For non-zero LEN, the value returned is -1 on error and the return 32104 status of the command otherwise. Only the exit status of the 32105 command is returned, which is extracted from the host's `system' 32106 return value by calling `WEXITSTATUS(retval)'. In case `/bin/sh' 32107 could not be executed, 127 is returned. 32108 32109 Errors: 32110 32111 `EINTR' 32112 The call was interrupted by the user. 32113 32114 32115 GDB takes over the full task of calling the necessary host calls to 32116 perform the `system' call. The return value of `system' on the host is 32117 simplified before it's returned to the target. Any termination signal 32118 information from the child process is discarded, and the return value 32119 consists entirely of the exit status of the called command. 32120 32121 Due to security concerns, the `system' call is by default refused by 32122 GDB. The user has to allow this call explicitly with the `set remote 32123 system-call-allowed 1' command. 32124 32125 `set remote system-call-allowed' 32126 Control whether to allow the `system' calls in the File I/O 32127 protocol for the remote target. The default is zero (disabled). 32128 32129 `show remote system-call-allowed' 32130 Show whether the `system' calls are allowed in the File I/O 32131 protocol. 32132 32133 32134 File: gdb.info, Node: Protocol-specific Representation of Datatypes, Next: Constants, Prev: List of Supported Calls, Up: File-I/O Remote Protocol Extension 32135 32136 E.13.8 Protocol-specific Representation of Datatypes 32137 ---------------------------------------------------- 32138 32139 * Menu: 32140 32141 * Integral Datatypes:: 32142 * Pointer Values:: 32143 * Memory Transfer:: 32144 * struct stat:: 32145 * struct timeval:: 32146 32147 32148 File: gdb.info, Node: Integral Datatypes, Next: Pointer Values, Up: Protocol-specific Representation of Datatypes 32149 32150 Integral Datatypes 32151 .................. 32152 32153 The integral datatypes used in the system calls are `int', `unsigned 32154 int', `long', `unsigned long', `mode_t', and `time_t'. 32155 32156 `int', `unsigned int', `mode_t' and `time_t' are implemented as 32 32157 bit values in this protocol. 32158 32159 `long' and `unsigned long' are implemented as 64 bit types. 32160 32161 *Note Limits::, for corresponding MIN and MAX values (similar to 32162 those in `limits.h') to allow range checking on host and target. 32163 32164 `time_t' datatypes are defined as seconds since the Epoch. 32165 32166 All integral datatypes transferred as part of a memory read or write 32167 of a structured datatype e.g. a `struct stat' have to be given in big 32168 endian byte order. 32169 32170 32171 File: gdb.info, Node: Pointer Values, Next: Memory Transfer, Prev: Integral Datatypes, Up: Protocol-specific Representation of Datatypes 32172 32173 Pointer Values 32174 .............. 32175 32176 Pointers to target data are transmitted as they are. An exception is 32177 made for pointers to buffers for which the length isn't transmitted as 32178 part of the function call, namely strings. Strings are transmitted as 32179 a pointer/length pair, both as hex values, e.g. 32180 32181 `1aaf/12' 32182 32183 which is a pointer to data of length 18 bytes at position 0x1aaf. The 32184 length is defined as the full string length in bytes, including the 32185 trailing null byte. For example, the string `"hello world"' at address 32186 0x123456 is transmitted as 32187 32188 `123456/d' 32189 32190 32191 File: gdb.info, Node: Memory Transfer, Next: struct stat, Prev: Pointer Values, Up: Protocol-specific Representation of Datatypes 32192 32193 Memory Transfer 32194 ............... 32195 32196 Structured data which is transferred using a memory read or write (for 32197 example, a `struct stat') is expected to be in a protocol-specific 32198 format with all scalar multibyte datatypes being big endian. 32199 Translation to this representation needs to be done both by the target 32200 before the `F' packet is sent, and by GDB before it transfers memory to 32201 the target. Transferred pointers to structured data should point to 32202 the already-coerced data at any time. 32203 32204 32205 File: gdb.info, Node: struct stat, Next: struct timeval, Prev: Memory Transfer, Up: Protocol-specific Representation of Datatypes 32206 32207 struct stat 32208 ........... 32209 32210 The buffer of type `struct stat' used by the target and GDB is defined 32211 as follows: 32212 32213 struct stat { 32214 unsigned int st_dev; /* device */ 32215 unsigned int st_ino; /* inode */ 32216 mode_t st_mode; /* protection */ 32217 unsigned int st_nlink; /* number of hard links */ 32218 unsigned int st_uid; /* user ID of owner */ 32219 unsigned int st_gid; /* group ID of owner */ 32220 unsigned int st_rdev; /* device type (if inode device) */ 32221 unsigned long st_size; /* total size, in bytes */ 32222 unsigned long st_blksize; /* blocksize for filesystem I/O */ 32223 unsigned long st_blocks; /* number of blocks allocated */ 32224 time_t st_atime; /* time of last access */ 32225 time_t st_mtime; /* time of last modification */ 32226 time_t st_ctime; /* time of last change */ 32227 }; 32228 32229 The integral datatypes conform to the definitions given in the 32230 appropriate section (see *note Integral Datatypes::, for details) so 32231 this structure is of size 64 bytes. 32232 32233 The values of several fields have a restricted meaning and/or range 32234 of values. 32235 32236 `st_dev' 32237 A value of 0 represents a file, 1 the console. 32238 32239 `st_ino' 32240 No valid meaning for the target. Transmitted unchanged. 32241 32242 `st_mode' 32243 Valid mode bits are described in *note Constants::. Any other 32244 bits have currently no meaning for the target. 32245 32246 `st_uid' 32247 `st_gid' 32248 `st_rdev' 32249 No valid meaning for the target. Transmitted unchanged. 32250 32251 `st_atime' 32252 `st_mtime' 32253 `st_ctime' 32254 These values have a host and file system dependent accuracy. 32255 Especially on Windows hosts, the file system may not support exact 32256 timing values. 32257 32258 The target gets a `struct stat' of the above representation and is 32259 responsible for coercing it to the target representation before 32260 continuing. 32261 32262 Note that due to size differences between the host, target, and 32263 protocol representations of `struct stat' members, these members could 32264 eventually get truncated on the target. 32265 32266 32267 File: gdb.info, Node: struct timeval, Prev: struct stat, Up: Protocol-specific Representation of Datatypes 32268 32269 struct timeval 32270 .............. 32271 32272 The buffer of type `struct timeval' used by the File-I/O protocol is 32273 defined as follows: 32274 32275 struct timeval { 32276 time_t tv_sec; /* second */ 32277 long tv_usec; /* microsecond */ 32278 }; 32279 32280 The integral datatypes conform to the definitions given in the 32281 appropriate section (see *note Integral Datatypes::, for details) so 32282 this structure is of size 8 bytes. 32283 32284 32285 File: gdb.info, Node: Constants, Next: File-I/O Examples, Prev: Protocol-specific Representation of Datatypes, Up: File-I/O Remote Protocol Extension 32286 32287 E.13.9 Constants 32288 ---------------- 32289 32290 The following values are used for the constants inside of the protocol. 32291 GDB and target are responsible for translating these values before and 32292 after the call as needed. 32293 32294 * Menu: 32295 32296 * Open Flags:: 32297 * mode_t Values:: 32298 * Errno Values:: 32299 * Lseek Flags:: 32300 * Limits:: 32301 32302 32303 File: gdb.info, Node: Open Flags, Next: mode_t Values, Up: Constants 32304 32305 Open Flags 32306 .......... 32307 32308 All values are given in hexadecimal representation. 32309 32310 O_RDONLY 0x0 32311 O_WRONLY 0x1 32312 O_RDWR 0x2 32313 O_APPEND 0x8 32314 O_CREAT 0x200 32315 O_TRUNC 0x400 32316 O_EXCL 0x800 32317 32318 32319 File: gdb.info, Node: mode_t Values, Next: Errno Values, Prev: Open Flags, Up: Constants 32320 32321 mode_t Values 32322 ............. 32323 32324 All values are given in octal representation. 32325 32326 S_IFREG 0100000 32327 S_IFDIR 040000 32328 S_IRUSR 0400 32329 S_IWUSR 0200 32330 S_IXUSR 0100 32331 S_IRGRP 040 32332 S_IWGRP 020 32333 S_IXGRP 010 32334 S_IROTH 04 32335 S_IWOTH 02 32336 S_IXOTH 01 32337 32338 32339 File: gdb.info, Node: Errno Values, Next: Lseek Flags, Prev: mode_t Values, Up: Constants 32340 32341 Errno Values 32342 ............ 32343 32344 All values are given in decimal representation. 32345 32346 EPERM 1 32347 ENOENT 2 32348 EINTR 4 32349 EBADF 9 32350 EACCES 13 32351 EFAULT 14 32352 EBUSY 16 32353 EEXIST 17 32354 ENODEV 19 32355 ENOTDIR 20 32356 EISDIR 21 32357 EINVAL 22 32358 ENFILE 23 32359 EMFILE 24 32360 EFBIG 27 32361 ENOSPC 28 32362 ESPIPE 29 32363 EROFS 30 32364 ENAMETOOLONG 91 32365 EUNKNOWN 9999 32366 32367 `EUNKNOWN' is used as a fallback error value if a host system returns 32368 any error value not in the list of supported error numbers. 32369 32370 32371 File: gdb.info, Node: Lseek Flags, Next: Limits, Prev: Errno Values, Up: Constants 32372 32373 Lseek Flags 32374 ........... 32375 32376 SEEK_SET 0 32377 SEEK_CUR 1 32378 SEEK_END 2 32379 32380 32381 File: gdb.info, Node: Limits, Prev: Lseek Flags, Up: Constants 32382 32383 Limits 32384 ...... 32385 32386 All values are given in decimal representation. 32387 32388 INT_MIN -2147483648 32389 INT_MAX 2147483647 32390 UINT_MAX 4294967295 32391 LONG_MIN -9223372036854775808 32392 LONG_MAX 9223372036854775807 32393 ULONG_MAX 18446744073709551615 32394 32395 32396 File: gdb.info, Node: File-I/O Examples, Prev: Constants, Up: File-I/O Remote Protocol Extension 32397 32398 E.13.10 File-I/O Examples 32399 ------------------------- 32400 32401 Example sequence of a write call, file descriptor 3, buffer is at target 32402 address 0x1234, 6 bytes should be written: 32403 32404 <- `Fwrite,3,1234,6' 32405 _request memory read from target_ 32406 -> `m1234,6' 32407 <- XXXXXX 32408 _return "6 bytes written"_ 32409 -> `F6' 32410 32411 Example sequence of a read call, file descriptor 3, buffer is at 32412 target address 0x1234, 6 bytes should be read: 32413 32414 <- `Fread,3,1234,6' 32415 _request memory write to target_ 32416 -> `X1234,6:XXXXXX' 32417 _return "6 bytes read"_ 32418 -> `F6' 32419 32420 Example sequence of a read call, call fails on the host due to 32421 invalid file descriptor (`EBADF'): 32422 32423 <- `Fread,3,1234,6' 32424 -> `F-1,9' 32425 32426 Example sequence of a read call, user presses `Ctrl-c' before 32427 syscall on host is called: 32428 32429 <- `Fread,3,1234,6' 32430 -> `F-1,4,C' 32431 <- `T02' 32432 32433 Example sequence of a read call, user presses `Ctrl-c' after syscall 32434 on host is called: 32435 32436 <- `Fread,3,1234,6' 32437 -> `X1234,6:XXXXXX' 32438 <- `T02' 32439 32440 32441 File: gdb.info, Node: Library List Format, Next: Memory Map Format, Prev: File-I/O Remote Protocol Extension, Up: Remote Protocol 32442 32443 E.14 Library List Format 32444 ======================== 32445 32446 On some platforms, a dynamic loader (e.g. `ld.so') runs in the same 32447 process as your application to manage libraries. In this case, GDB can 32448 use the loader's symbol table and normal memory operations to maintain 32449 a list of shared libraries. On other platforms, the operating system 32450 manages loaded libraries. GDB can not retrieve the list of currently 32451 loaded libraries through memory operations, so it uses the 32452 `qXfer:libraries:read' packet (*note qXfer library list read::) 32453 instead. The remote stub queries the target's operating system and 32454 reports which libraries are loaded. 32455 32456 The `qXfer:libraries:read' packet returns an XML document which 32457 lists loaded libraries and their offsets. Each library has an 32458 associated name and one or more segment or section base addresses, 32459 which report where the library was loaded in memory. 32460 32461 For the common case of libraries that are fully linked binaries, the 32462 library should have a list of segments. If the target supports dynamic 32463 linking of a relocatable object file, its library XML element should 32464 instead include a list of allocated sections. The segment or section 32465 bases are start addresses, not relocation offsets; they do not depend 32466 on the library's link-time base addresses. 32467 32468 GDB must be linked with the Expat library to support XML library 32469 lists. *Note Expat::. 32470 32471 A simple memory map, with one loaded library relocated by a single 32472 offset, looks like this: 32473 32474 <library-list> 32475 <library name="/lib/libc.so.6"> 32476 <segment address="0x10000000"/> 32477 </library> 32478 </library-list> 32479 32480 Another simple memory map, with one loaded library with three 32481 allocated sections (.text, .data, .bss), looks like this: 32482 32483 <library-list> 32484 <library name="sharedlib.o"> 32485 <section address="0x10000000"/> 32486 <section address="0x20000000"/> 32487 <section address="0x30000000"/> 32488 </library> 32489 </library-list> 32490 32491 The format of a library list is described by this DTD: 32492 32493 <!-- library-list: Root element with versioning --> 32494 <!ELEMENT library-list (library)*> 32495 <!ATTLIST library-list version CDATA #FIXED "1.0"> 32496 <!ELEMENT library (segment*, section*)> 32497 <!ATTLIST library name CDATA #REQUIRED> 32498 <!ELEMENT segment EMPTY> 32499 <!ATTLIST segment address CDATA #REQUIRED> 32500 <!ELEMENT section EMPTY> 32501 <!ATTLIST section address CDATA #REQUIRED> 32502 32503 In addition, segments and section descriptors cannot be mixed within 32504 a single library element, and you must supply at least one segment or 32505 section for each library. 32506 32507 32508 File: gdb.info, Node: Memory Map Format, Next: Thread List Format, Prev: Library List Format, Up: Remote Protocol 32509 32510 E.15 Memory Map Format 32511 ====================== 32512 32513 To be able to write into flash memory, GDB needs to obtain a memory map 32514 from the target. This section describes the format of the memory map. 32515 32516 The memory map is obtained using the `qXfer:memory-map:read' (*note 32517 qXfer memory map read::) packet and is an XML document that lists 32518 memory regions. 32519 32520 GDB must be linked with the Expat library to support XML memory 32521 maps. *Note Expat::. 32522 32523 The top-level structure of the document is shown below: 32524 32525 <?xml version="1.0"?> 32526 <!DOCTYPE memory-map 32527 PUBLIC "+//IDN gnu.org//DTD GDB Memory Map V1.0//EN" 32528 "http://sourceware.org/gdb/gdb-memory-map.dtd"> 32529 <memory-map> 32530 region... 32531 </memory-map> 32532 32533 Each region can be either: 32534 32535 * A region of RAM starting at ADDR and extending for LENGTH bytes 32536 from there: 32537 32538 <memory type="ram" start="ADDR" length="LENGTH"/> 32539 32540 * A region of read-only memory: 32541 32542 <memory type="rom" start="ADDR" length="LENGTH"/> 32543 32544 * A region of flash memory, with erasure blocks BLOCKSIZE bytes in 32545 length: 32546 32547 <memory type="flash" start="ADDR" length="LENGTH"> 32548 <property name="blocksize">BLOCKSIZE</property> 32549 </memory> 32550 32551 32552 Regions must not overlap. GDB assumes that areas of memory not 32553 covered by the memory map are RAM, and uses the ordinary `M' and `X' 32554 packets to write to addresses in such ranges. 32555 32556 The formal DTD for memory map format is given below: 32557 32558 <!-- ................................................... --> 32559 <!-- Memory Map XML DTD ................................ --> 32560 <!-- File: memory-map.dtd .............................. --> 32561 <!-- .................................... .............. --> 32562 <!-- memory-map.dtd --> 32563 <!-- memory-map: Root element with versioning --> 32564 <!ELEMENT memory-map (memory | property)> 32565 <!ATTLIST memory-map version CDATA #FIXED "1.0.0"> 32566 <!ELEMENT memory (property)> 32567 <!-- memory: Specifies a memory region, 32568 and its type, or device. --> 32569 <!ATTLIST memory type CDATA #REQUIRED 32570 start CDATA #REQUIRED 32571 length CDATA #REQUIRED 32572 device CDATA #IMPLIED> 32573 <!-- property: Generic attribute tag --> 32574 <!ELEMENT property (#PCDATA | property)*> 32575 <!ATTLIST property name CDATA #REQUIRED> 32576 32577 32578 File: gdb.info, Node: Thread List Format, Next: Traceframe Info Format, Prev: Memory Map Format, Up: Remote Protocol 32579 32580 E.16 Thread List Format 32581 ======================= 32582 32583 To efficiently update the list of threads and their attributes, GDB 32584 issues the `qXfer:threads:read' packet (*note qXfer threads read::) and 32585 obtains the XML document with the following structure: 32586 32587 <?xml version="1.0"?> 32588 <threads> 32589 <thread id="id" core="0"> 32590 ... description ... 32591 </thread> 32592 </threads> 32593 32594 Each `thread' element must have the `id' attribute that identifies 32595 the thread (*note thread-id syntax::). The `core' attribute, if 32596 present, specifies which processor core the thread was last executing 32597 on. The content of the of `thread' element is interpreted as 32598 human-readable auxilliary information. 32599 32600 32601 File: gdb.info, Node: Traceframe Info Format, Prev: Thread List Format, Up: Remote Protocol 32602 32603 E.17 Traceframe Info Format 32604 =========================== 32605 32606 To be able to know which objects in the inferior can be examined when 32607 inspecting a tracepoint hit, GDB needs to obtain the list of memory 32608 ranges, registers and trace state variables that have been collected in 32609 a traceframe. 32610 32611 This list is obtained using the `qXfer:traceframe-info:read' (*note 32612 qXfer traceframe info read::) packet and is an XML document. 32613 32614 GDB must be linked with the Expat library to support XML traceframe 32615 info discovery. *Note Expat::. 32616 32617 The top-level structure of the document is shown below: 32618 32619 <?xml version="1.0"?> 32620 <!DOCTYPE traceframe-info 32621 PUBLIC "+//IDN gnu.org//DTD GDB Memory Map V1.0//EN" 32622 "http://sourceware.org/gdb/gdb-traceframe-info.dtd"> 32623 <traceframe-info> 32624 block... 32625 </traceframe-info> 32626 32627 Each traceframe block can be either: 32628 32629 * A region of collected memory starting at ADDR and extending for 32630 LENGTH bytes from there: 32631 32632 <memory start="ADDR" length="LENGTH"/> 32633 32634 32635 The formal DTD for the traceframe info format is given below: 32636 32637 <!ELEMENT traceframe-info (memory)* > 32638 <!ATTLIST traceframe-info version CDATA #FIXED "1.0"> 32639 32640 <!ELEMENT memory EMPTY> 32641 <!ATTLIST memory start CDATA #REQUIRED 32642 length CDATA #REQUIRED> 32643 32644 32645 File: gdb.info, Node: Agent Expressions, Next: Target Descriptions, Prev: Remote Protocol, Up: Top 32646 32647 Appendix F The GDB Agent Expression Mechanism 32648 ********************************************* 32649 32650 In some applications, it is not feasible for the debugger to interrupt 32651 the program's execution long enough for the developer to learn anything 32652 helpful about its behavior. If the program's correctness depends on its 32653 real-time behavior, delays introduced by a debugger might cause the 32654 program to fail, even when the code itself is correct. It is useful to 32655 be able to observe the program's behavior without interrupting it. 32656 32657 Using GDB's `trace' and `collect' commands, the user can specify 32658 locations in the program, and arbitrary expressions to evaluate when 32659 those locations are reached. Later, using the `tfind' command, she can 32660 examine the values those expressions had when the program hit the trace 32661 points. The expressions may also denote objects in memory -- 32662 structures or arrays, for example -- whose values GDB should record; 32663 while visiting a particular tracepoint, the user may inspect those 32664 objects as if they were in memory at that moment. However, because GDB 32665 records these values without interacting with the user, it can do so 32666 quickly and unobtrusively, hopefully not disturbing the program's 32667 behavior. 32668 32669 When GDB is debugging a remote target, the GDB "agent" code running 32670 on the target computes the values of the expressions itself. To avoid 32671 having a full symbolic expression evaluator on the agent, GDB translates 32672 expressions in the source language into a simpler bytecode language, and 32673 then sends the bytecode to the agent; the agent then executes the 32674 bytecode, and records the values for GDB to retrieve later. 32675 32676 The bytecode language is simple; there are forty-odd opcodes, the 32677 bulk of which are the usual vocabulary of C operands (addition, 32678 subtraction, shifts, and so on) and various sizes of literals and 32679 memory reference operations. The bytecode interpreter operates 32680 strictly on machine-level values -- various sizes of integers and 32681 floating point numbers -- and requires no information about types or 32682 symbols; thus, the interpreter's internal data structures are simple, 32683 and each bytecode requires only a few native machine instructions to 32684 implement it. The interpreter is small, and strict limits on the 32685 memory and time required to evaluate an expression are easy to 32686 determine, making it suitable for use by the debugging agent in 32687 real-time applications. 32688 32689 * Menu: 32690 32691 * General Bytecode Design:: Overview of the interpreter. 32692 * Bytecode Descriptions:: What each one does. 32693 * Using Agent Expressions:: How agent expressions fit into the big picture. 32694 * Varying Target Capabilities:: How to discover what the target can do. 32695 * Rationale:: Why we did it this way. 32696 32697 32698 File: gdb.info, Node: General Bytecode Design, Next: Bytecode Descriptions, Up: Agent Expressions 32699 32700 F.1 General Bytecode Design 32701 =========================== 32702 32703 The agent represents bytecode expressions as an array of bytes. Each 32704 instruction is one byte long (thus the term "bytecode"). Some 32705 instructions are followed by operand bytes; for example, the `goto' 32706 instruction is followed by a destination for the jump. 32707 32708 The bytecode interpreter is a stack-based machine; most instructions 32709 pop their operands off the stack, perform some operation, and push the 32710 result back on the stack for the next instruction to consume. Each 32711 element of the stack may contain either a integer or a floating point 32712 value; these values are as many bits wide as the largest integer that 32713 can be directly manipulated in the source language. Stack elements 32714 carry no record of their type; bytecode could push a value as an 32715 integer, then pop it as a floating point value. However, GDB will not 32716 generate code which does this. In C, one might define the type of a 32717 stack element as follows: 32718 union agent_val { 32719 LONGEST l; 32720 DOUBLEST d; 32721 }; 32722 where `LONGEST' and `DOUBLEST' are `typedef' names for the largest 32723 integer and floating point types on the machine. 32724 32725 By the time the bytecode interpreter reaches the end of the 32726 expression, the value of the expression should be the only value left 32727 on the stack. For tracing applications, `trace' bytecodes in the 32728 expression will have recorded the necessary data, and the value on the 32729 stack may be discarded. For other applications, like conditional 32730 breakpoints, the value may be useful. 32731 32732 Separate from the stack, the interpreter has two registers: 32733 `pc' 32734 The address of the next bytecode to execute. 32735 32736 `start' 32737 The address of the start of the bytecode expression, necessary for 32738 interpreting the `goto' and `if_goto' instructions. 32739 32740 Neither of these registers is directly visible to the bytecode 32741 language itself, but they are useful for defining the meanings of the 32742 bytecode operations. 32743 32744 There are no instructions to perform side effects on the running 32745 program, or call the program's functions; we assume that these 32746 expressions are only used for unobtrusive debugging, not for patching 32747 the running code. 32748 32749 Most bytecode instructions do not distinguish between the various 32750 sizes of values, and operate on full-width values; the upper bits of the 32751 values are simply ignored, since they do not usually make a difference 32752 to the value computed. The exceptions to this rule are: 32753 memory reference instructions (`ref'N) 32754 There are distinct instructions to fetch different word sizes from 32755 memory. Once on the stack, however, the values are treated as 32756 full-size integers. They may need to be sign-extended; the `ext' 32757 instruction exists for this purpose. 32758 32759 the sign-extension instruction (`ext' N) 32760 These clearly need to know which portion of their operand is to be 32761 extended to occupy the full length of the word. 32762 32763 32764 If the interpreter is unable to evaluate an expression completely for 32765 some reason (a memory location is inaccessible, or a divisor is zero, 32766 for example), we say that interpretation "terminates with an error". 32767 This means that the problem is reported back to the interpreter's caller 32768 in some helpful way. In general, code using agent expressions should 32769 assume that they may attempt to divide by zero, fetch arbitrary memory 32770 locations, and misbehave in other ways. 32771 32772 Even complicated C expressions compile to a few bytecode 32773 instructions; for example, the expression `x + y * z' would typically 32774 produce code like the following, assuming that `x' and `y' live in 32775 registers, and `z' is a global variable holding a 32-bit `int': 32776 reg 1 32777 reg 2 32778 const32 address of z 32779 ref32 32780 ext 32 32781 mul 32782 add 32783 end 32784 32785 In detail, these mean: 32786 `reg 1' 32787 Push the value of register 1 (presumably holding `x') onto the 32788 stack. 32789 32790 `reg 2' 32791 Push the value of register 2 (holding `y'). 32792 32793 `const32 address of z' 32794 Push the address of `z' onto the stack. 32795 32796 `ref32' 32797 Fetch a 32-bit word from the address at the top of the stack; 32798 replace the address on the stack with the value. Thus, we replace 32799 the address of `z' with `z''s value. 32800 32801 `ext 32' 32802 Sign-extend the value on the top of the stack from 32 bits to full 32803 length. This is necessary because `z' is a signed integer. 32804 32805 `mul' 32806 Pop the top two numbers on the stack, multiply them, and push their 32807 product. Now the top of the stack contains the value of the 32808 expression `y * z'. 32809 32810 `add' 32811 Pop the top two numbers, add them, and push the sum. Now the top 32812 of the stack contains the value of `x + y * z'. 32813 32814 `end' 32815 Stop executing; the value left on the stack top is the value to be 32816 recorded. 32817 32818 32819 32820 File: gdb.info, Node: Bytecode Descriptions, Next: Using Agent Expressions, Prev: General Bytecode Design, Up: Agent Expressions 32821 32822 F.2 Bytecode Descriptions 32823 ========================= 32824 32825 Each bytecode description has the following form: 32826 32827 `add' (0x02): A B => A+B 32828 Pop the top two stack items, A and B, as integers; push their sum, 32829 as an integer. 32830 32831 32832 In this example, `add' is the name of the bytecode, and `(0x02)' is 32833 the one-byte value used to encode the bytecode, in hexadecimal. The 32834 phrase "A B => A+B" shows the stack before and after the bytecode 32835 executes. Beforehand, the stack must contain at least two values, A 32836 and B; since the top of the stack is to the right, B is on the top of 32837 the stack, and A is underneath it. After execution, the bytecode will 32838 have popped A and B from the stack, and replaced them with a single 32839 value, A+B. There may be other values on the stack below those shown, 32840 but the bytecode affects only those shown. 32841 32842 Here is another example: 32843 32844 `const8' (0x22) N: => N 32845 Push the 8-bit integer constant N on the stack, without sign 32846 extension. 32847 32848 32849 In this example, the bytecode `const8' takes an operand N directly 32850 from the bytecode stream; the operand follows the `const8' bytecode 32851 itself. We write any such operands immediately after the name of the 32852 bytecode, before the colon, and describe the exact encoding of the 32853 operand in the bytecode stream in the body of the bytecode description. 32854 32855 For the `const8' bytecode, there are no stack items given before the 32856 =>; this simply means that the bytecode consumes no values from the 32857 stack. If a bytecode consumes no values, or produces no values, the 32858 list on either side of the => may be empty. 32859 32860 If a value is written as A, B, or N, then the bytecode treats it as 32861 an integer. If a value is written is ADDR, then the bytecode treats it 32862 as an address. 32863 32864 We do not fully describe the floating point operations here; although 32865 this design can be extended in a clean way to handle floating point 32866 values, they are not of immediate interest to the customer, so we avoid 32867 describing them, to save time. 32868 32869 `float' (0x01): => 32870 Prefix for floating-point bytecodes. Not implemented yet. 32871 32872 `add' (0x02): A B => A+B 32873 Pop two integers from the stack, and push their sum, as an integer. 32874 32875 `sub' (0x03): A B => A-B 32876 Pop two integers from the stack, subtract the top value from the 32877 next-to-top value, and push the difference. 32878 32879 `mul' (0x04): A B => A*B 32880 Pop two integers from the stack, multiply them, and push the 32881 product on the stack. Note that, when one multiplies two N-bit 32882 numbers yielding another N-bit number, it is irrelevant whether the 32883 numbers are signed or not; the results are the same. 32884 32885 `div_signed' (0x05): A B => A/B 32886 Pop two signed integers from the stack; divide the next-to-top 32887 value by the top value, and push the quotient. If the divisor is 32888 zero, terminate with an error. 32889 32890 `div_unsigned' (0x06): A B => A/B 32891 Pop two unsigned integers from the stack; divide the next-to-top 32892 value by the top value, and push the quotient. If the divisor is 32893 zero, terminate with an error. 32894 32895 `rem_signed' (0x07): A B => A MODULO B 32896 Pop two signed integers from the stack; divide the next-to-top 32897 value by the top value, and push the remainder. If the divisor is 32898 zero, terminate with an error. 32899 32900 `rem_unsigned' (0x08): A B => A MODULO B 32901 Pop two unsigned integers from the stack; divide the next-to-top 32902 value by the top value, and push the remainder. If the divisor is 32903 zero, terminate with an error. 32904 32905 `lsh' (0x09): A B => A<<B 32906 Pop two integers from the stack; let A be the next-to-top value, 32907 and B be the top value. Shift A left by B bits, and push the 32908 result. 32909 32910 `rsh_signed' (0x0a): A B => `(signed)'A>>B 32911 Pop two integers from the stack; let A be the next-to-top value, 32912 and B be the top value. Shift A right by B bits, inserting copies 32913 of the top bit at the high end, and push the result. 32914 32915 `rsh_unsigned' (0x0b): A B => A>>B 32916 Pop two integers from the stack; let A be the next-to-top value, 32917 and B be the top value. Shift A right by B bits, inserting zero 32918 bits at the high end, and push the result. 32919 32920 `log_not' (0x0e): A => !A 32921 Pop an integer from the stack; if it is zero, push the value one; 32922 otherwise, push the value zero. 32923 32924 `bit_and' (0x0f): A B => A&B 32925 Pop two integers from the stack, and push their bitwise `and'. 32926 32927 `bit_or' (0x10): A B => A|B 32928 Pop two integers from the stack, and push their bitwise `or'. 32929 32930 `bit_xor' (0x11): A B => A^B 32931 Pop two integers from the stack, and push their bitwise 32932 exclusive-`or'. 32933 32934 `bit_not' (0x12): A => ~A 32935 Pop an integer from the stack, and push its bitwise complement. 32936 32937 `equal' (0x13): A B => A=B 32938 Pop two integers from the stack; if they are equal, push the value 32939 one; otherwise, push the value zero. 32940 32941 `less_signed' (0x14): A B => A<B 32942 Pop two signed integers from the stack; if the next-to-top value 32943 is less than the top value, push the value one; otherwise, push 32944 the value zero. 32945 32946 `less_unsigned' (0x15): A B => A<B 32947 Pop two unsigned integers from the stack; if the next-to-top value 32948 is less than the top value, push the value one; otherwise, push 32949 the value zero. 32950 32951 `ext' (0x16) N: A => A, sign-extended from N bits 32952 Pop an unsigned value from the stack; treating it as an N-bit 32953 twos-complement value, extend it to full length. This means that 32954 all bits to the left of bit N-1 (where the least significant bit 32955 is bit 0) are set to the value of bit N-1. Note that N may be 32956 larger than or equal to the width of the stack elements of the 32957 bytecode engine; in this case, the bytecode should have no effect. 32958 32959 The number of source bits to preserve, N, is encoded as a single 32960 byte unsigned integer following the `ext' bytecode. 32961 32962 `zero_ext' (0x2a) N: A => A, zero-extended from N bits 32963 Pop an unsigned value from the stack; zero all but the bottom N 32964 bits. This means that all bits to the left of bit N-1 (where the 32965 least significant bit is bit 0) are set to the value of bit N-1. 32966 32967 The number of source bits to preserve, N, is encoded as a single 32968 byte unsigned integer following the `zero_ext' bytecode. 32969 32970 `ref8' (0x17): ADDR => A 32971 `ref16' (0x18): ADDR => A 32972 `ref32' (0x19): ADDR => A 32973 `ref64' (0x1a): ADDR => A 32974 Pop an address ADDR from the stack. For bytecode `ref'N, fetch an 32975 N-bit value from ADDR, using the natural target endianness. Push 32976 the fetched value as an unsigned integer. 32977 32978 Note that ADDR may not be aligned in any particular way; the 32979 `refN' bytecodes should operate correctly for any address. 32980 32981 If attempting to access memory at ADDR would cause a processor 32982 exception of some sort, terminate with an error. 32983 32984 `ref_float' (0x1b): ADDR => D 32985 `ref_double' (0x1c): ADDR => D 32986 `ref_long_double' (0x1d): ADDR => D 32987 `l_to_d' (0x1e): A => D 32988 `d_to_l' (0x1f): D => A 32989 Not implemented yet. 32990 32991 `dup' (0x28): A => A A 32992 Push another copy of the stack's top element. 32993 32994 `swap' (0x2b): A B => B A 32995 Exchange the top two items on the stack. 32996 32997 `pop' (0x29): A => 32998 Discard the top value on the stack. 32999 33000 `pick' (0x32) N: A ... B => A ... B A 33001 Duplicate an item from the stack and push it on the top of the 33002 stack. N, a single byte, indicates the stack item to copy. If N 33003 is zero, this is the same as `dup'; if N is one, it copies the 33004 item under the top item, etc. If N exceeds the number of items on 33005 the stack, terminate with an error. 33006 33007 `rot' (0x33): A B C => C B A 33008 Rotate the top three items on the stack. 33009 33010 `if_goto' (0x20) OFFSET: A => 33011 Pop an integer off the stack; if it is non-zero, branch to the 33012 given offset in the bytecode string. Otherwise, continue to the 33013 next instruction in the bytecode stream. In other words, if A is 33014 non-zero, set the `pc' register to `start' + OFFSET. Thus, an 33015 offset of zero denotes the beginning of the expression. 33016 33017 The OFFSET is stored as a sixteen-bit unsigned value, stored 33018 immediately following the `if_goto' bytecode. It is always stored 33019 most significant byte first, regardless of the target's normal 33020 endianness. The offset is not guaranteed to fall at any particular 33021 alignment within the bytecode stream; thus, on machines where 33022 fetching a 16-bit on an unaligned address raises an exception, you 33023 should fetch the offset one byte at a time. 33024 33025 `goto' (0x21) OFFSET: => 33026 Branch unconditionally to OFFSET; in other words, set the `pc' 33027 register to `start' + OFFSET. 33028 33029 The offset is stored in the same way as for the `if_goto' bytecode. 33030 33031 `const8' (0x22) N: => N 33032 `const16' (0x23) N: => N 33033 `const32' (0x24) N: => N 33034 `const64' (0x25) N: => N 33035 Push the integer constant N on the stack, without sign extension. 33036 To produce a small negative value, push a small twos-complement 33037 value, and then sign-extend it using the `ext' bytecode. 33038 33039 The constant N is stored in the appropriate number of bytes 33040 following the `const'B bytecode. The constant N is always stored 33041 most significant byte first, regardless of the target's normal 33042 endianness. The constant is not guaranteed to fall at any 33043 particular alignment within the bytecode stream; thus, on machines 33044 where fetching a 16-bit on an unaligned address raises an 33045 exception, you should fetch N one byte at a time. 33046 33047 `reg' (0x26) N: => A 33048 Push the value of register number N, without sign extension. The 33049 registers are numbered following GDB's conventions. 33050 33051 The register number N is encoded as a 16-bit unsigned integer 33052 immediately following the `reg' bytecode. It is always stored most 33053 significant byte first, regardless of the target's normal 33054 endianness. The register number is not guaranteed to fall at any 33055 particular alignment within the bytecode stream; thus, on machines 33056 where fetching a 16-bit on an unaligned address raises an 33057 exception, you should fetch the register number one byte at a time. 33058 33059 `getv' (0x2c) N: => V 33060 Push the value of trace state variable number N, without sign 33061 extension. 33062 33063 The variable number N is encoded as a 16-bit unsigned integer 33064 immediately following the `getv' bytecode. It is always stored 33065 most significant byte first, regardless of the target's normal 33066 endianness. The variable number is not guaranteed to fall at any 33067 particular alignment within the bytecode stream; thus, on machines 33068 where fetching a 16-bit on an unaligned address raises an 33069 exception, you should fetch the register number one byte at a time. 33070 33071 `setv' (0x2d) N: => V 33072 Set trace state variable number N to the value found on the top of 33073 the stack. The stack is unchanged, so that the value is readily 33074 available if the assignment is part of a larger expression. The 33075 handling of N is as described for `getv'. 33076 33077 `trace' (0x0c): ADDR SIZE => 33078 Record the contents of the SIZE bytes at ADDR in a trace buffer, 33079 for later retrieval by GDB. 33080 33081 `trace_quick' (0x0d) SIZE: ADDR => ADDR 33082 Record the contents of the SIZE bytes at ADDR in a trace buffer, 33083 for later retrieval by GDB. SIZE is a single byte unsigned 33084 integer following the `trace' opcode. 33085 33086 This bytecode is equivalent to the sequence `dup const8 SIZE 33087 trace', but we provide it anyway to save space in bytecode strings. 33088 33089 `trace16' (0x30) SIZE: ADDR => ADDR 33090 Identical to trace_quick, except that SIZE is a 16-bit big-endian 33091 unsigned integer, not a single byte. This should probably have 33092 been named `trace_quick16', for consistency. 33093 33094 `tracev' (0x2e) N: => A 33095 Record the value of trace state variable number N in the trace 33096 buffer. The handling of N is as described for `getv'. 33097 33098 `end' (0x27): => 33099 Stop executing bytecode; the result should be the top element of 33100 the stack. If the purpose of the expression was to compute an 33101 lvalue or a range of memory, then the next-to-top of the stack is 33102 the lvalue's address, and the top of the stack is the lvalue's 33103 size, in bytes. 33104 33105 33106 33107 File: gdb.info, Node: Using Agent Expressions, Next: Varying Target Capabilities, Prev: Bytecode Descriptions, Up: Agent Expressions 33108 33109 F.3 Using Agent Expressions 33110 =========================== 33111 33112 Agent expressions can be used in several different ways by GDB, and the 33113 debugger can generate different bytecode sequences as appropriate. 33114 33115 One possibility is to do expression evaluation on the target rather 33116 than the host, such as for the conditional of a conditional tracepoint. 33117 In such a case, GDB compiles the source expression into a bytecode 33118 sequence that simply gets values from registers or memory, does 33119 arithmetic, and returns a result. 33120 33121 Another way to use agent expressions is for tracepoint data 33122 collection. GDB generates a different bytecode sequence for 33123 collection; in addition to bytecodes that do the calculation, GDB adds 33124 `trace' bytecodes to save the pieces of memory that were used. 33125 33126 * The user selects trace points in the program's code at which GDB 33127 should collect data. 33128 33129 * The user specifies expressions to evaluate at each trace point. 33130 These expressions may denote objects in memory, in which case 33131 those objects' contents are recorded as the program runs, or 33132 computed values, in which case the values themselves are recorded. 33133 33134 * GDB transmits the tracepoints and their associated expressions to 33135 the GDB agent, running on the debugging target. 33136 33137 * The agent arranges to be notified when a trace point is hit. 33138 33139 * When execution on the target reaches a trace point, the agent 33140 evaluates the expressions associated with that trace point, and 33141 records the resulting values and memory ranges. 33142 33143 * Later, when the user selects a given trace event and inspects the 33144 objects and expression values recorded, GDB talks to the agent to 33145 retrieve recorded data as necessary to meet the user's requests. 33146 If the user asks to see an object whose contents have not been 33147 recorded, GDB reports an error. 33148 33149 33150 33151 File: gdb.info, Node: Varying Target Capabilities, Next: Rationale, Prev: Using Agent Expressions, Up: Agent Expressions 33152 33153 F.4 Varying Target Capabilities 33154 =============================== 33155 33156 Some targets don't support floating-point, and some would rather not 33157 have to deal with `long long' operations. Also, different targets will 33158 have different stack sizes, and different bytecode buffer lengths. 33159 33160 Thus, GDB needs a way to ask the target about itself. We haven't 33161 worked out the details yet, but in general, GDB should be able to send 33162 the target a packet asking it to describe itself. The reply should be a 33163 packet whose length is explicit, so we can add new information to the 33164 packet in future revisions of the agent, without confusing old versions 33165 of GDB, and it should contain a version number. It should contain at 33166 least the following information: 33167 33168 * whether floating point is supported 33169 33170 * whether `long long' is supported 33171 33172 * maximum acceptable size of bytecode stack 33173 33174 * maximum acceptable length of bytecode expressions 33175 33176 * which registers are actually available for collection 33177 33178 * whether the target supports disabled tracepoints 33179 33180 33181 33182 File: gdb.info, Node: Rationale, Prev: Varying Target Capabilities, Up: Agent Expressions 33183 33184 F.5 Rationale 33185 ============= 33186 33187 Some of the design decisions apparent above are arguable. 33188 33189 What about stack overflow/underflow? 33190 GDB should be able to query the target to discover its stack size. 33191 Given that information, GDB can determine at translation time 33192 whether a given expression will overflow the stack. But this spec 33193 isn't about what kinds of error-checking GDB ought to do. 33194 33195 Why are you doing everything in LONGEST? 33196 Speed isn't important, but agent code size is; using LONGEST 33197 brings in a bunch of support code to do things like division, etc. 33198 So this is a serious concern. 33199 33200 First, note that you don't need different bytecodes for different 33201 operand sizes. You can generate code without _knowing_ how big the 33202 stack elements actually are on the target. If the target only 33203 supports 32-bit ints, and you don't send any 64-bit bytecodes, 33204 everything just works. The observation here is that the MIPS and 33205 the Alpha have only fixed-size registers, and you can still get 33206 C's semantics even though most instructions only operate on 33207 full-sized words. You just need to make sure everything is 33208 properly sign-extended at the right times. So there is no need 33209 for 32- and 64-bit variants of the bytecodes. Just implement 33210 everything using the largest size you support. 33211 33212 GDB should certainly check to see what sizes the target supports, 33213 so the user can get an error earlier, rather than later. But this 33214 information is not necessary for correctness. 33215 33216 Why don't you have `>' or `<=' operators? 33217 I want to keep the interpreter small, and we don't need them. We 33218 can combine the `less_' opcodes with `log_not', and swap the order 33219 of the operands, yielding all four asymmetrical comparison 33220 operators. For example, `(x <= y)' is `! (x > y)', which is `! (y 33221 < x)'. 33222 33223 Why do you have `log_not'? 33224 Why do you have `ext'? 33225 Why do you have `zero_ext'? 33226 These are all easily synthesized from other instructions, but I 33227 expect them to be used frequently, and they're simple, so I 33228 include them to keep bytecode strings short. 33229 33230 `log_not' is equivalent to `const8 0 equal'; it's used in half the 33231 relational operators. 33232 33233 `ext N' is equivalent to `const8 S-N lsh const8 S-N rsh_signed', 33234 where S is the size of the stack elements; it follows `refM' and 33235 REG bytecodes when the value should be signed. See the next 33236 bulleted item. 33237 33238 `zero_ext N' is equivalent to `constM MASK log_and'; it's used 33239 whenever we push the value of a register, because we can't assume 33240 the upper bits of the register aren't garbage. 33241 33242 Why not have sign-extending variants of the `ref' operators? 33243 Because that would double the number of `ref' operators, and we 33244 need the `ext' bytecode anyway for accessing bitfields. 33245 33246 Why not have constant-address variants of the `ref' operators? 33247 Because that would double the number of `ref' operators again, and 33248 `const32 ADDRESS ref32' is only one byte longer. 33249 33250 Why do the `refN' operators have to support unaligned fetches? 33251 GDB will generate bytecode that fetches multi-byte values at 33252 unaligned addresses whenever the executable's debugging 33253 information tells it to. Furthermore, GDB does not know the value 33254 the pointer will have when GDB generates the bytecode, so it 33255 cannot determine whether a particular fetch will be aligned or not. 33256 33257 In particular, structure bitfields may be several bytes long, but 33258 follow no alignment rules; members of packed structures are not 33259 necessarily aligned either. 33260 33261 In general, there are many cases where unaligned references occur 33262 in correct C code, either at the programmer's explicit request, or 33263 at the compiler's discretion. Thus, it is simpler to make the GDB 33264 agent bytecodes work correctly in all circumstances than to make 33265 GDB guess in each case whether the compiler did the usual thing. 33266 33267 Why are there no side-effecting operators? 33268 Because our current client doesn't want them? That's a cheap 33269 answer. I think the real answer is that I'm afraid of 33270 implementing function calls. We should re-visit this issue after 33271 the present contract is delivered. 33272 33273 Why aren't the `goto' ops PC-relative? 33274 The interpreter has the base address around anyway for PC bounds 33275 checking, and it seemed simpler. 33276 33277 Why is there only one offset size for the `goto' ops? 33278 Offsets are currently sixteen bits. I'm not happy with this 33279 situation either: 33280 33281 Suppose we have multiple branch ops with different offset sizes. 33282 As I generate code left-to-right, all my jumps are forward jumps 33283 (there are no loops in expressions), so I never know the target 33284 when I emit the jump opcode. Thus, I have to either always assume 33285 the largest offset size, or do jump relaxation on the code after I 33286 generate it, which seems like a big waste of time. 33287 33288 I can imagine a reasonable expression being longer than 256 bytes. 33289 I can't imagine one being longer than 64k. Thus, we need 16-bit 33290 offsets. This kind of reasoning is so bogus, but relaxation is 33291 pathetic. 33292 33293 The other approach would be to generate code right-to-left. Then 33294 I'd always know my offset size. That might be fun. 33295 33296 Where is the function call bytecode? 33297 When we add side-effects, we should add this. 33298 33299 Why does the `reg' bytecode take a 16-bit register number? 33300 Intel's IA-64 architecture has 128 general-purpose registers, and 33301 128 floating-point registers, and I'm sure it has some random 33302 control registers. 33303 33304 Why do we need `trace' and `trace_quick'? 33305 Because GDB needs to record all the memory contents and registers 33306 an expression touches. If the user wants to evaluate an expression 33307 `x->y->z', the agent must record the values of `x' and `x->y' as 33308 well as the value of `x->y->z'. 33309 33310 Don't the `trace' bytecodes make the interpreter less general? 33311 They do mean that the interpreter contains special-purpose code, 33312 but that doesn't mean the interpreter can only be used for that 33313 purpose. If an expression doesn't use the `trace' bytecodes, they 33314 don't get in its way. 33315 33316 Why doesn't `trace_quick' consume its arguments the way everything else does? 33317 In general, you do want your operators to consume their arguments; 33318 it's consistent, and generally reduces the amount of stack 33319 rearrangement necessary. However, `trace_quick' is a kludge to 33320 save space; it only exists so we needn't write `dup const8 SIZE 33321 trace' before every memory reference. Therefore, it's okay for it 33322 not to consume its arguments; it's meant for a specific context in 33323 which we know exactly what it should do with the stack. If we're 33324 going to have a kludge, it should be an effective kludge. 33325 33326 Why does `trace16' exist? 33327 That opcode was added by the customer that contracted Cygnus for 33328 the data tracing work. I personally think it is unnecessary; 33329 objects that large will be quite rare, so it is okay to use `dup 33330 const16 SIZE trace' in those cases. 33331 33332 Whatever we decide to do with `trace16', we should at least leave 33333 opcode 0x30 reserved, to remain compatible with the customer who 33334 added it. 33335 33336 33337 33338 File: gdb.info, Node: Target Descriptions, Next: Operating System Information, Prev: Agent Expressions, Up: Top 33339 33340 Appendix G Target Descriptions 33341 ****************************** 33342 33343 *Warning:* target descriptions are still under active development, and 33344 the contents and format may change between GDB releases. The format is 33345 expected to stabilize in the future. 33346 33347 One of the challenges of using GDB to debug embedded systems is that 33348 there are so many minor variants of each processor architecture in use. 33349 It is common practice for vendors to start with a standard processor 33350 core -- ARM, PowerPC, or MIPS, for example -- and then make changes to 33351 adapt it to a particular market niche. Some architectures have 33352 hundreds of variants, available from dozens of vendors. This leads to 33353 a number of problems: 33354 33355 * With so many different customized processors, it is difficult for 33356 the GDB maintainers to keep up with the changes. 33357 33358 * Since individual variants may have short lifetimes or limited 33359 audiences, it may not be worthwhile to carry information about 33360 every variant in the GDB source tree. 33361 33362 * When GDB does support the architecture of the embedded system at 33363 hand, the task of finding the correct architecture name to give the 33364 `set architecture' command can be error-prone. 33365 33366 To address these problems, the GDB remote protocol allows a target 33367 system to not only identify itself to GDB, but to actually describe its 33368 own features. This lets GDB support processor variants it has never 33369 seen before -- to the extent that the descriptions are accurate, and 33370 that GDB understands them. 33371 33372 GDB must be linked with the Expat library to support XML target 33373 descriptions. *Note Expat::. 33374 33375 * Menu: 33376 33377 * Retrieving Descriptions:: How descriptions are fetched from a target. 33378 * Target Description Format:: The contents of a target description. 33379 * Predefined Target Types:: Standard types available for target 33380 descriptions. 33381 * Standard Target Features:: Features GDB knows about. 33382 33383 33384 File: gdb.info, Node: Retrieving Descriptions, Next: Target Description Format, Up: Target Descriptions 33385 33386 G.1 Retrieving Descriptions 33387 =========================== 33388 33389 Target descriptions can be read from the target automatically, or 33390 specified by the user manually. The default behavior is to read the 33391 description from the target. GDB retrieves it via the remote protocol 33392 using `qXfer' requests (*note qXfer: General Query Packets.). The 33393 ANNEX in the `qXfer' packet will be `target.xml'. The contents of the 33394 `target.xml' annex are an XML document, of the form described in *note 33395 Target Description Format::. 33396 33397 Alternatively, you can specify a file to read for the target 33398 description. If a file is set, the target will not be queried. The 33399 commands to specify a file are: 33400 33401 `set tdesc filename PATH' 33402 Read the target description from PATH. 33403 33404 `unset tdesc filename' 33405 Do not read the XML target description from a file. GDB will use 33406 the description supplied by the current target. 33407 33408 `show tdesc filename' 33409 Show the filename to read for a target description, if any. 33410 33411 33412 File: gdb.info, Node: Target Description Format, Next: Predefined Target Types, Prev: Retrieving Descriptions, Up: Target Descriptions 33413 33414 G.2 Target Description Format 33415 ============================= 33416 33417 A target description annex is an XML (http://www.w3.org/XML/) document 33418 which complies with the Document Type Definition provided in the GDB 33419 sources in `gdb/features/gdb-target.dtd'. This means you can use 33420 generally available tools like `xmllint' to check that your feature 33421 descriptions are well-formed and valid. However, to help people 33422 unfamiliar with XML write descriptions for their targets, we also 33423 describe the grammar here. 33424 33425 Target descriptions can identify the architecture of the remote 33426 target and (for some architectures) provide information about custom 33427 register sets. They can also identify the OS ABI of the remote target. 33428 GDB can use this information to autoconfigure for your target, or to 33429 warn you if you connect to an unsupported target. 33430 33431 Here is a simple target description: 33432 33433 <target version="1.0"> 33434 <architecture>i386:x86-64</architecture> 33435 </target> 33436 33437 This minimal description only says that the target uses the x86-64 33438 architecture. 33439 33440 A target description has the following overall form, with [ ] marking 33441 optional elements and ... marking repeatable elements. The elements 33442 are explained further below. 33443 33444 <?xml version="1.0"?> 33445 <!DOCTYPE target SYSTEM "gdb-target.dtd"> 33446 <target version="1.0"> 33447 [ARCHITECTURE] 33448 [OSABI] 33449 [COMPATIBLE] 33450 [FEATURE...] 33451 </target> 33452 33453 The description is generally insensitive to whitespace and line breaks, 33454 under the usual common-sense rules. The XML version declaration and 33455 document type declaration can generally be omitted (GDB does not 33456 require them), but specifying them may be useful for XML validation 33457 tools. The `version' attribute for `<target>' may also be omitted, but 33458 we recommend including it; if future versions of GDB use an incompatible 33459 revision of `gdb-target.dtd', they will detect and report the version 33460 mismatch. 33461 33462 G.2.1 Inclusion 33463 --------------- 33464 33465 It can sometimes be valuable to split a target description up into 33466 several different annexes, either for organizational purposes, or to 33467 share files between different possible target descriptions. You can 33468 divide a description into multiple files by replacing any element of 33469 the target description with an inclusion directive of the form: 33470 33471 <xi:include href="DOCUMENT"/> 33472 33473 When GDB encounters an element of this form, it will retrieve the named 33474 XML DOCUMENT, and replace the inclusion directive with the contents of 33475 that document. If the current description was read using `qXfer', then 33476 so will be the included document; DOCUMENT will be interpreted as the 33477 name of an annex. If the current description was read from a file, GDB 33478 will look for DOCUMENT as a file in the same directory where it found 33479 the original description. 33480 33481 G.2.2 Architecture 33482 ------------------ 33483 33484 An `<architecture>' element has this form: 33485 33486 <architecture>ARCH</architecture> 33487 33488 ARCH is one of the architectures from the set accepted by `set 33489 architecture' (*note Specifying a Debugging Target: Targets.). 33490 33491 G.2.3 OS ABI 33492 ------------ 33493 33494 This optional field was introduced in GDB version 7.0. Previous 33495 versions of GDB ignore it. 33496 33497 An `<osabi>' element has this form: 33498 33499 <osabi>ABI-NAME</osabi> 33500 33501 ABI-NAME is an OS ABI name from the same selection accepted by 33502 `set osabi' (*note Configuring the Current ABI: ABI.). 33503 33504 G.2.4 Compatible Architecture 33505 ----------------------------- 33506 33507 This optional field was introduced in GDB version 7.0. Previous 33508 versions of GDB ignore it. 33509 33510 A `<compatible>' element has this form: 33511 33512 <compatible>ARCH</compatible> 33513 33514 ARCH is one of the architectures from the set accepted by `set 33515 architecture' (*note Specifying a Debugging Target: Targets.). 33516 33517 A `<compatible>' element is used to specify that the target is able 33518 to run binaries in some other than the main target architecture given 33519 by the `<architecture>' element. For example, on the Cell Broadband 33520 Engine, the main architecture is `powerpc:common' or 33521 `powerpc:common64', but the system is able to run binaries in the `spu' 33522 architecture as well. The way to describe this capability with 33523 `<compatible>' is as follows: 33524 33525 <architecture>powerpc:common</architecture> 33526 <compatible>spu</compatible> 33527 33528 G.2.5 Features 33529 -------------- 33530 33531 Each `<feature>' describes some logical portion of the target system. 33532 Features are currently used to describe available CPU registers and the 33533 types of their contents. A `<feature>' element has this form: 33534 33535 <feature name="NAME"> 33536 [TYPE...] 33537 REG... 33538 </feature> 33539 33540 Each feature's name should be unique within the description. The name 33541 of a feature does not matter unless GDB has some special knowledge of 33542 the contents of that feature; if it does, the feature should have its 33543 standard name. *Note Standard Target Features::. 33544 33545 G.2.6 Types 33546 ----------- 33547 33548 Any register's value is a collection of bits which GDB must interpret. 33549 The default interpretation is a two's complement integer, but other 33550 types can be requested by name in the register description. Some 33551 predefined types are provided by GDB (*note Predefined Target Types::), 33552 and the description can define additional composite types. 33553 33554 Each type element must have an `id' attribute, which gives a unique 33555 (within the containing `<feature>') name to the type. Types must be 33556 defined before they are used. 33557 33558 Some targets offer vector registers, which can be treated as arrays 33559 of scalar elements. These types are written as `<vector>' elements, 33560 specifying the array element type, TYPE, and the number of elements, 33561 COUNT: 33562 33563 <vector id="ID" type="TYPE" count="COUNT"/> 33564 33565 If a register's value is usefully viewed in multiple ways, define it 33566 with a union type containing the useful representations. The `<union>' 33567 element contains one or more `<field>' elements, each of which has a 33568 NAME and a TYPE: 33569 33570 <union id="ID"> 33571 <field name="NAME" type="TYPE"/> 33572 ... 33573 </union> 33574 33575 If a register's value is composed from several separate values, 33576 define it with a structure type. There are two forms of the `<struct>' 33577 element; a `<struct>' element must either contain only bitfields or 33578 contain no bitfields. If the structure contains only bitfields, its 33579 total size in bytes must be specified, each bitfield must have an 33580 explicit start and end, and bitfields are automatically assigned an 33581 integer type. The field's START should be less than or equal to its 33582 END, and zero represents the least significant bit. 33583 33584 <struct id="ID" size="SIZE"> 33585 <field name="NAME" start="START" end="END"/> 33586 ... 33587 </struct> 33588 33589 If the structure contains no bitfields, then each field has an 33590 explicit type, and no implicit padding is added. 33591 33592 <struct id="ID"> 33593 <field name="NAME" type="TYPE"/> 33594 ... 33595 </struct> 33596 33597 If a register's value is a series of single-bit flags, define it with 33598 a flags type. The `<flags>' element has an explicit SIZE and contains 33599 one or more `<field>' elements. Each field has a NAME, a START, and an 33600 END. Only single-bit flags are supported. 33601 33602 <flags id="ID" size="SIZE"> 33603 <field name="NAME" start="START" end="END"/> 33604 ... 33605 </flags> 33606 33607 G.2.7 Registers 33608 --------------- 33609 33610 Each register is represented as an element with this form: 33611 33612 <reg name="NAME" 33613 bitsize="SIZE" 33614 [regnum="NUM"] 33615 [save-restore="SAVE-RESTORE"] 33616 [type="TYPE"] 33617 [group="GROUP"]/> 33618 33619 The components are as follows: 33620 33621 NAME 33622 The register's name; it must be unique within the target 33623 description. 33624 33625 BITSIZE 33626 The register's size, in bits. 33627 33628 REGNUM 33629 The register's number. If omitted, a register's number is one 33630 greater than that of the previous register (either in the current 33631 feature or in a preceeding feature); the first register in the 33632 target description defaults to zero. This register number is used 33633 to read or write the register; e.g. it is used in the remote `p' 33634 and `P' packets, and registers appear in the `g' and `G' packets 33635 in order of increasing register number. 33636 33637 SAVE-RESTORE 33638 Whether the register should be preserved across inferior function 33639 calls; this must be either `yes' or `no'. The default is `yes', 33640 which is appropriate for most registers except for some system 33641 control registers; this is not related to the target's ABI. 33642 33643 TYPE 33644 The type of the register. TYPE may be a predefined type, a type 33645 defined in the current feature, or one of the special types `int' 33646 and `float'. `int' is an integer type of the correct size for 33647 BITSIZE, and `float' is a floating point type (in the 33648 architecture's normal floating point format) of the correct size 33649 for BITSIZE. The default is `int'. 33650 33651 GROUP 33652 The register group to which this register belongs. GROUP must be 33653 either `general', `float', or `vector'. If no GROUP is specified, 33654 GDB will not display the register in `info registers'. 33655 33656 33657 33658 File: gdb.info, Node: Predefined Target Types, Next: Standard Target Features, Prev: Target Description Format, Up: Target Descriptions 33659 33660 G.3 Predefined Target Types 33661 =========================== 33662 33663 Type definitions in the self-description can build up composite types 33664 from basic building blocks, but can not define fundamental types. 33665 Instead, standard identifiers are provided by GDB for the fundamental 33666 types. The currently supported types are: 33667 33668 `int8' 33669 `int16' 33670 `int32' 33671 `int64' 33672 `int128' 33673 Signed integer types holding the specified number of bits. 33674 33675 `uint8' 33676 `uint16' 33677 `uint32' 33678 `uint64' 33679 `uint128' 33680 Unsigned integer types holding the specified number of bits. 33681 33682 `code_ptr' 33683 `data_ptr' 33684 Pointers to unspecified code and data. The program counter and 33685 any dedicated return address register may be marked as code 33686 pointers; printing a code pointer converts it into a symbolic 33687 address. The stack pointer and any dedicated address registers 33688 may be marked as data pointers. 33689 33690 `ieee_single' 33691 Single precision IEEE floating point. 33692 33693 `ieee_double' 33694 Double precision IEEE floating point. 33695 33696 `arm_fpa_ext' 33697 The 12-byte extended precision format used by ARM FPA registers. 33698 33699 `i387_ext' 33700 The 10-byte extended precision format used by x87 registers. 33701 33702 `i386_eflags' 33703 32bit EFLAGS register used by x86. 33704 33705 `i386_mxcsr' 33706 32bit MXCSR register used by x86. 33707 33708 33709 33710 File: gdb.info, Node: Standard Target Features, Prev: Predefined Target Types, Up: Target Descriptions 33711 33712 G.4 Standard Target Features 33713 ============================ 33714 33715 A target description must contain either no registers or all the 33716 target's registers. If the description contains no registers, then GDB 33717 will assume a default register layout, selected based on the 33718 architecture. If the description contains any registers, the default 33719 layout will not be used; the standard registers must be described in 33720 the target description, in such a way that GDB can recognize them. 33721 33722 This is accomplished by giving specific names to feature elements 33723 which contain standard registers. GDB will look for features with 33724 those names and verify that they contain the expected registers; if any 33725 known feature is missing required registers, or if any required feature 33726 is missing, GDB will reject the target description. You can add 33727 additional registers to any of the standard features -- GDB will 33728 display them just as if they were added to an unrecognized feature. 33729 33730 This section lists the known features and their expected contents. 33731 Sample XML documents for these features are included in the GDB source 33732 tree, in the directory `gdb/features'. 33733 33734 Names recognized by GDB should include the name of the company or 33735 organization which selected the name, and the overall architecture to 33736 which the feature applies; so e.g. the feature containing ARM core 33737 registers is named `org.gnu.gdb.arm.core'. 33738 33739 The names of registers are not case sensitive for the purpose of 33740 recognizing standard features, but GDB will only display registers 33741 using the capitalization used in the description. 33742 33743 * Menu: 33744 33745 * ARM Features:: 33746 * i386 Features:: 33747 * MIPS Features:: 33748 * M68K Features:: 33749 * PowerPC Features:: 33750 33751 33752 File: gdb.info, Node: ARM Features, Next: i386 Features, Up: Standard Target Features 33753 33754 G.4.1 ARM Features 33755 ------------------ 33756 33757 The `org.gnu.gdb.arm.core' feature is required for non-M-profile ARM 33758 targets. It should contain registers `r0' through `r13', `sp', `lr', 33759 `pc', and `cpsr'. 33760 33761 For M-profile targets (e.g. Cortex-M3), the `org.gnu.gdb.arm.core' 33762 feature is replaced by `org.gnu.gdb.arm.m-profile'. It should contain 33763 registers `r0' through `r13', `sp', `lr', `pc', and `xpsr'. 33764 33765 The `org.gnu.gdb.arm.fpa' feature is optional. If present, it 33766 should contain registers `f0' through `f7' and `fps'. 33767 33768 The `org.gnu.gdb.xscale.iwmmxt' feature is optional. If present, it 33769 should contain at least registers `wR0' through `wR15' and `wCGR0' 33770 through `wCGR3'. The `wCID', `wCon', `wCSSF', and `wCASF' registers 33771 are optional. 33772 33773 The `org.gnu.gdb.arm.vfp' feature is optional. If present, it 33774 should contain at least registers `d0' through `d15'. If they are 33775 present, `d16' through `d31' should also be included. GDB will 33776 synthesize the single-precision registers from halves of the 33777 double-precision registers. 33778 33779 The `org.gnu.gdb.arm.neon' feature is optional. It does not need to 33780 contain registers; it instructs GDB to display the VFP double-precision 33781 registers as vectors and to synthesize the quad-precision registers 33782 from pairs of double-precision registers. If this feature is present, 33783 `org.gnu.gdb.arm.vfp' must also be present and include 32 33784 double-precision registers. 33785 33786 33787 File: gdb.info, Node: i386 Features, Next: MIPS Features, Prev: ARM Features, Up: Standard Target Features 33788 33789 G.4.2 i386 Features 33790 ------------------- 33791 33792 The `org.gnu.gdb.i386.core' feature is required for i386/amd64 targets. 33793 It should describe the following registers: 33794 33795 - `eax' through `edi' plus `eip' for i386 33796 33797 - `rax' through `r15' plus `rip' for amd64 33798 33799 - `eflags', `cs', `ss', `ds', `es', `fs', `gs' 33800 33801 - `st0' through `st7' 33802 33803 - `fctrl', `fstat', `ftag', `fiseg', `fioff', `foseg', `fooff' and 33804 `fop' 33805 33806 The register sets may be different, depending on the target. 33807 33808 The `org.gnu.gdb.i386.sse' feature is optional. It should describe 33809 registers: 33810 33811 - `xmm0' through `xmm7' for i386 33812 33813 - `xmm0' through `xmm15' for amd64 33814 33815 - `mxcsr' 33816 33817 The `org.gnu.gdb.i386.avx' feature is optional and requires the 33818 `org.gnu.gdb.i386.sse' feature. It should describe the upper 128 bits 33819 of YMM registers: 33820 33821 - `ymm0h' through `ymm7h' for i386 33822 33823 - `ymm0h' through `ymm15h' for amd64 33824 33825 The `org.gnu.gdb.i386.linux' feature is optional. It should 33826 describe a single register, `orig_eax'. 33827 33828 33829 File: gdb.info, Node: MIPS Features, Next: M68K Features, Prev: i386 Features, Up: Standard Target Features 33830 33831 G.4.3 MIPS Features 33832 ------------------- 33833 33834 The `org.gnu.gdb.mips.cpu' feature is required for MIPS targets. It 33835 should contain registers `r0' through `r31', `lo', `hi', and `pc'. 33836 They may be 32-bit or 64-bit depending on the target. 33837 33838 The `org.gnu.gdb.mips.cp0' feature is also required. It should 33839 contain at least the `status', `badvaddr', and `cause' registers. They 33840 may be 32-bit or 64-bit depending on the target. 33841 33842 The `org.gnu.gdb.mips.fpu' feature is currently required, though it 33843 may be optional in a future version of GDB. It should contain 33844 registers `f0' through `f31', `fcsr', and `fir'. They may be 32-bit or 33845 64-bit depending on the target. 33846 33847 The `org.gnu.gdb.mips.linux' feature is optional. It should contain 33848 a single register, `restart', which is used by the Linux kernel to 33849 control restartable syscalls. 33850 33851 33852 File: gdb.info, Node: M68K Features, Next: PowerPC Features, Prev: MIPS Features, Up: Standard Target Features 33853 33854 G.4.4 M68K Features 33855 ------------------- 33856 33857 ``org.gnu.gdb.m68k.core'' 33858 ``org.gnu.gdb.coldfire.core'' 33859 ``org.gnu.gdb.fido.core'' 33860 One of those features must be always present. The feature that is 33861 present determines which flavor of m68k is used. The feature that 33862 is present should contain registers `d0' through `d7', `a0' 33863 through `a5', `fp', `sp', `ps' and `pc'. 33864 33865 ``org.gnu.gdb.coldfire.fp'' 33866 This feature is optional. If present, it should contain registers 33867 `fp0' through `fp7', `fpcontrol', `fpstatus' and `fpiaddr'. 33868 33869 33870 File: gdb.info, Node: PowerPC Features, Prev: M68K Features, Up: Standard Target Features 33871 33872 G.4.5 PowerPC Features 33873 ---------------------- 33874 33875 The `org.gnu.gdb.power.core' feature is required for PowerPC targets. 33876 It should contain registers `r0' through `r31', `pc', `msr', `cr', 33877 `lr', `ctr', and `xer'. They may be 32-bit or 64-bit depending on the 33878 target. 33879 33880 The `org.gnu.gdb.power.fpu' feature is optional. It should contain 33881 registers `f0' through `f31' and `fpscr'. 33882 33883 The `org.gnu.gdb.power.altivec' feature is optional. It should 33884 contain registers `vr0' through `vr31', `vscr', and `vrsave'. 33885 33886 The `org.gnu.gdb.power.vsx' feature is optional. It should contain 33887 registers `vs0h' through `vs31h'. GDB will combine these registers 33888 with the floating point registers (`f0' through `f31') and the altivec 33889 registers (`vr0' through `vr31') to present the 128-bit wide registers 33890 `vs0' through `vs63', the set of vector registers for POWER7. 33891 33892 The `org.gnu.gdb.power.spe' feature is optional. It should contain 33893 registers `ev0h' through `ev31h', `acc', and `spefscr'. SPE targets 33894 should provide 32-bit registers in `org.gnu.gdb.power.core' and provide 33895 the upper halves in `ev0h' through `ev31h'. GDB will combine these to 33896 present registers `ev0' through `ev31' to the user. 33897 33898 33899 File: gdb.info, Node: Operating System Information, Next: Trace File Format, Prev: Target Descriptions, Up: Top 33900 33901 Appendix H Operating System Information 33902 *************************************** 33903 33904 * Menu: 33905 33906 * Process list:: 33907 33908 Users of GDB often wish to obtain information about the state of the 33909 operating system running on the target--for example the list of 33910 processes, or the list of open files. This section describes the 33911 mechanism that makes it possible. This mechanism is similar to the 33912 target features mechanism (*note Target Descriptions::), but focuses on 33913 a different aspect of target. 33914 33915 Operating system information is retrived from the target via the 33916 remote protocol, using `qXfer' requests (*note qXfer osdata read::). 33917 The object name in the request should be `osdata', and the ANNEX 33918 identifies the data to be fetched. 33919 33920 33921 File: gdb.info, Node: Process list, Up: Operating System Information 33922 33923 H.1 Process list 33924 ================ 33925 33926 When requesting the process list, the ANNEX field in the `qXfer' 33927 request should be `processes'. The returned data is an XML document. 33928 The formal syntax of this document is defined in 33929 `gdb/features/osdata.dtd'. 33930 33931 An example document is: 33932 33933 <?xml version="1.0"?> 33934 <!DOCTYPE target SYSTEM "osdata.dtd"> 33935 <osdata type="processes"> 33936 <item> 33937 <column name="pid">1</column> 33938 <column name="user">root</column> 33939 <column name="command">/sbin/init</column> 33940 <column name="cores">1,2,3</column> 33941 </item> 33942 </osdata> 33943 33944 Each item should include a column whose name is `pid'. The value of 33945 that column should identify the process on the target. The `user' and 33946 `command' columns are optional, and will be displayed by GDB. The 33947 `cores' column, if present, should contain a comma-separated list of 33948 cores that this process is running on. Target may provide additional 33949 columns, which GDB currently ignores. 33950 33951 33952 File: gdb.info, Node: Trace File Format, Next: Copying, Prev: Operating System Information, Up: Top 33953 33954 Appendix I Trace File Format 33955 **************************** 33956 33957 The trace file comes in three parts: a header, a textual description 33958 section, and a trace frame section with binary data. 33959 33960 The header has the form `\x7fTRACE0\n'. The first byte is `0x7f' so 33961 as to indicate that the file contains binary data, while the `0' is a 33962 version number that may have different values in the future. 33963 33964 The description section consists of multiple lines of ASCII text 33965 separated by newline characters (`0xa'). The lines may include a 33966 variety of optional descriptive or context-setting information, such as 33967 tracepoint definitions or register set size. GDB will ignore any line 33968 that it does not recognize. An empty line marks the end of this 33969 section. 33970 33971 The trace frame section consists of a number of consecutive frames. 33972 Each frame begins with a two-byte tracepoint number, followed by a 33973 four-byte size giving the amount of data in the frame. The data in the 33974 frame consists of a number of blocks, each introduced by a character 33975 indicating its type (at least register, memory, and trace state 33976 variable). The data in this section is raw binary, not a hexadecimal 33977 or other encoding; its endianness matches the target's endianness. 33978 33979 `R BYTES' 33980 Register block. The number and ordering of bytes matches that of a 33981 `g' packet in the remote protocol. Note that these are the actual 33982 bytes, in target order and GDB register order, not a hexadecimal 33983 encoding. 33984 33985 `M ADDRESS LENGTH BYTES...' 33986 Memory block. This is a contiguous block of memory, at the 8-byte 33987 address ADDRESS, with a 2-byte length LENGTH, followed by LENGTH 33988 bytes. 33989 33990 `V NUMBER VALUE' 33991 Trace state variable block. This records the 8-byte signed value 33992 VALUE of trace state variable numbered NUMBER. 33993 33994 33995 Future enhancements of the trace file format may include additional 33996 types of blocks. 33997 33998 33999 File: gdb.info, Node: Copying, Next: GNU Free Documentation License, Prev: Trace File Format, Up: Top 34000 34001 Appendix J GNU GENERAL PUBLIC LICENSE 34002 ************************************* 34003 34004 Version 3, 29 June 2007 34005 34006 Copyright (C) 2007 Free Software Foundation, Inc. `http://fsf.org/' 34007 34008 Everyone is permitted to copy and distribute verbatim copies of this 34009 license document, but changing it is not allowed. 34010 34011 Preamble 34012 ======== 34013 34014 The GNU General Public License is a free, copyleft license for software 34015 and other kinds of works. 34016 34017 The licenses for most software and other practical works are designed 34018 to take away your freedom to share and change the works. By contrast, 34019 the GNU General Public License is intended to guarantee your freedom to 34020 share and change all versions of a program--to make sure it remains 34021 free software for all its users. We, the Free Software Foundation, use 34022 the GNU General Public License for most of our software; it applies 34023 also to any other work released this way by its authors. You can apply 34024 it to your programs, too. 34025 34026 When we speak of free software, we are referring to freedom, not 34027 price. Our General Public Licenses are designed to make sure that you 34028 have the freedom to distribute copies of free software (and charge for 34029 them if you wish), that you receive source code or can get it if you 34030 want it, that you can change the software or use pieces of it in new 34031 free programs, and that you know you can do these things. 34032 34033 To protect your rights, we need to prevent others from denying you 34034 these rights or asking you to surrender the rights. Therefore, you 34035 have certain responsibilities if you distribute copies of the software, 34036 or if you modify it: responsibilities to respect the freedom of others. 34037 34038 For example, if you distribute copies of such a program, whether 34039 gratis or for a fee, you must pass on to the recipients the same 34040 freedoms that you received. You must make sure that they, too, receive 34041 or can get the source code. And you must show them these terms so they 34042 know their rights. 34043 34044 Developers that use the GNU GPL protect your rights with two steps: 34045 (1) assert copyright on the software, and (2) offer you this License 34046 giving you legal permission to copy, distribute and/or modify it. 34047 34048 For the developers' and authors' protection, the GPL clearly explains 34049 that there is no warranty for this free software. For both users' and 34050 authors' sake, the GPL requires that modified versions be marked as 34051 changed, so that their problems will not be attributed erroneously to 34052 authors of previous versions. 34053 34054 Some devices are designed to deny users access to install or run 34055 modified versions of the software inside them, although the 34056 manufacturer can do so. This is fundamentally incompatible with the 34057 aim of protecting users' freedom to change the software. The 34058 systematic pattern of such abuse occurs in the area of products for 34059 individuals to use, which is precisely where it is most unacceptable. 34060 Therefore, we have designed this version of the GPL to prohibit the 34061 practice for those products. If such problems arise substantially in 34062 other domains, we stand ready to extend this provision to those domains 34063 in future versions of the GPL, as needed to protect the freedom of 34064 users. 34065 34066 Finally, every program is threatened constantly by software patents. 34067 States should not allow patents to restrict development and use of 34068 software on general-purpose computers, but in those that do, we wish to 34069 avoid the special danger that patents applied to a free program could 34070 make it effectively proprietary. To prevent this, the GPL assures that 34071 patents cannot be used to render the program non-free. 34072 34073 The precise terms and conditions for copying, distribution and 34074 modification follow. 34075 34076 TERMS AND CONDITIONS 34077 ==================== 34078 34079 0. Definitions. 34080 34081 "This License" refers to version 3 of the GNU General Public 34082 License. 34083 34084 "Copyright" also means copyright-like laws that apply to other 34085 kinds of works, such as semiconductor masks. 34086 34087 "The Program" refers to any copyrightable work licensed under this 34088 License. Each licensee is addressed as "you". "Licensees" and 34089 "recipients" may be individuals or organizations. 34090 34091 To "modify" a work means to copy from or adapt all or part of the 34092 work in a fashion requiring copyright permission, other than the 34093 making of an exact copy. The resulting work is called a "modified 34094 version" of the earlier work or a work "based on" the earlier work. 34095 34096 A "covered work" means either the unmodified Program or a work 34097 based on the Program. 34098 34099 To "propagate" a work means to do anything with it that, without 34100 permission, would make you directly or secondarily liable for 34101 infringement under applicable copyright law, except executing it 34102 on a computer or modifying a private copy. Propagation includes 34103 copying, distribution (with or without modification), making 34104 available to the public, and in some countries other activities as 34105 well. 34106 34107 To "convey" a work means any kind of propagation that enables other 34108 parties to make or receive copies. Mere interaction with a user 34109 through a computer network, with no transfer of a copy, is not 34110 conveying. 34111 34112 An interactive user interface displays "Appropriate Legal Notices" 34113 to the extent that it includes a convenient and prominently visible 34114 feature that (1) displays an appropriate copyright notice, and (2) 34115 tells the user that there is no warranty for the work (except to 34116 the extent that warranties are provided), that licensees may 34117 convey the work under this License, and how to view a copy of this 34118 License. If the interface presents a list of user commands or 34119 options, such as a menu, a prominent item in the list meets this 34120 criterion. 34121 34122 1. Source Code. 34123 34124 The "source code" for a work means the preferred form of the work 34125 for making modifications to it. "Object code" means any 34126 non-source form of a work. 34127 34128 A "Standard Interface" means an interface that either is an 34129 official standard defined by a recognized standards body, or, in 34130 the case of interfaces specified for a particular programming 34131 language, one that is widely used among developers working in that 34132 language. 34133 34134 The "System Libraries" of an executable work include anything, 34135 other than the work as a whole, that (a) is included in the normal 34136 form of packaging a Major Component, but which is not part of that 34137 Major Component, and (b) serves only to enable use of the work 34138 with that Major Component, or to implement a Standard Interface 34139 for which an implementation is available to the public in source 34140 code form. A "Major Component", in this context, means a major 34141 essential component (kernel, window system, and so on) of the 34142 specific operating system (if any) on which the executable work 34143 runs, or a compiler used to produce the work, or an object code 34144 interpreter used to run it. 34145 34146 The "Corresponding Source" for a work in object code form means all 34147 the source code needed to generate, install, and (for an executable 34148 work) run the object code and to modify the work, including 34149 scripts to control those activities. However, it does not include 34150 the work's System Libraries, or general-purpose tools or generally 34151 available free programs which are used unmodified in performing 34152 those activities but which are not part of the work. For example, 34153 Corresponding Source includes interface definition files 34154 associated with source files for the work, and the source code for 34155 shared libraries and dynamically linked subprograms that the work 34156 is specifically designed to require, such as by intimate data 34157 communication or control flow between those subprograms and other 34158 parts of the work. 34159 34160 The Corresponding Source need not include anything that users can 34161 regenerate automatically from other parts of the Corresponding 34162 Source. 34163 34164 The Corresponding Source for a work in source code form is that 34165 same work. 34166 34167 2. Basic Permissions. 34168 34169 All rights granted under this License are granted for the term of 34170 copyright on the Program, and are irrevocable provided the stated 34171 conditions are met. This License explicitly affirms your unlimited 34172 permission to run the unmodified Program. The output from running 34173 a covered work is covered by this License only if the output, 34174 given its content, constitutes a covered work. This License 34175 acknowledges your rights of fair use or other equivalent, as 34176 provided by copyright law. 34177 34178 You may make, run and propagate covered works that you do not 34179 convey, without conditions so long as your license otherwise 34180 remains in force. You may convey covered works to others for the 34181 sole purpose of having them make modifications exclusively for 34182 you, or provide you with facilities for running those works, 34183 provided that you comply with the terms of this License in 34184 conveying all material for which you do not control copyright. 34185 Those thus making or running the covered works for you must do so 34186 exclusively on your behalf, under your direction and control, on 34187 terms that prohibit them from making any copies of your 34188 copyrighted material outside their relationship with you. 34189 34190 Conveying under any other circumstances is permitted solely under 34191 the conditions stated below. Sublicensing is not allowed; section 34192 10 makes it unnecessary. 34193 34194 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 34195 34196 No covered work shall be deemed part of an effective technological 34197 measure under any applicable law fulfilling obligations under 34198 article 11 of the WIPO copyright treaty adopted on 20 December 34199 1996, or similar laws prohibiting or restricting circumvention of 34200 such measures. 34201 34202 When you convey a covered work, you waive any legal power to forbid 34203 circumvention of technological measures to the extent such 34204 circumvention is effected by exercising rights under this License 34205 with respect to the covered work, and you disclaim any intention 34206 to limit operation or modification of the work as a means of 34207 enforcing, against the work's users, your or third parties' legal 34208 rights to forbid circumvention of technological measures. 34209 34210 4. Conveying Verbatim Copies. 34211 34212 You may convey verbatim copies of the Program's source code as you 34213 receive it, in any medium, provided that you conspicuously and 34214 appropriately publish on each copy an appropriate copyright notice; 34215 keep intact all notices stating that this License and any 34216 non-permissive terms added in accord with section 7 apply to the 34217 code; keep intact all notices of the absence of any warranty; and 34218 give all recipients a copy of this License along with the Program. 34219 34220 You may charge any price or no price for each copy that you convey, 34221 and you may offer support or warranty protection for a fee. 34222 34223 5. Conveying Modified Source Versions. 34224 34225 You may convey a work based on the Program, or the modifications to 34226 produce it from the Program, in the form of source code under the 34227 terms of section 4, provided that you also meet all of these 34228 conditions: 34229 34230 a. The work must carry prominent notices stating that you 34231 modified it, and giving a relevant date. 34232 34233 b. The work must carry prominent notices stating that it is 34234 released under this License and any conditions added under 34235 section 7. This requirement modifies the requirement in 34236 section 4 to "keep intact all notices". 34237 34238 c. You must license the entire work, as a whole, under this 34239 License to anyone who comes into possession of a copy. This 34240 License will therefore apply, along with any applicable 34241 section 7 additional terms, to the whole of the work, and all 34242 its parts, regardless of how they are packaged. This License 34243 gives no permission to license the work in any other way, but 34244 it does not invalidate such permission if you have separately 34245 received it. 34246 34247 d. If the work has interactive user interfaces, each must display 34248 Appropriate Legal Notices; however, if the Program has 34249 interactive interfaces that do not display Appropriate Legal 34250 Notices, your work need not make them do so. 34251 34252 A compilation of a covered work with other separate and independent 34253 works, which are not by their nature extensions of the covered 34254 work, and which are not combined with it such as to form a larger 34255 program, in or on a volume of a storage or distribution medium, is 34256 called an "aggregate" if the compilation and its resulting 34257 copyright are not used to limit the access or legal rights of the 34258 compilation's users beyond what the individual works permit. 34259 Inclusion of a covered work in an aggregate does not cause this 34260 License to apply to the other parts of the aggregate. 34261 34262 6. Conveying Non-Source Forms. 34263 34264 You may convey a covered work in object code form under the terms 34265 of sections 4 and 5, provided that you also convey the 34266 machine-readable Corresponding Source under the terms of this 34267 License, in one of these ways: 34268 34269 a. Convey the object code in, or embodied in, a physical product 34270 (including a physical distribution medium), accompanied by the 34271 Corresponding Source fixed on a durable physical medium 34272 customarily used for software interchange. 34273 34274 b. Convey the object code in, or embodied in, a physical product 34275 (including a physical distribution medium), accompanied by a 34276 written offer, valid for at least three years and valid for 34277 as long as you offer spare parts or customer support for that 34278 product model, to give anyone who possesses the object code 34279 either (1) a copy of the Corresponding Source for all the 34280 software in the product that is covered by this License, on a 34281 durable physical medium customarily used for software 34282 interchange, for a price no more than your reasonable cost of 34283 physically performing this conveying of source, or (2) access 34284 to copy the Corresponding Source from a network server at no 34285 charge. 34286 34287 c. Convey individual copies of the object code with a copy of 34288 the written offer to provide the Corresponding Source. This 34289 alternative is allowed only occasionally and noncommercially, 34290 and only if you received the object code with such an offer, 34291 in accord with subsection 6b. 34292 34293 d. Convey the object code by offering access from a designated 34294 place (gratis or for a charge), and offer equivalent access 34295 to the Corresponding Source in the same way through the same 34296 place at no further charge. You need not require recipients 34297 to copy the Corresponding Source along with the object code. 34298 If the place to copy the object code is a network server, the 34299 Corresponding Source may be on a different server (operated 34300 by you or a third party) that supports equivalent copying 34301 facilities, provided you maintain clear directions next to 34302 the object code saying where to find the Corresponding Source. 34303 Regardless of what server hosts the Corresponding Source, you 34304 remain obligated to ensure that it is available for as long 34305 as needed to satisfy these requirements. 34306 34307 e. Convey the object code using peer-to-peer transmission, 34308 provided you inform other peers where the object code and 34309 Corresponding Source of the work are being offered to the 34310 general public at no charge under subsection 6d. 34311 34312 34313 A separable portion of the object code, whose source code is 34314 excluded from the Corresponding Source as a System Library, need 34315 not be included in conveying the object code work. 34316 34317 A "User Product" is either (1) a "consumer product", which means 34318 any tangible personal property which is normally used for personal, 34319 family, or household purposes, or (2) anything designed or sold for 34320 incorporation into a dwelling. In determining whether a product 34321 is a consumer product, doubtful cases shall be resolved in favor of 34322 coverage. For a particular product received by a particular user, 34323 "normally used" refers to a typical or common use of that class of 34324 product, regardless of the status of the particular user or of the 34325 way in which the particular user actually uses, or expects or is 34326 expected to use, the product. A product is a consumer product 34327 regardless of whether the product has substantial commercial, 34328 industrial or non-consumer uses, unless such uses represent the 34329 only significant mode of use of the product. 34330 34331 "Installation Information" for a User Product means any methods, 34332 procedures, authorization keys, or other information required to 34333 install and execute modified versions of a covered work in that 34334 User Product from a modified version of its Corresponding Source. 34335 The information must suffice to ensure that the continued 34336 functioning of the modified object code is in no case prevented or 34337 interfered with solely because modification has been made. 34338 34339 If you convey an object code work under this section in, or with, 34340 or specifically for use in, a User Product, and the conveying 34341 occurs as part of a transaction in which the right of possession 34342 and use of the User Product is transferred to the recipient in 34343 perpetuity or for a fixed term (regardless of how the transaction 34344 is characterized), the Corresponding Source conveyed under this 34345 section must be accompanied by the Installation Information. But 34346 this requirement does not apply if neither you nor any third party 34347 retains the ability to install modified object code on the User 34348 Product (for example, the work has been installed in ROM). 34349 34350 The requirement to provide Installation Information does not 34351 include a requirement to continue to provide support service, 34352 warranty, or updates for a work that has been modified or 34353 installed by the recipient, or for the User Product in which it 34354 has been modified or installed. Access to a network may be denied 34355 when the modification itself materially and adversely affects the 34356 operation of the network or violates the rules and protocols for 34357 communication across the network. 34358 34359 Corresponding Source conveyed, and Installation Information 34360 provided, in accord with this section must be in a format that is 34361 publicly documented (and with an implementation available to the 34362 public in source code form), and must require no special password 34363 or key for unpacking, reading or copying. 34364 34365 7. Additional Terms. 34366 34367 "Additional permissions" are terms that supplement the terms of 34368 this License by making exceptions from one or more of its 34369 conditions. Additional permissions that are applicable to the 34370 entire Program shall be treated as though they were included in 34371 this License, to the extent that they are valid under applicable 34372 law. If additional permissions apply only to part of the Program, 34373 that part may be used separately under those permissions, but the 34374 entire Program remains governed by this License without regard to 34375 the additional permissions. 34376 34377 When you convey a copy of a covered work, you may at your option 34378 remove any additional permissions from that copy, or from any part 34379 of it. (Additional permissions may be written to require their own 34380 removal in certain cases when you modify the work.) You may place 34381 additional permissions on material, added by you to a covered work, 34382 for which you have or can give appropriate copyright permission. 34383 34384 Notwithstanding any other provision of this License, for material 34385 you add to a covered work, you may (if authorized by the copyright 34386 holders of that material) supplement the terms of this License 34387 with terms: 34388 34389 a. Disclaiming warranty or limiting liability differently from 34390 the terms of sections 15 and 16 of this License; or 34391 34392 b. Requiring preservation of specified reasonable legal notices 34393 or author attributions in that material or in the Appropriate 34394 Legal Notices displayed by works containing it; or 34395 34396 c. Prohibiting misrepresentation of the origin of that material, 34397 or requiring that modified versions of such material be 34398 marked in reasonable ways as different from the original 34399 version; or 34400 34401 d. Limiting the use for publicity purposes of names of licensors 34402 or authors of the material; or 34403 34404 e. Declining to grant rights under trademark law for use of some 34405 trade names, trademarks, or service marks; or 34406 34407 f. Requiring indemnification of licensors and authors of that 34408 material by anyone who conveys the material (or modified 34409 versions of it) with contractual assumptions of liability to 34410 the recipient, for any liability that these contractual 34411 assumptions directly impose on those licensors and authors. 34412 34413 All other non-permissive additional terms are considered "further 34414 restrictions" within the meaning of section 10. If the Program as 34415 you received it, or any part of it, contains a notice stating that 34416 it is governed by this License along with a term that is a further 34417 restriction, you may remove that term. If a license document 34418 contains a further restriction but permits relicensing or 34419 conveying under this License, you may add to a covered work 34420 material governed by the terms of that license document, provided 34421 that the further restriction does not survive such relicensing or 34422 conveying. 34423 34424 If you add terms to a covered work in accord with this section, you 34425 must place, in the relevant source files, a statement of the 34426 additional terms that apply to those files, or a notice indicating 34427 where to find the applicable terms. 34428 34429 Additional terms, permissive or non-permissive, may be stated in 34430 the form of a separately written license, or stated as exceptions; 34431 the above requirements apply either way. 34432 34433 8. Termination. 34434 34435 You may not propagate or modify a covered work except as expressly 34436 provided under this License. Any attempt otherwise to propagate or 34437 modify it is void, and will automatically terminate your rights 34438 under this License (including any patent licenses granted under 34439 the third paragraph of section 11). 34440 34441 However, if you cease all violation of this License, then your 34442 license from a particular copyright holder is reinstated (a) 34443 provisionally, unless and until the copyright holder explicitly 34444 and finally terminates your license, and (b) permanently, if the 34445 copyright holder fails to notify you of the violation by some 34446 reasonable means prior to 60 days after the cessation. 34447 34448 Moreover, your license from a particular copyright holder is 34449 reinstated permanently if the copyright holder notifies you of the 34450 violation by some reasonable means, this is the first time you have 34451 received notice of violation of this License (for any work) from 34452 that copyright holder, and you cure the violation prior to 30 days 34453 after your receipt of the notice. 34454 34455 Termination of your rights under this section does not terminate 34456 the licenses of parties who have received copies or rights from 34457 you under this License. If your rights have been terminated and 34458 not permanently reinstated, you do not qualify to receive new 34459 licenses for the same material under section 10. 34460 34461 9. Acceptance Not Required for Having Copies. 34462 34463 You are not required to accept this License in order to receive or 34464 run a copy of the Program. Ancillary propagation of a covered work 34465 occurring solely as a consequence of using peer-to-peer 34466 transmission to receive a copy likewise does not require 34467 acceptance. However, nothing other than this License grants you 34468 permission to propagate or modify any covered work. These actions 34469 infringe copyright if you do not accept this License. Therefore, 34470 by modifying or propagating a covered work, you indicate your 34471 acceptance of this License to do so. 34472 34473 10. Automatic Licensing of Downstream Recipients. 34474 34475 Each time you convey a covered work, the recipient automatically 34476 receives a license from the original licensors, to run, modify and 34477 propagate that work, subject to this License. You are not 34478 responsible for enforcing compliance by third parties with this 34479 License. 34480 34481 An "entity transaction" is a transaction transferring control of an 34482 organization, or substantially all assets of one, or subdividing an 34483 organization, or merging organizations. If propagation of a 34484 covered work results from an entity transaction, each party to that 34485 transaction who receives a copy of the work also receives whatever 34486 licenses to the work the party's predecessor in interest had or 34487 could give under the previous paragraph, plus a right to 34488 possession of the Corresponding Source of the work from the 34489 predecessor in interest, if the predecessor has it or can get it 34490 with reasonable efforts. 34491 34492 You may not impose any further restrictions on the exercise of the 34493 rights granted or affirmed under this License. For example, you 34494 may not impose a license fee, royalty, or other charge for 34495 exercise of rights granted under this License, and you may not 34496 initiate litigation (including a cross-claim or counterclaim in a 34497 lawsuit) alleging that any patent claim is infringed by making, 34498 using, selling, offering for sale, or importing the Program or any 34499 portion of it. 34500 34501 11. Patents. 34502 34503 A "contributor" is a copyright holder who authorizes use under this 34504 License of the Program or a work on which the Program is based. 34505 The work thus licensed is called the contributor's "contributor 34506 version". 34507 34508 A contributor's "essential patent claims" are all patent claims 34509 owned or controlled by the contributor, whether already acquired or 34510 hereafter acquired, that would be infringed by some manner, 34511 permitted by this License, of making, using, or selling its 34512 contributor version, but do not include claims that would be 34513 infringed only as a consequence of further modification of the 34514 contributor version. For purposes of this definition, "control" 34515 includes the right to grant patent sublicenses in a manner 34516 consistent with the requirements of this License. 34517 34518 Each contributor grants you a non-exclusive, worldwide, 34519 royalty-free patent license under the contributor's essential 34520 patent claims, to make, use, sell, offer for sale, import and 34521 otherwise run, modify and propagate the contents of its 34522 contributor version. 34523 34524 In the following three paragraphs, a "patent license" is any 34525 express agreement or commitment, however denominated, not to 34526 enforce a patent (such as an express permission to practice a 34527 patent or covenant not to sue for patent infringement). To 34528 "grant" such a patent license to a party means to make such an 34529 agreement or commitment not to enforce a patent against the party. 34530 34531 If you convey a covered work, knowingly relying on a patent 34532 license, and the Corresponding Source of the work is not available 34533 for anyone to copy, free of charge and under the terms of this 34534 License, through a publicly available network server or other 34535 readily accessible means, then you must either (1) cause the 34536 Corresponding Source to be so available, or (2) arrange to deprive 34537 yourself of the benefit of the patent license for this particular 34538 work, or (3) arrange, in a manner consistent with the requirements 34539 of this License, to extend the patent license to downstream 34540 recipients. "Knowingly relying" means you have actual knowledge 34541 that, but for the patent license, your conveying the covered work 34542 in a country, or your recipient's use of the covered work in a 34543 country, would infringe one or more identifiable patents in that 34544 country that you have reason to believe are valid. 34545 34546 If, pursuant to or in connection with a single transaction or 34547 arrangement, you convey, or propagate by procuring conveyance of, a 34548 covered work, and grant a patent license to some of the parties 34549 receiving the covered work authorizing them to use, propagate, 34550 modify or convey a specific copy of the covered work, then the 34551 patent license you grant is automatically extended to all 34552 recipients of the covered work and works based on it. 34553 34554 A patent license is "discriminatory" if it does not include within 34555 the scope of its coverage, prohibits the exercise of, or is 34556 conditioned on the non-exercise of one or more of the rights that 34557 are specifically granted under this License. You may not convey a 34558 covered work if you are a party to an arrangement with a third 34559 party that is in the business of distributing software, under 34560 which you make payment to the third party based on the extent of 34561 your activity of conveying the work, and under which the third 34562 party grants, to any of the parties who would receive the covered 34563 work from you, a discriminatory patent license (a) in connection 34564 with copies of the covered work conveyed by you (or copies made 34565 from those copies), or (b) primarily for and in connection with 34566 specific products or compilations that contain the covered work, 34567 unless you entered into that arrangement, or that patent license 34568 was granted, prior to 28 March 2007. 34569 34570 Nothing in this License shall be construed as excluding or limiting 34571 any implied license or other defenses to infringement that may 34572 otherwise be available to you under applicable patent law. 34573 34574 12. No Surrender of Others' Freedom. 34575 34576 If conditions are imposed on you (whether by court order, 34577 agreement or otherwise) that contradict the conditions of this 34578 License, they do not excuse you from the conditions of this 34579 License. If you cannot convey a covered work so as to satisfy 34580 simultaneously your obligations under this License and any other 34581 pertinent obligations, then as a consequence you may not convey it 34582 at all. For example, if you agree to terms that obligate you to 34583 collect a royalty for further conveying from those to whom you 34584 convey the Program, the only way you could satisfy both those 34585 terms and this License would be to refrain entirely from conveying 34586 the Program. 34587 34588 13. Use with the GNU Affero General Public License. 34589 34590 Notwithstanding any other provision of this License, you have 34591 permission to link or combine any covered work with a work licensed 34592 under version 3 of the GNU Affero General Public License into a 34593 single combined work, and to convey the resulting work. The terms 34594 of this License will continue to apply to the part which is the 34595 covered work, but the special requirements of the GNU Affero 34596 General Public License, section 13, concerning interaction through 34597 a network will apply to the combination as such. 34598 34599 14. Revised Versions of this License. 34600 34601 The Free Software Foundation may publish revised and/or new 34602 versions of the GNU General Public License from time to time. 34603 Such new versions will be similar in spirit to the present 34604 version, but may differ in detail to address new problems or 34605 concerns. 34606 34607 Each version is given a distinguishing version number. If the 34608 Program specifies that a certain numbered version of the GNU 34609 General Public License "or any later version" applies to it, you 34610 have the option of following the terms and conditions either of 34611 that numbered version or of any later version published by the 34612 Free Software Foundation. If the Program does not specify a 34613 version number of the GNU General Public License, you may choose 34614 any version ever published by the Free Software Foundation. 34615 34616 If the Program specifies that a proxy can decide which future 34617 versions of the GNU General Public License can be used, that 34618 proxy's public statement of acceptance of a version permanently 34619 authorizes you to choose that version for the Program. 34620 34621 Later license versions may give you additional or different 34622 permissions. However, no additional obligations are imposed on any 34623 author or copyright holder as a result of your choosing to follow a 34624 later version. 34625 34626 15. Disclaimer of Warranty. 34627 34628 THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 34629 APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE 34630 COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" 34631 WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, 34632 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 34633 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE 34634 RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. 34635 SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL 34636 NECESSARY SERVICING, REPAIR OR CORRECTION. 34637 34638 16. Limitation of Liability. 34639 34640 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 34641 WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES 34642 AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU 34643 FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 34644 CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE 34645 THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA 34646 BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 34647 PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 34648 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF 34649 THE POSSIBILITY OF SUCH DAMAGES. 34650 34651 17. Interpretation of Sections 15 and 16. 34652 34653 If the disclaimer of warranty and limitation of liability provided 34654 above cannot be given local legal effect according to their terms, 34655 reviewing courts shall apply local law that most closely 34656 approximates an absolute waiver of all civil liability in 34657 connection with the Program, unless a warranty or assumption of 34658 liability accompanies a copy of the Program in return for a fee. 34659 34660 34661 END OF TERMS AND CONDITIONS 34662 =========================== 34663 34664 How to Apply These Terms to Your New Programs 34665 ============================================= 34666 34667 If you develop a new program, and you want it to be of the greatest 34668 possible use to the public, the best way to achieve this is to make it 34669 free software which everyone can redistribute and change under these 34670 terms. 34671 34672 To do so, attach the following notices to the program. It is safest 34673 to attach them to the start of each source file to most effectively 34674 state the exclusion of warranty; and each file should have at least the 34675 "copyright" line and a pointer to where the full notice is found. 34676 34677 ONE LINE TO GIVE THE PROGRAM'S NAME AND A BRIEF IDEA OF WHAT IT DOES. 34678 Copyright (C) YEAR NAME OF AUTHOR 34679 34680 This program is free software: you can redistribute it and/or modify 34681 it under the terms of the GNU General Public License as published by 34682 the Free Software Foundation, either version 3 of the License, or (at 34683 your option) any later version. 34684 34685 This program is distributed in the hope that it will be useful, but 34686 WITHOUT ANY WARRANTY; without even the implied warranty of 34687 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 34688 General Public License for more details. 34689 34690 You should have received a copy of the GNU General Public License 34691 along with this program. If not, see `http://www.gnu.org/licenses/'. 34692 34693 Also add information on how to contact you by electronic and paper 34694 mail. 34695 34696 If the program does terminal interaction, make it output a short 34697 notice like this when it starts in an interactive mode: 34698 34699 PROGRAM Copyright (C) YEAR NAME OF AUTHOR 34700 This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 34701 This is free software, and you are welcome to redistribute it 34702 under certain conditions; type `show c' for details. 34703 34704 The hypothetical commands `show w' and `show c' should show the 34705 appropriate parts of the General Public License. Of course, your 34706 program's commands might be different; for a GUI interface, you would 34707 use an "about box". 34708 34709 You should also get your employer (if you work as a programmer) or 34710 school, if any, to sign a "copyright disclaimer" for the program, if 34711 necessary. For more information on this, and how to apply and follow 34712 the GNU GPL, see `http://www.gnu.org/licenses/'. 34713 34714 The GNU General Public License does not permit incorporating your 34715 program into proprietary programs. If your program is a subroutine 34716 library, you may consider it more useful to permit linking proprietary 34717 applications with the library. If this is what you want to do, use the 34718 GNU Lesser General Public License instead of this License. But first, 34719 please read `http://www.gnu.org/philosophy/why-not-lgpl.html'. 34720 34721 34722 File: gdb.info, Node: GNU Free Documentation License, Next: Index, Prev: Copying, Up: Top 34723 34724 Appendix K GNU Free Documentation License 34725 ***************************************** 34726 34727 Version 1.3, 3 November 2008 34728 34729 Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. 34730 `http://fsf.org/' 34731 34732 Everyone is permitted to copy and distribute verbatim copies 34733 of this license document, but changing it is not allowed. 34734 34735 0. PREAMBLE 34736 34737 The purpose of this License is to make a manual, textbook, or other 34738 functional and useful document "free" in the sense of freedom: to 34739 assure everyone the effective freedom to copy and redistribute it, 34740 with or without modifying it, either commercially or 34741 noncommercially. Secondarily, this License preserves for the 34742 author and publisher a way to get credit for their work, while not 34743 being considered responsible for modifications made by others. 34744 34745 This License is a kind of "copyleft", which means that derivative 34746 works of the document must themselves be free in the same sense. 34747 It complements the GNU General Public License, which is a copyleft 34748 license designed for free software. 34749 34750 We have designed this License in order to use it for manuals for 34751 free software, because free software needs free documentation: a 34752 free program should come with manuals providing the same freedoms 34753 that the software does. But this License is not limited to 34754 software manuals; it can be used for any textual work, regardless 34755 of subject matter or whether it is published as a printed book. 34756 We recommend this License principally for works whose purpose is 34757 instruction or reference. 34758 34759 1. APPLICABILITY AND DEFINITIONS 34760 34761 This License applies to any manual or other work, in any medium, 34762 that contains a notice placed by the copyright holder saying it 34763 can be distributed under the terms of this License. Such a notice 34764 grants a world-wide, royalty-free license, unlimited in duration, 34765 to use that work under the conditions stated herein. The 34766 "Document", below, refers to any such manual or work. Any member 34767 of the public is a licensee, and is addressed as "you". You 34768 accept the license if you copy, modify or distribute the work in a 34769 way requiring permission under copyright law. 34770 34771 A "Modified Version" of the Document means any work containing the 34772 Document or a portion of it, either copied verbatim, or with 34773 modifications and/or translated into another language. 34774 34775 A "Secondary Section" is a named appendix or a front-matter section 34776 of the Document that deals exclusively with the relationship of the 34777 publishers or authors of the Document to the Document's overall 34778 subject (or to related matters) and contains nothing that could 34779 fall directly within that overall subject. (Thus, if the Document 34780 is in part a textbook of mathematics, a Secondary Section may not 34781 explain any mathematics.) The relationship could be a matter of 34782 historical connection with the subject or with related matters, or 34783 of legal, commercial, philosophical, ethical or political position 34784 regarding them. 34785 34786 The "Invariant Sections" are certain Secondary Sections whose 34787 titles are designated, as being those of Invariant Sections, in 34788 the notice that says that the Document is released under this 34789 License. If a section does not fit the above definition of 34790 Secondary then it is not allowed to be designated as Invariant. 34791 The Document may contain zero Invariant Sections. If the Document 34792 does not identify any Invariant Sections then there are none. 34793 34794 The "Cover Texts" are certain short passages of text that are 34795 listed, as Front-Cover Texts or Back-Cover Texts, in the notice 34796 that says that the Document is released under this License. A 34797 Front-Cover Text may be at most 5 words, and a Back-Cover Text may 34798 be at most 25 words. 34799 34800 A "Transparent" copy of the Document means a machine-readable copy, 34801 represented in a format whose specification is available to the 34802 general public, that is suitable for revising the document 34803 straightforwardly with generic text editors or (for images 34804 composed of pixels) generic paint programs or (for drawings) some 34805 widely available drawing editor, and that is suitable for input to 34806 text formatters or for automatic translation to a variety of 34807 formats suitable for input to text formatters. A copy made in an 34808 otherwise Transparent file format whose markup, or absence of 34809 markup, has been arranged to thwart or discourage subsequent 34810 modification by readers is not Transparent. An image format is 34811 not Transparent if used for any substantial amount of text. A 34812 copy that is not "Transparent" is called "Opaque". 34813 34814 Examples of suitable formats for Transparent copies include plain 34815 ASCII without markup, Texinfo input format, LaTeX input format, 34816 SGML or XML using a publicly available DTD, and 34817 standard-conforming simple HTML, PostScript or PDF designed for 34818 human modification. Examples of transparent image formats include 34819 PNG, XCF and JPG. Opaque formats include proprietary formats that 34820 can be read and edited only by proprietary word processors, SGML or 34821 XML for which the DTD and/or processing tools are not generally 34822 available, and the machine-generated HTML, PostScript or PDF 34823 produced by some word processors for output purposes only. 34824 34825 The "Title Page" means, for a printed book, the title page itself, 34826 plus such following pages as are needed to hold, legibly, the 34827 material this License requires to appear in the title page. For 34828 works in formats which do not have any title page as such, "Title 34829 Page" means the text near the most prominent appearance of the 34830 work's title, preceding the beginning of the body of the text. 34831 34832 The "publisher" means any person or entity that distributes copies 34833 of the Document to the public. 34834 34835 A section "Entitled XYZ" means a named subunit of the Document 34836 whose title either is precisely XYZ or contains XYZ in parentheses 34837 following text that translates XYZ in another language. (Here XYZ 34838 stands for a specific section name mentioned below, such as 34839 "Acknowledgements", "Dedications", "Endorsements", or "History".) 34840 To "Preserve the Title" of such a section when you modify the 34841 Document means that it remains a section "Entitled XYZ" according 34842 to this definition. 34843 34844 The Document may include Warranty Disclaimers next to the notice 34845 which states that this License applies to the Document. These 34846 Warranty Disclaimers are considered to be included by reference in 34847 this License, but only as regards disclaiming warranties: any other 34848 implication that these Warranty Disclaimers may have is void and 34849 has no effect on the meaning of this License. 34850 34851 2. VERBATIM COPYING 34852 34853 You may copy and distribute the Document in any medium, either 34854 commercially or noncommercially, provided that this License, the 34855 copyright notices, and the license notice saying this License 34856 applies to the Document are reproduced in all copies, and that you 34857 add no other conditions whatsoever to those of this License. You 34858 may not use technical measures to obstruct or control the reading 34859 or further copying of the copies you make or distribute. However, 34860 you may accept compensation in exchange for copies. If you 34861 distribute a large enough number of copies you must also follow 34862 the conditions in section 3. 34863 34864 You may also lend copies, under the same conditions stated above, 34865 and you may publicly display copies. 34866 34867 3. COPYING IN QUANTITY 34868 34869 If you publish printed copies (or copies in media that commonly 34870 have printed covers) of the Document, numbering more than 100, and 34871 the Document's license notice requires Cover Texts, you must 34872 enclose the copies in covers that carry, clearly and legibly, all 34873 these Cover Texts: Front-Cover Texts on the front cover, and 34874 Back-Cover Texts on the back cover. Both covers must also clearly 34875 and legibly identify you as the publisher of these copies. The 34876 front cover must present the full title with all words of the 34877 title equally prominent and visible. You may add other material 34878 on the covers in addition. Copying with changes limited to the 34879 covers, as long as they preserve the title of the Document and 34880 satisfy these conditions, can be treated as verbatim copying in 34881 other respects. 34882 34883 If the required texts for either cover are too voluminous to fit 34884 legibly, you should put the first ones listed (as many as fit 34885 reasonably) on the actual cover, and continue the rest onto 34886 adjacent pages. 34887 34888 If you publish or distribute Opaque copies of the Document 34889 numbering more than 100, you must either include a 34890 machine-readable Transparent copy along with each Opaque copy, or 34891 state in or with each Opaque copy a computer-network location from 34892 which the general network-using public has access to download 34893 using public-standard network protocols a complete Transparent 34894 copy of the Document, free of added material. If you use the 34895 latter option, you must take reasonably prudent steps, when you 34896 begin distribution of Opaque copies in quantity, to ensure that 34897 this Transparent copy will remain thus accessible at the stated 34898 location until at least one year after the last time you 34899 distribute an Opaque copy (directly or through your agents or 34900 retailers) of that edition to the public. 34901 34902 It is requested, but not required, that you contact the authors of 34903 the Document well before redistributing any large number of 34904 copies, to give them a chance to provide you with an updated 34905 version of the Document. 34906 34907 4. MODIFICATIONS 34908 34909 You may copy and distribute a Modified Version of the Document 34910 under the conditions of sections 2 and 3 above, provided that you 34911 release the Modified Version under precisely this License, with 34912 the Modified Version filling the role of the Document, thus 34913 licensing distribution and modification of the Modified Version to 34914 whoever possesses a copy of it. In addition, you must do these 34915 things in the Modified Version: 34916 34917 A. Use in the Title Page (and on the covers, if any) a title 34918 distinct from that of the Document, and from those of 34919 previous versions (which should, if there were any, be listed 34920 in the History section of the Document). You may use the 34921 same title as a previous version if the original publisher of 34922 that version gives permission. 34923 34924 B. List on the Title Page, as authors, one or more persons or 34925 entities responsible for authorship of the modifications in 34926 the Modified Version, together with at least five of the 34927 principal authors of the Document (all of its principal 34928 authors, if it has fewer than five), unless they release you 34929 from this requirement. 34930 34931 C. State on the Title page the name of the publisher of the 34932 Modified Version, as the publisher. 34933 34934 D. Preserve all the copyright notices of the Document. 34935 34936 E. Add an appropriate copyright notice for your modifications 34937 adjacent to the other copyright notices. 34938 34939 F. Include, immediately after the copyright notices, a license 34940 notice giving the public permission to use the Modified 34941 Version under the terms of this License, in the form shown in 34942 the Addendum below. 34943 34944 G. Preserve in that license notice the full lists of Invariant 34945 Sections and required Cover Texts given in the Document's 34946 license notice. 34947 34948 H. Include an unaltered copy of this License. 34949 34950 I. Preserve the section Entitled "History", Preserve its Title, 34951 and add to it an item stating at least the title, year, new 34952 authors, and publisher of the Modified Version as given on 34953 the Title Page. If there is no section Entitled "History" in 34954 the Document, create one stating the title, year, authors, 34955 and publisher of the Document as given on its Title Page, 34956 then add an item describing the Modified Version as stated in 34957 the previous sentence. 34958 34959 J. Preserve the network location, if any, given in the Document 34960 for public access to a Transparent copy of the Document, and 34961 likewise the network locations given in the Document for 34962 previous versions it was based on. These may be placed in 34963 the "History" section. You may omit a network location for a 34964 work that was published at least four years before the 34965 Document itself, or if the original publisher of the version 34966 it refers to gives permission. 34967 34968 K. For any section Entitled "Acknowledgements" or "Dedications", 34969 Preserve the Title of the section, and preserve in the 34970 section all the substance and tone of each of the contributor 34971 acknowledgements and/or dedications given therein. 34972 34973 L. Preserve all the Invariant Sections of the Document, 34974 unaltered in their text and in their titles. Section numbers 34975 or the equivalent are not considered part of the section 34976 titles. 34977 34978 M. Delete any section Entitled "Endorsements". Such a section 34979 may not be included in the Modified Version. 34980 34981 N. Do not retitle any existing section to be Entitled 34982 "Endorsements" or to conflict in title with any Invariant 34983 Section. 34984 34985 O. Preserve any Warranty Disclaimers. 34986 34987 If the Modified Version includes new front-matter sections or 34988 appendices that qualify as Secondary Sections and contain no 34989 material copied from the Document, you may at your option 34990 designate some or all of these sections as invariant. To do this, 34991 add their titles to the list of Invariant Sections in the Modified 34992 Version's license notice. These titles must be distinct from any 34993 other section titles. 34994 34995 You may add a section Entitled "Endorsements", provided it contains 34996 nothing but endorsements of your Modified Version by various 34997 parties--for example, statements of peer review or that the text 34998 has been approved by an organization as the authoritative 34999 definition of a standard. 35000 35001 You may add a passage of up to five words as a Front-Cover Text, 35002 and a passage of up to 25 words as a Back-Cover Text, to the end 35003 of the list of Cover Texts in the Modified Version. Only one 35004 passage of Front-Cover Text and one of Back-Cover Text may be 35005 added by (or through arrangements made by) any one entity. If the 35006 Document already includes a cover text for the same cover, 35007 previously added by you or by arrangement made by the same entity 35008 you are acting on behalf of, you may not add another; but you may 35009 replace the old one, on explicit permission from the previous 35010 publisher that added the old one. 35011 35012 The author(s) and publisher(s) of the Document do not by this 35013 License give permission to use their names for publicity for or to 35014 assert or imply endorsement of any Modified Version. 35015 35016 5. COMBINING DOCUMENTS 35017 35018 You may combine the Document with other documents released under 35019 this License, under the terms defined in section 4 above for 35020 modified versions, provided that you include in the combination 35021 all of the Invariant Sections of all of the original documents, 35022 unmodified, and list them all as Invariant Sections of your 35023 combined work in its license notice, and that you preserve all 35024 their Warranty Disclaimers. 35025 35026 The combined work need only contain one copy of this License, and 35027 multiple identical Invariant Sections may be replaced with a single 35028 copy. If there are multiple Invariant Sections with the same name 35029 but different contents, make the title of each such section unique 35030 by adding at the end of it, in parentheses, the name of the 35031 original author or publisher of that section if known, or else a 35032 unique number. Make the same adjustment to the section titles in 35033 the list of Invariant Sections in the license notice of the 35034 combined work. 35035 35036 In the combination, you must combine any sections Entitled 35037 "History" in the various original documents, forming one section 35038 Entitled "History"; likewise combine any sections Entitled 35039 "Acknowledgements", and any sections Entitled "Dedications". You 35040 must delete all sections Entitled "Endorsements." 35041 35042 6. COLLECTIONS OF DOCUMENTS 35043 35044 You may make a collection consisting of the Document and other 35045 documents released under this License, and replace the individual 35046 copies of this License in the various documents with a single copy 35047 that is included in the collection, provided that you follow the 35048 rules of this License for verbatim copying of each of the 35049 documents in all other respects. 35050 35051 You may extract a single document from such a collection, and 35052 distribute it individually under this License, provided you insert 35053 a copy of this License into the extracted document, and follow 35054 this License in all other respects regarding verbatim copying of 35055 that document. 35056 35057 7. AGGREGATION WITH INDEPENDENT WORKS 35058 35059 A compilation of the Document or its derivatives with other 35060 separate and independent documents or works, in or on a volume of 35061 a storage or distribution medium, is called an "aggregate" if the 35062 copyright resulting from the compilation is not used to limit the 35063 legal rights of the compilation's users beyond what the individual 35064 works permit. When the Document is included in an aggregate, this 35065 License does not apply to the other works in the aggregate which 35066 are not themselves derivative works of the Document. 35067 35068 If the Cover Text requirement of section 3 is applicable to these 35069 copies of the Document, then if the Document is less than one half 35070 of the entire aggregate, the Document's Cover Texts may be placed 35071 on covers that bracket the Document within the aggregate, or the 35072 electronic equivalent of covers if the Document is in electronic 35073 form. Otherwise they must appear on printed covers that bracket 35074 the whole aggregate. 35075 35076 8. TRANSLATION 35077 35078 Translation is considered a kind of modification, so you may 35079 distribute translations of the Document under the terms of section 35080 4. Replacing Invariant Sections with translations requires special 35081 permission from their copyright holders, but you may include 35082 translations of some or all Invariant Sections in addition to the 35083 original versions of these Invariant Sections. You may include a 35084 translation of this License, and all the license notices in the 35085 Document, and any Warranty Disclaimers, provided that you also 35086 include the original English version of this License and the 35087 original versions of those notices and disclaimers. In case of a 35088 disagreement between the translation and the original version of 35089 this License or a notice or disclaimer, the original version will 35090 prevail. 35091 35092 If a section in the Document is Entitled "Acknowledgements", 35093 "Dedications", or "History", the requirement (section 4) to 35094 Preserve its Title (section 1) will typically require changing the 35095 actual title. 35096 35097 9. TERMINATION 35098 35099 You may not copy, modify, sublicense, or distribute the Document 35100 except as expressly provided under this License. Any attempt 35101 otherwise to copy, modify, sublicense, or distribute it is void, 35102 and will automatically terminate your rights under this License. 35103 35104 However, if you cease all violation of this License, then your 35105 license from a particular copyright holder is reinstated (a) 35106 provisionally, unless and until the copyright holder explicitly 35107 and finally terminates your license, and (b) permanently, if the 35108 copyright holder fails to notify you of the violation by some 35109 reasonable means prior to 60 days after the cessation. 35110 35111 Moreover, your license from a particular copyright holder is 35112 reinstated permanently if the copyright holder notifies you of the 35113 violation by some reasonable means, this is the first time you have 35114 received notice of violation of this License (for any work) from 35115 that copyright holder, and you cure the violation prior to 30 days 35116 after your receipt of the notice. 35117 35118 Termination of your rights under this section does not terminate 35119 the licenses of parties who have received copies or rights from 35120 you under this License. If your rights have been terminated and 35121 not permanently reinstated, receipt of a copy of some or all of 35122 the same material does not give you any rights to use it. 35123 35124 10. FUTURE REVISIONS OF THIS LICENSE 35125 35126 The Free Software Foundation may publish new, revised versions of 35127 the GNU Free Documentation License from time to time. Such new 35128 versions will be similar in spirit to the present version, but may 35129 differ in detail to address new problems or concerns. See 35130 `http://www.gnu.org/copyleft/'. 35131 35132 Each version of the License is given a distinguishing version 35133 number. If the Document specifies that a particular numbered 35134 version of this License "or any later version" applies to it, you 35135 have the option of following the terms and conditions either of 35136 that specified version or of any later version that has been 35137 published (not as a draft) by the Free Software Foundation. If 35138 the Document does not specify a version number of this License, 35139 you may choose any version ever published (not as a draft) by the 35140 Free Software Foundation. If the Document specifies that a proxy 35141 can decide which future versions of this License can be used, that 35142 proxy's public statement of acceptance of a version permanently 35143 authorizes you to choose that version for the Document. 35144 35145 11. RELICENSING 35146 35147 "Massive Multiauthor Collaboration Site" (or "MMC Site") means any 35148 World Wide Web server that publishes copyrightable works and also 35149 provides prominent facilities for anybody to edit those works. A 35150 public wiki that anybody can edit is an example of such a server. 35151 A "Massive Multiauthor Collaboration" (or "MMC") contained in the 35152 site means any set of copyrightable works thus published on the MMC 35153 site. 35154 35155 "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0 35156 license published by Creative Commons Corporation, a not-for-profit 35157 corporation with a principal place of business in San Francisco, 35158 California, as well as future copyleft versions of that license 35159 published by that same organization. 35160 35161 "Incorporate" means to publish or republish a Document, in whole or 35162 in part, as part of another Document. 35163 35164 An MMC is "eligible for relicensing" if it is licensed under this 35165 License, and if all works that were first published under this 35166 License somewhere other than this MMC, and subsequently 35167 incorporated in whole or in part into the MMC, (1) had no cover 35168 texts or invariant sections, and (2) were thus incorporated prior 35169 to November 1, 2008. 35170 35171 The operator of an MMC Site may republish an MMC contained in the 35172 site under CC-BY-SA on the same site at any time before August 1, 35173 2009, provided the MMC is eligible for relicensing. 35174 35175 35176 ADDENDUM: How to use this License for your documents 35177 ==================================================== 35178 35179 To use this License in a document you have written, include a copy of 35180 the License in the document and put the following copyright and license 35181 notices just after the title page: 35182 35183 Copyright (C) YEAR YOUR NAME. 35184 Permission is granted to copy, distribute and/or modify this document 35185 under the terms of the GNU Free Documentation License, Version 1.3 35186 or any later version published by the Free Software Foundation; 35187 with no Invariant Sections, no Front-Cover Texts, and no Back-Cover 35188 Texts. A copy of the license is included in the section entitled ``GNU 35189 Free Documentation License''. 35190 35191 If you have Invariant Sections, Front-Cover Texts and Back-Cover 35192 Texts, replace the "with...Texts." line with this: 35193 35194 with the Invariant Sections being LIST THEIR TITLES, with 35195 the Front-Cover Texts being LIST, and with the Back-Cover Texts 35196 being LIST. 35197 35198 If you have Invariant Sections without Cover Texts, or some other 35199 combination of the three, merge those two alternatives to suit the 35200 situation. 35201 35202 If your document contains nontrivial examples of program code, we 35203 recommend releasing these examples in parallel under your choice of 35204 free software license, such as the GNU General Public License, to 35205 permit their use in free software. 35206 35207 35208 File: gdb.info, Node: Index, Prev: GNU Free Documentation License, Up: Top 35209 35210 Index 35211 ***** 35212 35213 [index] 35214 * Menu: 35215 35216 * ! packet: Packets. (line 49) 35217 * "No symbol "foo" in current context": Variables. (line 74) 35218 * # (a comment): Command Syntax. (line 38) 35219 * # in Modula-2: GDB/M2. (line 18) 35220 * $: Value History. (line 13) 35221 * $$: Value History. (line 13) 35222 * $_ and info breakpoints: Set Breaks. (line 128) 35223 * $_ and info line: Machine Code. (line 30) 35224 * $_, $__, and value history: Memory. (line 109) 35225 * $_, convenience variable: Convenience Vars. (line 64) 35226 * $__, convenience variable: Convenience Vars. (line 73) 35227 * $_exitcode, convenience variable: Convenience Vars. (line 79) 35228 * $_sdata, collect: Tracepoint Actions. (line 65) 35229 * $_sdata, inspect, convenience variable: Convenience Vars. (line 83) 35230 * $_siginfo, convenience variable: Convenience Vars. (line 89) 35231 * $_thread, convenience variable: Threads. (line 116) 35232 * $_tlb, convenience variable: Convenience Vars. (line 95) 35233 * $bpnum, convenience variable: Set Breaks. (line 6) 35234 * $cdir, convenience variable: Source Path. (line 108) 35235 * $cwd, convenience variable: Source Path. (line 108) 35236 * $tpnum: Create and Delete Tracepoints. 35237 (line 98) 35238 * $trace_file: Tracepoint Variables. 35239 (line 16) 35240 * $trace_frame: Tracepoint Variables. 35241 (line 6) 35242 * $trace_func: Tracepoint Variables. 35243 (line 19) 35244 * $trace_line: Tracepoint Variables. 35245 (line 13) 35246 * $tracepoint: Tracepoint Variables. 35247 (line 10) 35248 * --annotate: Mode Options. (line 107) 35249 * --args: Mode Options. (line 120) 35250 * --batch: Mode Options. (line 23) 35251 * --batch-silent: Mode Options. (line 41) 35252 * --baud: Mode Options. (line 126) 35253 * --cd: Mode Options. (line 82) 35254 * --command: File Options. (line 51) 35255 * --core: File Options. (line 43) 35256 * --data-directory: Mode Options. (line 86) 35257 * --directory: File Options. (line 67) 35258 * --disable-gdb-index: Mode Options. (line 172) 35259 * --epoch: Mode Options. (line 102) 35260 * --eval-command: File Options. (line 57) 35261 * --exec: File Options. (line 35) 35262 * --fullname: Mode Options. (line 91) 35263 * --interpreter: Mode Options. (line 147) 35264 * --nowindows: Mode Options. (line 72) 35265 * --nx: Mode Options. (line 11) 35266 * --pid: File Options. (line 47) 35267 * --quiet: Mode Options. (line 19) 35268 * --readnow: File Options. (line 71) 35269 * --return-child-result: Mode Options. (line 53) 35270 * --se: File Options. (line 39) 35271 * --silent: Mode Options. (line 19) 35272 * --statistics: Mode Options. (line 164) 35273 * --symbols: File Options. (line 31) 35274 * --tty: Mode Options. (line 135) 35275 * --tui: Mode Options. (line 138) 35276 * --version: Mode Options. (line 168) 35277 * --windows: Mode Options. (line 78) 35278 * --with-gdb-datadir: Data Files. (line 19) 35279 * --with-relocated-sources: Source Path. (line 89) 35280 * --with-sysroot: Files. (line 434) 35281 * --write: Mode Options. (line 159) 35282 * -add-inferior: GDB/MI Miscellaneous Commands. 35283 (line 288) 35284 * -b: Mode Options. (line 126) 35285 * -break-after: GDB/MI Breakpoint Commands. 35286 (line 11) 35287 * -break-commands: GDB/MI Breakpoint Commands. 35288 (line 55) 35289 * -break-condition: GDB/MI Breakpoint Commands. 35290 (line 88) 35291 * -break-delete: GDB/MI Breakpoint Commands. 35292 (line 125) 35293 * -break-disable: GDB/MI Breakpoint Commands. 35294 (line 159) 35295 * -break-enable: GDB/MI Breakpoint Commands. 35296 (line 195) 35297 * -break-info: GDB/MI Breakpoint Commands. 35298 (line 230) 35299 * -break-insert: GDB/MI Breakpoint Commands. 35300 (line 250) 35301 * -break-list: GDB/MI Breakpoint Commands. 35302 (line 355) 35303 * -break-passcount: GDB/MI Breakpoint Commands. 35304 (line 430) 35305 * -break-watch: GDB/MI Breakpoint Commands. 35306 (line 442) 35307 * -c: File Options. (line 43) 35308 * -d: File Options. (line 67) 35309 * -data-disassemble: GDB/MI Data Manipulation. 35310 (line 12) 35311 * -data-evaluate-expression: GDB/MI Data Manipulation. 35312 (line 141) 35313 * -data-list-changed-registers: GDB/MI Data Manipulation. 35314 (line 179) 35315 * -data-list-register-names: GDB/MI Data Manipulation. 35316 (line 215) 35317 * -data-list-register-values: GDB/MI Data Manipulation. 35318 (line 255) 35319 * -data-read-memory: GDB/MI Data Manipulation. 35320 (line 345) 35321 * -data-read-memory-bytes: GDB/MI Data Manipulation. 35322 (line 452) 35323 * -data-write-memory-bytes: GDB/MI Data Manipulation. 35324 (line 527) 35325 * -e: File Options. (line 35) 35326 * -enable-pretty-printing: GDB/MI Variable Objects. 35327 (line 116) 35328 * -enable-timings: GDB/MI Miscellaneous Commands. 35329 (line 384) 35330 * -environment-cd: GDB/MI Program Context. 35331 (line 33) 35332 * -environment-directory: GDB/MI Program Context. 35333 (line 56) 35334 * -environment-path: GDB/MI Program Context. 35335 (line 100) 35336 * -environment-pwd: GDB/MI Program Context. 35337 (line 141) 35338 * -ex: File Options. (line 57) 35339 * -exec-arguments: GDB/MI Program Context. 35340 (line 9) 35341 * -exec-continue: GDB/MI Program Execution. 35342 (line 13) 35343 * -exec-finish: GDB/MI Program Execution. 35344 (line 56) 35345 * -exec-interrupt: GDB/MI Program Execution. 35346 (line 99) 35347 * -exec-jump: GDB/MI Program Execution. 35348 (line 149) 35349 * -exec-next: GDB/MI Program Execution. 35350 (line 173) 35351 * -exec-next-instruction: GDB/MI Program Execution. 35352 (line 204) 35353 * -exec-return: GDB/MI Program Execution. 35354 (line 240) 35355 * -exec-run: GDB/MI Program Execution. 35356 (line 283) 35357 * -exec-step: GDB/MI Program Execution. 35358 (line 348) 35359 * -exec-step-instruction: GDB/MI Program Execution. 35360 (line 390) 35361 * -exec-until: GDB/MI Program Execution. 35362 (line 431) 35363 * -f: Mode Options. (line 91) 35364 * -file-exec-and-symbols: GDB/MI File Commands. 35365 (line 12) 35366 * -file-exec-file: GDB/MI File Commands. 35367 (line 40) 35368 * -file-list-exec-source-file: GDB/MI File Commands. 35369 (line 67) 35370 * -file-list-exec-source-files: GDB/MI File Commands. 35371 (line 93) 35372 * -file-symbol-file: GDB/MI File Commands. 35373 (line 123) 35374 * -gdb-exit: GDB/MI Miscellaneous Commands. 35375 (line 9) 35376 * -gdb-set: GDB/MI Miscellaneous Commands. 35377 (line 31) 35378 * -gdb-show: GDB/MI Miscellaneous Commands. 35379 (line 54) 35380 * -gdb-version: GDB/MI Miscellaneous Commands. 35381 (line 77) 35382 * -inferior-tty-set: GDB/MI Miscellaneous Commands. 35383 (line 335) 35384 * -inferior-tty-show: GDB/MI Miscellaneous Commands. 35385 (line 358) 35386 * -interpreter-exec: GDB/MI Miscellaneous Commands. 35387 (line 310) 35388 * -l: Mode Options. (line 130) 35389 * -list-features: GDB/MI Miscellaneous Commands. 35390 (line 111) 35391 * -list-target-features: GDB/MI Miscellaneous Commands. 35392 (line 154) 35393 * -list-thread-groups: GDB/MI Miscellaneous Commands. 35394 (line 180) 35395 * -n: Mode Options. (line 11) 35396 * -nw: Mode Options. (line 72) 35397 * -p: File Options. (line 47) 35398 * -q: Mode Options. (line 19) 35399 * -r: File Options. (line 71) 35400 * -s: File Options. (line 31) 35401 * -stack-info-depth: GDB/MI Stack Manipulation. 35402 (line 35) 35403 * -stack-info-frame: GDB/MI Stack Manipulation. 35404 (line 9) 35405 * -stack-list-arguments: GDB/MI Stack Manipulation. 35406 (line 73) 35407 * -stack-list-frames: GDB/MI Stack Manipulation. 35408 (line 162) 35409 * -stack-list-locals: GDB/MI Stack Manipulation. 35410 (line 265) 35411 * -stack-list-variables: GDB/MI Stack Manipulation. 35412 (line 305) 35413 * -stack-select-frame: GDB/MI Stack Manipulation. 35414 (line 328) 35415 * -symbol-list-lines: GDB/MI Symbol Query. (line 9) 35416 * -t: Mode Options. (line 135) 35417 * -target-attach: GDB/MI Target Manipulation. 35418 (line 9) 35419 * -target-detach: GDB/MI Target Manipulation. 35420 (line 36) 35421 * -target-disconnect: GDB/MI Target Manipulation. 35422 (line 61) 35423 * -target-download: GDB/MI Target Manipulation. 35424 (line 85) 35425 * -target-file-delete: GDB/MI File Transfer Commands. 35426 (line 57) 35427 * -target-file-get: GDB/MI File Transfer Commands. 35428 (line 33) 35429 * -target-file-put: GDB/MI File Transfer Commands. 35430 (line 9) 35431 * -target-select: GDB/MI Target Manipulation. 35432 (line 198) 35433 * -thread-info: GDB/MI Thread Commands. 35434 (line 9) 35435 * -thread-list-ids: GDB/MI Thread Commands. 35436 (line 90) 35437 * -thread-select: GDB/MI Thread Commands. 35438 (line 118) 35439 * -trace-define-variable: GDB/MI Tracepoint Commands. 35440 (line 83) 35441 * -trace-find: GDB/MI Tracepoint Commands. 35442 (line 12) 35443 * -trace-list-variables: GDB/MI Tracepoint Commands. 35444 (line 100) 35445 * -trace-save: GDB/MI Tracepoint Commands. 35446 (line 143) 35447 * -trace-start: GDB/MI Tracepoint Commands. 35448 (line 160) 35449 * -trace-status: GDB/MI Tracepoint Commands. 35450 (line 176) 35451 * -trace-stop: GDB/MI Tracepoint Commands. 35452 (line 244) 35453 * -var-assign: GDB/MI Variable Objects. 35454 (line 474) 35455 * -var-create: GDB/MI Variable Objects. 35456 (line 134) 35457 * -var-delete: GDB/MI Variable Objects. 35458 (line 220) 35459 * -var-evaluate-expression: GDB/MI Variable Objects. 35460 (line 453) 35461 * -var-info-expression: GDB/MI Variable Objects. 35462 (line 391) 35463 * -var-info-num-children: GDB/MI Variable Objects. 35464 (line 269) 35465 * -var-info-path-expression: GDB/MI Variable Objects. 35466 (line 415) 35467 * -var-info-type: GDB/MI Variable Objects. 35468 (line 378) 35469 * -var-list-children: GDB/MI Variable Objects. 35470 (line 285) 35471 * -var-set-format: GDB/MI Variable Objects. 35472 (line 233) 35473 * -var-set-frozen: GDB/MI Variable Objects. 35474 (line 612) 35475 * -var-set-update-range: GDB/MI Variable Objects. 35476 (line 638) 35477 * -var-set-visualizer: GDB/MI Variable Objects. 35478 (line 661) 35479 * -var-show-attributes: GDB/MI Variable Objects. 35480 (line 439) 35481 * -var-show-format: GDB/MI Variable Objects. 35482 (line 256) 35483 * -var-update: GDB/MI Variable Objects. 35484 (line 498) 35485 * -w: Mode Options. (line 78) 35486 * -x: File Options. (line 51) 35487 * ., Modula-2 scope operator: M2 Scope. (line 6) 35488 * .build-id directory: Separate Debug Files. 35489 (line 6) 35490 * .debug subdirectories: Separate Debug Files. 35491 (line 6) 35492 * .debug_gdb_scripts section: .debug_gdb_scripts section. 35493 (line 6) 35494 * .gdb_index section: Index Files. (line 6) 35495 * .gdbinit: Startup. (line 60) 35496 * .gnu_debuglink sections: Separate Debug Files. 35497 (line 78) 35498 * .note.gnu.build-id sections: Separate Debug Files. 35499 (line 96) 35500 * .o files, reading symbols from: Files. (line 132) 35501 * /proc: SVR4 Process Information. 35502 (line 6) 35503 * <architecture>: Target Description Format. 35504 (line 73) 35505 * <compatible>: Target Description Format. 35506 (line 96) 35507 * <feature>: Target Description Format. 35508 (line 120) 35509 * <flags>: Target Description Format. 35510 (line 186) 35511 * <osabi>: Target Description Format. 35512 (line 83) 35513 * <reg>: Target Description Format. 35514 (line 199) 35515 * <struct>: Target Description Format. 35516 (line 164) 35517 * <union>: Target Description Format. 35518 (line 154) 35519 * <vector>: Target Description Format. 35520 (line 147) 35521 * ? packet: Packets. (line 58) 35522 * @, referencing memory as an array: Arrays. (line 6) 35523 * ^connected: GDB/MI Result Records. 35524 (line 22) 35525 * ^done: GDB/MI Result Records. 35526 (line 9) 35527 * ^error: GDB/MI Result Records. 35528 (line 25) 35529 * ^exit: GDB/MI Result Records. 35530 (line 29) 35531 * ^running: GDB/MI Result Records. 35532 (line 14) 35533 * __init__ on Breakpoint: Breakpoints In Python. 35534 (line 9) 35535 * __init__ on Command: Commands In Python. (line 12) 35536 * __init__ on Function: Functions In Python. (line 11) 35537 * __init__ on Parameter: Parameters In Python. 35538 (line 20) 35539 * __init__ on Value: Values From Inferior. 35540 (line 76) 35541 * _NSPrintForDebugger, and printing Objective-C objects: The Print Command with Objective-C. 35542 (line 11) 35543 * A packet: Packets. (line 65) 35544 * abbreviation: Command Syntax. (line 13) 35545 * abort (C-g): Miscellaneous Commands. 35546 (line 10) 35547 * accept-line (Newline or Return): Commands For History. 35548 (line 6) 35549 * acknowledgment, for GDB remote: Packet Acknowledgment. 35550 (line 6) 35551 * actions: Tracepoint Actions. (line 6) 35552 * active targets: Active Targets. (line 6) 35553 * Ada: Ada. (line 6) 35554 * Ada exception catching: Set Catchpoints. (line 19) 35555 * Ada mode, general: Ada Mode Intro. (line 6) 35556 * Ada task switching: Ada Tasks. (line 115) 35557 * Ada tasking and core file debugging: Ada Tasks and Core Files. 35558 (line 6) 35559 * Ada, deviations from: Additions to Ada. (line 6) 35560 * Ada, omissions from: Omissions from Ada. (line 6) 35561 * Ada, problems: Ada Glitches. (line 6) 35562 * Ada, tasking: Ada Tasks. (line 6) 35563 * add new commands for external monitor: Connecting. (line 105) 35564 * add-inferior: Inferiors and Programs. 35565 (line 60) 35566 * add-shared-symbol-files: Files. (line 172) 35567 * add-symbol-file: Files. (line 113) 35568 * add-symbol-file-from-memory: Files. (line 162) 35569 * addr_class: Symbols In Python. (line 71) 35570 * address <1>: Lazy Strings In Python. 35571 (line 27) 35572 * address: Values From Inferior. 35573 (line 45) 35574 * address of a symbol: Symbols. (line 44) 35575 * address size for remote targets: Remote Configuration. 35576 (line 12) 35577 * ADP (Angel Debugger Protocol) logging: ARM. (line 89) 35578 * advance LOCATION: Continuing and Stepping. 35579 (line 181) 35580 * aggregates (Ada): Omissions from Ada. (line 44) 35581 * AIX threads: Debugging Output. (line 28) 35582 * alignment of remote memory accesses: Packets. (line 228) 35583 * all-stop mode: All-Stop Mode. (line 6) 35584 * Alpha stack: MIPS. (line 6) 35585 * ambiguous expressions: Ambiguous Expressions. 35586 (line 6) 35587 * AMD 29K register stack: A29K. (line 6) 35588 * annotations: Annotations Overview. 35589 (line 6) 35590 * annotations for errors, warnings and interrupts: Errors. (line 6) 35591 * annotations for invalidation messages: Invalidation. (line 6) 35592 * annotations for prompts: Prompting. (line 6) 35593 * annotations for running programs: Annotations for Running. 35594 (line 6) 35595 * annotations for source display: Source Annotations. (line 6) 35596 * append: Dump/Restore Files. (line 35) 35597 * append data to a file: Dump/Restore Files. (line 6) 35598 * apply command to several threads: Threads. (line 122) 35599 * apropos: Help. (line 62) 35600 * architecture debugging info: Debugging Output. (line 18) 35601 * argument count in user-defined commands: Define. (line 25) 35602 * arguments (to your program): Arguments. (line 6) 35603 * arguments, to gdbserver: Server. (line 34) 35604 * arguments, to user-defined commands: Define. (line 6) 35605 * ARM 32-bit mode: ARM. (line 25) 35606 * ARM RDI: ARM. (line 6) 35607 * array aggregates (Ada): Omissions from Ada. (line 44) 35608 * array on Type: Types In Python. (line 82) 35609 * arrays: Arrays. (line 6) 35610 * arrays in expressions: Expressions. (line 14) 35611 * artificial array: Arrays. (line 6) 35612 * assembly instructions: Machine Code. (line 36) 35613 * assf: Files. (line 172) 35614 * assignment: Assignment. (line 6) 35615 * async output in GDB/MI: GDB/MI Output Syntax. 35616 (line 98) 35617 * async records in GDB/MI: GDB/MI Async Records. 35618 (line 6) 35619 * asynchronous execution: Background Execution. 35620 (line 6) 35621 * asynchronous execution, and process record and replay: Process Record and Replay. 35622 (line 52) 35623 * AT&T disassembly flavor: Machine Code. (line 127) 35624 * attach: Attach. (line 6) 35625 * attach to a program by name: Server. (line 79) 35626 * attach&: Background Execution. 35627 (line 38) 35628 * auto-loading, Python: Auto-loading. (line 6) 35629 * auto-retry, for remote TCP target: Remote Configuration. 35630 (line 108) 35631 * automatic display: Auto Display. (line 6) 35632 * automatic hardware breakpoints: Set Breaks. (line 284) 35633 * automatic overlay debugging: Automatic Overlay Debugging. 35634 (line 6) 35635 * automatic thread selection: All-Stop Mode. (line 28) 35636 * auxiliary vector: OS Information. (line 21) 35637 * AVR: AVR. (line 6) 35638 * awatch: Set Watchpoints. (line 68) 35639 * b (break): Set Breaks. (line 6) 35640 * B packet: Packets. (line 92) 35641 * b packet: Packets. (line 77) 35642 * background execution: Background Execution. 35643 (line 6) 35644 * backtrace: Backtrace. (line 11) 35645 * backtrace beyond main function: Backtrace. (line 93) 35646 * backtrace limit: Backtrace. (line 129) 35647 * backward-char (C-b): Commands For Moving. (line 15) 35648 * backward-delete-char (Rubout): Commands For Text. (line 11) 35649 * backward-kill-line (C-x Rubout): Commands For Killing. 35650 (line 9) 35651 * backward-kill-word (M-<DEL>): Commands For Killing. 35652 (line 24) 35653 * backward-word (M-b): Commands For Moving. (line 22) 35654 * base name differences: Files. (line 501) 35655 * baud rate for remote targets: Remote Configuration. 35656 (line 21) 35657 * bc packet: Packets. (line 97) 35658 * bcache statistics: Maintenance Commands. 35659 (line 223) 35660 * beginning-of-history (M-<): Commands For History. 35661 (line 19) 35662 * beginning-of-line (C-a): Commands For Moving. (line 6) 35663 * bell-style: Readline Init File Syntax. 35664 (line 35) 35665 * bind-tty-special-chars: Readline Init File Syntax. 35666 (line 42) 35667 * bits in remote address: Remote Configuration. 35668 (line 12) 35669 * block on Frame: Frames In Python. (line 83) 35670 * block_for_pc: Blocks In Python. (line 17) 35671 * blocks in python: Blocks In Python. (line 6) 35672 * bookmark: Checkpoint/Restart. (line 6) 35673 * BP_ACCESS_WATCHPOINT: Breakpoints In Python. 35674 (line 131) 35675 * BP_BREAKPOINT: Breakpoints In Python. 35676 (line 119) 35677 * BP_HARDWARE_WATCHPOINT: Breakpoints In Python. 35678 (line 125) 35679 * BP_READ_WATCHPOINT: Breakpoints In Python. 35680 (line 128) 35681 * BP_WATCHPOINT: Breakpoints In Python. 35682 (line 122) 35683 * break: Set Breaks. (line 6) 35684 * break ... task TASKNO (Ada): Ada Tasks. (line 135) 35685 * break ... thread THREADNO: Thread-Specific Breakpoints. 35686 (line 10) 35687 * break in overloaded functions: Debugging C Plus Plus. 35688 (line 9) 35689 * break on a system call.: Set Catchpoints. (line 48) 35690 * break on fork/exec: Set Catchpoints. (line 43) 35691 * BREAK signal instead of Ctrl-C: Remote Configuration. 35692 (line 29) 35693 * break, and Objective-C: Method Names in Commands. 35694 (line 9) 35695 * break-range: PowerPC Embedded. (line 38) 35696 * breakpoint: Events In Python. (line 102) 35697 * breakpoint address adjusted: Breakpoint-related Warnings. 35698 (line 6) 35699 * breakpoint annotation: Annotations for Running. 35700 (line 47) 35701 * breakpoint commands: Break Commands. (line 6) 35702 * breakpoint commands for GDB/MI: GDB/MI Breakpoint Commands. 35703 (line 6) 35704 * breakpoint conditions: Conditions. (line 6) 35705 * breakpoint numbers: Breakpoints. (line 41) 35706 * breakpoint on events: Breakpoints. (line 33) 35707 * breakpoint on memory address: Breakpoints. (line 20) 35708 * breakpoint on variable modification: Breakpoints. (line 20) 35709 * breakpoint ranges: Breakpoints. (line 48) 35710 * breakpoint subroutine, remote: Stub Contents. (line 31) 35711 * breakpointing Ada elaboration code: Stopping Before Main Program. 35712 (line 6) 35713 * breakpoints <1>: Basic Python. (line 32) 35714 * breakpoints: Breakpoints. (line 6) 35715 * breakpoints and tasks, in Ada: Ada Tasks. (line 135) 35716 * breakpoints and threads: Thread-Specific Breakpoints. 35717 (line 10) 35718 * breakpoints at functions matching a regexp: Set Breaks. (line 92) 35719 * breakpoints in overlays: Overlay Commands. (line 93) 35720 * breakpoints in python: Breakpoints In Python. 35721 (line 6) 35722 * breakpoints, multiple locations: Set Breaks. (line 190) 35723 * breakpoints-invalid annotation: Invalidation. (line 13) 35724 * bs packet: Packets. (line 103) 35725 * bt (backtrace): Backtrace. (line 11) 35726 * bug criteria: Bug Criteria. (line 6) 35727 * bug reports: Bug Reporting. (line 6) 35728 * bugs in GDB: GDB Bugs. (line 6) 35729 * build ID sections: Separate Debug Files. 35730 (line 96) 35731 * build ID, and separate debugging files: Separate Debug Files. 35732 (line 6) 35733 * building GDB, requirements for: Requirements. (line 6) 35734 * built-in simulator target: Target Commands. (line 73) 35735 * c (continue): Continuing and Stepping. 35736 (line 15) 35737 * c (SingleKey TUI key): TUI Single Key Mode. (line 10) 35738 * C and C++: C. (line 6) 35739 * C and C++ checks: C Checks. (line 6) 35740 * C and C++ constants: C Constants. (line 6) 35741 * C and C++ defaults: C Defaults. (line 6) 35742 * C and C++ operators: C Operators. (line 6) 35743 * C packet: Packets. (line 116) 35744 * c packet: Packets. (line 110) 35745 * C++: C. (line 10) 35746 * C++ compilers: C Plus Plus Expressions. 35747 (line 8) 35748 * C++ exception handling: Debugging C Plus Plus. 35749 (line 20) 35750 * C++ overload debugging info: Debugging Output. (line 125) 35751 * C++ scope resolution: Variables. (line 54) 35752 * C++ symbol decoding style: Print Settings. (line 296) 35753 * C++ symbol display: Debugging C Plus Plus. 35754 (line 29) 35755 * C-L: TUI Keys. (line 65) 35756 * C-x 1: TUI Keys. (line 19) 35757 * C-x 2: TUI Keys. (line 26) 35758 * C-x A: TUI Keys. (line 12) 35759 * C-x a: TUI Keys. (line 11) 35760 * C-x C-a: TUI Keys. (line 10) 35761 * C-x o: TUI Keys. (line 34) 35762 * C-x s: TUI Keys. (line 41) 35763 * caching data of remote targets: Caching Remote Data. (line 6) 35764 * call: Calling. (line 10) 35765 * call dummy stack unwinding: Calling. (line 35) 35766 * call dummy stack unwinding on unhandled exception.: Calling. 35767 (line 46) 35768 * call overloaded functions: C Plus Plus Expressions. 35769 (line 27) 35770 * call stack: Stack. (line 9) 35771 * call stack traces: Backtrace. (line 6) 35772 * call-last-kbd-macro (C-x e): Keyboard Macros. (line 13) 35773 * calling functions: Calling. (line 6) 35774 * calling make: Shell Commands. (line 19) 35775 * capitalize-word (M-c): Commands For Text. (line 49) 35776 * case sensitivity in symbol names: Symbols. (line 27) 35777 * case-insensitive symbol names: Symbols. (line 27) 35778 * cast on Value: Values From Inferior. 35779 (line 109) 35780 * casts, in expressions: Expressions. (line 28) 35781 * casts, to view memory: Expressions. (line 43) 35782 * catch: Set Catchpoints. (line 10) 35783 * catch Ada exceptions: Set Catchpoints. (line 19) 35784 * catch exceptions, list active handlers: Frame Info. (line 60) 35785 * catchpoints: Breakpoints. (line 33) 35786 * catchpoints, setting: Set Catchpoints. (line 6) 35787 * cd: Working Directory. (line 16) 35788 * cdir: Source Path. (line 108) 35789 * Cell Broadband Engine: SPU. (line 6) 35790 * change working directory: Working Directory. (line 16) 35791 * character sets: Character Sets. (line 6) 35792 * character-search (C-]): Miscellaneous Commands. 35793 (line 41) 35794 * character-search-backward (M-C-]): Miscellaneous Commands. 35795 (line 46) 35796 * charset: Character Sets. (line 6) 35797 * checkpoint: Checkpoint/Restart. (line 6) 35798 * checkpoints and process id: Checkpoint/Restart. (line 80) 35799 * checks, range: Type Checking. (line 65) 35800 * checks, type: Checks. (line 31) 35801 * checksum, for GDB remote: Overview. (line 20) 35802 * children on pretty printer: Pretty Printing API. (line 12) 35803 * choosing target byte order: Byte Order. (line 6) 35804 * circular trace buffer: Starting and Stopping Trace Experiments. 35805 (line 74) 35806 * clear: Delete Breaks. (line 21) 35807 * clear, and Objective-C: Method Names in Commands. 35808 (line 9) 35809 * clear-screen (C-l): Commands For Moving. (line 26) 35810 * clearing breakpoints, watchpoints, catchpoints: Delete Breaks. 35811 (line 6) 35812 * clone-inferior: Inferiors and Programs. 35813 (line 67) 35814 * close, file-i/o system call: close. (line 6) 35815 * closest symbol and offset for an address: Symbols. (line 54) 35816 * code: Types In Python. (line 24) 35817 * code address and its source line: Machine Code. (line 25) 35818 * collect (tracepoints): Tracepoint Actions. (line 49) 35819 * collected data discarded: Starting and Stopping Trace Experiments. 35820 (line 6) 35821 * colon, doubled as scope operator: M2 Scope. (line 6) 35822 * colon-colon, context for variables/functions: Variables. (line 44) 35823 * colon-colon, in Modula-2: M2 Scope. (line 6) 35824 * command editing: Readline Bare Essentials. 35825 (line 6) 35826 * command files: Command Files. (line 6) 35827 * command history: Command History. (line 6) 35828 * command hooks: Hooks. (line 6) 35829 * command interpreters: Interpreters. (line 6) 35830 * command line editing: Editing. (line 6) 35831 * command scripts, debugging: Messages/Warnings. (line 67) 35832 * command tracing: Messages/Warnings. (line 62) 35833 * COMMAND_BREAKPOINTS: Commands In Python. (line 145) 35834 * COMMAND_DATA: Commands In Python. (line 115) 35835 * COMMAND_FILES: Commands In Python. (line 126) 35836 * COMMAND_MAINTENANCE: Commands In Python. (line 163) 35837 * COMMAND_NONE: Commands In Python. (line 105) 35838 * COMMAND_OBSCURE: Commands In Python. (line 157) 35839 * COMMAND_RUNNING: Commands In Python. (line 109) 35840 * COMMAND_STACK: Commands In Python. (line 120) 35841 * COMMAND_STATUS: Commands In Python. (line 139) 35842 * COMMAND_SUPPORT: Commands In Python. (line 132) 35843 * COMMAND_TRACEPOINTS: Commands In Python. (line 151) 35844 * commands <1>: Breakpoints In Python. 35845 (line 157) 35846 * commands: Break Commands. (line 11) 35847 * commands annotation: Prompting. (line 27) 35848 * commands for C++: Debugging C Plus Plus. 35849 (line 6) 35850 * commands in python: Commands In Python. (line 6) 35851 * commands to access python: Python Commands. (line 6) 35852 * comment: Command Syntax. (line 38) 35853 * comment-begin: Readline Init File Syntax. 35854 (line 47) 35855 * COMMON blocks, Fortran: Special Fortran Commands. 35856 (line 9) 35857 * common targets: Target Commands. (line 46) 35858 * compare-sections: Memory. (line 129) 35859 * compatibility, GDB/MI and CLI: GDB/MI Compatibility with CLI. 35860 (line 6) 35861 * compilation directory: Source Path. (line 108) 35862 * compiling, on Sparclet: Sparclet. (line 16) 35863 * complete: Help. (line 76) 35864 * complete (<TAB>): Commands For Completion. 35865 (line 6) 35866 * complete on Command: Commands In Python. (line 73) 35867 * COMPLETE_COMMAND: Commands In Python. (line 184) 35868 * COMPLETE_FILENAME: Commands In Python. (line 177) 35869 * COMPLETE_LOCATION: Commands In Python. (line 180) 35870 * COMPLETE_NONE: Commands In Python. (line 174) 35871 * COMPLETE_SYMBOL: Commands In Python. (line 188) 35872 * completion: Completion. (line 6) 35873 * completion of Python commands: Commands In Python. (line 72) 35874 * completion of quoted strings: Completion. (line 57) 35875 * completion of structure field names: Completion. (line 96) 35876 * completion of union field names: Completion. (line 96) 35877 * completion-query-items: Readline Init File Syntax. 35878 (line 57) 35879 * compressed debug sections: Requirements. (line 41) 35880 * condition <1>: Breakpoints In Python. 35881 (line 152) 35882 * condition: Conditions. (line 45) 35883 * conditional breakpoints: Conditions. (line 6) 35884 * conditional tracepoints: Tracepoint Conditions. 35885 (line 6) 35886 * configuring GDB: Running Configure. (line 6) 35887 * confirmation: Messages/Warnings. (line 50) 35888 * connect on EventRegistry: Events In Python. (line 20) 35889 * connection timeout, for remote TCP target: Remote Configuration. 35890 (line 123) 35891 * console i/o as part of file-i/o: Console I/O. (line 6) 35892 * console interpreter: Interpreters. (line 21) 35893 * console output in GDB/MI: GDB/MI Output Syntax. 35894 (line 106) 35895 * const on Type: Types In Python. (line 91) 35896 * constants, in file-i/o protocol: Constants. (line 6) 35897 * continue: Continuing and Stepping. 35898 (line 15) 35899 * continue&: Background Execution. 35900 (line 53) 35901 * continuing: Continuing and Stepping. 35902 (line 6) 35903 * continuing threads: Thread Stops. (line 6) 35904 * control C, and remote debugging: Bootstrapping. (line 25) 35905 * controlling terminal: Input/Output. (line 23) 35906 * convenience functions: Convenience Vars. (line 106) 35907 * convenience functions in python: Functions In Python. (line 6) 35908 * convenience variables: Convenience Vars. (line 6) 35909 * convenience variables for tracepoints: Tracepoint Variables. 35910 (line 6) 35911 * convenience variables, and trace state variables: Trace State Variables. 35912 (line 17) 35913 * convenience variables, initializing: Convenience Vars. (line 41) 35914 * convert-meta: Readline Init File Syntax. 35915 (line 67) 35916 * copy-backward-word (): Commands For Killing. 35917 (line 49) 35918 * copy-forward-word (): Commands For Killing. 35919 (line 54) 35920 * copy-region-as-kill (): Commands For Killing. 35921 (line 45) 35922 * core dump file: Files. (line 6) 35923 * core dump file target: Target Commands. (line 54) 35924 * core-file: Files. (line 97) 35925 * crash of debugger: Bug Criteria. (line 9) 35926 * CRC algorithm definition: Separate Debug Files. 35927 (line 140) 35928 * CRC of memory block, remote request: General Query Packets. 35929 (line 63) 35930 * CRIS: CRIS. (line 6) 35931 * CRIS mode: CRIS. (line 26) 35932 * CRIS version: CRIS. (line 10) 35933 * Ctrl-BREAK, MS-Windows: Cygwin Native. (line 9) 35934 * ctrl-c message, in file-i/o protocol: The Ctrl-C Message. (line 6) 35935 * Ctrl-o (operate-and-get-next): Command Syntax. (line 42) 35936 * current Ada task ID: Ada Tasks. (line 105) 35937 * current directory: Source Path. (line 108) 35938 * current stack frame: Frames. (line 45) 35939 * current thread: Threads. (line 45) 35940 * current thread, remote request: General Query Packets. 35941 (line 52) 35942 * current_objfile: Objfiles In Python. (line 16) 35943 * current_progspace: Progspaces In Python. 35944 (line 15) 35945 * cwd: Source Path. (line 108) 35946 * Cygwin DLL, debugging: Cygwin Native. (line 42) 35947 * Cygwin-specific commands: Cygwin Native. (line 6) 35948 * D: D. (line 6) 35949 * d (delete): Delete Breaks. (line 41) 35950 * d (SingleKey TUI key): TUI Single Key Mode. (line 13) 35951 * D packet: Packets. (line 129) 35952 * d packet: Packets. (line 122) 35953 * Darwin: Darwin. (line 6) 35954 * data breakpoints: Breakpoints. (line 20) 35955 * data manipulation, in GDB/MI: GDB/MI Data Manipulation. 35956 (line 6) 35957 * dcache line-size: Caching Remote Data. (line 48) 35958 * dcache size: Caching Remote Data. (line 45) 35959 * dead names, GNU Hurd: Hurd Native. (line 85) 35960 * debug expression parser: Debugging Output. (line 131) 35961 * debug formats and C++: C Plus Plus Expressions. 35962 (line 8) 35963 * debug link sections: Separate Debug Files. 35964 (line 78) 35965 * debug remote protocol: Debugging Output. (line 140) 35966 * debug_chaos: M32R/D. (line 50) 35967 * debugger crash: Bug Criteria. (line 9) 35968 * debugging C++ programs: C Plus Plus Expressions. 35969 (line 8) 35970 * debugging information directory, global: Separate Debug Files. 35971 (line 6) 35972 * debugging information in separate files: Separate Debug Files. 35973 (line 6) 35974 * debugging libthread_db: Threads. (line 212) 35975 * debugging multiple processes: Forks. (line 52) 35976 * debugging optimized code: Optimized Code. (line 6) 35977 * debugging stub, example: Remote Stub. (line 6) 35978 * debugging target: Targets. (line 6) 35979 * debugging the Cygwin DLL: Cygwin Native. (line 42) 35980 * decimal floating point format: Decimal Floating Point. 35981 (line 6) 35982 * decode_line: Basic Python. (line 158) 35983 * default collection action: Tracepoint Actions. (line 114) 35984 * default data directory: Data Files. (line 19) 35985 * default source path substitution: Source Path. (line 89) 35986 * default system root: Files. (line 434) 35987 * default_visualizer: Pretty Printing API. (line 86) 35988 * define: Define. (line 37) 35989 * define trace state variable, remote request: Tracepoint Packets. 35990 (line 127) 35991 * defining macros interactively: Macros. (line 52) 35992 * definition, showing a macro's: Macros. (line 47) 35993 * delete: Delete Breaks. (line 41) 35994 * delete breakpoints: Delete Breaks. (line 41) 35995 * delete checkpoint CHECKPOINT-ID: Checkpoint/Restart. (line 56) 35996 * delete display: Auto Display. (line 45) 35997 * delete mem: Memory Region Attributes. 35998 (line 34) 35999 * delete on Breakpoint: Breakpoints In Python. 36000 (line 70) 36001 * delete tracepoint: Create and Delete Tracepoints. 36002 (line 101) 36003 * delete tvariable: Trace State Variables. 36004 (line 42) 36005 * delete-char (C-d): Commands For Text. (line 6) 36006 * delete-char-or-list (): Commands For Completion. 36007 (line 30) 36008 * delete-horizontal-space (): Commands For Killing. 36009 (line 37) 36010 * deleting breakpoints, watchpoints, catchpoints: Delete Breaks. 36011 (line 6) 36012 * deliver a signal to a program: Signaling. (line 6) 36013 * demangling C++ names: Print Settings. (line 277) 36014 * deprecated commands: Maintenance Commands. 36015 (line 90) 36016 * dereference on Value: Values From Inferior. 36017 (line 115) 36018 * derived type of an object, printing: Print Settings. (line 329) 36019 * descriptor tables display: DJGPP Native. (line 24) 36020 * detach: Attach. (line 36) 36021 * detach (remote): Connecting. (line 91) 36022 * detach from task, GNU Hurd: Hurd Native. (line 60) 36023 * detach from thread, GNU Hurd: Hurd Native. (line 110) 36024 * detach inferiors INFNO...: Inferiors and Programs. 36025 (line 97) 36026 * digit-argument (M-0, M-1, ... M--): Numeric Arguments. (line 6) 36027 * dir: Source Path. (line 39) 36028 * direct memory access (DMA) on MS-DOS: DJGPP Native. (line 75) 36029 * directories for source files: Source Path. (line 6) 36030 * directory: Source Path. (line 39) 36031 * directory, compilation: Source Path. (line 108) 36032 * directory, current: Source Path. (line 108) 36033 * dis (disable): Disabling. (line 38) 36034 * disable: Disabling. (line 38) 36035 * disable display: Auto Display. (line 56) 36036 * disable mem: Memory Region Attributes. 36037 (line 38) 36038 * disable pretty-printer: Pretty-Printer Commands. 36039 (line 20) 36040 * disable tracepoint: Enable and Disable Tracepoints. 36041 (line 9) 36042 * disable-completion: Readline Init File Syntax. 36043 (line 73) 36044 * disassemble: Machine Code. (line 36) 36045 * disconnect: Connecting. (line 98) 36046 * disconnect on EventRegistry: Events In Python. (line 25) 36047 * disconnected tracing: Starting and Stopping Trace Experiments. 36048 (line 38) 36049 * displaced stepping debugging info: Debugging Output. (line 53) 36050 * displaced stepping support: Maintenance Commands. 36051 (line 56) 36052 * displaced stepping, and process record and replay: Process Record and Replay. 36053 (line 47) 36054 * display: Auto Display. (line 23) 36055 * display command history: Command History. (line 78) 36056 * display derived types: Print Settings. (line 329) 36057 * display disabled out of scope: Auto Display. (line 86) 36058 * display GDB copyright: Help. (line 136) 36059 * display of expressions: Auto Display. (line 6) 36060 * display remote monitor communications: Target Commands. (line 108) 36061 * display remote packets: Debugging Output. (line 140) 36062 * display_hint on pretty printer: Pretty Printing API. (line 25) 36063 * DJGPP debugging: DJGPP Native. (line 6) 36064 * dll-symbols: Cygwin Native. (line 38) 36065 * DLLs with no debugging symbols: Non-debug DLL Symbols. 36066 (line 6) 36067 * do (down): Selection. (line 40) 36068 * do not print frame argument values: Print Settings. (line 135) 36069 * do-uppercase-version (M-a, M-b, M-X, ...): Miscellaneous Commands. 36070 (line 14) 36071 * document: Define. (line 49) 36072 * documentation: Formatting Documentation. 36073 (line 22) 36074 * don't repeat command: Define. (line 61) 36075 * don't repeat Python command: Commands In Python. (line 43) 36076 * dont-repeat: Define. (line 61) 36077 * dont_repeat on Command: Commands In Python. (line 44) 36078 * DOS file-name semantics of file names.: Files. (line 457) 36079 * DOS serial data link, remote debugging: DJGPP Native. (line 121) 36080 * DOS serial port status: DJGPP Native. (line 142) 36081 * Down: TUI Keys. (line 56) 36082 * down: Selection. (line 40) 36083 * down-silently: Selection. (line 64) 36084 * downcase-word (M-l): Commands For Text. (line 45) 36085 * download server address (M32R): M32R/D. (line 27) 36086 * download to Sparclet: Sparclet Download. (line 6) 36087 * download to VxWorks: VxWorks Download. (line 6) 36088 * DPMI: DJGPP Native. (line 6) 36089 * dump: Dump/Restore Files. (line 13) 36090 * dump all data collected at tracepoint: tdump. (line 6) 36091 * dump core from inferior: Core File Generation. 36092 (line 6) 36093 * dump data to a file: Dump/Restore Files. (line 6) 36094 * dump-functions (): Miscellaneous Commands. 36095 (line 61) 36096 * dump-macros (): Miscellaneous Commands. 36097 (line 73) 36098 * dump-variables (): Miscellaneous Commands. 36099 (line 67) 36100 * dump/restore files: Dump/Restore Files. (line 6) 36101 * DVC register: PowerPC Embedded. (line 6) 36102 * DWARF 2 compilation units cache: Maintenance Commands. 36103 (line 281) 36104 * DWARF-2 CFI and CRIS: CRIS. (line 18) 36105 * DWARF2 DIEs: Debugging Output. (line 46) 36106 * dynamic linking: Files. (line 113) 36107 * dynamic varobj: GDB/MI Variable Objects. 36108 (line 164) 36109 * dynamic_cast on Value: Values From Inferior. 36110 (line 131) 36111 * dynamic_type: Values From Inferior. 36112 (line 59) 36113 * e (edit): Edit. (line 6) 36114 * echo: Output. (line 12) 36115 * edit: Edit. (line 6) 36116 * editing: Editing. (line 15) 36117 * editing command lines: Readline Bare Essentials. 36118 (line 6) 36119 * editing source files: Edit. (line 6) 36120 * editing-mode: Readline Init File Syntax. 36121 (line 78) 36122 * eight-bit characters in strings: Print Settings. (line 222) 36123 * elaboration phase: Starting. (line 90) 36124 * else: Command Files. (line 75) 36125 * Emacs: Emacs. (line 6) 36126 * empty response, for unsupported packets: Overview. (line 96) 36127 * enable: Disabling. (line 45) 36128 * enable display: Auto Display. (line 65) 36129 * enable mem: Memory Region Attributes. 36130 (line 42) 36131 * enable pretty-printer: Pretty-Printer Commands. 36132 (line 25) 36133 * enable tracepoint: Enable and Disable Tracepoints. 36134 (line 15) 36135 * enable-keypad: Readline Init File Syntax. 36136 (line 84) 36137 * enable/disable a breakpoint: Disabling. (line 6) 36138 * enabled: Breakpoints In Python. 36139 (line 75) 36140 * encoding: Lazy Strings In Python. 36141 (line 37) 36142 * end: Blocks In Python. (line 40) 36143 * end (breakpoint commands): Break Commands. (line 11) 36144 * end (if/else/while commands): Command Files. (line 104) 36145 * end (user-defined commands): Define. (line 49) 36146 * end-kbd-macro (C-x )): Keyboard Macros. (line 9) 36147 * end-of-history (M->): Commands For History. 36148 (line 22) 36149 * end-of-line (C-e): Commands For Moving. (line 9) 36150 * entering numbers: Numbers. (line 6) 36151 * environment (of your program): Environment. (line 6) 36152 * errno values, in file-i/o protocol: Errno Values. (line 6) 36153 * error annotation: Errors. (line 10) 36154 * error on valid input: Bug Criteria. (line 12) 36155 * error-begin annotation: Errors. (line 22) 36156 * eval: Output. (line 117) 36157 * event debugging info: Debugging Output. (line 61) 36158 * event designators: Event Designators. (line 6) 36159 * event handling: Set Catchpoints. (line 6) 36160 * examine process image: SVR4 Process Information. 36161 (line 6) 36162 * examining data: Data. (line 6) 36163 * examining memory: Memory. (line 9) 36164 * exception handlers: Set Catchpoints. (line 6) 36165 * exception handlers, how to list: Frame Info. (line 60) 36166 * exceptionHandler: Bootstrapping. (line 38) 36167 * exceptions, python: Exception Handling. (line 6) 36168 * exchange-point-and-mark (C-x C-x): Miscellaneous Commands. 36169 (line 36) 36170 * exec-file: Files. (line 39) 36171 * executable file: Files. (line 16) 36172 * executable file target: Target Commands. (line 50) 36173 * executable file, for remote target: Remote Configuration. 36174 (line 79) 36175 * execute: Basic Python. (line 15) 36176 * execute commands from a file: Command Files. (line 17) 36177 * execute forward or backward in time: Reverse Execution. (line 87) 36178 * execute remote command, remote request: General Query Packets. 36179 (line 268) 36180 * execution, foreground, background and asynchronous: Background Execution. 36181 (line 6) 36182 * exit_code: Events In Python. (line 72) 36183 * exited annotation: Annotations for Running. 36184 (line 18) 36185 * exiting GDB: Quitting GDB. (line 6) 36186 * expand macro once: Macros. (line 38) 36187 * expand-tilde: Readline Init File Syntax. 36188 (line 89) 36189 * expanding preprocessor macros: Macros. (line 29) 36190 * expression: Breakpoints In Python. 36191 (line 146) 36192 * expression debugging info: Debugging Output. (line 68) 36193 * expression parser, debugging info: Debugging Output. (line 131) 36194 * expressions: Expressions. (line 6) 36195 * expressions in Ada: Ada. (line 11) 36196 * expressions in C or C++: C. (line 6) 36197 * expressions in C++: C Plus Plus Expressions. 36198 (line 6) 36199 * expressions in Modula-2: Modula-2. (line 12) 36200 * extend GDB for remote targets: Connecting. (line 105) 36201 * extending GDB: Extending GDB. (line 6) 36202 * extra signal information: Signals. (line 102) 36203 * f (frame): Selection. (line 11) 36204 * f (SingleKey TUI key): TUI Single Key Mode. (line 16) 36205 * F packet: Packets. (line 146) 36206 * F reply packet: The F Reply Packet. (line 6) 36207 * F request packet: The F Request Packet. 36208 (line 6) 36209 * fast tracepoints: Set Tracepoints. (line 24) 36210 * fast tracepoints, setting: Create and Delete Tracepoints. 36211 (line 40) 36212 * fatal signal: Bug Criteria. (line 9) 36213 * fatal signals: Signals. (line 15) 36214 * features of the remote protocol: General Query Packets. 36215 (line 328) 36216 * fg (resume foreground execution): Continuing and Stepping. 36217 (line 15) 36218 * fields on Type: Types In Python. (line 41) 36219 * file: Files. (line 16) 36220 * file name canonicalization: Files. (line 501) 36221 * file transfer: File Transfer. (line 6) 36222 * file transfer, remote protocol: Host I/O Packets. (line 6) 36223 * file-i/o examples: File-I/O Examples. (line 6) 36224 * file-i/o overview: File-I/O Overview. (line 6) 36225 * File-I/O remote protocol extension: File-I/O Remote Protocol Extension. 36226 (line 6) 36227 * file-i/o reply packet: The F Reply Packet. (line 6) 36228 * file-i/o request packet: The F Request Packet. 36229 (line 6) 36230 * filename <1>: Symbol Tables In Python. 36231 (line 41) 36232 * filename <2>: Objfiles In Python. (line 29) 36233 * filename: Progspaces In Python. 36234 (line 25) 36235 * fin (finish): Continuing and Stepping. 36236 (line 110) 36237 * find: Searching Memory. (line 9) 36238 * find downloadable SREC files (M32R): M32R/D. (line 15) 36239 * find trace snapshot: tfind. (line 6) 36240 * find_sal on Frame: Frames In Python. (line 96) 36241 * finish: Continuing and Stepping. 36242 (line 110) 36243 * finish&: Background Execution. 36244 (line 56) 36245 * flinching: Messages/Warnings. (line 50) 36246 * float promotion: ABI. (line 29) 36247 * floating point: Floating Point Hardware. 36248 (line 6) 36249 * floating point registers: Registers. (line 15) 36250 * floating point, MIPS remote: MIPS Embedded. (line 60) 36251 * flush: Basic Python. (line 122) 36252 * flush_i_cache: Bootstrapping. (line 60) 36253 * flushregs: Maintenance Commands. 36254 (line 208) 36255 * focus: TUI Commands. (line 40) 36256 * focus of debugging: Threads. (line 45) 36257 * foo: Symbol Errors. (line 50) 36258 * foreground execution: Background Execution. 36259 (line 6) 36260 * fork, debugging programs which call: Forks. (line 6) 36261 * format options: Print Settings. (line 6) 36262 * formatted output: Output Formats. (line 6) 36263 * Fortran: Summary. (line 40) 36264 * Fortran Defaults: Fortran Defaults. (line 6) 36265 * Fortran operators and expressions: Fortran Operators. (line 6) 36266 * Fortran-specific support in GDB: Fortran. (line 6) 36267 * forward-backward-delete-char (): Commands For Text. (line 15) 36268 * forward-char (C-f): Commands For Moving. (line 12) 36269 * forward-search: Search. (line 9) 36270 * forward-search-history (C-s): Commands For History. 36271 (line 30) 36272 * forward-word (M-f): Commands For Moving. (line 18) 36273 * FR-V shared-library debugging: Debugging Output. (line 158) 36274 * frame debugging info: Debugging Output. (line 76) 36275 * frame number: Frames. (line 28) 36276 * frame pointer: Frames. (line 21) 36277 * frame pointer register: Registers. (line 26) 36278 * frame, command: Frames. (line 45) 36279 * frame, definition: Frames. (line 6) 36280 * frame, selecting: Selection. (line 11) 36281 * frame_stop_reason_string: Frames In Python. (line 30) 36282 * frameless execution: Frames. (line 34) 36283 * frames in python: Frames In Python. (line 6) 36284 * frames-invalid annotation: Invalidation. (line 9) 36285 * free memory information (MS-DOS): DJGPP Native. (line 19) 36286 * fstat, file-i/o system call: stat/fstat. (line 6) 36287 * ftrace: Create and Delete Tracepoints. 36288 (line 40) 36289 * Fujitsu: Remote Stub. (line 69) 36290 * full symbol tables, listing GDB's internal: Symbols. (line 291) 36291 * fullname on Symtab: Symbol Tables In Python. 36292 (line 58) 36293 * function: Blocks In Python. (line 43) 36294 * Function: Functions In Python. (line 6) 36295 * function call arguments, optimized out: Backtrace. (line 71) 36296 * function entry/exit, wrong values of variables: Variables. (line 58) 36297 * function on Frame: Frames In Python. (line 86) 36298 * functions without line info, and stepping: Continuing and Stepping. 36299 (line 93) 36300 * G packet: Packets. (line 180) 36301 * g packet: Packets. (line 151) 36302 * g++, GNU C++ compiler: C. (line 10) 36303 * garbled pointers: DJGPP Native. (line 42) 36304 * GCC and C++: C Plus Plus Expressions. 36305 (line 8) 36306 * gcore: Core File Generation. 36307 (line 18) 36308 * GDB bugs, reporting: Bug Reporting. (line 6) 36309 * GDB internal error: Maintenance Commands. 36310 (line 124) 36311 * gdb module: Basic Python. (line 6) 36312 * GDB reference card: Formatting Documentation. 36313 (line 6) 36314 * GDB startup: Startup. (line 6) 36315 * GDB version number: Help. (line 126) 36316 * gdb.Block: Blocks In Python. (line 6) 36317 * gdb.block_for_pc: Blocks In Python. (line 16) 36318 * gdb.BP_ACCESS_WATCHPOINT: Breakpoints In Python. 36319 (line 131) 36320 * gdb.BP_BREAKPOINT: Breakpoints In Python. 36321 (line 119) 36322 * gdb.BP_HARDWARE_WATCHPOINT: Breakpoints In Python. 36323 (line 125) 36324 * gdb.BP_READ_WATCHPOINT: Breakpoints In Python. 36325 (line 128) 36326 * gdb.BP_WATCHPOINT: Breakpoints In Python. 36327 (line 122) 36328 * gdb.Breakpoint: Breakpoints In Python. 36329 (line 6) 36330 * gdb.breakpoints: Basic Python. (line 31) 36331 * gdb.COMMAND_BREAKPOINTS: Commands In Python. (line 145) 36332 * gdb.COMMAND_DATA: Commands In Python. (line 115) 36333 * gdb.COMMAND_FILES: Commands In Python. (line 126) 36334 * gdb.COMMAND_MAINTENANCE: Commands In Python. (line 163) 36335 * gdb.COMMAND_NONE: Commands In Python. (line 105) 36336 * gdb.COMMAND_OBSCURE: Commands In Python. (line 157) 36337 * gdb.COMMAND_RUNNING: Commands In Python. (line 109) 36338 * gdb.COMMAND_STACK: Commands In Python. (line 120) 36339 * gdb.COMMAND_STATUS: Commands In Python. (line 139) 36340 * gdb.COMMAND_SUPPORT: Commands In Python. (line 132) 36341 * gdb.COMMAND_TRACEPOINTS: Commands In Python. (line 151) 36342 * gdb.COMPLETE_COMMAND: Commands In Python. (line 184) 36343 * gdb.COMPLETE_FILENAME: Commands In Python. (line 177) 36344 * gdb.COMPLETE_LOCATION: Commands In Python. (line 180) 36345 * gdb.COMPLETE_NONE: Commands In Python. (line 174) 36346 * gdb.COMPLETE_SYMBOL: Commands In Python. (line 188) 36347 * gdb.current_objfile: Objfiles In Python. (line 15) 36348 * gdb.current_progspace: Progspaces In Python. 36349 (line 14) 36350 * gdb.decode_line: Basic Python. (line 157) 36351 * gdb.default_visualizer: Pretty Printing API. (line 85) 36352 * gdb.error: Exception Handling. (line 22) 36353 * gdb.execute: Basic Python. (line 14) 36354 * gdb.flush: Basic Python. (line 121) 36355 * gdb.Function: Functions In Python. (line 6) 36356 * gdb.GdbError: Exception Handling. (line 42) 36357 * gdb.history: Basic Python. (line 46) 36358 * gdb.Inferior: Inferiors In Python. (line 6) 36359 * gdb.InferiorThread: Threads In Python. (line 6) 36360 * gdb.ini: Startup. (line 60) 36361 * gdb.LazyString: Lazy Strings In Python. 36362 (line 6) 36363 * gdb.lookup_global_symbol: Symbols In Python. (line 33) 36364 * gdb.lookup_symbol: Symbols In Python. (line 13) 36365 * gdb.lookup_type: Types In Python. (line 11) 36366 * gdb.MemoryError: Exception Handling. (line 30) 36367 * gdb.newest_frame: Frames In Python. (line 26) 36368 * gdb.Objfile: Objfiles In Python. (line 6) 36369 * gdb.objfiles: Objfiles In Python. (line 21) 36370 * gdb.PARAM_AUTO_BOOLEAN: Parameters In Python. 36371 (line 93) 36372 * gdb.PARAM_BOOLEAN: Parameters In Python. 36373 (line 89) 36374 * gdb.PARAM_ENUM: Parameters In Python. 36375 (line 127) 36376 * gdb.PARAM_FILENAME: Parameters In Python. 36377 (line 119) 36378 * gdb.PARAM_INTEGER: Parameters In Python. 36379 (line 102) 36380 * gdb.PARAM_OPTIONAL_FILENAME: Parameters In Python. 36381 (line 116) 36382 * gdb.PARAM_STRING: Parameters In Python. 36383 (line 106) 36384 * gdb.PARAM_STRING_NOESCAPE: Parameters In Python. 36385 (line 112) 36386 * gdb.PARAM_UINTEGER: Parameters In Python. 36387 (line 98) 36388 * gdb.PARAM_ZINTEGER: Parameters In Python. 36389 (line 123) 36390 * gdb.Parameter: Parameters In Python. 36391 (line 6) 36392 * gdb.parameter: Basic Python. (line 35) 36393 * gdb.parse_and_eval: Basic Python. (line 58) 36394 * gdb.post_event: Basic Python. (line 69) 36395 * gdb.printing: gdb.printing. (line 6) 36396 * gdb.Progspace: Progspaces In Python. 36397 (line 6) 36398 * gdb.progspaces: Progspaces In Python. 36399 (line 18) 36400 * gdb.PYTHONDIR: Basic Python. (line 11) 36401 * gdb.read_memory: Inferiors In Python. (line 44) 36402 * gdb.search_memory: Inferiors In Python. (line 57) 36403 * gdb.selected_frame: Frames In Python. (line 22) 36404 * gdb.selected_thread: Threads In Python. (line 13) 36405 * gdb.solib_name: Basic Python. (line 153) 36406 * gdb.STDERR: Basic Python. (line 111) 36407 * gdb.STDLOG: Basic Python. (line 114) 36408 * gdb.STDOUT: Basic Python. (line 108) 36409 * gdb.string_to_argv: Commands In Python. (line 62) 36410 * gdb.Symbol: Symbols In Python. (line 6) 36411 * gdb.SYMBOL_FUNCTIONS_DOMAIN: Symbols In Python. (line 117) 36412 * gdb.SYMBOL_LABEL_DOMAIN: Symbols In Python. (line 110) 36413 * gdb.SYMBOL_LOC_ARG: Symbols In Python. (line 139) 36414 * gdb.SYMBOL_LOC_BLOCK: Symbols In Python. (line 160) 36415 * gdb.SYMBOL_LOC_COMPUTED: Symbols In Python. (line 174) 36416 * gdb.SYMBOL_LOC_CONST: Symbols In Python. (line 130) 36417 * gdb.SYMBOL_LOC_CONST_BYTES: Symbols In Python. (line 163) 36418 * gdb.SYMBOL_LOC_LOCAL: Symbols In Python. (line 153) 36419 * gdb.SYMBOL_LOC_OPTIMIZED_OUT: Symbols In Python. (line 171) 36420 * gdb.SYMBOL_LOC_REF_ARG: Symbols In Python. (line 143) 36421 * gdb.SYMBOL_LOC_REGISTER: Symbols In Python. (line 136) 36422 * gdb.SYMBOL_LOC_REGPARM_ADDR: Symbols In Python. (line 148) 36423 * gdb.SYMBOL_LOC_STATIC: Symbols In Python. (line 133) 36424 * gdb.SYMBOL_LOC_TYPEDEF: Symbols In Python. (line 156) 36425 * gdb.SYMBOL_LOC_UNDEF: Symbols In Python. (line 128) 36426 * gdb.SYMBOL_LOC_UNRESOLVED: Symbols In Python. (line 166) 36427 * gdb.SYMBOL_STRUCT_DOMAIN: Symbols In Python. (line 107) 36428 * gdb.SYMBOL_TYPES_DOMAIN: Symbols In Python. (line 120) 36429 * gdb.SYMBOL_UNDEF_DOMAIN: Symbols In Python. (line 100) 36430 * gdb.SYMBOL_VAR_DOMAIN: Symbols In Python. (line 103) 36431 * gdb.SYMBOL_VARIABLES_DOMAIN: Symbols In Python. (line 113) 36432 * gdb.Symtab: Symbol Tables In Python. 36433 (line 6) 36434 * gdb.Symtab_and_line: Symbol Tables In Python. 36435 (line 6) 36436 * gdb.target_charset: Basic Python. (line 142) 36437 * gdb.target_wide_charset: Basic Python. (line 147) 36438 * gdb.Type: Types In Python. (line 6) 36439 * gdb.TYPE_CODE_ARRAY: Types In Python. (line 155) 36440 * gdb.TYPE_CODE_BITSTRING: Types In Python. (line 193) 36441 * gdb.TYPE_CODE_BOOL: Types In Python. (line 214) 36442 * gdb.TYPE_CODE_CHAR: Types In Python. (line 211) 36443 * gdb.TYPE_CODE_COMPLEX: Types In Python. (line 217) 36444 * gdb.TYPE_CODE_DECFLOAT: Types In Python. (line 226) 36445 * gdb.TYPE_CODE_ENUM: Types In Python. (line 164) 36446 * gdb.TYPE_CODE_ERROR: Types In Python. (line 196) 36447 * gdb.TYPE_CODE_FLAGS: Types In Python. (line 167) 36448 * gdb.TYPE_CODE_FLT: Types In Python. (line 176) 36449 * gdb.TYPE_CODE_FUNC: Types In Python. (line 170) 36450 * gdb.TYPE_CODE_INT: Types In Python. (line 173) 36451 * gdb.TYPE_CODE_INTERNAL_FUNCTION: Types In Python. (line 229) 36452 * gdb.TYPE_CODE_MEMBERPTR: Types In Python. (line 205) 36453 * gdb.TYPE_CODE_METHOD: Types In Python. (line 199) 36454 * gdb.TYPE_CODE_METHODPTR: Types In Python. (line 202) 36455 * gdb.TYPE_CODE_NAMESPACE: Types In Python. (line 223) 36456 * gdb.TYPE_CODE_PTR: Types In Python. (line 152) 36457 * gdb.TYPE_CODE_RANGE: Types In Python. (line 185) 36458 * gdb.TYPE_CODE_REF: Types In Python. (line 208) 36459 * gdb.TYPE_CODE_SET: Types In Python. (line 182) 36460 * gdb.TYPE_CODE_STRING: Types In Python. (line 188) 36461 * gdb.TYPE_CODE_STRUCT: Types In Python. (line 158) 36462 * gdb.TYPE_CODE_TYPEDEF: Types In Python. (line 220) 36463 * gdb.TYPE_CODE_UNION: Types In Python. (line 161) 36464 * gdb.TYPE_CODE_VOID: Types In Python. (line 179) 36465 * gdb.types: gdb.types. (line 6) 36466 * gdb.Value: Values From Inferior. 36467 (line 6) 36468 * gdb.WP_ACCESS: Breakpoints In Python. 36469 (line 58) 36470 * gdb.WP_READ: Breakpoints In Python. 36471 (line 52) 36472 * gdb.WP_WRITE: Breakpoints In Python. 36473 (line 55) 36474 * gdb.write: Basic Python. (line 103) 36475 * gdb.write_memory: Inferiors In Python. (line 50) 36476 * GDB/MI development: GDB/MI Development and Front Ends. 36477 (line 6) 36478 * GDB/MI General Design: GDB/MI General Design. 36479 (line 6) 36480 * GDB/MI, async records: GDB/MI Async Records. 36481 (line 6) 36482 * GDB/MI, breakpoint commands: GDB/MI Breakpoint Commands. 36483 (line 6) 36484 * GDB/MI, compatibility with CLI: GDB/MI Compatibility with CLI. 36485 (line 6) 36486 * GDB/MI, data manipulation: GDB/MI Data Manipulation. 36487 (line 6) 36488 * GDB/MI, input syntax: GDB/MI Input Syntax. (line 6) 36489 * GDB/MI, its purpose: GDB/MI. (line 9) 36490 * GDB/MI, output syntax: GDB/MI Output Syntax. 36491 (line 6) 36492 * GDB/MI, result records: GDB/MI Result Records. 36493 (line 6) 36494 * GDB/MI, simple examples: GDB/MI Simple Examples. 36495 (line 6) 36496 * GDB/MI, stream records: GDB/MI Stream Records. 36497 (line 6) 36498 * gdbarch debugging info: Debugging Output. (line 18) 36499 * GDBHISTFILE, environment variable: Command History. (line 26) 36500 * gdbserver: Server. (line 6) 36501 * gdbserver, multiple processes: Server. (line 91) 36502 * gdbserver, search path for libthread_db: Server. (line 188) 36503 * GDT: DJGPP Native. (line 24) 36504 * generate-core-file: Core File Generation. 36505 (line 18) 36506 * get thread information block address: General Query Packets. 36507 (line 143) 36508 * get thread-local storage address, remote request: General Query Packets. 36509 (line 112) 36510 * get_set_string on parameter: Parameters In Python. 36511 (line 74) 36512 * get_show_string on parameter: Parameters In Python. 36513 (line 80) 36514 * getDebugChar: Bootstrapping. (line 14) 36515 * gettimeofday, file-i/o system call: gettimeofday. (line 6) 36516 * global debugging information directory: Separate Debug Files. 36517 (line 6) 36518 * GNU C++: C. (line 10) 36519 * GNU Emacs: Emacs. (line 6) 36520 * GNU Hurd debugging: Hurd Native. (line 6) 36521 * GNU/Hurd debug messages: Debugging Output. (line 83) 36522 * GNU/Linux LWP async debug messages: Debugging Output. (line 111) 36523 * GNU/Linux LWP debug messages: Debugging Output. (line 104) 36524 * gnu_debuglink_crc32: Separate Debug Files. 36525 (line 164) 36526 * h (help): Help. (line 9) 36527 * H packet: Packets. (line 191) 36528 * handle: Signals. (line 45) 36529 * handle_exception: Stub Contents. (line 15) 36530 * handling signals: Signals. (line 27) 36531 * hardware breakpoints: Set Breaks. (line 62) 36532 * hardware debug registers: Maintenance Commands. 36533 (line 307) 36534 * hardware watchpoints: Set Watchpoints. (line 31) 36535 * hash mark while downloading: Target Commands. (line 99) 36536 * hbreak: Set Breaks. (line 62) 36537 * help: Help. (line 6) 36538 * help function: Convenience Vars. (line 112) 36539 * help target: Target Commands. (line 19) 36540 * help user-defined: Define. (line 66) 36541 * heuristic-fence-post (Alpha, MIPS): MIPS. (line 14) 36542 * history: Basic Python. (line 47) 36543 * history events: Event Designators. (line 7) 36544 * history expansion: History Interaction. (line 6) 36545 * history expansion, turn on/off: Command History. (line 53) 36546 * history file: Command History. (line 26) 36547 * history number: Value History. (line 13) 36548 * history of values printed by GDB: Value History. (line 6) 36549 * history size: Command History. (line 45) 36550 * history substitution: Command History. (line 26) 36551 * history-preserve-point: Readline Init File Syntax. 36552 (line 93) 36553 * history-search-backward (): Commands For History. 36554 (line 50) 36555 * history-search-forward (): Commands For History. 36556 (line 45) 36557 * HISTSIZE, environment variable: Command History. (line 45) 36558 * hit_count: Breakpoints In Python. 36559 (line 135) 36560 * hook: Hooks. (line 6) 36561 * hookpost: Hooks. (line 11) 36562 * hooks, for commands: Hooks. (line 6) 36563 * hooks, post-command: Hooks. (line 11) 36564 * hooks, pre-command: Hooks. (line 6) 36565 * horizontal-scroll-mode: Readline Init File Syntax. 36566 (line 98) 36567 * host character set: Character Sets. (line 6) 36568 * Host I/O, remote protocol: Host I/O Packets. (line 6) 36569 * how many arguments (user-defined commands): Define. (line 25) 36570 * HPPA support: HPPA. (line 6) 36571 * htrace: OpenRISC 1000. (line 69) 36572 * hwatch: OpenRISC 1000. (line 59) 36573 * i (info): Help. (line 99) 36574 * I packet: Packets. (line 210) 36575 * i packet: Packets. (line 205) 36576 * i/o: Input/Output. (line 6) 36577 * I/O registers (Atmel AVR): AVR. (line 10) 36578 * i386: Remote Stub. (line 57) 36579 * i386-stub.c: Remote Stub. (line 57) 36580 * IDT: DJGPP Native. (line 24) 36581 * if: Command Files. (line 75) 36582 * ignore: Conditions. (line 77) 36583 * ignore count (of breakpoint): Conditions. (line 66) 36584 * ignore_count: Breakpoints In Python. 36585 (line 98) 36586 * INCLUDE_RDB: VxWorks. (line 33) 36587 * incomplete type: Symbols. (line 107) 36588 * indentation in structure display: Print Settings. (line 198) 36589 * index files: Index Files. (line 6) 36590 * inferior: Inferiors and Programs. 36591 (line 13) 36592 * inferior debugging info: Debugging Output. (line 89) 36593 * inferior events in Python: Events In Python. (line 6) 36594 * inferior functions, calling: Calling. (line 6) 36595 * inferior INFNO: Inferiors and Programs. 36596 (line 49) 36597 * inferior tty: Input/Output. (line 44) 36598 * inferior_thread: Events In Python. (line 57) 36599 * inferiors: Inferiors In Python. (line 15) 36600 * inferiors in Python: Inferiors In Python. (line 6) 36601 * infinite recursion in user-defined commands: Define. (line 76) 36602 * info: Help. (line 99) 36603 * info address: Symbols. (line 44) 36604 * info all-registers: Registers. (line 15) 36605 * info args: Frame Info. (line 51) 36606 * info auto-load-scripts: Auto-loading. (line 29) 36607 * info auxv: OS Information. (line 33) 36608 * info breakpoints: Set Breaks. (line 128) 36609 * info catch: Frame Info. (line 60) 36610 * info checkpoints: Checkpoint/Restart. (line 31) 36611 * info classes: Symbols. (line 205) 36612 * info common: Special Fortran Commands. 36613 (line 9) 36614 * info copying: Help. (line 136) 36615 * info dcache: Caching Remote Data. (line 34) 36616 * info display: Auto Display. (line 78) 36617 * info dll: Cygwin Native. (line 35) 36618 * info dos: DJGPP Native. (line 15) 36619 * info extensions: Show. (line 34) 36620 * info f (info frame): Frame Info. (line 17) 36621 * info files: Files. (line 191) 36622 * info float: Floating Point Hardware. 36623 (line 9) 36624 * info for known .debug_gdb_scripts-loaded scripts: Maintenance Commands. 36625 (line 216) 36626 * info for known object files: Maintenance Commands. 36627 (line 211) 36628 * info frame: Frame Info. (line 17) 36629 * info frame, show the source language: Show. (line 15) 36630 * info functions: Symbols. (line 184) 36631 * info handle: Signals. (line 33) 36632 * info inferiors: Inferiors and Programs. 36633 (line 25) 36634 * info io_registers, AVR: AVR. (line 10) 36635 * info line: Machine Code. (line 14) 36636 * info line, and Objective-C: Method Names in Commands. 36637 (line 9) 36638 * info locals: Frame Info. (line 55) 36639 * info macro: Macros. (line 47) 36640 * info mem: Memory Region Attributes. 36641 (line 45) 36642 * info meminfo: SVR4 Process Information. 36643 (line 78) 36644 * info or1k spr: OpenRISC 1000. (line 20) 36645 * info os: OS Information. (line 47) 36646 * info os processes: OS Information. (line 52) 36647 * info pidlist: SVR4 Process Information. 36648 (line 74) 36649 * info pretty-printer: Pretty-Printer Commands. 36650 (line 6) 36651 * info proc: SVR4 Process Information. 36652 (line 16) 36653 * info program: Stopping. (line 18) 36654 * info record: Process Record and Replay. 36655 (line 137) 36656 * info registers: Registers. (line 11) 36657 * info scope: Symbols. (line 138) 36658 * info selectors: Symbols. (line 211) 36659 * info serial: DJGPP Native. (line 142) 36660 * info set: Help. (line 119) 36661 * info share: Files. (line 326) 36662 * info sharedlibrary: Files. (line 326) 36663 * info signals: Signals. (line 33) 36664 * info source: Symbols. (line 159) 36665 * info source, show the source language: Show. (line 21) 36666 * info sources: Symbols. (line 178) 36667 * info spu: SPU. (line 10) 36668 * info stack: Backtrace. (line 34) 36669 * info static-tracepoint-markers: Listing Static Tracepoint Markers. 36670 (line 6) 36671 * info symbol: Symbols. (line 54) 36672 * info target: Files. (line 191) 36673 * info task TASKNO: Ada Tasks. (line 89) 36674 * info tasks: Ada Tasks. (line 9) 36675 * info terminal: Input/Output. (line 12) 36676 * info threads: Threads. (line 66) 36677 * info tp [N...]: Listing Tracepoints. (line 6) 36678 * info tracepoints [N...]: Listing Tracepoints. (line 6) 36679 * info tvariables: Trace State Variables. 36680 (line 37) 36681 * info types: Symbols. (line 124) 36682 * info udot: OS Information. (line 16) 36683 * info variables: Symbols. (line 196) 36684 * info vector: Vector Unit. (line 9) 36685 * info w32: Cygwin Native. (line 19) 36686 * info warranty: Help. (line 140) 36687 * info watchpoints [N...]: Set Watchpoints. (line 72) 36688 * info win: TUI Commands. (line 18) 36689 * information about static tracepoint markers: Listing Static Tracepoint Markers. 36690 (line 6) 36691 * information about tracepoints: Listing Tracepoints. (line 6) 36692 * inheritance: Debugging C Plus Plus. 36693 (line 25) 36694 * init file: Startup. (line 11) 36695 * init file name: Startup. (line 60) 36696 * init-if-undefined: Convenience Vars. (line 41) 36697 * initial frame: Frames. (line 12) 36698 * initialization file, readline: Readline Init File. (line 6) 36699 * inline functions, debugging: Inline Functions. (line 6) 36700 * innermost frame: Frames. (line 12) 36701 * input syntax for GDB/MI: GDB/MI Input Syntax. (line 6) 36702 * input-meta: Readline Init File Syntax. 36703 (line 105) 36704 * insert-comment (M-#): Miscellaneous Commands. 36705 (line 51) 36706 * insert-completions (M-*): Commands For Completion. 36707 (line 14) 36708 * inspect: Data. (line 6) 36709 * installation: Installing GDB. (line 6) 36710 * instructions, assembly: Machine Code. (line 36) 36711 * integral datatypes, in file-i/o protocol: Integral Datatypes. 36712 (line 6) 36713 * Intel: Remote Stub. (line 57) 36714 * Intel disassembly flavor: Machine Code. (line 127) 36715 * interaction, readline: Readline Interaction. 36716 (line 6) 36717 * internal commands: Maintenance Commands. 36718 (line 6) 36719 * internal errors, control of GDB behavior: Maintenance Commands. 36720 (line 124) 36721 * internal GDB breakpoints: Set Breaks. (line 333) 36722 * interpreter-exec: Interpreters. (line 43) 36723 * interrupt <1>: Background Execution. 36724 (line 73) 36725 * interrupt: Quitting GDB. (line 13) 36726 * interrupt debuggee on MS-Windows: Cygwin Native. (line 9) 36727 * interrupt remote programs: Remote Configuration. 36728 (line 29) 36729 * interrupting remote programs: Connecting. (line 78) 36730 * interrupting remote targets: Bootstrapping. (line 25) 36731 * interrupts (remote protocol): Interrupts. (line 6) 36732 * invalid input: Bug Criteria. (line 16) 36733 * invoke another interpreter: Interpreters. (line 37) 36734 * invoke on Command: Commands In Python. (line 50) 36735 * invoke on Function: Functions In Python. (line 21) 36736 * is_argument: Symbols In Python. (line 77) 36737 * is_constant: Symbols In Python. (line 80) 36738 * is_exited on InferiorThread: Threads In Python. (line 61) 36739 * is_function: Symbols In Python. (line 83) 36740 * is_optimized_out: Values From Inferior. 36741 (line 50) 36742 * is_running on InferiorThread: Threads In Python. (line 58) 36743 * is_stopped on InferiorThread: Threads In Python. (line 55) 36744 * is_valid on Block: Blocks In Python. (line 24) 36745 * is_valid on Breakpoint: Breakpoints In Python. 36746 (line 62) 36747 * is_valid on Frame: Frames In Python. (line 37) 36748 * is_valid on Inferior: Inferiors In Python. (line 33) 36749 * is_valid on InferiorThread: Threads In Python. (line 43) 36750 * is_valid on Objfile: Objfiles In Python. (line 42) 36751 * is_valid on Symbol: Symbols In Python. (line 91) 36752 * is_valid on Symtab: Symbol Tables In Python. 36753 (line 51) 36754 * is_valid on Symtab_and_line: Symbol Tables In Python. 36755 (line 31) 36756 * is_variable: Symbols In Python. (line 86) 36757 * isatty, file-i/o system call: isatty. (line 6) 36758 * isearch-terminators: Readline Init File Syntax. 36759 (line 112) 36760 * JIT compilation interface: JIT Interface. (line 6) 36761 * jump: Jumping. (line 10) 36762 * jump, and Objective-C: Method Names in Commands. 36763 (line 9) 36764 * just-in-time compilation: JIT Interface. (line 6) 36765 * just-in-time compilation, debugging messages: Debugging Output. 36766 (line 98) 36767 * k packet: Packets. (line 214) 36768 * kernel crash dump: BSD libkvm Interface. 36769 (line 6) 36770 * kernel memory image: BSD libkvm Interface. 36771 (line 6) 36772 * KeyboardInterrupt: Exception Handling. (line 34) 36773 * keymap: Readline Init File Syntax. 36774 (line 119) 36775 * kill: Kill Process. (line 6) 36776 * kill inferiors INFNO...: Inferiors and Programs. 36777 (line 103) 36778 * kill ring: Readline Killing Commands. 36779 (line 19) 36780 * kill-line (C-k): Commands For Killing. 36781 (line 6) 36782 * kill-region (): Commands For Killing. 36783 (line 41) 36784 * kill-whole-line (): Commands For Killing. 36785 (line 15) 36786 * kill-word (M-d): Commands For Killing. 36787 (line 19) 36788 * killing text: Readline Killing Commands. 36789 (line 6) 36790 * kvm: BSD libkvm Interface. 36791 (line 24) 36792 * l (list): List. (line 6) 36793 * languages: Languages. (line 6) 36794 * last tracepoint number: Create and Delete Tracepoints. 36795 (line 98) 36796 * latest breakpoint: Set Breaks. (line 6) 36797 * layout: TUI Commands. (line 21) 36798 * lazy strings in python: Lazy Strings In Python. 36799 (line 6) 36800 * lazy_string on Value: Values From Inferior. 36801 (line 172) 36802 * LDT: DJGPP Native. (line 24) 36803 * leaving GDB: Quitting GDB. (line 6) 36804 * Left: TUI Keys. (line 59) 36805 * length: Lazy Strings In Python. 36806 (line 31) 36807 * libkvm: BSD libkvm Interface. 36808 (line 6) 36809 * library list format, remote protocol: Library List Format. (line 6) 36810 * limit hardware breakpoints and watchpoints: Remote Configuration. 36811 (line 72) 36812 * limit on number of printed array elements: Print Settings. (line 123) 36813 * limits, in file-i/o protocol: Limits. (line 6) 36814 * line: Symbol Tables In Python. 36815 (line 25) 36816 * linespec: Specify Location. (line 6) 36817 * linkage_name: Symbols In Python. (line 62) 36818 * Linux lightweight processes: Debugging Output. (line 104) 36819 * list: List. (line 6) 36820 * list active threads, remote request: General Query Packets. 36821 (line 84) 36822 * list of supported file-i/o calls: List of Supported Calls. 36823 (line 6) 36824 * list output in GDB/MI: GDB/MI Output Syntax. 36825 (line 117) 36826 * list, and Objective-C: Method Names in Commands. 36827 (line 9) 36828 * list, how many lines to display: List. (line 30) 36829 * listing GDB's internal symbol tables: Symbols. (line 291) 36830 * listing machine instructions: Machine Code. (line 36) 36831 * listing mapped overlays: Overlay Commands. (line 60) 36832 * load address, overlay's: How Overlays Work. (line 6) 36833 * load FILENAME: Target Commands. (line 115) 36834 * load shared library: Files. (line 323) 36835 * load symbols from memory: Files. (line 162) 36836 * local variables: Symbols. (line 138) 36837 * locate address: Output Formats. (line 35) 36838 * location: Breakpoints In Python. 36839 (line 140) 36840 * lock scheduler: All-Stop Mode. (line 37) 36841 * log output in GDB/MI: GDB/MI Output Syntax. 36842 (line 113) 36843 * logging file name: Logging Output. (line 13) 36844 * logging GDB output: Logging Output. (line 6) 36845 * lookup_global_symbol: Symbols In Python. (line 34) 36846 * lookup_symbol: Symbols In Python. (line 14) 36847 * lookup_type: Types In Python. (line 12) 36848 * loop_break: Command Files. (line 94) 36849 * loop_continue: Command Files. (line 98) 36850 * lseek flags, in file-i/o protocol: Lseek Flags. (line 6) 36851 * lseek, file-i/o system call: lseek. (line 6) 36852 * M packet: Packets. (line 241) 36853 * m packet: Packets. (line 221) 36854 * M32-EVA target board address: M32R/D. (line 21) 36855 * M32R/Chaos debugging: M32R/D. (line 50) 36856 * m680x0: Remote Stub. (line 60) 36857 * m68k-stub.c: Remote Stub. (line 60) 36858 * machine instructions: Machine Code. (line 36) 36859 * macro define: Macros. (line 52) 36860 * macro definition, showing: Macros. (line 47) 36861 * macro exp1: Macros. (line 36) 36862 * macro expand: Macros. (line 29) 36863 * macro expansion, showing the results of preprocessor: Macros. 36864 (line 29) 36865 * macro list: Macros. (line 73) 36866 * macro undef: Macros. (line 67) 36867 * macros, example of debugging with: Macros. (line 76) 36868 * macros, user-defined: Macros. (line 52) 36869 * mailing lists: GDB/MI Development and Front Ends. 36870 (line 35) 36871 * maint agent: Maintenance Commands. 36872 (line 12) 36873 * maint agent-eval: Maintenance Commands. 36874 (line 12) 36875 * maint check-symtabs: Maintenance Commands. 36876 (line 78) 36877 * maint cplus first_component: Maintenance Commands. 36878 (line 81) 36879 * maint cplus namespace: Maintenance Commands. 36880 (line 84) 36881 * maint demangle: Maintenance Commands. 36882 (line 87) 36883 * maint deprecate: Maintenance Commands. 36884 (line 90) 36885 * maint dump-me: Maintenance Commands. 36886 (line 98) 36887 * maint info breakpoints: Maintenance Commands. 36888 (line 25) 36889 * maint info program-spaces: Inferiors and Programs. 36890 (line 138) 36891 * maint info psymtabs: Symbols. (line 291) 36892 * maint info sections: Files. (line 200) 36893 * maint info sol-threads: Threads. (line 98) 36894 * maint info symtabs: Symbols. (line 291) 36895 * maint internal-error: Maintenance Commands. 36896 (line 103) 36897 * maint internal-warning: Maintenance Commands. 36898 (line 103) 36899 * maint packet: Maintenance Commands. 36900 (line 143) 36901 * maint print architecture: Maintenance Commands. 36902 (line 149) 36903 * maint print c-tdesc: Maintenance Commands. 36904 (line 153) 36905 * maint print cooked-registers: Maintenance Commands. 36906 (line 176) 36907 * maint print dummy-frames: Maintenance Commands. 36908 (line 158) 36909 * maint print objfiles: Maintenance Commands. 36910 (line 211) 36911 * maint print psymbols: Symbols. (line 272) 36912 * maint print raw-registers: Maintenance Commands. 36913 (line 176) 36914 * maint print reggroups: Maintenance Commands. 36915 (line 192) 36916 * maint print register-groups: Maintenance Commands. 36917 (line 176) 36918 * maint print registers: Maintenance Commands. 36919 (line 176) 36920 * maint print section-scripts: Maintenance Commands. 36921 (line 216) 36922 * maint print statistics: Maintenance Commands. 36923 (line 223) 36924 * maint print symbols: Symbols. (line 272) 36925 * maint print target-stack: Maintenance Commands. 36926 (line 236) 36927 * maint print type: Maintenance Commands. 36928 (line 248) 36929 * maint print unwind, HPPA: HPPA. (line 17) 36930 * maint set dwarf2 always-disassemble: Maintenance Commands. 36931 (line 255) 36932 * maint set dwarf2 max-cache-age: Maintenance Commands. 36933 (line 277) 36934 * maint set internal-error: Maintenance Commands. 36935 (line 124) 36936 * maint set internal-warning: Maintenance Commands. 36937 (line 124) 36938 * maint set profile: Maintenance Commands. 36939 (line 291) 36940 * maint set python print-stack: Python Commands. (line 31) 36941 * maint set show-all-tib: Maintenance Commands. 36942 (line 315) 36943 * maint set show-debug-regs: Maintenance Commands. 36944 (line 307) 36945 * maint show dwarf2 always-disassemble: Maintenance Commands. 36946 (line 255) 36947 * maint show dwarf2 max-cache-age: Maintenance Commands. 36948 (line 277) 36949 * maint show internal-error: Maintenance Commands. 36950 (line 124) 36951 * maint show internal-warning: Maintenance Commands. 36952 (line 124) 36953 * maint show profile: Maintenance Commands. 36954 (line 291) 36955 * maint show show-all-tib: Maintenance Commands. 36956 (line 315) 36957 * maint show show-debug-regs: Maintenance Commands. 36958 (line 307) 36959 * maint space: Maintenance Commands. 36960 (line 321) 36961 * maint time: Maintenance Commands. 36962 (line 328) 36963 * maint translate-address: Maintenance Commands. 36964 (line 339) 36965 * maint undeprecate: Maintenance Commands. 36966 (line 90) 36967 * maintenance commands: Maintenance Commands. 36968 (line 6) 36969 * make: Shell Commands. (line 19) 36970 * manual overlay debugging: Overlay Commands. (line 23) 36971 * map an overlay: Overlay Commands. (line 30) 36972 * mapinfo list, QNX Neutrino: SVR4 Process Information. 36973 (line 78) 36974 * mapped address: How Overlays Work. (line 6) 36975 * mapped overlays: How Overlays Work. (line 6) 36976 * mark-modified-lines: Readline Init File Syntax. 36977 (line 132) 36978 * mark-symlinked-directories: Readline Init File Syntax. 36979 (line 137) 36980 * markers, static tracepoints: Set Tracepoints. (line 28) 36981 * match-hidden-files: Readline Init File Syntax. 36982 (line 142) 36983 * maximum value for offset of closest symbol: Print Settings. (line 70) 36984 * may-insert-breakpoints: Observer Mode. (line 50) 36985 * may-insert-fast-tracepoints: Observer Mode. (line 69) 36986 * may-insert-tracepoints: Observer Mode. (line 59) 36987 * may-interrupt: Observer Mode. (line 79) 36988 * may-write-memory: Observer Mode. (line 41) 36989 * may-write-registers: Observer Mode. (line 32) 36990 * mem: Memory Region Attributes. 36991 (line 22) 36992 * member functions: C Plus Plus Expressions. 36993 (line 18) 36994 * memory address space mappings: SVR4 Process Information. 36995 (line 32) 36996 * memory map format: Memory Map Format. (line 6) 36997 * memory region attributes: Memory Region Attributes. 36998 (line 6) 36999 * memory tracing: Breakpoints. (line 20) 37000 * memory transfer, in file-i/o protocol: Memory Transfer. (line 6) 37001 * memory used by commands: Maintenance Commands. 37002 (line 321) 37003 * memory used for symbol tables: Files. (line 311) 37004 * memory, alignment and size of remote accesses: Packets. (line 228) 37005 * memory, viewing as typed object: Expressions. (line 43) 37006 * memset: Bootstrapping. (line 70) 37007 * menu-complete (): Commands For Completion. 37008 (line 18) 37009 * meta-flag: Readline Init File Syntax. 37010 (line 105) 37011 * mi interpreter: Interpreters. (line 26) 37012 * mi1 interpreter: Interpreters. (line 34) 37013 * mi2 interpreter: Interpreters. (line 31) 37014 * minimal language: Unsupported Languages. 37015 (line 6) 37016 * Minimal symbols and DLLs: Non-debug DLL Symbols. 37017 (line 6) 37018 * MIPS addresses, masking: MIPS. (line 61) 37019 * MIPS boards: MIPS Embedded. (line 6) 37020 * MIPS remote floating point: MIPS Embedded. (line 60) 37021 * MIPS stack: MIPS. (line 6) 37022 * miscellaneous settings: Other Misc Settings. (line 6) 37023 * MMX registers (x86): Registers. (line 71) 37024 * mode_t values, in file-i/o protocol: mode_t Values. (line 6) 37025 * Modula-2: Summary. (line 29) 37026 * Modula-2 built-ins: Built-In Func/Proc. (line 6) 37027 * Modula-2 checks: M2 Checks. (line 6) 37028 * Modula-2 constants: Built-In Func/Proc. (line 112) 37029 * Modula-2 defaults: M2 Defaults. (line 6) 37030 * Modula-2 operators: M2 Operators. (line 6) 37031 * Modula-2 types: M2 Types. (line 6) 37032 * Modula-2, deviations from: Deviations. (line 6) 37033 * Modula-2, GDB support: Modula-2. (line 6) 37034 * monitor: Connecting. (line 105) 37035 * monitor commands, for gdbserver: Server. (line 171) 37036 * Motorola 680x0: Remote Stub. (line 60) 37037 * MS Windows debugging: Cygwin Native. (line 6) 37038 * MS-DOS system info: DJGPP Native. (line 19) 37039 * MS-DOS-specific commands: DJGPP Native. (line 6) 37040 * multiple locations, breakpoints: Set Breaks. (line 190) 37041 * multiple processes: Forks. (line 6) 37042 * multiple processes with gdbserver: Server. (line 91) 37043 * multiple targets: Active Targets. (line 6) 37044 * multiple threads: Threads. (line 6) 37045 * multiple threads, backtrace: Backtrace. (line 37) 37046 * multiple-symbols menu: Ambiguous Expressions. 37047 (line 51) 37048 * multiprocess extensions, in remote protocol: General Query Packets. 37049 (line 527) 37050 * n (next): Continuing and Stepping. 37051 (line 78) 37052 * n (SingleKey TUI key): TUI Single Key Mode. (line 19) 37053 * name <1>: Symbols In Python. (line 58) 37054 * name: Threads In Python. (line 20) 37055 * name a thread: Threads. (line 131) 37056 * name on Frame: Frames In Python. (line 44) 37057 * names of symbols: Symbols. (line 14) 37058 * namespace in C++: C Plus Plus Expressions. 37059 (line 22) 37060 * native Cygwin debugging: Cygwin Native. (line 6) 37061 * native DJGPP debugging: DJGPP Native. (line 6) 37062 * negative breakpoint numbers: Set Breaks. (line 333) 37063 * NetROM ROM emulator target: Target Commands. (line 88) 37064 * New SYSTAG message: Threads. (line 51) 37065 * newer on Frame: Frames In Python. (line 93) 37066 * newest_frame: Frames In Python. (line 27) 37067 * next: Continuing and Stepping. 37068 (line 78) 37069 * next&: Background Execution. 37070 (line 47) 37071 * next-history (C-n): Commands For History. 37072 (line 16) 37073 * nexti: Continuing and Stepping. 37074 (line 203) 37075 * nexti&: Background Execution. 37076 (line 50) 37077 * ni (nexti): Continuing and Stepping. 37078 (line 203) 37079 * non-incremental-forward-search-history (M-n): Commands For History. 37080 (line 40) 37081 * non-incremental-reverse-search-history (M-p): Commands For History. 37082 (line 35) 37083 * non-member C++ functions, set breakpoint in: Set Breaks. (line 108) 37084 * non-stop mode: Non-Stop Mode. (line 6) 37085 * non-stop mode, and breakpoint always-inserted: Set Breaks. (line 326) 37086 * non-stop mode, and process record and replay: Process Record and Replay. 37087 (line 52) 37088 * non-stop mode, and set displaced-stepping: Maintenance Commands. 37089 (line 73) 37090 * non-stop mode, remote request: General Query Packets. 37091 (line 220) 37092 * noninvasive task options: Hurd Native. (line 73) 37093 * nosharedlibrary: Files. (line 341) 37094 * notation, readline: Readline Bare Essentials. 37095 (line 6) 37096 * notational conventions, for GDB/MI: GDB/MI. (line 25) 37097 * notification packets: Notification Packets. 37098 (line 6) 37099 * notify output in GDB/MI: GDB/MI Output Syntax. 37100 (line 102) 37101 * NULL elements in arrays: Print Settings. (line 189) 37102 * num <1>: Threads In Python. (line 30) 37103 * num: Inferiors In Python. (line 20) 37104 * number: Breakpoints In Python. 37105 (line 102) 37106 * number of array elements to print: Print Settings. (line 123) 37107 * number representation: Numbers. (line 6) 37108 * numbers for breakpoints: Breakpoints. (line 41) 37109 * object files, relocatable, reading symbols from: Files. (line 132) 37110 * Objective-C: Objective-C. (line 6) 37111 * Objective-C, classes and selectors: Symbols. (line 205) 37112 * Objective-C, print objects: The Print Command with Objective-C. 37113 (line 6) 37114 * objfile: Symbol Tables In Python. 37115 (line 45) 37116 * Objfile: Objfiles In Python. (line 6) 37117 * OBJFILE-gdb.py: objfile-gdb.py file. (line 6) 37118 * objfiles: Objfiles In Python. (line 22) 37119 * objfiles in python: Objfiles In Python. (line 6) 37120 * observer: Observer Mode. (line 22) 37121 * observer debugging info: Debugging Output. (line 118) 37122 * octal escapes in strings: Print Settings. (line 222) 37123 * older on Frame: Frames In Python. (line 90) 37124 * online documentation: Help. (line 6) 37125 * opaque data types: Symbols. (line 241) 37126 * open flags, in file-i/o protocol: Open Flags. (line 6) 37127 * open, file-i/o system call: open. (line 6) 37128 * OpenCL C: OpenCL C. (line 6) 37129 * OpenCL C Datatypes: OpenCL C Datatypes. (line 6) 37130 * OpenCL C Expressions: OpenCL C Expressions. 37131 (line 6) 37132 * OpenCL C Operators: OpenCL C Operators. (line 6) 37133 * OpenRISC 1000: OpenRISC 1000. (line 6) 37134 * OpenRISC 1000 htrace: OpenRISC 1000. (line 58) 37135 * operating system information: Operating System Information. 37136 (line 6) 37137 * operating system information, process list: Process list. (line 6) 37138 * optimized code, debugging: Optimized Code. (line 6) 37139 * optimized code, wrong values of variables: Variables. (line 58) 37140 * optimized out value in Python: Values From Inferior. 37141 (line 49) 37142 * optimized out, in backtrace: Backtrace. (line 71) 37143 * optional debugging messages: Debugging Output. (line 6) 37144 * optional warnings: Messages/Warnings. (line 6) 37145 * or1k boards: OpenRISC 1000. (line 6) 37146 * or1ksim: OpenRISC 1000. (line 16) 37147 * OS ABI: ABI. (line 11) 37148 * OS information: OS Information. (line 6) 37149 * out-of-line single-stepping: Maintenance Commands. 37150 (line 56) 37151 * outermost frame: Frames. (line 12) 37152 * output: Output. (line 35) 37153 * output formats: Output Formats. (line 6) 37154 * output syntax of GDB/MI: GDB/MI Output Syntax. 37155 (line 6) 37156 * output-meta: Readline Init File Syntax. 37157 (line 149) 37158 * overlay: Overlay Commands. (line 17) 37159 * overlay area: How Overlays Work. (line 6) 37160 * overlay example program: Overlay Sample Program. 37161 (line 6) 37162 * overlays: Overlays. (line 6) 37163 * overlays, setting breakpoints in: Overlay Commands. (line 93) 37164 * overload-choice annotation: Prompting. (line 32) 37165 * overloaded functions, calling: C Plus Plus Expressions. 37166 (line 27) 37167 * overloaded functions, overload resolution: Debugging C Plus Plus. 37168 (line 48) 37169 * overloading in C++: Debugging C Plus Plus. 37170 (line 15) 37171 * overwrite-mode (): Commands For Text. (line 53) 37172 * P packet: Packets. (line 269) 37173 * p packet: Packets. (line 254) 37174 * packet acknowledgment, for GDB remote: Packet Acknowledgment. 37175 (line 6) 37176 * packet size, remote protocol: General Query Packets. 37177 (line 458) 37178 * packets, notification: Notification Packets. 37179 (line 6) 37180 * packets, reporting on stdout: Debugging Output. (line 140) 37181 * packets, tracepoint: Tracepoint Packets. (line 6) 37182 * page tables display (MS-DOS): DJGPP Native. (line 56) 37183 * page-completions: Readline Init File Syntax. 37184 (line 154) 37185 * PARAM_AUTO_BOOLEAN: Parameters In Python. 37186 (line 93) 37187 * PARAM_BOOLEAN: Parameters In Python. 37188 (line 89) 37189 * PARAM_ENUM: Parameters In Python. 37190 (line 127) 37191 * PARAM_FILENAME: Parameters In Python. 37192 (line 119) 37193 * PARAM_INTEGER: Parameters In Python. 37194 (line 102) 37195 * PARAM_OPTIONAL_FILENAME: Parameters In Python. 37196 (line 116) 37197 * PARAM_STRING: Parameters In Python. 37198 (line 106) 37199 * PARAM_STRING_NOESCAPE: Parameters In Python. 37200 (line 112) 37201 * PARAM_UINTEGER: Parameters In Python. 37202 (line 98) 37203 * PARAM_ZINTEGER: Parameters In Python. 37204 (line 123) 37205 * Parameter: Parameters In Python. 37206 (line 6) 37207 * parameter: Basic Python. (line 36) 37208 * parameters in python: Parameters In Python. 37209 (line 6) 37210 * parse_and_eval: Basic Python. (line 59) 37211 * partial symbol dump: Symbols. (line 272) 37212 * partial symbol tables, listing GDB's internal: Symbols. (line 291) 37213 * Pascal: Summary. (line 35) 37214 * Pascal objects, static members display: Print Settings. (line 353) 37215 * Pascal support in GDB, limitations: Pascal. (line 6) 37216 * pass signals to inferior, remote request: General Query Packets. 37217 (line 240) 37218 * passcount: Tracepoint Passcounts. 37219 (line 6) 37220 * patching binaries: Patching. (line 6) 37221 * patching object files: Files. (line 26) 37222 * path: Environment. (line 14) 37223 * pause current task (GNU Hurd): Hurd Native. (line 49) 37224 * pause current thread (GNU Hurd): Hurd Native. (line 91) 37225 * pauses in output: Screen Size. (line 6) 37226 * pc: Symbol Tables In Python. 37227 (line 21) 37228 * pc on Frame: Frames In Python. (line 80) 37229 * pending breakpoints: Set Breaks. (line 232) 37230 * PgDn: TUI Keys. (line 50) 37231 * PgUp: TUI Keys. (line 47) 37232 * physical address from linear address: DJGPP Native. (line 81) 37233 * physname: Debugging Output. (line 35) 37234 * pid: Inferiors In Python. (line 23) 37235 * pipe, target remote to: Connecting. (line 60) 37236 * pipes: Starting. (line 62) 37237 * pmon, MIPS remote: MIPS Embedded. (line 132) 37238 * po (print-object): The Print Command with Objective-C. 37239 (line 6) 37240 * pointer on Type: Types In Python. (line 114) 37241 * pointer values, in file-i/o protocol: Pointer Values. (line 6) 37242 * pointer, finding referent: Print Settings. (line 79) 37243 * port rights, GNU Hurd: Hurd Native. (line 85) 37244 * port sets, GNU Hurd: Hurd Native. (line 85) 37245 * possible-completions (M-?): Commands For Completion. 37246 (line 11) 37247 * post-commands annotation: Prompting. (line 27) 37248 * post-overload-choice annotation: Prompting. (line 32) 37249 * post-prompt annotation: Prompting. (line 24) 37250 * post-prompt-for-continue annotation: Prompting. (line 40) 37251 * post-query annotation: Prompting. (line 36) 37252 * post_event: Basic Python. (line 70) 37253 * PowerPC architecture: PowerPC. (line 6) 37254 * pre-commands annotation: Prompting. (line 27) 37255 * pre-overload-choice annotation: Prompting. (line 32) 37256 * pre-prompt annotation: Prompting. (line 24) 37257 * pre-prompt-for-continue annotation: Prompting. (line 40) 37258 * pre-query annotation: Prompting. (line 36) 37259 * prefix for data files: Data Files. (line 6) 37260 * prefix for shared library file names: Files. (line 374) 37261 * prefix-meta (<ESC>): Miscellaneous Commands. 37262 (line 18) 37263 * premature return from system calls: Interrupted System Calls. 37264 (line 6) 37265 * preprocessor macro expansion, showing the results of: Macros. 37266 (line 29) 37267 * pretty print arrays: Print Settings. (line 98) 37268 * pretty print C++ virtual function tables: Print Settings. (line 364) 37269 * pretty-printer commands: Pretty-Printer Commands. 37270 (line 6) 37271 * pretty_printers <1>: Objfiles In Python. (line 32) 37272 * pretty_printers: Progspaces In Python. 37273 (line 28) 37274 * previous-history (C-p): Commands For History. 37275 (line 12) 37276 * print: Data. (line 6) 37277 * print all frame argument values: Print Settings. (line 135) 37278 * print an Objective-C object description: The Print Command with Objective-C. 37279 (line 11) 37280 * print array indexes: Print Settings. (line 108) 37281 * print frame argument values for scalars only: Print Settings. 37282 (line 135) 37283 * print list of auto-loaded scripts: Auto-loading. (line 29) 37284 * print messages on inferior start and exit: Inferiors and Programs. 37285 (line 117) 37286 * print messages on thread start and exit: Threads. (line 156) 37287 * print messages when symbols are loaded: Symbols. (line 259) 37288 * print settings: Print Settings. (line 6) 37289 * print structures in indented form: Print Settings. (line 198) 37290 * print-object: The Print Command with Objective-C. 37291 (line 6) 37292 * print/don't print memory addresses: Print Settings. (line 13) 37293 * print_name: Symbols In Python. (line 66) 37294 * printf: Output. (line 46) 37295 * printing byte arrays: Output Formats. (line 60) 37296 * printing data: Data. (line 6) 37297 * printing frame argument values: Print Settings. (line 135) 37298 * printing strings: Output Formats. (line 60) 37299 * probe static tracepoint marker: Create and Delete Tracepoints. 37300 (line 51) 37301 * probing markers, static tracepoints: Set Tracepoints. (line 28) 37302 * proc-trace-entry: SVR4 Process Information. 37303 (line 70) 37304 * proc-trace-exit: SVR4 Process Information. 37305 (line 70) 37306 * proc-untrace-entry: SVR4 Process Information. 37307 (line 70) 37308 * proc-untrace-exit: SVR4 Process Information. 37309 (line 70) 37310 * process detailed status information: SVR4 Process Information. 37311 (line 40) 37312 * process ID: SVR4 Process Information. 37313 (line 16) 37314 * process info via /proc: SVR4 Process Information. 37315 (line 6) 37316 * process list, QNX Neutrino: SVR4 Process Information. 37317 (line 74) 37318 * process record and replay: Process Record and Replay. 37319 (line 6) 37320 * process status register: Registers. (line 26) 37321 * processes, multiple: Forks. (line 6) 37322 * procfs API calls: SVR4 Process Information. 37323 (line 53) 37324 * profiling GDB: Maintenance Commands. 37325 (line 291) 37326 * program counter register: Registers. (line 26) 37327 * program entry point: Backtrace. (line 93) 37328 * programming in python: Python API. (line 6) 37329 * Progspace: Progspaces In Python. 37330 (line 6) 37331 * progspaces: Progspaces In Python. 37332 (line 19) 37333 * progspaces in python: Progspaces In Python. 37334 (line 6) 37335 * prompt: Prompt. (line 6) 37336 * prompt annotation: Prompting. (line 24) 37337 * prompt-for-continue annotation: Prompting. (line 40) 37338 * protocol basics, file-i/o: Protocol Basics. (line 6) 37339 * protocol, GDB remote serial: Overview. (line 14) 37340 * protocol-specific representation of datatypes, in file-i/o protocol: Protocol-specific Representation of Datatypes. 37341 (line 6) 37342 * ptid: Threads In Python. (line 33) 37343 * ptrace system call: OS Information. (line 9) 37344 * ptype: Symbols. (line 85) 37345 * putDebugChar: Bootstrapping. (line 20) 37346 * pwd: Working Directory. (line 19) 37347 * python: Python Commands. (line 9) 37348 * python api: Python API. (line 6) 37349 * python commands <1>: Commands In Python. (line 6) 37350 * python commands: Python Commands. (line 6) 37351 * python convenience functions: Functions In Python. (line 6) 37352 * python directory: Python. (line 10) 37353 * python exceptions: Exception Handling. (line 6) 37354 * python functions: Basic Python. (line 6) 37355 * python module: Basic Python. (line 6) 37356 * python modules: Python modules. (line 6) 37357 * python pagination: Python API. (line 6) 37358 * python parameters: Parameters In Python. 37359 (line 6) 37360 * python scripting: Python. (line 6) 37361 * python stdout: Python API. (line 6) 37362 * Python, working with types: Types In Python. (line 6) 37363 * python, working with values from inferior: Values From Inferior. 37364 (line 6) 37365 * PYTHONDIR: Basic Python. (line 12) 37366 * q (quit): Quitting GDB. (line 6) 37367 * q (SingleKey TUI key): TUI Single Key Mode. (line 22) 37368 * Q packet: Packets. (line 282) 37369 * q packet: Packets. (line 282) 37370 * QAllow packet: General Query Packets. 37371 (line 41) 37372 * qAttached packet: General Query Packets. 37373 (line 835) 37374 * qC packet: General Query Packets. 37375 (line 52) 37376 * qCRC packet: General Query Packets. 37377 (line 63) 37378 * qfThreadInfo packet: General Query Packets. 37379 (line 84) 37380 * qGetTIBAddr packet: General Query Packets. 37381 (line 143) 37382 * qGetTLSAddr packet: General Query Packets. 37383 (line 112) 37384 * QNonStop packet: General Query Packets. 37385 (line 220) 37386 * QNX Neutrino: Neutrino. (line 6) 37387 * qOffsets packet: General Query Packets. 37388 (line 182) 37389 * qP packet: General Query Packets. 37390 (line 209) 37391 * QPassSignals packet: General Query Packets. 37392 (line 240) 37393 * qRcmd packet: General Query Packets. 37394 (line 268) 37395 * qSearch:memory packet: General Query Packets. 37396 (line 293) 37397 * QStartNoAckMode packet: General Query Packets. 37398 (line 313) 37399 * qsThreadInfo packet: General Query Packets. 37400 (line 84) 37401 * qSupported packet: General Query Packets. 37402 (line 328) 37403 * qSymbol packet: General Query Packets. 37404 (line 567) 37405 * QTDPsrc packet: Tracepoint Packets. (line 96) 37406 * QTDV packet: Tracepoint Packets. (line 127) 37407 * qThreadExtraInfo packet: General Query Packets. 37408 (line 612) 37409 * qTV packet: Tracepoint Packets. (line 276) 37410 * query annotation: Prompting. (line 36) 37411 * query attached, remote request: General Query Packets. 37412 (line 835) 37413 * quit [EXPRESSION]: Quitting GDB. (line 6) 37414 * quit annotation: Errors. (line 6) 37415 * quoted-insert (C-q or C-v): Commands For Text. (line 20) 37416 * quotes in commands: Completion. (line 57) 37417 * quoting Ada internal identifiers: Additions to Ada. (line 76) 37418 * quoting names: Symbols. (line 14) 37419 * qXfer packet: General Query Packets. 37420 (line 648) 37421 * r (run): Starting. (line 6) 37422 * r (SingleKey TUI key): TUI Single Key Mode. (line 25) 37423 * R packet: Packets. (line 291) 37424 * r packet: Packets. (line 286) 37425 * raise exceptions: Set Catchpoints. (line 197) 37426 * range checking: Type Checking. (line 65) 37427 * range on Type: Types In Python. (line 104) 37428 * ranged breakpoint: PowerPC Embedded. (line 30) 37429 * ranges of breakpoints: Breakpoints. (line 48) 37430 * Ravenscar Profile: Ravenscar Profile. (line 6) 37431 * raw printing: Output Formats. (line 70) 37432 * rbreak: Set Breaks. (line 92) 37433 * rc (reverse-continue): Reverse Execution. (line 30) 37434 * RDI heartbeat: ARM. (line 112) 37435 * rdilogenable: ARM. (line 95) 37436 * rdilogfile: ARM. (line 89) 37437 * re-read-init-file (C-x C-r): Miscellaneous Commands. 37438 (line 6) 37439 * read special object, remote request: General Query Packets. 37440 (line 648) 37441 * read, file-i/o system call: read. (line 6) 37442 * read-only sections: Files. (line 258) 37443 * read_memory on Inferior: Inferiors In Python. (line 45) 37444 * read_var on Frame: Frames In Python. (line 100) 37445 * reading symbols from relocatable object files: Files. (line 132) 37446 * reading symbols immediately: Files. (line 90) 37447 * readline: Editing. (line 6) 37448 * readnow: Files. (line 90) 37449 * rec: Process Record and Replay. 37450 (line 38) 37451 * rec del: Process Record and Replay. 37452 (line 155) 37453 * rec s: Process Record and Replay. 37454 (line 57) 37455 * receive rights, GNU Hurd: Hurd Native. (line 85) 37456 * recent tracepoint number: Create and Delete Tracepoints. 37457 (line 98) 37458 * record: Process Record and Replay. 37459 (line 38) 37460 * record aggregates (Ada): Omissions from Ada. (line 44) 37461 * record delete: Process Record and Replay. 37462 (line 155) 37463 * record mode: Process Record and Replay. 37464 (line 19) 37465 * record restore: Process Record and Replay. 37466 (line 85) 37467 * record save: Process Record and Replay. 37468 (line 80) 37469 * record serial communications on file: Remote Configuration. 37470 (line 57) 37471 * record stop: Process Record and Replay. 37472 (line 57) 37473 * recording a session script: Bug Reporting. (line 104) 37474 * recording inferior's execution and replaying it: Process Record and Replay. 37475 (line 6) 37476 * redirection: Input/Output. (line 6) 37477 * redraw-current-line (): Commands For Moving. (line 30) 37478 * reference card: Formatting Documentation. 37479 (line 6) 37480 * reference declarations: C Plus Plus Expressions. 37481 (line 51) 37482 * reference on Type: Types In Python. (line 110) 37483 * refresh: TUI Commands. (line 58) 37484 * register stack, AMD29K: A29K. (line 6) 37485 * registers: Registers. (line 6) 37486 * regs, Super-H: Super-H. (line 9) 37487 * regular expression: Set Breaks. (line 92) 37488 * reinterpret_cast on Value: Values From Inferior. 37489 (line 135) 37490 * reloading symbols: Symbols. (line 217) 37491 * reloading the overlay table: Overlay Commands. (line 52) 37492 * relocatable object files, reading symbols from: Files. (line 132) 37493 * remote connection without stubs: Server. (line 6) 37494 * remote debugging: Remote Debugging. (line 6) 37495 * remote delete: File Transfer. (line 23) 37496 * remote get: File Transfer. (line 19) 37497 * remote memory comparison: Memory. (line 123) 37498 * remote monitor prompt: MIPS Embedded. (line 107) 37499 * remote packets, enabling and disabling: Remote Configuration. 37500 (line 132) 37501 * remote programs, interrupting: Connecting. (line 78) 37502 * remote protocol debugging: Debugging Output. (line 140) 37503 * remote protocol, binary data: Overview. (line 61) 37504 * remote protocol, field separator: Overview. (line 53) 37505 * remote put: File Transfer. (line 15) 37506 * remote query requests: General Query Packets. 37507 (line 6) 37508 * remote serial debugging summary: Debug Session. (line 6) 37509 * remote serial debugging, overview: Remote Stub. (line 14) 37510 * remote serial protocol: Overview. (line 14) 37511 * remote serial stub: Stub Contents. (line 6) 37512 * remote serial stub list: Remote Stub. (line 54) 37513 * remote serial stub, initialization: Stub Contents. (line 10) 37514 * remote serial stub, main routine: Stub Contents. (line 15) 37515 * remote stub, example: Remote Stub. (line 6) 37516 * remote stub, support routines: Bootstrapping. (line 6) 37517 * remote target: Target Commands. (line 58) 37518 * remote target, file transfer: File Transfer. (line 6) 37519 * remote target, limit break- and watchpoints: Remote Configuration. 37520 (line 72) 37521 * remote timeout: Remote Configuration. 37522 (line 65) 37523 * remotetimeout: Sparclet. (line 12) 37524 * remove actions from a tracepoint: Tracepoint Actions. (line 21) 37525 * remove-inferiors: Inferiors and Programs. 37526 (line 86) 37527 * rename, file-i/o system call: rename. (line 6) 37528 * Renesas: Remote Stub. (line 63) 37529 * repeated array elements: Print Settings. (line 176) 37530 * repeating command sequences: Command Syntax. (line 42) 37531 * repeating commands: Command Syntax. (line 21) 37532 * replay log events, remote reply: Stop Reply Packets. (line 61) 37533 * replay mode: Process Record and Replay. 37534 (line 10) 37535 * reporting bugs in GDB: GDB Bugs. (line 6) 37536 * reprint the last value: Data. (line 23) 37537 * reset SDI connection, M32R: M32R/D. (line 44) 37538 * response time, MIPS debugging: MIPS. (line 10) 37539 * restart: Checkpoint/Restart. (line 6) 37540 * restart CHECKPOINT-ID: Checkpoint/Restart. (line 44) 37541 * restore: Dump/Restore Files. (line 41) 37542 * restore data from a file: Dump/Restore Files. (line 6) 37543 * result records in GDB/MI: GDB/MI Result Records. 37544 (line 6) 37545 * resume threads of multiple processes simultaneously: All-Stop Mode. 37546 (line 53) 37547 * resuming execution: Continuing and Stepping. 37548 (line 6) 37549 * RET (repeat last command): Command Syntax. (line 21) 37550 * retransmit-timeout, MIPS protocol: MIPS Embedded. (line 83) 37551 * return: Returning. (line 6) 37552 * returning from a function: Returning. (line 6) 37553 * reverse execution: Reverse Execution. (line 6) 37554 * reverse-continue: Reverse Execution. (line 30) 37555 * reverse-finish: Reverse Execution. (line 77) 37556 * reverse-next: Reverse Execution. (line 60) 37557 * reverse-nexti: Reverse Execution. (line 69) 37558 * reverse-search: Search. (line 16) 37559 * reverse-search-history (C-r): Commands For History. 37560 (line 26) 37561 * reverse-step: Reverse Execution. (line 37) 37562 * reverse-stepi: Reverse Execution. (line 52) 37563 * revert-line (M-r): Miscellaneous Commands. 37564 (line 25) 37565 * rewind program state: Checkpoint/Restart. (line 6) 37566 * Right: TUI Keys. (line 62) 37567 * rn (reverse-next): Reverse Execution. (line 60) 37568 * rni (reverse-nexti): Reverse Execution. (line 69) 37569 * ROM at zero address, RDI: ARM. (line 102) 37570 * rs (step): Reverse Execution. (line 37) 37571 * rsi (reverse-stepi): Reverse Execution. (line 52) 37572 * run: Starting. (line 6) 37573 * run to main procedure: Starting. (line 79) 37574 * run until specified location: Continuing and Stepping. 37575 (line 118) 37576 * run&: Background Execution. 37577 (line 34) 37578 * running: Starting. (line 6) 37579 * running and debugging Sparclet programs: Sparclet Execution. 37580 (line 6) 37581 * running programs backward: Reverse Execution. (line 6) 37582 * running VxWorks tasks: VxWorks Attach. (line 6) 37583 * running, on Sparclet: Sparclet. (line 28) 37584 * rwatch: Set Watchpoints. (line 64) 37585 * s (SingleKey TUI key): TUI Single Key Mode. (line 28) 37586 * s (step): Continuing and Stepping. 37587 (line 46) 37588 * S packet: Packets. (line 304) 37589 * s packet: Packets. (line 298) 37590 * save breakpoints: Save Breakpoints. (line 9) 37591 * save breakpoints to a file for future sessions: Save Breakpoints. 37592 (line 9) 37593 * save command history: Command History. (line 36) 37594 * save GDB output to a file: Logging Output. (line 6) 37595 * save gdb-index: Index Files. (line 19) 37596 * save tracepoints: save tracepoints. (line 6) 37597 * save tracepoints for future sessions: save tracepoints. (line 6) 37598 * save-tracepoints: save tracepoints. (line 6) 37599 * scheduler locking mode: All-Stop Mode. (line 37) 37600 * scope: M2 Scope. (line 6) 37601 * scripting commands: Command Files. (line 6) 37602 * scripting with python: Python. (line 6) 37603 * sdireset: M32R/D. (line 44) 37604 * sdistatus: M32R/D. (line 47) 37605 * SDS protocol: PowerPC Embedded. (line 80) 37606 * sds, a command: PowerPC Embedded. (line 91) 37607 * search: Search. (line 9) 37608 * search for a thread: Threads. (line 142) 37609 * search path for libthread_db: Threads. (line 177) 37610 * search_memory on Inferior: Inferiors In Python. (line 58) 37611 * searching memory: Searching Memory. (line 6) 37612 * searching memory, in remote debugging: General Query Packets. 37613 (line 293) 37614 * searching source files: Search. (line 6) 37615 * section: Files. (line 182) 37616 * section offsets, remote request: General Query Packets. 37617 (line 182) 37618 * segment descriptor tables: DJGPP Native. (line 24) 37619 * select Ctrl-C, BREAK or BREAK-g: Remote Configuration. 37620 (line 85) 37621 * select on Frame: Frames In Python. (line 108) 37622 * select trace snapshot: tfind. (line 6) 37623 * select-frame: Frames. (line 51) 37624 * selected frame: Stack. (line 19) 37625 * selected_frame: Frames In Python. (line 23) 37626 * selected_thread: Threads In Python. (line 14) 37627 * selecting frame silently: Frames. (line 51) 37628 * self-insert (a, b, A, 1, !, ...): Commands For Text. (line 27) 37629 * send command to remote monitor: Connecting. (line 105) 37630 * send command to simulator: Embedded Processors. (line 9) 37631 * send interrupt-sequence on start: Remote Configuration. 37632 (line 98) 37633 * send PMON command: MIPS Embedded. (line 132) 37634 * send rights, GNU Hurd: Hurd Native. (line 85) 37635 * sending files to remote systems: File Transfer. (line 6) 37636 * separate debugging information files: Separate Debug Files. 37637 (line 6) 37638 * sequence-id, for GDB remote: Overview. (line 29) 37639 * serial connections, debugging: Debugging Output. (line 140) 37640 * serial line, target remote: Connecting. (line 18) 37641 * serial protocol, GDB remote: Overview. (line 14) 37642 * server prefix: Server Prefix. (line 6) 37643 * server, command prefix: Command History. (line 20) 37644 * set: Help. (line 107) 37645 * set ABI for MIPS: MIPS. (line 32) 37646 * set ada trust-PAD-over-XVS: Ada Glitches. (line 43) 37647 * set annotate: Annotations Overview. 37648 (line 29) 37649 * set architecture: Targets. (line 21) 37650 * set args: Arguments. (line 21) 37651 * set arm: ARM. (line 18) 37652 * set auto-load-scripts: Auto-loading. (line 23) 37653 * set auto-solib-add: Files. (line 303) 37654 * set backtrace: Backtrace. (line 104) 37655 * set basenames-may-differ: Files. (line 517) 37656 * set board-address: M32R/D. (line 21) 37657 * set breakpoint always-inserted: Set Breaks. (line 314) 37658 * set breakpoint auto-hw: Set Breaks. (line 294) 37659 * set breakpoint pending: Set Breaks. (line 263) 37660 * set breakpoints in many functions: Set Breaks. (line 92) 37661 * set breakpoints on all functions: Set Breaks. (line 112) 37662 * set can-use-hw-watchpoints: Set Watchpoints. (line 101) 37663 * set case-sensitive: Symbols. (line 27) 37664 * set charset: Character Sets. (line 46) 37665 * set check range: Range Checking. (line 34) 37666 * set check type: Type Checking. (line 42) 37667 * set circular-trace-buffer: Starting and Stopping Trace Experiments. 37668 (line 87) 37669 * set coerce-float-to-double: ABI. (line 41) 37670 * set com1base: DJGPP Native. (line 125) 37671 * set com1irq: DJGPP Native. (line 125) 37672 * set com2base: DJGPP Native. (line 125) 37673 * set com2irq: DJGPP Native. (line 125) 37674 * set com3base: DJGPP Native. (line 125) 37675 * set com3irq: DJGPP Native. (line 125) 37676 * set com4base: DJGPP Native. (line 125) 37677 * set com4irq: DJGPP Native. (line 125) 37678 * set complaints: Messages/Warnings. (line 29) 37679 * set confirm: Messages/Warnings. (line 50) 37680 * set cp-abi: ABI. (line 53) 37681 * set cygwin-exceptions: Cygwin Native. (line 42) 37682 * set data-directory: Data Files. (line 12) 37683 * set dcache line-size: Caching Remote Data. (line 48) 37684 * set dcache size: Caching Remote Data. (line 45) 37685 * set debug: Debugging Output. (line 18) 37686 * set debug darwin: Darwin. (line 9) 37687 * set debug hppa: HPPA. (line 10) 37688 * set debug libthread-db: Threads. (line 212) 37689 * set debug mach-o: Darwin. (line 16) 37690 * set debug mips: MIPS. (line 81) 37691 * set debug monitor: Target Commands. (line 108) 37692 * set debug nto-debug: Neutrino. (line 9) 37693 * set debug-file-directory: Separate Debug Files. 37694 (line 68) 37695 * set debugevents: Cygwin Native. (line 71) 37696 * set debugexceptions: Cygwin Native. (line 82) 37697 * set debugexec: Cygwin Native. (line 78) 37698 * set debugmemory: Cygwin Native. (line 86) 37699 * set default-collect: Tracepoint Actions. (line 114) 37700 * set demangle-style: Print Settings. (line 296) 37701 * set detach-on-fork: Forks. (line 55) 37702 * set directories: Source Path. (line 120) 37703 * set disable-randomization: Starting. (line 136) 37704 * set disassemble-next-line: Machine Code. (line 139) 37705 * set disassembly-flavor: Machine Code. (line 127) 37706 * set disconnected-tracing: Starting and Stopping Trace Experiments. 37707 (line 48) 37708 * set displaced-stepping: Maintenance Commands. 37709 (line 56) 37710 * set download-path: M32R/D. (line 15) 37711 * set editing: Editing. (line 15) 37712 * set endian: Byte Order. (line 13) 37713 * set environment: Environment. (line 39) 37714 * set exceptions, Hurd command: Hurd Native. (line 40) 37715 * set exec-direction: Reverse Execution. (line 83) 37716 * set exec-done-display: Debugging Output. (line 11) 37717 * set exec-wrapper: Starting. (line 111) 37718 * set extension-language: Show. (line 30) 37719 * set fast tracepoint: Create and Delete Tracepoints. 37720 (line 40) 37721 * set follow-exec-mode: Forks. (line 101) 37722 * set follow-fork-mode: Forks. (line 35) 37723 * set gnutarget: Target Commands. (line 28) 37724 * set hash, for remote monitors: Target Commands. (line 99) 37725 * set height: Screen Size. (line 21) 37726 * set history expansion: Command History. (line 65) 37727 * set history filename: Command History. (line 26) 37728 * set history save: Command History. (line 36) 37729 * set history size: Command History. (line 45) 37730 * set host-charset: Character Sets. (line 33) 37731 * set inferior controlling terminal: Input/Output. (line 44) 37732 * set inferior-tty: Input/Output. (line 49) 37733 * set input-radix: Numbers. (line 14) 37734 * set interactive-mode: Other Misc Settings. (line 6) 37735 * set language: Manually. (line 9) 37736 * set libthread-db-search-path: Threads. (line 177) 37737 * set listsize: List. (line 33) 37738 * set logging: Logging Output. (line 9) 37739 * set mach-exceptions: Darwin. (line 27) 37740 * set max-user-call-depth: Define. (line 76) 37741 * set mem inaccessible-by-default: Memory Region Attributes. 37742 (line 130) 37743 * set mips abi: MIPS. (line 32) 37744 * set mips mask-address: MIPS. (line 61) 37745 * set mipsfpu: MIPS Embedded. (line 60) 37746 * set monitor-prompt, MIPS remote: MIPS Embedded. (line 107) 37747 * set monitor-warnings, MIPS remote: MIPS Embedded. (line 123) 37748 * set multiple-symbols: Ambiguous Expressions. 37749 (line 50) 37750 * set new-console: Cygwin Native. (line 54) 37751 * set new-group: Cygwin Native. (line 63) 37752 * set non-stop: Non-Stop Mode. (line 38) 37753 * set opaque-type-resolution: Symbols. (line 241) 37754 * set osabi: ABI. (line 11) 37755 * set output-radix: Numbers. (line 31) 37756 * set overload-resolution: Debugging C Plus Plus. 37757 (line 48) 37758 * set pagination: Screen Size. (line 38) 37759 * set powerpc: PowerPC Embedded. (line 48) 37760 * set print: Print Settings. (line 11) 37761 * set print frame-arguments: Print Settings. (line 135) 37762 * set print inferior-events: Inferiors and Programs. 37763 (line 117) 37764 * set print symbol-loading: Symbols. (line 259) 37765 * set print thread-events: Threads. (line 156) 37766 * set processor: Targets. (line 31) 37767 * set procfs-file: SVR4 Process Information. 37768 (line 59) 37769 * set procfs-trace: SVR4 Process Information. 37770 (line 53) 37771 * set prompt: Prompt. (line 16) 37772 * set radix: Numbers. (line 44) 37773 * set ravenscar task-switching off: Ravenscar Profile. (line 14) 37774 * set ravenscar task-switching on: Ravenscar Profile. (line 10) 37775 * set rdiheartbeat: ARM. (line 112) 37776 * set rdiromatzero: ARM. (line 102) 37777 * set record insn-number-max: Process Record and Replay. 37778 (line 89) 37779 * set record memory-query: Process Record and Replay. 37780 (line 123) 37781 * set record stop-at-limit: Process Record and Replay. 37782 (line 109) 37783 * set remote: Remote Configuration. 37784 (line 6) 37785 * set remote system-call-allowed: system. (line 38) 37786 * set remote-mips64-transfers-32bit-regs: MIPS. (line 71) 37787 * set remotecache: Caching Remote Data. (line 18) 37788 * set remoteflow: Remote Configuration. 37789 (line 41) 37790 * set retransmit-timeout: MIPS Embedded. (line 83) 37791 * set rstack_high_address: A29K. (line 6) 37792 * set schedule-multiple: All-Stop Mode. (line 66) 37793 * set script-extension: Extending GDB. (line 19) 37794 * set sdstimeout: PowerPC Embedded. (line 84) 37795 * set server-address: M32R/D. (line 27) 37796 * set sh calling-convention: Super-H. (line 12) 37797 * set shell: Cygwin Native. (line 90) 37798 * set signal-thread: Hurd Native. (line 21) 37799 * set signals, Hurd command: Hurd Native. (line 11) 37800 * set sigs, Hurd command: Hurd Native. (line 11) 37801 * set sigthread: Hurd Native. (line 21) 37802 * set solib-absolute-prefix: Files. (line 374) 37803 * set solib-search-path: Files. (line 443) 37804 * set spu: SPU. (line 39) 37805 * set stack-cache: Caching Remote Data. (line 26) 37806 * set static tracepoint: Create and Delete Tracepoints. 37807 (line 51) 37808 * set step-mode: Continuing and Stepping. 37809 (line 92) 37810 * set stop-on-solib-events: Files. (line 351) 37811 * set stopped, Hurd command: Hurd Native. (line 32) 37812 * set struct-convention: i386. (line 7) 37813 * set substitute-path: Source Path. (line 127) 37814 * set symbol-reloading: Symbols. (line 224) 37815 * set syn-garbage-limit, MIPS remote: MIPS Embedded. (line 98) 37816 * set sysroot: Files. (line 374) 37817 * set target-async: Background Execution. 37818 (line 17) 37819 * set target-charset: Character Sets. (line 28) 37820 * set target-file-system-kind (unix|dos-based|auto): Files. (line 457) 37821 * set target-wide-charset: Character Sets. (line 61) 37822 * set task, Hurd commands: Hurd Native. (line 49) 37823 * set tcp: Remote Configuration. 37824 (line 107) 37825 * set tdesc filename: Retrieving Descriptions. 37826 (line 18) 37827 * set thread, Hurd command: Hurd Native. (line 91) 37828 * set timeout: MIPS Embedded. (line 83) 37829 * set trace-commands: Messages/Warnings. (line 67) 37830 * set tracepoint: Create and Delete Tracepoints. 37831 (line 6) 37832 * set trust-readonly-sections: Files. (line 258) 37833 * set tui active-border-mode: TUI Configuration. (line 24) 37834 * set tui border-kind: TUI Configuration. (line 9) 37835 * set tui border-mode: TUI Configuration. (line 23) 37836 * set unwind-on-terminating-exception: Calling. (line 46) 37837 * set unwindonsignal: Calling. (line 35) 37838 * set variable: Assignment. (line 16) 37839 * set verbose: Messages/Warnings. (line 15) 37840 * set watchdog: Maintenance Commands. 37841 (line 357) 37842 * set width: Screen Size. (line 21) 37843 * set write: Patching. (line 15) 37844 * set-mark (C-@): Miscellaneous Commands. 37845 (line 32) 37846 * set_debug_traps: Stub Contents. (line 10) 37847 * set_doc: Parameters In Python. 37848 (line 54) 37849 * setting variables: Assignment. (line 6) 37850 * setting watchpoints: Set Watchpoints. (line 6) 37851 * SH: Remote Stub. (line 63) 37852 * sh-stub.c: Remote Stub. (line 63) 37853 * share: Files. (line 332) 37854 * shared libraries: Files. (line 281) 37855 * shared library events, remote reply: Stop Reply Packets. (line 56) 37856 * sharedlibrary: Files. (line 332) 37857 * shell: Shell Commands. (line 10) 37858 * shell escape: Shell Commands. (line 10) 37859 * show: Help. (line 112) 37860 * show ada trust-PAD-over-XVS: Ada Glitches. (line 43) 37861 * show all convenience functions: Convenience Vars. (line 112) 37862 * show all user variables: Convenience Vars. (line 37) 37863 * show annotate: Annotations Overview. 37864 (line 34) 37865 * show architecture: Targets. (line 21) 37866 * show args: Arguments. (line 28) 37867 * show arm: ARM. (line 22) 37868 * show auto-load-scripts: Auto-loading. (line 26) 37869 * show auto-solib-add: Files. (line 320) 37870 * show backtrace: Backtrace. (line 111) 37871 * show basenames-may-differ: Files. (line 520) 37872 * show board-address: M32R/D. (line 24) 37873 * show breakpoint always-inserted: Set Breaks. (line 314) 37874 * show breakpoint auto-hw: Set Breaks. (line 294) 37875 * show breakpoint pending: Set Breaks. (line 263) 37876 * show can-use-hw-watchpoints: Set Watchpoints. (line 104) 37877 * show case-sensitive: Symbols. (line 40) 37878 * show charset: Character Sets. (line 52) 37879 * show check range: Range Checking. (line 34) 37880 * show check type: Type Checking. (line 42) 37881 * show circular-trace-buffer: Starting and Stopping Trace Experiments. 37882 (line 94) 37883 * show coerce-float-to-double: ABI. (line 50) 37884 * show com1base: DJGPP Native. (line 137) 37885 * show com1irq: DJGPP Native. (line 137) 37886 * show com2base: DJGPP Native. (line 137) 37887 * show com2irq: DJGPP Native. (line 137) 37888 * show com3base: DJGPP Native. (line 137) 37889 * show com3irq: DJGPP Native. (line 137) 37890 * show com4base: DJGPP Native. (line 137) 37891 * show com4irq: DJGPP Native. (line 137) 37892 * show commands: Command History. (line 78) 37893 * show complaints: Messages/Warnings. (line 35) 37894 * show confirm: Messages/Warnings. (line 58) 37895 * show convenience: Convenience Vars. (line 37) 37896 * show copying: Help. (line 136) 37897 * show cp-abi: ABI. (line 53) 37898 * show cygwin-exceptions: Cygwin Native. (line 50) 37899 * show data-directory: Data Files. (line 16) 37900 * show dcache line-size: Caching Remote Data. (line 56) 37901 * show dcache size: Caching Remote Data. (line 52) 37902 * show debug: Debugging Output. (line 22) 37903 * show debug darwin: Darwin. (line 13) 37904 * show debug libthread-db: Threads. (line 212) 37905 * show debug mach-o: Darwin. (line 23) 37906 * show debug mips: MIPS. (line 85) 37907 * show debug monitor: Target Commands. (line 112) 37908 * show debug nto-debug: Neutrino. (line 13) 37909 * show debug-file-directory: Separate Debug Files. 37910 (line 73) 37911 * show default-collect: Tracepoint Actions. (line 123) 37912 * show detach-on-fork: Forks. (line 71) 37913 * show directories: Source Path. (line 124) 37914 * show disassemble-next-line: Machine Code. (line 139) 37915 * show disassembly-flavor: Machine Code. (line 136) 37916 * show disconnected-tracing: Starting and Stopping Trace Experiments. 37917 (line 55) 37918 * show displaced-stepping: Maintenance Commands. 37919 (line 56) 37920 * show download-path: M32R/D. (line 18) 37921 * show editing: Editing. (line 22) 37922 * show environment: Environment. (line 33) 37923 * show exceptions, Hurd command: Hurd Native. (line 46) 37924 * show exec-done-display: Debugging Output. (line 14) 37925 * show follow-fork-mode: Forks. (line 49) 37926 * show gnutarget: Target Commands. (line 40) 37927 * show hash, for remote monitors: Target Commands. (line 105) 37928 * show height: Screen Size. (line 21) 37929 * show history: Command History. (line 70) 37930 * show host-charset: Character Sets. (line 55) 37931 * show inferior-tty: Input/Output. (line 52) 37932 * show input-radix: Numbers. (line 36) 37933 * show interactive-mode: Other Misc Settings. (line 21) 37934 * show language: Show. (line 10) 37935 * show last commands: Command History. (line 78) 37936 * show libthread-db-search-path: Threads. (line 209) 37937 * show listsize: List. (line 37) 37938 * show logging: Logging Output. (line 26) 37939 * show mach-exceptions: Darwin. (line 34) 37940 * show max-user-call-depth: Define. (line 76) 37941 * show mem inaccessible-by-default: Memory Region Attributes. 37942 (line 136) 37943 * show mips abi: MIPS. (line 54) 37944 * show mips mask-address: MIPS. (line 67) 37945 * show mipsfpu: MIPS Embedded. (line 60) 37946 * show monitor-prompt, MIPS remote: MIPS Embedded. (line 119) 37947 * show monitor-warnings, MIPS remote: MIPS Embedded. (line 129) 37948 * show multiple-symbols: Ambiguous Expressions. 37949 (line 70) 37950 * show new-console: Cygwin Native. (line 59) 37951 * show new-group: Cygwin Native. (line 68) 37952 * show non-stop: Non-Stop Mode. (line 42) 37953 * show opaque-type-resolution: Symbols. (line 256) 37954 * show osabi: ABI. (line 11) 37955 * show output-radix: Numbers. (line 39) 37956 * show overload-resolution: Debugging C Plus Plus. 37957 (line 65) 37958 * show pagination: Screen Size. (line 44) 37959 * show paths: Environment. (line 29) 37960 * show print: Print Settings. (line 39) 37961 * show print inferior-events: Inferiors and Programs. 37962 (line 125) 37963 * show print symbol-loading: Symbols. (line 269) 37964 * show print thread-events: Threads. (line 166) 37965 * show processor: Targets. (line 31) 37966 * show procfs-file: SVR4 Process Information. 37967 (line 64) 37968 * show procfs-trace: SVR4 Process Information. 37969 (line 56) 37970 * show prompt: Prompt. (line 19) 37971 * show radix: Numbers. (line 44) 37972 * show ravenscar task-switching: Ravenscar Profile. (line 22) 37973 * show rdiheartbeat: ARM. (line 117) 37974 * show rdiromatzero: ARM. (line 109) 37975 * show record insn-number-max: Process Record and Replay. 37976 (line 106) 37977 * show record memory-query: Process Record and Replay. 37978 (line 134) 37979 * show record stop-at-limit: Process Record and Replay. 37980 (line 120) 37981 * show remote: Remote Configuration. 37982 (line 6) 37983 * show remote system-call-allowed: system. (line 42) 37984 * show remote-mips64-transfers-32bit-regs: MIPS. (line 77) 37985 * show remotecache: Caching Remote Data. (line 23) 37986 * show remoteflow: Remote Configuration. 37987 (line 45) 37988 * show retransmit-timeout: MIPS Embedded. (line 83) 37989 * show rstack_high_address: A29K. (line 17) 37990 * show script-extension: Extending GDB. (line 19) 37991 * show sdstimeout: PowerPC Embedded. (line 88) 37992 * show server-address: M32R/D. (line 31) 37993 * show sh calling-convention: Super-H. (line 25) 37994 * show shell: Cygwin Native. (line 94) 37995 * show signal-thread: Hurd Native. (line 28) 37996 * show signals, Hurd command: Hurd Native. (line 17) 37997 * show sigs, Hurd command: Hurd Native. (line 17) 37998 * show sigthread: Hurd Native. (line 28) 37999 * show solib-search-path: Files. (line 454) 38000 * show spu: SPU. (line 44) 38001 * show stack-cache: Caching Remote Data. (line 31) 38002 * show stop-on-solib-events: Files. (line 357) 38003 * show stopped, Hurd command: Hurd Native. (line 37) 38004 * show struct-convention: i386. (line 15) 38005 * show substitute-path: Source Path. (line 164) 38006 * show symbol-reloading: Symbols. (line 238) 38007 * show syn-garbage-limit, MIPS remote: MIPS Embedded. (line 103) 38008 * show sysroot: Files. (line 440) 38009 * show target-async: Background Execution. 38010 (line 21) 38011 * show target-charset: Character Sets. (line 58) 38012 * show target-file-system-kind: Files. (line 457) 38013 * show target-wide-charset: Character Sets. (line 67) 38014 * show task, Hurd commands: Hurd Native. (line 57) 38015 * show tcp: Remote Configuration. 38016 (line 107) 38017 * show tdesc filename: Retrieving Descriptions. 38018 (line 25) 38019 * show thread, Hurd command: Hurd Native. (line 101) 38020 * show timeout: MIPS Embedded. (line 83) 38021 * show unwind-on-terminating-exception: Calling. (line 54) 38022 * show unwindonsignal: Calling. (line 42) 38023 * show user: Define. (line 70) 38024 * show values: Value History. (line 47) 38025 * show verbose: Messages/Warnings. (line 21) 38026 * show version: Help. (line 126) 38027 * show warranty: Help. (line 140) 38028 * show width: Screen Size. (line 21) 38029 * show write: Patching. (line 26) 38030 * show-all-if-ambiguous: Readline Init File Syntax. 38031 (line 164) 38032 * show-all-if-unmodified: Readline Init File Syntax. 38033 (line 170) 38034 * show_doc: Parameters In Python. 38035 (line 60) 38036 * si (stepi): Continuing and Stepping. 38037 (line 190) 38038 * signal: Signaling. (line 6) 38039 * signal annotation: Annotations for Running. 38040 (line 42) 38041 * signal-name annotation: Annotations for Running. 38042 (line 22) 38043 * signal-name-end annotation: Annotations for Running. 38044 (line 22) 38045 * signal-string annotation: Annotations for Running. 38046 (line 22) 38047 * signal-string-end annotation: Annotations for Running. 38048 (line 22) 38049 * signalled annotation: Annotations for Running. 38050 (line 22) 38051 * signals: Signals. (line 6) 38052 * SIGQUIT signal, dump core of GDB: Maintenance Commands. 38053 (line 99) 38054 * silent <1>: Breakpoints In Python. 38055 (line 79) 38056 * silent: Break Commands. (line 43) 38057 * sim: Z8000. (line 15) 38058 * sim, a command: Embedded Processors. (line 13) 38059 * simulator, Z8000: Z8000. (line 6) 38060 * size of remote memory accesses: Packets. (line 228) 38061 * size of screen: Screen Size. (line 6) 38062 * sizeof: Types In Python. (line 28) 38063 * snapshot of a process: Checkpoint/Restart. (line 6) 38064 * software watchpoints: Set Watchpoints. (line 31) 38065 * solib_name: Basic Python. (line 154) 38066 * source: Command Files. (line 17) 38067 * source annotation: Source Annotations. (line 6) 38068 * source file and line of a symbol: Print Settings. (line 51) 38069 * source line and its code address: Machine Code. (line 6) 38070 * source path: Source Path. (line 6) 38071 * Sparc: Remote Stub. (line 66) 38072 * sparc-stub.c: Remote Stub. (line 66) 38073 * sparcl-stub.c: Remote Stub. (line 69) 38074 * Sparclet: Sparclet. (line 6) 38075 * SparcLite: Remote Stub. (line 69) 38076 * Special Fortran commands: Special Fortran Commands. 38077 (line 6) 38078 * specifying location: Specify Location. (line 6) 38079 * spr: OpenRISC 1000. (line 33) 38080 * SPU: SPU. (line 6) 38081 * SSE registers (x86): Registers. (line 71) 38082 * stack frame: Frames. (line 6) 38083 * stack on Alpha: MIPS. (line 6) 38084 * stack on MIPS: MIPS. (line 6) 38085 * stack pointer register: Registers. (line 26) 38086 * stacking targets: Active Targets. (line 6) 38087 * standard registers: Registers. (line 26) 38088 * start <1>: Blocks In Python. (line 36) 38089 * start: Starting. (line 78) 38090 * start a new trace experiment: Starting and Stopping Trace Experiments. 38091 (line 6) 38092 * start-kbd-macro (C-x (): Keyboard Macros. (line 6) 38093 * starting: Starting. (line 6) 38094 * starting annotation: Annotations for Running. 38095 (line 6) 38096 * startup code, and backtrace: Backtrace. (line 93) 38097 * stat, file-i/o system call: stat/fstat. (line 6) 38098 * static members of C++ objects: Print Settings. (line 342) 38099 * static members of Pascal objects: Print Settings. (line 353) 38100 * static tracepoints: Set Tracepoints. (line 28) 38101 * static tracepoints, in remote protocol: General Query Packets. 38102 (line 563) 38103 * static tracepoints, setting: Create and Delete Tracepoints. 38104 (line 51) 38105 * status of trace data collection: Starting and Stopping Trace Experiments. 38106 (line 20) 38107 * status output in GDB/MI: GDB/MI Output Syntax. 38108 (line 94) 38109 * STDERR: Basic Python. (line 111) 38110 * STDLOG: Basic Python. (line 114) 38111 * STDOUT: Basic Python. (line 108) 38112 * step: Continuing and Stepping. 38113 (line 46) 38114 * step&: Background Execution. 38115 (line 41) 38116 * stepi: Continuing and Stepping. 38117 (line 190) 38118 * stepi&: Background Execution. 38119 (line 44) 38120 * stepping: Continuing and Stepping. 38121 (line 6) 38122 * stepping into functions with no line info: Continuing and Stepping. 38123 (line 93) 38124 * stop a running trace experiment: Starting and Stopping Trace Experiments. 38125 (line 12) 38126 * stop on C++ exceptions: Set Catchpoints. (line 13) 38127 * stop on gdb.Breakpoint: Breakpoints In Python. 38128 (line 25) 38129 * stop reply packets: Stop Reply Packets. (line 6) 38130 * stop, a pseudo-command: Hooks. (line 21) 38131 * stop_signal: Events In Python. (line 91) 38132 * stopped threads: Thread Stops. (line 6) 38133 * stopping annotation: Annotations for Running. 38134 (line 6) 38135 * strace: Create and Delete Tracepoints. 38136 (line 51) 38137 * stream records in GDB/MI: GDB/MI Stream Records. 38138 (line 6) 38139 * string on Value: Values From Inferior. 38140 (line 139) 38141 * strip_typedefs on Type: Types In Python. (line 118) 38142 * struct return convention: i386. (line 7) 38143 * struct stat, in file-i/o protocol: struct stat. (line 6) 38144 * struct timeval, in file-i/o protocol: struct timeval. (line 6) 38145 * struct user contents: OS Information. (line 9) 38146 * struct/union returned in registers: i386. (line 7) 38147 * structure field name completion: Completion. (line 96) 38148 * stub example, remote debugging: Remote Stub. (line 6) 38149 * stupid questions: Messages/Warnings. (line 50) 38150 * Super-H: Super-H. (line 6) 38151 * superblock: Blocks In Python. (line 48) 38152 * supported packets, remote query: General Query Packets. 38153 (line 328) 38154 * switch on InferiorThread: Threads In Python. (line 51) 38155 * switching threads: Threads. (line 6) 38156 * switching threads automatically: All-Stop Mode. (line 28) 38157 * symbol decoding style, C++: Print Settings. (line 296) 38158 * symbol dump: Symbols. (line 272) 38159 * symbol from address: Symbols. (line 54) 38160 * symbol lookup, remote request: General Query Packets. 38161 (line 567) 38162 * symbol names: Symbols. (line 14) 38163 * symbol table: Files. (line 6) 38164 * symbol tables in python: Symbol Tables In Python. 38165 (line 6) 38166 * symbol tables, listing GDB's internal: Symbols. (line 291) 38167 * symbol, source file and line: Print Settings. (line 51) 38168 * symbol-file: Files. (line 45) 38169 * SYMBOL_FUNCTIONS_DOMAIN: Symbols In Python. (line 117) 38170 * SYMBOL_LABEL_DOMAIN: Symbols In Python. (line 110) 38171 * SYMBOL_LOC_ARG: Symbols In Python. (line 139) 38172 * SYMBOL_LOC_BLOCK: Symbols In Python. (line 160) 38173 * SYMBOL_LOC_COMPUTED: Symbols In Python. (line 174) 38174 * SYMBOL_LOC_CONST: Symbols In Python. (line 130) 38175 * SYMBOL_LOC_CONST_BYTES: Symbols In Python. (line 163) 38176 * SYMBOL_LOC_LOCAL: Symbols In Python. (line 153) 38177 * SYMBOL_LOC_OPTIMIZED_OUT: Symbols In Python. (line 171) 38178 * SYMBOL_LOC_REF_ARG: Symbols In Python. (line 143) 38179 * SYMBOL_LOC_REGISTER: Symbols In Python. (line 136) 38180 * SYMBOL_LOC_REGPARM_ADDR: Symbols In Python. (line 148) 38181 * SYMBOL_LOC_STATIC: Symbols In Python. (line 133) 38182 * SYMBOL_LOC_TYPEDEF: Symbols In Python. (line 156) 38183 * SYMBOL_LOC_UNDEF: Symbols In Python. (line 128) 38184 * SYMBOL_LOC_UNRESOLVED: Symbols In Python. (line 166) 38185 * SYMBOL_STRUCT_DOMAIN: Symbols In Python. (line 107) 38186 * SYMBOL_TYPES_DOMAIN: Symbols In Python. (line 120) 38187 * SYMBOL_UNDEF_DOMAIN: Symbols In Python. (line 100) 38188 * SYMBOL_VAR_DOMAIN: Symbols In Python. (line 103) 38189 * SYMBOL_VARIABLES_DOMAIN: Symbols In Python. (line 113) 38190 * symbols in python: Symbols In Python. (line 6) 38191 * symbols, reading from relocatable object files: Files. (line 132) 38192 * symbols, reading immediately: Files. (line 90) 38193 * symtab <1>: Symbol Tables In Python. 38194 (line 17) 38195 * symtab: Symbols In Python. (line 53) 38196 * synchronize with remote MIPS target: MIPS Embedded. (line 98) 38197 * syscall DSO: Files. (line 162) 38198 * sysinfo: DJGPP Native. (line 19) 38199 * system calls and thread breakpoints: Interrupted System Calls. 38200 (line 6) 38201 * system root, alternate: Files. (line 374) 38202 * system, file-i/o system call: system. (line 6) 38203 * system-wide init file: System-wide configuration. 38204 (line 6) 38205 * T packet: Packets. (line 316) 38206 * t packet: Packets. (line 311) 38207 * T packet reply: Stop Reply Packets. (line 22) 38208 * tabset: TUI Commands. (line 84) 38209 * tag: Types In Python. (line 33) 38210 * target: Target Commands. (line 49) 38211 * target architecture: Targets. (line 17) 38212 * target array: MIPS Embedded. (line 49) 38213 * target byte order: Byte Order. (line 6) 38214 * target character set: Character Sets. (line 6) 38215 * target dbug: M68K. (line 9) 38216 * target ddb PORT: MIPS Embedded. (line 41) 38217 * target debugging info: Debugging Output. (line 165) 38218 * target descriptions: Target Descriptions. (line 6) 38219 * target descriptions, ARM features: ARM Features. (line 6) 38220 * target descriptions, i386 features: i386 Features. (line 6) 38221 * target descriptions, inclusion: Target Description Format. 38222 (line 54) 38223 * target descriptions, M68K features: M68K Features. (line 6) 38224 * target descriptions, MIPS features: MIPS Features. (line 6) 38225 * target descriptions, PowerPC features: PowerPC Features. (line 6) 38226 * target descriptions, predefined types: Predefined Target Types. 38227 (line 6) 38228 * target descriptions, standard features: Standard Target Features. 38229 (line 6) 38230 * target descriptions, XML format: Target Description Format. 38231 (line 6) 38232 * target dink32: PowerPC Embedded. (line 69) 38233 * target jtag: OpenRISC 1000. (line 9) 38234 * target lsi PORT: MIPS Embedded. (line 44) 38235 * target m32r: M32R/D. (line 6) 38236 * target m32rsdi: M32R/D. (line 9) 38237 * target mips PORT: MIPS Embedded. (line 14) 38238 * target on Type: Types In Python. (line 122) 38239 * target op50n: PA. (line 6) 38240 * target output in GDB/MI: GDB/MI Output Syntax. 38241 (line 110) 38242 * target pmon PORT: MIPS Embedded. (line 38) 38243 * target ppcbug: PowerPC Embedded. (line 72) 38244 * target ppcbug1: PowerPC Embedded. (line 73) 38245 * target r3900: MIPS Embedded. (line 46) 38246 * target rdi: ARM. (line 6) 38247 * target rdp: ARM. (line 11) 38248 * target record: Process Record and Replay. 38249 (line 38) 38250 * target remote: Connecting. (line 11) 38251 * target sds: PowerPC Embedded. (line 77) 38252 * target sim, with Z8000: Z8000. (line 15) 38253 * target sparclite: Sparclite. (line 6) 38254 * target stack description: Maintenance Commands. 38255 (line 236) 38256 * target tfile: Trace Files. (line 22) 38257 * target vxworks: VxWorks. (line 6) 38258 * target w89k: PA. (line 9) 38259 * target_charset: Basic Python. (line 143) 38260 * target_wide_charset: Basic Python. (line 148) 38261 * task: Breakpoints In Python. 38262 (line 92) 38263 * task (Ada): Ada Tasks. (line 105) 38264 * task attributes (GNU Hurd): Hurd Native. (line 49) 38265 * task breakpoints, in Ada: Ada Tasks. (line 135) 38266 * task exception port, GNU Hurd: Hurd Native. (line 68) 38267 * task suspend count: Hurd Native. (line 60) 38268 * task switching with program using Ravenscar Profile: Ravenscar Profile. 38269 (line 10) 38270 * tbreak: Set Breaks. (line 55) 38271 * TCP port, target remote: Connecting. (line 29) 38272 * tdump: tdump. (line 6) 38273 * template_argument on Type: Types In Python. (line 137) 38274 * terminal: Input/Output. (line 6) 38275 * teval (tracepoints): Tracepoint Actions. (line 89) 38276 * Text User Interface: TUI. (line 6) 38277 * tfile: Trace Files. (line 22) 38278 * tfind: tfind. (line 6) 38279 * thbreak: Set Breaks. (line 82) 38280 * this, inside C++ member functions: C Plus Plus Expressions. 38281 (line 22) 38282 * thread: Breakpoints In Python. 38283 (line 87) 38284 * thread apply: Threads. (line 122) 38285 * thread attributes info, remote request: General Query Packets. 38286 (line 612) 38287 * thread breakpoints: Thread-Specific Breakpoints. 38288 (line 10) 38289 * thread breakpoints and system calls: Interrupted System Calls. 38290 (line 6) 38291 * thread default settings, GNU Hurd: Hurd Native. (line 131) 38292 * thread find: Threads. (line 142) 38293 * thread identifier (GDB): Threads. (line 63) 38294 * thread identifier (system): Threads. (line 51) 38295 * thread info (Solaris): Threads. (line 98) 38296 * thread information, remote request: General Query Packets. 38297 (line 209) 38298 * thread list format: Thread List Format. (line 6) 38299 * thread name: Threads. (line 131) 38300 * thread number: Threads. (line 63) 38301 * thread properties, GNU Hurd: Hurd Native. (line 91) 38302 * thread suspend count, GNU Hurd: Hurd Native. (line 110) 38303 * thread THREADNO: Threads. (line 100) 38304 * THREAD-ID, in remote protocol: Packets. (line 20) 38305 * threads and watchpoints: Set Watchpoints. (line 165) 38306 * threads in python: Threads In Python. (line 6) 38307 * threads of execution: Threads. (line 6) 38308 * threads on Inferior: Inferiors In Python. (line 40) 38309 * threads, automatic switching: All-Stop Mode. (line 28) 38310 * threads, continuing: Thread Stops. (line 6) 38311 * threads, stopped: Thread Stops. (line 6) 38312 * time of command execution: Maintenance Commands. 38313 (line 328) 38314 * timeout for commands: Maintenance Commands. 38315 (line 357) 38316 * timeout for serial communications: Remote Configuration. 38317 (line 65) 38318 * timeout, for remote target connection: Remote Configuration. 38319 (line 123) 38320 * timeout, MIPS protocol: MIPS Embedded. (line 83) 38321 * timestampping debugging info: Debugging Output. (line 176) 38322 * tload, M32R: M32R/D. (line 39) 38323 * to_string on pretty printer: Pretty Printing API. (line 54) 38324 * trace: Create and Delete Tracepoints. 38325 (line 6) 38326 * trace experiment, status of: Starting and Stopping Trace Experiments. 38327 (line 20) 38328 * trace file format: Trace File Format. (line 6) 38329 * trace files: Trace Files. (line 6) 38330 * trace state variable value, remote request: Tracepoint Packets. 38331 (line 276) 38332 * trace state variables: Trace State Variables. 38333 (line 6) 38334 * traceback: Backtrace. (line 6) 38335 * traceframe info format: Traceframe Info Format. 38336 (line 6) 38337 * tracepoint actions: Tracepoint Actions. (line 6) 38338 * tracepoint conditions: Tracepoint Conditions. 38339 (line 6) 38340 * tracepoint data, display: tdump. (line 6) 38341 * tracepoint deletion: Create and Delete Tracepoints. 38342 (line 101) 38343 * tracepoint number: Create and Delete Tracepoints. 38344 (line 98) 38345 * tracepoint packets: Tracepoint Packets. (line 6) 38346 * tracepoint pass count: Tracepoint Passcounts. 38347 (line 6) 38348 * tracepoint restrictions: Tracepoint Restrictions. 38349 (line 6) 38350 * tracepoint variables: Tracepoint Variables. 38351 (line 6) 38352 * tracepoints: Tracepoints. (line 6) 38353 * tracepoints support in gdbserver: Server. (line 207) 38354 * trailing underscore, in Fortran symbols: Fortran. (line 9) 38355 * translating between character sets: Character Sets. (line 6) 38356 * transpose-chars (C-t): Commands For Text. (line 30) 38357 * transpose-words (M-t): Commands For Text. (line 36) 38358 * tsave: Trace Files. (line 12) 38359 * tstart: Starting and Stopping Trace Experiments. 38360 (line 6) 38361 * tstatus: Starting and Stopping Trace Experiments. 38362 (line 20) 38363 * tstop: Starting and Stopping Trace Experiments. 38364 (line 12) 38365 * tty: Input/Output. (line 23) 38366 * TUI: TUI. (line 6) 38367 * TUI commands: TUI Commands. (line 6) 38368 * TUI configuration variables: TUI Configuration. (line 6) 38369 * TUI key bindings: TUI Keys. (line 6) 38370 * tui reg: TUI Commands. (line 61) 38371 * TUI single key mode: TUI Single Key Mode. (line 6) 38372 * tvariable: Trace State Variables. 38373 (line 26) 38374 * type <1>: Lazy Strings In Python. 38375 (line 44) 38376 * type <2>: Breakpoints In Python. 38377 (line 107) 38378 * type <3>: Symbols In Python. (line 48) 38379 * type: Values From Inferior. 38380 (line 55) 38381 * type casting memory: Expressions. (line 43) 38382 * type chain of a data type: Maintenance Commands. 38383 (line 248) 38384 * type checking: Checks. (line 31) 38385 * type conversions in C++: C Plus Plus Expressions. 38386 (line 27) 38387 * type on Frame: Frames In Python. (line 48) 38388 * TYPE_CODE_ARRAY: Types In Python. (line 155) 38389 * TYPE_CODE_BITSTRING: Types In Python. (line 193) 38390 * TYPE_CODE_BOOL: Types In Python. (line 214) 38391 * TYPE_CODE_CHAR: Types In Python. (line 211) 38392 * TYPE_CODE_COMPLEX: Types In Python. (line 217) 38393 * TYPE_CODE_DECFLOAT: Types In Python. (line 226) 38394 * TYPE_CODE_ENUM: Types In Python. (line 164) 38395 * TYPE_CODE_ERROR: Types In Python. (line 196) 38396 * TYPE_CODE_FLAGS: Types In Python. (line 167) 38397 * TYPE_CODE_FLT: Types In Python. (line 176) 38398 * TYPE_CODE_FUNC: Types In Python. (line 170) 38399 * TYPE_CODE_INT: Types In Python. (line 173) 38400 * TYPE_CODE_INTERNAL_FUNCTION: Types In Python. (line 229) 38401 * TYPE_CODE_MEMBERPTR: Types In Python. (line 205) 38402 * TYPE_CODE_METHOD: Types In Python. (line 199) 38403 * TYPE_CODE_METHODPTR: Types In Python. (line 202) 38404 * TYPE_CODE_NAMESPACE: Types In Python. (line 223) 38405 * TYPE_CODE_PTR: Types In Python. (line 152) 38406 * TYPE_CODE_RANGE: Types In Python. (line 185) 38407 * TYPE_CODE_REF: Types In Python. (line 208) 38408 * TYPE_CODE_SET: Types In Python. (line 182) 38409 * TYPE_CODE_STRING: Types In Python. (line 188) 38410 * TYPE_CODE_STRUCT: Types In Python. (line 158) 38411 * TYPE_CODE_TYPEDEF: Types In Python. (line 220) 38412 * TYPE_CODE_UNION: Types In Python. (line 161) 38413 * TYPE_CODE_VOID: Types In Python. (line 179) 38414 * types in Python: Types In Python. (line 6) 38415 * u (SingleKey TUI key): TUI Single Key Mode. (line 31) 38416 * u (until): Continuing and Stepping. 38417 (line 118) 38418 * UDP port, target remote: Connecting. (line 49) 38419 * undisplay: Auto Display. (line 45) 38420 * undo (C-_ or C-x C-u): Miscellaneous Commands. 38421 (line 22) 38422 * union field name completion: Completion. (line 96) 38423 * unions in structures, printing: Print Settings. (line 236) 38424 * universal-argument (): Numeric Arguments. (line 10) 38425 * unix-filename-rubout (): Commands For Killing. 38426 (line 32) 38427 * unix-line-discard (C-u): Commands For Killing. 38428 (line 12) 38429 * unix-word-rubout (C-w): Commands For Killing. 38430 (line 28) 38431 * unknown address, locating: Output Formats. (line 35) 38432 * unlink, file-i/o system call: unlink. (line 6) 38433 * unlinked object files: Files. (line 26) 38434 * unload symbols from shared libraries: Files. (line 341) 38435 * unmap an overlay: Overlay Commands. (line 39) 38436 * unmapped overlays: How Overlays Work. (line 6) 38437 * unqualified on Type: Types In Python. (line 99) 38438 * unset environment: Environment. (line 55) 38439 * unset substitute-path: Source Path. (line 156) 38440 * unset tdesc filename: Retrieving Descriptions. 38441 (line 21) 38442 * unsupported languages: Unsupported Languages. 38443 (line 6) 38444 * until: Continuing and Stepping. 38445 (line 118) 38446 * until&: Background Execution. 38447 (line 59) 38448 * unwind stack in called functions: Calling. (line 35) 38449 * unwind stack in called functions with unhandled exceptions: Calling. 38450 (line 46) 38451 * unwind_stop_reason on Frame: Frames In Python. (line 74) 38452 * Up: TUI Keys. (line 53) 38453 * up: Selection. (line 35) 38454 * up-silently: Selection. (line 64) 38455 * upcase-word (M-u): Commands For Text. (line 41) 38456 * update: TUI Commands. (line 76) 38457 * upload, M32R: M32R/D. (line 34) 38458 * use only software watchpoints: Set Watchpoints. (line 93) 38459 * use_dbt_break: M32R/D. (line 64) 38460 * use_debug_dma: M32R/D. (line 53) 38461 * use_ib_break: M32R/D. (line 61) 38462 * use_mon_code: M32R/D. (line 57) 38463 * user-defined command: Define. (line 6) 38464 * user-defined macros: Macros. (line 52) 38465 * user-defined variables: Convenience Vars. (line 6) 38466 * v (SingleKey TUI key): TUI Single Key Mode. (line 34) 38467 * value: Parameters In Python. 38468 (line 66) 38469 * value history: Value History. (line 6) 38470 * value on LazyString: Lazy Strings In Python. 38471 (line 21) 38472 * values from inferior, with Python: Values From Inferior. 38473 (line 6) 38474 * variable name conflict: Variables. (line 36) 38475 * variable object debugging info: Debugging Output. (line 185) 38476 * variable objects in GDB/MI: GDB/MI Variable Objects. 38477 (line 9) 38478 * variable values, wrong: Variables. (line 58) 38479 * variables, readline: Readline Init File Syntax. 38480 (line 34) 38481 * variables, setting: Assignment. (line 16) 38482 * vAttach packet: Packets. (line 331) 38483 * vCont packet: Packets. (line 351) 38484 * vCont? packet: Packets. (line 393) 38485 * vector unit: Vector Unit. (line 6) 38486 * vector, auxiliary: OS Information. (line 21) 38487 * verbose operation: Messages/Warnings. (line 6) 38488 * verify remote memory image: Memory. (line 123) 38489 * vFile packet: Packets. (line 404) 38490 * vFlashDone packet: Packets. (line 452) 38491 * vFlashErase packet: Packets. (line 408) 38492 * vFlashWrite packet: Packets. (line 430) 38493 * virtual functions (C++) display: Print Settings. (line 364) 38494 * visible: Breakpoints In Python. 38495 (line 112) 38496 * visible-stats: Readline Init File Syntax. 38497 (line 179) 38498 * vKill packet: Packets. (line 460) 38499 * volatile on Type: Types In Python. (line 95) 38500 * vRun packet: Packets. (line 473) 38501 * vStopped packet: Packets. (line 490) 38502 * VTBL display: Print Settings. (line 364) 38503 * VxWorks: VxWorks. (line 6) 38504 * vxworks-timeout: VxWorks. (line 23) 38505 * w (SingleKey TUI key): TUI Single Key Mode. (line 37) 38506 * was_attached: Inferiors In Python. (line 27) 38507 * watch: Set Watchpoints. (line 42) 38508 * watchdog timer: Maintenance Commands. 38509 (line 357) 38510 * watchpoint annotation: Annotations for Running. 38511 (line 50) 38512 * watchpoints: Breakpoints. (line 20) 38513 * watchpoints and threads: Set Watchpoints. (line 165) 38514 * weak alias functions: Calling. (line 58) 38515 * whatis: Symbols. (line 74) 38516 * where: Backtrace. (line 34) 38517 * where to look for shared libraries: Files. (line 369) 38518 * while: Command Files. (line 86) 38519 * while-stepping (tracepoints): Tracepoint Actions. (line 97) 38520 * wild pointer, interpreting: Print Settings. (line 79) 38521 * winheight: TUI Commands. (line 80) 38522 * word completion: Completion. (line 6) 38523 * working directory: Source Path. (line 108) 38524 * working directory (of your program): Working Directory. (line 6) 38525 * working language: Languages. (line 13) 38526 * WP_ACCESS: Breakpoints In Python. 38527 (line 58) 38528 * WP_READ: Breakpoints In Python. 38529 (line 52) 38530 * WP_WRITE: Breakpoints In Python. 38531 (line 55) 38532 * write: Basic Python. (line 104) 38533 * write data into object, remote request: General Query Packets. 38534 (line 781) 38535 * write, file-i/o system call: write. (line 6) 38536 * write_memory on Inferior: Inferiors In Python. (line 51) 38537 * writing a pretty-printer: Writing a Pretty-Printer. 38538 (line 6) 38539 * writing convenience functions: Functions In Python. (line 6) 38540 * writing into corefiles: Patching. (line 6) 38541 * writing into executables: Patching. (line 6) 38542 * wrong values: Variables. (line 58) 38543 * x (examine memory): Memory. (line 9) 38544 * x command, default address: Machine Code. (line 30) 38545 * X packet: Packets. (line 502) 38546 * x(examine), and info line: Machine Code. (line 30) 38547 * Xilinx MicroBlaze: MicroBlaze. (line 6) 38548 * XInclude: Target Description Format. 38549 (line 54) 38550 * XMD, Xilinx Microprocessor Debugger: MicroBlaze. (line 6) 38551 * XML parser debugging: Debugging Output. (line 193) 38552 * yank (C-y): Commands For Killing. 38553 (line 59) 38554 * yank-last-arg (M-. or M-_): Commands For History. 38555 (line 64) 38556 * yank-nth-arg (M-C-y): Commands For History. 38557 (line 55) 38558 * yank-pop (M-y): Commands For Killing. 38559 (line 62) 38560 * yanking text: Readline Killing Commands. 38561 (line 6) 38562 * z packet: Packets. (line 515) 38563 * Z packets: Packets. (line 515) 38564 * Z0 packet: Packets. (line 530) 38565 * z0 packet: Packets. (line 530) 38566 * Z1 packet: Packets. (line 558) 38567 * z1 packet: Packets. (line 558) 38568 * Z2 packet: Packets. (line 580) 38569 * z2 packet: Packets. (line 580) 38570 * Z3 packet: Packets. (line 595) 38571 * z3 packet: Packets. (line 595) 38572 * Z4 packet: Packets. (line 610) 38573 * z4 packet: Packets. (line 610) 38574 * Z8000: Z8000. (line 6) 38575 * Zilog Z8000 simulator: Z8000. (line 6) 38576 * {TYPE}: Expressions. (line 43) 38577 38578 38579 38580 Tag Table: 38581 Node: Top1946 38582 Node: Summary5124 38583 Node: Free Software6926 38584 Node: Contributors12494 38585 Node: Sample Session20583 38586 Node: Invocation27425 38587 Node: Invoking GDB27969 38588 Node: File Options30282 38589 Node: Mode Options33019 38590 Node: Startup40131 38591 Ref: Startup-Footnote-142910 38592 Node: Quitting GDB43019 38593 Node: Shell Commands43916 38594 Node: Logging Output44758 38595 Node: Commands45604 38596 Node: Command Syntax46242 38597 Node: Completion48408 38598 Ref: Completion-Footnote-153614 38599 Node: Help53774 38600 Node: Running59015 38601 Node: Compilation60244 38602 Node: Starting62221 38603 Node: Arguments71111 38604 Node: Environment72381 38605 Node: Working Directory75649 38606 Node: Input/Output76757 38607 Node: Attach78728 38608 Node: Kill Process81195 38609 Node: Inferiors and Programs82176 38610 Node: Threads89421 38611 Node: Forks98584 38612 Node: Checkpoint/Restart104894 38613 Ref: Checkpoint/Restart-Footnote-1109423 38614 Node: Stopping109458 38615 Node: Breakpoints110617 38616 Node: Set Breaks114053 38617 Ref: Set Breaks-Footnote-1130365 38618 Node: Set Watchpoints130613 38619 Node: Set Catchpoints139142 38620 Node: Delete Breaks148338 38621 Node: Disabling150274 38622 Node: Conditions153127 38623 Node: Break Commands158076 38624 Node: Save Breakpoints161300 38625 Node: Error in Breakpoints162476 38626 Node: Breakpoint-related Warnings163207 38627 Node: Continuing and Stepping165534 38628 Node: Signals174894 38629 Ref: extra signal information179166 38630 Node: Thread Stops180669 38631 Node: All-Stop Mode181768 38632 Node: Non-Stop Mode185666 38633 Node: Background Execution189143 38634 Node: Thread-Specific Breakpoints191712 38635 Node: Interrupted System Calls193034 38636 Node: Observer Mode194548 38637 Node: Reverse Execution197987 38638 Ref: Reverse Execution-Footnote-1202614 38639 Ref: Reverse Execution-Footnote-2203241 38640 Node: Process Record and Replay203291 38641 Node: Stack210538 38642 Node: Frames212031 38643 Node: Backtrace214783 38644 Ref: Backtrace-Footnote-1219996 38645 Node: Selection220184 38646 Node: Frame Info223048 38647 Node: Source225379 38648 Node: List226445 38649 Node: Specify Location229058 38650 Node: Edit232704 38651 Ref: Edit-Footnote-1234179 38652 Node: Search234414 38653 Node: Source Path235222 38654 Ref: set substitute-path241589 38655 Node: Machine Code243810 38656 Node: Data250484 38657 Node: Expressions253154 38658 Node: Ambiguous Expressions255246 38659 Node: Variables258480 38660 Node: Arrays262983 38661 Node: Output Formats265514 38662 Ref: Output Formats-Footnote-1268702 38663 Node: Memory268859 38664 Node: Auto Display275013 38665 Node: Print Settings279555 38666 Node: Pretty Printing293159 38667 Node: Pretty-Printer Introduction293672 38668 Node: Pretty-Printer Example295427 38669 Node: Pretty-Printer Commands296205 38670 Node: Value History298629 38671 Node: Convenience Vars301050 38672 Node: Registers305785 38673 Ref: Registers-Footnote-1310462 38674 Node: Floating Point Hardware310857 38675 Node: Vector Unit311389 38676 Node: OS Information311776 38677 Node: Memory Region Attributes314421 38678 Node: Dump/Restore Files319091 38679 Node: Core File Generation321396 38680 Node: Character Sets322630 38681 Node: Caching Remote Data328995 38682 Ref: Caching Remote Data-Footnote-1331260 38683 Node: Searching Memory331498 38684 Node: Optimized Code334375 38685 Node: Inline Functions335985 38686 Node: Macros338955 38687 Node: Tracepoints346058 38688 Node: Set Tracepoints348119 38689 Node: Create and Delete Tracepoints351057 38690 Node: Enable and Disable Tracepoints355945 38691 Node: Tracepoint Passcounts356729 38692 Node: Tracepoint Conditions358156 38693 Node: Trace State Variables359850 38694 Node: Tracepoint Actions362040 38695 Node: Listing Tracepoints367380 38696 Node: Listing Static Tracepoint Markers368501 38697 Node: Starting and Stopping Trace Experiments370347 38698 Node: Tracepoint Restrictions374761 38699 Node: Analyze Collected Data378514 38700 Node: tfind379819 38701 Node: tdump384241 38702 Node: save tracepoints386756 38703 Node: Tracepoint Variables387252 38704 Node: Trace Files388380 38705 Node: Overlays389838 38706 Node: How Overlays Work390558 38707 Ref: A code overlay393118 38708 Node: Overlay Commands396556 38709 Node: Automatic Overlay Debugging400746 38710 Node: Overlay Sample Program402887 38711 Node: Languages404647 38712 Node: Setting405810 38713 Node: Filenames407512 38714 Node: Manually408323 38715 Node: Automatically409532 38716 Node: Show410593 38717 Node: Checks411915 38718 Node: Type Checking413305 38719 Node: Range Checking416038 38720 Node: Supported Languages418439 38721 Node: C419700 38722 Node: C Operators420991 38723 Node: C Constants425310 38724 Node: C Plus Plus Expressions427714 38725 Node: C Defaults431257 38726 Node: C Checks431940 38727 Node: Debugging C432663 38728 Node: Debugging C Plus Plus433147 38729 Node: Decimal Floating Point436334 38730 Node: D437593 38731 Node: Objective-C437859 38732 Node: Method Names in Commands438321 38733 Node: The Print Command with Objective-C440016 38734 Node: OpenCL C440667 38735 Node: OpenCL C Datatypes440942 38736 Node: OpenCL C Expressions441317 38737 Node: OpenCL C Operators441674 38738 Node: Fortran441906 38739 Node: Fortran Operators442628 38740 Node: Fortran Defaults443484 38741 Node: Special Fortran Commands443869 38742 Node: Pascal444375 38743 Node: Modula-2444890 38744 Node: M2 Operators445865 38745 Node: Built-In Func/Proc448864 38746 Node: M2 Constants451725 38747 Node: M2 Types453326 38748 Node: M2 Defaults456545 38749 Node: Deviations457145 38750 Node: M2 Checks458246 38751 Node: M2 Scope459064 38752 Node: GDB/M2460088 38753 Node: Ada461000 38754 Node: Ada Mode Intro462063 38755 Node: Omissions from Ada463973 38756 Node: Additions to Ada468327 38757 Node: Stopping Before Main Program472257 38758 Node: Ada Tasks472786 38759 Node: Ada Tasks and Core Files479199 38760 Node: Ravenscar Profile480117 38761 Node: Ada Glitches481187 38762 Node: Unsupported Languages483981 38763 Node: Symbols484671 38764 Node: Altering499069 38765 Node: Assignment500038 38766 Node: Jumping503143 38767 Node: Signaling505278 38768 Node: Returning506409 38769 Node: Calling509761 38770 Node: Patching512788 38771 Node: GDB Files513865 38772 Node: Files514510 38773 Ref: Shared Libraries527345 38774 Ref: Files-Footnote-1538698 38775 Node: Separate Debug Files538873 38776 Node: Index Files550443 38777 Node: Symbol Errors551786 38778 Node: Data Files555399 38779 Node: Targets556355 38780 Node: Active Targets557835 38781 Node: Target Commands558909 38782 Ref: load563182 38783 Node: Byte Order564163 38784 Node: Remote Debugging565140 38785 Node: Connecting566402 38786 Node: File Transfer571342 38787 Node: Server572282 38788 Ref: Monitor Commands for gdbserver579932 38789 Ref: Server-Footnote-1584586 38790 Node: Remote Configuration584706 38791 Ref: set remotebreak585730 38792 Ref: set remote hardware-watchpoint-limit587194 38793 Ref: set remote hardware-breakpoint-limit587194 38794 Ref: set remote exec-file587476 38795 Node: Remote Stub593744 38796 Node: Stub Contents596641 38797 Node: Bootstrapping598752 38798 Node: Debug Session602561 38799 Node: Configurations604121 38800 Node: Native604890 38801 Node: HP-UX605525 38802 Node: BSD libkvm Interface605814 38803 Node: SVR4 Process Information606885 38804 Node: DJGPP Native610315 38805 Node: Cygwin Native616895 38806 Node: Non-debug DLL Symbols620844 38807 Node: Hurd Native625392 38808 Node: Neutrino630655 38809 Node: Darwin631045 38810 Node: Embedded OS632303 38811 Node: VxWorks632779 38812 Node: VxWorks Connection634996 38813 Node: VxWorks Download635930 38814 Node: VxWorks Attach637665 38815 Node: Embedded Processors638063 38816 Node: ARM639242 38817 Node: M32R/D643363 38818 Node: M68K645065 38819 Node: MicroBlaze645358 38820 Node: MIPS Embedded646808 38821 Node: OpenRISC 1000651758 38822 Node: PowerPC Embedded654613 38823 Node: PA658241 38824 Node: Sparclet658530 38825 Node: Sparclet File660014 38826 Node: Sparclet Connection660894 38827 Node: Sparclet Download661372 38828 Node: Sparclet Execution662421 38829 Node: Sparclite663012 38830 Node: Z8000663387 38831 Node: AVR664771 38832 Node: CRIS665134 38833 Node: Super-H666112 38834 Node: Architectures667227 38835 Node: i386667649 38836 Node: A29K668331 38837 Node: Alpha669170 38838 Node: MIPS669303 38839 Node: HPPA671927 38840 Node: SPU672446 38841 Node: PowerPC674634 38842 Node: Controlling GDB675352 38843 Node: Prompt676178 38844 Node: Editing676957 38845 Node: Command History677900 38846 Node: Screen Size681304 38847 Node: Numbers683138 38848 Node: ABI685115 38849 Node: Messages/Warnings688044 38850 Ref: confirmation requests689470 38851 Node: Debugging Output690677 38852 Node: Other Misc Settings697235 38853 Node: Extending GDB698262 38854 Node: Sequences699753 38855 Node: Define700348 38856 Node: Hooks703961 38857 Node: Command Files706328 38858 Node: Output711398 38859 Node: Python716331 38860 Node: Python Commands717250 38861 Node: Python API718925 38862 Node: Basic Python720733 38863 Node: Exception Handling727704 38864 Node: Values From Inferior730203 38865 Node: Types In Python738713 38866 Node: Pretty Printing API746803 38867 Node: Selecting Pretty-Printers750702 38868 Node: Writing a Pretty-Printer753035 38869 Node: Inferiors In Python758349 38870 Node: Events In Python761265 38871 Node: Threads In Python765716 38872 Node: Commands In Python768347 38873 Node: Parameters In Python777163 38874 Node: Functions In Python782618 38875 Node: Progspaces In Python784731 38876 Node: Objfiles In Python786093 38877 Node: Frames In Python788025 38878 Node: Blocks In Python792253 38879 Node: Symbols In Python794457 38880 Node: Symbol Tables In Python801177 38881 Node: Breakpoints In Python803714 38882 Node: Lazy Strings In Python810565 38883 Node: Auto-loading812839 38884 Node: objfile-gdb.py file814735 38885 Node: .debug_gdb_scripts section815990 38886 Node: Which flavor to choose?817367 38887 Node: Python modules819184 38888 Node: gdb.printing819492 38889 Node: gdb.types820567 38890 Node: Interpreters821554 38891 Node: TUI823653 38892 Node: TUI Overview824620 38893 Node: TUI Keys827053 38894 Node: TUI Single Key Mode829357 38895 Node: TUI Commands830232 38896 Node: TUI Configuration832616 38897 Node: Emacs833912 38898 Node: GDB/MI839389 38899 Node: GDB/MI General Design841237 38900 Node: Context management843760 38901 Node: Asynchronous and non-stop modes846895 38902 Node: Thread groups848887 38903 Node: GDB/MI Command Syntax851165 38904 Node: GDB/MI Input Syntax851408 38905 Node: GDB/MI Output Syntax852962 38906 Node: GDB/MI Compatibility with CLI856534 38907 Node: GDB/MI Development and Front Ends857271 38908 Node: GDB/MI Output Records858928 38909 Node: GDB/MI Result Records859300 38910 Node: GDB/MI Stream Records860306 38911 Node: GDB/MI Async Records861571 38912 Node: GDB/MI Frame Information867868 38913 Node: GDB/MI Thread Information868946 38914 Node: GDB/MI Ada Exception Information869925 38915 Node: GDB/MI Simple Examples870348 38916 Node: GDB/MI Command Description Format872525 38917 Node: GDB/MI Breakpoint Commands873405 38918 Node: GDB/MI Program Context891401 38919 Node: GDB/MI Thread Commands895669 38920 Node: GDB/MI Program Execution899622 38921 Node: GDB/MI Stack Manipulation911403 38922 Node: GDB/MI Variable Objects922305 38923 Ref: -var-set-format932037 38924 Ref: -var-list-children933155 38925 Ref: -var-update941332 38926 Ref: -var-set-frozen944029 38927 Ref: -var-set-update-range944825 38928 Ref: -var-set-visualizer945355 38929 Node: GDB/MI Data Manipulation946852 38930 Node: GDB/MI Tracepoint Commands964437 38931 Node: GDB/MI Symbol Query971766 38932 Node: GDB/MI File Commands972455 38933 Node: GDB/MI Target Manipulation975792 38934 Node: GDB/MI File Transfer Commands982014 38935 Node: GDB/MI Miscellaneous Commands983336 38936 Ref: -interpreter-exec992868 38937 Node: Annotations995177 38938 Node: Annotations Overview996096 38939 Node: Server Prefix998559 38940 Node: Prompting999293 38941 Node: Errors1000810 38942 Node: Invalidation1001706 38943 Node: Annotations for Running1002183 38944 Node: Source Annotations1003703 38945 Node: JIT Interface1004628 38946 Node: Declarations1006346 38947 Node: Registering Code1007733 38948 Node: Unregistering Code1008705 38949 Node: GDB Bugs1009306 38950 Node: Bug Criteria1010035 38951 Node: Bug Reporting1010912 38952 Node: Command Line Editing1018535 38953 Node: Introduction and Notation1019187 38954 Node: Readline Interaction1020807 38955 Node: Readline Bare Essentials1021996 38956 Node: Readline Movement Commands1023783 38957 Node: Readline Killing Commands1024746 38958 Node: Readline Arguments1026664 38959 Node: Searching1027706 38960 Node: Readline Init File1029855 38961 Node: Readline Init File Syntax1030918 38962 Node: Conditional Init Constructs1042850 38963 Node: Sample Init File1045381 38964 Node: Bindable Readline Commands1048496 38965 Node: Commands For Moving1049551 38966 Node: Commands For History1050410 38967 Node: Commands For Text1053532 38968 Node: Commands For Killing1056256 38969 Node: Numeric Arguments1058396 38970 Node: Commands For Completion1059533 38971 Node: Keyboard Macros1061075 38972 Node: Miscellaneous Commands1061644 38973 Node: Readline vi Mode1065003 38974 Node: Using History Interactively1065920 38975 Node: History Interaction1066422 38976 Node: Event Designators1067844 38977 Node: Word Designators1068777 38978 Node: Modifiers1070414 38979 Node: In Memoriam1071639 38980 Node: Formatting Documentation1072522 38981 Ref: Formatting Documentation-Footnote-11075859 38982 Node: Installing GDB1075935 38983 Node: Requirements1076507 38984 Ref: Expat1077076 38985 Node: Running Configure1079521 38986 Node: Separate Objdir1083150 38987 Node: Config Names1086070 38988 Node: Configure Options1087527 38989 Node: System-wide configuration1089897 38990 Node: Maintenance Commands1091192 38991 Ref: maint info breakpoints1092376 38992 Node: Remote Protocol1106411 38993 Node: Overview1107000 38994 Ref: Binary Data1109562 38995 Node: Packets1111821 38996 Ref: thread-id syntax1112721 38997 Ref: extended mode1114166 38998 Ref: bc1115887 38999 Ref: bs1116097 39000 Ref: read registers packet1117523 39001 Ref: cycle step packet1119367 39002 Ref: write register packet1121243 39003 Ref: step with signal packet1122150 39004 Ref: vStopped packet1128431 39005 Ref: X packet1128774 39006 Ref: insert breakpoint or watchpoint packet1129060 39007 Node: Stop Reply Packets1131822 39008 Node: General Query Packets1136562 39009 Ref: QNonStop1145502 39010 Ref: QPassSignals1146126 39011 Ref: qSearch memory1148203 39012 Ref: QStartNoAckMode1148701 39013 Ref: qSupported1149231 39014 Ref: multiprocess extensions1158173 39015 Ref: qXfer read1162003 39016 Ref: qXfer auxiliary vector read1162497 39017 Ref: qXfer target description read1162846 39018 Ref: qXfer library list read1163290 39019 Ref: qXfer memory map read1163936 39020 Ref: qXfer sdata read1164322 39021 Ref: qXfer siginfo read1164786 39022 Ref: qXfer spu read1165182 39023 Ref: qXfer threads read1165705 39024 Ref: qXfer traceframe info read1166107 39025 Ref: qXfer osdata read1166524 39026 Ref: qXfer write1167726 39027 Ref: qXfer siginfo write1168283 39028 Ref: qXfer spu write1168679 39029 Ref: General Query Packets-Footnote-11170766 39030 Node: Architecture-Specific Protocol Details1171093 39031 Node: Tracepoint Packets1172606 39032 Node: Host I/O Packets1189053 39033 Node: Interrupts1193195 39034 Node: Notification Packets1195098 39035 Node: Remote Non-Stop1197369 39036 Node: Packet Acknowledgment1201628 39037 Node: Examples1203743 39038 Node: File-I/O Remote Protocol Extension1204369 39039 Node: File-I/O Overview1204831 39040 Node: Protocol Basics1207028 39041 Node: The F Request Packet1209260 39042 Node: The F Reply Packet1210161 39043 Node: The Ctrl-C Message1211079 39044 Node: Console I/O1212708 39045 Node: List of Supported Calls1213925 39046 Node: open1214287 39047 Node: close1216781 39048 Node: read1217163 39049 Node: write1217770 39050 Node: lseek1218537 39051 Node: rename1219415 39052 Node: unlink1220811 39053 Node: stat/fstat1221750 39054 Node: gettimeofday1222637 39055 Node: isatty1223072 39056 Node: system1223668 39057 Node: Protocol-specific Representation of Datatypes1225210 39058 Node: Integral Datatypes1225587 39059 Node: Pointer Values1226394 39060 Node: Memory Transfer1227102 39061 Node: struct stat1227722 39062 Node: struct timeval1229924 39063 Node: Constants1230441 39064 Node: Open Flags1230890 39065 Node: mode_t Values1231231 39066 Node: Errno Values1231723 39067 Node: Lseek Flags1232534 39068 Node: Limits1232719 39069 Node: File-I/O Examples1233079 39070 Node: Library List Format1234195 39071 Node: Memory Map Format1236959 39072 Node: Thread List Format1239519 39073 Node: Traceframe Info Format1240337 39074 Node: Agent Expressions1241794 39075 Node: General Bytecode Design1244615 39076 Node: Bytecode Descriptions1249415 39077 Node: Using Agent Expressions1261561 39078 Node: Varying Target Capabilities1263539 39079 Node: Rationale1264701 39080 Node: Target Descriptions1272087 39081 Node: Retrieving Descriptions1274147 39082 Node: Target Description Format1275232 39083 Node: Predefined Target Types1284282 39084 Node: Standard Target Features1285667 39085 Node: ARM Features1287438 39086 Node: i386 Features1288930 39087 Node: MIPS Features1290034 39088 Node: M68K Features1290979 39089 Node: PowerPC Features1291642 39090 Node: Operating System Information1292926 39091 Node: Process list1293764 39092 Node: Trace File Format1294826 39093 Node: Copying1296807 39094 Node: GNU Free Documentation License1334394 39095 Node: Index1359552 39096 39097 End Tag Table 39098