home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / unix / info / gdb.i06 (.txt) < prev    next >
GNU Info File  |  1993-06-12  |  51KB  |  936 lines

  1. This is Info file gdb.info, produced by Makeinfo-1.47 from the input
  2. file gdb-all.tex.
  3. START-INFO-DIR-ENTRY
  4. * Gdb: (gdb).                   The GNU debugger.
  5. END-INFO-DIR-ENTRY
  6.    This file documents the GNU debugger GDB.
  7.    This is Edition 4.06, October 1992, of `Debugging with GDB: the GNU
  8. Source-Level Debugger' for GDB Version 4.7.
  9.    Copyright (C) 1988, 1989, 1990, 1991, 1992 Free Software Foundation,
  10.    Permission is granted to make and distribute verbatim copies of this
  11. manual provided the copyright notice and this permission notice are
  12. preserved on all copies.
  13.    Permission is granted to copy and distribute modified versions of
  14. this manual under the conditions for verbatim copying, provided also
  15. that the section entitled "GNU General Public License" is included
  16. exactly as in the original, and provided that the entire resulting
  17. derived work is distributed under the terms of a permission notice
  18. identical to this one.
  19.    Permission is granted to copy and distribute translations of this
  20. manual into another language, under the above conditions for modified
  21. versions, except that the section entitled "GNU General Public License"
  22. may be included in a translation approved by the Free Software
  23. Foundation instead of in the original English.
  24. File: gdb.info,  Node: Hitachi H8/300 Remote,  Prev: ST2000 Remote,  Up: Remote
  25. GDB and the Hitachi H8/300
  26. --------------------------
  27.    GDB needs to know these things to talk to your H8/300:
  28.   1. that you want to use `target hms', the remote debugging interface
  29.      for the H8/300 (this is the default when GDB is configured
  30.      specifically for the H8/300);
  31.   2. what serial device connects your host to your H8/300 (the first
  32.      serial device available on your host is the default);
  33.    GDB depends on an auxiliary terminate-and-stay-resident program
  34. called `asynctsr' to communicate with the H8/300 development board
  35. through a PC serial port.  You must also use the DOS `mode' command to
  36. set up the serial port on the DOS side.
  37.    The following sample session illustrates the steps needed to start a
  38. program under GDB control on your H8/300.  The example uses a sample
  39. H8/300 program called `t.x'.
  40.    First hook up your H8/300 development board.  In this example, we
  41. use a board attached to serial port `COM2'; if you use a different
  42. serial port, substitute its name in the argument of the `mode' command.
  43. When you call `asynctsr', the auxiliary comms program used by the
  44. degugger, you give it just the numeric part of the serial port's name;
  45. for example, `asyncstr 2' below runs `asyncstr' on `COM2'.
  46.      (eg-C:\H8300\TEST) mode com2:9600,n,8,1,p
  47.      
  48.      Resident portion of MODE loaded
  49.      
  50.      COM2: 9600, n, 8, 1, p
  51.      
  52.      (eg-C:\H8300\TEST) asynctsr 2
  53.      *Warning:* We have noticed a bug in PC-NFS that conflicts with
  54.      `asynctsr'.  If you also run PC-NFS on your DOS host, you may need
  55.      to disable it, or even boot without it, to use `asynctsr' to
  56.      control your H8/300 board.
  57.    Now that serial communications are set up, and the H8/300 is
  58. connected, you can start up GDB.  Call `gdb' with the name of your
  59. program as the argument.  `gdb' prompts you, as usual, with the prompt
  60. `(gdb)'.  Use two special commands to begin your debugging session:
  61. `target hms' to specify cross-debugging to the Hitachi board, and the
  62. `load' command to download your program to the board. `load' displays
  63. the names of the program's sections, and a `*' for each 2K of data
  64. downloaded.  (If you want to refresh GDB data on symbols or on the
  65. executable file without downloading, use the GDB commands `file' or
  66. `symbol-file'.  These commands, and `load' itself, are described in
  67. *Note Commands to Specify Files: Files.)
  68.      (eg-C:\H8300\TEST) gdb t.x
  69.      GDB is free software and you are welcome to distribute copies
  70.       of it under certain conditions; type "show copying" to see
  71.       the conditions.
  72.      There is absolutely no warranty for GDB; type "show warranty"
  73.      for details.
  74.      GDB 4.7, Copyright 1992 Free Software Foundation, Inc...
  75.      (gdb) target hms
  76.      Connected to remote H8/300 HMS system.
  77.      (gdb) load t.x
  78.      .text   : 0x8000 .. 0xabde ***********
  79.      .data   : 0xabde .. 0xad30 *
  80.      .stack  : 0xf000 .. 0xf014 *
  81.    At this point, you're ready to run or debug your program.  From here
  82. on, you can use all the usual GDB commands.  The `break' command sets
  83. breakpoints; the `run' command starts your program; `print' or `x'
  84. display data; the `continue' command resumes execution after stopping
  85. at a breakpoint.  You can use the `help' command at any time to find
  86. out more about GDB commands.
  87.    Remember, however, that *operating system* facilities aren't
  88. available on your H8/300; for example, if your program hangs, you can't
  89. send an interrupt--but you can press the RESET switch!
  90.    Use the RESET button on the H8/300 board
  91.    * to interrupt your program (don't use `ctl-C' on the DOS host--it
  92.      has no way to pass an interrupt signal to the H8/300); and
  93.    * to return to the GDB command prompt after your program finishes
  94.      normally.  The communications protocol provides no other way for
  95.      GDB to detect program completion.
  96.    In either case, GDB will see the effect of a RESET on the H8/300
  97. board as a "normal exit" of your program.
  98. File: gdb.info,  Node: Controlling GDB,  Next: Sequences,  Prev: Targets,  Up: Top
  99. Controlling GDB
  100. ***************
  101.    You can alter many aspects of GDB's interaction with you by using
  102. the `set' command.  For commands controlling how GDB displays data,
  103. *note Print Settings: Print Settings.; other settings are described
  104. here.
  105. * Menu:
  106. * Prompt::                      Prompt
  107. * Editing::                     Command Editing
  108. * History::                     Command History
  109. * Screen Size::                 Screen Size
  110. * Numbers::                     Numbers
  111. * Messages/Warnings::           Optional Warnings and Messages
  112. File: gdb.info,  Node: Prompt,  Next: Editing,  Up: Controlling GDB
  113. Prompt
  114. ======
  115.    GDB indicates its readiness to read a command by printing a string
  116. called the "prompt".  This string is normally `(gdb)'.  You can change
  117. the prompt string with the `set prompt' command.  For instance, when
  118. debugging GDB with GDB, it is useful to change the prompt in one of the
  119. GDBs so that you can always tell which one you are talking to.
  120. `set prompt NEWPROMPT'
  121.      Directs GDB to use NEWPROMPT as its prompt string henceforth.
  122. `show prompt'
  123.      Prints a line of the form: `Gdb's prompt is: YOUR-PROMPT'
  124. File: gdb.info,  Node: Editing,  Next: History,  Prev: Prompt,  Up: Controlling GDB
  125. Command Editing
  126. ===============
  127.    GDB reads its input commands via the "readline" interface.  This GNU
  128. library provides consistent behavior for programs which provide a
  129. command line interface to the user.  Advantages are `emacs'-style or
  130. `vi'-style inline editing of commands, `csh'-like history substitution,
  131. and a storage and recall of command history across debugging sessions.
  132.    You may control the behavior of command line editing in GDB with the
  133. command `set'.
  134. `set editing'
  135. `set editing on'
  136.      Enable command line editing (enabled by default).
  137. `set editing off'
  138.      Disable command line editing.
  139. `show editing'
  140.      Show whether command line editing is enabled.
  141. File: gdb.info,  Node: History,  Next: Screen Size,  Prev: Editing,  Up: Controlling GDB
  142. Command History
  143. ===============
  144. `set history filename FNAME'
  145.      Set the name of the GDB command history file to FNAME.  This is
  146.      the file from which GDB will read an initial command history list
  147.      or to which it will write this list when it exits.  This list is
  148.      accessed through history expansion or through the history command
  149.      editing characters listed below.  This file defaults to the value
  150.      of the environment variable `GDBHISTFILE', or to `./.gdb_history'
  151.      if this variable is not set.
  152. `set history save'
  153. `set history save on'
  154.      Record command history in a file, whose name may be specified with
  155.      the `set history filename' command.  By default, this option is
  156.      disabled.
  157. `set history save off'
  158.      Stop recording command history in a file.
  159. `set history size SIZE'
  160.      Set the number of commands which GDB will keep in its history list.
  161.      This defaults to the value of the environment variable `HISTSIZE',
  162.      or to 256 if this variable is not set.
  163.    History expansion assigns special meaning to the character `!'.
  164. Since `!' is also the logical not operator in C, history expansion is
  165. off by default. If you decide to enable history expansion with the `set
  166. history expansion on' command, you may sometimes need to follow `!'
  167. (when it is used as logical not, in an expression) with a space or a
  168. tab to prevent it from being expanded.  The readline history facilities
  169. will not attempt substitution on the strings `!=' and `!(', even when
  170. history expansion is enabled.
  171.    The commands to control history expansion are:
  172. `set history expansion on'
  173. `set history expansion'
  174.      Enable history expansion.  History expansion is off by default.
  175. `set history expansion off'
  176.      Disable history expansion.
  177.      The readline code comes with more complete documentation of
  178.      editing and history expansion features.  Users unfamiliar with
  179.      `emacs' or `vi' may wish to read it.
  180. `show history'
  181. `show history filename'
  182. `show history save'
  183. `show history size'
  184. `show history expansion'
  185.      These commands display the state of the GDB history parameters.
  186.      `show history' by itself displays all four states.
  187. `show commands'
  188.      Display the last ten commands in the command history.
  189. `show commands N'
  190.      Print ten commands centered on command number N.
  191. `show commands +'
  192.      Print ten commands just after the commands last printed.
  193. File: gdb.info,  Node: Screen Size,  Next: Numbers,  Prev: History,  Up: Controlling GDB
  194. Screen Size
  195. ===========
  196.    Certain commands to GDB may produce large amounts of information
  197. output to the screen.  To help you read all of it, GDB pauses and asks
  198. you for input at the end of each page of output.  Type RET when you
  199. want to continue the output.  GDB also uses the screen width setting to
  200. determine when to wrap lines of output.  Depending on what is being
  201. printed, it tries to break the line at a readable place, rather than
  202. simply letting it overflow onto the following line.
  203.    Normally GDB knows the size of the screen from the termcap data base
  204. together with the value of the `TERM' environment variable and the
  205. `stty rows' and `stty cols' settings. If this is not correct, you can
  206. override it with the `set height' and `set width' commands:
  207. `set height LPP'
  208. `show height'
  209. `set width CPL'
  210. `show width'
  211.      These `set' commands specify a screen height of LPP lines and a
  212.      screen width of CPL characters.  The associated `show' commands
  213.      display the current settings.
  214.      If you specify a height of zero lines, GDB will not pause during
  215.      output no matter how long the output is.  This is useful if output
  216.      is to a file or to an editor buffer.
  217. File: gdb.info,  Node: Numbers,  Next: Messages/Warnings,  Prev: Screen Size,  Up: Controlling GDB
  218. Numbers
  219. =======
  220.    You can always enter numbers in octal, decimal, or hexadecimal in
  221. GDB by the usual conventions: octal numbers begin with `0', decimal
  222. numbers end with `.', and hexadecimal numbers begin with `0x'. Numbers
  223. that begin with none of these are, by default, entered in base 10;
  224. likewise, the default display for numbers--when no particular format is
  225. specified--is base 10.  You can change the default base for both input
  226. and output with the `set radix' command.
  227. `set radix BASE'
  228.      Set the default base for numeric input and display.  Supported
  229.      choices for BASE are decimal 2, 8, 10, 16.  BASE must itself be
  230.      specified either unambiguously or using the current default radix;
  231.      for example, any of
  232.           set radix 1010
  233.           set radix 012
  234.           set radix 10.
  235.           set radix 0xa
  236.      will set the base to decimal.  On the other hand, `set radix 10'
  237.      will leave the radix unchanged no matter what it was.
  238. `show radix'
  239.      Display the current default base for numeric input and display.
  240. File: gdb.info,  Node: Messages/Warnings,  Prev: Numbers,  Up: Controlling GDB
  241. Optional Warnings and Messages
  242. ==============================
  243.    By default, GDB is silent about its inner workings.  If you are
  244. running on a slow machine, you may want to use the `set verbose'
  245. command. It will make GDB tell you when it does a lengthy internal
  246. operation, so you will not think it has crashed.
  247.    Currently, the messages controlled by `set verbose' are those which
  248. announce that the symbol table for a source file is being read; see
  249. `symbol-file' in *Note Commands to Specify Files: Files.
  250. `set verbose on'
  251.      Enables GDB's output of certain informational messages.
  252. `set verbose off'
  253.      Disables GDB's output of certain informational messages.
  254. `show verbose'
  255.      Displays whether `set verbose' is on or off.
  256.    By default, if GDB encounters bugs in the symbol table of an object
  257. file, it is silent; but if you are debugging a compiler, you may find
  258. this information useful (*note Errors Reading Symbol Files: Symbol
  259. Errors.).
  260. `set complaints LIMIT'
  261.      Permits GDB to output LIMIT complaints about each type of unusual
  262.      symbols before becoming silent about the problem.  Set LIMIT to
  263.      zero to suppress all complaints; set it to a large number to
  264.      prevent complaints from being suppressed.
  265. `show complaints'
  266.      Displays how many symbol complaints GDB is permitted to produce.
  267.    By default, GDB is cautious, and asks what sometimes seems to be a
  268. lot of stupid questions to confirm certain commands.  For example, if
  269. you try to run a program which is already running:
  270.      (gdb) run
  271.      The program being debugged has been started already.
  272.      Start it from the beginning? (y or n)
  273.    If you are willing to unflinchingly face the consequences of your own
  274. commands, you can disable this "feature":
  275. `set confirm off'
  276.      Disables confirmation requests.
  277. `set confirm on'
  278.      Enables confirmation requests (the default).
  279. `show confirm'
  280.      Displays state of confirmation requests.
  281.    Some systems allow individual object files that make up your program
  282. to be replaced without stopping and restarting your program. For
  283. example, in VxWorks you can simply recompile a defective object file
  284. and keep on running. If you are running on one of these systems, you
  285. can allow GDB to reload the symbols for automatically relinked modules:
  286. `set symbol-reloading on'
  287.      Replace symbol definitions for the corresponding source file when
  288.      an object file with a particular name is seen again.
  289. `set symbol-reloading off'
  290.      Do not replace symbol definitions when re-encountering object
  291.      files of the same name.  This is the default state; if you are not
  292.      running on a system that permits automatically relinking modules,
  293.      you should leave `symbol-reloading' off, since otherwise GDB may
  294.      discard symbols when linking large programs, that may contain
  295.      several modules (from different directories or libraries) with the
  296.      same name.
  297. `show symbol-reloading'
  298.      Show the current `on' or `off' setting.
  299. File: gdb.info,  Node: Sequences,  Next: Emacs,  Prev: Controlling GDB,  Up: Top
  300. Canned Sequences of Commands
  301. ****************************
  302.    Aside from breakpoint commands (*note Breakpoint Command Lists:
  303. Break Commands.), GDB provides two ways to store sequences of commands
  304. for execution as a unit: user-defined commands and command files.
  305. * Menu:
  306. * Define::                      User-Defined Commands
  307. * Hooks::            User-Defined Command Hooks
  308. * Command Files::               Command Files
  309. * Output::                      Commands for Controlled Output
  310. File: gdb.info,  Node: Define,  Next: Hooks,  Up: Sequences
  311. User-Defined Commands
  312. =====================
  313.    A "user-defined command" is a sequence of GDB commands to which you
  314. assign a new name as a command.  This is done with the `define' command.
  315. `define COMMANDNAME'
  316.      Define a command named COMMANDNAME.  If there is already a command
  317.      by that name, you are asked to confirm that you want to redefine
  318.      it.
  319.      The definition of the command is made up of other GDB command
  320.      lines, which are given following the `define' command.  The end of
  321.      these commands is marked by a line containing `end'.
  322. `document COMMANDNAME'
  323.      Give documentation to the user-defined command COMMANDNAME.  The
  324.      command COMMANDNAME must already be defined.  This command reads
  325.      lines of documentation just as `define' reads the lines of the
  326.      command definition, ending with `end'.  After the `document'
  327.      command is finished, `help' on command COMMANDNAME will print the
  328.      documentation you have specified.
  329.      You may use the `document' command again to change the
  330.      documentation of a command.  Redefining the command with `define'
  331.      does not change the documentation.
  332. `help user-defined'
  333.      List all user-defined commands, with the first line of the
  334.      documentation (if any) for each.
  335. `show user'
  336. `show user COMMANDNAME'
  337.      Display the GDB commands used to define COMMANDNAME (but not its
  338.      documentation).  If no COMMANDNAME is given, display the
  339.      definitions for all user-defined commands.
  340.    User-defined commands do not take arguments.  When they are
  341. executed, the commands of the definition are not printed.  An error in
  342. any command stops execution of the user-defined command.
  343.    Commands that would ask for confirmation if used interactively
  344. proceed without asking when used inside a user-defined command.  Many
  345. GDB commands that normally print messages to say what they are doing
  346. omit the messages when used in a user-defined command.
  347. File: gdb.info,  Node: Hooks,  Next: Command Files,  Prev: Define,  Up: Sequences
  348. User-Defined Command Hooks
  349. ==========================
  350.    You may define *hooks*, which are a special kind of user-defined
  351. command.  Whenever you run the command `foo', if the user-defined
  352. command `hook-foo' exists, it is executed (with no arguments) before
  353. that command.
  354.    In addition, a pseudo-command, `stop' exists.  Hooking this command
  355. will cause your hook to be executed every time execution stops in the
  356. inferior program, before breakpoint commands are run, displays are
  357. printed, or the stack frame is printed.
  358.    For example, to cause `SIGALRM' signals to be ignored while
  359. single-stepping, but cause them to be resumed during normal execution,
  360. you could do:
  361.      define hook-stop
  362.      handle SIGALRM nopass
  363.      end
  364.      
  365.      define hook-run
  366.      handle SIGALRM pass
  367.      end
  368.      
  369.      define hook-continue
  370.      handle SIGLARM pass
  371.      end
  372.    Any single-word command in GDB can be hooked.  Aliases for other
  373. commands cannot be hooked (you should hook the basic command name, e.g.
  374. `backtrace' rather than `bt').  If an error occurs during the execution
  375. of your hook, execution of GDB commands stops and you are returned to
  376. the GDB prompt (before the command that you actually typed had a chance
  377. to run).
  378.    If you try to define a hook which doesn't match any known command,
  379. you will get a warning from the `define' command.
  380. File: gdb.info,  Node: Command Files,  Next: Output,  Prev: Hooks,  Up: Sequences
  381. Command Files
  382. =============
  383.    A command file for GDB is a file of lines that are GDB commands. 
  384. Comments (lines starting with `#') may also be included.  An empty line
  385. in a command file does nothing; it does not mean to repeat the last
  386. command, as it would from the terminal.
  387.    When you start GDB, it automatically executes commands from its
  388. "init files".  These are files named `.gdbinit'.  GDB reads the init
  389. file (if any) in your home directory and then the init file (if any) in
  390. the current working directory.  (The init files are not executed if you
  391. use the `-nx' option; *note Choosing Modes: Mode Options..)  You can
  392. also request the execution of a command file with the `source' command:
  393. `source FILENAME'
  394.      Execute the command file FILENAME.
  395.    The lines in a command file are executed sequentially.  They are not
  396. printed as they are executed.  An error in any command terminates
  397. execution of the command file.
  398.    Commands that would ask for confirmation if used interactively
  399. proceed without asking when used in a command file.  Many GDB commands
  400. that normally print messages to say what they are doing omit the
  401. messages when called from command files.
  402. File: gdb.info,  Node: Output,  Prev: Command Files,  Up: Sequences
  403. Commands for Controlled Output
  404. ==============================
  405.    During the execution of a command file or a user-defined command,
  406. normal GDB output is suppressed; the only output that appears is what is
  407. explicitly printed by the commands in the definition.  This section
  408. describes three commands useful for generating exactly the output you
  409. want.
  410. `echo TEXT'
  411.      Print TEXT.  Nonprinting characters can be included in TEXT using
  412.      C escape sequences, such as `\n' to print a newline.  *No newline
  413.      will be printed unless you specify one.* In addition to the
  414.      standard C escape sequences, a backslash followed by a space
  415.      stands for a space.  This is useful for outputting a string with
  416.      spaces at the beginning or the end, since leading and trailing
  417.      spaces are otherwise trimmed from all arguments. To print ` and
  418.      foo = ', use the command `echo \ and foo = \ '.
  419.      A backslash at the end of TEXT can be used, as in C, to continue
  420.      the command onto subsequent lines.  For example,
  421.           echo This is some text\n\
  422.           which is continued\n\
  423.           onto several lines.\n
  424.      produces the same output as
  425.           echo This is some text\n
  426.           echo which is continued\n
  427.           echo onto several lines.\n
  428. `output EXPRESSION'
  429.      Print the value of EXPRESSION and nothing but that value: no
  430.      newlines, no `$NN = '.  The value is not entered in the value
  431.      history either.  *Note Expressions: Expressions, for more
  432.      information on expressions.
  433. `output/FMT EXPRESSION'
  434.      Print the value of EXPRESSION in format FMT.  You can use the same
  435.      formats as for `print'; *note Output formats::., for more
  436.      information.
  437. `printf STRING, EXPRESSIONS...'
  438.      Print the values of the EXPRESSIONS under the control of STRING. 
  439.      The EXPRESSIONS are separated by commas and may be either numbers
  440.      or pointers.  Their values are printed as specified by STRING,
  441.      exactly as if your program were to execute
  442.           printf (STRING, EXPRESSIONS...);
  443.      For example, you can print two values in hex like this:
  444.           printf "foo, bar-foo = 0x%x, 0x%x\n", foo, bar-foo
  445.      The only backslash-escape sequences that you can use in the format
  446.      string are the simple ones that consist of backslash followed by a
  447.      letter.
  448. File: gdb.info,  Node: Emacs,  Next: GDB Bugs,  Prev: Sequences,  Up: Top
  449. Using GDB under GNU Emacs
  450. *************************
  451.    A special interface allows you to use GNU Emacs to view (and edit)
  452. the source files for the program you are debugging with GDB.
  453.    To use this interface, use the command `M-x gdb' in Emacs.  Give the
  454. executable file you want to debug as an argument.  This command starts
  455. GDB as a subprocess of Emacs, with input and output through a newly
  456. created Emacs buffer.
  457.    Using GDB under Emacs is just like using GDB normally except for two
  458. things:
  459.    * All "terminal" input and output goes through the Emacs buffer.
  460.    This applies both to GDB commands and their output, and to the input
  461. and output done by the program you are debugging.
  462.    This is useful because it means that you can copy the text of
  463. previous commands and input them again; you can even use parts of the
  464. output in this way.
  465.    All the facilities of Emacs' Shell mode are available for interacting
  466. with your program.  In particular, you can send signals the usual
  467. way--for example, `C-c C-c' for an interrupt, `C-c C-z' for a stop.
  468.    * GDB displays source code through Emacs.
  469.    Each time GDB displays a stack frame, Emacs automatically finds the
  470. source file for that frame and puts an arrow (`=>') at the left margin
  471. of the current line.  Emacs uses a separate buffer for source display,
  472. and splits the window to show both your GDB session and the source.
  473.    Explicit GDB `list' or search commands still produce output as
  474. usual, but you probably will have no reason to use them.
  475.      *Warning:* If the directory where your program resides is not your
  476.      current directory, it can be easy to confuse Emacs about the
  477.      location of the source files, in which case the auxiliary display
  478.      buffer will not appear to show your source.  GDB can find programs
  479.      by searching your environment's `PATH' variable, so the GDB input
  480.      and output session will proceed normally; but Emacs does not get
  481.      enough information back from GDB to locate the source files in
  482.      this situation.  To avoid this problem, either start GDB mode from
  483.      the directory where your program resides, or specify a full path
  484.      name when prompted for the `M-x gdb' argument.
  485.      A similar confusion can result if you use the GDB `file' command to
  486.      switch to debugging a program in some other location, from an
  487.      existing GDB buffer in Emacs.
  488.    By default, `M-x gdb' calls the program called `gdb'.  If you need
  489. to call GDB by a different name (for example, if you keep several
  490. configurations around, with different names) you can set the Emacs
  491. variable `gdb-command-name'; for example,
  492.      (setq gdb-command-name "mygdb")
  493. (preceded by `ESC ESC', or typed in the `*scratch*' buffer, or in your
  494. `.emacs' file) will make Emacs call the program named "`mygdb'" instead.
  495.    In the GDB I/O buffer, you can use these special Emacs commands in
  496. addition to the standard Shell mode commands:
  497. `C-h m'
  498.      Describe the features of Emacs' GDB Mode.
  499. `M-s'
  500.      Execute to another source line, like the GDB `step' command; also
  501.      update the display window to show the current file and location.
  502. `M-n'
  503.      Execute to next source line in this function, skipping all function
  504.      calls, like the GDB `next' command.  Then update the display window
  505.      to show the current file and location.
  506. `M-i'
  507.      Execute one instruction, like the GDB `stepi' command; update
  508.      display window accordingly.
  509. `M-x gdb-nexti'
  510.      Execute to next instruction, using the GDB `nexti' command; update
  511.      display window accordingly.
  512. `C-c C-f'
  513.      Execute until exit from the selected stack frame, like the GDB
  514.      `finish' command.
  515. `M-c'
  516.      Continue execution of your program, like the GDB `continue'
  517.      command.
  518.      *Warning:* In Emacs v19, this command is `C-c C-p'.
  519. `M-u'
  520.      Go up the number of frames indicated by the numeric argument
  521.      (*note Numeric Arguments: (emacs)Arguments.), like the GDB `up'
  522.      command.
  523.      *Warning:* In Emacs v19, this command is `C-c C-u'.
  524. `M-d'
  525.      Go down the number of frames indicated by the numeric argument,
  526.      like the GDB `down' command.
  527.      *Warning:* In Emacs v19, this command is `C-c C-d'.
  528. `C-x &'
  529.      Read the number where the cursor is positioned, and insert it at
  530.      the end of the GDB I/O buffer.  For example, if you wish to
  531.      disassemble code around an address that was displayed earlier,
  532.      type `disassemble'; then move the cursor to the address display,
  533.      and pick up the argument for `disassemble' by typing `C-x &'.
  534.      You can customize this further on the fly by defining elements of
  535.      the list `gdb-print-command'; once it is defined, you can format or
  536.      otherwise process numbers picked up by `C-x &' before they are
  537.      inserted.  A numeric argument to `C-x &' will both indicate that
  538.      you wish special formatting, and act as an index to pick an
  539.      element of the list.  If the list element is a string, the number
  540.      to be inserted is formatted using the Emacs function `format';
  541.      otherwise the number is passed as an argument to the corresponding
  542.      list element.
  543.    In any source file, the Emacs command `C-x SPC' (`gdb-break') tells
  544. GDB to set a breakpoint on the source line point is on.
  545.    If you accidentally delete the source-display buffer, an easy way to
  546. get it back is to type the command `f' in the GDB buffer, to request a
  547. frame display; when you run under Emacs, this will recreate the source
  548. buffer if necessary to show you the context of the current frame.
  549.    The source files displayed in Emacs are in ordinary Emacs buffers
  550. which are visiting the source files in the usual way.  You can edit the
  551. files with these buffers if you wish; but keep in mind that GDB
  552. communicates with Emacs in terms of line numbers.  If you add or delete
  553. lines from the text, the line numbers that GDB knows will cease to
  554. correspond properly to the code.
  555. File: gdb.info,  Node: GDB Bugs,  Next: Renamed Commands,  Prev: Emacs,  Up: Top
  556. Reporting Bugs in GDB
  557. *********************
  558.    Your bug reports play an essential role in making GDB reliable.
  559.    Reporting a bug may help you by bringing a solution to your problem,
  560. or it may not.  But in any case the principal function of a bug report
  561. is to help the entire community by making the next version of GDB work
  562. better.  Bug reports are your contribution to the maintenance of GDB.
  563.    In order for a bug report to serve its purpose, you must include the
  564. information that enables us to fix the bug.
  565. * Menu:
  566. * Bug Criteria::                Have You Found a Bug?
  567. * Bug Reporting::               How to Report Bugs
  568. File: gdb.info,  Node: Bug Criteria,  Next: Bug Reporting,  Up: GDB Bugs
  569. Have You Found a Bug?
  570. =====================
  571.    If you are not sure whether you have found a bug, here are some
  572. guidelines:
  573.    * If the debugger gets a fatal signal, for any input whatever, that
  574.      is a GDB bug.  Reliable debuggers never crash.
  575.    * If GDB produces an error message for valid input, that is a bug.
  576.    * If GDB does not produce an error message for invalid input, that
  577.      is a bug.  However, you should note that your idea of "invalid
  578.      input" might be our idea of "an extension" or "support for
  579.      traditional practice".
  580.    * If you are an experienced user of debugging tools, your suggestions
  581.      for improvement of GDB are welcome in any case.
  582. File: gdb.info,  Node: Bug Reporting,  Prev: Bug Criteria,  Up: GDB Bugs
  583. How to Report Bugs
  584. ==================
  585.    A number of companies and individuals offer support for GNU products.
  586. If you obtained GDB from a support organization, we recommend you
  587. contact that organization first.
  588.    Contact information for many support companies and individuals is
  589. available in the file `etc/SERVICE' in the GNU Emacs distribution.
  590.    In any event, we also recommend that you send bug reports for GDB to
  591. one of these addresses:
  592.      bug-gdb@prep.ai.mit.edu
  593.      {ucbvax|mit-eddie|uunet}!prep.ai.mit.edu!bug-gdb
  594.    *Do not send bug reports to `info-gdb', or to `help-gdb', or to any
  595. newsgroups.* Most users of GDB do not want to receive bug reports. 
  596. Those that do, have arranged to receive `bug-gdb'.
  597.    The mailing list `bug-gdb' has a newsgroup `gnu.gdb.bug' which
  598. serves as a repeater.  The mailing list and the newsgroup carry exactly
  599. the same messages.  Often people think of posting bug reports to the
  600. newsgroup instead of mailing them.  This appears to work, but it has one
  601. problem which can be crucial: a newsgroup posting often lacks a mail
  602. path back to the sender.  Thus, if we need to ask for more information,
  603. we may be unable to reach you.  For this reason, it is better to send
  604. bug reports to the mailing list.
  605.    As a last resort, send bug reports on paper to:
  606.      GNU Debugger Bugs
  607.      Free Software Foundation
  608.      545 Tech Square
  609.      Cambridge, MA 02139
  610.    The fundamental principle of reporting bugs usefully is this:
  611. *report all the facts*.  If you are not sure whether to state a fact or
  612. leave it out, state it!
  613.    Often people omit facts because they think they know what causes the
  614. problem and assume that some details do not matter.  Thus, you might
  615. assume that the name of the variable you use in an example does not
  616. matter. Well, probably it does not, but one cannot be sure.  Perhaps
  617. the bug is a stray memory reference which happens to fetch from the
  618. location where that name is stored in memory; perhaps, if the name were
  619. different, the contents of that location would fool the debugger into
  620. doing the right thing despite the bug.  Play it safe and give a
  621. specific, complete example.  That is the easiest thing for you to do,
  622. and the most helpful.
  623.    Keep in mind that the purpose of a bug report is to enable us to fix
  624. the bug if it is new to us.  It is not as important as what happens if
  625. the bug is already known.  Therefore, always write your bug reports on
  626. the assumption that the bug has not been reported previously.
  627.    Sometimes people give a few sketchy facts and ask, "Does this ring a
  628. bell?"  Those bug reports are useless, and we urge everyone to *refuse
  629. to respond to them* except to chide the sender to report bugs properly.
  630.    To enable us to fix the bug, you should include all these things:
  631.    * The version of GDB.  GDB announces it if you start with no
  632.      arguments; you can also print it at any time using `show version'.
  633.      Without this, we will not know whether there is any point in
  634.      looking for the bug in the current version of GDB.
  635.    * The type of machine you are using, and the operating system name
  636.      and version number.
  637.    * What compiler (and its version) was used to compile GDB--e.g.
  638.      "gcc-2.0".
  639.    * What compiler (and its version) was used to compile the program you
  640.      are debugging--e.g.  "gcc-2.0".
  641.    * The command arguments you gave the compiler to compile your
  642.      example and observe the bug.  For example, did you use `-O'?  To
  643.      guarantee you will not omit something important, list them all.  A
  644.      copy of the Makefile (or the output from make) is sufficient.
  645.      If we were to try to guess the arguments, we would probably guess
  646.      wrong and then we might not encounter the bug.
  647.    * A complete input script, and all necessary source files, that will
  648.      reproduce the bug.
  649.    * A description of what behavior you observe that you believe is
  650.      incorrect.  For example, "It gets a fatal signal."
  651.      Of course, if the bug is that GDB gets a fatal signal, then we will
  652.      certainly notice it.  But if the bug is incorrect output, we might
  653.      not notice unless it is glaringly wrong.  We are human, after all.
  654.       You might as well not give us a chance to make a mistake.
  655.      Even if the problem you experience is a fatal signal, you should
  656.      still say so explicitly.  Suppose something strange is going on,
  657.      such as, your copy of GDB is out of synch, or you have encountered
  658.      a bug in the C library on your system.  (This has happened!)  Your
  659.      copy might crash and ours would not.  If you told us to expect a
  660.      crash, then when ours fails to crash, we would know that the bug
  661.      was not happening for us.  If you had not told us to expect a
  662.      crash, then we would not be able to draw any conclusion from our
  663.      observations.
  664.    * If you wish to suggest changes to the GDB source, send us context
  665.      diffs.  If you even discuss something in the GDB source, refer to
  666.      it by context, not by line number.
  667.      The line numbers in our development sources will not match those
  668.      in your sources.  Your line numbers would convey no useful
  669.      information to us.
  670.    Here are some things that are not necessary:
  671.    * A description of the envelope of the bug.
  672.      Often people who encounter a bug spend a lot of time investigating
  673.      which changes to the input file will make the bug go away and which
  674.      changes will not affect it.
  675.      This is often time consuming and not very useful, because the way
  676.      we will find the bug is by running a single example under the
  677.      debugger with breakpoints, not by pure deduction from a series of
  678.      examples. We recommend that you save your time for something else.
  679.      Of course, if you can find a simpler example to report *instead*
  680.      of the original one, that is a convenience for us.  Errors in the
  681.      output will be easier to spot, running under the debugger will take
  682.      less time, etc.
  683.      However, simplification is not vital; if you do not want to do
  684.      this, report the bug anyway and send us the entire test case you
  685.      used.
  686.    * A patch for the bug.
  687.      A patch for the bug does help us if it is a good one.  But do not
  688.      omit the necessary information, such as the test case, on the
  689.      assumption that a patch is all we need.  We might see problems
  690.      with your patch and decide to fix the problem another way, or we
  691.      might not understand it at all.
  692.      Sometimes with a program as complicated as GDB it is very hard to
  693.      construct an example that will make the program follow a certain
  694.      path through the code.  If you do not send us the example, we will
  695.      not be able to construct one, so we will not be able to verify
  696.      that the bug is fixed.
  697.      And if we cannot understand what bug you are trying to fix, or why
  698.      your patch should be an improvement, we will not install it.  A
  699.      test case will help us to understand.
  700.    * A guess about what the bug is or what it depends on.
  701.      Such guesses are usually wrong.  Even we cannot guess right about
  702.      such things without first using the debugger to find the facts.
  703. File: gdb.info,  Node: Renamed Commands,  Next: Formatting Documentation,  Prev: GDB Bugs,  Up: Top
  704. Renamed Commands
  705. ****************
  706.    The following commands were renamed in GDB 4, in order to make the
  707. command set as a whole more consistent and easier to use and remember:
  708.      OLD COMMAND               NEW COMMAND
  709.      ---------------           -------------------------------
  710.      add-syms                  add-symbol-file
  711.      delete environment        unset environment
  712.      info convenience          show convenience
  713.      info copying              show copying
  714.      info directories          show directories
  715.      info editing              show commands
  716.      info history              show values
  717.      info targets              help target
  718.      info values               show values
  719.      info version              show version
  720.      info warranty             show warranty
  721.      set/show addressprint     set/show print address
  722.      set/show array-max        set/show print elements
  723.      set/show arrayprint       set/show print array
  724.      set/show asm-demangle     set/show print asm-demangle
  725.      set/show caution          set/show confirm
  726.      set/show demangle         set/show print demangle
  727.      set/show history write    set/show history save
  728.      set/show prettyprint      set/show print pretty
  729.      set/show screen-height    set/show height
  730.      set/show screen-width     set/show width
  731.      set/show sevenbit-strings set/show print sevenbit-strings
  732.      set/show unionprint       set/show print union
  733.      set/show vtblprint        set/show print vtbl
  734.      
  735.      unset                     [No longer an alias for delete]
  736. File: gdb.info,  Node: Formatting Documentation,  Next: Installing GDB,  Prev: Renamed Commands,  Up: Top
  737. Formatting the Documentation
  738. ****************************
  739.    The GDB 4 release includes an already-formatted reference card, ready
  740. for printing with PostScript or GhostScript, in the `gdb' subdirectory
  741. of the main source directory--in `gdb-4.7/gdb/refcard.ps' of the
  742. version 4.7 release. If you can use PostScript or GhostScript with your
  743. printer, you can print the reference card immediately with `refcard.ps'.
  744.    The release also includes the source for the reference card.  You
  745. can format it, using TeX, by typing:
  746.      make refcard.dvi
  747.    The GDB reference card is designed to print in landscape mode on US
  748. "letter" size paper; that is, on a sheet 11 inches wide by 8.5 inches
  749. high.  You will need to specify this form of printing as an option to
  750. your DVI output program.
  751.    All the documentation for GDB comes as part of the machine-readable
  752. distribution.  The documentation is written in Texinfo format, which is
  753. a documentation system that uses a single source file to produce both
  754. on-line information and a printed manual.  You can use one of the Info
  755. formatting commands to create the on-line version of the documentation
  756. and TeX (or `texi2roff') to typeset the printed version.
  757.    GDB includes an already formatted copy of the on-line Info version of
  758. this manual in the `gdb' subdirectory.  The main Info file is
  759. `gdb-VERSION-NUMBER/gdb/gdb.info', and it refers to subordinate files
  760. matching `gdb.info*' in the same directory.  If necessary, you can
  761. print out these files, or read them with any editor; but they are
  762. easier to read using the `info' subsystem in GNU Emacs or the
  763. standalone `info' program, available as part of the GNU Texinfo
  764. distribution.
  765.    If you want to format these Info files yourself, you need one of the
  766. Info formatting programs, such as `texinfo-format-buffer' or `makeinfo'.
  767.    If you have `makeinfo' installed, and are in the top level GDB
  768. source directory (`gdb-4.7', in the case of version 4.7), you can make
  769. the Info file by typing:
  770.      cd gdb
  771.      make gdb.info
  772.    If you want to typeset and print copies of this manual, you need
  773. TeX, a printing program such as `lpr', and `texinfo.tex', the Texinfo
  774. definitions file.
  775.    TeX is typesetting program; it does not print files directly, but
  776. produces output files called DVI files.  To print a typeset document,
  777. you need a program to print DVI files.  If your system has TeX
  778. installed, chances are it has such a program.  The precise command to
  779. use depends on your system; `lpr -d' is common; another is `dvips'. 
  780. The DVI print command may require a file name without any extension or
  781. a `.dvi' extension.
  782.    TeX also requires a macro definitions file called `texinfo.tex'. 
  783. This file tells TeX how to typeset a document written in Texinfo
  784. format.  On its own, TeX cannot read, much less typeset a Texinfo file.
  785.  `texinfo.tex' is distributed with GDB and is located in the
  786. `gdb-VERSION-NUMBER/texinfo' directory.
  787.    If you have TeX and a DVI printer program installed, you can typeset
  788. and print this manual.  First switch to the the `gdb' subdirectory of
  789. the main source directory (for example, to `gdb-4.7/gdb') and then type:
  790.      make gdb.dvi
  791. File: gdb.info,  Node: Installing GDB,  Next: Copying,  Prev: Formatting Documentation,  Up: Top
  792. Installing GDB
  793. **************
  794.    GDB comes with a `configure' script that automates the process of
  795. preparing GDB for installation; you can then use `make' to build the
  796. program.
  797.    The GDB distribution includes all the source code you need for GDB in
  798. a single directory, whose name is usually composed by appending the
  799. version number to `gdb'.
  800.    For example, the GDB version 4.7 distribution is in the `gdb-4.7'
  801. directory.  That directory contains:
  802. `gdb-4.7/configure (and supporting files)'
  803.      script for configuring GDB and all its supporting libraries.
  804. `gdb-4.7/gdb'
  805.      the source specific to GDB itself
  806. `gdb-4.7/bfd'
  807.      source for the Binary File Descriptor library
  808. `gdb-4.7/include'
  809.      GNU include files
  810. `gdb-4.7/libiberty'
  811.      source for the `-liberty' free software library
  812. `gdb-4.7/opcodes'
  813.      source for the library of opcode tables and disassemblers
  814. `gdb-4.7/readline'
  815.      source for the GNU command-line interface
  816. `gdb-4.7/glob'
  817.      source for the GNU filename pattern-matching subroutine
  818. `gdb-4.7/mmalloc'
  819.      source for the GNU memory-mapped malloc package
  820.    The simplest way to configure and build GDB is to run `configure'
  821. from the `gdb-VERSION-NUMBER' source directory, which in this example
  822. is the `gdb-4.7' directory.
  823.    First switch to the `gdb-VERSION-NUMBER' source directory if you are
  824. not already in it; then run `configure'.  Pass the identifier for the
  825. platform on which GDB will run as an argument.
  826.    For example:
  827.      cd gdb-4.7
  828.      ./configure HOST
  829.      make
  830. where HOST is an identifier such as `sun4' or `decstation', that
  831. identifies the platform where GDB will run.
  832.    Running `configure HOST' followed by `make' builds the `bfd',
  833. `readline', `mmalloc', and `libiberty' libraries, then `gdb' itself. 
  834. The configured source files, and the binaries, are left in the
  835. corresponding source directories.
  836.    `configure' is a Bourne-shell (`/bin/sh') script; if your system
  837. does not recognize this automatically when you run a different shell,
  838. you may need to run `sh' on it explicitly:
  839.      sh configure HOST
  840.    If you run `configure' from a directory that contains source
  841. directories for multiple libraries or programs, such as the `gdb-4.7'
  842. source directory for version 4.7, `configure' creates configuration
  843. files for every directory level underneath (unless you tell it not to,
  844. with the `--norecursion' option).
  845.    You can run the `configure' script from any of the subordinate
  846. directories in the GDB distribution, if you only want to configure that
  847. subdirectory; but be sure to specify a path to it.
  848.    For example, with version 4.7, type the following to configure only
  849. the `bfd' subdirectory:
  850.      cd gdb-4.7/bfd
  851.      ../configure HOST
  852.    You can install `gdb' anywhere; it has no hardwired paths. However,
  853. you should make sure that the shell on your path (named by the `SHELL'
  854. environment variable) is publicly readable.  Remember that GDB uses the
  855. shell to start your program--some systems refuse to let GDB debug child
  856. processes whose programs are not readable.
  857. * Menu:
  858. * Separate Objdir::             Compiling GDB in another directory
  859. * Config Names::                Specifying names for hosts and targets
  860. * configure Options::           Summary of options for configure
  861. File: gdb.info,  Node: Separate Objdir,  Next: Config Names,  Up: Installing GDB
  862. Compiling GDB in Another Directory
  863. ==================================
  864.    If you want to run GDB versions for several host or target machines,
  865. you'll need a different `gdb' compiled for each combination of host and
  866. target.  `configure' is designed to make this easy by allowing you to
  867. generate each configuration in a separate subdirectory, rather than in
  868. the source directory.  If your `make' program handles the `VPATH'
  869. feature (GNU `make' does), running `make' in each of these directories
  870. then builds the `gdb' program specified there.
  871.    To build `gdb' in a separate directory, run `configure' with the
  872. `--srcdir' option to specify where to find the source. (You'll also
  873. need to specify a path to find `configure' itself from your working
  874. directory.  If the path to `configure' would be the same as the
  875. argument to `--srcdir', you can leave out the `--srcdir' option; it
  876. will be assumed.)
  877.    For example, with version 4.7, you can build GDB in a separate
  878. directory for a Sun 4 like this:
  879.      cd gdb-4.7
  880.      mkdir ../gdb-sun4
  881.      cd ../gdb-sun4
  882.      ../gdb-4.7/configure sun4
  883.      make
  884.    When `configure' builds a configuration using a remote source
  885. directory, it creates a tree for the binaries with the same structure
  886. (and using the same names) as the tree under the source directory.  In
  887. the example, you'd find the Sun 4 library `libiberty.a' in the
  888. directory `gdb-sun4/libiberty', and GDB itself in `gdb-sun4/gdb'.
  889.    One popular reason to build several GDB configurations in separate
  890. directories is to configure GDB for cross-compiling (where GDB runs on
  891. one machine--the host--while debugging programs that run on another
  892. machine--the target).  You specify a cross-debugging target by giving
  893. the `--target=TARGET' option to `configure'.
  894.    When you run `make' to build a program or library, you must run it
  895. in a configured directory--whatever directory you were in when you
  896. called `configure' (or one of its subdirectories).
  897.    The `Makefile' generated by `configure' for each source directory
  898. also runs recursively.  If you type `make' in a source directory such
  899. as `gdb-4.7' (or in a separate configured directory configured with
  900. `--srcdir=PATH/gdb-4.7'), you will build all the required libraries,
  901. then build GDB.
  902.    When you have multiple hosts or targets configured in separate
  903. directories, you can run `make' on them in parallel (for example, if
  904. they are NFS-mounted on each of the hosts); they will not interfere
  905. with each other.
  906. File: gdb.info,  Node: Config Names,  Next: configure Options,  Prev: Separate Objdir,  Up: Installing GDB
  907. Specifying Names for Hosts and Targets
  908. ======================================
  909.    The specifications used for hosts and targets in the `configure'
  910. script are based on a three-part naming scheme, but some short
  911. predefined aliases are also supported.  The full naming scheme encodes
  912. three pieces of information in the following pattern:
  913.      ARCHITECTURE-VENDOR-OS
  914.    For example, you can use the alias `sun4' as a HOST argument or in a
  915. `--target=TARGET' option, but the equivalent full name is
  916. `sparc-sun-sunos4'.
  917.    The `configure' script accompanying GDB does not provide any query
  918. facility to list all supported host and target names or aliases. 
  919. `configure' calls the Bourne shell script `config.sub' to map
  920. abbreviations to full names; you can read the script, if you wish, or
  921. you can use it to test your guesses on abbreviations--for example:
  922.      % sh config.sub sun4
  923.      sparc-sun-sunos411
  924.      % sh config.sub sun3
  925.      m68k-sun-sunos411
  926.      % sh config.sub decstation
  927.      mips-dec-ultrix42
  928.      % sh config.sub hp300bsd
  929.      m68k-hp-bsd
  930.      % sh config.sub i386v
  931.      i386-unknown-sysv
  932.      % sh config.sub i786v
  933.      Invalid configuration `i786v': machine `i786v' not recognized
  934. `config.sub' is also distributed in the GDB source directory
  935. (`gdb-4.7', for version 4.7).
  936.