home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / gdb_inf.zip / gdb-all.INF (.txt) next >
OS/2 Help File  |  1993-04-28  |  197KB  |  6,868 lines

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