home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / adav313.zip / gnat-3_13p-docs.zip / gdb.INF (.txt) < prev    next >
OS/2 Help File  |  2001-09-16  |  197KB  |  6,021 lines

  1.  
  2. ΓòÉΓòÉΓòÉ 1. Title page ΓòÉΓòÉΓòÉ
  3.  
  4.                                  Debugging with
  5.  
  6.                           The gnu Source-Level Debugger
  7.  
  8.                                        ()
  9.  
  10.                         Second GNAT Edition, for  version
  11.  
  12.                                   November 1998
  13.  
  14.                      Richard M. Stallman and Roland H. Pesch
  15.  
  16. Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998 
  17. Free Software Foundation, Inc. 
  18.  
  19. Published by the Free Software Foundation 
  20. 59 Temple Place - Suite 330, 
  21. Boston, MA 02111-1307 USA 
  22. Printed copies are available for $20 each. 
  23. ISBN 1-882114-11-6 
  24.  
  25. Permission is granted to make and distribute verbatim copies of this manual 
  26. provided the copyright notice and this permission notice are preserved on all 
  27. copies. 
  28.  
  29. Permission is granted to copy and distribute modified versions of this manual 
  30. under the conditions for verbatim copying, provided also that the entire 
  31. resulting derived work is distributed under the terms of a permission notice 
  32. identical to this one. 
  33.  
  34. Permission is granted to copy and distribute translations of this manual into 
  35. another language, under the above conditions for modified versions. 
  36.  
  37.  
  38. ΓòÉΓòÉΓòÉ 2. Top node: "Debugging with " ΓòÉΓòÉΓòÉ
  39.  
  40. This file describes , the gnu symbolic debugger. 
  41.  
  42. This is the Second GNAT Edition, November 1998, for  Version . 
  43.  
  44.  Summary                                 Summary of GDBN 
  45.  
  46.  Sample Session                          A sample GDBN session 
  47.  
  48.  Invocation                              Getting in and out of GDBN 
  49.  Commands                                GDBN commands 
  50.  Running                                 Running programs under GDBN 
  51.  Stopping                                Stopping and continuing 
  52.  Stack                                   Examining the stack 
  53.  Source                                  Examining source files 
  54.  Data                                    Examining data 
  55.  
  56.  Languages                               Using GDBN with different languages 
  57.  
  58.  C                                       C language support 
  59.  
  60.  Symbols                                 Examining the symbol table 
  61.  Altering                                Altering execution 
  62.  GDB Files                               GDBN files 
  63.  Targets                                 Specifying a debugging target 
  64.  Controlling GDB                         Controlling GDBN 
  65.  Sequences                               Canned sequences of commands 
  66.  
  67.  Emacs                                   Using GDBN under gnu Emacs 
  68.  
  69.  GDB Bugs                                Reporting bugs in GDBN 
  70.  Command Line Editing                    Facilities of the readline library 
  71.  Using History Interactively 
  72.  
  73.  Formatting Documentation                How to format and print GDBN 
  74.                                          documentation 
  75.  Installing GDB                          Installing GDB 
  76.  
  77.  Index                                   Index 
  78.  
  79.  
  80. ΓòÉΓòÉΓòÉ 3. Summary of ΓòÉΓòÉΓòÉ
  81.  
  82. The purpose of a debugger such as  is to allow you to see what is going on 
  83. ``inside'' another program while it executes---or what another program was 
  84. doing at the moment it crashed. 
  85.  
  86.  can do four main kinds of things (plus other things in support of these) to 
  87. help you catch bugs in the act: 
  88.  
  89.      Start your program, specifying anything that might affect its behavior. 
  90.  
  91.      Make your program stop on specified conditions. 
  92.  
  93.      Examine what has happened, when your program has stopped. 
  94.  
  95.      Change things in your program, so you can experiment with correcting the 
  96.       effects of one bug and go on to learn about another. 
  97.  
  98.  You can use  to debug programs written in C or C++. For more information, see 
  99.  Supported languages. 
  100.  
  101.  Free Software                           Freely redistributable software 
  102.  
  103.  
  104.  Contributors                            Contributors to GDB 
  105.  
  106.  
  107. ΓòÉΓòÉΓòÉ 3.1. Free software ΓòÉΓòÉΓòÉ
  108.  
  109.  is free software, protected by the gnu General Public License (GPL).  The GPL 
  110. gives you the freedom to copy or adapt a licensed program---but every person 
  111. getting a copy also gets with it the freedom to modify that copy (which means 
  112. that they must get access to the source code), and the freedom to distribute 
  113. further copies. Typical software companies use copyrights to limit your 
  114. freedoms; the Free Software Foundation uses the GPL to preserve these freedoms. 
  115.  
  116. Fundamentally, the General Public License is a license which says that you have 
  117. these freedoms and that you cannot take these freedoms away from anyone else. 
  118.  
  119.  
  120. ΓòÉΓòÉΓòÉ 3.2. Contributors to GDB ΓòÉΓòÉΓòÉ
  121.  
  122. Richard Stallman was the original author of GDB, and of many other gnu 
  123. programs.  Many others have contributed to its development.  This section 
  124. attempts to credit major contributors.  One of the virtues of free software is 
  125. that everyone is free to contribute to it; with regret, we cannot actually 
  126. acknowledge everyone here.  The file `ChangeLog' in the  distribution 
  127. approximates a blow-by-blow account. 
  128.  
  129. Changes much prior to version 2.0 are lost in the mists of time. 
  130.  
  131. Plea: Additions to this section are particularly welcome.  If you or your 
  132. friends (or enemies, to be evenhanded) have been unfairly omitted from this 
  133. list, we would like to add your names! 
  134.  
  135. So that they may not regard their long labor as thankless, we particularly 
  136. thank those who shepherded GDB through major releases: Stan Shebs (release 
  137. 4.14), Fred Fish (releases 4.13, 4.12, 4.11, 4.10, and 4.9), Stu Grossman and 
  138. John Gilmore (releases 4.8, 4.7, 4.6, 4.5, and 4.4), John Gilmore (releases 
  139. 4.3, 4.2, 4.1, 4.0, and 3.9); Jim Kingdon (releases 3.5, 3.4, and 3.3); and 
  140. Randy Smith (releases 3.2, 3.1, and 3.0). As major maintainer of  for some 
  141. period, each contributed significantly to the structure, stability, and 
  142. capabilities of the entire debugger. 
  143.  
  144. Richard Stallman, assisted at various times by Peter TerMaat, Chris Hanson, and 
  145. Richard Mlynarik, handled releases through 2.8. 
  146.  
  147. Michael Tiemann is the author of most of the gnu C++ support in GDB, with 
  148. significant additional contributions from Per Bothner.  James Clark wrote the 
  149. gnu C++ demangler.  Early work on C++ was by Peter TerMaat (who also did much 
  150. general update work leading to release 3.0). 
  151.  
  152.  4 uses the BFD subroutine library to examine multiple object-file formats; BFD 
  153. was a joint project of David V. Henkel-Wallace, Rich Pixley, Steve Chamberlain, 
  154. and John Gilmore. 
  155.  
  156. David Johnson wrote the original COFF support; Pace Willison did the original 
  157. support for encapsulated COFF. 
  158.  
  159. Brent Benson of Harris Computer Systems contributed DWARF 2 support. 
  160.  
  161. Adam de Boor and Bradley Davis contributed the ISI Optimum V support. Per 
  162. Bothner, Noboyuki Hikichi, and Alessandro Forin contributed MIPS support. 
  163. Jean-Daniel Fekete contributed Sun 386i support. Chris Hanson improved the 
  164. HP9000 support. Noboyuki Hikichi and Tomoyuki Hasei contributed Sony/News OS 3 
  165. support. David Johnson contributed Encore Umax support. Jyrki Kuoppala 
  166. contributed Altos 3068 support. Jeff Law contributed HP PA and SOM support. 
  167. Keith Packard contributed NS32K support. Doug Rabson contributed Acorn Risc 
  168. Machine support. Bob Rusk contributed Harris Nighthawk CX-UX support. Chris 
  169. Smith contributed Convex support (and Fortran debugging). Jonathan Stone 
  170. contributed Pyramid support. Michael Tiemann contributed SPARC support. Tim 
  171. Tucker contributed support for the Gould NP1 and Gould Powernode. Pace Willison 
  172. contributed Intel 386 support. Jay Vosburgh contributed Symmetry support. 
  173.  
  174. Rich Schaefer and Peter Schauer helped with support of SunOS shared libraries. 
  175.  
  176. Jay Fenlason and Roland McGrath ensured that  and GAS agree about several 
  177. machine instruction sets. 
  178.  
  179. Patrick Duval, Ted Goldstein, Vikram Koka and Glenn Engel helped develop remote 
  180. debugging.  Intel Corporation, Wind River Systems, AMD, and ARM contributed 
  181. remote debugging modules for the i960, VxWorks, A29K UDI, and RDI targets, 
  182. respectively. 
  183.  
  184. Brian Fox is the author of the readline libraries providing command-line 
  185. editing and command history. 
  186.  
  187. Andrew Beers of SUNY Buffalo wrote the language-switching code, and contributed 
  188. the Languages chapter of this manual. 
  189.  
  190. Fred Fish wrote most of the support for Unix System Vr4. He also enhanced the 
  191. command-completion support to cover C++ overloaded symbols. 
  192.  
  193. Hitachi America, Ltd. sponsored the support for Hitachi microprocessors. 
  194.  
  195. Kung Hsu, Jeff Law, and Rick Sladkey added support for hardware watchpoints. 
  196.  
  197. Michael Snyder added support for tracepoints. 
  198.  
  199. Stu Grossman wrote gdbserver. 
  200.  
  201. Jim Kingdon, Peter Schauer, Ian Taylor, and Stu Grossman made nearly 
  202. innumerable bug fixes and cleanups throughout GDB. 
  203.  
  204. Cygnus Solutions has sponsored GDB maintenance and much of its development 
  205. since 1991. 
  206.  
  207.  
  208. ΓòÉΓòÉΓòÉ 4. A Sample  Session ΓòÉΓòÉΓòÉ
  209.  
  210. You can use this manual at your leisure to read all about . However, a handful 
  211. of commands are enough to get started using the debugger.  This chapter 
  212. illustrates those commands. 
  213.  
  214. One of the preliminary versions of gnu m4 (a generic macro processor) exhibits 
  215. the following bug: sometimes, when we change its quote strings from the 
  216. default, the commands used to capture one macro definition within another stop 
  217. working.  In the following short m4 session, we define a macro foo which 
  218. expands to 0000; we then use the m4 built-in defn to define bar as the same 
  219. thing.  However, when we change the open quote string to <QUOTE> and the close 
  220. quote string to <UNQUOTE>, the same procedure fails to define a new synonym 
  221. baz: 
  222.  
  223. $ cd gnu/m4
  224. $ ./m4
  225. define(foo,0000)
  226.  
  227. foo
  228. 0000
  229. define(bar,defn(`foo'))
  230.  
  231. bar
  232. 0000
  233. changequote(<QUOTE>,<UNQUOTE>)
  234.  
  235. define(baz,defn(<QUOTE>foo<UNQUOTE>))
  236. baz
  237. C-d
  238. m4: End of input: 0: fatal error: EOF in string
  239.  
  240. Let us use  to try to see what is going on. 
  241.  
  242. $  m4
  243. Copyright 1998 Free Software Foundation, Inc.
  244.  is free software and you are welcome to distribute copies
  245.  of it under certain conditions; type "show copying" to see
  246.  the conditions.
  247. There is absolutely no warranty for ; type "show warranty"
  248.  for details.
  249.  
  250. ()
  251.  
  252.  reads only enough symbol data to know where to find the rest when needed; as a 
  253. result, the first prompt comes up very quickly. We now tell  to use a narrower 
  254. display width than usual, so that examples fit in this manual. 
  255.  
  256. () set width 70
  257.  
  258. We need to see how the m4 built-in changequote works. Having looked at the 
  259. source, we know the relevant subroutine is m4_changequote, so we set a 
  260. breakpoint there with the break command. 
  261.  
  262. () break m4_changequote
  263. Breakpoint 1 at 0x62f4: file builtin.c, line 879.
  264.  
  265. Using the run command, we start m4 running under control; as long as control 
  266. does not reach the m4_changequote subroutine, the program runs as usual: 
  267.  
  268. () run
  269. Starting program: /work/Editorial/gdb/gnu/m4/m4
  270. define(foo,0000)
  271.  
  272. foo
  273. 0000
  274.  
  275. To trigger the breakpoint, we call changequote. suspends execution of m4, 
  276. displaying information about the context where it stops. 
  277.  
  278. changequote(<QUOTE>,<UNQUOTE>)
  279.  
  280. Breakpoint 1, m4_changequote (argc=3, argv=0x33c70)
  281.     at builtin.c:879
  282. 879         if (bad_argc(TOKEN_DATA_TEXT(argv[0]),argc,1,3))
  283.  
  284. Now we use the command n (next) to advance execution to the next line of the 
  285. current function. 
  286.  
  287. () n
  288. 882         set_quotes((argc >= 2) ? TOKEN_DATA_TEXT(argv[1])\
  289.  : nil,
  290.  
  291. set_quotes looks like a promising subroutine.  We can go into it by using the 
  292. command s (step) instead of next. step goes to the next line to be executed in 
  293. any subroutine, so it steps into set_quotes. 
  294.  
  295. () s
  296. set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
  297.     at input.c:530
  298. 530         if (lquote != def_lquote)
  299.  
  300. The display that shows the subroutine where m4 is now suspended (and its 
  301. arguments) is called a stack frame display.  It shows a summary of the stack. 
  302. We can use the backtrace command (which can also be spelled bt), to see where 
  303. we are in the stack as a whole: the backtrace command displays a stack frame 
  304. for each active subroutine. 
  305.  
  306. () bt
  307. #0  set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
  308.     at input.c:530
  309. #1  0x6344 in m4_changequote (argc=3, argv=0x33c70)
  310.     at builtin.c:882
  311. #2  0x8174 in expand_macro (sym=0x33320) at macro.c:242
  312. #3  0x7a88 in expand_token (obs=0x0, t=209696, td=0xf7fffa30)
  313.     at macro.c:71
  314. #4  0x79dc in expand_input () at macro.c:40
  315. #5  0x2930 in main (argc=0, argv=0xf7fffb20) at m4.c:195
  316.  
  317. We step through a few more lines to see what happens.  The first two times, we 
  318. can use `s'; the next two times we use n to avoid falling into the xstrdup 
  319. subroutine. 
  320.  
  321. () s
  322. 0x3b5c  532         if (rquote != def_rquote)
  323. () s
  324. 0x3b80  535         lquote = (lq == nil || *lq == '\0') ?  \
  325. def_lquote : xstrdup(lq);
  326. () n
  327. 536         rquote = (rq == nil || *rq == '\0') ? def_rquote\
  328.  : xstrdup(rq);
  329. () n
  330. 538         len_lquote = strlen(rquote);
  331.  
  332. The last line displayed looks a little odd; we can examine the variables lquote 
  333. and rquote to see if they are in fact the new left and right quotes we 
  334. specified.  We use the command p (print) to see their values. 
  335.  
  336. () p lquote
  337. $1 = 0x35d40 "<QUOTE>"
  338. () p rquote
  339. $2 = 0x35d50 "<UNQUOTE>"
  340.  
  341. lquote and rquote are indeed the new left and right quotes. To look at some 
  342. context, we can display ten lines of source surrounding the current line with 
  343. the l (list) command. 
  344.  
  345. () l
  346. 533             xfree(rquote);
  347. 534
  348. 535         lquote = (lq == nil || *lq == '\0') ? def_lquote\
  349.  : xstrdup (lq);
  350. 536         rquote = (rq == nil || *rq == '\0') ? def_rquote\
  351.  : xstrdup (rq);
  352. 537
  353. 538         len_lquote = strlen(rquote);
  354. 539         len_rquote = strlen(lquote);
  355. 540     }
  356. 541
  357. 542     void
  358.  
  359. Let us step past the two lines that set len_lquote and len_rquote, and then 
  360. examine the values of those variables. 
  361.  
  362. () n
  363. 539         len_rquote = strlen(lquote);
  364. () n
  365. 540     }
  366. () p len_lquote
  367. $3 = 9
  368. () p len_rquote
  369. $4 = 7
  370.  
  371. That certainly looks wrong, assuming len_lquote and len_rquote are meant to be 
  372. the lengths of lquote and rquote respectively.  We can set them to better 
  373. values using the p command, since it can print the value of any 
  374. expression---and that expression can include subroutine calls and assignments. 
  375.  
  376. () p len_lquote=strlen(lquote)
  377. $5 = 7
  378. () p len_rquote=strlen(rquote)
  379. $6 = 9
  380.  
  381. Is that enough to fix the problem of using the new quotes with the m4 built-in 
  382. defn?  We can allow m4 to continue executing with the c (continue) command, and 
  383. then try the example that caused trouble initially: 
  384.  
  385. () c
  386. Continuing.
  387.  
  388. define(baz,defn(<QUOTE>foo<UNQUOTE>))
  389.  
  390. baz
  391. 0000
  392.  
  393. Success!  The new quotes now work just as well as the default ones.  The 
  394. problem seems to have been just the two typos defining the wrong lengths.  We 
  395. allow m4 exit by giving it an EOF as input: 
  396.  
  397. C-d
  398. Program exited normally.
  399.  
  400. The message `Program exited normally.' is from ; it indicates m4 has finished 
  401. executing.  We can end our session with the  quit command. 
  402.  
  403. () quit
  404.  
  405.  
  406. ΓòÉΓòÉΓòÉ 5. Getting In and Out of ΓòÉΓòÉΓòÉ
  407.  
  408. This chapter discusses how to start , and how to get out of it. The essentials 
  409. are: 
  410.  
  411.      type `' to start GDB. 
  412.  
  413.      type quit or C-d to exit. 
  414.  
  415.  Invoking GDB                            How to start GDBN 
  416.  Quitting GDB                            How to quit GDBN 
  417.  Shell Commands                          How to use shell commands inside GDBN 
  418.  
  419.  
  420. ΓòÉΓòÉΓòÉ 5.1. Invoking ΓòÉΓòÉΓòÉ
  421.  
  422. Invoke  by running the program .  Once started,  reads commands from the 
  423. terminal until you tell it to exit. 
  424.  
  425. You can also run  with a variety of arguments and options, to specify more of 
  426. your debugging environment at the outset. 
  427.  
  428. The most usual way to start  is with one argument, specifying an executable 
  429. program: 
  430.  
  431.  program
  432.  
  433. You can also start with both an executable program and a core file specified: 
  434.  
  435.  program core
  436.  
  437. You can, instead, specify a process ID as a second argument, if you want to 
  438. debug a running process: 
  439.  
  440.  program 1234
  441.  
  442. would attach  to process 1234 (unless you also have a file named `1234';  does 
  443. check for a core file first). 
  444.  
  445. Taking advantage of the second command-line argument requires a fairly complete 
  446. operating system; when you use  as a remote debugger attached to a bare board, 
  447. there may not be any notion of ``process'', and there is often no way to get a 
  448. core dump. 
  449.  
  450. You can run gdb without printing the front material, which describes 's 
  451. non-warranty, by specifying -silent: 
  452.  
  453.  -silent
  454.  
  455. You can further control how  starts up by using command-line options.  itself 
  456. can remind you of the options available. 
  457.  
  458. Type 
  459.  
  460.  -help
  461.  
  462. to display all available options and briefly describe their use (` -h' is a 
  463. shorter equivalent). 
  464.  
  465. All options and coE13p-unx-docs\texi\gdb.texinfo line 775 : can't open included 
  466. file remote.texinfo mmand line arguments you give are processed in sequential 
  467. order.  The order makes a difference when the `-x' option is used. 
  468.  
  469.  Remote Serial                           GDBN remote serial protocol 
  470.  
  471.  i960-Nindy Remote                       GDBN with a remote i960 (Nindy) 
  472.  
  473.  UDI29K Remote                           The UDI protocol for AMD29K 
  474.  EB29K Remote                            The EBMON protocol for AMD29K 
  475.  
  476.  VxWorks Remote                          GDBN and VxWorks 
  477.  
  478.  ST2000 Remote                           GDBN with a Tandem ST2000 
  479.  
  480.  Hitachi Remote                          GDBN and Hitachi Microprocessors 
  481.  
  482.  MIPS Remote                             GDBN and MIPS boards 
  483.  
  484.  Sparclet Remote                         GDBN and Sparclet boards 
  485.  
  486.  Simulator                               Simulated CPU target 
  487.  
  488.  File Options                            Choosing files 
  489.  Mode Options                            Choosing modes 
  490.  
  491.  
  492. ΓòÉΓòÉΓòÉ 5.1.1. Choosing files ΓòÉΓòÉΓòÉ
  493.  
  494. When  starts, it reads any arguments other than options as specifying an 
  495. executable file and core file (or process ID).  This is the same as if the 
  496. arguments were specified by the `-se' and `-c' options respectively.  ( reads 
  497. the first argument that does not have an associated option flag as equivalent 
  498. to the `-se' option followed by that argument; and the second argument that 
  499. does not have an associated option flag, if any, as equivalent to the `-c' 
  500. option followed by that argument.) 
  501.  
  502. Many options have both long and short forms; both are shown in the following 
  503. list.  also recognizes the long forms if you truncate them, so long as enough 
  504. of the option is present to be unambiguous. (If you prefer, you can flag option 
  505. arguments with `--' rather than `-', though we illustrate the more usual 
  506. convention.) 
  507.  
  508.  -symbols file 
  509.  -s file 
  510.            Read symbol table from file file. 
  511.  
  512.  -exec file 
  513.  -e file 
  514.            Use file file as the executable file to execute when appropriate, 
  515.            and for examining pure data in conjunction with a core dump. 
  516.  
  517.  -se file 
  518.            Read symbol table from file file and use it as the executable file. 
  519.  
  520.  -core file 
  521.  -c file 
  522.            Use file file as a core dump to examine. 
  523.  
  524.  -c number 
  525.            Connect to process ID number, as with the attach command (unless 
  526.            there is a file in core-dump format named number, in which case `-c' 
  527.            specifies that file as a core dump to read). 
  528.  
  529.  -command file 
  530.  -x file 
  531.            Execute  commands from file file. See Command files. 
  532.  
  533.  -directory directory 
  534.  -d directory 
  535.            Add directory to the path to search for source files. 
  536.  
  537.  -m 
  538.  -mapped 
  539.            Warning: this option depends on operating system facilities that are 
  540.            not supported on all systems. 
  541.            If memory-mapped files are available on your system through the mmap 
  542.            system call, you can use this option to have  write the symbols from 
  543.            your program into a reusable file in the current directory.  If the 
  544.            program you are debugging is called `/tmp/fred', the mapped symbol 
  545.            file is `./fred.syms'. Future  debugging sessions notice the 
  546.            presence of this file, and can quickly map in symbol information 
  547.            from it, rather than reading the symbol table from the executable 
  548.            program. 
  549.  
  550.            The `.syms' file is specific to the host machine where is run.  It 
  551.            holds an exact image of the internal  symbol table.  It cannot be 
  552.            shared across multiple host platforms. 
  553.  
  554.  -r 
  555.  -readnow 
  556.            Read each symbol file's entire symbol table immediately, rather than 
  557.            the default, which is to read it incrementally as it is needed. This 
  558.            makes startup slower, but makes future operations faster. 
  559.  
  560.  The -mapped and -readnow options are typically combined in order to build a 
  561.  `.syms' file that contains complete symbol information.  (See Commands to 
  562.  specify files, for information 
  563.  
  564.  a `.syms' file for future use is: 
  565.  
  566.           gdb -batch -nx -mapped -readnow programname
  567.  
  568.  
  569. ΓòÉΓòÉΓòÉ 5.1.2. Choosing modes ΓòÉΓòÉΓòÉ
  570.  
  571. You can run  in various alternative modes---for example, in batch mode or quiet 
  572. mode. 
  573.  
  574.  -nx 
  575.  -n 
  576.            Do not execute commands from any initialization files (normally 
  577.            called `').  Normally, the commands in these files are executed 
  578.            after all the command options and arguments have been processed. 
  579.            See Command files. 
  580.  
  581.  -quiet 
  582.  -q 
  583.            ``Quiet''.  Do not print the introductory and copyright messages. 
  584.            These messages are also suppressed in batch mode. 
  585.  
  586.  -batch 
  587.            Run in batch mode.  Exit with status 0 after processing all the 
  588.            command files specified with `-x' (and all commands from 
  589.            initialization files, if not inhibited with `-n').  Exit with 
  590.            nonzero status if an error occurs in executing the  commands in the 
  591.            command files. 
  592.  
  593.            Batch mode may be useful for running  as a filter, for example to 
  594.            download and run a program on another computer; in order to make 
  595.            this more useful, the message 
  596.  
  597.                       Program exited normally.
  598.  
  599.            (which is ordinarily issued whenever a program running under 
  600.            control terminates) is not issued when running in batch mode. 
  601.  
  602.  -cd directory 
  603.            Run  using directory as its working directory, instead of the 
  604.            current directory. 
  605.  
  606.  -fullname 
  607.  -f 
  608.            gnu Emacs sets this option when it runs  as a subprocess.  It tells 
  609.            to output the full file name and line number in a standard, 
  610.            recognizable fashion each time a stack frame is displayed (which 
  611.            includes each time your program stops).  This recognizable format 
  612.            looks like two `\032' characters, followed by the file name, line 
  613.            number and character position separated by colons, and a newline. 
  614.            The Emacs-to- interface program uses the two `\032' characters as a 
  615.            signal to display the source code for the frame. 
  616.  
  617.  
  618. ΓòÉΓòÉΓòÉ 5.2. Quitting ΓòÉΓòÉΓòÉ
  619.  
  620.  quit 
  621.            To exit , use the quit command (abbreviated q), or type an 
  622.            end-of-file character (usually C-d).  If you do not supply 
  623.            expression,  will terminate normally; otherwise it will terminate 
  624.            using the result of expression as the error code. 
  625.  
  626.  An interrupt (often C-c) does not exit from , but rather terminates the action 
  627.  of any  command that is in progress and returns to  command level.  It is safe 
  628.  to type the interrupt character at any time because  does not allow it to take 
  629.  effect until a time when it is safe. 
  630.  
  631.  If you have been using  to control an attached process or device, you can 
  632.  release it with the detach command (see Debugging an already-running process). 
  633.  
  634.  
  635. ΓòÉΓòÉΓòÉ 5.3. Shell commands ΓòÉΓòÉΓòÉ
  636.  
  637. If you need to execute occasional shell commands during your debugging session, 
  638. there is no need to leave or suspend ; you can just use the shell command. 
  639.  
  640.  shell command string 
  641.            Invoke a the standard shell to execute command string. If it exists, 
  642.            the environment variable SHELL determines which shell to run. 
  643.            Otherwise  uses /bin/sh. 
  644.  
  645.  The utility make is often needed in development environments. You do not have 
  646.  to use the shell command for this purpose in : 
  647.  
  648.  make make-args 
  649.            Execute the make program with the specified arguments.  This is 
  650.            equivalent to `shell make make-args'. 
  651.  
  652.  
  653. ΓòÉΓòÉΓòÉ 6. Commands ΓòÉΓòÉΓòÉ
  654.  
  655. You can abbreviate a  command to the first few letters of the command name, if 
  656. that abbreviation is unambiguous; and you can repeat certain  commands by 
  657. typing just RET.  You can also use the TAB key to get  to fill out the rest of 
  658. a word in a command (or to show you the alternatives available, if there is 
  659. more than one possibility). 
  660.  
  661.  Command Syntax                          How to give commands to GDBN 
  662.  Completion                              Command completion 
  663.  Help                                    How to ask GDBN for help 
  664.  
  665.  
  666. ΓòÉΓòÉΓòÉ 6.1. Command syntax ΓòÉΓòÉΓòÉ
  667.  
  668. A  command is a single line of input.  There is no limit on how long it can be. 
  669. It starts with a command name, which is followed by arguments whose meaning 
  670. depends on the command name.  For example, the command step accepts an argument 
  671. which is the number of times to step, as in `step 5'.  You can also use the 
  672. step command with no arguments.  Some command names do not allow any arguments. 
  673.  
  674.  command names may always be truncated if that abbreviation is unambiguous. 
  675. Other possible command abbreviations are listed in the documentation for 
  676. individual commands.  In some cases, even ambiguous abbreviations are allowed; 
  677. for example, s is specially defined as equivalent to step even though there are 
  678. other commands whose names start with s.  You can test abbreviations by using 
  679. them as arguments to the help command. 
  680.  
  681. A blank line as input to  (typing just RET) means to repeat the previous 
  682. command. Certain commands (for example, run) will not repeat this way; these 
  683. are commands whose unintentional repetition might cause trouble and which you 
  684. are unlikely to want to repeat. 
  685.  
  686. The list and x commands, when you repeat them with RET, construct new arguments 
  687. rather than repeating exactly as typed.  This permits easy scanning of source 
  688. or memory. 
  689.  
  690.  can also use RET in another way: to partition lengthy output, in a way similar 
  691. to the common utility more (see Screen size).  Since it is easy to press one 
  692. RET too many in this situation,  disables command repetition after any command 
  693. that generates this sort of display. 
  694.  
  695. Any text from a # to the end of the line is a comment; it does nothing.  This 
  696. is useful mainly in command files ( see Command files). 
  697.  
  698.  
  699. ΓòÉΓòÉΓòÉ 6.2. Command completion ΓòÉΓòÉΓòÉ
  700.  
  701.  can fill in the rest of a word in a command for you, if there is only one 
  702. possibility; it can also show you what the valid possibilities are for the next 
  703. word in a command, at any time.  This works for commands,  subcommands, and the 
  704. names of symbols in your program. 
  705.  
  706. Press the TAB key whenever you want  to fill out the rest of a word.  If there 
  707. is only one possibility,  fills in the word, and waits for you to finish the 
  708. command (or press RET to enter it).  For example, if you type 
  709.  
  710. () info bre TAB
  711.  
  712.  fills in the rest of the word `breakpoints', since that is the only info 
  713. subcommand beginning with `bre': 
  714.  
  715. () info breakpoints
  716.  
  717. You can either press RET at this point, to run the info breakpoints command, or 
  718. backspace and enter something else, if `breakpoints' does not look like the 
  719. command you expected.  (If you were sure you wanted info breakpoints in the 
  720. first place, you might as well just type RET immediately after `info bre', to 
  721. exploit command abbreviations rather than command completion). 
  722.  
  723. If there is more than one possibility for the next word when you press TAB, 
  724. sounds a bell.  You can either supply more characters and try again, or just 
  725. press TAB a second time;  displays all the possible completions for that word. 
  726. For example, you might want to set a breakpoint on a subroutine whose name 
  727. begins with `make_', but when you type b make_TAB just sounds the bell.  Typing 
  728. TAB again displays all the function names in your program that begin with those 
  729. characters, for example: 
  730.  
  731. () b make_ TAB
  732.  sounds bell; press TAB again, to see:
  733. make_a_section_from_file     make_environ
  734. make_abs_section             make_function_type
  735. make_blockvector             make_pointer_type
  736. make_cleanup                 make_reference_type
  737. make_command                 make_symbol_completion_list
  738. () b make_
  739.  
  740. After displaying the available possibilities,  copies your partial input (`b 
  741. make_' in the example) so you can finish the command. 
  742.  
  743. If you just want to see the list of alternatives in the first place, you can 
  744. press M-? rather than pressing TAB twice. M-? means META ?.  You can type this 
  745. either by holding down a key designated as the META shift on your keyboard (if 
  746. there is one) while typing ?, or as ESC followed by ?. 
  747.  
  748. Sometimes the string you need, while logically a ``word'', may contain 
  749. parentheses or other characters that  normally excludes from its notion of a 
  750. word.  To permit word completion to work in this situation, you may enclose 
  751. words in ' (single quote marks) in  commands. 
  752.  
  753. The most likely situation where you might need this is in typing the name of a 
  754. C++ function.  This is because C++ allows function overloading (multiple 
  755. definitions of the same function, distinguished by argument type).  For 
  756. example, when you want to set a breakpoint you may need to distinguish whether 
  757. you mean the version of name that takes an int parameter, name(int), or the 
  758. version that takes a float parameter, name(float).  To use the word-completion 
  759. facilities in this situation, type a single quote ' at the beginning of the 
  760. function name.  This alerts  that it may need to consider more information than 
  761. usual when you press TAB or M-? to request word completion: 
  762.  
  763. () b 'bubble( M-?
  764. bubble(double,double)    bubble(int,int)
  765. () b 'bubble(
  766.  
  767. In some cases,  can tell that completing a name requires using quotes.  When 
  768. this happens,  inserts the quote for you (while completing as much as it can) 
  769. if you do not type the quote in the first place: 
  770.  
  771. () b bub TAB
  772.  alters your input line to the following, and rings a bell:
  773. () b 'bubble(
  774.  
  775. In general,  can tell that a quote is needed (and inserts it) if you have not 
  776. yet started typing the argument list when you ask for completion on an 
  777. overloaded symbol. 
  778.  
  779.  
  780. ΓòÉΓòÉΓòÉ 6.3. Getting help ΓòÉΓòÉΓòÉ
  781.  
  782. You can always ask  itself for information on its commands, using the command 
  783. help. 
  784.  
  785.  help 
  786.  h 
  787.            You can use help (abbreviated h) with no arguments to display a 
  788.            short list of named classes of commands: 
  789.  
  790.                       () help
  791.                       List of classes of commands:
  792.  
  793.                       running -- Running the program
  794.                       stack -- Examining the stack
  795.                       data -- Examining data
  796.                       breakpoints -- Making program stop at certain points
  797.                       files -- Specifying and examining files
  798.                       status -- Status inquiries
  799.                       support -- Support facilities
  800.                       user-defined -- User-defined commands
  801.                       aliases -- Aliases of other commands
  802.                       obscure -- Obscure features
  803.  
  804.                       Type "help" followed by a class name for a list of
  805.                       commands in that class.
  806.                       Type "help" followed by command name for full
  807.                       documentation.
  808.                       Command name abbreviations are allowed if unambiguous.
  809.                       ()
  810.  
  811.  help class 
  812.            Using one of the general help classes as an argument, you can get a 
  813.            list of the individual commands in that class.  For example, here is 
  814.            the help display for the class status: 
  815.  
  816.                       () help status
  817.                       Status inquiries.
  818.  
  819.                       List of commands:
  820.  
  821.                       show -- Generic command for showing things set
  822.                        with "set"
  823.                       info -- Generic command for printing status
  824.  
  825.                       Type "help" followed by command name for full
  826.                       documentation.
  827.                       Command name abbreviations are allowed if unambiguous.
  828.                       ()
  829.  
  830.  help command 
  831.            With a command name as help argument,  displays a short paragraph on 
  832.            how to use that command. 
  833.  
  834.  complete args 
  835.            The complete args command lists all the possible completions for the 
  836.            beginning of a command.  Use args to specify the beginning of the 
  837.            command you want completed.  For example: 
  838.  
  839.                       complete i
  840.  
  841.            results in: 
  842.  
  843.                       info
  844.                       inspect
  845.                       ignore
  846.  
  847.            This is intended for use by gnu Emacs. 
  848.  
  849.  In addition to help, you can use the  commands info and show to inquire about 
  850.  the state of your program, or the state of  itself.  Each command supports 
  851.  many topics of inquiry; this manual introduces each of them in the appropriate 
  852.  context.  The listings under info and under show in the Index point to all the 
  853.  sub-commands.  See Index. 
  854.  
  855.  info 
  856.            This command (abbreviated i) is for describing the state of your 
  857.            program.  For example, you can list the arguments given to your 
  858.            program with info args, list the registers currently in use with 
  859.            info registers, or list the breakpoints you have set with info 
  860.            breakpoints. You can get a complete list of the info sub-commands 
  861.            with help info. 
  862.  
  863.  set 
  864.            You can assign the result of an expresson to an environment variable 
  865.            with set.  For example, you can set the  prompt to a $-sign with set 
  866.            prompt $. 
  867.  
  868.  show 
  869.            In contrast to info, show is for describing the state of  itself. 
  870.            You can change most of the things you can show, by using the related 
  871.            command set; for example, you can control what number system is used 
  872.            for displays with set radix, or simply inquire which is currently in 
  873.            use with show radix. 
  874.  
  875.            To display all the settable parameters and their current values, you 
  876.            can use show with no arguments; you may also use info set.  Both 
  877.            commands produce the same display. 
  878.  
  879.  Here are three miscellaneous show subcommands, all of which are exceptional in 
  880.  lacking corresponding set commands: 
  881.  
  882.  show version 
  883.            Show what version of  is running.  You should include this 
  884.            information in  bug-reports.  If multiple versions of  are in use at 
  885.            your site, you may occasionally want to determine which version of 
  886.            you are running; as  evolves, new commands are introduced, and old 
  887.            ones may wither away.  The version number is also announced when you 
  888.            start . 
  889.  
  890.  show copying 
  891.            Display information about permission for copying . 
  892.  
  893.  show warranty 
  894.            Display the gnu ``NO WARRANTY'' statement. 
  895.  
  896.  
  897. ΓòÉΓòÉΓòÉ 7. Running Programs Under ΓòÉΓòÉΓòÉ
  898.  
  899. When you run a program under , you must first generate debugging information 
  900. when you compile it. You may start  with its arguments, if any, in an 
  901. environment of your choice.  You may redirect your program's input and output, 
  902. debug an already running process, or kill a child process. 
  903.  
  904.  Compilation                             Compiling for debugging 
  905.  Starting                                Starting your program 
  906.  
  907.  Arguments                               Your program's arguments 
  908.  Environment                             Your program's environment 
  909.  Working Directory                       Your program's working directory 
  910.  Input/Output                            Your program's input and output 
  911.  Attach                                  Debugging an already-running process 
  912.  Kill Process                            Killing the child process 
  913.  Process Information                     Additional process information 
  914.  Threads                                 Debugging programs with multiple 
  915.                                          threads 
  916.  Processes                               Debugging programs with multiple 
  917.                                          processes 
  918.  
  919.  
  920. ΓòÉΓòÉΓòÉ 7.1. Compiling for debugging ΓòÉΓòÉΓòÉ
  921.  
  922. In order to debug a program effectively, you need to generate debugging 
  923. information when you compile it.  This debugging information is stored in the 
  924. object file; it describes the data type of each variable or function and the 
  925. correspondence between source line numbers and addresses in the executable 
  926. code. 
  927.  
  928. To request debugging information, specify the `-g' option when you run the 
  929. compiler. 
  930.  
  931. Many C compilers are unable to handle the `-g' and `-O' options together. 
  932. Using those compilers, you cannot generate optimized executables containing 
  933. debugging information. 
  934.  
  935. , the gnu C compiler, supports `-g' with or without `-O', making it possible to 
  936. debug optimized code.  We recommend that you always use `-g' whenever you 
  937. compile a program. You may think your program is correct, but there is no sense 
  938. in pushing your luck. 
  939.  
  940. When you debug a program compiled with `-g -O', remember that the optimizer is 
  941. rearranging your code; the debugger shows you what is really there.  Do not be 
  942. too surprised when the execution path does not exactly match your source file! 
  943. An extreme example: if you define a variable, but never use it,  never sees 
  944. that variable---because the compiler optimizes it out of existence. 
  945.  
  946. Some things do not work as well with `-g -O' as with just `-g', particularly on 
  947. machines with instruction scheduling.  If in doubt, recompile with `-g' alone, 
  948. and if this fixes the problem, please report it to us as a bug (including a 
  949. test case!). 
  950.  
  951. Older versions of the gnu C compiler permitted a variant option `-gg' for 
  952. debugging information.  no longer supports this format; if your gnu C compiler 
  953. has this option, do not use it. 
  954.  
  955.  
  956. ΓòÉΓòÉΓòÉ 7.2. Starting your program ΓòÉΓòÉΓòÉ
  957.  
  958.  run 
  959.  r 
  960.            Use the run command to start your program under .  You must first 
  961.            specify the program name with an argument to  ( see Getting In and 
  962.            Out of), or by using the file or exec-file command (see Commands to 
  963.            specify files). 
  964.  
  965.  If you are running your program in an execution environment that supports 
  966.  processes, run creates an inferior process and makes that process run your 
  967.  program.  (In environments without processes, run jumps to the start of your 
  968.  program.) 
  969.  
  970.  The execution of a program is affected by certain information it receives from 
  971.  its superior.  provides ways to specify this information, which you must do 
  972.  before starting your program.  (You can change it after starting your program, 
  973.  but such changes only affect your program the next time you start it.)  This 
  974.  information may be divided into four categories: 
  975.  
  976.  The arguments. 
  977.            Specify the arguments to give your program as the arguments of the 
  978.            run command.  If a shell is available on your target, the shell is 
  979.            used to pass the arguments, so that you may use normal conventions 
  980.            (such as wildcard expansion or variable substitution) in describing 
  981.            the arguments.  In Unix systems, you can control which shell is used 
  982.            with the SHELL environment variable. See Your program_s arguments. 
  983.  
  984.  The environment. 
  985.            Your program normally inherits its environment from , but you can 
  986.            use the  commands set environment and unset environment to change 
  987.            parts of the environment that affect your program.  See Your 
  988.            program_s environment. 
  989.  
  990.  The working directory. 
  991.            Your program inherits its working directory from .  You can set the 
  992.            working directory with the cd command in . See Your program_s 
  993.            working directory. 
  994.  
  995.  The standard input and output. 
  996.            Your program normally uses the same device for standard input and 
  997.            standard output as  is using.  You can redirect input and output in 
  998.            the run command line, or you can use the tty command to set a 
  999.            different device for your program. See Your program_s input and 
  1000.            output. 
  1001.  
  1002.            Warning: While input and output redirection work, you cannot use 
  1003.            pipes to pass the output of the program you are debugging to another 
  1004.            program; if you attempt this,  is likely to wind up debugging the 
  1005.            wrong program. 
  1006.  
  1007.  When you issue the run command, your program begins to execute immediately. 
  1008.  See Stopping and continuing, for discussion of how to arrange for your program 
  1009.  to stop.  Once your program has stopped, you may call functions in your 
  1010.  program, using the print or call commands.  See Examining Data. 
  1011.  
  1012.  If the modification time of your symbol file has changed since the last time 
  1013.  read its symbols,  discards its symbol table, and reads it again.  When it 
  1014.  does this,  tries to retain your current breakpoints. 
  1015.  
  1016.  
  1017. ΓòÉΓòÉΓòÉ 7.3. Your program's arguments ΓòÉΓòÉΓòÉ
  1018.  
  1019. The arguments to your program can be specified by the arguments of the run 
  1020. command.  They are passed to a shell, which expands wildcard characters and 
  1021. performs redirection of I/O, and thence to your program. Your SHELL environment 
  1022. variable (if it exists) specifies what shell  uses.  If you do not define 
  1023. SHELL,  uses /bin/sh. 
  1024.  
  1025. run with no arguments uses the same arguments used by the previous run, or 
  1026. those set by the set args command. 
  1027.  
  1028.  set args 
  1029.            Specify the arguments to be used the next time your program is run. 
  1030.            If set args has no arguments, run executes your program with no 
  1031.            arguments.  Once you have run your program with arguments, using set 
  1032.            args before the next run is the only way to run it again without 
  1033.            arguments. 
  1034.  
  1035.  show args 
  1036.            Show the arguments to give your program when it is started. 
  1037.  
  1038.  
  1039. ΓòÉΓòÉΓòÉ 7.4. Your program's environment ΓòÉΓòÉΓòÉ
  1040.  
  1041. The environment consists of a set of environment variables and their values. 
  1042. Environment variables conventionally record such things as your user name, your 
  1043. home directory, your terminal type, and your search path for programs to run. 
  1044. Usually you set up environment variables with the shell and they are inherited 
  1045. by all the other programs you run.  When debugging, it can be useful to try 
  1046. running your program with a modified environment without having to start  over 
  1047. again. 
  1048.  
  1049.  path directory 
  1050.            Add directory to the front of the PATH environment variable (the 
  1051.            search path for executables), for both  and your program. You may 
  1052.            specify several directory names, separated by `:' or whitespace.  If 
  1053.            directory is already in the path, it is moved to the front, so it is 
  1054.            searched sooner. 
  1055.  
  1056.            You can use the string `$cwd' to refer to whatever is the current 
  1057.            working directory at the time  searches the path.  If you use `.' 
  1058.            instead, it refers to the directory where you executed the path 
  1059.            command.  replaces `.' in the directory argument (with the current 
  1060.            path) before adding directory to the search path. 
  1061.  
  1062.  show paths 
  1063.            Display the list of search paths for executables (the PATH 
  1064.            environment variable). 
  1065.  
  1066.  show environment [varname] 
  1067.            Print the value of environment variable varname to be given to your 
  1068.            program when it starts.  If you do not supply varname, print the 
  1069.            names and values of all environment variables to be given to your 
  1070.            program.  You can abbreviate environment as env. 
  1071.  
  1072.  set environment varname [=] value 
  1073.            Set environment variable varname to value.  The value changes for 
  1074.            your program only, not for  itself.  value may be any string; the 
  1075.            values of environment variables are just strings, and any 
  1076.            interpretation is supplied by your program itself.  The value 
  1077.            parameter is optional; if it is eliminated, the variable is set to a 
  1078.            null value. 
  1079.  
  1080.            For example, this command: 
  1081.  
  1082.                       set env USER = foo
  1083.  
  1084.            tells a Unix program, when subsequently run, that its user is named 
  1085.            `foo'.  (The spaces around `=' are used for clarity here; they are 
  1086.            not actually required.) 
  1087.  
  1088.  unset environment varname 
  1089.            Remove variable varname from the environment to be passed to your 
  1090.            program.  This is different from `set env varname ='; unset 
  1091.            environment removes the variable from the environment, rather than 
  1092.            assigning it an empty value. 
  1093.  
  1094.  Warning:  runs your program using the shell indicated by your SHELL 
  1095.  environment variable if it exists (or /bin/sh if not).  If your SHELL variable 
  1096.  names a shell that runs an initialization file---such as `.cshrc' for C-shell, 
  1097.  or `.bashrc' for BASH---any variables you set in that file affect your 
  1098.  program.  You may wish to move setting of environment variables to files that 
  1099.  are only run when you sign on, such as `.login' or `.profile'. 
  1100.  
  1101.  
  1102. ΓòÉΓòÉΓòÉ 7.5. Your program's working directory ΓòÉΓòÉΓòÉ
  1103.  
  1104. Each time you start your program with run, it inherits its working directory 
  1105. from the current working directory of . The  working directory is initially 
  1106. whatever it inherited from its parent process (typically the shell), but you 
  1107. can specify a new working directory in  with the cd command. 
  1108.  
  1109. The  working directory also serves as a default for the commands that specify 
  1110. files for  to operate on. See Commands to specify files. 
  1111.  
  1112.  cd directory 
  1113.            Set the  working directory to directory. 
  1114.  
  1115.  pwd 
  1116.            Print the  working directory. 
  1117.  
  1118.  
  1119. ΓòÉΓòÉΓòÉ 7.6. Your program's input and output ΓòÉΓòÉΓòÉ
  1120.  
  1121. By default, the program you run under  does input and output to the same 
  1122. terminal that  uses.  switches the terminal to its own terminal modes to 
  1123. interact with you, but it records the terminal modes your program was using and 
  1124. switches back to them when you continue running your program. 
  1125.  
  1126.  info terminal 
  1127.            Displays information recorded by  about the terminal modes your 
  1128.            program is using. 
  1129.  
  1130.  You can redirect your program's input and/or output using shell redirection 
  1131.  with the run command.  For example, 
  1132.  
  1133.   run > outfile
  1134.  
  1135.  starts your program, diverting its output to the file `outfile'. 
  1136.  
  1137.  Another way to specify where your program should do input and output is with 
  1138.  the tty command.  This command accepts a file name as argument, and causes 
  1139.  this file to be the default for future run commands.  It also resets the 
  1140.  controlling terminal for the child process, for future run commands.  For 
  1141.  example, 
  1142.  
  1143.   tty /dev/ttyb
  1144.  
  1145.  directs that processes started with subsequent run commands default to do 
  1146.  input and output on the terminal `/dev/ttyb' and have that as their 
  1147.  controlling terminal. 
  1148.  
  1149.  An explicit redirection in run overrides the tty command's effect on the 
  1150.  input/output device, but not its effect on the controlling terminal. 
  1151.  
  1152.  When you use the tty command or redirect input in the run command, only the 
  1153.  input for your program is affected.  The input for  still comes from your 
  1154.  terminal. 
  1155.  
  1156.  
  1157. ΓòÉΓòÉΓòÉ 7.7. Debugging an already-running process ΓòÉΓòÉΓòÉ
  1158.  
  1159.  attach process-id 
  1160.            This command attaches to a running process---one that was started 
  1161.            outside .  (info files shows your active targets.)  The command 
  1162.            takes as argument a process ID.  The usual way to find out the 
  1163.            process-id of a Unix process is with the ps utility, or with the 
  1164.            `jobs -l' shell command. 
  1165.  
  1166.            attach does not repeat if you press RET a second time after 
  1167.            executing the command. 
  1168.  
  1169.  To use attach, your program must be running in an environment which supports 
  1170.  processes; for example, attach does not work for programs on bare-board 
  1171.  targets that lack an operating system.  You must also have permission to send 
  1172.  the process a signal. 
  1173.  
  1174.  When using attach, you should first use the file command to specify the 
  1175.  program running in the process and load its symbol table. See Commands to 
  1176.  Specify Files. 
  1177.  
  1178.  The first thing  does after arranging to debug the specified process is to 
  1179.  stop it.  You can examine and modify an attached process with all the 
  1180.  commands that are ordinarily available when you start processes with run.  You 
  1181.  can insert breakpoints; you can step and continue; you can modify storage.  If 
  1182.  you would rather the process continue running, you may use the continue 
  1183.  command after attaching  to the process. 
  1184.  
  1185.  detach 
  1186.            When you have finished debugging the attached process, you can use 
  1187.            the detach command to release it from  control.  Detaching the 
  1188.            process continues its execution.  After the detach command, that 
  1189.            process and  become completely independent once more, and you are 
  1190.            ready to attach another process or start one with run. detach does 
  1191.            not repeat if you press RET again after executing the command. 
  1192.  
  1193.  If you exit  or use the run command while you have an attached process, you 
  1194.  kill that process.  By default,  asks for confirmation if you try to do either 
  1195.  of these things; you can control whether or not you need to confirm by using 
  1196.  the set confirm command ( see Optional warnings and messages). 
  1197.  
  1198.  
  1199. ΓòÉΓòÉΓòÉ 7.8. Killing the child process ΓòÉΓòÉΓòÉ
  1200.  
  1201.  kill 
  1202.            Kill the child process in which your program is running under . 
  1203.  
  1204.  This command is useful if you wish to debug a core dump instead of a running 
  1205.  process.  ignores any core dump file while your program is running. 
  1206.  
  1207.  On some operating systems, a program cannot be executed outside while you have 
  1208.  breakpoints set on it inside .  You can use the kill command in this situation 
  1209.  to permit running your program outside the debugger. 
  1210.  
  1211.  The kill command is also useful if you wish to recompile and relink your 
  1212.  program, since on many systems it is impossible to modify an executable file 
  1213.  while it is running in a process.  In this case, when you next type run, 
  1214.  notices that the file has changed, and reads the symbol table again (while 
  1215.  trying to preserve your current breakpoint settings). 
  1216.  
  1217.  
  1218. ΓòÉΓòÉΓòÉ 7.9. Additional process information ΓòÉΓòÉΓòÉ
  1219.  
  1220. Some operating systems provide a facility called `/proc' that can be used to 
  1221. examine the image of a running process using file-system subroutines.  If  is 
  1222. configured for an operating system with this facility, the command info proc is 
  1223. available to report on several kinds of information about the process running 
  1224. your program. info proc works only on SVR4 systems that support procfs. 
  1225.  
  1226.  info proc 
  1227.            Summarize available information about the process. 
  1228.  
  1229.  info proc mappings 
  1230.            Report on the address ranges accessible in the program, with 
  1231.            information on whether your program may read, write, or execute each 
  1232.            range. 
  1233.  
  1234.  info proc times 
  1235.            Starting time, user CPU time, and system CPU time for your program 
  1236.            and its children. 
  1237.  
  1238.  info proc id 
  1239.            Report on the process IDs related to your program: its own process 
  1240.            ID, the ID of its parent, the process group ID, and the session ID. 
  1241.  
  1242.  info proc status 
  1243.            General information on the state of the process.  If the process is 
  1244.            stopped, this report includes the reason for stopping, and any 
  1245.            signal received. 
  1246.  
  1247.  info proc all 
  1248.            Show all the above information about the process. 
  1249.  
  1250.  
  1251. ΓòÉΓòÉΓòÉ 7.10. Debugging programs with multiple threads ΓòÉΓòÉΓòÉ
  1252.  
  1253. In some operating systems, a single program may have more than one thread of 
  1254. execution.  The precise semantics of threads differ from one operating system 
  1255. to another, but in general the threads of a single program are akin to multiple 
  1256. processes---except that they share one address space (that is, they can all 
  1257. examine and modify the same variables).  On the other hand, each thread has its 
  1258. own registers and execution stack, and perhaps private memory. 
  1259.  
  1260.  provides these facilities for debugging multi-thread programs: 
  1261.  
  1262.      automatic notification of new threads 
  1263.  
  1264.      `thread threadno', a command to switch among threads 
  1265.  
  1266.      `info threads', a command to inquire about existing threads 
  1267.  
  1268.      `thread apply [threadno] [all] args', a command to apply a command to a 
  1269.       list of threads 
  1270.  
  1271.      thread-specific breakpoints 
  1272.  
  1273.  Warning: These facilities are not yet available on every  configuration where 
  1274.  the operating system supports threads. If your  does not support threads, 
  1275.  these commands have no effect.  For example, a system without thread support 
  1276.  shows no output from `info threads', and always rejects the thread command, 
  1277.  like this: 
  1278.  
  1279.   () info threads
  1280.   () thread 1
  1281.   Thread ID 1 not known.  Use the "info threads" command to
  1282.   see the IDs of currently known threads.
  1283.  
  1284.  The  thread debugging facility allows you to observe all threads while your 
  1285.  program runs---but whenever  takes control, one thread in particular is always 
  1286.  the focus of debugging. This thread is called the current thread.  Debugging 
  1287.  commands show program information from the perspective of the current thread. 
  1288.  
  1289.  Whenever  detects a new thread in your program, it displays the target 
  1290.  system's identification for the thread with a message in the form `[New 
  1291.  systag]'.  systag is a thread identifier whose form varies depending on the 
  1292.  particular system.  For example, on LynxOS, you might see 
  1293.  
  1294.   [New process 35 thread 27]
  1295.  
  1296.  when  notices a new thread.  In contrast, on an SGI system, the systag is 
  1297.  simply something like `process 368', with no further qualifier. 
  1298.  
  1299.  For debugging purposes,  associates its own thread number---always a single 
  1300.  integer---with each thread in your program. 
  1301.  
  1302.  info threads 
  1303.            Display a summary of all threads currently in your program. 
  1304.            displays for each thread (in this order): 
  1305.  
  1306.              1. the thread number assigned by 
  1307.  
  1308.              2. the target system's thread identifier (systag) 
  1309.  
  1310.              3. the current stack frame summary for that thread 
  1311.  
  1312.            An asterisk `*' to the left of the  thread number indicates the 
  1313.            current thread. 
  1314.  
  1315.            For example, 
  1316.  
  1317.   () info threads
  1318.     3 process 35 thread 27  0x34e5 in sigpause ()
  1319.     2 process 35 thread 23  0x34e5 in sigpause ()
  1320.   * 1 process 35 thread 13  main (argc=1, argv=0x7ffffff8)
  1321.       at threadtest.c:68
  1322.  
  1323.  thread threadno 
  1324.            Make thread number threadno the current thread.  The command 
  1325.            argument threadno is the internal  thread number, as shown in the 
  1326.            first field of the `info threads' display.  responds by displaying 
  1327.            the system identifier of the thread you selected, and its current 
  1328.            stack frame summary: 
  1329.  
  1330.                       () thread 2
  1331.                       [Switching to process 35 thread 23]
  1332.                       0x34e5 in sigpause ()
  1333.  
  1334.            As with the `[New ...]' message, the form of the text after 
  1335.            `Switching to' depends on your system's conventions for identifying 
  1336.            threads. 
  1337.  
  1338.  thread apply [threadno] [all]  args 
  1339.            The thread apply command allows you to apply a command to one or 
  1340.            more threads.  Specify the numbers of the threads that you want 
  1341.            affected with the command argument threadno.  threadno is the 
  1342.            internal  thread number, as shown in the first field of the `info 
  1343.            threads' display.  To apply a command to all threads, use thread 
  1344.            apply all args. 
  1345.  
  1346.  Whenever  stops your program, due to a breakpoint or a signal, it 
  1347.  automatically selects the thread where that breakpoint or signal happened. 
  1348.  alerts you to the context switch with a message of the form `[Switching to 
  1349.  systag]' to identify the thread. 
  1350.  
  1351.  See Stopping and starting multi-thread programs, for more information about 
  1352.  how  behaves when you stop and start programs with multiple threads. 
  1353.  
  1354.  See Setting watchpoints, for information about watchpoints in programs with 
  1355.  multiple threads. 
  1356.  
  1357.  
  1358. ΓòÉΓòÉΓòÉ 7.11. Debugging programs with multiple processes ΓòÉΓòÉΓòÉ
  1359.  
  1360.  has no special support for debugging programs which create additional 
  1361. processes using the fork function.  When a program forks,  will continue to 
  1362. debug the parent process and the child process will run unimpeded.  If you have 
  1363. set a breakpoint in any code which the child then executes, the child will get 
  1364. a SIGTRAP signal which (unless it catches the signal) will cause it to 
  1365. terminate. 
  1366.  
  1367. However, if you want to debug the child process there is a workaround which 
  1368. isn't too painful.  Put a call to sleep in the code which the child process 
  1369. executes after the fork.  It may be useful to sleep only if a certain 
  1370. environment variable is set, or a certain file exists, so that the delay need 
  1371. not occur when you don't want to run on the child.  While the child is 
  1372. sleeping, use the ps program to get its process ID.  Then tell  (a new 
  1373. invocation of  if you are also debugging the parent process) to attach to the 
  1374. child process (see Attach).  From that point on you can debug the child process 
  1375. just like any other process which you attached to. 
  1376.  
  1377.  
  1378. ΓòÉΓòÉΓòÉ 8. Stopping and Continuing ΓòÉΓòÉΓòÉ
  1379.  
  1380. The principal purposes of using a debugger are so that you can stop your 
  1381. program before it terminates; or so that, if your program runs into trouble, 
  1382. you can investigate and find out why. 
  1383.  
  1384. Inside , your program may stop for any of several reasons, such as a signal, a 
  1385. breakpoint, or reaching a new line after a command such as step.  You may then 
  1386. examine and change variables, set new breakpoints or remove old ones, and then 
  1387. continue execution.  Usually, the messages shown by  provide ample explanation 
  1388. of the status of your program---but you can also explicitly request this 
  1389. information at any time. 
  1390.  
  1391.  info program 
  1392.            Display information about the status of your program: whether it is 
  1393.            running or not, what process it is, and why it stopped. 
  1394.  
  1395.  Breakpoints                             Breakpoints, watchpoints, and 
  1396.                                          exceptions 
  1397.  
  1398.  Breakpoints                             Breakpoints and watchpoints 
  1399.  
  1400.  Continuing and Stepping                 Resuming execution 
  1401.  
  1402.  Signals                                 Signals 
  1403.  
  1404.  Thread Stops                            Stopping and starting multi-thread 
  1405.                                          programs 
  1406.  
  1407.  
  1408. ΓòÉΓòÉΓòÉ 8.1. Breakpoints, watchpoints, and exceptions ΓòÉΓòÉΓòÉ
  1409.  
  1410. A breakpoint makes your program stop whenever a certain point in the program is 
  1411. reached.  For each breakpoint, you can add conditions to control in finer 
  1412. detail whether your program stops. You can set breakpoints with the break 
  1413. command and its variants (see Setting breakpoints), to specify the place where 
  1414. your program should stop by line number, function name or exact address in the 
  1415. program. In languages with exception handling (such as gnu C++), you can also 
  1416. set breakpoints where an exception is raised ( see Breakpoints and exceptions). 
  1417.  
  1418. In SunOS 4.x, SVR4, and Alpha OSF/1 configurations, you can now set breakpoints 
  1419. in shared libraries before the executable is run. 
  1420.  
  1421. A watchpoint is a special breakpoint that stops your program when the value of 
  1422. an expression changes.  You must use a different command to set watchpoints ( 
  1423. see Setting watchpoints), but aside from that, you can manage a watchpoint like 
  1424. any other breakpoint: you enable, disable, and delete both breakpoints and 
  1425. watchpoints using the same commands. 
  1426.  
  1427. You can arrange to have values from your program displayed automatically 
  1428. whenever  stops at a breakpoint. See Automatic display. 
  1429.  
  1430.  assigns a number to each breakpoint or watchpoint when you create it; these 
  1431. numbers are successive integers starting with one.  In many of the commands for 
  1432. controlling various features of breakpoints you use the breakpoint number to 
  1433. say which breakpoint you want to change. Each breakpoint may be enabled or 
  1434. disabled; if disabled, it has no effect on your program until you enable it 
  1435. again. 
  1436.  
  1437.  Set Breaks                              Setting breakpoints 
  1438.  Set Watchpoints                         Setting watchpoints 
  1439.  
  1440.  Exception Handling                      Breakpoints and exceptions 
  1441.  
  1442.  Delete Breaks                           Deleting breakpoints 
  1443.  Disabling                               Disabling breakpoints 
  1444.  Conditions                              Break conditions 
  1445.  Break Commands                          Breakpoint command lists 
  1446.  
  1447.  Breakpoint Menus                        Breakpoint menus 
  1448.  
  1449.  
  1450. ΓòÉΓòÉΓòÉ 8.1.1. Setting breakpoints ΓòÉΓòÉΓòÉ
  1451.  
  1452. Breakpoints are set with the break command (abbreviated b).  The debugger 
  1453. convenience variable `$bpnum' records the number of the breakpoints you've set 
  1454. most recently; see Convenience variables, for a discussion of what you can do 
  1455. with convenience variables. 
  1456.  
  1457. You have several ways to say where the breakpoint should go. 
  1458.  
  1459.  break function 
  1460.            Set a breakpoint at entry to function function. When using source 
  1461.            languages that permit overloading of symbols, such as C++, function 
  1462.            may refer to more than one possible place to break. See Breakpoint 
  1463.            menus, for a discussion of that situation. 
  1464.  
  1465.  break +offset 
  1466.  break -offset 
  1467.            Set a breakpoint some number of lines forward or back from the 
  1468.            position at which execution stopped in the currently selected frame. 
  1469.  
  1470.  break linenum 
  1471.            Set a breakpoint at line linenum in the current source file. That 
  1472.            file is the last file whose source text was printed.  This 
  1473.            breakpoint stops your program just before it executes any of the 
  1474.            code on that line. 
  1475.  
  1476.  break filename:linenum 
  1477.            Set a breakpoint at line linenum in source file filename. 
  1478.  
  1479.  break filename:function 
  1480.            Set a breakpoint at entry to function function found in file 
  1481.            filename.  Specifying a file name as well as a function name is 
  1482.            superfluous except when multiple files contain similarly named 
  1483.            functions. 
  1484.  
  1485.  break *address 
  1486.            Set a breakpoint at address address.  You can use this to set 
  1487.            breakpoints in parts of your program which do not have debugging 
  1488.            information or source files. 
  1489.  
  1490.  break 
  1491.            When called without any arguments, break sets a breakpoint at the 
  1492.            next instruction to be executed in the selected stack frame (see 
  1493.            Examining the Stack).  In any selected frame but the innermost, this 
  1494.            makes your program stop as soon as control returns to that frame. 
  1495.            This is similar to the effect of a finish command in the frame 
  1496.            inside the selected frame---except that finish does not leave an 
  1497.            active breakpoint.  If you use break without an argument in the 
  1498.            innermost frame,  stops the next time it reaches the current 
  1499.            location; this may be useful inside loops. 
  1500.  
  1501.             normally ignores breakpoints when it resumes execution, until at 
  1502.            least one instruction has been executed.  If it did not do this, you 
  1503.            would be unable to proceed past a breakpoint without first disabling 
  1504.            the breakpoint.  This rule applies whether or not the breakpoint 
  1505.            already existed when your program stopped. 
  1506.  
  1507.  break ... if cond 
  1508.            Set a breakpoint with condition cond; evaluate the expression cond 
  1509.            each time the breakpoint is reached, and stop only if the value is 
  1510.            nonzero---that is, if cond evaluates as true. `...' stands for one 
  1511.            of the possible arguments described above (or no argument) 
  1512.            specifying where to break. See Break conditions, for more 
  1513.            information on breakpoint conditions. 
  1514.  
  1515.  tbreak args 
  1516.            Set a breakpoint enabled only for one stop.  args are the same as 
  1517.            for the break command, and the breakpoint is set in the same way, 
  1518.            but the breakpoint is automatically deleted after the first time 
  1519.            your program stops there.  See Disabling breakpoints. 
  1520.  
  1521.  hbreak args 
  1522.            Set a hardware-assisted breakpoint.  args are the same as for the 
  1523.            break command and the breakpoint is set in the same way, but the 
  1524.            breakpoint requires hardware support and some target hardware may 
  1525.            not have this support.  The main purpose of this is EPROM/ROM code 
  1526.            debugging, so you can set a breakpoint at an instruction without 
  1527.            changing the instruction.  This can be used with the new 
  1528.            trap-generation provided by SPARClite DSU.  DSU will generate traps 
  1529.            when a program accesses some date or instruction address that is 
  1530.            assigned to the debug registers. However the hardware breakpoint 
  1531.            registers can only take two data breakpoints, and  will reject this 
  1532.            command if more than two are used. Delete or disable usused hardware 
  1533.            breakpoints before setting new ones.  See Break conditions. 
  1534.  
  1535.  thbreak args 
  1536.            Set a hardware-assisted breakpoint enabled only for one stop.  args 
  1537.            are the same as for the hbreak command and the breakpoint is set in 
  1538.            the same way.  However, like the tbreak command, the breakpoint is 
  1539.            automatically deleted after the first time your program stops there. 
  1540.            Also, like the hbreak command, the breakpoint requires hardware 
  1541.            support and some target hardware may not have this support.  See 
  1542.            Disabling breakpoints. Also See Break conditions. 
  1543.  
  1544.  rbreak regex 
  1545.            Set breakpoints on all functions matching the regular expression 
  1546.            regex.  This command sets an unconditional breakpoint on all 
  1547.            matches, printing a list of all breakpoints it set.  Once these 
  1548.            breakpoints are set, they are treated just like the breakpoints set 
  1549.            with the break command.  You can delete them, disable them, or make 
  1550.            them conditional the same way as any other breakpoint. 
  1551.  
  1552.            When debugging C++ programs, rbreak is useful for setting 
  1553.            breakpoints on overloaded functions that are not members of any 
  1554.            special classes. 
  1555.  
  1556.  info breakpoints [n] 
  1557.  info break [n] 
  1558.  info watchpoints [n] 
  1559.            Print a table of all breakpoints and watchpoints set and not 
  1560.            deleted, with the following columns for each breakpoint: 
  1561.  
  1562.            Breakpoint Numbers 
  1563.  
  1564.            Type 
  1565.                           Breakpoint or watchpoint. 
  1566.  
  1567.            Disposition 
  1568.                           Whether the breakpoint is marked to be disabled or 
  1569.                           deleted when hit. 
  1570.  
  1571.            Enabled or Disabled 
  1572.                           Enabled breakpoints are marked with `y'.  `n' marks 
  1573.                           breakpoints that are not enabled. 
  1574.  
  1575.            Address 
  1576.                           Where the breakpoint is in your program, as a memory 
  1577.                           address 
  1578.  
  1579.            What 
  1580.                           Where the breakpoint is in the source for your 
  1581.                           program, as a file and line number. 
  1582.  
  1583.            If a breakpoint is conditional, info break shows the condition on 
  1584.            the line following the affected breakpoint; breakpoint commands, if 
  1585.            any, are listed after that. 
  1586.  
  1587.            info break with a breakpoint number n as argument lists only that 
  1588.            breakpoint.  The convenience variable $_ and the default 
  1589.            examining-address for the x command are set to the address of the 
  1590.            last breakpoint listed (see Examining memory). 
  1591.  
  1592.            info break now displays a count of the number of times the 
  1593.            breakpoint has been hit.  This is especially useful in conjunction 
  1594.            with the ignore command.  You can ignore a large number of 
  1595.            breakpoint hits, look at the breakpoint info to see how many times 
  1596.            the breakpoint was hit, and then run again, ignoring one less than 
  1597.            that number.  This will get you quickly to the last hit of that 
  1598.            breakpoint. 
  1599.  
  1600.   allows you to set any number of breakpoints at the same place in your 
  1601.  program.  There is nothing silly or meaningless about this.  When the 
  1602.  breakpoints are conditional, this is even useful (see Break conditions). 
  1603.  
  1604.   itself sometimes sets breakpoints in your program for special purposes, such 
  1605.  as proper handling of longjmp (in C programs). These internal breakpoints are 
  1606.  assigned negative numbers, starting with -1; `info breakpoints' does not 
  1607.  display them. 
  1608.  
  1609.  You can see these breakpoints with the  maintenance command `maint info 
  1610.  breakpoints'. 
  1611.  
  1612.  maint info breakpoints 
  1613.            Using the same format as `info breakpoints', display both the 
  1614.            breakpoints you've set explicitly, and those  is using for internal 
  1615.            purposes.  Internal breakpoints are shown with negative breakpoint 
  1616.            numbers.  The type column identifies what kind of breakpoint is 
  1617.            shown: 
  1618.  
  1619.            breakpoint 
  1620.                           Normal, explicitly set breakpoint. 
  1621.  
  1622.            watchpoint 
  1623.                           Normal, explicitly set watchpoint. 
  1624.  
  1625.            longjmp 
  1626.                           Internal breakpoint, used to handle correctly 
  1627.                           stepping through longjmp calls. 
  1628.  
  1629.            longjmp resume 
  1630.                           Internal breakpoint at the target of a longjmp. 
  1631.  
  1632.            until 
  1633.                           Temporary internal breakpoint used by the  until 
  1634.                           command. 
  1635.  
  1636.            finish 
  1637.                           Temporary internal breakpoint used by the  finish 
  1638.                           command. 
  1639.  
  1640.  
  1641. ΓòÉΓòÉΓòÉ 8.1.2. Setting watchpoints ΓòÉΓòÉΓòÉ
  1642.  
  1643. You can use a watchpoint to stop execution whenever the value of an expression 
  1644. changes, without having to predict a particular place where this may happen. 
  1645.  
  1646. Watchpoints currently execute two orders of magnitude more slowly than other 
  1647. breakpoints, but this can be well worth it to catch errors where you have no 
  1648. clue what part of your program is the culprit. 
  1649.  
  1650.  watch expr 
  1651.            Set a watchpoint for an expression.  will break when expr is written 
  1652.            into by the program and its value changes. This can be used with the 
  1653.            new trap-generation provided by SPARClite DSU.  DSU will generate 
  1654.            traps when a program accesses some date or instruction address that 
  1655.            is assigned to the debug registers. For the data addresses, DSU 
  1656.            facilitates the watch command. However the hardware breakpoint 
  1657.            registers can only take two data watchpoints, and both watchpoints 
  1658.            must be the same kind.  For example, you can set two watchpoints 
  1659.            with watch commands, two with rwatch commands, *or* two with awatch 
  1660.            commands, but you cannot set one watchpoint with one command and the 
  1661.            other with a different command.  will reject the command if you try 
  1662.            to mix watchpoints. Delete or disable unused watchpoint commands 
  1663.            before setting new ones. 
  1664.  
  1665.  rwatch expr 
  1666.            Set a watchpoint that will break when watch args is read by the 
  1667.            program. If you use both watchpoints, both must be set with the 
  1668.            rwatch command. 
  1669.  
  1670.  awatch expr 
  1671.            Set a watchpoint that will break when args is read and written into 
  1672.            by the program.  If you use both watchpoints, both must be set with 
  1673.            the awatch command. 
  1674.  
  1675.  info watchpoints 
  1676.            This command prints a list of watchpoints and breakpoints; it is the 
  1677.            same as info break. 
  1678.  
  1679.  Warning: in multi-thread programs, watchpoints have only limited usefulness. 
  1680.  With the current watchpoint implementation, can only watch the value of an 
  1681.  expression in a single thread.  If you are confident that the expression can 
  1682.  only change due to the current thread's activity (and if you are also 
  1683.  confident that no other thread can become current), then you can use 
  1684.  watchpoints as usual.  However,  may not notice when a non-current thread's 
  1685.  activity changes the expression. 
  1686.  
  1687.  
  1688. ΓòÉΓòÉΓòÉ 8.1.3. Breakpoints and exceptions ΓòÉΓòÉΓòÉ
  1689.  
  1690. Some languages, such as gnu C++, implement exception handling.  You can use  to 
  1691. examine what caused your program to raise an exception, and to list the 
  1692. exceptions your program is prepared to handle at a given point in time. 
  1693.  
  1694.  catch exceptions 
  1695.            You can set breakpoints at active exception handlers by using the 
  1696.            catch command.  exceptions is a list of names of exceptions to 
  1697.            catch. 
  1698.  
  1699.  You can use info catch to list active exception handlers. See Information 
  1700.  about a frame. 
  1701.  
  1702.  There are currently some limitations to exception handling in : 
  1703.  
  1704.      If you call a function interactively,  normally returns control to you 
  1705.       when the function has finished executing.  If the call raises an 
  1706.       exception, however, the call may bypass the mechanism that returns 
  1707.       control to you and cause your program to simply continue running until it 
  1708.       hits a breakpoint, catches a signal that  is listening for, or exits. 
  1709.  
  1710.      You cannot raise an exception interactively. 
  1711.  
  1712.      You cannot install an exception handler interactively. 
  1713.  
  1714.  Sometimes catch is not the best way to debug exception handling: if you need 
  1715.  to know exactly where an exception is raised, it is better to stop before the 
  1716.  exception handler is called, since that way you can see the stack before any 
  1717.  unwinding takes place.  If you set a breakpoint in an exception handler 
  1718.  instead, it may not be easy to find out where the exception was raised. 
  1719.  
  1720.  To stop just before an exception handler is called, you need some knowledge of 
  1721.  the implementation.  In the case of gnu C++, exceptions are raised by calling 
  1722.  a library function named __raise_exception which has the following ANSI C 
  1723.  interface: 
  1724.  
  1725.       /* addr is where the exception identifier is stored.
  1726.          ID is the exception identifier.  */
  1727.       void __raise_exception (void **addr, void *id);
  1728.  
  1729.  To make the debugger catch all exceptions before any stack unwinding takes 
  1730.  place, set a breakpoint on __raise_exception (see Breakpoints; watchpoints; 
  1731.  and exceptions). 
  1732.  
  1733.  With a conditional breakpoint (see Break conditions) that depends on the value 
  1734.  of id, you can stop your program when a specific exception is raised.  You can 
  1735.  use multiple conditional breakpoints to stop your program when any of a number 
  1736.  of exceptions are raised. 
  1737.  
  1738.  
  1739. ΓòÉΓòÉΓòÉ 8.1.4. Deleting breakpoints ΓòÉΓòÉΓòÉ
  1740.  
  1741. It is often necessary to eliminate a breakpoint or watchpoint once it has done 
  1742. its job and you no longer want your program to stop there.  This is called 
  1743. deleting the breakpoint.  A breakpoint that has been deleted no longer exists; 
  1744. it is forgotten. 
  1745.  
  1746. With the clear command you can delete breakpoints according to where they are 
  1747. in your program.  With the delete command you can delete individual breakpoints 
  1748. or watchpoints by specifying their breakpoint numbers. 
  1749.  
  1750. It is not necessary to delete a breakpoint to proceed past it. automatically 
  1751. ignores breakpoints on the first instruction to be executed when you continue 
  1752. execution without changing the execution address. 
  1753.  
  1754.  clear 
  1755.            Delete any breakpoints at the next instruction to be executed in the 
  1756.            selected stack frame (see Selecting a frame).  When the innermost 
  1757.            frame is selected, this is a good way to delete a breakpoint where 
  1758.            your program just stopped. 
  1759.  
  1760.  clear function 
  1761.  clear filename:function 
  1762.            Delete any breakpoints set at entry to the function function. 
  1763.  
  1764.  clear linenum 
  1765.  clear filename:linenum 
  1766.            Delete any breakpoints set at or within the code of the specified 
  1767.            line. 
  1768.  
  1769.  delete [breakpoints] [bnums...] 
  1770.            Delete the breakpoints or watchpoints of the numbers specified as 
  1771.            arguments.  If no argument is specified, delete all breakpoints ( 
  1772.            asks confirmation, unless you have set confirm off).  You can 
  1773.            abbreviate this command as d. 
  1774.  
  1775.  
  1776. ΓòÉΓòÉΓòÉ 8.1.5. Disabling breakpoints ΓòÉΓòÉΓòÉ
  1777.  
  1778. Rather than deleting a breakpoint or watchpoint, you might prefer to disable 
  1779. it.  This makes the breakpoint inoperative as if it had been deleted, but 
  1780. remembers the information on the breakpoint so that you can enable it again 
  1781. later. 
  1782.  
  1783. You disable and enable breakpoints and watchpoints with the enable and disable 
  1784. commands, optionally specifying one or more breakpoint numbers as arguments. 
  1785. Use info break or info watch to print a list of breakpoints or watchpoints if 
  1786. you do not know which numbers to use. 
  1787.  
  1788. A breakpoint or watchpoint can have any of four different states of enablement: 
  1789.  
  1790.      Enabled.  The breakpoint stops your program.  A breakpoint set with the 
  1791.       break command starts out in this state. 
  1792.  
  1793.      Disabled.  The breakpoint has no effect on your program. 
  1794.  
  1795.      Enabled once.  The breakpoint stops your program, but then becomes 
  1796.       disabled.  A breakpoint set with the tbreak command starts out in this 
  1797.       state. 
  1798.  
  1799.      Enabled for deletion.  The breakpoint stops your program, but immediately 
  1800.       after it does so it is deleted permanently. 
  1801.  
  1802.  You can use the following commands to enable or disable breakpoints and 
  1803.  watchpoints: 
  1804.  
  1805.  disable [breakpoints] [bnums...] 
  1806.            Disable the specified breakpoints---or all breakpoints, if none are 
  1807.            listed.  A disabled breakpoint has no effect but is not forgotten. 
  1808.            All options such as ignore-counts, conditions and commands are 
  1809.            remembered in case the breakpoint is enabled again later.  You may 
  1810.            abbreviate disable as dis. 
  1811.  
  1812.  enable [breakpoints] [bnums...] 
  1813.            Enable the specified breakpoints (or all defined breakpoints).  They 
  1814.            become effective once again in stopping your program. 
  1815.  
  1816.  enable [breakpoints] once bnums... 
  1817.            Enable the specified breakpoints temporarily.  disables any of these 
  1818.            breakpoints immediately after stopping your program. 
  1819.  
  1820.  enable [breakpoints] delete bnums... 
  1821.            Enable the specified breakpoints to work once, then die. deletes any 
  1822.            of these breakpoints as soon as your program stops there. 
  1823.  
  1824.  Except for a breakpoint set with tbreak ( see Setting breakpoints), 
  1825.  breakpoints that you set are initially enabled; subsequently, they become 
  1826.  disabled or enabled only when you use one of the commands above.  (The command 
  1827.  until can set and delete a breakpoint of its own, but it does not change the 
  1828.  state of your other breakpoints; see Continuing and stepping.) 
  1829.  
  1830.  
  1831. ΓòÉΓòÉΓòÉ 8.1.6. Break conditions ΓòÉΓòÉΓòÉ
  1832.  
  1833. The simplest sort of breakpoint breaks every time your program reaches a 
  1834. specified place.  You can also specify a condition for a breakpoint.  A 
  1835. condition is just a Boolean expression in your programming language (see 
  1836. Expressions).  A breakpoint with a condition evaluates the expression each time 
  1837. your program reaches it, and your program stops only if the condition is true. 
  1838.  
  1839. This is the converse of using assertions for program validation; in that 
  1840. situation, you want to stop when the assertion is violated---that is, when the 
  1841. condition is false.  In C, if you want to test an assertion expressed by the 
  1842. condition assert, you should set the condition `! assert' on the appropriate 
  1843. breakpoint. 
  1844.  
  1845. Conditions are also accepted for watchpoints; you may not need them, since a 
  1846. watchpoint is inspecting the value of an expression anyhow---but it might be 
  1847. simpler, say, to just set a watchpoint on a variable name, and specify a 
  1848. condition that tests whether the new value is an interesting one. 
  1849.  
  1850. Break conditions can have side effects, and may even call functions in your 
  1851. program.  This can be useful, for example, to activate functions that log 
  1852. program progress, or to use your own print functions to format special data 
  1853. structures. The effects are completely predictable unless there is another 
  1854. enabled breakpoint at the same address.  (In that case,  might see the other 
  1855. breakpoint first and stop your program without checking the condition of this 
  1856. one.)  Note that breakpoint commands are usually more convenient and flexible 
  1857. for the purpose of performing side effects when a breakpoint is reached (see 
  1858. Breakpoint command lists). 
  1859.  
  1860. Break conditions can be specified when a breakpoint is set, by using `if' in 
  1861. the arguments to the break command. See Setting breakpoints.  They can also be 
  1862. changed at any time with the condition command.  The watch command does not 
  1863. recognize the if keyword; condition is the only way to impose a further 
  1864. condition on a watchpoint. 
  1865.  
  1866.  condition bnum expression 
  1867.            Specify expression as the break condition for breakpoint or 
  1868.            watchpoint number bnum.  After you set a condition, breakpoint bnum 
  1869.            stops your program only if the value of expression is true (nonzero, 
  1870.            in C).  When you use condition, checks expression immediately for 
  1871.            syntactic correctness, and to determine whether symbols in it have 
  1872.            referents in the context of your breakpoint.  does not actually 
  1873.            evaluate expression at the time the condition command is given, 
  1874.            however.  See Expressions. 
  1875.  
  1876.  condition bnum 
  1877.            Remove the condition from breakpoint number bnum.  It becomes an 
  1878.            ordinary unconditional breakpoint. 
  1879.  
  1880.  A special case of a breakpoint condition is to stop only when the breakpoint 
  1881.  has been reached a certain number of times.  This is so useful that there is a 
  1882.  special way to do it, using the ignore count of the breakpoint.  Every 
  1883.  breakpoint has an ignore count, which is an integer.  Most of the time, the 
  1884.  ignore count is zero, and therefore has no effect.  But if your program 
  1885.  reaches a breakpoint whose ignore count is positive, then instead of stopping, 
  1886.  it just decrements the ignore count by one and continues.  As a result, if the 
  1887.  ignore count value is n, the breakpoint does not stop the next n times your 
  1888.  program reaches it. 
  1889.  
  1890.  ignore bnum count 
  1891.            Set the ignore count of breakpoint number bnum to count. The next 
  1892.            count times the breakpoint is reached, your program's execution does 
  1893.            not stop; other than to decrement the ignore count, takes no action. 
  1894.  
  1895.            To make the breakpoint stop the next time it is reached, specify a 
  1896.            count of zero. 
  1897.  
  1898.            When you use continue to resume execution of your program from a 
  1899.            breakpoint, you can specify an ignore count directly as an argument 
  1900.            to continue, rather than using ignore. See Continuing and stepping. 
  1901.  
  1902.            If a breakpoint has a positive ignore count and a condition, the 
  1903.            condition is not checked.  Once the ignore count reaches zero, 
  1904.            resumes checking the condition. 
  1905.  
  1906.            You could achieve the effect of the ignore count with a condition 
  1907.            such as `$foo-- <= 0' using a debugger convenience variable that is 
  1908.            decremented each time. See Convenience variables. 
  1909.  
  1910.  
  1911. ΓòÉΓòÉΓòÉ 8.1.7. Breakpoint command lists ΓòÉΓòÉΓòÉ
  1912.  
  1913. You can give any breakpoint (or watchpoint) a series of commands to execute 
  1914. when your program stops due to that breakpoint.  For example, you might want to 
  1915. print the values of certain expressions, or enable other breakpoints. 
  1916.  
  1917.  commands [bnum] 
  1918.  ... command-list ... 
  1919.  end 
  1920.            Specify a list of commands for breakpoint number bnum.  The commands 
  1921.            themselves appear on the following lines.  Type a line containing 
  1922.            just end to terminate the commands. 
  1923.  
  1924.            To remove all commands from a breakpoint, type commands and follow 
  1925.            it immediately with end; that is, give no commands. 
  1926.  
  1927.            With no bnum argument, commands refers to the last breakpoint or 
  1928.            watchpoint set (not to the breakpoint most recently encountered). 
  1929.  
  1930.  Pressing RET as a means of repeating the last  command is disabled within a 
  1931.  command-list. 
  1932.  
  1933.  You can use breakpoint commands to start your program up again.  Simply use 
  1934.  the continue command, or step, or any other command that resumes execution. 
  1935.  
  1936.  Any other commands in the command list, after a command that resumes 
  1937.  execution, are ignored.  This is because any time you resume execution (even 
  1938.  with a simple next or step), you may encounter another breakpoint---which 
  1939.  could have its own command list, leading to ambiguities about which list to 
  1940.  execute. 
  1941.  
  1942.  If the first command you specify in a command list is silent, the usual 
  1943.  message about stopping at a breakpoint is not printed.  This may be desirable 
  1944.  for breakpoints that are to print a specific message and then continue.  If 
  1945.  none of the remaining commands print anything, you see no sign that the 
  1946.  breakpoint was reached.  silent is meaningful only at the beginning of a 
  1947.  breakpoint command list. 
  1948.  
  1949.  The commands echo, output, and printf allow you to print precisely controlled 
  1950.  output, and are often useful in silent breakpoints.  See Commands for 
  1951.  controlled output. 
  1952.  
  1953.  For example, here is how you could use breakpoint commands to print the value 
  1954.  of x at entry to foo whenever x is positive. 
  1955.  
  1956.   break foo if x>0
  1957.   commands
  1958.   silent
  1959.   printf "x is %d\n",x
  1960.   cont
  1961.   end
  1962.  
  1963.  One application for breakpoint commands is to compensate for one bug so you 
  1964.  can test for another.  Put a breakpoint just after the erroneous line of code, 
  1965.  give it a condition to detect the case in which something erroneous has been 
  1966.  done, and give it commands to assign correct values to any variables that need 
  1967.  them.  End with the continue command so that your program does not stop, and 
  1968.  start with the silent command so that no output is produced.  Here is an 
  1969.  example: 
  1970.  
  1971.   break 403
  1972.   commands
  1973.   silent
  1974.   set x = y + 4
  1975.   cont
  1976.   end
  1977.  
  1978.  
  1979. ΓòÉΓòÉΓòÉ 8.1.8. Breakpoint menus ΓòÉΓòÉΓòÉ
  1980.  
  1981. Some programming languages (notably C++) permit a single function name to be 
  1982. defined several times, for application in different contexts. This is called 
  1983. overloading.  When a function name is overloaded, `break function' is not 
  1984. enough to tell  where you want a breakpoint.  If you realize this is a problem, 
  1985. you can use something like `break function(types)' to specify which particular 
  1986. version of the function you want.  Otherwise,  offers you a menu of numbered 
  1987. choices for different possible breakpoints, and waits for your selection with 
  1988. the prompt `>'.  The first two options are always `[0] cancel' and `[1] all'. 
  1989. Typing 1 sets a breakpoint at each definition of function, and typing 0 aborts 
  1990. the break command without setting any new breakpoints. 
  1991.  
  1992. For example, the following session excerpt shows an attempt to set a breakpoint 
  1993. at the overloaded symbol String::after. We choose three particular definitions 
  1994. of that function name: 
  1995.  
  1996. () b String::after
  1997. [0] cancel
  1998. [1] all
  1999. [2] file:String.cc; line number:867
  2000. [3] file:String.cc; line number:860
  2001. [4] file:String.cc; line number:875
  2002. [5] file:String.cc; line number:853
  2003. [6] file:String.cc; line number:846
  2004. [7] file:String.cc; line number:735
  2005. > 2 4 6
  2006. Breakpoint 1 at 0xb26c: file String.cc, line 867.
  2007. Breakpoint 2 at 0xb344: file String.cc, line 875.
  2008. Breakpoint 3 at 0xafcc: file String.cc, line 846.
  2009. Multiple breakpoints were set.
  2010. Use the "delete" command to delete unwanted
  2011.  breakpoints.
  2012. ()
  2013.  
  2014.  
  2015. ΓòÉΓòÉΓòÉ 8.2. Continuing and stepping ΓòÉΓòÉΓòÉ
  2016.  
  2017. Continuing means resuming program execution until your program completes 
  2018. normally.  In contrast, stepping means executing just one more ``step'' of your 
  2019. program, where ``step'' may mean either one line of source code, or one machine 
  2020. instruction (depending on what particular command you use).  Either when 
  2021. continuing or when stepping, your program may stop even sooner, due to a 
  2022. breakpoint or a signal.  (If due to a signal, you may want to use handle, or 
  2023. use `signal 0' to resume execution. See Signals.) 
  2024.  
  2025.  continue [ignore-count] 
  2026.  c [ignore-count] 
  2027.  fg [ignore-count] 
  2028.            Resume program execution, at the address where your program last 
  2029.            stopped; any breakpoints set at that address are bypassed.  The 
  2030.            optional argument ignore-count allows you to specify a further 
  2031.            number of times to ignore a breakpoint at this location; its effect 
  2032.            is like that of ignore (see Break conditions). 
  2033.  
  2034.            The argument ignore-count is meaningful only when your program 
  2035.            stopped due to a breakpoint.  At other times, the argument to 
  2036.            continue is ignored. 
  2037.  
  2038.            The synonyms c and fg are provided purely for convenience, and have 
  2039.            exactly the same behavior as continue. 
  2040.  
  2041.  To resume execution at a different place, you can use return (see Returning 
  2042.  from a function) to go back to the calling function; or jump ( see Continuing 
  2043.  at a different address) to go to an arbitrary location in your program. 
  2044.  
  2045.  A typical technique for using stepping is to set a breakpoint (see 
  2046.  Breakpoints; watchpoints; and exceptions) at the beginning of the function or 
  2047.  the section of your program where a problem is believed to lie, run your 
  2048.  program until it stops at that breakpoint, and then step through the suspect 
  2049.  area, examining the variables that are interesting, until you see the problem 
  2050.  happen. 
  2051.  
  2052.  step 
  2053.            Continue running your program until control reaches a different 
  2054.            source line, then stop it and return control to .  This command is 
  2055.            abbreviated s. 
  2056.  
  2057.            Warning: If you use the step command while control is within a 
  2058.            function that was compiled without debugging information, execution 
  2059.            proceeds until control reaches a function that does have debugging 
  2060.            information.  Likewise, it will not step into a function which is 
  2061.            compiled without debugging information.  To step through functions 
  2062.            without debugging information, use the stepi command, described 
  2063.            below. 
  2064.  
  2065.            The step command now only stops at the first instruction of a source 
  2066.            line.  This prevents the multiple stops that used to occur in switch 
  2067.            statements, for loops, etc.  step continues to stop if a function 
  2068.            that has debugging information is called within the line. 
  2069.  
  2070.            Also, the step command now only enters a subroutine if there is line 
  2071.            number information for the subroutine.  Otherwise it acts like the 
  2072.            next command.  This avoids problems when using cc -gl on MIPS 
  2073.            machines.  Previously, step entered subroutines if there was any 
  2074.            debugging information about the routine. 
  2075.  
  2076.  step count 
  2077.            Continue running as in step, but do so count times.  If a breakpoint 
  2078.            is reached, or a signal not related to stepping occurs before count 
  2079.            steps, stepping stops right away. 
  2080.  
  2081.  next [count] 
  2082.            Continue to the next source line in the current (innermost) stack 
  2083.            frame. This is similar to step, but function calls that appear 
  2084.            within the line of code are executed without stopping.  Execution 
  2085.            stops when control reaches a different line of code at the original 
  2086.            stack level that was executing when you gave the next command.  This 
  2087.            command is abbreviated n. 
  2088.  
  2089.            An argument count is a repeat count, as for step. 
  2090.  
  2091.            The next command now only stops at the first instruction of a source 
  2092.            line.  This prevents the multiple stops that used to occur in swtch 
  2093.            statements, for loops, etc. 
  2094.  
  2095.  finish 
  2096.            Continue running until just after function in the selected stack 
  2097.            frame returns.  Print the returned value (if any). 
  2098.  
  2099.            Contrast this with the return command ( see Returning from a 
  2100.            function). 
  2101.            u 
  2102.  
  2103.  until 
  2104.            Continue running until a source line past the current line, in the 
  2105.            current stack frame, is reached.  This command is used to avoid 
  2106.            single stepping through a loop more than once.  It is like the next 
  2107.            command, except that when until encounters a jump, it automatically 
  2108.            continues execution until the program counter is greater than the 
  2109.            address of the jump. 
  2110.  
  2111.            This means that when you reach the end of a loop after single 
  2112.            stepping though it, until makes your program continue execution 
  2113.            until it exits the loop.  In contrast, a next command at the end of 
  2114.            a loop simply steps back to the beginning of the loop, which forces 
  2115.            you to step through the next iteration. 
  2116.  
  2117.            until always stops your program if it attempts to exit the current 
  2118.            stack frame. 
  2119.  
  2120.            until may produce somewhat counterintuitive results if the order of 
  2121.            machine code does not match the order of the source lines.  For 
  2122.            example, in the following excerpt from a debugging session, the f 
  2123.            (frame) command shows that execution is stopped at line 206; yet 
  2124.            when we use until, we get to line 195: 
  2125.  
  2126.                       () f
  2127.                       #0  main (argc=4, argv=0xf7fffae8) at m4.c:206
  2128.                       206                 expand_input();
  2129.                       () until
  2130.                       195             for ( ; argc > 0; NEXTARG) {
  2131.  
  2132.            This happened because, for execution efficiency, the compiler had 
  2133.            generated code for the loop closure test at the end, rather than the 
  2134.            start, of the loop---even though the test in a C for-loop is written 
  2135.            before the body of the loop.  The until command appeared to step 
  2136.            back to the beginning of the loop when it advanced to this 
  2137.            expression; however, it has not really gone to an earlier 
  2138.            statement---not in terms of the actual machine code. 
  2139.  
  2140.            until with no argument works by means of single instruction 
  2141.            stepping, and hence is slower than until with an argument. 
  2142.  
  2143.  until location 
  2144.  u location 
  2145.            Continue running your program until either the specified location is 
  2146.            reached, or the current stack frame returns.  location is any of the 
  2147.            forms of argument acceptable to break ( see Setting breakpoints). 
  2148.            This form of the command uses breakpoints, and hence is quicker than 
  2149.            until without an argument. 
  2150.  
  2151.  stepi 
  2152.  si 
  2153.            Execute one machine instruction, then stop and return to the 
  2154.            debugger. 
  2155.  
  2156.            It is often useful to do `display/i $pc' when stepping by machine 
  2157.            instructions.  This makes  automatically display the next 
  2158.            instruction to be executed, each time your program stops. See 
  2159.            Automatic display. 
  2160.  
  2161.            An argument is a repeat count, as in step. 
  2162.  
  2163.  nexti 
  2164.  ni 
  2165.            Execute one machine instruction, but if it is a function call, 
  2166.            proceed until the function returns. 
  2167.  
  2168.            An argument is a repeat count, as in next. 
  2169.  
  2170.  
  2171. ΓòÉΓòÉΓòÉ 8.3. Stopping and starting multi-thread programs ΓòÉΓòÉΓòÉ
  2172.  
  2173. When your program has multiple threads ( see Debugging programs with multiple 
  2174. threads), you can choose whether to set breakpoints on all threads, or on a 
  2175. particular thread. 
  2176.  
  2177.  break linespec thread threadno 
  2178.  break linespec thread threadno if ... 
  2179.            linespec specifies source lines; there are several ways of writing 
  2180.            them, but the effect is always to specify some source line. 
  2181.  
  2182.            Use the qualifier `thread threadno' with a breakpoint command to 
  2183.            specify that you only want  to stop the program when a particular 
  2184.            thread reaches this breakpoint.  threadno is one of the numeric 
  2185.            thread identifiers assigned by , shown in the first column of the 
  2186.            `info threads' display. 
  2187.  
  2188.            If you do not specify `thread threadno' when you set a breakpoint, 
  2189.            the breakpoint applies to all threads of your program. 
  2190.  
  2191.            You can use the thread qualifier on conditional breakpoints as well; 
  2192.            in this case, place `thread threadno' before the breakpoint 
  2193.            condition, like this: 
  2194.  
  2195.                       (gdb) break frik.c:13 thread 28 if bartab > lim
  2196.  
  2197.  Whenever your program stops under  for any reason, all threads of execution 
  2198.  stop, not just the current thread.  This allows you to examine the overall 
  2199.  state of the program, including switching between threads, without worrying 
  2200.  that things may change underfoot. 
  2201.  
  2202.  Conversely, whenever you restart the program, all threads start executing. 
  2203.  This is true even when single-stepping with commands like step or next. 
  2204.  
  2205.  In particular,  cannot single-step all threads in lockstep. Since thread 
  2206.  scheduling is up to your debugging target's operating system (not controlled 
  2207.  by ), other threads may execute more than one statement while the current 
  2208.  thread completes a single step.  Moreover, in general other threads stop in 
  2209.  the middle of a statement, rather than at a clean statement boundary, when the 
  2210.  program stops. 
  2211.  
  2212.  You might even find your program stopped in another thread after continuing or 
  2213.  even single-stepping.  This happens whenever some other thread runs into a 
  2214.  breakpoint, a signal, or an exception before the first thread completes 
  2215.  whatever you requested. 
  2216.  
  2217.  
  2218. ΓòÉΓòÉΓòÉ 9. Examining the Stack ΓòÉΓòÉΓòÉ
  2219.  
  2220. When your program has stopped, the first thing you need to know is where it 
  2221. stopped and how it got there. 
  2222.  
  2223. Each time your program performs a function call, information about the call is 
  2224. generated. That information includes the location of the call in your program, 
  2225. the arguments of the call, and the local variables of the function being 
  2226. called. The information is saved in a block of data called a stack frame. The 
  2227. stack frames are allocated in a region of memory called the call stack. 
  2228.  
  2229. When your program stops, the  commands for examining the stack allow you to see 
  2230. all of this information. 
  2231.  
  2232. One of the stack frames is selected by  and many  commands refer implicitly to 
  2233. the selected frame.  In particular, whenever you ask  for the value of a 
  2234. variable in your program, the value is found in the selected frame.  There are 
  2235. special  commands to select whichever frame you are interested in. See 
  2236. Selecting a frame. 
  2237.  
  2238. When your program stops,  automatically selects the currently executing frame 
  2239. and describes it briefly, similar to the frame command (see Information about a 
  2240. frame). 
  2241.  
  2242.  Frames                                  Stack frames 
  2243.  Backtrace                               Backtraces 
  2244.  Selection                               Selecting a frame 
  2245.  Frame Info                              Information on a frame 
  2246.  
  2247.  MIPS Stack                              MIPS machines and the function stack 
  2248.  
  2249.  
  2250. ΓòÉΓòÉΓòÉ 9.1. Stack frames ΓòÉΓòÉΓòÉ
  2251.  
  2252. The call stack is divided up into contiguous pieces called stack frames, or 
  2253. frames for short; each frame is the data associated with one call to one 
  2254. function.  The frame contains the arguments given to the function, the 
  2255. function's local variables, and the address at which the function is executing. 
  2256.  
  2257. When your program is started, the stack has only one frame, that of the 
  2258. function main.  This is called the initial frame or the outermost frame.  Each 
  2259. time a function is called, a new frame is made.  Each time a function returns, 
  2260. the frame for that function invocation is eliminated.  If a function is 
  2261. recursive, there can be many frames for the same function.  The frame for the 
  2262. function in which execution is actually occurring is called the innermost 
  2263. frame.  This is the most recently created of all the stack frames that still 
  2264. exist. 
  2265.  
  2266. Inside your program, stack frames are identified by their addresses.  A stack 
  2267. frame consists of many bytes, each of which has its own address; each kind of 
  2268. computer has a convention for choosing one byte whose address serves as the 
  2269. address of the frame.  Usually this address is kept in a register called the 
  2270. frame pointer register while execution is going on in that frame. 
  2271.  
  2272.  assigns numbers to all existing stack frames, starting with zero for the 
  2273. innermost frame, one for the frame that called it, and so on upward.  These 
  2274. numbers do not really exist in your program; they are assigned by  to give you 
  2275. a way of designating stack frames in  commands. 
  2276.  
  2277. Some compilers provide a way to compile functions so that they operate without 
  2278. stack frames.  (For example, the  option `-fomit-frame-pointer' generates 
  2279. functions without a frame.) This is occasionally done with heavily used library 
  2280. functions to save the frame setup time.  has limited facilities for dealing 
  2281. with these function invocations.  If the innermost function invocation has no 
  2282. stack frame,  nevertheless regards it as though it had a separate frame, which 
  2283. is numbered zero as usual, allowing correct tracing of the function call chain. 
  2284. However,  has no provision for frameless functions elsewhere in the stack. 
  2285.  
  2286.  frame args 
  2287.            The frame command allows you to move from one stack frame to 
  2288.            another, and to print the stack frame you select.  args may be 
  2289.            either the address of the frame or the stack frame number.  Without 
  2290.            an argument, frame prints the current stack frame. 
  2291.  
  2292.  select-frame 
  2293.            The select-frame command allows you to move from one stack frame to 
  2294.            another without printing the frame.  This is the silent version of 
  2295.            frame. 
  2296.  
  2297.  
  2298. ΓòÉΓòÉΓòÉ 9.2. Backtraces ΓòÉΓòÉΓòÉ
  2299.  
  2300. A backtrace is a summary of how your program got where it is.  It shows one 
  2301. line per frame, for many frames, starting with the currently executing frame 
  2302. (frame zero), followed by its caller (frame one), and on up the stack. 
  2303.  
  2304.  backtrace 
  2305.  bt 
  2306.            Print a backtrace of the entire stack: one line per frame for all 
  2307.            frames in the stack. 
  2308.  
  2309.            You can stop the backtrace at any time by typing the system 
  2310.            interrupt character, normally C-c. 
  2311.  
  2312.  backtrace n 
  2313.  bt n 
  2314.            Similar, but print only the innermost n frames. 
  2315.  
  2316.  backtrace -n 
  2317.  bt -n 
  2318.            Similar, but print only the outermost n frames. 
  2319.  
  2320.  The names where and info stack (abbreviated info s) are additional aliases for 
  2321.  backtrace. 
  2322.  
  2323.  Each line in the backtrace shows the frame number and the function name. The 
  2324.  program counter value is also shown---unless you use set print address off. 
  2325.  The backtrace also shows the source file name and line number, as well as the 
  2326.  arguments to the function.  The program counter value is omitted if it is at 
  2327.  the beginning of the code for that line number. 
  2328.  
  2329.  Here is an example of a backtrace.  It was made with the command `bt 3', so it 
  2330.  shows the innermost three frames. 
  2331.  
  2332.   #0  m4_traceon (obs=0x24eb0, argc=1, argv=0x2b8c8)
  2333.       at builtin.c:993
  2334.   #1  0x6e38 in expand_macro (sym=0x2b600) at macro.c:242
  2335.   #2  0x6840 in expand_token (obs=0x0, t=177664, td=0xf7fffb08)
  2336.       at macro.c:71
  2337.   (More stack frames follow...)
  2338.  
  2339.  The display for frame zero does not begin with a program counter value, 
  2340.  indicating that your program has stopped at the beginning of the code for line 
  2341.  993 of builtin.c. 
  2342.  
  2343.  
  2344. ΓòÉΓòÉΓòÉ 9.3. Selecting a frame ΓòÉΓòÉΓòÉ
  2345.  
  2346. Most commands for examining the stack and other data in your program work on 
  2347. whichever stack frame is selected at the moment.  Here are the commands for 
  2348. selecting a stack frame; all of them finish by printing a brief description of 
  2349. the stack frame just selected. 
  2350.  
  2351.  frame n 
  2352.  f n 
  2353.            Select frame number n.  Recall that frame zero is the innermost 
  2354.            (currently executing) frame, frame one is the frame that called the 
  2355.            innermost one, and so on.  The highest-numbered frame is the one for 
  2356.            main. 
  2357.  
  2358.  frame addr 
  2359.  f addr 
  2360.            Select the frame at address addr.  This is useful mainly if the 
  2361.            chaining of stack frames has been damaged by a bug, making it 
  2362.            impossible for  to assign numbers properly to all frames.  In 
  2363.            addition, this can be useful when your program has multiple stacks 
  2364.            and switches between them. 
  2365.  
  2366.            On the SPARC architecture, frame needs two addresses to select an 
  2367.            arbitrary frame: a frame pointer and a stack pointer. 
  2368.  
  2369.            On the MIPS and Alpha architecture, it needs two addresses: a stack 
  2370.            pointer and a program counter. 
  2371.  
  2372.            On the 29k architecture, it needs three addresses: a register stack 
  2373.            pointer, a program counter, and a memory stack pointer. 
  2374.  
  2375.  up n 
  2376.            Move n frames up the stack.  For positive numbers n, this advances 
  2377.            toward the outermost frame, to higher frame numbers, to frames that 
  2378.            have existed longer.  n defaults to one. 
  2379.  
  2380.  down n 
  2381.            Move n frames down the stack.  For positive numbers n, this advances 
  2382.            toward the innermost frame, to lower frame numbers, to frames that 
  2383.            were created more recently.  n defaults to one.  You may abbreviate 
  2384.            down as do. 
  2385.  
  2386.  All of these commands end by printing two lines of output describing the 
  2387.  frame.  The first line shows the frame number, the function name, the 
  2388.  arguments, and the source file and line number of execution in that frame. 
  2389.  The second line shows the text of that source line. 
  2390.  
  2391.  For example: 
  2392.  
  2393.   () up
  2394.   #1  0x22f0 in main (argc=1, argv=0xf7fffbf4, env=0xf7fffbfc)
  2395.       at env.c:10
  2396.   10              read_input_file (argv[i]);
  2397.  
  2398.  After such a printout, the list command with no arguments prints ten lines 
  2399.  centered on the point of execution in the frame. See Printing source lines. 
  2400.  
  2401.  up-silently n 
  2402.  down-silently n 
  2403.            These two commands are variants of up and down, respectively; they 
  2404.            differ in that they do their work silently, without causing display 
  2405.            of the new frame.  They are intended primarily for use in  command 
  2406.            scripts, where the output might be unnecessary and distracting. 
  2407.  
  2408.  
  2409. ΓòÉΓòÉΓòÉ 9.4. Information about a frame ΓòÉΓòÉΓòÉ
  2410.  
  2411. There are several other commands to print information about the selected stack 
  2412. frame. 
  2413.  
  2414.  frame 
  2415.  f 
  2416.            When used without any argument, this command does not change which 
  2417.            frame is selected, but prints a brief description of the currently 
  2418.            selected stack frame.  It can be abbreviated f.  With an argument, 
  2419.            this command is used to select a stack frame. See Selecting a frame. 
  2420.  
  2421.  info frame 
  2422.  info f 
  2423.            This command prints a verbose description of the selected stack 
  2424.            frame, including: 
  2425.  
  2426.                the address of the frame 
  2427.  
  2428.                the address of the next frame down (called by this frame) 
  2429.  
  2430.                the address of the next frame up (caller of this frame) 
  2431.  
  2432.                the language in which the source code corresponding to this 
  2433.                 frame is written 
  2434.  
  2435.                the address of the frame's arguments 
  2436.  
  2437.                the program counter saved in it (the address of execution in 
  2438.                 the caller frame) 
  2439.  
  2440.                which registers were saved in the frame 
  2441.  
  2442.            The verbose description is useful when something has gone wrong that 
  2443.            has made the stack format fail to fit the usual conventions. 
  2444.  
  2445.  info frame addr 
  2446.  info f addr 
  2447.            Print a verbose description of the frame at address addr, without 
  2448.            selecting that frame.  The selected frame remains unchanged by this 
  2449.            command.  This requires the same kind of address (more than one for 
  2450.            some architectures) that you specify in the frame command. See 
  2451.            Selecting a frame. 
  2452.  
  2453.  info args 
  2454.            Print the arguments of the selected frame, each on a separate line. 
  2455.  
  2456.  info locals 
  2457.            Print the local variables of the selected frame, each on a separate 
  2458.            line.  These are all variables (declared either static or automatic) 
  2459.            accessible at the point of execution of the selected frame. 
  2460.  
  2461.  info catch 
  2462.            Print a list of all the exception handlers that are active in the 
  2463.            current stack frame at the current point of execution.  To see other 
  2464.            exception handlers, visit the associated frame (using the up, down, 
  2465.            or frame commands); then type info catch. See Breakpoints and 
  2466.            exceptions. 
  2467.  
  2468.  
  2469. ΓòÉΓòÉΓòÉ 10. Examining Source Files ΓòÉΓòÉΓòÉ
  2470.  
  2471.  can print parts of your program's source, since the debugging information 
  2472. recorded in the program tells  what source files were used to build it.  When 
  2473. your program stops,  spontaneously prints the line where it stopped.  Likewise, 
  2474. when you select a stack frame (see Selecting a frame),  prints the line where 
  2475. execution in that frame has stopped.  You can print other portions of source 
  2476. files by explicit command. 
  2477.  
  2478. If you use  through its gnu Emacs interface, you may prefer to use Emacs 
  2479. facilities to view source; see Using  under gnu Emacs. 
  2480.  
  2481.  List                                    Printing source lines 
  2482.  
  2483.  Search                                  Searching source files 
  2484.  
  2485.  Source Path                             Specifying source directories 
  2486.  Machine Code                            Source and machine code 
  2487.  
  2488.  
  2489. ΓòÉΓòÉΓòÉ 10.1. Printing source lines ΓòÉΓòÉΓòÉ
  2490.  
  2491. To print lines from a source file, use the list command (abbreviated l).  By 
  2492. default, ten lines are printed. There are several ways to specify what part of 
  2493. the file you want to print. 
  2494.  
  2495. Here are the forms of the list command most commonly used: 
  2496.  
  2497.  list linenum 
  2498.            Print lines centered around line number linenum in the current 
  2499.            source file. 
  2500.  
  2501.  list function 
  2502.            Print lines centered around the beginning of function function. 
  2503.  
  2504.  list 
  2505.            Print more lines.  If the last lines printed were printed with a 
  2506.            list command, this prints lines following the last lines printed; 
  2507.            however, if the last line printed was a solitary line printed as 
  2508.            part of displaying a stack frame ( see Examining the Stack), this 
  2509.            prints lines centered around that line. 
  2510.  
  2511.  list - 
  2512.            Print lines just before the lines last printed. 
  2513.  
  2514.  By default,  prints ten source lines with any of these forms of the list 
  2515.  command.  You can change this using set listsize: 
  2516.  
  2517.  set listsize count 
  2518.            Make the list command display count source lines (unless the list 
  2519.            argument explicitly specifies some other number). 
  2520.  
  2521.  show listsize 
  2522.            Display the number of lines that list prints. 
  2523.  
  2524.  Repeating a list command with RET discards the argument, so it is equivalent 
  2525.  to typing just list.  This is more useful than listing the same lines again. 
  2526.  An exception is made for an argument of `-'; that argument is preserved in 
  2527.  repetition so that each repetition moves up in the source file. 
  2528.  
  2529.  In general, the list command expects you to supply zero, one or two linespecs. 
  2530.  Linespecs specify source lines; there are several ways of writing them but the 
  2531.  effect is always to specify some source line. Here is a complete description 
  2532.  of the possible arguments for list: 
  2533.  
  2534.  list linespec 
  2535.            Print lines centered around the line specified by linespec. 
  2536.  
  2537.  list first,last 
  2538.            Print lines from first to last.  Both arguments are linespecs. 
  2539.  
  2540.  list ,last 
  2541.            Print lines ending with last. 
  2542.  
  2543.  list first, 
  2544.            Print lines starting with first. 
  2545.  
  2546.  list + 
  2547.            Print lines just after the lines last printed. 
  2548.  
  2549.  list - 
  2550.            Print lines just before the lines last printed. 
  2551.  
  2552.  list 
  2553.            As described in the preceding table. 
  2554.  
  2555.  Here are the ways of specifying a single source line---all the kinds of 
  2556.  linespec. 
  2557.  
  2558.  number 
  2559.            Specifies line number of the current source file. When a list 
  2560.            command has two linespecs, this refers to the same source file as 
  2561.            the first linespec. 
  2562.  
  2563.  +offset 
  2564.            Specifies the line offset lines after the last line printed. When 
  2565.            used as the second linespec in a list command that has two, this 
  2566.            specifies the line offset lines down from the first linespec. 
  2567.  
  2568.  -offset 
  2569.            Specifies the line offset lines before the last line printed. 
  2570.  
  2571.  filename:number 
  2572.            Specifies line number in the source file filename. 
  2573.  
  2574.  function 
  2575.            Specifies the line that begins the body of the function function. 
  2576.            For example: in C, this is the line with the open brace. 
  2577.  
  2578.  filename:function 
  2579.            Specifies the line of the open-brace that begins the body of the 
  2580.            function function in the file filename.  You only need the file name 
  2581.            with a function name to avoid ambiguity when there are identically 
  2582.            named functions in different source files. 
  2583.  
  2584.  *address 
  2585.            Specifies the line containing the program address address. address 
  2586.            may be any expression. 
  2587.  
  2588.  
  2589. ΓòÉΓòÉΓòÉ 10.2. Searching source files ΓòÉΓòÉΓòÉ
  2590.  
  2591. There are two commands for searching through the current source file for a 
  2592. regular expression. 
  2593.  
  2594.  forward-search regexp 
  2595.  search regexp 
  2596.            The command `forward-search regexp' checks each line, starting with 
  2597.            the one following the last line listed, for a match for regexp.  It 
  2598.            lists the line that is found.  You can use the synonym `search 
  2599.            regexp' or abbreviate the command name as fo. 
  2600.  
  2601.  reverse-search regexp 
  2602.            The command `reverse-search regexp' checks each line, starting with 
  2603.            the one before the last line listed and going backward, for a match 
  2604.            for regexp.  It lists the line that is found.  You can abbreviate 
  2605.            this command as rev. 
  2606.  
  2607.  
  2608. ΓòÉΓòÉΓòÉ 10.3. Specifying source directories ΓòÉΓòÉΓòÉ
  2609.  
  2610. Executable programs sometimes do not record the directories of the source files 
  2611. from which they were compiled, just the names.  Even when they do, the 
  2612. directories could be moved between the compilation and your debugging session. 
  2613. has a list of directories to search for source files; this is called the source 
  2614. path.  Each time  wants a source file, it tries all the directories in the 
  2615. list, in the order they are present in the list, until it finds a file with the 
  2616. desired name.  Note that the executable search path is not used for this 
  2617. purpose.  Neither is the current working directory, unless it happens to be in 
  2618. the source path. 
  2619.  
  2620. If  cannot find a source file in the source path, and the object program 
  2621. records a directory,  tries that directory too.  If the source path is empty, 
  2622. and there is no record of the compilation directory,  looks in the current 
  2623. directory as a last resort. 
  2624.  
  2625. Whenever you reset or rearrange the source path,  clears out any information it 
  2626. has cached about where source files are found and where each line is in the 
  2627. file. 
  2628.  
  2629. When you start , its source path is empty. To add other directories, use the 
  2630. directory command. 
  2631.  
  2632.  directory dirname ... 
  2633.  
  2634.  dir dirname ... 
  2635.            Add directory dirname to the front of the source path.  Several 
  2636.            directory names may be given to this command, separated by `:' or 
  2637.            whitespace.  You may specify a directory that is already in the 
  2638.            source path; this moves it forward, so  searches it sooner. 
  2639.  
  2640.            You can use the string `$cdir' to refer to the compilation directory 
  2641.            (if one is recorded), and `$cwd' to refer to the current working 
  2642.            directory.  `$cwd' is not the same as `.'---the former tracks the 
  2643.            current working directory as it changes during your session, while 
  2644.            the latter is immediately expanded to the current directory at the 
  2645.            time you add an entry to the source path. 
  2646.  
  2647.  directory 
  2648.            Reset the source path to empty again.  This requires confirmation. 
  2649.  
  2650.  show directories 
  2651.            Print the source path: show which directories it contains. 
  2652.  
  2653.  If your source path is cluttered with directories that are no longer of 
  2654.  interest,  may sometimes cause confusion by finding the wrong versions of 
  2655.  source.  You can correct the situation as follows: 
  2656.  
  2657.    1. Use directory with no argument to reset the source path to empty. 
  2658.  
  2659.    2. Use directory with suitable arguments to reinstall the directories you 
  2660.       want in the source path.  You can add all the directories in one command. 
  2661.  
  2662.  
  2663. ΓòÉΓòÉΓòÉ 10.4. Source and machine code ΓòÉΓòÉΓòÉ
  2664.  
  2665. You can use the command info line to map source lines to program addresses (and 
  2666. vice versa), and the command disassemble to display a range of addresses as 
  2667. machine instructions.  When run under gnu Emacs mode, the info line command now 
  2668. causes the arrow to point to the line specified.  Also, info line prints 
  2669. addresses in symbolic form as well as hex. 
  2670.  
  2671.  info line linespec 
  2672.            Print the starting and ending addresses of the compiled code for 
  2673.            source line linespec.  You can specify source lines in any of the 
  2674.            ways understood by the list command ( see Printing source lines). 
  2675.  
  2676.  For example, we can use info line to discover the location of the object code 
  2677.  for the first line of function m4_changequote: 
  2678.  
  2679.   () info line m4_changecom
  2680.   Line 895 of "builtin.c" starts at pc 0x634c and ends at 0x6350.
  2681.  
  2682.  We can also inquire (using *addr as the form for linespec) what source line 
  2683.  covers a particular address: 
  2684.  
  2685.   () info line *0x63ff
  2686.   Line 926 of "builtin.c" starts at pc 0x63e4 and ends at 0x6404.
  2687.  
  2688.  After info line, the default address for the x command is changed to the 
  2689.  starting address of the line, so that `x/i' is sufficient to begin examining 
  2690.  the machine code ( see Examining memory).  Also, this address is saved as the 
  2691.  value of the convenience variable $_ ( see Convenience variables). 
  2692.  
  2693.  disassemble 
  2694.            This specialized command dumps a range of memory as machine 
  2695.            instructions.  The default memory range is the function surrounding 
  2696.            the program counter of the selected frame.  A single argument to 
  2697.            this command is a program counter value;  dumps the function 
  2698.            surrounding this value.  Two arguments specify a range of addresses 
  2699.            (first inclusive, second exclusive) to dump. 
  2700.  
  2701.  We can use disassemble to inspect the object code range shown in the last info 
  2702.  line example (the example shows SPARC machine instructions): 
  2703.  
  2704.   () disas 0x63e4 0x6404
  2705.   Dump of assembler code from 0x63e4 to 0x6404:
  2706.   0x63e4 <builtin_init+5340>:     ble 0x63f8 <builtin_init+5360>
  2707.   0x63e8 <builtin_init+5344>:     sethi %hi(0x4c00), %o0
  2708.   0x63ec <builtin_init+5348>:     ld [%i1+4], %o0
  2709.   0x63f0 <builtin_init+5352>:     b 0x63fc <builtin_init+5364>
  2710.   0x63f4 <builtin_init+5356>:     ld [%o0+4], %o0
  2711.   0x63f8 <builtin_init+5360>:     or %o0, 0x1a4, %o0
  2712.   0x63fc <builtin_init+5364>:     call 0x9288 <path_search>
  2713.   0x6400 <builtin_init+5368>:     nop
  2714.   End of assembler dump.
  2715.  
  2716.  set assembly-language instruction-set 
  2717.            This command selects the instruction set to use when disassembling 
  2718.            the program via the disassemble or x/i commands.  It is useful for 
  2719.            architectures that have more than one native instruction set. 
  2720.  
  2721.            Currently it is only defined for the Intel x86 family.  You can set 
  2722.            instruction-set to either i386 or i8086.  The default is i386. 
  2723.  
  2724.  
  2725. ΓòÉΓòÉΓòÉ 11. Examining Data ΓòÉΓòÉΓòÉ
  2726.  
  2727. The usual way to examine data in your program is with the print command 
  2728. (abbreviated p), or its synonym inspect. It evaluates and prints the value of 
  2729. an expression of the language your program is written in ( see Using  with 
  2730. Different Languages). 
  2731.  
  2732.  print exp 
  2733.  print /f exp 
  2734.            exp is an expression (in the source language).  By default the value 
  2735.            of exp is printed in a format appropriate to its data type; you can 
  2736.            choose a different format by specifying `/f', where f is a letter 
  2737.            specifying the format; see Output formats. 
  2738.  
  2739.  print 
  2740.  print /f 
  2741.            If you omit exp,  displays the last value again (from the value 
  2742.            history; see Value history).  This allows you to conveniently 
  2743.            inspect the same value in an alternative format. 
  2744.  
  2745.  A more low-level way of examining data is with the x command. It examines data 
  2746.  in memory at a specified address and prints it in a specified format.  See 
  2747.  Examining memory. 
  2748.  
  2749.  If you are interested in information about types, or about how the fields of a 
  2750.  struct or class are declared, use the ptype exp command rather than print. See 
  2751.  Examining the Symbol Table. 
  2752.  
  2753.  Expressions                             Expressions 
  2754.  Variables                               Program variables 
  2755.  Arrays                                  Artificial arrays 
  2756.  Output Formats                          Output formats 
  2757.  Memory                                  Examining memory 
  2758.  Auto Display                            Automatic display 
  2759.  Print Settings                          Print settings 
  2760.  Value History                           Value history 
  2761.  Convenience Vars                        Convenience variables 
  2762.  Registers                               Registers 
  2763.  
  2764.  Floating Point Hardware                 Floating point hardware 
  2765.  
  2766.  
  2767. ΓòÉΓòÉΓòÉ 11.1. Expressions ΓòÉΓòÉΓòÉ
  2768.  
  2769. print and many other  commands accept an expression and compute its value.  Any 
  2770. kind of constant, variable or operator defined by the programming language you 
  2771. are using is valid in an expression in .  This includes conditional 
  2772. expressions, function calls, casts and string constants.  It unfortunately does 
  2773. not include symbols defined by preprocessor #define commands. 
  2774.  
  2775.  now supports array constants in expressions input by the user.  The syntax is 
  2776. {element, element...}.  For example, you can now use the command print {1, 2, 
  2777. 3} to build up an array in memory that is malloc'd in the target program. 
  2778.  
  2779. Because C is so widespread, most of the expressions shown in examples in this 
  2780. manual are in C. See Using  with Different Languages, for information on how to 
  2781. use expressions in other languages. 
  2782.  
  2783. In this section, we discuss operators that you can use in expressions 
  2784. regardless of your programming language. 
  2785.  
  2786. Casts are supported in all languages, not just in C, because it is so useful to 
  2787. cast a number into a pointer in order to examine a structure at that address in 
  2788. memory. 
  2789.  
  2790.  supports these operators, in addition to those common to programming 
  2791. languages: 
  2792.  
  2793.  @ 
  2794.            `@' is a binary operator for treating parts of memory as arrays. See 
  2795.            Artificial arrays, for more information. 
  2796.  
  2797.  :: 
  2798.            `::' allows you to specify a variable in terms of the file or 
  2799.            function where it is defined.  See Program variables. 
  2800.  
  2801.  {type} addr 
  2802.            Refers to an object of type type stored at address addr in memory. 
  2803.            addr may be any expression whose value is an integer or pointer (but 
  2804.            parentheses are required around binary operators, just as in a 
  2805.            cast).  This construct is allowed regardless of what kind of data is 
  2806.            normally supposed to reside at addr. 
  2807.  
  2808.  
  2809. ΓòÉΓòÉΓòÉ 11.2. Program variables ΓòÉΓòÉΓòÉ
  2810.  
  2811. The most common kind of expression to use is the name of a variable in your 
  2812. program. 
  2813.  
  2814. Variables in expressions are understood in the selected stack frame (see 
  2815. Selecting a frame); they must be either: 
  2816.  
  2817.      global (or static) 
  2818.  
  2819.  or 
  2820.  
  2821.      visible according to the scope rules of the programming language from the 
  2822.       point of execution in that frame 
  2823.  
  2824.  This means that in the function 
  2825.  
  2826.   foo (a)
  2827.        int a;
  2828.   {
  2829.     bar (a);
  2830.     {
  2831.       int b = test ();
  2832.       bar (b);
  2833.     }
  2834.   }
  2835.  
  2836.  you can examine and use the variable a whenever your program is executing 
  2837.  within the function foo, but you can only use or examine the variable b while 
  2838.  your program is executing inside the block where b is declared. 
  2839.  
  2840.  There is an exception: you can refer to a variable or function whose scope is 
  2841.  a single source file even if the current execution point is not in this file. 
  2842.  But it is possible to have more than one such variable or function with the 
  2843.  same name (in different source files).  If that happens, referring to that 
  2844.  name has unpredictable effects.  If you wish, you can specify a static 
  2845.  variable in a particular function or file, using the colon-colon notation: 
  2846.  
  2847.   file::variable
  2848.   function::variable
  2849.  
  2850.  Here file or function is the name of the context for the static variable.  In 
  2851.  the case of file names, you can use quotes to make sure  parses the file name 
  2852.  as a single word---for example, to print a global value of x defined in 
  2853.  `f2.c': 
  2854.  
  2855.   () p 'f2.c'::x
  2856.  
  2857.  This use of `::' is very rarely in conflict with the very similar use of the 
  2858.  same notation in C++.  also supports use of the C++ scope resolution operator 
  2859.  in  expressions. 
  2860.  
  2861.  Warning: Occasionally, a local variable may appear to have the wrong value at 
  2862.  certain points in a function---just after entry to a new scope, and just 
  2863.  before exit. You may see this problem when you are stepping by machine 
  2864.  instructions. This is because, on most machines, it takes more than one 
  2865.  instruction to set up a stack frame (including local variable definitions); if 
  2866.  you are stepping by machine instructions, variables may appear to have the 
  2867.  wrong values until the stack frame is completely built.  On exit, it usually 
  2868.  also takes more than one machine instruction to destroy a stack frame; after 
  2869.  you begin stepping through that group of instructions, local variable 
  2870.  definitions may be gone. 
  2871.  
  2872.  
  2873. ΓòÉΓòÉΓòÉ 11.3. Artificial arrays ΓòÉΓòÉΓòÉ
  2874.  
  2875. It is often useful to print out several successive objects of the same type in 
  2876. memory; a section of an array, or an array of dynamically determined size for 
  2877. which only a pointer exists in the program. 
  2878.  
  2879. You can do this by referring to a contiguous span of memory as an artificial 
  2880. array, using the binary operator `@'.  The left operand of `@' should be the 
  2881. first element of the desired array and be an individual object.  The right 
  2882. operand should be the desired length of the array.  The result is an array 
  2883. value whose elements are all of the type of the left argument.  The first 
  2884. element is actually the left argument; the second element comes from bytes of 
  2885. memory immediately following those that hold the first element, and so on. 
  2886. Here is an example.  If a program says 
  2887.  
  2888. int *array = (int *) malloc (len * sizeof (int));
  2889.  
  2890. you can print the contents of array with 
  2891.  
  2892. p *array@len
  2893.  
  2894. The left operand of `@' must reside in memory.  Array values made with `@' in 
  2895. this way behave just like other arrays in terms of subscripting, and are 
  2896. coerced to pointers when used in expressions. Artificial arrays most often 
  2897. appear in expressions via the value history (see Value history), after printing 
  2898. one out. 
  2899.  
  2900. Another way to create an artificial array is to use a cast. This re-interprets 
  2901. a value as if it were an array. The value need not be in memory: 
  2902.  
  2903. () p/x (short[2])0x12345678
  2904. $1 = {0x1234, 0x5678}
  2905.  
  2906. As a convenience, if you leave the array length out (as in `(type)[])value') 
  2907. gdb calculates the size to fill the value (as `sizeof(value)/sizeof(type)': 
  2908.  
  2909. () p/x (short[])0x12345678
  2910. $2 = {0x1234, 0x5678}
  2911.  
  2912. Sometimes the artificial array mechanism is not quite enough; in moderately 
  2913. complex data structures, the elements of interest may not actually be 
  2914. adjacent---for example, if you are interested in the values of pointers in an 
  2915. array.  One useful work-around in this situation is to use a convenience 
  2916. variable ( see Convenience variables) as a counter in an expression that prints 
  2917. the first interesting value, and then repeat that expression via RET.  For 
  2918. instance, suppose you have an array dtab of pointers to structures, and you are 
  2919. interested in the values of a field fv in each structure.  Here is an example 
  2920. of what you might type: 
  2921.  
  2922. set $i = 0
  2923. p dtab[$i++]->fv
  2924. RET
  2925. RET
  2926. ...
  2927.  
  2928.  
  2929. ΓòÉΓòÉΓòÉ 11.4. Output formats ΓòÉΓòÉΓòÉ
  2930.  
  2931. By default,  prints a value according to its data type.  Sometimes this is not 
  2932. what you want.  For example, you might want to print a number in hex, or a 
  2933. pointer in decimal.  Or you might want to view data in memory at a certain 
  2934. address as a character string or as an instruction.  To do these things, 
  2935. specify an output format when you print a value. 
  2936.  
  2937. The simplest use of output formats is to say how to print a value already 
  2938. computed.  This is done by starting the arguments of the print command with a 
  2939. slash and a format letter.  The format letters supported are: 
  2940.  
  2941.  x 
  2942.            Regard the bits of the value as an integer, and print the integer in 
  2943.            hexadecimal. 
  2944.  
  2945.  d 
  2946.            Print as integer in signed decimal. 
  2947.  
  2948.  u 
  2949.            Print as integer in unsigned decimal. 
  2950.  
  2951.  o 
  2952.            Print as integer in octal. 
  2953.  
  2954.  t 
  2955.            Print as integer in binary.  The letter `t' stands for ``two''. (1) 
  2956.  
  2957.  a 
  2958.            Print as an address, both absolute in hexadecimal and as an offset 
  2959.            from the nearest preceding symbol.  You can use this format used to 
  2960.            discover where (in what function) an unknown address is located: 
  2961.  
  2962.                       () p/a 0x54320
  2963.                       $3 = 0x54320 <_initialize_vx+396>
  2964.  
  2965.  c 
  2966.            Regard as an integer and print it as a character constant. 
  2967.  
  2968.  f 
  2969.            Regard the bits of the value as a floating point number and print 
  2970.            using typical floating point syntax. 
  2971.  
  2972.  For example, to print the program counter in hex (see Registers), type 
  2973.  
  2974.   p/x $pc
  2975.  
  2976.  Note that no space is required before the slash; this is because command names 
  2977.  in  cannot contain a slash. 
  2978.  
  2979.  To reprint the last value in the value history with a different format, you 
  2980.  can use the print command with just a format and no expression.  For example, 
  2981.  `p/x' reprints the last value in hex. 
  2982.  
  2983.  
  2984. ΓòÉΓòÉΓòÉ 11.5. Examining memory ΓòÉΓòÉΓòÉ
  2985.  
  2986. You can use the command x (for ``examine'') to examine memory in any of several 
  2987. formats, independently of your program's data types. 
  2988.  
  2989.  x/nfu addr 
  2990.  x addr 
  2991.  x 
  2992.            Use the x command to examine memory. 
  2993.  
  2994.  n, f, and u are all optional parameters that specify how much memory to 
  2995.  display and how to format it; addr is an expression giving the address where 
  2996.  you want to start displaying memory. If you use defaults for nfu, you need not 
  2997.  type the slash `/'. Several commands set convenient defaults for addr. 
  2998.  
  2999.  n, the repeat count 
  3000.            The repeat count is a decimal integer; the default is 1.  It 
  3001.            specifies how much memory (counting by units u) to display. 
  3002.  
  3003.  f, the display format 
  3004.            The display format is one of the formats used by print, `s' 
  3005.            (null-terminated string), or `i' (machine instruction). The default 
  3006.            is `x' (hexadecimal) initially. The default changes each time you 
  3007.            use either x or print. 
  3008.  
  3009.  u, the unit size 
  3010.            The unit size is any of 
  3011.  
  3012.            b 
  3013.                           Bytes. 
  3014.  
  3015.            h 
  3016.                           Halfwords (two bytes). 
  3017.  
  3018.            w 
  3019.                           Words (four bytes).  This is the initial default. 
  3020.  
  3021.            g 
  3022.                           Giant words (eight bytes). 
  3023.  
  3024.            Each time you specify a unit size with x, that size becomes the 
  3025.            default unit the next time you use x.  (For the `s' and `i' formats, 
  3026.            the unit size is ignored and is normally not written.) 
  3027.  
  3028.  addr, starting display address 
  3029.            addr is the address where you want  to begin displaying memory.  The 
  3030.            expression need not have a pointer value (though it may); it is 
  3031.            always interpreted as an integer address of a byte of memory. See 
  3032.            Expressions, for more information on expressions.  The default for 
  3033.            addr is usually just after the last address examined---but several 
  3034.            other commands also set the default address: info breakpoints (to 
  3035.            the address of the last breakpoint listed), info line (to the 
  3036.            starting address of a line), and print (if you use it to display a 
  3037.            value from memory). 
  3038.  
  3039.  For example, `x/3uh 0x54320' is a request to display three halfwords (h) of 
  3040.  memory, formatted as unsigned decimal integers (`u'), starting at address 
  3041.  0x54320.  `x/4xw $sp' prints the four words (`w') of memory above the stack 
  3042.  pointer (here, `$sp'; see Registers) in hexadecimal (`x'). 
  3043.  
  3044.  Since the letters indicating unit sizes are all distinct from the letters 
  3045.  specifying output formats, you do not have to remember whether unit size or 
  3046.  format comes first; either order works.  The output specifications `4xw' and 
  3047.  `4wx' mean exactly the same thing. (However, the count n must come first; 
  3048.  `wx4' does not work.) 
  3049.  
  3050.  Even though the unit size u is ignored for the formats `s' and `i', you might 
  3051.  still want to use a count n; for example, `3i' specifies that you want to see 
  3052.  three machine instructions, including any operands.  The command disassemble 
  3053.  gives an alternative way of inspecting machine instructions; see Source and 
  3054.  machine code. 
  3055.  
  3056.  All the defaults for the arguments to x are designed to make it easy to 
  3057.  continue scanning memory with minimal specifications each time you use x.  For 
  3058.  example, after you have inspected three machine instructions with `x/3i addr', 
  3059.  you can inspect the next seven with just `x/7'.  If you use RET to repeat the 
  3060.  x command, the repeat count n is used again; the other arguments default as 
  3061.  for successive uses of x. 
  3062.  
  3063.  The addresses and contents printed by the x command are not saved in the value 
  3064.  history because there is often too much of them and they would get in the way. 
  3065.  Instead,  makes these values available for subsequent use in expressions as 
  3066.  values of the convenience variables $_ and $__.  After an x command, the last 
  3067.  address examined is available for use in expressions in the convenience 
  3068.  variable $_.  The contents of that address, as examined, are available in the 
  3069.  convenience variable $__. 
  3070.  
  3071.  If the x command has a repeat count, the address and contents saved are from 
  3072.  the last memory unit printed; this is not the same as the last address printed 
  3073.  if several units were printed on the last line of output. 
  3074.  
  3075.  
  3076. ΓòÉΓòÉΓòÉ 11.6. Automatic display ΓòÉΓòÉΓòÉ
  3077.  
  3078. If you find that you want to print the value of an expression frequently (to 
  3079. see how it changes), you might want to add it to the automatic display list so 
  3080. that  prints its value each time your program stops. Each expression added to 
  3081. the list is given a number to identify it; to remove an expression from the 
  3082. list, you specify that number. The automatic display looks like this: 
  3083.  
  3084. 2: foo = 38
  3085. 3: bar[5] = (struct hack *) 0x3804
  3086.  
  3087. This display shows item numbers, expressions and their current values.  As with 
  3088. displays you request manually using x or print, you can specify the output 
  3089. format you prefer; in fact, display decides whether to use print or x depending 
  3090. on how elaborate your format specification is---it uses x if you specify a unit 
  3091. size, or one of the two formats (`i' and `s') that are only supported by x; 
  3092. otherwise it uses print. 
  3093.  
  3094.  display exp 
  3095.            Add the expression exp to the list of expressions to display each 
  3096.            time your program stops.  See Expressions. 
  3097.  
  3098.            display does not repeat if you press RET again after using it. 
  3099.  
  3100.  display/fmt exp 
  3101.            For fmt specifying only a display format and not a size or count, 
  3102.            add the expression exp to the auto-display list but arrange to 
  3103.            display it each time in the specified format fmt. See Output 
  3104.            formats. 
  3105.  
  3106.  display/fmt addr 
  3107.            For fmt `i' or `s', or including a unit-size or a number of units, 
  3108.            add the expression addr as a memory address to be examined each time 
  3109.            your program stops.  Examining means in effect doing `x/fmt addr'. 
  3110.            See Examining memory. 
  3111.  
  3112.  For example, `display/i $pc' can be helpful, to see the machine instruction 
  3113.  about to be executed each time execution stops (`$pc' is a common name for the 
  3114.  program counter; see Registers). 
  3115.  
  3116.  undisplay dnums... 
  3117.  delete display dnums... 
  3118.            Remove item numbers dnums from the list of expressions to display. 
  3119.  
  3120.            undisplay does not repeat if you press RET after using it. 
  3121.            (Otherwise you would just get the error `No display number ...'.) 
  3122.  
  3123.  disable display dnums... 
  3124.            Disable the display of item numbers dnums.  A disabled display item 
  3125.            is not printed automatically, but is not forgotten.  It may be 
  3126.            enabled again later. 
  3127.  
  3128.  enable display dnums... 
  3129.            Enable display of item numbers dnums.  It becomes effective once 
  3130.            again in auto display of its expression, until you specify 
  3131.            otherwise. 
  3132.  
  3133.  display 
  3134.            Display the current values of the expressions on the list, just as 
  3135.            is done when your program stops. 
  3136.  
  3137.  info display 
  3138.            Print the list of expressions previously set up to display 
  3139.            automatically, each one with its item number, but without showing 
  3140.            the values.  This includes disabled expressions, which are marked as 
  3141.            such. It also includes expressions which would not be displayed 
  3142.            right now because they refer to automatic variables not currently 
  3143.            available. 
  3144.  
  3145.  If a display expression refers to local variables, then it does not make sense 
  3146.  outside the lexical context for which it was set up.  Such an expression is 
  3147.  disabled when execution enters a context where one of its variables is not 
  3148.  defined.  For example, if you give the command display last_char while inside 
  3149.  a function with an argument last_char,  displays this argument while your 
  3150.  program continues to stop inside that function.  When it stops 
  3151.  elsewhere---where there is no variable last_char---the display is disabled 
  3152.  automatically.  The next time your program stops where last_char is 
  3153.  meaningful, you can enable the display expression once again. 
  3154.  
  3155.  
  3156. ΓòÉΓòÉΓòÉ 11.7. Print settings ΓòÉΓòÉΓòÉ
  3157.  
  3158.  provides the following ways to control how arrays, structures, and symbols are 
  3159. printed. 
  3160.  
  3161. These settings are useful for debugging programs in any language: 
  3162.  
  3163.  set print address 
  3164.  set print address on 
  3165.             prints memory addresses showing the location of stack traces, 
  3166.            structure values, pointer values, breakpoints, and so forth, even 
  3167.            when it also displays the contents of those addresses.  The default 
  3168.            is on.  For example, this is what a stack frame display looks like 
  3169.            with set print address on: 
  3170.  
  3171.                       () f
  3172.                       #0  set_quotes (lq=0x34c78 "<<", rq=0x34c88 ">>")
  3173.                           at input.c:530
  3174.                       530         if (lquote != def_lquote)
  3175.  
  3176.  set print address off 
  3177.            Do not print addresses when displaying their contents.  For example, 
  3178.            this is the same stack frame displayed with set print address off: 
  3179.  
  3180.                       () set print addr off
  3181.                       () f
  3182.                       #0  set_quotes (lq="<<", rq=">>") at input.c:530
  3183.                       530         if (lquote != def_lquote)
  3184.  
  3185.            You can use `set print address off' to eliminate all machine 
  3186.            dependent displays from the  interface.  For example, with print 
  3187.            address off, you should get the same text for backtraces on all 
  3188.            machines---whether or not they involve pointer arguments. 
  3189.  
  3190.  show print address 
  3191.            Show whether or not addresses are to be printed. 
  3192.  
  3193.  When  prints a symbolic address, it normally prints the closest earlier symbol 
  3194.  plus an offset.  If that symbol does not uniquely identify the address (for 
  3195.  example, it is a name whose scope is a single source file), you may need to 
  3196.  clarify.  One way to do this is with info line, for example `info line 
  3197.  *0x4537'.  Alternately, you can set  to print the source file and line number 
  3198.  when it prints a symbolic address: 
  3199.  
  3200.  set print symbol-filename on 
  3201.            Tell  to print the source file name and line number of a symbol in 
  3202.            the symbolic form of an address. 
  3203.  
  3204.  set print symbol-filename off 
  3205.            Do not print source file name and line number of a symbol.  This is 
  3206.            the default. 
  3207.  
  3208.  show print symbol-filename 
  3209.            Show whether or not  will print the source file name and line number 
  3210.            of a symbol in the symbolic form of an address. 
  3211.  
  3212.  Another situation where it is helpful to show symbol filenames and line 
  3213.  numbers is when disassembling code;  shows you the line number and source file 
  3214.  that corresponds to each instruction. 
  3215.  
  3216.  Also, you may wish to see the symbolic form only if the address being printed 
  3217.  is reasonably close to the closest earlier symbol: 
  3218.  
  3219.  set print max-symbolic-offset max-offset 
  3220.            Tell  to only display the symbolic form of an address if the offset 
  3221.            between the closest earlier symbol and the address is less than 
  3222.            max-offset.  The default is 0, which tells to always print the 
  3223.            symbolic form of an address if any symbol precedes it. 
  3224.  
  3225.  show print max-symbolic-offset 
  3226.            Ask how large the maximum offset is that  prints in a symbolic 
  3227.            address. 
  3228.  
  3229.  If you have a pointer and you are not sure where it points, try `set print 
  3230.  symbol-filename on'.  Then you can determine the name and source file location 
  3231.  of the variable where it points, using `p/a pointer'.  This interprets the 
  3232.  address in symbolic form. For example, here  shows that a variable ptt points 
  3233.  at another variable t, defined in `hi2.c': 
  3234.  
  3235.   () set print symbol-filename on
  3236.   () p/a ptt
  3237.   $4 = 0xe008 <t in hi2.c>
  3238.  
  3239.  Warning: For pointers that point to a local variable, `p/a' does not show the 
  3240.  symbol name and filename of the referent, even with the appropriate set print 
  3241.  options turned on. 
  3242.  
  3243.  Other settings control how different kinds of objects are printed: 
  3244.  
  3245.  set print array 
  3246.  set print array on 
  3247.            Pretty print arrays.  This format is more convenient to read, but 
  3248.            uses more space.  The default is off. 
  3249.  
  3250.  set print array off 
  3251.            Return to compressed format for arrays. 
  3252.  
  3253.  show print array 
  3254.            Show whether compressed or pretty format is selected for displaying 
  3255.            arrays. 
  3256.  
  3257.  set print elements number-of-elements 
  3258.            Set a limit on how many elements of an array  will print. If  is 
  3259.            printing a large array, it stops printing after it has printed the 
  3260.            number of elements set by the set print elements command. This limit 
  3261.            also applies to the display of strings. Setting  number-of-elements 
  3262.            to zero means that the printing is unlimited. 
  3263.  
  3264.  show print elements 
  3265.            Display the number of elements of a large array that  will print. If 
  3266.            the number is 0, then the printing is unlimited. 
  3267.  
  3268.  set print null-stop 
  3269.            Cause  to stop printing the characters of an array when the first 
  3270.            NULL is encountered.  This is useful when large arrays actually 
  3271.            contain only short strings. 
  3272.  
  3273.  set print pretty on 
  3274.            Cause  to print structures in an indented format with one member per 
  3275.            line, like this: 
  3276.  
  3277.                       $1 = {
  3278.                         next = 0x0,
  3279.                         flags = {
  3280.                           sweet = 1,
  3281.                           sour = 1
  3282.                         },
  3283.                         meat = 0x54 "Pork"
  3284.                       }
  3285.  
  3286.  set print pretty off 
  3287.            Cause  to print structures in a compact format, like this: 
  3288.  
  3289.                       $1 = {next = 0x0, flags = {sweet = 1, sour = 1}, \
  3290.                       meat = 0x54 "Pork"}
  3291.  
  3292.            This is the default format. 
  3293.  
  3294.  show print pretty 
  3295.            Show which format  is using to print structures. 
  3296.  
  3297.  set print sevenbit-strings on 
  3298.            Print using only seven-bit characters; if this option is set, 
  3299.            displays any eight-bit characters (in strings or character values) 
  3300.            using the notation \nnn.  This setting is best if you are working in 
  3301.            English (ascii) and you use the high-order bit of characters as a 
  3302.            marker or ``meta'' bit. 
  3303.  
  3304.  set print sevenbit-strings off 
  3305.            Print full eight-bit characters.  This allows the use of more 
  3306.            international character sets, and is the default. 
  3307.  
  3308.  show print sevenbit-strings 
  3309.            Show whether or not  is printing only seven-bit characters. 
  3310.  
  3311.  set print union on 
  3312.            Tell  to print unions which are contained in structures.  This is 
  3313.            the default setting. 
  3314.  
  3315.  set print union off 
  3316.            Tell  not to print unions which are contained in structures. 
  3317.  
  3318.  show print union 
  3319.            Ask  whether or not it will print unions which are contained in 
  3320.            structures. 
  3321.  
  3322.            For example, given the declarations 
  3323.  
  3324.                       typedef enum {Tree, Bug} Species;
  3325.                       typedef enum {Big_tree, Acorn, Seedling} Tree_forms;
  3326.                       typedef enum {Caterpillar, Cocoon, Butterfly}
  3327.                                     Bug_forms;
  3328.  
  3329.                       struct thing {
  3330.                         Species it;
  3331.                         union {
  3332.                           Tree_forms tree;
  3333.                           Bug_forms bug;
  3334.                         } form;
  3335.                       };
  3336.  
  3337.                       struct thing foo = {Tree, {Acorn}};
  3338.  
  3339.            with set print union on in effect `p foo' would print 
  3340.  
  3341.                       $1 = {it = Tree, form = {tree = Acorn, bug = Cocoon}}
  3342.  
  3343.            and with set print union off in effect it would print 
  3344.  
  3345.                       $1 = {it = Tree, form = {...}}
  3346.  
  3347.  These settings are of interest when debugging C++ programs: 
  3348.  
  3349.  set print demangle 
  3350.  set print demangle on 
  3351.            Print C++ names in their source form rather than in the encoded 
  3352.            (``mangled'') form passed to the assembler and linker for type-safe 
  3353.            linkage.  The default is `on'. 
  3354.  
  3355.  show print demangle 
  3356.            Show whether C++ names are printed in mangled or demangled form. 
  3357.  
  3358.  set print asm-demangle 
  3359.  set print asm-demangle on 
  3360.            Print C++ names in their source form rather than their mangled form, 
  3361.            even in assembler code printouts such as instruction disassemblies. 
  3362.            The default is off. 
  3363.  
  3364.  show print asm-demangle 
  3365.            Show whether C++ names in assembly listings are printed in mangled 
  3366.            or demangled form. 
  3367.  
  3368.  set demangle-style style 
  3369.            Choose among several encoding schemes used by different compilers to 
  3370.            represent C++ names.  The choices for style are currently: 
  3371.  
  3372.            auto 
  3373.                           Allow  to choose a decoding style by inspecting your 
  3374.                           program. 
  3375.  
  3376.            gnu 
  3377.                           Decode based on the gnu C++ compiler (g++) encoding 
  3378.                           algorithm. This is the default. 
  3379.  
  3380.            lucid 
  3381.                           Decode based on the Lucid C++ compiler (lcc) encoding 
  3382.                           algorithm. 
  3383.  
  3384.            arm 
  3385.                           Decode using the algorithm in the C++ Annotated 
  3386.                           Reference Manual. *Warning:* this setting alone is 
  3387.                           not sufficient to allow debugging cfront-generated 
  3388.                           executables.  would require further enhancement to 
  3389.                           permit that. 
  3390.  
  3391.            foo 
  3392.                           Show the list of formats. 
  3393.  
  3394.  show demangle-style 
  3395.            Display the encoding style currently in use for decoding C++ 
  3396.            symbols. 
  3397.  
  3398.  set print object 
  3399.  set print object on 
  3400.            When displaying a pointer to an object, identify the actual 
  3401.            (derived) type of the object rather than the declared type, using 
  3402.            the virtual function table. 
  3403.  
  3404.  set print object off 
  3405.            Display only the declared type of objects, without reference to the 
  3406.            virtual function table.  This is the default setting. 
  3407.  
  3408.  show print object 
  3409.            Show whether actual, or declared, object types are displayed. 
  3410.  
  3411.  set print static-members 
  3412.  set print static-members on 
  3413.            Print static members when displaying a C++ object.  The default is 
  3414.            on. 
  3415.  
  3416.  set print static-members off 
  3417.            Do not print static members when displaying a C++ object. 
  3418.  
  3419.  show print static-members 
  3420.            Show whether C++ static members are printed, or not. 
  3421.  
  3422.  set print vtbl 
  3423.  set print vtbl on 
  3424.            Pretty print C++ virtual function tables.  The default is off. 
  3425.  
  3426.  set print vtbl off 
  3427.            Do not pretty print C++ virtual function tables. 
  3428.  
  3429.  show print vtbl 
  3430.            Show whether C++ virtual function tables are pretty printed, or not. 
  3431.  
  3432.  
  3433. ΓòÉΓòÉΓòÉ 11.8. Value history ΓòÉΓòÉΓòÉ
  3434.  
  3435. Values printed by the print command are saved in the value history.  This 
  3436. allows you to refer to them in other expressions. Values are kept until the 
  3437. symbol table is re-read or discarded (for example with the file or symbol-file 
  3438. commands). When the symbol table changes, the value history is discarded, since 
  3439. the values may contain pointers back to the types defined in the symbol table. 
  3440.  
  3441. The values printed are given history numbers by which you can refer to them. 
  3442. These are successive integers starting with one. print shows you the history 
  3443. number assigned to a value by printing `$num = ' before the value; here num is 
  3444. the history number. 
  3445.  
  3446. To refer to any previous value, use `$' followed by the value's history number. 
  3447. The way print labels its output is designed to remind you of this.  Just $ 
  3448. refers to the most recent value in the history, and $$ refers to the value 
  3449. before that. $$n refers to the nth value from the end; $$2 is the value just 
  3450. prior to $$, $$1 is equivalent to $$, and $$0 is equivalent to $. 
  3451.  
  3452. For example, suppose you have just printed a pointer to a structure and want to 
  3453. see the contents of the structure.  It suffices to type 
  3454.  
  3455. p *$
  3456.  
  3457. If you have a chain of structures where the component next points to the next 
  3458. one, you can print the contents of the next one with this: 
  3459.  
  3460. p *$.next
  3461.  
  3462. You can print successive links in the chain by repeating this command---which 
  3463. you can do by just typing RET. 
  3464.  
  3465. Note that the history records values, not expressions.  If the value of x is 4 
  3466. and you type these commands: 
  3467.  
  3468. print x
  3469. set x=5
  3470.  
  3471. then the value recorded in the value history by the print command remains 4 
  3472. even though the value of x has changed. 
  3473.  
  3474.  show values 
  3475.            Print the last ten values in the value history, with their item 
  3476.            numbers. This is like `p@ $$9' repeated ten times, except that show 
  3477.            values does not change the history. 
  3478.  
  3479.  show values n 
  3480.            Print ten history values centered on history item number n. 
  3481.  
  3482.  show values + 
  3483.            Print ten history values just after the values last printed.  If no 
  3484.            more values are available, show values + produces no display. 
  3485.  
  3486.  Pressing RET to repeat show values n has exactly the same effect as `show 
  3487.  values +'. 
  3488.  
  3489.  
  3490. ΓòÉΓòÉΓòÉ 11.9. Convenience variables ΓòÉΓòÉΓòÉ
  3491.  
  3492.  provides convenience variables that you can use within  to hold on to a value 
  3493. and refer to it later.  These variables exist entirely within ; they are not 
  3494. part of your program, and setting a convenience variable has no direct effect 
  3495. on further execution of your program.  That is why you can use them freely. 
  3496.  
  3497. Convenience variables are prefixed with `$'.  Any name preceded by `$' can be 
  3498. used for a convenience variable, unless it is one of the predefined 
  3499. machine-specific register names (see Registers). (Value history references, in 
  3500. contrast, are numbers preceded by `$'.  See Value history.) 
  3501.  
  3502. You can save a value in a convenience variable with an assignment expression, 
  3503. just as you would set a variable in your program. For example: 
  3504.  
  3505. set $foo = *object_ptr
  3506.  
  3507. would save in $foo the value contained in the object pointed to by object_ptr. 
  3508.  
  3509. Using a convenience variable for the first time creates it, but its value is 
  3510. void until you assign a new value.  You can alter the value with another 
  3511. assignment at any time. 
  3512.  
  3513. Convenience variables have no fixed types.  You can assign a convenience 
  3514. variable any type of value, including structures and arrays, even if that 
  3515. variable already has a value of a different type.  The convenience variable, 
  3516. when used as an expression, has the type of its current value. 
  3517.  
  3518.  show convenience 
  3519.            Print a list of convenience variables used so far, and their values. 
  3520.            Abbreviated show con. 
  3521.  
  3522.  One of the ways to use a convenience variable is as a counter to be 
  3523.  incremented or a pointer to be advanced.  For example, to print a field from 
  3524.  successive elements of an array of structures: 
  3525.  
  3526.   set $i = 0
  3527.   print bar[$i++]->contents
  3528.  
  3529.  Repeat that command by typing RET. 
  3530.  
  3531.  Some convenience variables are created automatically by  and given values 
  3532.  likely to be useful. 
  3533.  
  3534.  $_ 
  3535.            The variable $_ is automatically set by the x command to the last 
  3536.            address examined (see Examining memory).  Other commands which 
  3537.            provide a default address for x to examine also set $_ to that 
  3538.            address; these commands include info line and info breakpoint.  The 
  3539.            type of $_ is void * except when set by the x command, in which case 
  3540.            it is a pointer to the type of $__. 
  3541.  
  3542.  $__ 
  3543.            The variable $__ is automatically set by the x command to the value 
  3544.            found in the last address examined.  Its type is chosen to match the 
  3545.            format in which the data was printed. 
  3546.  
  3547.  $_exitcode 
  3548.            The variable $_exitcode is automatically set to the exit code when 
  3549.            the program being debugged terminates. 
  3550.  
  3551.  
  3552. ΓòÉΓòÉΓòÉ 11.10. Registers ΓòÉΓòÉΓòÉ
  3553.  
  3554. You can refer to machine register contents, in expressions, as variables with 
  3555. names starting with `$'.  The names of registers are different for each 
  3556. machine; use info registers to see the names used on your machine. 
  3557.  
  3558.  info registers 
  3559.            Print the names and values of all registers except floating-point 
  3560.            registers (in the selected stack frame). 
  3561.  
  3562.  info all-registers 
  3563.            Print the names and values of all registers, including 
  3564.            floating-point registers. 
  3565.  
  3566.  info registers regname ... 
  3567.            Print the relativized value of each specified register regname. As 
  3568.            discussed in detail below, register values are normally relative to 
  3569.            the selected stack frame.  regname may be any register name valid on 
  3570.            the machine you are using, with or without the initial `$'. 
  3571.  
  3572.   has four ``standard'' register names that are available (in expressions) on 
  3573.  most machines---whenever they do not conflict with an architecture's canonical 
  3574.  mnemonics for registers.  The register names $pc and $sp are used for the 
  3575.  program counter register and the stack pointer.  $fp is used for a register 
  3576.  that contains a pointer to the current stack frame, and $ps is used for a 
  3577.  register that contains the processor status.  For example, you could print the 
  3578.  program counter in hex with 
  3579.  
  3580.   p/x $pc
  3581.  
  3582.  or print the instruction to be executed next with 
  3583.  
  3584.   x/i $pc
  3585.  
  3586.  or add four to the stack pointer(2) with 
  3587.  
  3588.   set $sp += 4
  3589.  
  3590.  Whenever possible, these four standard register names are available on your 
  3591.  machine even though the machine has different canonical mnemonics, so long as 
  3592.  there is no conflict.  The info registers command shows the canonical names. 
  3593.  For example, on the SPARC, info registers displays the processor status 
  3594.  register as $psr but you can also refer to it as $ps. 
  3595.  
  3596.   always considers the contents of an ordinary register as an integer when the 
  3597.  register is examined in this way.  Some machines have special registers which 
  3598.  can hold nothing but floating point; these registers are considered to have 
  3599.  floating point values.  There is no way to refer to the contents of an 
  3600.  ordinary register as floating point value (although you can print it as a 
  3601.  floating point value with `print/f $regname'). 
  3602.  
  3603.  Some registers have distinct ``raw'' and ``virtual'' data formats.  This means 
  3604.  that the data format in which the register contents are saved by the operating 
  3605.  system is not the same one that your program normally sees.  For example, the 
  3606.  registers of the 68881 floating point coprocessor are always saved in 
  3607.  ``extended'' (raw) format, but all C programs expect to work with ``double'' 
  3608.  (virtual) format.  In such cases,  normally works with the virtual format only 
  3609.  (the format that makes sense for your program), but the info registers command 
  3610.  prints the data in both formats. 
  3611.  
  3612.  Normally, register values are relative to the selected stack frame (see 
  3613.  Selecting a frame).  This means that you get the value that the register would 
  3614.  contain if all stack frames farther in were exited and their saved registers 
  3615.  restored.  In order to see the true contents of hardware registers, you must 
  3616.  select the innermost frame (with `frame 0'). 
  3617.  
  3618.  However,  must deduce where registers are saved, from the machine code 
  3619.  generated by your compiler.  If some registers are not saved, or if  is unable 
  3620.  to locate the saved registers, the selected stack frame makes no difference. 
  3621.  
  3622.  
  3623. ΓòÉΓòÉΓòÉ 11.11. Floating point hardware ΓòÉΓòÉΓòÉ
  3624.  
  3625. Depending on the configuration,  may be able to give you more information about 
  3626. the status of the floating point hardware. 
  3627.  
  3628.  info float 
  3629.            Display hardware-dependent information about the floating point 
  3630.            unit.  The exact contents and layout vary depending on the floating 
  3631.            point chip.  Currently, `info float' is supported on the ARM and x86 
  3632.            machines. 
  3633.  
  3634.  
  3635. ΓòÉΓòÉΓòÉ 12. Using  with Different Languages ΓòÉΓòÉΓòÉ
  3636.  
  3637. Language-specific information is built into  for some languages, allowing you 
  3638. to express operations like the above in your program's native language, and 
  3639. allowing  to output values in a manner consistent with the syntax of your 
  3640. program's native language.  The language you use to build expressions is called 
  3641. the working language. 
  3642.  
  3643.  Setting                                 Switching between source languages 
  3644.  Show                                    Displaying the language 
  3645.  
  3646.  Checks                                  Type and range checks 
  3647.  
  3648.  Support                                 Supported languages 
  3649.  
  3650.  
  3651. ΓòÉΓòÉΓòÉ 12.1. Switching between source languages ΓòÉΓòÉΓòÉ
  3652.  
  3653. There are two ways to control the working language---either have set it 
  3654. automatically, or select it manually yourself.  You can use the set language 
  3655. command for either purpose.  On startup, defaults to setting the language 
  3656. automatically.  The working language is used to determine how expressions you 
  3657. type are interpreted, how values are printed, etc. 
  3658.  
  3659. In addition to the working language, every source file that  knows about has 
  3660. its own working language.  For some object file formats, the compiler might 
  3661. indicate which language a particular source file is in.  However, most of the 
  3662. time  infers the language from the name of the file.  The language of a source 
  3663. file controls whether C++ names are demangled---this way backtrace can show 
  3664. each frame appropriately for its own language.  There is no way to set the 
  3665. language of a source file from within . 
  3666.  
  3667. This is most commonly a problem when you use a program, such as cfront or f2c, 
  3668. that generates C but is written in another language.  In that case, make the 
  3669. program use #line directives in its C output; that way  will know the correct 
  3670. language of the source code of the original program, and will display that 
  3671. source code, not the generated C code. 
  3672.  
  3673.  Filenames                               Filename extensions and languages. 
  3674.  Manually                                Setting the working language manually 
  3675.  Automatically                           Having GDBN infer the source language 
  3676.  
  3677.  
  3678. ΓòÉΓòÉΓòÉ 12.1.1. List of filename extensions and languages ΓòÉΓòÉΓòÉ
  3679.  
  3680. If a source file name ends in one of the following extensions, then  infers 
  3681. that its language is the one indicated. 
  3682.  
  3683.  `.ada' 
  3684.  `.ads' 
  3685.  `.adb' 
  3686.  `.a' 
  3687.            Ada source file. 
  3688.  
  3689.  `.c' 
  3690.            C source file 
  3691.  
  3692.  `.C' 
  3693.  `.cc' 
  3694.  `.cxx' 
  3695.  `.cpp' 
  3696.  `.cp' 
  3697.  `.c++' 
  3698.            C++ source file 
  3699.  
  3700.  `.ch' 
  3701.  `.c186' 
  3702.  `.c286' 
  3703.            CHILL source file. 
  3704.  
  3705.  `.s' 
  3706.  `.S' 
  3707.            Assembler source file.  This actually behaves almost like C, but 
  3708.            does not skip over function prologues when stepping. 
  3709.  
  3710.  
  3711. ΓòÉΓòÉΓòÉ 12.1.2. Setting the working language ΓòÉΓòÉΓòÉ
  3712.  
  3713. If you allow  to set the language automatically, expressions are interpreted 
  3714. the same way in your debugging session and your program. 
  3715.  
  3716. If you wish, you may set the language manually.  To do this, issue the command 
  3717. `set language lang', where lang is the name of a language, such as c. For a 
  3718. list of the supported languages, type `set language'. 
  3719.  
  3720.  
  3721. ΓòÉΓòÉΓòÉ 12.1.3. Having  infer the source language ΓòÉΓòÉΓòÉ
  3722.  
  3723. To have  set the working language automatically, use `set language local' or 
  3724. `set language auto'. then infers the working language.  That is, when your 
  3725. program stops in a frame (usually by encountering a breakpoint),  sets the 
  3726. working language to the language recorded for the function in that frame.  If 
  3727. the language for a frame is unknown (that is, if the function or block 
  3728. corresponding to the frame was defined in a source file that does not have a 
  3729. recognized extension), the current working language is not changed, and  issues 
  3730. a warning. 
  3731.  
  3732. This may not seem necessary for most programs, which are written entirely in 
  3733. one source language.  However, program modules and libraries written in one 
  3734. source language can be used by a main program written in a different source 
  3735. language.  Using `set language auto' in this case frees you from having to set 
  3736. the worE13p-unx-docs\texi\gdb.texinfo line 5577 : unrecognized Texinfo command 
  3737. @raisesections king language manually. 
  3738.  
  3739.  
  3740. ΓòÉΓòÉΓòÉ 12.2. Displaying the language ΓòÉΓòÉΓòÉ
  3741.  
  3742. The following commands help you find out which language is the working 
  3743. language, and also what language source files were written in. 
  3744.  
  3745.  show language 
  3746.            Display the current working language.  This is the language you can 
  3747.            use with commands such as print to build and compute expressions 
  3748.            that may involve variables in your program. 
  3749.  
  3750.  info frame 
  3751.            Display the source language for this frame.  This language becomes 
  3752.            the working language if you use an identifier from this frame. See 
  3753.            Information about a frame, to identify the other information listed 
  3754.            here. 
  3755.  
  3756.  info source 
  3757.            Display the source language of this source file. See Examining the 
  3758.            Symbol Table, to identify the other information listed here. 
  3759.  
  3760.  Type Checking                           An overview of type checking 
  3761.  
  3762.  
  3763.  Range Checking                          An overview of range checking 
  3764.  
  3765.  
  3766. ΓòÉΓòÉΓòÉ 12.3. Supported languages ΓòÉΓòÉΓòÉ
  3767.  
  3768.  4 supports C, and C++. Some  features may be used in expressions regardless of 
  3769. the language you use: the  @ and :: operators, and the `{type}addr' construct ( 
  3770. see Expressions) can be used with the constructs of any supported language. 
  3771.  
  3772. The following sections detail to what degree each source language is supported 
  3773. by .  These sections are not meant to be language tutorials or references, but 
  3774. serve only as a reference guide to what the  expression parser accepts, and 
  3775. what input and output formats should look like for different languages.  There 
  3776. are many good books written on each of these languages; please look to these 
  3777. for a language reference or tutorial. 
  3778.  
  3779.  C                                       C and C++ 
  3780.  
  3781.  Modula-2                                Modula-2 
  3782.  
  3783.  Ada                                     Ada 
  3784.  
  3785.  
  3786. ΓòÉΓòÉΓòÉ 12.3.1. C and C++ ΓòÉΓòÉΓòÉ
  3787.  
  3788. Since C and C++ are so closely related, many features of  apply to both 
  3789. languages.  Whenever this is the case, we discuss those languages together. 
  3790.  
  3791. The C++ debugging facilities are jointly implemented by the gnu C++ compiler 
  3792. and .  Therefore, to debug your C++ code effectively, you must compile your C++ 
  3793. programs with the gnu C++ compiler, g++. 
  3794.  
  3795. For best results when debugging C++ programs, use the stabs debugging format. 
  3796. You can select that format explicitly with the g++ command-line options 
  3797. `-gstabs' or `-gstabs+'.  See Options for Debugging Your Program or gnu CC, for 
  3798. more information. 
  3799.  
  3800.  C Operators                             C operators 
  3801.  
  3802.  
  3803.  C Constants                             C constants 
  3804.  Debugging C                             GDBN and C 
  3805.  
  3806.  C Operators                             C and C++ operators 
  3807.  C Constants                             C and C++ constants 
  3808.  Cplus expressions                       C++ expressions 
  3809.  C Defaults                              Default settings for C and C++ 
  3810.  
  3811.  C Checks                                C and C++ type and range checks 
  3812.  
  3813.  Debugging C                             GDBN and C 
  3814.  Debugging C plus plus                   Special features for C++ 
  3815.  
  3816.  
  3817. ΓòÉΓòÉΓòÉ 12.3.1.1. C and C++ operators ΓòÉΓòÉΓòÉ
  3818.  
  3819. Operators must be defined on values of specific types.  For instance, 
  3820.  
  3821. + is defined on numbers, but not on structures.  Operators are often defined on 
  3822. groups of types. 
  3823.  
  3824. For the purposes of C and C++, the following definitions hold: 
  3825.  
  3826.      Integral types include int with any of its storage-class specifiers; 
  3827.       char; and enum. 
  3828.  
  3829.      Floating-point types include float and double. 
  3830.  
  3831.      Pointer types include all types defined as (type *). 
  3832.  
  3833.      Scalar types include all of the above. 
  3834.  
  3835.  The following operators are supported.  They are listed here in order of 
  3836.  increasing precedence: 
  3837.  
  3838.  , 
  3839.            The comma or sequencing operator.  Expressions in a comma-separated 
  3840.            list are evaluated from left to right, with the result of the entire 
  3841.            expression being the last expression evaluated. 
  3842.  
  3843.  = 
  3844.            Assignment.  The value of an assignment expression is the value 
  3845.            assigned.  Defined on scalar types. 
  3846.  
  3847.  op= 
  3848.            Used in an expression of the form a op= b, and translated to a = a 
  3849.            op b. op= and = have the same precendence. op is any one of the 
  3850.            operators |, ^, &, <<, >>, +, -, *, /, %. 
  3851.  
  3852.  ?: 
  3853.            The ternary operator.  a ? b : c can be thought of as:  if a then b 
  3854.            else c.  a should be of an integral type. 
  3855.  
  3856.  || 
  3857.            Logical or.  Defined on integral types. 
  3858.  
  3859.  && 
  3860.            Logical and.  Defined on integral types. 
  3861.  
  3862.  | 
  3863.            Bitwise or.  Defined on integral types. 
  3864.  
  3865.  ^ 
  3866.            Bitwise exclusive-or.  Defined on integral types. 
  3867.  
  3868.  & 
  3869.            Bitwise and.  Defined on integral types. 
  3870.  
  3871.  ==, != 
  3872.            Equality and inequality.  Defined on scalar types.  The value of 
  3873.            these expressions is 0 for false and non-zero for true. 
  3874.  
  3875.  <, >, <=, >= 
  3876.            Less than, greater than, less than or equal, greater than or equal. 
  3877.            Defined on scalar types.  The value of these expressions is 0 for 
  3878.            false and non-zero for true. 
  3879.  
  3880.  <<, >> 
  3881.            left shift, and right shift.  Defined on integral types. 
  3882.  
  3883.  @ 
  3884.            The  ``artificial array'' operator (see Expressions). 
  3885.  
  3886.  +, - 
  3887.            Addition and subtraction.  Defined on integral types, floating-point 
  3888.            types and pointer types. 
  3889.  
  3890.  *, /, % 
  3891.            Multiplication, division, and modulus.  Multiplication and division 
  3892.            are defined on integral and floating-point types.  Modulus is 
  3893.            defined on integral types. 
  3894.  
  3895.  ++, -- 
  3896.            Increment and decrement.  When appearing before a variable, the 
  3897.            operation is performed before the variable is used in an expression; 
  3898.            when appearing after it, the variable's value is used before the 
  3899.            operation takes place. 
  3900.  
  3901.  * 
  3902.            Pointer dereferencing.  Defined on pointer types.  Same precedence 
  3903.            as ++. 
  3904.  
  3905.  & 
  3906.            Address operator.  Defined on variables.  Same precedence as ++. 
  3907.  
  3908.            For debugging C++,  implements a use of `&' beyond what is allowed 
  3909.            in the C++ language itself: you can use `&(&ref)' (or, if you 
  3910.            prefer, simply `&&ref') to examine the address where a C++ reference 
  3911.            variable (declared with `&ref') is stored. 
  3912.  
  3913.  - 
  3914.            Negative.  Defined on integral and floating-point types.  Same 
  3915.            precedence as ++. 
  3916.  
  3917.  ! 
  3918.            Logical negation.  Defined on integral types.  Same precedence as 
  3919.            ++. 
  3920.  
  3921.  ~ 
  3922.            Bitwise complement operator.  Defined on integral types.  Same 
  3923.            precedence as ++. 
  3924.  
  3925.  ., -> 
  3926.            Structure member, and pointer-to-structure member.  For convenience, 
  3927.            regards the two as equivalent, choosing whether to dereference a 
  3928.            pointer based on the stored type information. Defined on struct and 
  3929.            union data. 
  3930.  
  3931.  [] 
  3932.            Array indexing.  a[i] is defined as *(a+i).  Same precedence as ->. 
  3933.  
  3934.  () 
  3935.            Function parameter list.  Same precedence as ->. 
  3936.  
  3937.  :: 
  3938.            C++ scope resolution operator.  Defined on struct, union, and class 
  3939.            types. 
  3940.  
  3941.  :: 
  3942.            Doubled colons also represent the  scope operator ( see 
  3943.            Expressions). Same precedence as ::, above. 
  3944.  
  3945.  
  3946. ΓòÉΓòÉΓòÉ 12.3.1.2. C and C++ constants ΓòÉΓòÉΓòÉ
  3947.  
  3948.  allows you to express the constants of C and C++ in the following ways: 
  3949.  
  3950.      Integer constants are a sequence of digits.  Octal constants are 
  3951.       specified by a leading `0' (i.e. zero), and hexadecimal constants by a 
  3952.       leading `0x' or `0X'.  Constants may also end with a letter `l', 
  3953.       specifying that the constant should be treated as a long value. 
  3954.  
  3955.      Floating point constants are a sequence of digits, followed by a decimal 
  3956.       point, followed by a sequence of digits, and optionally followed by an 
  3957.       exponent.  An exponent is of the form: `e[[+]|-]nnn', where nnn is 
  3958.       another sequence of digits.  The `+' is optional for positive exponents. 
  3959.  
  3960.      Enumerated constants consist of enumerated identifiers, or their integral 
  3961.       equivalents. 
  3962.  
  3963.      Character constants are a single character surrounded by single quotes 
  3964.       ('), or a number---the ordinal value of the corresponding character 
  3965.       (usually its ASCII value).  Within quotes, the single character may be 
  3966.       represented by a letter or by escape sequences, which are of the form 
  3967.       `\nnn', where nnn is the octal representation of the character's ordinal 
  3968.       value; or of the form `\x', where `x' is a predefined special 
  3969.       character---for example, `\n' for newline. 
  3970.  
  3971.      String constants are a sequence of character constants surrounded by 
  3972.       double quotes ("). 
  3973.  
  3974.      Pointer constants are an integral value.  You can also write pointers to 
  3975.       constants using the C operator `&'. 
  3976.  
  3977.      Array constants are comma-separated lists surrounded by braces `{' and 
  3978.       `}'; for example, `{1,2,3}' is a three-element array of integers, 
  3979.       `{{1,2}, {3,4}, {5,6}}' is a three-by-two array, and `{&"hi", &"there", 
  3980.       &"fred"}' is a three-element array of pointers. 
  3981.  
  3982.  
  3983. ΓòÉΓòÉΓòÉ 12.3.1.3. C++ expressions ΓòÉΓòÉΓòÉ
  3984.  
  3985.  expression handling has a number of extensions to interpret a significant 
  3986. subset of C++ expressions. 
  3987.  
  3988. Warning:  can only debug C++ code if you compile with the gnu C++ compiler. 
  3989. Moreover, C++ debugging depends on the use of additional debugging information 
  3990. in the symbol table, and thus requires special support.  has this support only 
  3991. with the stabs debug format.  In particular, if your compiler generates a.out, 
  3992. MIPS ecoff, RS/6000 xcoff, or elf with stabs extensions to the symbol table, 
  3993. these facilities are all available.  (With gnu CC, you can use the `-gstabs' 
  3994. option to request stabs debugging extensions explicitly.)  Where the object 
  3995. code format is standard coff or dwarf in elf, on the other hand, most of the 
  3996. C++ support in  does not work. 
  3997.  
  3998.    1. Member function calls are allowed; you can use expressions like 
  3999.  
  4000.             count = aml->GetOriginal(x, y)
  4001.  
  4002.    2. While a member function is active (in the selected stack frame), your 
  4003.       expressions have the same namespace available as the member function; 
  4004.       that is,  allows implicit references to the class instance pointer this 
  4005.       following the same rules as C++. 
  4006.  
  4007.    3. You can call overloaded functions;  resolves the function call to the 
  4008.       right definition, with one restriction---you must use arguments of the 
  4009.       type required by the function that you want to call.  does not perform 
  4010.       conversions requiring constructors or user-defined type operators. 
  4011.  
  4012.    4. understands variables declared as C++ references; you can use them in 
  4013.       expressions just as you do in C++ source---they are automatically 
  4014.       dereferenced. 
  4015.  
  4016.       In the parameter list shown when  displays a frame, the values of 
  4017.       reference variables are not displayed (unlike other variables); this 
  4018.       avoids clutter, since references are often used for large structures. The 
  4019.       address of a reference variable is always shown, unless you have 
  4020.       specified `set print address off'. 
  4021.  
  4022.    5. supports the C++ name resolution operator ::---your expressions can use 
  4023.       it just as expressions in your program do.  Since one scope may be 
  4024.       defined in another, you can use :: repeatedly if necessary, for example 
  4025.       in an expression like `scope1::scope2::name'.  also allows resolving name 
  4026.       scope by reference to source files, in both C and C++ debugging (see 
  4027.       Program variables). 
  4028.  
  4029.  
  4030. ΓòÉΓòÉΓòÉ 12.3.1.4. C and C++ defaults ΓòÉΓòÉΓòÉ
  4031.  
  4032. If you allow  to set type and range checking automatically, they both default 
  4033. to off whenever the working language changes to C or C++.  This happens 
  4034. regardless of whether you or selects the working language. 
  4035.  
  4036. If you allow  to set the language automatically, it recognizes source files 
  4037. whose names end with `.c', `.C', or `.cc', and when  enters code compiled from 
  4038. one of these files, it sets the working language to C or C++. See Having  infer 
  4039. the source language, for further details. 
  4040.  
  4041.  
  4042. ΓòÉΓòÉΓòÉ 12.3.1.5. and C ΓòÉΓòÉΓòÉ
  4043.  
  4044. The set print union and show print union commands apply to 
  4045.  
  4046. the union type.  When set to `on', any union that is inside a struct or class 
  4047. is also printed. Otherwise, it appears as `{...}'. 
  4048.  
  4049. The @ operator aids in the debugging of dynamic arrays, formed with pointers 
  4050. and a memory allocation function. See Expressions. 
  4051.  
  4052.  
  4053. ΓòÉΓòÉΓòÉ 12.3.1.6. features for C++ ΓòÉΓòÉΓòÉ
  4054.  
  4055. Some  commands are particularly useful with C++, and some are designed 
  4056. specifically for use with C++.  Here is a summary: 
  4057.  
  4058.  breakpoint menus 
  4059.            When you want a breakpoint in a function whose name is overloaded, 
  4060.            breakpoint menus help you specify which function definition you 
  4061.            want.  See Breakpoint menus. 
  4062.  
  4063.  rbreak regex 
  4064.            Setting breakpoints using regular expressions is helpful for setting 
  4065.            breakpoints on overloaded functions that are not members of any 
  4066.            special classes. See Setting breakpoints. 
  4067.  
  4068.  catch exceptions 
  4069.  info catch 
  4070.            Debug C++ exception handling using these commands. See Breakpoints 
  4071.            and exceptions. 
  4072.  
  4073.  ptype typename13p-unx-docs\texi\gdb.texinfo line 6071 : unrecognized Texinfo 
  4074.  command @lowersections facename=default size=0x0. 
  4075.            Print inheritance relationships as well as other information for 
  4076.            type typename. See Examining the Symbol Table. 
  4077.  
  4078.  set print demangle 
  4079.  show print demangle 
  4080.  set print asm-demangle 
  4081.  show print asm-demangle 
  4082.            Control whether C++ symbols display in their source form, both when 
  4083.            displaying code as C++ source and when displaying disassemblies. See 
  4084.            Print settings. 
  4085.  
  4086.  set print object 
  4087.  show print object 
  4088.            Choose whether to print derived (actual) or declared types of 
  4089.            objects. See Print settings. 
  4090.  
  4091.  set print vtbl 
  4092.  show print vtbl 
  4093.            Control the format for printing virtual function tables. See Print 
  4094.            settings. 
  4095.  
  4096.  Overloaded symbol names 
  4097.            You can specify a particular definition of an overloaded symbol, 
  4098.            using the same notation that is used to declare such symbols in C++: 
  4099.            type symbol(types) rather than just symbol.  You can also use the 
  4100.            command-line word completion facilities to list the available 
  4101.            choices, or to finish the type list for you. See Command completion, 
  4102.            for details on how to do this. 
  4103.  
  4104.  M2 Operators                            Built-in operators 
  4105.  
  4106.  
  4107.  Built-In Func/Proc                      Built-in functions and procedures 
  4108.  M2 Constants                            Modula-2 constants 
  4109.  M2 Defaults                             Default settings for Modula-2 
  4110.  Deviations                              Deviations from standard Modula-2 
  4111.  M2 Checks                               Modula-2 type and range checks 
  4112.  M2 Scope                                The scope operators :: and . 
  4113.  GDB/M2                                  GDBN and Modula-2 
  4114.  
  4115.  Ada Mode Intro                          General remarks on the Ada syntax 
  4116.  
  4117.                                          and semantics supported by Ada mode in 
  4118.                                          GDBN 
  4119.  Omissions from Ada                      Restrictions on the Ada expression 
  4120.                                          syntax. 
  4121.  Additions to Ada                        Extensions of the Ada expression 
  4122.                                          syntax. 
  4123.  Stopping at Main Program                Executing to the beginning of the main 
  4124.                                          program. 
  4125.  Ada Exceptions                          Setting breakpoints on exception 
  4126.                                          handlers. 
  4127.  Ada Tasks                               Listing and setting breakpoints in 
  4128.                                          tasks. 
  4129.  Ada Generic Units                       Dealing with generic instantiations. 
  4130.  Ada Set Commands                        New settable GDB parameters for Ada. 
  4131.  Ada Glitches                            Known peculiarities of Ada mode. 
  4132.  
  4133.  
  4134. ΓòÉΓòÉΓòÉ 13. Examining the Symbol Table ΓòÉΓòÉΓòÉ
  4135.  
  4136. The commands described in this section allow you to inquire about the symbols 
  4137. (names of variables, functions and types) defined in your program.  This 
  4138. information is inherent in the text of your program and does not change as your 
  4139. program executes.  finds it in your program's symbol table, in the file 
  4140. indicated when you started (see Choosing files), or by one of the 
  4141. file-management commands (see Commands to specify files). 
  4142.  
  4143. Occasionally, you may need to refer to symbols that contain unusual characters, 
  4144. which  ordinarily treats as word delimiters.  The most frequent case is in 
  4145. referring to static variables in other source files (see Program variables). 
  4146. File names are recorded in object files as debugging symbols, but  would 
  4147. ordinarily parse a typical file name, like `foo.c', as the three words `foo' 
  4148. `.' `c'.  To allow  to recognize `foo.c' as a single symbol, enclose it in 
  4149. single quotes; for example, 
  4150.  
  4151. p 'foo.c'::x
  4152.  
  4153. looks up the value of x in the scope of the file `foo.c'. 
  4154.  
  4155.  info address symbol 
  4156.            Describe where the data for symbol is stored.  For a register 
  4157.            variable, this says which register it is kept in.  For a 
  4158.            non-register local variable, this prints the stack-frame offset at 
  4159.            which the variable is always stored. 
  4160.  
  4161.            Note the contrast with `print &symbol', which does not work at all 
  4162.            for a register variable, and for a stack local variable prints the 
  4163.            exact address of the current instantiation of the variable. 
  4164.  
  4165.  whatis exp 
  4166.            Print the data type of expression exp.  exp is not actually 
  4167.            evaluated, and any side-effecting operations (such as assignments or 
  4168.            function calls) inside it do not take place. See Expressions. 
  4169.  
  4170.  whatis 
  4171.            Print the data type of $, the last value in the value history. 
  4172.  
  4173.  ptype typename 
  4174.            Print a description of data type typename.  typename may be the name 
  4175.            of a type, or for C code it may have the form `class class-name', 
  4176.            `struct struct-tag', `union union-tag' or `enum enum-tag'. 
  4177.  
  4178.  ptype exp 
  4179.  ptype 
  4180.            Print a description of the type of expression exp.  ptype differs 
  4181.            from whatis by printing a detailed description, instead of just the 
  4182.            name of the type. 
  4183.  
  4184.            For example, for this variable declaration: 
  4185.  
  4186.                       struct complex {double real; double imag;} v;
  4187.  
  4188.            the two commands give this output: 
  4189.  
  4190.                       () whatis v
  4191.                       type = struct complex
  4192.                       () ptype v
  4193.                       type = struct complex {
  4194.                           double real;
  4195.                           double imag;
  4196.                       }
  4197.  
  4198.            As with whatis, using ptype without an argument refers to the type 
  4199.            of $, the last value in the value history. 
  4200.  
  4201.  info types regexp 
  4202.  info types 
  4203.            Print a brief description of all types whose name matches regexp (or 
  4204.            all types in your program, if you supply no argument).  Each 
  4205.            complete typename is matched as though it were a complete line; 
  4206.            thus, `i type value' gives information on all types in your program 
  4207.            whose name includes the string value, but `i type ^value$' gives 
  4208.            information only on types whose complete name is value. 
  4209.  
  4210.            This command differs from ptype in two ways: first, like whatis, it 
  4211.            does not print a detailed description; second, it lists all source 
  4212.            files where a type is defined. 
  4213.  
  4214.  info source 
  4215.            Show the name of the current source file---that is, the source file 
  4216.            for the function containing the current point of execution---and the 
  4217.            language it was written in. 
  4218.  
  4219.  info sources 
  4220.            Print the names of all source files in your program for which there 
  4221.            is debugging information, organized into two lists: files whose 
  4222.            symbols have already been read, and files whose symbols will be read 
  4223.            when needed. 
  4224.  
  4225.  info functions 
  4226.            Print the names and data types of all defined functions. 
  4227.  
  4228.  info functions regexp 
  4229.            Print the names and data types of all defined functions whose names 
  4230.            contain a match for regular expression regexp. Thus, `info fun step' 
  4231.            finds all functions whose names include step; `info fun ^step' finds 
  4232.            those whose names start with step. 
  4233.  
  4234.  info variables 
  4235.            Print the names and data types of all variables that are declared 
  4236.            outside of functions (i.e., excluding local variables). 
  4237.  
  4238.  info variables regexp 
  4239.            Print the names and data types of all variables (except for local 
  4240.            variables) whose names contain a match for regular expression 
  4241.            regexp. 
  4242.  
  4243.            Some systems allow individual object files that make up your program 
  4244.            to be replaced without stopping and restarting your program. If you 
  4245.            are running on one of these systems, you can allow  to reload the 
  4246.            symbols for automatically relinked modules: 
  4247.  
  4248.            set symbol-reloading on 
  4249.                           Replace symbol definitions for the corresponding 
  4250.                           source file when an object file with a particular 
  4251.                           name is seen again. 
  4252.  
  4253.            set symbol-reloading off 
  4254.                           Do not replace symbol definitions when 
  4255.                           re-encountering object files of the same name.  This 
  4256.                           is the default state; if you are not running on a 
  4257.                           system that permits automatically relinking modules, 
  4258.                           you should leave symbol-reloading off, since 
  4259.                           otherwise  may discard symbols when linking large 
  4260.                           programs, that may contain several modules (from 
  4261.                           different directories or libraries) with the same 
  4262.                           name. 
  4263.  
  4264.            show symbol-reloading 
  4265.                           Show the current on or off setting. 
  4266.  
  4267.  maint print symbols filename 
  4268.  maint print psymbols filename 
  4269.  maint print msymbols filename 
  4270.            Write a dump of debugging symbol data into the file filename. These 
  4271.            commands are used to debug the  symbol-reading code.  Only symbols 
  4272.            with debugging data are included.  If you use `maint print symbols', 
  4273.            includes all the symbols for which it has already collected full 
  4274.            details: that is, filename reflects symbols for only those files 
  4275.            whose symbols  has read.  You can use the command info sources to 
  4276.            find out which files these are.  If you use `maint print psymbols' 
  4277.            instead, the dump shows information about symbols that  only knows 
  4278.            partially---that is, symbols defined in files that  has skimmed, but 
  4279.            not yet read completely.  Finally, `maint print msymbols' dumps just 
  4280.            the minimal symbol information required for each object file from 
  4281.            which  has read some symbols. See Commands to specify files, for a 
  4282.            discussion of how  reads symbols (in the description of 
  4283.            symbol-file). 
  4284.  
  4285.  
  4286. ΓòÉΓòÉΓòÉ 14. Altering Execution ΓòÉΓòÉΓòÉ
  4287.  
  4288. Once you think you have found an error in your program, you might want to find 
  4289. out for certain whether correcting the apparent error would lead to correct 
  4290. results in the rest of the run.  You can find the answer by experiment, using 
  4291. the  features for altering execution of the program. 
  4292.  
  4293. For example, you can store new values into variables or memory locations, give 
  4294. your program a signal, restart it at a different address, or even return 
  4295. prematurely from a function. 
  4296.  
  4297.  Assignment                              Assignment to variables 
  4298.  Jumping                                 Continuing at a different address 
  4299.  
  4300.  Signaling                               Giving your program a signal 
  4301.  
  4302.  Returning                               Returning from a function 
  4303.  Calling                                 Calling your program's functions 
  4304.  Patching                                Patching your program 
  4305.  
  4306.  
  4307. ΓòÉΓòÉΓòÉ 14.1. Assignment to variables ΓòÉΓòÉΓòÉ
  4308.  
  4309. To alter the value of a variable, evaluate an assignment expression. See 
  4310. Expressions.  For example, 
  4311.  
  4312. print x=4
  4313.  
  4314. stores the value 4 into the variable x, and then prints the value of the 
  4315. assignment expression (which is 4). See Using  with Different Languages, for 
  4316. more information on operators in supported languages. 
  4317.  
  4318. If you are not interested in seeing the value of the assignment, use the set 
  4319. command instead of the print command.  set is really the same as print except 
  4320. that the expression's value is not printed and is not put in the value history 
  4321. ( see Value history).  The expression is evaluated only for its effects. 
  4322.  
  4323. If the beginning of the argument string of the set command appears identical to 
  4324. a set subcommand, use the set variable command instead of just set.  This 
  4325. command is identical to set except for its lack of subcommands.  For example, 
  4326. if your program has a variable width, you get an error if you try to set a new 
  4327. value with just `set width=13', because  has the command set width: 
  4328.  
  4329. () whatis width
  4330. type = double
  4331. () p width
  4332. $4 = 13
  4333. () set width=47
  4334. Invalid syntax in expression.
  4335.  
  4336. The invalid expression, of course, is `=47'.  In order to actually set the 
  4337. program's variable width, use 
  4338.  
  4339. () set var width=47
  4340.  
  4341.  allows more implicit conversions in assignments than C; you can freely store 
  4342. an integer value into a pointer variable or vice versa, and you can convert any 
  4343. structure to any other structure that is the same length or shorter. 
  4344.  
  4345. To store values into arbitrary places in memory, use the `{...}' construct to 
  4346. generate a value of specified type at a specified address (see Expressions). 
  4347. For example, {int}0x83040 refers to memory location 0x83040 as an integer 
  4348. (which implies a certain size and representation in memory), and 
  4349.  
  4350. set {int}0x83040 = 4
  4351.  
  4352. stores the value 4 into that memory location. 
  4353.  
  4354.  
  4355. ΓòÉΓòÉΓòÉ 14.2. Continuing at a different address ΓòÉΓòÉΓòÉ
  4356.  
  4357. Ordinarily, when you continue your program, you do so at the place where it 
  4358. stopped, with the continue command.  You can instead continue at an address of 
  4359. your own choosing, with the following commands: 
  4360.  
  4361.  jump linespec 
  4362.            Resume execution at line linespec.  Execution stops again 
  4363.            immediately if there is a breakpoint there. See Printing source 
  4364.            lines, for a description of the different forms of linespec. 
  4365.  
  4366.            The jump command does not change the current stack frame, or the 
  4367.            stack pointer, or the contents of any memory location or any 
  4368.            register other than the program counter.  If line linespec is in a 
  4369.            different function from the one currently executing, the results may 
  4370.            be bizarre if the two functions expect different patterns of 
  4371.            arguments or of local variables.  For this reason, the jump command 
  4372.            requests confirmation if the specified line is not in the function 
  4373.            currently executing.  However, even bizarre results are predictable 
  4374.            if you are well acquainted with the machine-language code of your 
  4375.            program. 
  4376.  
  4377.  jump *address 
  4378.            Resume execution at the instruction at address address. 
  4379.  
  4380.  You can get much the same effect as the jump command by storing a new value 
  4381.  into the register $pc.  The difference is that this does not start your 
  4382.  program running; it only changes the address of where it will run when you 
  4383.  continue.  For example, 
  4384.  
  4385.   set $pc = 0x485
  4386.  
  4387.  makes the next continue command or stepping command execute at address 0x485, 
  4388.  rather than at the address where your program stopped. See Continuing and 
  4389.  stepping. 
  4390.  
  4391.  The most common occasion to use the jump command is to back up-- perhaps with 
  4392.  more breakpoints set--over a portion of a program that has already executed, 
  4393.  in order to examine its execution in more detail. 
  4394.  
  4395.  
  4396. ΓòÉΓòÉΓòÉ 14.3. Giving your program a signal ΓòÉΓòÉΓòÉ
  4397.  
  4398.  signal signal 
  4399.            Resume execution where your program stopped, but immediately give it 
  4400.            the signal signal.  signal can be the name or the number of a 
  4401.            signal.  For example, on many systems signal 2 and signal SIGINT are 
  4402.            both ways of sending an interrupt signal. 
  4403.  
  4404.            Alternatively, if signal is zero, continue execution without giving 
  4405.            a signal.  This is useful when your program stopped on account of a 
  4406.            signal and would ordinary see the signal when resumed with the 
  4407.            continue command; `signal 0' causes it to resume without a signal. 
  4408.  
  4409.            signal does not repeat when you press RET a second time after 
  4410.            executing the command. 
  4411.  
  4412.  Invoking the signal command is not the same as invoking the kill utility from 
  4413.  the shell.  Sending a signal with kill causes  to decide what to do with the 
  4414.  signal depending on the signal handling tables (see Signals).  The signal 
  4415.  command passes the signal directly to your program. 
  4416.  
  4417.  
  4418. ΓòÉΓòÉΓòÉ 14.4. Returning from a function ΓòÉΓòÉΓòÉ
  4419.  
  4420.  return 
  4421.  return expression 
  4422.            You can cancel execution of a function call with the return command. 
  4423.            If you give an expression argument, its value is used as the 
  4424.            function's return value. 
  4425.  
  4426.  When you use return,  discards the selected stack frame (and all frames within 
  4427.  it).  You can think of this as making the discarded frame return prematurely. 
  4428.  If you wish to specify a value to be returned, give that value as the argument 
  4429.  to return. 
  4430.  
  4431.  This pops the selected stack frame ( see Selecting a frame), and any other 
  4432.  frames inside of it, leaving its caller as the innermost remaining frame. 
  4433.  That frame becomes selected.  The specified value is stored in the registers 
  4434.  used for returning values of functions. 
  4435.  
  4436.  The return command does not resume execution; it leaves the program stopped in 
  4437.  the state that would exist if the function had just returned.  In contrast, 
  4438.  the finish command ( see Continuing and stepping) resumes execution until the 
  4439.  selected stack frame returns naturally. 
  4440.  
  4441.  
  4442. ΓòÉΓòÉΓòÉ 14.5. Calling program functions ΓòÉΓòÉΓòÉ
  4443.  
  4444.  call expr 
  4445.            Evaluate the expression expr without displaying void returned 
  4446.            values. 
  4447.  
  4448.  You can use this variant of the print command if you want to execute a 
  4449.  function from your program, but without cluttering the output with void 
  4450.  returned values.  If the result is not void, it is printed and saved in the 
  4451.  value history. 
  4452.  
  4453.  A new user-controlled variable, call_scratch_address, specifies the location 
  4454.  of a scratch area to be used when  calls a function in the target.  This is 
  4455.  necessary because the usual method of putting the scratch area on the stack 
  4456.  does not work in systems that have separate instruction and data spaces. 
  4457.  
  4458.  
  4459. ΓòÉΓòÉΓòÉ 14.6. Patching programs ΓòÉΓòÉΓòÉ
  4460.  
  4461. By default,  opens the file containing your program's executable code (or the 
  4462. corefile) read-only.  This prevents accidental alterations to machine code; but 
  4463. it also prevents you from intentionally patching your program's binary. 
  4464.  
  4465. If you'd like to be able to patch the binary, you can specify that explicitly 
  4466. with the set write command.  For example, you might want to turn on internal 
  4467. debugging flags, or even to make emergency repairs. 
  4468.  
  4469.  set write on 
  4470.  set write off 
  4471.            If you specify `set write on',  opens executable and core files for 
  4472.            both reading and writing; if you specify `set write off' (the 
  4473.            default),  opens them read-only. 
  4474.  
  4475.            If you have already loaded a file, you must load it again (using the 
  4476.            exec-file or core-file command) after changing set write, for your 
  4477.            new setting to take effect. 
  4478.  
  4479.  show write 
  4480.            Display whether executable files and core files are opened for 
  4481.            writing as well as reading. 
  4482.  
  4483.  
  4484. ΓòÉΓòÉΓòÉ 15. Files ΓòÉΓòÉΓòÉ
  4485.  
  4486.  needs to know the file name of the program to be debugged, both in order to 
  4487. read its symbol table and in order to start your program. To debug a core dump 
  4488. of a previous run, you must also tell the name of the core dump file. 
  4489.  
  4490.  Files                                   Commands to specify files 
  4491.  Symbol Errors                           Errors reading symbol files 
  4492.  
  4493.  
  4494. ΓòÉΓòÉΓòÉ 15.1. Commands to specify files ΓòÉΓòÉΓòÉ
  4495.  
  4496. You may want to specify executable and core dump file names. The usual way to 
  4497. do this is at start-up time, using the arguments to 's start-up commands ( see 
  4498. Getting In and Out of). 
  4499.  
  4500. Occasionally it is necessary to change to a different file during a  session. 
  4501. Or you may run  and forget to specify a file you want to use.  In these 
  4502. situations the  commands to specify new files are useful. 
  4503.  
  4504.  file filename 
  4505.            Use filename as the program to be debugged.  It is read for its 
  4506.            symbols and for the contents of pure memory.  It is also the program 
  4507.            executed when you use the run command.  If you do not specify a 
  4508.            directory and the file is not found in the  working directory,  uses 
  4509.            the environment variable PATH as a list of directories to search, 
  4510.            just as the shell does when looking for a program to run.  You can 
  4511.            change the value of this variable, for both and your program, using 
  4512.            the path command. 
  4513.  
  4514.            On systems with memory-mapped files, an auxiliary file 
  4515.            `filename.syms' may hold symbol table information for filename.  If 
  4516.            so,  maps in the symbol table from `filename.syms', starting up more 
  4517.            quickly.  See the descriptions of the file options `-mapped' and 
  4518.            `-readnow' (available on the command line, and with the commands 
  4519.            file, symbol-file, or add-symbol-file, described below), for more 
  4520.            information. 
  4521.  
  4522.  file 
  4523.            file with no argument makes  discard any information it has on both 
  4524.            executable file and the symbol table. 
  4525.  
  4526.  exec-file [ filename ] 
  4527.            Specify that the program to be run (but not the symbol table) is 
  4528.            found in filename.  searches the environment variable PATH if 
  4529.            necessary to locate your program.  Omitting filename means to 
  4530.            discard information on the executable file. 
  4531.  
  4532.  symbol-file [ filename ] 
  4533.            Read symbol table information from file filename.  PATH is searched 
  4534.            when necessary.  Use the file command to get both symbol table and 
  4535.            program to run from the same file. 
  4536.  
  4537.            symbol-file with no argument clears out  information on your 
  4538.            program's symbol table. 
  4539.  
  4540.            The symbol-file command causes  to forget the contents of its 
  4541.            convenience variables, the value history, and all breakpoints and 
  4542.            auto-display expressions.  This is because they may contain pointers 
  4543.            to the internal data recording symbols and data types, which are 
  4544.            part of the old symbol table data being discarded inside . 
  4545.  
  4546.            symbol-file does not repeat if you press RET again after executing 
  4547.            it once. 
  4548.  
  4549.            When  is configured for a particular environment, it understands 
  4550.            debugging information in whatever format is the standard generated 
  4551.            for that environment; you may use either a gnu compiler, or other 
  4552.            compilers that adhere to the local conventions.  Best results are 
  4553.            usually obtained from gnu compilers; for example, using  you can 
  4554.            generate debugging information for optimized code. 
  4555.  
  4556.            On some kinds of object files, the symbol-file command does not 
  4557.            normally read the symbol table in full right away.  Instead, it 
  4558.            scans the symbol table quickly to find which source files and which 
  4559.            symbols are present.  The details are read later, one source file at 
  4560.            a time, as they are needed. 
  4561.  
  4562.            The purpose of this two-stage reading strategy is to make  start up 
  4563.            faster.  For the most part, it is invisible except for occasional 
  4564.            pauses while the symbol table details for a particular source file 
  4565.            are being read.  (The set verbose command can turn these pauses into 
  4566.            messages if desired. See Optional warnings and messages.) 
  4567.  
  4568.            We have not implemented the two-stage strategy for COFF yet.  When 
  4569.            the symbol table is stored in COFF format, symbol-file reads the 
  4570.            symbol table data in full right away. 
  4571.  
  4572.  symbol-file filename [ -readnow ] [ -mapped ] 
  4573.  file filename [ -readnow ] [ -mapped ] 
  4574.            You can override the  two-stage strategy for reading symbol tables 
  4575.            by using the `-readnow' option with any of the commands that load 
  4576.            symbol table information, if you want to be sure  has the entire 
  4577.            symbol table available. 
  4578.  
  4579.            If memory-mapped files are available on your system through the mmap 
  4580.            system call, you can use another option, `-mapped', to cause  to 
  4581.            write the symbols for your program into a reusable file.  Future 
  4582.            debugging sessions map in symbol information from this auxiliary 
  4583.            symbol file (if the program has not changed), rather than spending 
  4584.            time reading the symbol table from the executable program.  Using 
  4585.            the `-mapped' option has the same effect as starting  with the 
  4586.            `-mapped' command-line option. 
  4587.  
  4588.            You can use both options together, to make sure the auxiliary symbol 
  4589.            file has all the symbol information for your program. 
  4590.  
  4591.            The auxiliary symbol file for a program called myprog is called 
  4592.            `myprog.syms'.  Once this file exists (so long as it is newer than 
  4593.            the corresponding executable),  always attempts to use it when you 
  4594.            debug myprog; no special options or commands are needed. 
  4595.  
  4596.            The `.syms' file is specific to the host machine where you run .  It 
  4597.            holds an exact image of the internal symbol table.  It cannot be 
  4598.            shared across multiple host platforms. 
  4599.  
  4600.  core-file [ filename ] 
  4601.            Specify the whereabouts of a core dump file to be used as the 
  4602.            ``contents of memory''.  Traditionally, core files contain only some 
  4603.            parts of the address space of the process that generated them;  can 
  4604.            access the executable file itself for other parts. 
  4605.  
  4606.            core-file with no argument specifies that no core file is to be 
  4607.            used. 
  4608.  
  4609.            Note that the core file is ignored when your program is actually 
  4610.            running under .  So, if you have been running your program and you 
  4611.            wish to debug a core file instead, you must kill the subprocess in 
  4612.            which the program is running.  To do this, use the kill command (see 
  4613.            Killing the child process). 
  4614.  
  4615.  load filename 
  4616.            The file is loaded at whatever address is specified in the 
  4617.            executable. For some object file formats, you can specify the load 
  4618.            address when you link the program; for other formats, like a.out, 
  4619.            the object file format specifies a fixed address. load does not 
  4620.            repeat if you press RET again after using it. 
  4621.  
  4622.  add-symbol-file filename address 
  4623.  add-symbol-file filename address [ -readnow ] [ -mapped ] 
  4624.            The add-symbol-file command reads additional symbol table 
  4625.            information from the file filename.  You would use this command when 
  4626.            filename has been dynamically loaded (by some other means) into the 
  4627.            program that is running.  address should be the memory address at 
  4628.            which the file has been loaded;  cannot figure this out for itself. 
  4629.            You can specify address as an expression. 
  4630.  
  4631.            The symbol table of the file filename is added to the symbol table 
  4632.            originally read with the symbol-file command.  You can use the 
  4633.            add-symbol-file command any number of times; the new symbol data 
  4634.            thus read keeps adding to the old.  To discard all old symbol data 
  4635.            instead, use the symbol-file command. 
  4636.  
  4637.            add-symbol-file does not repeat if you press RET after using it. 
  4638.  
  4639.            You can use the `-mapped' and `-readnow' options just as with the 
  4640.            symbol-file command, to change how  manages the symbol table 
  4641.            information for filename. 
  4642.  
  4643.  add-shared-symbol-file 
  4644.            The add-shared-symbol-file command can be used only under Harris' 
  4645.            CXUX operating system for the Motorola 88k.  automatically looks for 
  4646.            shared libraries, however if  does not find yours, you can run 
  4647.            add-shared-symbol-file.  It takes no arguments. 
  4648.  
  4649.  section 
  4650.            The section command changes the base address of section SECTION of 
  4651.            the exec file to ADDR.  This can be used if the exec file does not 
  4652.            contain section addresses, (such as in the a.out format), or when 
  4653.            the addresses specified in the file itself are wrong.  Each section 
  4654.            must be changed separately.  The ``info files'' command lists all 
  4655.            the sections and their addresses. 
  4656.  
  4657.  info files 
  4658.  info target 
  4659.            info files and info target are synonymous; both print the current 
  4660.            target (see Specifying a Debugging Target), including the names of 
  4661.            the executable and core dump files currently in use by , and the 
  4662.            files from which symbols were loaded.  The command help target lists 
  4663.            all possible targets rather than current ones. 
  4664.  
  4665.  All file-specifying commands allow both absolute and relative file names as 
  4666.  arguments.  always converts the file name to an absolute file name and 
  4667.  remembers it that way. 
  4668.  
  4669.   supports SunOS, SVr4, Irix 5, and IBM RS/6000 shared libraries. 
  4670.  automatically loads symbol definitions from shared libraries when you use the 
  4671.  run command, or when you examine a core file. (Before you issue the run 
  4672.  command,  does not understand references to a function in a shared library, 
  4673.  however---unless you are debugging a core file). 
  4674.  
  4675.  info share 
  4676.  info sharedlibrary 
  4677.            Print the names of the shared libraries which are currently loaded. 
  4678.  
  4679.  sharedlibrary regex 
  4680.  share regex 
  4681.            Load shared object library symbols for files matching a Unix regular 
  4682.            expression. As with files loaded automatically, it only loads shared 
  4683.            libraries required by your program for a core file or after typing 
  4684.            run.  If regex is omitted all shared libraries required by your 
  4685.            program are loaded. 
  4686.  
  4687.  
  4688. ΓòÉΓòÉΓòÉ 15.2. Errors reading symbol files ΓòÉΓòÉΓòÉ
  4689.  
  4690. While reading a symbol file,  occasionally encounters problems, such as symbol 
  4691. types it does not recognize, or known bugs in compiler output.  By default, 
  4692. does not notify you of such problems, since they are relatively common and 
  4693. primarily of interest to people debugging compilers.  If you are interested in 
  4694. seeing information about ill-constructed symbol tables, you can either ask  to 
  4695. print only one message about each such type of problem, no matter how many 
  4696. times the problem occurs; or you can ask  to print more messages, to see how 
  4697. many times the problems occur, with the set complaints command ( see Optional 
  4698. warnings and messages). 
  4699.  
  4700. The messages currently printed, and their meanings, include: 
  4701.  
  4702.  inner block not inside outer block in symbol 
  4703.            The symbol information shows where symbol scopes begin and end (such 
  4704.            as at the start of a function or a block of statements).  This error 
  4705.            indicates that an inner scope block is not fully contained in its 
  4706.            outer scope blocks. 
  4707.  
  4708.             circumvents the problem by treating the inner block as if it had 
  4709.            the same scope as the outer block.  In the error message, symbol may 
  4710.            be shown as ``(don't know)'' if the outer block is not a function. 
  4711.  
  4712.  block at address out of order 
  4713.            The symbol information for symbol scope blocks should occur in order 
  4714.            of increasing addresses.  This error indicates that it does not do 
  4715.            so. 
  4716.  
  4717.             does not circumvent this problem, and has trouble locating symbols 
  4718.            in the source file whose symbols it is reading.  (You can often 
  4719.            determine what source file is affected by specifying set verbose on. 
  4720.            See Optional warnings and messages.) 
  4721.  
  4722.  bad block start address patched 
  4723.            The symbol information for a symbol scope block has a start address 
  4724.            smaller than the address of the preceding source line.  This is 
  4725.            known to occur in the SunOS 4.1.1 (and earlier) C compiler. 
  4726.  
  4727.             circumvents the problem by treating the symbol scope block as 
  4728.            starting on the previous source line. 
  4729.  
  4730.  bad string table offset in symbol n 
  4731.            Symbol number n contains a pointer into the string table which is 
  4732.            larger than the size of the string table. 
  4733.  
  4734.             circumvents the problem by considering the symbol to have the name 
  4735.            foo, which may cause other problems if many symbols end up with this 
  4736.            name. 
  4737.  
  4738.  unknown symbol type 0xnn 
  4739.            The symbol information contains new data types that  does not yet 
  4740.            know how to read.  0xnn is the symbol type of the misunderstood 
  4741.            information, in hexadecimal. 
  4742.  
  4743.             circumvents the error by ignoring this symbol information.  This 
  4744.            usually allows you to debug your program, though certain symbols are 
  4745.            not accessible.  If you encounter such a problem and feel like 
  4746.            debugging it, you can debug  with itself, breakpoint on complain, 
  4747.            then go up to the function read_dbx_symtab and examine *bufp to see 
  4748.            the symbol. 
  4749.  
  4750.  stub type has NULL name 
  4751.             could not find the full definition for a struct or class. 
  4752.  
  4753.  const/volatile indicator missing (ok if using g++ v1.x), got... 
  4754.            The symbol information for a C++ member function is missing some 
  4755.            information that recent versions of the compiler should have output 
  4756.            for it. 
  4757.  
  4758.  info mismatch between compiler and debugger 
  4759.             could not parse a type specification output by the compiler. 
  4760.  
  4761.  
  4762. ΓòÉΓòÉΓòÉ 16. Specifying a Debugging Target ΓòÉΓòÉΓòÉ
  4763.  
  4764. A target is the execution environment occupied by your program. Often,  runs in 
  4765. the same host environment as your program; in that case, the debugging target 
  4766. is specified as a side effect when you use the file or core commands.  When you 
  4767. need more flexibility---for example, running  on a physically separate host, or 
  4768. controlling a standalone system over a serial port or a realtime system over a 
  4769. TCP/IP connection---you can use the target command to specify one of the target 
  4770. types configured for  ( see Commands for managing targets). 
  4771.  
  4772.  Active Targets                          Active targets 
  4773.  Target Commands                         Commands for managing targets 
  4774.  Remote                                  Remote debugging 
  4775.  
  4776.  
  4777. ΓòÉΓòÉΓòÉ 16.1. Active targets ΓòÉΓòÉΓòÉ
  4778.  
  4779. There are three classes of targets: processes, core files, and executable 
  4780. files.  can work concurrently on up to three active targets, one in each class. 
  4781. This allows you to (for example) start a process and inspect its activity 
  4782. without abandoning your work on a core file. 
  4783.  
  4784. For example, if you execute `gdb a.out', then the executable file a.out is the 
  4785. only active target.  If you designate a core file as well---presumably from a 
  4786. prior run that crashed and coredumped---then  has two active targets and uses 
  4787. them in tandem, looking first in the corefile target, then in the executable 
  4788. file, to satisfy requests for memory addresses.  (Typically, these two classes 
  4789. of target are complementary, since core files contain only a program's 
  4790. read-write memory---variables and so on---plus machine status, while executable 
  4791. files contain only the program text and initialized data.) 
  4792.  
  4793. When you type run, your executable file becomes an active process target as 
  4794. well.  When a process target is active, all  commands requesting memory 
  4795. addresses refer to that target; addresses in an active core file or executable 
  4796. file target are obscured while the process target is active. 
  4797.  
  4798. Use the core-file and exec-file commands to select a new core file or 
  4799. executable target ( see Commands to specify files).  To specify as a target a 
  4800. process that is already running, use the attach command ( see Debugging an 
  4801. already-running process). 
  4802.  
  4803.  
  4804. ΓòÉΓòÉΓòÉ 16.2. Commands for managing targets ΓòÉΓòÉΓòÉ
  4805.  
  4806.  target type parameters 
  4807.            Connects the  host environment to a target machine or process.  A 
  4808.            target is typically a protocol for talking to debugging facilities. 
  4809.            You use the argument type to specify the type or protocol of the 
  4810.            target machine. 
  4811.  
  4812.            Further parameters are interpreted by the target protocol, but 
  4813.            typically include things like device names or host names to connect 
  4814.            with, process numbers, and baud rates. 
  4815.  
  4816.            The target command does not repeat if you press RET again after 
  4817.            executing the command. 
  4818.  
  4819.  help target 
  4820.            Displays the names of all targets available.  To display targets 
  4821.            currently selected, use either info target or info files (see 
  4822.            Commands to specify files). 
  4823.  
  4824.  help target name 
  4825.            Describe a particular target, including any parameters necessary to 
  4826.            select it. 
  4827.  
  4828.  set gnutarget args 
  4829.            uses its own library BFD to read your files. knows whether it is 
  4830.            reading an executable, a core, or a .o file, however you can specify 
  4831.            the file format with the set gnutarget command.  Unlike most target 
  4832.            commands, with gnutarget the target refers to a program, not a 
  4833.            machine. 
  4834.  
  4835.            Warning: To specify a file format with set gnutarget, you must know 
  4836.            the actual BFD name. 
  4837.  
  4838.            See Commands to specify files. 
  4839.  
  4840.  show gnutarget 
  4841.            Use the show gnutarget command to display what file format gnutarget 
  4842.            is set to read.  If you have not set gnutarget,  will determine the 
  4843.            file format for each file automatically and show gnutarget displays 
  4844.            The current BDF target is "auto". 
  4845.  
  4846.  Here are some common targets (available, or not, depending on the GDB 
  4847.  configuration): 
  4848.  
  4849.  target exec program 
  4850.            An executable file.  `target exec program' is the same as `exec-file 
  4851.            program'. 
  4852.  
  4853.  target core filename 
  4854.            A core dump file.  `target core filename' is the same as `core-file 
  4855.            filename'. 
  4856.  
  4857.  target bug dev 
  4858.            BUG monitor, running on a MVME187 (m88k) board. 
  4859.  
  4860.  target cpu32bug dev 
  4861.            CPU32BUG monitor, running on a CPU32 (M68K) board. 
  4862.  
  4863.  target op50n dev 
  4864.            OP50N monitor, running on an OKI HPPA board. 
  4865.  
  4866.  target w89k dev 
  4867.            W89K monitor, running on a Winbond HPPA board. 
  4868.  
  4869.  target est dev 
  4870.            EST-300 ICE monitor, running on a CPU32 (M68K) board. 
  4871.  
  4872.  target rom68k dev 
  4873.            ROM 68K monitor, running on an IDP board. 
  4874.  
  4875.  target array dev 
  4876.            Array Tech LSI33K RAID controller board. 
  4877.  
  4878.  target sparclite dev 
  4879.            Fujitsu sparclite boards, used only for the purpose of loading. You 
  4880.            must use an additional command to debug the program. For example: 
  4881.            target remote dev using  standard remote protocol. 
  4882.  
  4883.  
  4884. ΓòÉΓòÉΓòÉ 16.3. Choosing target byte order ΓòÉΓòÉΓòÉ
  4885.  
  4886. You can now choose which byte order to use with a target system. Use the set 
  4887. endian big and set endian little commands. Use the set endian auto command to 
  4888. instruct  to use the byte order associated with the executable. You can see the 
  4889. current setting for byte order with the show endian command. 
  4890.  
  4891. Warning: Currently, only embedded MIPS configurations support dynamic selection 
  4892. of target byte order. 
  4893.  
  4894.  
  4895. ΓòÉΓòÉΓòÉ 16.4. Remote debugging ΓòÉΓòÉΓòÉ
  4896.  
  4897. If you are trying to debug a program running on a machine that cannot run  in 
  4898. the usual way, it is often useful to use remote debugging. For example, you 
  4899. might use remote debugging on an operating system kernel, or on a small system 
  4900. which does not have a general purpose operating system powerful enough to run a 
  4901. full-featured debugger. 
  4902.  
  4903. Some configurations of  have special serial or TCP/IP interfaces to make this 
  4904. work with particular debugging targets.  In addition,  comes with a generic 
  4905. serial protocol (specific to , but not specific to any particular target 
  4906. system) which you can use if you write the remote stubs---the code that runs on 
  4907. the remote system to communicate with . 
  4908.  
  4909. Other remote targets may be available in your configuration of ; use help 
  4910. target to list them. 
  4911.  
  4912.  Remote Serial                           GDBN remote serial protocol 
  4913.  
  4914.  i960-Nindy Remote                       GDBN with a remote i960 (Nindy) 
  4915.  
  4916.  UDI29K Remote                           The UDI protocol for AMD29K 
  4917.  EB29K Remote                            The EBMON protocol for AMD29K 
  4918.  
  4919.  VxWorks Remote                          GDBN and VxWorks 
  4920.  
  4921.  ST2000 Remote                           GDBN with a Tandem ST2000 
  4922.  
  4923.  Hitachi Remote                          GDBN and Hitachi Microprocessors 
  4924.  13p-unx-docs\texi\gdb.texinfo line 8390 : can't open included file 
  4925.  remote.texinfo compact. MIPS RemoteGDBN and MIPS boards 
  4926.  
  4927.  Sparclet Remote                         GDBN and Sparclet boards 
  4928.  
  4929.  Simulator                               Simulated CPU target 
  4930.  
  4931.  
  4932. ΓòÉΓòÉΓòÉ 17. Controlling ΓòÉΓòÉΓòÉ
  4933.  
  4934. You can alter the way  interacts with you by using the set command.  For 
  4935. commands controlling how  displays data, see Print settings; other settings are 
  4936. described here. 
  4937.  
  4938.  Prompt                                  Prompt 
  4939.  Editing                                 Command editing 
  4940.  History                                 Command history 
  4941.  Screen Size                             Screen size 
  4942.  Numbers                                 Numbers 
  4943.  Messages/Warnings                       Optional warnings and messages 
  4944.  
  4945.  
  4946. ΓòÉΓòÉΓòÉ 17.1. Prompt ΓòÉΓòÉΓòÉ
  4947.  
  4948.  indicates its readiness to read a command by printing a string called the 
  4949. prompt.  This string is normally `()'.  You can change the prompt string with 
  4950. the set prompt command.  For instance, when debugging  with , it is useful to 
  4951. change the prompt in one of the  sessions so that you can always tell which one 
  4952. you are talking to. 
  4953.  
  4954. Note:  set prompt no longer adds a space for you after the prompt you set. 
  4955. This allows you to set a prompt which ends in a space or a prompt that does 
  4956. not. 
  4957.  
  4958.  set prompt newprompt 
  4959.            Directs  to use newprompt as its prompt string henceforth. 
  4960.  
  4961.  show prompt 
  4962.            Prints a line of the form: `Gdb's prompt is: your-prompt' 
  4963.  
  4964.  
  4965. ΓòÉΓòÉΓòÉ 17.2. Command editing ΓòÉΓòÉΓòÉ
  4966.  
  4967.  reads its input commands via the readline interface.  This gnu library 
  4968. provides consistent behavior for programs which provide a command line 
  4969. interface to the user.  Advantages are gnu Emacs-style or vi-style inline 
  4970. editing of commands, csh-like history substitution, and a storage and recall of 
  4971. command history across debugging sessions. 
  4972.  
  4973. You may control the behavior of command line editing in  with the command set. 
  4974.  
  4975.  set editing 
  4976.  set editing on 
  4977.            Enable command line editing (enabled by default). 
  4978.  
  4979.  set editing off 
  4980.            Disable command line editing. 
  4981.  
  4982.  show editing 
  4983.            Show whether command line editing is enabled. 
  4984.  
  4985.  
  4986. ΓòÉΓòÉΓòÉ 17.3. Command history ΓòÉΓòÉΓòÉ
  4987.  
  4988.  can keep track of the commands you type during your debugging sessions, so 
  4989. that you can be certain of precisely what happened.  Use these commands to 
  4990. manage the  command history facility. 
  4991.  
  4992.  set history filename fname 
  4993.            Set the name of the  command history file to fname. This is the file 
  4994.            where  reads an initial command history list, and where it writes 
  4995.            the command history from this session when it exits.  You can access 
  4996.            this list through history expansion or through the history command 
  4997.            editing characters listed below.  This file defaults to the value of 
  4998.            the environment variable GDBHISTFILE, or to `./.gdb_history' if this 
  4999.            variable is not set. 
  5000.  
  5001.  set history save 
  5002.  set history save on 
  5003.            Record command history in a file, whose name may be specified with 
  5004.            the set history filename command.  By default, this option is 
  5005.            disabled. 
  5006.  
  5007.  set history save off 
  5008.            Stop recording command history in a file. 
  5009.  
  5010.  set history size size 
  5011.            Set the number of commands which  keeps in its history list. This 
  5012.            defaults to the value of the environment variable HISTSIZE, or to 
  5013.            256 if this variable is not set. 
  5014.  
  5015.  History expansion assigns special meaning to the character !. 
  5016.  
  5017.  Since ! is also the logical not operator in C, history expansion is off by 
  5018.  default. If you decide to enable history expansion with the set history 
  5019.  expansion on command, you may sometimes need to follow ! (when it is used as 
  5020.  logical not, in an expression) with a space or a tab to prevent it from being 
  5021.  expanded.  The readline history facilities do not attempt substitution on the 
  5022.  strings != and !(, even when history expansion is enabled. 
  5023.  
  5024.  The commands to control history expansion are: 
  5025.  
  5026.  set history expansion on 
  5027.  set history expansion 
  5028.            Enable history expansion.  History expansion is off by default. 
  5029.  
  5030.  set history expansion off 
  5031.            Disable history expansion. 
  5032.  
  5033.            The readline code comes with more complete documentation of editing 
  5034.            and history expansion features.  Users unfamiliar with gnu Emacs or 
  5035.            vi may wish to read it. 
  5036.  
  5037.  show history 
  5038.  show history filename 
  5039.  show history save 
  5040.  show history size 
  5041.  show history expansion 
  5042.            These commands display the state of the  history parameters. show 
  5043.            history by itself displays all four states. 
  5044.  
  5045.  show commands 
  5046.            Display the last ten commands in the command history. 
  5047.  
  5048.  show commands n 
  5049.            Print ten commands centered on command number n. 
  5050.  
  5051.  show commands + 
  5052.            Print ten commands just after the commands last printed. 
  5053.  
  5054.  
  5055. ΓòÉΓòÉΓòÉ 17.4. Screen size ΓòÉΓòÉΓòÉ
  5056.  
  5057. Certain commands to  may produce large amounts of information output to the 
  5058. screen.  To help you read all of it,  pauses and asks you for input at the end 
  5059. of each page of output.  Type RET when you want to continue the output, or q to 
  5060. discard the remaining output.  Also, the screen width setting determines when 
  5061. to wrap lines of output.  Depending on what is being printed,  tries to break 
  5062. the line at a readable place, rather than simply letting it overflow onto the 
  5063. following line. 
  5064.  
  5065. Normally  knows the size of the screen from the termcap data base together with 
  5066. the value of the TERM environment variable and the stty rows and stty cols 
  5067. settings. If this is not correct, you can override it with the set height and 
  5068. set width commands: 
  5069.  
  5070.  set height lpp 
  5071.  show height 
  5072.  set width cpl 
  5073.  show width 
  5074.            These set commands specify a screen height of lpp lines and a screen 
  5075.            width of cpl characters.  The associated show commands display the 
  5076.            current settings. 
  5077.  
  5078.            If you specify a height of zero lines,  does not pause during output 
  5079.            no matter how long the output is.  This is useful if output is to a 
  5080.            file or to an editor buffer. 
  5081.  
  5082.            Likewise, you can specify `set width 0' to prevent from wrapping its 
  5083.            output. 
  5084.  
  5085.  
  5086. ΓòÉΓòÉΓòÉ 17.5. Numbers ΓòÉΓòÉΓòÉ
  5087.  
  5088. You can always enter numbers in octal, decimal, or hexadecimal in  by the usual 
  5089. conventions: octal numbers begin with `0', decimal numbers end with `.', and 
  5090. hexadecimal numbers begin with `0x'. Numbers that begin with none of these are, 
  5091. by default, entered in base 10; likewise, the default display for 
  5092. numbers---when no particular format is specified---is base 10.  You can change 
  5093. the default base for both input and output with the set radix command. 
  5094.  
  5095.  set input-radix base 
  5096.            Set the default base for numeric input.  Supported choices for base 
  5097.            are decimal 8, 10, or 16.  base must itself be specified either 
  5098.            unambiguously or using the current default radix; for example, any 
  5099.            of 
  5100.  
  5101.                       set radix 012
  5102.                       set radix 10.
  5103.                       set radix 0xa
  5104.  
  5105.            sets the base to decimal.  On the other hand, `set radix 10' leaves 
  5106.            the radix unchanged no matter what it was. 
  5107.  
  5108.  set output-radix base 
  5109.            Set the default base for numeric display.  Supported choices for 
  5110.            base are decimal 8, 10, or 16.  base must itself be specified either 
  5111.            unambiguously or using the current default radix. 
  5112.  
  5113.  show input-radix 
  5114.            Display the current default base for numeric input. 
  5115.  
  5116.  show output-radix 
  5117.            Display the current default base for numeric display. 
  5118.  
  5119.  
  5120. ΓòÉΓòÉΓòÉ 17.6. Optional warnings and messages ΓòÉΓòÉΓòÉ
  5121.  
  5122. By default,  is silent about its inner workings.  If you are running on a slow 
  5123. machine, you may want to use the set verbose command. This makes  tell you when 
  5124. it does a lengthy internal operation, so you will not think it has crashed. 
  5125.  
  5126. Currently, the messages controlled by set verbose are those which announce that 
  5127. the symbol table for a source file is being read; see symbol-file in Commands 
  5128. to specify files. 
  5129.  
  5130.  set verbose on 
  5131.            Enables  output of certain informational messages. 
  5132.  
  5133.  set verbose off 
  5134.            Disables  output of certain informational messages. 
  5135.  
  5136.  show verbose 
  5137.            Displays whether set verbose is on or off. 
  5138.  
  5139.  By default, if  encounters bugs in the symbol table of an object file, it is 
  5140.  silent; but if you are debugging a compiler, you may find this information 
  5141.  useful (see Errors reading symbol files). 
  5142.  
  5143.  set complaints limit 
  5144.            Permits  to output limit complaints about each type of unusual 
  5145.            symbols before becoming silent about the problem.  Set limit to zero 
  5146.            to suppress all complaints; set it to a large number to prevent 
  5147.            complaints from being suppressed. 
  5148.  
  5149.  show complaints 
  5150.            Displays how many symbol complaints  is permitted to produce. 
  5151.  
  5152.  By default,  is cautious, and asks what sometimes seems to be a lot of stupid 
  5153.  questions to confirm certain commands.  For example, if you try to run a 
  5154.  program which is already running: 
  5155.  
  5156.   () run
  5157.   The program being debugged has been started already.
  5158.   Start it from the beginning? (y or n)
  5159.  
  5160.  If you are willing to unflinchingly face the consequences of your own 
  5161.  commands, you can disable this ``feature'': 
  5162.  
  5163.  set confirm off 
  5164.            Disables confirmation requests. 
  5165.  
  5166.  set confirm on 
  5167.            Enables confirmation requests (the default). 
  5168.  
  5169.  show confirm 
  5170.            Displays state of confirmation requests. 
  5171.  
  5172.  
  5173. ΓòÉΓòÉΓòÉ 18. Canned Sequences of Commands ΓòÉΓòÉΓòÉ
  5174.  
  5175. Aside from breakpoint commands ( see Breakpoint command lists),  provides two 
  5176. ways to store sequences of commands for execution as a unit: user-defined 
  5177. commands and command files. 
  5178.  
  5179.  Define                                  User-defined commands 
  5180.  Hooks                                   User-defined command hooks 
  5181.  Command Files                           Command files 
  5182.  Output                                  Commands for controlled output 
  5183.  
  5184.  
  5185. ΓòÉΓòÉΓòÉ 18.1. User-defined commands ΓòÉΓòÉΓòÉ
  5186.  
  5187. A user-defined command is a sequence of  commands to which you assign a new 
  5188. name as a command.  This is done with the define command.  User commands may 
  5189. accept up to 10 arguments separated by whitespace. Arguments are accessed 
  5190. within the user command via $arg0...$arg9. A trivial example: 
  5191.  
  5192. define adder
  5193.   print $arg0 + $arg1 + $arg2
  5194.  
  5195. To execute the command use: 
  5196.  
  5197. adder 1 2 3
  5198.  
  5199. This defines the command adder, which prints the sum of its three arguments. 
  5200. Note the arguments are text substitutions, so they may reference variables, use 
  5201. complex expressions, or even perform inferior functions calls. 
  5202.  
  5203.  define commandname 
  5204.            Define a command named commandname.  If there is already a command 
  5205.            by that name, you are asked to confirm that you want to redefine it. 
  5206.  
  5207.            The definition of the command is made up of other  command lines, 
  5208.            which are given following the define command.  The end of these 
  5209.            commands is marked by a line containing end. 
  5210.  
  5211.  if 
  5212.            Takes a single argument, which is an expression to evaluate. It is 
  5213.            followed by a series of commands that are executed only if the 
  5214.            expression is true (nonzero). There can then optionally be a line 
  5215.            else, followed by a series of commands that are only executed if the 
  5216.            expression was false.  The end of the list is marked by a line 
  5217.            containing end. 
  5218.  
  5219.  while 
  5220.            The syntax is similar to if: the command takes a single argument, 
  5221.            which is an expression to evaluate, and must be followed by the 
  5222.            commands to execute, one per line, terminated by an end. The 
  5223.            commands are executed repeatedly as long as the expression evaluates 
  5224.            to true. 
  5225.  
  5226.  document commandname 
  5227.            Document the user-defined command commandname, so that it can be 
  5228.            accessed by help.  The command commandname must already be defined. 
  5229.            This command reads lines of documentation just as define reads the 
  5230.            lines of the command definition, ending with end. After the document 
  5231.            command is finished, help on command commandname displays the 
  5232.            documentation you have written. 
  5233.  
  5234.            You may use the document command again to change the documentation 
  5235.            of a command.  Redefining the command with define does not change 
  5236.            the documentation. 
  5237.  
  5238.  help user-defined 
  5239.            List all user-defined commands, with the first line of the 
  5240.            documentation (if any) for each. 
  5241.  
  5242.  show user 
  5243.  show user commandname 
  5244.            Display the  commands used to define commandname (but not its 
  5245.            documentation).  If no commandname is given, display the definitions 
  5246.            for all user-defined commands. 
  5247.  
  5248.  When user-defined commands are executed, the commands of the definition are 
  5249.  not printed.  An error in any command stops execution of the user-defined 
  5250.  command. 
  5251.  
  5252.  If used interactively, commands that would ask for confirmation proceed 
  5253.  without asking when used inside a user-defined command.  Many commands that 
  5254.  normally print messages to say what they are doing omit the messages when used 
  5255.  in a user-defined command. 
  5256.  
  5257.  
  5258. ΓòÉΓòÉΓòÉ 18.2. User-defined command hooks ΓòÉΓòÉΓòÉ
  5259.  
  5260. You may define hooks, which are a special kind of user-defined command. 
  5261. Whenever you run the command `foo', if the user-defined command `hook-foo' 
  5262. exists, it is executed (with no arguments) before that command. 
  5263.  
  5264. In addition, a pseudo-command, `stop' exists.  Defining (`hook-stop') makes the 
  5265. associated commands execute every time execution stops in your program: before 
  5266. breakpoint commands are run, displays are printed, or the stack frame is 
  5267. printed. 
  5268.  
  5269. For example, to ignore SIGALRM signals while single-stepping, but treat them 
  5270. normally during normal execution, you could define: 
  5271.  
  5272. define hook-stop
  5273. handle SIGALRM nopass
  5274. end
  5275.  
  5276. define hook-run
  5277. handle SIGALRM pass
  5278. end
  5279.  
  5280. define hook-continue
  5281. handle SIGLARM pass
  5282. end
  5283.  
  5284. You can define a hook for any single-word command in , but not for command 
  5285. aliases; you should define a hook for the basic command name, e.g.  backtrace 
  5286. rather than bt. If an error occurs during the execution of your hook, execution 
  5287. of  commands stops and  issues a prompt (before the command that you actually 
  5288. typed had a chance to run). 
  5289.  
  5290. If you try to define a hook which does not match any known command, you get a 
  5291. warning from the define command. 
  5292.  
  5293.  
  5294. ΓòÉΓòÉΓòÉ 18.3. Command files ΓòÉΓòÉΓòÉ
  5295.  
  5296. A command file for  is a file of lines that are commands.  Comments (lines 
  5297. starting with #) may also be included. An empty line in a command file does 
  5298. nothing; it does not mean to repeat the last command, as it would from the 
  5299. terminal. 
  5300.  
  5301. When you start , it automatically executes commands from its init files.  These 
  5302. are files named `'.  reads the init file (if any) in your home directory, then 
  5303. processes command line options and operands, and then reads the init file (if 
  5304. any) in the current working directory.  This is so the init file in your home 
  5305. directory can set options (such as set complaints) which affect the processing 
  5306. of the command line options and operands.  The init files are not executed if 
  5307. you use the `-nx' option; see Choosing modes. You can also request the 
  5308. execution of a command file with the 
  5309.  
  5310. source command: 
  5311.  
  5312.  source filename 
  5313.            Execute the command file filename. 
  5314.  
  5315.  The lines in a command file are executed sequentially.  They are not printed 
  5316.  as they are executed.  An error in any command terminates execution of the 
  5317.  command file. 
  5318.  
  5319.  Commands that would ask for confirmation if used interactively proceed without 
  5320.  asking when used in a command file.  Many  commands that normally print 
  5321.  messages to say what they are doing omit the messages when called from command 
  5322.  files. 
  5323.  
  5324.  
  5325. ΓòÉΓòÉΓòÉ 18.4. Commands for controlled output ΓòÉΓòÉΓòÉ
  5326.  
  5327. During the execution of a command file or a user-defined command, normal 
  5328. output is suppressed; the only output that appears is what is explicitly 
  5329. printed by the commands in the definition.  This section describes three 
  5330. commands useful for generating exactly the output you want. 
  5331.  
  5332.  echo text 
  5333.            Print text.  Nonprinting characters can be included in text using C 
  5334.            escape sequences, such as `\n' to print a newline.  *No newline is 
  5335.            printed unless you specify one.* In addition to the standard C 
  5336.            escape sequences, a backslash followed by a space stands for a 
  5337.            space.  This is useful for displaying a string with spaces at the 
  5338.            beginning or the end, since leading and trailing spaces are 
  5339.            otherwise trimmed from all arguments. To print `and foo =', use the 
  5340.            command `echo \and foo = \'. 
  5341.  
  5342.            A backslash at the end of text can be used, as in C, to continue the 
  5343.            command onto subsequent lines.  For example, 
  5344.  
  5345.                       echo This is some text\n\
  5346.                       which is continued\n\
  5347.                       onto several lines.\n
  5348.  
  5349.            produces the same output as 
  5350.  
  5351.                       echo This is some text\n
  5352.                       echo which is continued\n
  5353.                       echo onto several lines.\n
  5354.  
  5355.  output expression 
  5356.            Print the value of expression and nothing but that value: no 
  5357.            newlines, no `$nn = '.  The value is not entered in the value 
  5358.            history either.  See Expressions, for more information on 
  5359.            expressions. 
  5360.  
  5361.  output/fmt expression 
  5362.            Print the value of expression in format fmt.  You can use the same 
  5363.            formats as for print. See Output formats, for more information. 
  5364.  
  5365.  printf string, expressions... 
  5366.            Print the values of the expressions under the control of string. 
  5367.            The expressions are separated by commas and may be either numbers or 
  5368.            pointers.  Their values are printed as specified by string, exactly 
  5369.            as if your program were to execute the C subroutine 
  5370.  
  5371.                       printf (string, expressions...);
  5372.  
  5373.            For example, you can print two values in hex like this: 
  5374.  
  5375.                       printf "foo, bar-foo = 0x%x, 0x%x\n", foo, bar-foo
  5376.  
  5377.            The only backslash-escape sequences that you can use in the format 
  5378.            string are the simple ones that consist of backslash followed by a 
  5379.            letter. 
  5380.  
  5381.  
  5382. ΓòÉΓòÉΓòÉ 19. Using  under gnu Emacs ΓòÉΓòÉΓòÉ
  5383.  
  5384. A special interface allows you to use gnu Emacs to view (and edit) the source 
  5385. files for the program you are debugging with . 
  5386.  
  5387. To use this interface, use the command M-x gdb in Emacs.  Give the executable 
  5388. file you want to debug as an argument.  This command starts  as a subprocess of 
  5389. Emacs, with input and output through a newly created Emacs buffer. 
  5390.  
  5391. Using  under Emacs is just like using  normally except for two things: 
  5392.  
  5393.      All ``terminal'' input and output goes through the Emacs buffer. 
  5394.  
  5395.  This applies both to  commands and their output, and to the input and output 
  5396.  done by the program you are debugging. 
  5397.  
  5398.  This is useful because it means that you can copy the text of previous 
  5399.  commands and input them again; you can even use parts of the output in this 
  5400.  way. 
  5401.  
  5402.  All the facilities of Emacs' Shell mode are available for interacting with 
  5403.  your program.  In particular, you can send signals the usual way---for 
  5404.  example, C-c C-c for an interrupt, C-c C-z for a stop. 
  5405.  
  5406.      displays source code through Emacs. 
  5407.  
  5408.  Each time  displays a stack frame, Emacs automatically finds the source file 
  5409.  for that frame and puts an arrow (`=>') at the left margin of the current 
  5410.  line.  Emacs uses a separate buffer for source display, and splits the screen 
  5411.  to show both your  session and the source. 
  5412.  
  5413.  Explicit  list or search commands still produce output as usual, but you 
  5414.  probably have no reason to use them from Emacs. 
  5415.  
  5416.  Warning: If the directory where your program resides is not your current 
  5417.  directory, it can be easy to confuse Emacs about the location of the source 
  5418.  files, in which case the auxiliary display buffer does not appear to show your 
  5419.  source.  can find programs by searching your environment's PATH variable, so 
  5420.  the  input and output session proceeds normally; but Emacs does not get enough 
  5421.  information back from  to locate the source files in this situation.  To avoid 
  5422.  this problem, either start  mode from the directory where your program 
  5423.  resides, or specify an absolute file name when prompted for the M-x gdb 
  5424.  argument. 
  5425.  
  5426.  A similar confusion can result if you use the  file command to switch to 
  5427.  debugging a program in some other location, from an existing  buffer in Emacs. 
  5428.  
  5429.  By default, M-x gdb calls the program called `gdb'.  If you need to call  by a 
  5430.  different name (for example, if you keep several configurations around, with 
  5431.  different names) you can set the Emacs variable gdb-command-name; for example, 
  5432.  
  5433.   (setq gdb-command-name "mygdb")
  5434.  
  5435.  (preceded by ESC ESC, or typed in the *scratch* buffer, or in your `.emacs' 
  5436.  file) makes Emacs call the program named ``mygdb'' instead. 
  5437.  
  5438.  In the  I/O buffer, you can use these special Emacs commands in addition to 
  5439.  the standard Shell mode commands: 
  5440.  
  5441.  C-h m 
  5442.            Describe the features of Emacs'  Mode. 
  5443.  
  5444.  M-s 
  5445.            Execute to another source line, like the  step command; also update 
  5446.            the display window to show the current file and location. 
  5447.  
  5448.  M-n 
  5449.            Execute to next source line in this function, skipping all function 
  5450.            calls, like the  next command.  Then update the display window to 
  5451.            show the current file and location. 
  5452.  
  5453.  M-i 
  5454.            Execute one instruction, like the  stepi command; update display 
  5455.            window accordingly. 
  5456.  
  5457.  M-x gdb-nexti 
  5458.            Execute to next instruction, using the  nexti command; update 
  5459.            display window accordingly. 
  5460.  
  5461.  C-c C-f 
  5462.            Execute until exit from the selected stack frame, like the finish 
  5463.            command. 
  5464.  
  5465.  M-c 
  5466.            Continue execution of your program, like the  continue command. 
  5467.  
  5468.            Warning: In Emacs v19, this command is C-c C-p. 
  5469.  
  5470.  M-u 
  5471.            Go up the number of frames indicated by the numeric argument (see 
  5472.            Numeric Arguments), like the  up command. 
  5473.  
  5474.            Warning: In Emacs v19, this command is C-c C-u. 
  5475.  
  5476.  M-d 
  5477.            Go down the number of frames indicated by the numeric argument, like 
  5478.            the  down command. 
  5479.  
  5480.            Warning: In Emacs v19, this command is C-c C-d. 
  5481.  
  5482.  C-x & 
  5483.            Read the number where the cursor is positioned, and insert it at the 
  5484.            end of the  I/O buffer.  For example, if you wish to disassemble 
  5485.            code around an address that was displayed earlier, type disassemble; 
  5486.            then move the cursor to the address display, and pick up the 
  5487.            argument for disassemble by typing C-x &. 
  5488.  
  5489.            You can customize this further by defining elements of the list 
  5490.            gdb-print-command; once it is defined, you can format or otherwise 
  5491.            process numbers picked up by C-x & before they are inserted.  A 
  5492.            numeric argument to C-x & indicates that you wish special 
  5493.            formatting, and also acts as an index to pick an element of the 
  5494.            list.  If the list element is a string, the number to be inserted is 
  5495.            formatted using the Emacs function format; otherwise the number is 
  5496.            passed as an argument to the corresponding list element. 
  5497.  
  5498.  In any source file, the Emacs command C-x SPC (gdb-break) tells  to set a 
  5499.  breakpoint on the source line point is on. 
  5500.  
  5501.  If you accidentally delete the source-display buffer, an easy way to get it 
  5502.  back is to type the command f in the  buffer, to request a frame display; when 
  5503.  you run under Emacs, this recreates the source buffer if necessary to show you 
  5504.  the context of the current frame. 
  5505.  
  5506.  The source files displayed in Emacs are in ordinary Emacs buffers which are 
  5507.  visiting the source files in the usual way.  You can edit the files with these 
  5508.  buffers if you wish; but keep in mind that communicates with Emacs in terms of 
  5509.  line numbers.  If you add or delete lines from the text, the line numbers that 
  5510.  knows cease to correspond properly with the code. 
  5511.  
  5512.  
  5513. ΓòÉΓòÉΓòÉ 20. Reporting Bugs in ΓòÉΓòÉΓòÉ
  5514.  
  5515. Your bug reports play an essential role in making  reliable. 
  5516.  
  5517. Reporting a bug may help you by bringing a solution to your problem, or it may 
  5518. not.  But in any case the principal function of a bug report is to help the 
  5519. entire community by making the next version of  work better.  Bug reports are 
  5520. your contribution to the maintenance of . 
  5521.  
  5522. In order for a bug report to serve its purpose, you must include the 
  5523. information that enables us to fix the bug. 
  5524.  
  5525.  Bug Criteria                            Have you found a bug? 
  5526.  Bug Reporting                           How to report bugs 
  5527.  
  5528.  
  5529. ΓòÉΓòÉΓòÉ 20.1. Have you found a bug? ΓòÉΓòÉΓòÉ
  5530.  
  5531. If you are not sure whether you have found a bug, here are some guidelines: 
  5532.  
  5533.      If the debugger gets a fatal signal, for any input whatever, that is a 
  5534.       bug.  Reliable debuggers never crash. 
  5535.  
  5536.      If  produces an error message for valid input, that is a bug. 
  5537.  
  5538.      If  does not produce an error message for invalid input, that is a bug. 
  5539.       However, you should note that your idea of ``invalid input'' might be our 
  5540.       idea of ``an extension'' or ``support for traditional practice''. 
  5541.  
  5542.      If you are an experienced user of debugging tools, your suggestions for 
  5543.       improvement of  are welcome in any case. 
  5544.  
  5545.  
  5546. ΓòÉΓòÉΓòÉ 20.2. How to report bugs ΓòÉΓòÉΓòÉ
  5547.  
  5548. A number of companies and individuals offer support for gnu products. If you 
  5549. obtained  from a support organization, we recommend you contact that 
  5550. organization first. 
  5551.  
  5552. You can find contact information for many support companies and individuals in 
  5553. the file `etc/SERVICE' in the gnu Emacs distribution. 
  5554.  
  5555. In any event, we also recommend that you send bug reports for  to one of these 
  5556. addresses: 
  5557.  
  5558. bug-gdb@prep.ai.mit.edu
  5559. {ucbvax|mit-eddie|uunet}!prep.ai.mit.edu!bug-gdb
  5560.  
  5561. *Do not send bug reports to `info-gdb', or to `help-gdb', or to any 
  5562. newsgroups.* Most users of  do not want to receive bug reports.  Those that do 
  5563. have arranged to receive `bug-gdb'. 
  5564.  
  5565. The mailing list `bug-gdb' has a newsgroup `gnu.gdb.bug' which serves as a 
  5566. repeater.  The mailing list and the newsgroup carry exactly the same messages. 
  5567. Often people think of posting bug reports to the newsgroup instead of mailing 
  5568. them.  This appears to work, but it has one problem which can be crucial: a 
  5569. newsgroup posting often lacks a mail path back to the sender.  Thus, if we need 
  5570. to ask for more information, we may be unable to reach you.  For this reason, 
  5571. it is better to send bug reports to the mailing list. 
  5572.  
  5573. As a last resort, send bug reports on paper to: 
  5574.  
  5575. gnu Debugger Bugs
  5576. Free Software Foundation Inc.
  5577. 59 Temple Place - Suite 330
  5578. Boston, MA 02111-1307
  5579. USA
  5580.  
  5581. The fundamental principle of reporting bugs usefully is this: *report all the 
  5582. facts*.  If you are not sure whether to state a fact or leave it out, state it! 
  5583.  
  5584. Often people omit facts because they think they know what causes the problem 
  5585. and assume that some details do not matter.  Thus, you might assume that the 
  5586. name of the variable you use in an example does not matter. Well, probably it 
  5587. does not, but one cannot be sure.  Perhaps the bug is a stray memory reference 
  5588. which happens to fetch from the location where that name is stored in memory; 
  5589. perhaps, if the name were different, the contents of that location would fool 
  5590. the debugger into doing the right thing despite the bug.  Play it safe and give 
  5591. a specific, complete example.  That is the easiest thing for you to do, and the 
  5592. most helpful. 
  5593.  
  5594. Keep in mind that the purpose of a bug report is to enable us to fix the bug if 
  5595. it is new to us. Therefore, always write your bug reports on the assumption 
  5596. that the bug has not been reported previously. 
  5597.  
  5598. Sometimes people give a few sketchy facts and ask, ``Does this ring a bell?'' 
  5599. Those bug reports are useless, and we urge everyone to refuse to respond to 
  5600. them except to chide the sender to report bugs properly. 
  5601.  
  5602. To enable us to fix the bug, you should include all these things: 
  5603.  
  5604.      The version of .  announces it if you start with no arguments; you can 
  5605.       also print it at any time using show version. 
  5606.  
  5607.       Without this, we will not know whether there is any point in looking for 
  5608.       the bug in the current version of . 
  5609.  
  5610.      The type of machine you are using, and the operating system name and 
  5611.       version number. 
  5612.  
  5613.      What compiler (and its version) was used to compile ---e.g. ``--2.0''. 
  5614.  
  5615.      What compiler (and its version) was used to compile the program you are 
  5616.       debugging---e.g.  ``--2.0''. 
  5617.  
  5618.      The command arguments you gave the compiler to compile your example and 
  5619.       observe the bug.  For example, did you use `-O'?  To guarantee you will 
  5620.       not omit something important, list them all.  A copy of the Makefile (or 
  5621.       the output from make) is sufficient. 
  5622.  
  5623.       If we were to try to guess the arguments, we would probably guess wrong 
  5624.       and then we might not encounter the bug. 
  5625.  
  5626.      A complete input script, and all necessary source files, that will 
  5627.       reproduce the bug. 
  5628.  
  5629.      A description of what behavior you observe that you believe is incorrect. 
  5630.       For example, ``It gets a fatal signal.'' 
  5631.  
  5632.       Of course, if the bug is that  gets a fatal signal, then we will 
  5633.       certainly notice it.  But if the bug is incorrect output, we might not 
  5634.       notice unless it is glaringly wrong.  You might as well not give us a 
  5635.       chance to make a mistake. 
  5636.  
  5637.       Even if the problem you experience is a fatal signal, you should still 
  5638.       say so explicitly.  Suppose something strange is going on, such as, your 
  5639.       copy of  is out of synch, or you have encountered a bug in the C library 
  5640.       on your system.  (This has happened!)  Your copy might crash and ours 
  5641.       would not.  If you told us to expect a crash, then when ours fails to 
  5642.       crash, we would know that the bug was not happening for us.  If you had 
  5643.       not told us to expect a crash, then we would not be able to draw any 
  5644.       conclusion from our observations. 
  5645.  
  5646.      If you wish to suggest changes to the  source, send us context diffs.  If 
  5647.       you even discuss something in the  source, refer to it by context, not by 
  5648.       line number. 
  5649.  
  5650.       The line numbers in our development sources will not match those in your 
  5651.       sources.  Your line numbers would convey no useful information to us. 
  5652.  
  5653.  Here are some things that are nE13p-unx-docs\texi\gdb.texinfo line 9451 : 
  5654.  can't open included file rluser.texinfo E13p-unx-docs\texi\gdb.texinfo line 
  5655.  9452 : can't open included file inc-hist.texinfo ot necessary: 
  5656.  
  5657.      A description of the envelope of the bug. 
  5658.  
  5659.       Often people who encounter a bug spend a lot of time investigating which 
  5660.       changes to the input file will make the bug go away and which changes 
  5661.       will not affect it. 
  5662.  
  5663.       This is often time consuming and not very useful, because the way we will 
  5664.       find the bug is by running a single example under the debugger with 
  5665.       breakpoints, not by pure deduction from a series of examples. We 
  5666.       recommend that you save your time for something else. 
  5667.  
  5668.       Of course, if you can find a simpler example to report instead of the 
  5669.       original one, that is a convenience for us.  Errors in the output will be 
  5670.       easier to spot, running under the debugger will take less time, and so 
  5671.       on. 
  5672.  
  5673.       However, simplification is not vital; if you do not want to do this, 
  5674.       report the bug anyway and send us the entire test case you used. 
  5675.  
  5676.      A patch for the bug. 
  5677.  
  5678.       A patch for the bug does help us if it is a good one.  But do not omit 
  5679.       the necessary information, such as the test case, on the assumption that 
  5680.       a patch is all we need.  We might see problems with your patch and decide 
  5681.       to fix the problem another way, or we might not understand it at all. 
  5682.  
  5683.       Sometimes with a program as complicated as  it is very hard to construct 
  5684.       an example that will make the program follow a certain path through the 
  5685.       code.  If you do not send us the example, we will not be able to 
  5686.       construct one, so we will not be able to verify that the bug is fixed. 
  5687.  
  5688.       And if we cannot understand what bug you are trying to fix, or why your 
  5689.       patch should be an improvement, we will not install it.  A test case will 
  5690.       help us to understand. 
  5691.  
  5692.      A guess about what the bug is or what it depends on. 
  5693.  
  5694.       Such guesses are usually wrong.  Even we cannot guess right about such 
  5695.       things without first using the debugger to find the facts. 
  5696.  
  5697.  
  5698. ΓòÉΓòÉΓòÉ 21. Formatting Documentation ΓòÉΓòÉΓòÉ
  5699.  
  5700. The  4 release includes an already-formatted reference card, ready for printing 
  5701. with PostScript or Ghostscript, in the `gdb' subdirectory of the main source 
  5702. directory(3).  If you can use PostScript or Ghostscript with your printer, you 
  5703. can print the reference card immediately with `refcard.ps'. 
  5704.  
  5705. The release also includes the source for the reference card.  You can format 
  5706. it, using TeX, by typing: 
  5707.  
  5708. make refcard.dvi
  5709.  
  5710. The  reference card is designed to print in landscape mode on US ``letter'' 
  5711. size paper; that is, on a sheet 11 inches wide by 8.5 inches high.  You will 
  5712. need to specify this form of printing as an option to your dvi output program. 
  5713.  
  5714. All the documentation for  comes as part of the machine-readable distribution. 
  5715. The documentation is written in Texinfo format, which is a documentation system 
  5716. that uses a single source file to produce both on-line information and a 
  5717. printed manual.  You can use one of the Info formatting commands to create the 
  5718. on-line version of the documentation and TeX (or texi2roff) to typeset the 
  5719. printed version. 
  5720.  
  5721.  includes an already formatted copy of the on-line Info version of this manual 
  5722. in the `gdb' subdirectory.  The main Info file is 
  5723. `gdb-version-number/gdb/gdb.info', and it refers to subordinate files matching 
  5724. `gdb.info*' in the same directory.  If necessary, you can print out these 
  5725. files, or read them with any editor; but they are easier to read using the info 
  5726. subsystem in gnu Emacs or the standalone info program, available as part of the 
  5727. gnu Texinfo distribution. 
  5728.  
  5729. If you want to format these Info files yourself, you need one of the Info 
  5730. formatting programs, such as texinfo-format-buffer or makeinfo. 
  5731.  
  5732. If you have makeinfo installed, and are in the top level source directory 
  5733. (`gdb-', in the case of version ), you can make the Info file by typing: 
  5734.  
  5735. cd gdb
  5736. make gdb.info
  5737.  
  5738. If you want to typeset and print copies of this manual, you need TeX, a program 
  5739. to print its dvi output files, and `texinfo.tex', the Texinfo definitions file. 
  5740.  
  5741. TeX is a typesetting program; it does not print files directly, but produces 
  5742. output files called dvi files.  To print a typeset document, you need a program 
  5743. to print dvi files.  If your system has TeX installed, chances are it has such 
  5744. a program.  The precise command to use depends on your system; lpr -d is 
  5745. common; another (for PostScript devices) is dvips.  The dvi print command may 
  5746. require a file name without any extension or a `.dvi' extension. 
  5747.  
  5748. TeX also requires a macro definitions file called `texinfo.tex'.  This file 
  5749. tells TeX how to typeset a document written in Texinfo format.  On its own, TeX 
  5750. cannot either read or typeset a Texinfo file.  `texinfo.tex' is distributed 
  5751. with GDB and is located in the `gdb-version-number/texinfo' directory. 
  5752.  
  5753. If you have TeX and a dvi printer program installed, you can typeset and print 
  5754. this manual.  First switch to the the `gdb' subdirectory of the main source 
  5755. directory (for example, to `gdb-/gdb') and then type: 
  5756.  
  5757. make gdb.dvi
  5758.  
  5759.  
  5760. ΓòÉΓòÉΓòÉ 22. Installing ΓòÉΓòÉΓòÉ
  5761.  
  5762.  comes with a configure script that automates the process of preparing  for 
  5763. installation; you can then use make to build the gdb program. 
  5764.  
  5765. The  distribution includes all the source code you need for  in a single 
  5766. directory, whose name is usually composed by appending the version number to 
  5767. `gdb'. 
  5768.  
  5769. For example, the  version  distribution is in the `gdb-' directory.  That 
  5770. directory contains: 
  5771.  
  5772.  gdb-GDBVN/configure (and supporting files) 
  5773.            script for configuring  and all its supporting libraries 
  5774.  
  5775.  gdb-GDBVN/gdb 
  5776.            the source specific to  itself 
  5777.  
  5778.  gdb-GDBVN/bfd 
  5779.            source for the Binary File Descriptor library 
  5780.  
  5781.  gdb-GDBVN/include 
  5782.            gnu include files 
  5783.  
  5784.  gdb-GDBVN/libiberty 
  5785.            source for the `-liberty' free software library 
  5786.  
  5787.  gdb-GDBVN/opcodes 
  5788.            source for the library of opcode tables and disassemblers 
  5789.  
  5790.  gdb-GDBVN/readline 
  5791.            source for the gnu command-line interface 
  5792.  
  5793.  gdb-GDBVN/glob 
  5794.            source for the gnu filename pattern-matching subroutine 
  5795.  
  5796.  gdb-GDBVN/mmalloc 
  5797.            source for the gnu memory-mapped malloc package 
  5798.  
  5799.  The simplest way to configure and build  is to run configure from the 
  5800.  `gdb-version-number' source directory, which in this example is the `gdb-' 
  5801.  directory. 
  5802.  
  5803.  First switch to the `gdb-version-number' source directory if you are not 
  5804.  already in it; then run configure.  Pass the identifier for the platform on 
  5805.  which  will run as an argument. 
  5806.  
  5807.  For example: 
  5808.  
  5809.   cd gdb-
  5810.   ./configure host
  5811.   make
  5812.  
  5813.  where host is an identifier such as `sun4' or `decstation', that identifies 
  5814.  the platform where  will run. (You can often leave off host; configure tries 
  5815.  to guess the correct value by examining your system.) 
  5816.  
  5817.  Running `configure host' and then running make builds the `bfd', `readline', 
  5818.  `mmalloc', and `libiberty' libraries, then gdb itself.  The configured source 
  5819.  files, and the binaries, are left in the corresponding source directories. 
  5820.  
  5821.  configure is a Bourne-shell (/bin/sh) script; if your system does not 
  5822.  recognize this automatically when you run a different shell, you may need to 
  5823.  run sh on it explicitly: 
  5824.  
  5825.   sh configure host
  5826.  
  5827.  If you run configure from a directory that contains source directories for 
  5828.  multiple libraries or programs, such as the `gdb-' source directory for 
  5829.  version , configure creates configuration files for every directory level 
  5830.  underneath (unless you tell it not to, with the `--norecursion' option). 
  5831.  
  5832.  You can run the configure script from any of the subordinate directories in 
  5833.  the  distribution if you only want to configure that subdirectory, but be sure 
  5834.  to specify a path to it. 
  5835.  
  5836.  For example, with version , type the following to configure only the bfd 
  5837.  subdirectory: 
  5838.  
  5839.   cd gdb-/bfd
  5840.   ../configure host
  5841.  
  5842.  You can install  anywhere; it has no hardwired paths. However, you should make 
  5843.  sure that the shell on your path (named by the `SHELL' environment variable) 
  5844.  is publicly readable.  Remember that  uses the shell to start your 
  5845.  program---some systems refuse to let  debug child processes whose programs are 
  5846.  not readable. 
  5847.  
  5848.  Separate Objdir                         Compiling GDBN in another directory 
  5849.  Config Names                            Specifying names for hosts and targets 
  5850.  configure Options                       Summary of options for configure 
  5851.  
  5852.  
  5853. ΓòÉΓòÉΓòÉ 22.1. Compiling  in another directory ΓòÉΓòÉΓòÉ
  5854.  
  5855. If you want to run  versions for several host or target machines, you need a 
  5856. different gdb compiled for each combination of host and target.  configure is 
  5857. designed to make this easy by allowing you to generate each configuration in a 
  5858. separate subdirectory, rather than in the source directory.  If your make 
  5859. program handles the `VPATH' feature (gnu make does), running make in each of 
  5860. these directories builds the gdb program specified there. 
  5861.  
  5862. To build gdb in a separate directory, run configure with the `--srcdir' option 
  5863. to specify where to find the source. (You also need to specify a path to find 
  5864. configure itself from your working directory.  If the path to configure would 
  5865. be the same as the argument to `--srcdir', you can leave out the `--srcdir' 
  5866. option; it is assumed.) 
  5867.  
  5868. For example, with version , you can build  in a separate directory for a Sun 4 
  5869. like this: 
  5870.  
  5871. cd gdb-
  5872. mkdir ../gdb-sun4
  5873. cd ../gdb-sun4
  5874. ../gdb-/configure sun4
  5875. make
  5876.  
  5877. When configure builds a configuration using a remote source directory, it 
  5878. creates a tree for the binaries with the same structure (and using the same 
  5879. names) as the tree under the source directory.  In the example, you'd find the 
  5880. Sun 4 library `libiberty.a' in the directory `gdb-sun4/libiberty', and  itself 
  5881. in `gdb-sun4/gdb'. 
  5882.  
  5883. One popular reason to build several  configurations in separate directories is 
  5884. to configure  for cross-compiling (where  runs on one machine---the 
  5885. host---while debugging programs that run on another machine---the target). You 
  5886. specify a cross-debugging target by giving the `--target=target' option to 
  5887. configure. 
  5888.  
  5889. When you run make to build a program or library, you must run it in a 
  5890. configured directory---whatever directory you were in when you called configure 
  5891. (or one of its subdirectories). 
  5892.  
  5893. The Makefile that configure generates in each source directory also runs 
  5894. recursively.  If you type make in a source directory such as `gdb-' (or in a 
  5895. separate configured directory configured with `--srcdir=dirname/gdb-'), you 
  5896. will build all the required libraries, and then build GDB. 
  5897.  
  5898. When you have multiple hosts or targets configured in separate directories, you 
  5899. can run make on them in parallel (for example, if they are NFS-mounted on each 
  5900. of the hosts); they will not interfere with each other. 
  5901.  
  5902.  
  5903. ΓòÉΓòÉΓòÉ 22.2. Specifying names for hosts and targets ΓòÉΓòÉΓòÉ
  5904.  
  5905. The specifications used for hosts and targets in the configure script are based 
  5906. on a three-part naming scheme, but some short predefined aliases are also 
  5907. supported.  The full naming scheme encodes three pieces of information in the 
  5908. following pattern: 
  5909.  
  5910. architecture-vendor-os
  5911.  
  5912. For example, you can use the alias sun4 as a host argument, or as the value for 
  5913. target in a --target=target option.  The equivalent full name is 
  5914. `sparc-sun-sunos4'. 
  5915.  
  5916. The configure script accompanying  does not provide any query facility to list 
  5917. all supported host and target names or aliases.  configure calls the Bourne 
  5918. shell script config.sub to map abbreviations to full names; you can read the 
  5919. script, if you wish, or you can use it to test your guesses on 
  5920. abbreviations---for example: 
  5921.  
  5922. % sh config.sub sun4
  5923. sparc-sun-sunos4.1.1
  5924. % sh config.sub sun3
  5925. m68k-sun-sunos4.1.1
  5926. % sh config.sub decstation
  5927. mips-dec-ultrix4.2
  5928. % sh config.sub hp300bsd
  5929. m68k-hp-bsd
  5930. % sh config.sub i386v
  5931. i386-unknown-sysv
  5932. % sh config.sub i786v
  5933. Invalid configuration `i786v': machine `i786v' not recognized
  5934.  
  5935. config.sub is also distributed in the  source directory (`gdb-', for version ). 
  5936.  
  5937.  
  5938. ΓòÉΓòÉΓòÉ 22.3. configure options ΓòÉΓòÉΓòÉ
  5939.  
  5940. Here is a summary of the configure options and arguments that are most often 
  5941. useful for building .  configure also has several other options not listed 
  5942. here.  See Info file What Configure Does,,configure.info, for a full 
  5943. explanation of configure. 
  5944.  
  5945. configure [--help]
  5946.           [--prefix=dir]
  5947.           [--srcdir=dirname]
  5948.           [--norecursion] [--rm]
  5949.           [--target=target] host
  5950.  
  5951. You may introduce options with a single `-' rather than `--' if you prefer; but 
  5952. you may abbreviate option names if you use `--'. 
  5953.  
  5954.  --help 
  5955.            Display a quick summary of how to invoke configure. 
  5956.  
  5957.  -prefix=dir 
  5958.            Configure the source to install programs and files under directory 
  5959.            `dir'. 
  5960.  
  5961.  --srcdir=dirname 
  5962.            *Warning: using this option requires gnu make, or another make that 
  5963.            implements the VPATH feature.* 
  5964.            Use this option to make configurations in directories separate from 
  5965.            the  source directories.  Among other things, you can use this to 
  5966.            build (or maintain) several configurations simultaneously, in 
  5967.            separate directories.  configure writes configuration specific files 
  5968.            in the current directory, but arranges for them to use the source in 
  5969.            the directory dirname.  configure creates directories under the 
  5970.            working directory in parallel to the source directories below 
  5971.            dirname. 
  5972.  
  5973.  --norecursion 
  5974.            Configure only the directory level where configure is executed; do 
  5975.            not propagate configuration to subdirectories. 
  5976.  
  5977.  --rm 
  5978.            Remove files otherwise built during configuration. 
  5979.  
  5980.  --target=target 
  5981.            Configure  for cross-debugging programs running on the specified 
  5982.            target.  Without this option,  is configured to debug programs that 
  5983.            run on the same machine (host) as  itself. 
  5984.  
  5985.            There is no convenient way to generate a list of all available 
  5986.            targets. 
  5987.  
  5988.  host ... 
  5989.            Configure  to run on the specified host. 
  5990.  
  5991.            There is no convenient way to generate a list of all available 
  5992.            hosts. 
  5993.  
  5994.  configure accepts other options, for compatibility with configuring other gnu 
  5995.  tools recursively; but these are the only options that affect  or its 
  5996.  supporting libraries. 
  5997.  
  5998.  
  5999. ΓòÉΓòÉΓòÉ 23. Index ΓòÉΓòÉΓòÉ
  6000.  
  6001. Sorry, no cp index 
  6002.  
  6003.  
  6004. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  6005.  
  6006. `b' cannot be used because these format letters are also used with the x 
  6007. command, where `b' stands for ``byte''; see Examining memory.
  6008.  
  6009.  
  6010. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  6011.  
  6012. This is a way of removing one word from the stack, on machines where stacks 
  6013. grow downward in memory (most machines, nowadays).  This assumes that the 
  6014. innermost stack frame is selected; setting $sp is not allowed when other stack 
  6015. frames are selected.  To pop entire frames off the stack, regardless of machine 
  6016. architecture, use return; see Returning from a function.
  6017.  
  6018.  
  6019. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  6020.  
  6021. In `gdb-/gdb/refcard.ps' of the version