home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / gdb-4.9 / gdb / gdb.info-1 < prev    next >
Encoding:
GNU Info File  |  1993-05-12  |  49.6 KB  |  1,305 lines

  1. This is Info file ./gdb.info, produced by Makeinfo-1.52 from the input
  2. file gdb.texinfo.
  3.  
  4. START-INFO-DIR-ENTRY
  5. * Gdb: (gdb).                   The GNU debugger.
  6. END-INFO-DIR-ENTRY
  7.    This file documents the GNU debugger GDB.
  8.  
  9.    This is Edition 4.09, April 1993, of `Debugging with GDB: the GNU
  10. Source-Level Debugger' for GDB Version 4.9.
  11.  
  12.    Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993 Free Software
  13. Foundation, Inc.
  14.  
  15.    Permission is granted to make and distribute verbatim copies of this
  16. manual provided the copyright notice and this permission notice are
  17. preserved on all copies.
  18.  
  19.    Permission is granted to copy and distribute modified versions of
  20. this manual under the conditions for verbatim copying, provided also
  21. that the section entitled "GNU General Public License" is included
  22. exactly as in the original, and provided that the entire resulting
  23. derived work is distributed under the terms of a permission notice
  24. identical to this one.
  25.  
  26.    Permission is granted to copy and distribute translations of this
  27. manual into another language, under the above conditions for modified
  28. versions, except that the section entitled "GNU General Public License"
  29. may be included in a translation approved by the Free Software
  30. Foundation instead of in the original English.
  31.  
  32. 
  33. File: gdb.info,  Node: Top,  Next: Summary,  Prev: (DIR),  Up: (DIR)
  34.  
  35. Debugging with GDB
  36. ******************
  37.  
  38.    This file describes GDB, the GNU symbolic debugger.
  39.  
  40.    This is Edition 4.09, April 1993, for GDB Version 4.9.
  41.  
  42. * Menu:
  43.  
  44. * Summary::                     Summary of GDB
  45.  
  46. * New Features::                New features since GDB version 3.5
  47.  
  48. * Sample Session::              A sample GDB session
  49.  
  50. * Invocation::                  Getting in and out of GDB
  51. * Commands::                    GDB commands
  52. * Running::                     Running programs under GDB
  53. * Stopping::                    Stopping and continuing
  54. * Stack::                       Examining the stack
  55. * Source::                      Examining source files
  56. * Data::                        Examining data
  57.  
  58. * Languages::                   Using GDB with different languages
  59.  
  60.  
  61. * Symbols::                     Examining the symbol table
  62. * Altering::                    Altering execution
  63. * GDB Files::                   GDB files
  64. * Targets::                     Specifying a debugging target
  65. * Controlling GDB::             Controlling GDB
  66. * Sequences::                   Canned sequences of commands
  67.  
  68. * Emacs::                       Using GDB under GNU Emacs
  69.  
  70. * GDB Bugs::                    Reporting bugs in GDB
  71.  
  72. * Renamed Commands::
  73.  
  74. * Formatting Documentation::    How to format and print GDB documentation
  75. * Installing GDB::              Installing GDB
  76.  
  77. * Copying::                     GNU GENERAL PUBLIC LICENSE
  78.  
  79. * Index::                       Index
  80.  
  81. 
  82. File: gdb.info,  Node: Summary,  Next: New Features,  Prev: Top,  Up: Top
  83.  
  84. Summary of GDB
  85. **************
  86.  
  87.    The purpose of a debugger such as GDB is to allow you to see what is
  88. going on "inside" another program while it executes--or what another
  89. program was doing at the moment it crashed.
  90.  
  91.    GDB can do four main kinds of things (plus other things in support of
  92. these) to help you catch bugs in the act:
  93.  
  94.    * Start your program, specifying anything that might affect its
  95.      behavior.
  96.  
  97.    * Make your program stop on specified conditions.
  98.  
  99.    * Examine what has happened, when your program has stopped.
  100.  
  101.    * Change things in your program, so you can experiment with
  102.      correcting the effects of one bug and go on to learn about another.
  103.  
  104.    You can use GDB to debug programs written in C, C++, and Modula-2.
  105. Fortran support will be added when a GNU Fortran compiler is ready.
  106.  
  107. * Menu:
  108.  
  109. * Free Software::               Freely redistributable software
  110. * Contributors::                Contributors to GDB
  111.  
  112. 
  113. File: gdb.info,  Node: Free Software,  Next: Contributors,  Up: Summary
  114.  
  115. Free software
  116. =============
  117.  
  118.    GDB is "free software", protected by the GNU General Public License
  119. (GPL).  The GPL gives you the freedom to copy or adapt a licensed
  120. program--but every person getting a copy also gets with it the freedom
  121. to modify that copy (which means that they must get access to the
  122. source code), and the freedom to distribute further copies.  Typical
  123. software companies use copyrights to limit your freedoms; the Free
  124. Software Foundation uses the GPL to preserve these freedoms.
  125.  
  126.    Fundamentally, the General Public License is a license which says
  127. that you have these freedoms and that you cannot take these freedoms
  128. away from anyone else.
  129.  
  130.    For full details, *note GNU GENERAL PUBLIC LICENSE: Copying..
  131.  
  132. 
  133. File: gdb.info,  Node: Contributors,  Prev: Free Software,  Up: Summary
  134.  
  135. Contributors to GDB
  136. ===================
  137.  
  138.    Richard Stallman was the original author of GDB, and of many other
  139. GNU programs.  Many others have contributed to its development.  This
  140. section attempts to credit major contributors.  One of the virtues of
  141. free software is that everyone is free to contribute to it; with
  142. regret, we cannot actually acknowledge everyone here.  The file
  143. `ChangeLog' in the GDB distribution approximates a blow-by-blow account.
  144.  
  145.    Changes much prior to version 2.0 are lost in the mists of time.
  146.  
  147.      *Plea:* Additions to this section are particularly welcome.  If you
  148.      or your friends (or enemies, to be evenhanded) have been unfairly
  149.      omitted from this list, we would like to add your names!
  150.  
  151.    So that they may not regard their long labor as thankless, we
  152. particularly thank those who shepherded GDB through major releases: Stu
  153. Grossman and John Gilmore (releases 4.8, 4.7, 4.6, 4.5, 4.4), John
  154. Gilmore (releases 4.3, 4.2, 4.1, 4.0, and 3.9); Jim Kingdon (releases
  155. 3.5, 3.4, 3.3); and Randy Smith (releases 3.2, 3.1, 3.0).  As major
  156. maintainer of GDB for some period, each contributed significantly to
  157. the structure, stability, and capabilities of the entire debugger.
  158.  
  159.    Richard Stallman, assisted at various times by Pete TerMaat, Chris
  160. Hanson, and Richard Mlynarik, handled releases through 2.8.
  161.  
  162.    Michael Tiemann is the author of most of the GNU C++ support in GDB,
  163. with significant additional contributions from Per Bothner.  James
  164. Clark wrote the GNU C++ demangler.  Early work on C++ was by Peter
  165. TerMaat (who also did much general update work leading to release 3.0).
  166.  
  167.    GDB 4 uses the BFD subroutine library to examine multiple
  168. object-file formats; BFD was a joint project of David V.
  169. Henkel-Wallace, Rich Pixley, Steve Chamberlain, and John Gilmore.
  170.  
  171.    David Johnson wrote the original COFF support; Pace Willison did the
  172. original support for encapsulated COFF.
  173.  
  174.    Adam de Boor and Bradley Davis contributed the ISI Optimum V support.
  175. Per Bothner, Noboyuki Hikichi, and Alessandro Forin contributed MIPS
  176. support.  Jean-Daniel Fekete contributed Sun 386i support.  Chris
  177. Hanson improved the HP9000 support.  Noboyuki Hikichi and Tomoyuki
  178. Hasei contributed Sony/News OS 3 support.  David Johnson contributed
  179. Encore Umax support.  Jyrki Kuoppala contributed Altos 3068 support.
  180. Keith Packard contributed NS32K support.  Doug Rabson contributed Acorn
  181. Risc Machine support.  Chris Smith contributed Convex support (and
  182. Fortran debugging).  Jonathan Stone contributed Pyramid support.
  183. Michael Tiemann contributed SPARC support.  Tim Tucker contributed
  184. support for the Gould NP1 and Gould Powernode.  Pace Willison
  185. contributed Intel 386 support.  Jay Vosburgh contributed Symmetry
  186. support.
  187.  
  188.    Rich Schaefer and Peter Schauer helped with support of SunOS shared
  189. libraries.
  190.  
  191.    Jay Fenlason and Roland McGrath ensured that GDB and GAS agree about
  192. several machine instruction sets.
  193.  
  194.    Patrick Duval, Ted Goldstein, Vikram Koka and Glenn Engel helped
  195. develop remote debugging.  Intel Corporation and Wind River Systems
  196. contributed remote debugging modules for their products.
  197.  
  198.    Brian Fox is the author of the readline libraries providing
  199. command-line editing and command history.
  200.  
  201.    Andrew Beers of SUNY Buffalo wrote the language-switching code and
  202. the Modula-2 support, and contributed the Languages chapter of this
  203. manual.
  204.  
  205.    Fred Fish wrote most of the support for Unix System Vr4.  He also
  206. enhanced the command-completion support to cover C++ overloaded symbols.
  207.  
  208.    Hitachi America, Ltd. sponsored the support for Hitachi
  209. microprocessors.
  210.  
  211. 
  212. File: gdb.info,  Node: New Features,  Next: Sample Session,  Prev: Summary,  Up: Top
  213.  
  214. New Features since GDB Version 3.5
  215. **********************************
  216.  
  217. *Targets*
  218.      Using the new command `target', you can select at runtime whether
  219.      you are debugging local files, local processes, standalone systems
  220.      over a serial port, realtime systems over a TCP/IP connection,
  221.      etc.  The command `load' can download programs into a remote
  222.      system.  Serial stubs are available for Motorola 680x0, Intel
  223.      80386, and Sparc remote systems; GDB also supports debugging
  224.      realtime processes running under VxWorks, using SunRPC Remote
  225.      Procedure Calls over TCP/IP to talk to a debugger stub on the
  226.      target system.  Internally, GDB now uses a function vector to
  227.      mediate access to different targets; if you need to add your own
  228.      support for a remote protocol, this makes it much easier.
  229.  
  230. *Watchpoints*
  231.      GDB now sports watchpoints as well as breakpoints.  You can use a
  232.      watchpoint to stop execution whenever the value of an expression
  233.      changes, without having to predict a particular place in your
  234.      program where this may happen.
  235.  
  236. *Wide Output*
  237.      Commands that issue wide output now insert newlines at places
  238.      designed to make the output more readable.
  239.  
  240. *Object Code Formats*
  241.      GDB uses a new library called the Binary File Descriptor (BFD)
  242.      Library to permit it to switch dynamically, without
  243.      reconfiguration or recompilation, between different object-file
  244.      formats.  Formats currently supported are COFF, a.out, and the
  245.      Intel 960 b.out; files may be read as .o files, archive libraries,
  246.      or core dumps.  BFD is available as a subroutine library so that
  247.      other programs may take advantage of it, and the other GNU binary
  248.      utilities are being converted to use it.
  249.  
  250. *Configuration and Ports*
  251.      Compile-time configuration (to select a particular architecture and
  252.      operating system) is much easier.  The script `configure' now
  253.      allows you to configure GDB as either a native debugger or a
  254.      cross-debugger. *Note Installing GDB::, for details on how to
  255.      configure.
  256.  
  257. *Interaction*
  258.      The user interface to the GDB control variables is simpler, and is
  259.      consolidated in two commands, `set' and `show'.  Output lines are
  260.      now broken at readable places, rather than overflowing onto the
  261.      next line.  You can suppress output of machine-level addresses,
  262.      displaying only source language information.
  263.  
  264. *C++*
  265.      GDB now supports C++ multiple inheritance (if used with a GCC
  266.      version 2 compiler), and also has limited support for C++ exception
  267.      handling, with the commands `catch' and `info catch': GDB can
  268.      break when an exception is raised, before the stack is peeled back
  269.      to the exception handler's context.
  270.  
  271. *Modula-2*
  272.      GDB now has preliminary support for the GNU Modula-2 compiler,
  273.      currently under development at the State University of New York at
  274.      Buffalo.  Coordinated development of both GDB and the GNU Modula-2
  275.      compiler will continue.  Other Modula-2 compilers are currently
  276.      not supported, and attempting to debug programs compiled with them
  277.      will likely result in an error as the symbol table of the
  278.      executable is read in.
  279.  
  280. *Command Rationalization*
  281.      Many GDB commands have been renamed to make them easier to remember
  282.      and use.  In particular, the subcommands of `info' and
  283.      `show'/`set' are grouped to make the former refer to the state of
  284.      your program, and the latter refer to the state of GDB itself.
  285.      *Note Renamed Commands::, for details on what commands were
  286.      renamed.
  287.  
  288. *Shared Libraries*
  289.      GDB 4 can debug programs and core files that use SunOS, SVR4, or
  290.      IBM RS/6000 shared libraries.
  291.  
  292. *Reference Card*
  293.      GDB 4 has a reference card.  *Note Formatting the Documentation:
  294.      Formatting Documentation, for instructions about how to print it.
  295.  
  296. *Work in Progress*
  297.      Kernel debugging for BSD and Mach systems; Tahoe and HPPA
  298.      architecture support.
  299.  
  300. 
  301. File: gdb.info,  Node: Sample Session,  Next: Invocation,  Prev: New Features,  Up: Top
  302.  
  303. A Sample GDB Session
  304. ********************
  305.  
  306.    You can use this manual at your leisure to read all about GDB.
  307. However, a handful of commands are enough to get started using the
  308. debugger.  This chapter illustrates those commands.
  309.  
  310.    One of the preliminary versions of GNU `m4' (a generic macro
  311. processor) exhibits the following bug: sometimes, when we change its
  312. quote strings from the default, the commands used to capture one macro
  313. definition within another stop working.  In the following short `m4'
  314. session, we define a macro `foo' which expands to `0000'; we then use
  315. the `m4' built-in `defn' to define `bar' as the same thing.  However,
  316. when we change the open quote string to `<QUOTE>' and the close quote
  317. string to `<UNQUOTE>', the same procedure fails to define a new synonym
  318. `baz':
  319.  
  320.      $ cd gnu/m4
  321.      $ ./m4
  322.      define(foo,0000)
  323.      
  324.      foo
  325.      0000
  326.      define(bar,defn(`foo'))
  327.      
  328.      bar
  329.      0000
  330.      changequote(<QUOTE>,<UNQUOTE>)
  331.      
  332.      define(baz,defn(<QUOTE>foo<UNQUOTE>))
  333.      baz
  334.      C-d
  335.      m4: End of input: 0: fatal error: EOF in string
  336.  
  337. Let us use GDB to try to see what is going on.
  338.  
  339.      $ gdb m4
  340.      GDB is free software and you are welcome to distribute copies
  341.       of it under certain conditions; type "show copying" to see
  342.       the conditions.
  343.      There is absolutely no warranty for GDB; type "show warranty"
  344.       for details.
  345.      GDB 4.9, Copyright 1993 Free Software Foundation, Inc...
  346.      (gdb)
  347.  
  348. GDB reads only enough symbol data to know where to find the rest when
  349. needed; as a result, the first prompt comes up very quickly.  We now
  350. tell GDB to use a narrower display width than usual, so that examples
  351. will fit in this manual.
  352.  
  353.      (gdb) set width 70
  354.  
  355. We need to see how the `m4' built-in `changequote' works.  Having
  356. looked at the source, we know the relevant subroutine is
  357. `m4_changequote', so we set a breakpoint there with the GDB `break'
  358. command.
  359.  
  360.      (gdb) break m4_changequote
  361.      Breakpoint 1 at 0x62f4: file builtin.c, line 879.
  362.  
  363. Using the `run' command, we start `m4' running under GDB control; as
  364. long as control does not reach the `m4_changequote' subroutine, the
  365. program runs as usual:
  366.  
  367.      (gdb) run
  368.      Starting program: /work/Editorial/gdb/gnu/m4/m4
  369.      define(foo,0000)
  370.      
  371.      foo
  372.      0000
  373.  
  374. To trigger the breakpoint, we call `changequote'.  GDB suspends
  375. execution of `m4', displaying information about the context where it
  376. stops.
  377.  
  378.      changequote(<QUOTE>,<UNQUOTE>)
  379.      
  380.      Breakpoint 1, m4_changequote (argc=3, argv=0x33c70)
  381.          at builtin.c:879
  382.      879         if (bad_argc(TOKEN_DATA_TEXT(argv[0]),argc,1,3))
  383.  
  384. Now we use the command `n' (`next') to advance execution to the next
  385. line of the current function.
  386.  
  387.      (gdb) n
  388.      882         set_quotes((argc >= 2) ? TOKEN_DATA_TEXT(argv[1])\
  389.       : nil,
  390.  
  391. `set_quotes' looks like a promising subroutine.  We can go into it by
  392. using the command `s' (`step') instead of `next'.  `step' goes to the
  393. next line to be executed in *any* subroutine, so it steps into
  394. `set_quotes'.
  395.  
  396.      (gdb) s
  397.      set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
  398.          at input.c:530
  399.      530         if (lquote != def_lquote)
  400.  
  401. The display that shows the subroutine where `m4' is now suspended (and
  402. its arguments) is called a stack frame display.  It shows a summary of
  403. the stack.  We can use the `backtrace' command (which can also be
  404. spelled `bt'), to see where we are in the stack as a whole: the
  405. `backtrace' command displays a stack frame for each active subroutine.
  406.  
  407.      (gdb) bt
  408.      #0  set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
  409.          at input.c:530
  410.      #1  0x6344 in m4_changequote (argc=3, argv=0x33c70)
  411.          at builtin.c:882
  412.      #2  0x8174 in expand_macro (sym=0x33320) at macro.c:242
  413.      #3  0x7a88 in expand_token (obs=0x0, t=209696, td=0xf7fffa30)
  414.          at macro.c:71
  415.      #4  0x79dc in expand_input () at macro.c:40
  416.      #5  0x2930 in main (argc=0, argv=0xf7fffb20) at m4.c:195
  417.  
  418. We will step through a few more lines to see what happens.  The first
  419. two times, we can use `s'; the next two times we use `n' to avoid
  420. falling into the `xstrdup' subroutine.
  421.  
  422.      (gdb) s
  423.      0x3b5c  532         if (rquote != def_rquote)
  424.      (gdb) s
  425.      0x3b80  535         lquote = (lq == nil || *lq == '\0') ?  \
  426.      def_lquote : xstrdup(lq);
  427.      (gdb) n
  428.      536         rquote = (rq == nil || *rq == '\0') ? def_rquote\
  429.       : xstrdup(rq);
  430.      (gdb) n
  431.      538         len_lquote = strlen(rquote);
  432.  
  433. The last line displayed looks a little odd; we can examine the variables
  434. `lquote' and `rquote' to see if they are in fact the new left and right
  435. quotes we specified.  We use the command `p' (`print') to see their
  436. values.
  437.  
  438.      (gdb) p lquote
  439.      $1 = 0x35d40 "<QUOTE>"
  440.      (gdb) p rquote
  441.      $2 = 0x35d50 "<UNQUOTE>"
  442.  
  443. `lquote' and `rquote' are indeed the new left and right quotes.  To
  444. look at some context, we can display ten lines of source surrounding
  445. the current line with the `l' (`list') command.
  446.  
  447.      (gdb) l
  448.      533             xfree(rquote);
  449.      534
  450.      535         lquote = (lq == nil || *lq == '\0') ? def_lquote\
  451.       : xstrdup (lq);
  452.      536         rquote = (rq == nil || *rq == '\0') ? def_rquote\
  453.       : xstrdup (rq);
  454.      537
  455.      538         len_lquote = strlen(rquote);
  456.      539         len_rquote = strlen(lquote);
  457.      540     }
  458.      541
  459.      542     void
  460.  
  461. Let us step past the two lines that set `len_lquote' and `len_rquote',
  462. and then examine the values of those variables.
  463.  
  464.      (gdb) n
  465.      539         len_rquote = strlen(lquote);
  466.      (gdb) n
  467.      540     }
  468.      (gdb) p len_lquote
  469.      $3 = 9
  470.      (gdb) p len_rquote
  471.      $4 = 7
  472.  
  473. That certainly looks wrong, assuming `len_lquote' and `len_rquote' are
  474. meant to be the lengths of `lquote' and `rquote' respectively.  We can
  475. set them to better values using the `p' command, since it can print the
  476. value of any expression--and that expression can include subroutine
  477. calls and assignments.
  478.  
  479.      (gdb) p len_lquote=strlen(lquote)
  480.      $5 = 7
  481.      (gdb) p len_rquote=strlen(rquote)
  482.      $6 = 9
  483.  
  484. Is that enough to fix the problem of using the new quotes with the `m4'
  485. built-in `defn'?  We can allow `m4' to continue executing with the `c'
  486. (`continue') command, and then try the example that caused trouble
  487. initially:
  488.  
  489.      (gdb) c
  490.      Continuing.
  491.      
  492.      define(baz,defn(<QUOTE>foo<UNQUOTE>))
  493.      
  494.      baz
  495.      0000
  496.  
  497. Success!  The new quotes now work just as well as the default ones.  The
  498. problem seems to have been just the two typos defining the wrong
  499. lengths.  We allow `m4' exit by giving it an EOF as input:
  500.  
  501.      C-d
  502.      Program exited normally.
  503.  
  504. The message `Program exited normally.' is from GDB; it indicates `m4'
  505. has finished executing.  We can end our GDB session with the GDB `quit'
  506. command.
  507.  
  508.      (gdb) quit
  509.  
  510. 
  511. File: gdb.info,  Node: Invocation,  Next: Commands,  Prev: Sample Session,  Up: Top
  512.  
  513. Getting In and Out of GDB
  514. *************************
  515.  
  516.    This chapter discusses how to start GDB, and how to get out of it.
  517. (The essentials: type `gdb' to start GDB, and type `quit' or `C-d' to
  518. exit.)
  519.  
  520. * Menu:
  521.  
  522. * Invoking GDB::                How to start GDB
  523. * Quitting GDB::                 How to quit GDB
  524. * Shell Commands::              How to use shell commands inside GDB
  525.  
  526. 
  527. File: gdb.info,  Node: Invoking GDB,  Next: Quitting GDB,  Up: Invocation
  528.  
  529. Invoking GDB
  530. ============
  531.  
  532.    Invoke GDB by running the program `gdb'.  Once started, GDB reads
  533. commands from the terminal until you tell it to exit.
  534.  
  535.    You can also run `gdb' with a variety of arguments and options, to
  536. specify more of your debugging environment at the outset.
  537.  
  538.    The command-line options described here are designed to cover a
  539. variety of situations; in some environments, some of these options may
  540. effectively be unavailable.
  541.  
  542.    The most usual way to start GDB is with one argument, specifying an
  543. executable program:
  544.  
  545.      gdb PROGRAM
  546.  
  547. You can also start with both an executable program and a core file
  548. specified:
  549.  
  550.      gdb PROGRAM CORE
  551.  
  552.    You can, instead, specify a process ID as a second argument, if you
  553. want to debug a running process:
  554.  
  555.      gdb PROGRAM 1234
  556.  
  557. would attach GDB to process `1234' (unless you also have a file named
  558. `1234'; GDB does check for a core file first).
  559.  
  560.    Taking advantage of the second command-line argument requires a
  561. fairly complete operating system; when you use GDB as a remote debugger
  562. attached to a bare board, there may not be any notion of "process", and
  563. there is often no way to get a core dump.
  564.  
  565. You can further control how GDB starts up by using command-line
  566. options.  GDB itself can remind you of the options available.
  567.  
  568. Type
  569.  
  570.      gdb -help
  571.  
  572. to display all available options and briefly describe their use (`gdb
  573. -h' is a shorter equivalent).
  574.  
  575.    All options and command line arguments you give are processed in
  576. sequential order.  The order makes a difference when the `-x' option is
  577. used.
  578.  
  579. * Menu:
  580.  
  581.  
  582.  
  583. * File Options::                Choosing files
  584. * Mode Options::                Choosing modes
  585.  
  586. 
  587. File: gdb.info,  Node: File Options,  Next: Mode Options,  Up: Invoking GDB
  588.  
  589. Choosing files
  590. --------------
  591.  
  592.    When GDB starts, it reads any arguments other than options as
  593. specifying an executable file and core file (or process ID).  This is
  594. the same as if the arguments were specified by the `-se' and `-c'
  595. options respectively.  (GDB reads the first argument that does not have
  596. an associated option flag as equivalent to the `-se' option followed by
  597. that argument; and the second argument that does not have an associated
  598. option flag, if any, as equivalent to the `-c' option followed by that
  599. argument.)
  600.  
  601.    Many options have both long and short forms; both are shown in the
  602. following list.  GDB also recognizes the long forms if you truncate
  603. them, so long as enough of the option is present to be unambiguous.
  604. (If you prefer, you can flag option arguments with `--' rather than
  605. `-', though we illustrate the more usual convention.)
  606.  
  607. `-symbols=FILE'
  608. `-s FILE'
  609.      Read symbol table from file FILE.
  610.  
  611. `-exec=FILE'
  612. `-e FILE'
  613.      Use file FILE as the executable file to execute when appropriate,
  614.      and for examining pure data in conjunction with a core dump.
  615.  
  616. `-se=FILE'
  617.      Read symbol table from file FILE and use it as the executable file.
  618.  
  619. `-core=FILE'
  620. `-c FILE'
  621.      Use file FILE as a core dump to examine.
  622.  
  623. `-command=FILE'
  624. `-x FILE'
  625.      Execute GDB commands from file FILE.  *Note Command files: Command
  626.      Files.
  627.  
  628. `-directory=DIRECTORY'
  629. `-d DIRECTORY'
  630.      Add DIRECTORY to the path to search for source files.
  631.  
  632. `-m'
  633. `-mapped'
  634.      *Warning: this option depends on operating system facilities that
  635.      are not supported on all systems.*
  636.      If memory-mapped files are available on your system through the
  637.      `mmap' system call, you can use this option to have GDB write the
  638.      symbols from your program into a reusable file in the current
  639.      directory.  If the program you are debugging is called
  640.      `/tmp/fred', the mapped symbol file will be `./fred.syms'.  Future
  641.      GDB debugging sessions will notice the presence of this file, and
  642.      will quickly map in symbol information from it, rather than reading
  643.      the symbol table from the executable program.
  644.  
  645.      The `.syms' file is specific to the host machine where GDB is run.
  646.      It holds an exact image of the internal GDB symbol table.  It
  647.      cannot be shared across multiple host platforms.
  648.  
  649. `-r'
  650. `-readnow'
  651.      Read each symbol file's entire symbol table immediately, rather
  652.      than the default, which is to read it incrementally as it is
  653.      needed.  This makes startup slower, but makes future operations
  654.      faster.
  655.  
  656.    The `-mapped' and `-readnow' options are typically combined in order
  657. to build a `.syms' file that contains complete symbol information.
  658. (*Note Commands to specify files: Files, for information on `.syms'
  659. files.)  A simple GDB invocation to do nothing but build a `.syms' file
  660. for future use is:
  661.  
  662.          gdb -batch -nx -mapped -readnow programname
  663.  
  664. 
  665. File: gdb.info,  Node: Mode Options,  Prev: File Options,  Up: Invoking GDB
  666.  
  667. Choosing modes
  668. --------------
  669.  
  670.    You can run GDB in various alternative modes--for example, in batch
  671. mode or quiet mode.
  672.  
  673. `-nx'
  674. `-n'
  675.      Do not execute commands from any `.gdbinit' initialization files.
  676.      Normally, the commands in these files are executed after all the
  677.      command options and arguments have been processed.  *Note Command
  678.      files: Command Files.
  679.  
  680. `-quiet'
  681. `-q'
  682.      "Quiet".  Do not print the introductory and copyright messages.
  683.      These messages are also suppressed in batch mode.
  684.  
  685. `-batch'
  686.      Run in batch mode.  Exit with status `0' after processing all the
  687.      command files specified with `-x' (and `.gdbinit', if not
  688.      inhibited).  Exit with nonzero status if an error occurs in
  689.      executing the GDB commands in the command files.
  690.  
  691.      Batch mode may be useful for running GDB as a filter, for example
  692.      to download and run a program on another computer; in order to
  693.      make this more useful, the message
  694.  
  695.           Program exited normally.
  696.  
  697.      (which is ordinarily issued whenever a program running under GDB
  698.      control terminates) is not issued when running in batch mode.
  699.  
  700. `-cd=DIRECTORY'
  701.      Run GDB using DIRECTORY as its working directory, instead of the
  702.      current directory.
  703.  
  704. `-fullname'
  705. `-f'
  706.      Emacs sets this option when it runs GDB as a subprocess.  It tells
  707.      GDB to output the full file name and line number in a standard,
  708.      recognizable fashion each time a stack frame is displayed (which
  709.      includes each time your program stops).  This recognizable format
  710.      looks like two `\032' characters, followed by the file name, line
  711.      number and character position separated by colons, and a newline.
  712.      The Emacs-to-GDB interface program uses the two `\032' characters
  713.      as a signal to display the source code for the frame.
  714.  
  715. `-b BPS'
  716.      Set the line speed (baud rate or bits per second) of any serial
  717.      interface used by GDB for remote debugging.
  718.  
  719. `-tty=DEVICE'
  720.      Run using DEVICE for your program's standard input and output.
  721.  
  722. 
  723. File: gdb.info,  Node: Quitting GDB,  Next: Shell Commands,  Prev: Invoking GDB,  Up: Invocation
  724.  
  725. Quitting GDB
  726. ============
  727.  
  728. `quit'
  729.      To exit GDB, use the `quit' command (abbreviated `q'), or type an
  730.      end-of-file character (usually `C-d').
  731.  
  732.    An interrupt (often `C-c') will not exit from GDB, but rather will
  733. terminate the action of any GDB command that is in progress and return
  734. to GDB command level.  It is safe to type the interrupt character at
  735. any time because GDB does not allow it to take effect until a time when
  736. it is safe.
  737.  
  738.    If you have been using GDB to control an attached process or device,
  739. you can release it with the `detach' command (*note Debugging an
  740. already-running process: Attach.).
  741.  
  742. 
  743. File: gdb.info,  Node: Shell Commands,  Prev: Quitting GDB,  Up: Invocation
  744.  
  745. Shell commands
  746. ==============
  747.  
  748.    If you need to execute occasional shell commands during your
  749. debugging session, there is no need to leave or suspend GDB; you can
  750. just use the `shell' command.
  751.  
  752. `shell COMMAND STRING'
  753.      Invoke a the standard shell to execute COMMAND STRING.  If it
  754.      exists, the environment variable `SHELL' determines which shell to
  755.      run.  Otherwise GDB uses `/bin/sh'.
  756.  
  757.    The utility `make' is often needed in development environments.  You
  758. do not have to use the `shell' command for this purpose in GDB:
  759.  
  760. `make MAKE-ARGS'
  761.      Execute the `make' program with the specified arguments.  This is
  762.      equivalent to `shell make MAKE-ARGS'.
  763.  
  764. 
  765. File: gdb.info,  Node: Commands,  Next: Running,  Prev: Invocation,  Up: Top
  766.  
  767. GDB Commands
  768. ************
  769.  
  770.    You can abbreviate a GDB command to the first few letters of the
  771. command name, if that abbreviation is unambiguous; and you can repeat
  772. certain GDB commands by typing just RET.  You can also use the TAB key
  773. to get GDB to fill out the rest of a word in a command (or to show you
  774. the alternatives available, if there is more than one possibility).
  775.  
  776. * Menu:
  777.  
  778. * Command Syntax::              How to give commands to GDB
  779. * Completion::                  Command completion
  780. * Help::                        How to ask GDB for help
  781.  
  782. 
  783. File: gdb.info,  Node: Command Syntax,  Next: Completion,  Up: Commands
  784.  
  785. Command syntax
  786. ==============
  787.  
  788.    A GDB command is a single line of input.  There is no limit on how
  789. long it can be.  It starts with a command name, which is followed by
  790. arguments whose meaning depends on the command name.  For example, the
  791. command `step' accepts an argument which is the number of times to
  792. step, as in `step 5'.  You can also use the `step' command with no
  793. arguments.  Some command names do not allow any arguments.
  794.  
  795.    GDB command names may always be truncated if that abbreviation is
  796. unambiguous.  Other possible command abbreviations are listed in the
  797. documentation for individual commands.  In some cases, even ambiguous
  798. abbreviations are allowed; for example, `s' is specially defined as
  799. equivalent to `step' even though there are other commands whose names
  800. start with `s'.  You can test abbreviations by using them as arguments
  801. to the `help' command.
  802.  
  803.    A blank line as input to GDB (typing just RET) means to repeat the
  804. previous command. Certain commands (for example, `run') will not repeat
  805. this way; these are commands for which unintentional repetition might
  806. cause trouble and which you are unlikely to want to repeat.
  807.  
  808.    The `list' and `x' commands, when you repeat them with RET,
  809. construct new arguments rather than repeating exactly as typed.  This
  810. permits easy scanning of source or memory.
  811.  
  812.    GDB can also use RET in another way: to partition lengthy output, in
  813. a way similar to the common utility `more' (*note Screen size: Screen
  814. Size.).  Since it is easy to press one RET too many in this situation,
  815. GDB disables command repetition after any command that generates this
  816. sort of display.
  817.  
  818.    Any text from a `#' to the end of the line is a comment; it does
  819. nothing.  This is useful mainly in command files (*note Command files:
  820. Command Files.).
  821.  
  822. 
  823. File: gdb.info,  Node: Completion,  Next: Help,  Prev: Command Syntax,  Up: Commands
  824.  
  825. Command completion
  826. ==================
  827.  
  828.    GDB can fill in the rest of a word in a command for you, if there is
  829. only one possibility; it can also show you what the valid possibilities
  830. are for the next word in a command, at any time.  This works for GDB
  831. commands, GDB subcommands, and the names of symbols in your program.
  832.  
  833.    Press the TAB key whenever you want GDB to fill out the rest of a
  834. word.  If there is only one possibility, GDB will fill in the word, and
  835. wait for you to finish the command (or press RET to enter it).  For
  836. example, if you type
  837.  
  838.      (gdb) info bre TAB
  839.  
  840. GDB fills in the rest of the word `breakpoints', since that is the only
  841. `info' subcommand beginning with `bre':
  842.  
  843.      (gdb) info breakpoints
  844.  
  845. You can either press RET at this point, to run the `info breakpoints'
  846. command, or backspace and enter something else, if `breakpoints' does
  847. not look like the command you expected.  (If you were sure you wanted
  848. `info breakpoints' in the first place, you might as well just type RET
  849. immediately after `info bre', to exploit command abbreviations rather
  850. than command completion).
  851.  
  852.    If there is more than one possibility for the next word when you
  853. press TAB, GDB will sound a bell.  You can either supply more
  854. characters and try again, or just press TAB a second time, and GDB will
  855. display all the possible completions for that word.  For example, you
  856. might want to set a breakpoint on a subroutine whose name begins with
  857. `make_', but when you type `b make_TAB' GDB just sounds the bell.
  858. Typing TAB again will display all the function names in your program
  859. that begin with those characters, for example:
  860.  
  861.      (gdb) b make_ TAB
  862. GDB sounds bell; press TAB again, to see:
  863.      make_a_section_from_file     make_environ
  864.      make_abs_section             make_function_type
  865.      make_blockvector             make_pointer_type
  866.      make_cleanup                 make_reference_type
  867.      make_command                 make_symbol_completion_list
  868.      (gdb) b make_
  869.  
  870. After displaying the available possibilities, GDB copies your partial
  871. input (`b make_' in the example) so you can finish the command.
  872.  
  873.    If you just want to see the list of alternatives in the first place,
  874. you can press `M-?' rather than pressing TAB twice. `M-?' means `META
  875. ?'.  You can type this either by holding down a key designated as the
  876. META shift on your keyboard (if there is one) while typing `?', or as
  877. ESC followed by `?'.
  878.  
  879.    Sometimes the string you need, while logically a "word", may contain
  880. parentheses or other characters that GDB normally excludes from its
  881. notion of a word.  To permit word completion to work in this situation,
  882. you may enclose words in `'' (single quote marks) in GDB commands.
  883.  
  884.    The most likely situation where you might need this is in typing the
  885. name of a C++ function.  This is because C++ allows function overloading
  886. (multiple definitions of the same function, distinguished by argument
  887. type).  For example, when you want to set a breakpoint you may need to
  888. distinguish whether you mean the version of `name' that takes an `int'
  889. parameter, `name(int)', or the version that takes a `float' parameter,
  890. `name(float)'.  To use the word-completion facilities in this
  891. situation, type a single quote `'' at the beginning of the function
  892. name.  This alerts GDB that it may need to consider more information
  893. than usual when you press TAB or `M-?' to request word completion:
  894.  
  895.      (gdb) b 'bubble( M-?
  896.      bubble(double,double)    bubble(int,int)
  897.      (gdb) b 'bubble(
  898.  
  899.    In some cases, GDB can tell that completing a name will require
  900. quotes.  When this happens, GDB will insert the quote for you (while
  901. completing as much as it can) if you do not type the quote in the first
  902. place:
  903.  
  904.      (gdb) b bub TAB
  905. GDB alters your input line to the following, and rings a bell:
  906.      (gdb) b 'bubble(
  907.  
  908. In general, GDB can tell that a quote is needed (and inserts it) if you
  909. have not yet started typing the argument list when you ask for
  910. completion on an overloaded symbol.
  911.  
  912. 
  913. File: gdb.info,  Node: Help,  Prev: Completion,  Up: Commands
  914.  
  915. Getting help
  916. ============
  917.  
  918.    You can always ask GDB itself for information on its commands, using
  919. the command `help'.
  920.  
  921. `help'
  922. `h'
  923.      You can use `help' (abbreviated `h') with no arguments to display
  924.      a short list of named classes of commands:
  925.  
  926.           (gdb) help
  927.           List of classes of commands:
  928.           
  929.           running -- Running the program
  930.           stack -- Examining the stack
  931.           data -- Examining data
  932.           breakpoints -- Making program stop at certain points
  933.           files -- Specifying and examining files
  934.           status -- Status inquiries
  935.           support -- Support facilities
  936.           user-defined -- User-defined commands
  937.           aliases -- Aliases of other commands
  938.           obscure -- Obscure features
  939.           
  940.           Type "help" followed by a class name for a list of
  941.           commands in that class.
  942.           Type "help" followed by command name for full
  943.           documentation.
  944.           Command name abbreviations are allowed if unambiguous.
  945.           (gdb)
  946.  
  947. `help CLASS'
  948.      Using one of the general help classes as an argument, you can get a
  949.      list of the individual commands in that class.  For example, here
  950.      is the help display for the class `status':
  951.  
  952.           (gdb) help status
  953.           Status inquiries.
  954.           
  955.           List of commands:
  956.           
  957.           show -- Generic command for showing things set
  958.            with "set"
  959.           info -- Generic command for printing status
  960.           
  961.           Type "help" followed by command name for full
  962.           documentation.
  963.           Command name abbreviations are allowed if unambiguous.
  964.           (gdb)
  965.  
  966. `help COMMAND'
  967.      With a command name as `help' argument, GDB will display a short
  968.      paragraph on how to use that command.
  969.  
  970.    In addition to `help', you can use the GDB commands `info' and
  971. `show' to inquire about the state of your program, or the state of GDB
  972. itself.  Each command supports many topics of inquiry; this manual
  973. introduces each of them in the appropriate context.  The listings under
  974. `info' and under `show' in the Index point to all the sub-commands.
  975. *Note Index::.
  976.  
  977. `info'
  978.      This command (abbreviated `i') is for describing the state of your
  979.      program.  For example, you can list the arguments given to your
  980.      program with `info args', list the registers currently in use with
  981.      `info registers', or list the breakpoints you have set with `info
  982.      breakpoints'.  You can get a complete list of the `info'
  983.      sub-commands with `help info'.
  984.  
  985. `show'
  986.      In contrast, `show' is for describing the state of GDB itself.
  987.      You can change most of the things you can `show', by using the
  988.      related command `set'; for example, you can control what number
  989.      system is used for displays with `set radix', or simply inquire
  990.      which is currently in use with `show radix'.
  991.  
  992.      To display all the settable parameters and their current values,
  993.      you can use `show' with no arguments; you may also use `info set'.
  994.      Both commands produce the same display.
  995.  
  996.    Here are three miscellaneous `show' subcommands, all of which are
  997. exceptional in lacking corresponding `set' commands:
  998.  
  999. `show version'
  1000.      Show what version of GDB is running.  You should include this
  1001.      information in GDB bug-reports.  If multiple versions of GDB are in
  1002.      use at your site, you may occasionally want to determine which
  1003.      version of GDB you are running; as GDB evolves, new commands are
  1004.      introduced, and old ones may wither away.  The version number is
  1005.      also announced when you start GDB with no arguments.
  1006.  
  1007. `show copying'
  1008.      Display information about permission for copying GDB.
  1009.  
  1010. `show warranty'
  1011.      Display the GNU "NO WARRANTY" statement.
  1012.  
  1013. 
  1014. File: gdb.info,  Node: Running,  Next: Stopping,  Prev: Commands,  Up: Top
  1015.  
  1016. Running Programs Under GDB
  1017. **************************
  1018.  
  1019.    When you run a program under GDB, you must first generate debugging
  1020. information when you compile it.  You may start it with its arguments,
  1021. if any, in an environment of your choice.  You may redirect your
  1022. program's input and output, debug an already running process, or kill a
  1023. child process.
  1024.  
  1025. * Menu:
  1026.  
  1027. * Compilation::                 Compiling for debugging
  1028. * Starting::                    Starting your program
  1029.  
  1030. * Arguments::                   Your program's arguments
  1031. * Environment::                 Your program's environment
  1032. * Working Directory::           Your program's working directory
  1033. * Input/Output::                Your program's input and output
  1034. * Attach::                      Debugging an already-running process
  1035. * Kill Process::                Killing the child process
  1036. * Process Information::         Additional process information
  1037.  
  1038. 
  1039. File: gdb.info,  Node: Compilation,  Next: Starting,  Up: Running
  1040.  
  1041. Compiling for debugging
  1042. =======================
  1043.  
  1044.    In order to debug a program effectively, you need to generate
  1045. debugging information when you compile it.  This debugging information
  1046. is stored in the object file; it describes the data type of each
  1047. variable or function and the correspondence between source line numbers
  1048. and addresses in the executable code.
  1049.  
  1050.    To request debugging information, specify the `-g' option when you
  1051. run the compiler.
  1052.  
  1053.    Many C compilers are unable to handle the `-g' and `-O' options
  1054. together.  Using those compilers, you cannot generate optimized
  1055. executables containing debugging information.
  1056.  
  1057.    GCC, the GNU C compiler, supports `-g' with or without `-O', making
  1058. it possible to debug optimized code.  We recommend that you *always*
  1059. use `-g' whenever you compile a program.  You may think your program is
  1060. correct, but there is no sense in pushing your luck.
  1061.  
  1062.    When you debug a program compiled with `-g -O', remember that the
  1063. optimizer is rearranging your code; the debugger will show you what is
  1064. really there.  Do not be too surprised when the execution path does not
  1065. exactly match your source file!  An extreme example: if you define a
  1066. variable, but never use it, GDB will never see that variable--because
  1067. the compiler optimizes it out of existence.
  1068.  
  1069.    Some things do not work as well with `-g -O' as with just `-g',
  1070. particularly on machines with instruction scheduling.  If in doubt,
  1071. recompile with `-g' alone, and if this fixes the problem, please report
  1072. it as a bug (including a test case!).
  1073.  
  1074.    Older versions of the GNU C compiler permitted a variant option
  1075. `-gg' for debugging information.  GDB no longer supports this format;
  1076. if your GNU C compiler has this option, do not use it.
  1077.  
  1078. 
  1079. File: gdb.info,  Node: Starting,  Next: Arguments,  Prev: Compilation,  Up: Running
  1080.  
  1081. Starting your program
  1082. =====================
  1083.  
  1084. `run'
  1085. `r'
  1086.      Use the `run' command to start your program under GDB.  You must
  1087.      first specify the program name (except on VxWorks) with an
  1088.      argument to GDB (*note Getting In and Out of GDB: Invocation.), or
  1089.      by using the `file' or `exec-file' command (*note Commands to
  1090.      specify files: Files.).
  1091.  
  1092.    If you are running your program in an execution environment that
  1093. supports processes, `run' creates an inferior process and makes that
  1094. process run your program.  (In environments without processes, `run'
  1095. jumps to the start of your program.)
  1096.  
  1097.    The execution of a program is affected by certain information it
  1098. receives from its superior.  GDB provides ways to specify this
  1099. information, which you must do *before* starting your program.  (You
  1100. can change it after starting your program, but such changes will only
  1101. affect your program the next time you start it.)  This information may
  1102. be divided into four categories:
  1103.  
  1104. The *arguments.*
  1105.      Specify the arguments to give your program as the arguments of the
  1106.      `run' command.  If a shell is available on your target, the shell
  1107.      is used to pass the arguments, so that you may use normal
  1108.      conventions (such as wildcard expansion or variable substitution)
  1109.      in describing the arguments.  In Unix systems, you can control
  1110.      which shell is used with the `SHELL' environment variable. *Note
  1111.      Your program's arguments: Arguments.
  1112.  
  1113. The *environment.*
  1114.      Your program normally inherits its environment from GDB, but you
  1115.      can use the GDB commands `set environment' and `unset environment'
  1116.      to change parts of the environment that will be given to your
  1117.      program.  *Note Your program's environment: Environment.
  1118.  
  1119. The *working directory.*
  1120.      Your program inherits its working directory from GDB.  You can set
  1121.      the GDB working directory with the `cd' command in GDB.  *Note
  1122.      Your program's working directory: Working Directory.
  1123.  
  1124. The *standard input and output.*
  1125.      Your program normally uses the same device for standard input and
  1126.      standard output as GDB is using.  You can redirect input and output
  1127.      in the `run' command line, or you can use the `tty' command to set
  1128.      a different device for your program.  *Note Your program's input
  1129.      and output: Input/Output.
  1130.  
  1131.      *Warning:* While input and output redirection work, you cannot use
  1132.      pipes to pass the output of the program you are debugging to
  1133.      another program; if you attempt this, GDB is likely to wind up
  1134.      debugging the wrong program.
  1135.  
  1136.    When you issue the `run' command, your program begins to execute
  1137. immediately.  *Note Stopping and continuing: Stopping, for discussion
  1138. of how to arrange for your program to stop.  Once your program has
  1139. stopped, you may calls functions in your program, using the `print' or
  1140. `call' commands.  *Note Examining Data: Data.
  1141.  
  1142.    If the modification time of your symbol file has changed since the
  1143. last time GDB read its symbols, GDB will discard its symbol table and
  1144. re-read it.  When it does this, GDB tries to retain your current
  1145. breakpoints.
  1146.  
  1147. 
  1148. File: gdb.info,  Node: Arguments,  Next: Environment,  Prev: Starting,  Up: Running
  1149.  
  1150. Your program's arguments
  1151. ========================
  1152.  
  1153.    The arguments to your program can be specified by the arguments of
  1154. the `run' command.  They are passed to a shell, which expands wildcard
  1155. characters and performs redirection of I/O, and thence to your program.
  1156. Your `SHELL' environment variable (if it exists) specifies what shell
  1157. GDB if you do not define `SHELL', GDB uses `/bin/sh'.
  1158.  
  1159.    `run' with no arguments uses the same arguments used by the previous
  1160. `run', or those set by the `set args' command.
  1161.  
  1162. `set args'
  1163.      Specify the arguments to be used the next time your program is
  1164.      run.  If `set args' has no arguments, `run' will execute your
  1165.      program with no arguments.  Once you have run your program with
  1166.      arguments, using `set args' before the next `run' is the only way
  1167.      to run it again without arguments.
  1168.  
  1169. `show args'
  1170.      Show the arguments to give your program when it is started.
  1171.  
  1172. 
  1173. File: gdb.info,  Node: Environment,  Next: Working Directory,  Prev: Arguments,  Up: Running
  1174.  
  1175. Your program's environment
  1176. ==========================
  1177.  
  1178.    The "environment" consists of a set of environment variables and
  1179. their values.  Environment variables conventionally record such things
  1180. as your user name, your home directory, your terminal type, and your
  1181. search path for programs to run.  Usually you set up environment
  1182. variables with the shell and they are inherited by all the other
  1183. programs you run.  When debugging, it can be useful to try running your
  1184. program with a modified environment without having to start GDB over
  1185. again.
  1186.  
  1187. `path DIRECTORY'
  1188.      Add DIRECTORY to the front of the `PATH' environment variable (the
  1189.      search path for executables), for both GDB and your program.  You
  1190.      may specify several directory names, separated by `:' or
  1191.      whitespace.  If DIRECTORY is already in the path, it is moved to
  1192.      the front, so it will be searched sooner.
  1193.  
  1194.      You can use the string `$cwd' to refer to whatever is the current
  1195.      working directory at the time GDB searches the path.  If you use
  1196.      `.' instead, it refers to the directory where you executed the
  1197.      `path' command.  GDB fills in the current path where needed in the
  1198.      DIRECTORY argument, before adding it to the search path.
  1199.  
  1200. `show paths'
  1201.      Display the list of search paths for executables (the `PATH'
  1202.      environment variable).
  1203.  
  1204. `show environment [VARNAME]'
  1205.      Print the value of environment variable VARNAME to be given to
  1206.      your program when it starts.  If you do not supply VARNAME, print
  1207.      the names and values of all environment variables to be given to
  1208.      your program.  You can abbreviate `environment' as `env'.
  1209.  
  1210. `set environment VARNAME [=] VALUE'
  1211.      Set environment variable VARNAME to VALUE.  The value changes for
  1212.      your program only, not for GDB itself.  VALUE may be any string;
  1213.      the values of environment variables are just strings, and any
  1214.      interpretation is supplied by your program itself.  The VALUE
  1215.      parameter is optional; if it is eliminated, the variable is set to
  1216.      a null value.
  1217.  
  1218.      For example, this command:
  1219.  
  1220.           set env USER = foo
  1221.  
  1222.      tells a Unix program, when subsequently run, that its user is named
  1223.      `foo'.  (The spaces around `=' are used for clarity here; they are
  1224.      not actually required.)
  1225.  
  1226. `unset environment VARNAME'
  1227.      Remove variable VARNAME from the environment to be passed to your
  1228.      program.  This is different from `set env VARNAME ='; `unset
  1229.      environment' removes the variable from the environment, rather
  1230.      than assigning it an empty value.
  1231.  
  1232.    *Warning:* GDB runs your program using the shell indicated by your
  1233. `SHELL' environment variable if it exists (or `/bin/sh' if not).  If
  1234. your `SHELL' variable names a shell that runs an initialization
  1235. file--such as `.cshrc' for C-shell, or `.bashrc' for BASH--any
  1236. variables you set in that file will affect your program.  You may wish
  1237. to move setting of environment variables to files that are only run
  1238. when you sign on, such as `.login' or `.profile'.
  1239.  
  1240. 
  1241. File: gdb.info,  Node: Working Directory,  Next: Input/Output,  Prev: Environment,  Up: Running
  1242.  
  1243. Your program's working directory
  1244. ================================
  1245.  
  1246.    Each time you start your program with `run', it inherits its working
  1247. directory from the current working directory of GDB.  The GDB working
  1248. directory is initially whatever it inherited from its parent process
  1249. (typically the shell), but you can specify a new working directory in
  1250. GDB with the `cd' command.
  1251.  
  1252.    The GDB working directory also serves as a default for the commands
  1253. that specify files for GDB to operate on.  *Note Commands to specify
  1254. files: Files.
  1255.  
  1256. `cd DIRECTORY'
  1257.      Set the GDB working directory to DIRECTORY.
  1258.  
  1259. `pwd'
  1260.      Print the GDB working directory.
  1261.  
  1262. 
  1263. File: gdb.info,  Node: Input/Output,  Next: Attach,  Prev: Working Directory,  Up: Running
  1264.  
  1265. Your program's input and output
  1266. ===============================
  1267.  
  1268.    By default, the program you run under GDB does input and output to
  1269. the same terminal that GDB uses.  GDB switches the terminal to its own
  1270. terminal modes to interact with you, but it records the terminal modes
  1271. your program was using and switches back to them when you continue
  1272. running your program.
  1273.  
  1274. `info terminal'
  1275.      Displays information recorded by GDB about the terminal modes your
  1276.      program is using.
  1277.  
  1278.    You can redirect your program's input and/or output using shell
  1279. redirection with the `run' command.  For example,
  1280.  
  1281.      run > outfile
  1282.  
  1283. starts your program, diverting its output to the file `outfile'.
  1284.  
  1285.    Another way to specify where your program should do input and output
  1286. is with the `tty' command.  This command accepts a file name as
  1287. argument, and causes this file to be the default for future `run'
  1288. commands.  It also resets the controlling terminal for the child
  1289. process, for future `run' commands.  For example,
  1290.  
  1291.      tty /dev/ttyb
  1292.  
  1293. directs that processes started with subsequent `run' commands default
  1294. to do input and output on the terminal `/dev/ttyb' and have that as
  1295. their controlling terminal.
  1296.  
  1297.    An explicit redirection in `run' overrides the `tty' command's
  1298. effect on the input/output device, but not its effect on the controlling
  1299. terminal.
  1300.  
  1301.    When you use the `tty' command or redirect input in the `run'
  1302. command, only the input *for your program* is affected.  The input for
  1303. GDB still comes from your terminal.
  1304.  
  1305.