home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Atari / Gnu / gdb36p4b.zoo / gdb.info (.txt) < prev    next >
GNU Info File  |  1993-10-05  |  145KB  |  2,766 lines

  1. This is Info file gdb.info, produced by Makeinfo-1.55 from the input
  2. file gdb.texinfo.
  3.    This file documents the GNU debugger GDB.
  4.    Copyright (C) 1988, 1989 Free Software Foundation, Inc.
  5.    Permission is granted to make and distribute verbatim copies of this
  6. manual provided the copyright notice and this permission notice are
  7. preserved on all copies.
  8.    Permission is granted to copy and distribute modified versions of
  9. this manual under the conditions for verbatim copying, provided also
  10. that the section entitled "GNU General Public License" is included
  11. exactly as in the original, and provided that the entire resulting
  12. derived work is distributed under the terms of a permission notice
  13. identical to this one.
  14.    Permission is granted to copy and distribute translations of this
  15. manual into another language, under the above conditions for modified
  16. versions, except that the section entitled "GNU General Public License"
  17. may be included in a translation approved by the author instead of in
  18. the original English.
  19. File: gdb.info,  Node: Top,  Next: Top,  Prev: Top,  Up: (DIR)
  20. Summary of GDB
  21. **************
  22.    The purpose of a debugger such as GDB is to allow you to execute
  23. another program while examining what is going on inside it.  We call
  24. the other program "your program" or "the program being debugged".
  25.    GDB can do four kinds of things (plus other things in support of
  26. these):
  27.   1. Start the program, specifying anything that might affect its
  28.      behavior.
  29.   2. Make the program stop on specified conditions.
  30.   3. Examine what has happened, when the program has stopped, so that
  31.      you can see bugs happen.
  32.   4. Change things in the program, so you can correct the effects of
  33.      one bug and go on to learn about another without having to
  34.      recompile first.
  35.    GDB can be used to debug programs written in C and C++.  Pascal
  36. support is being implemented, and Fortran support will be added when a
  37. GNU Fortran compiler is written.
  38. * Menu:
  39. * License::    The GNU General Public License gives you permission
  40.            to redistribute GDB on certain terms; and also
  41.            explains that there is no warranty.
  42. * User Interface::      GDB command syntax and input and output conventions.
  43. * Files::      Specifying files for GDB to operate on.
  44. * Options::    GDB arguments and options.
  45. * Compilation::Compiling your program so you can debug it.
  46. * Running::    Running your program under GDB.
  47. * Stopping::   Making your program stop.  Why it may stop.  What to do then.
  48. * Stack::      Examining your program's stack.
  49. * Source::     Examining your program's source files.
  50. * Data::       Examining data in your program.
  51. * Symbols::    Examining the debugger's symbol table.
  52. * Altering::   Altering things in your program.
  53. * Sequences::  Canned command sequences for repeated use.
  54. * Emacs::      Using GDB through GNU Emacs.
  55. * Remote::     Remote kernel debugging across a serial line.
  56. * Commands::   Index of GDB commands.
  57. * Concepts::   Index of GDB concepts.
  58. File: gdb.info,  Node: License,  Next: User Interface,  Prev: Top,  Up: Top
  59. GNU GENERAL PUBLIC LICENSE
  60. **************************
  61.                        Version 1, February 1989
  62.      Copyright (C) 1989 Free Software Foundation, Inc.
  63.      675 Mass Ave, Cambridge, MA 02139, USA
  64.      
  65.      Everyone is permitted to copy and distribute verbatim copies
  66.      of this license document, but changing it is not allowed.
  67. Preamble
  68. ========
  69.    The license agreements of most software companies try to keep users
  70. at the mercy of those companies.  By contrast, our General Public
  71. License is intended to guarantee your freedom to share and change free
  72. software--to make sure the software is free for all its users.  The
  73. General Public License applies to the Free Software Foundation's
  74. software and to any other program whose authors commit to using it.
  75. You can use it for your programs, too.
  76.    When we speak of free software, we are referring to freedom, not
  77. price.  Specifically, the General Public License is designed to make
  78. sure that you have the freedom to give away or sell copies of free
  79. software, that you receive source code or can get it if you want it,
  80. that you can change the software or use pieces of it in new free
  81. programs; and that you know you can do these things.
  82.    To protect your rights, we need to make restrictions that forbid
  83. anyone to deny you these rights or to ask you to surrender the rights.
  84. These restrictions translate to certain responsibilities for you if you
  85. distribute copies of the software, or if you modify it.
  86.    For example, if you distribute copies of a such a program, whether
  87. gratis or for a fee, you must give the recipients all the rights that
  88. you have.  You must make sure that they, too, receive or can get the
  89. source code.  And you must tell them their rights.
  90.    We protect your rights with two steps: (1) copyright the software,
  91. and (2) offer you this license which gives you legal permission to copy,
  92. distribute and/or modify the software.
  93.    Also, for each author's protection and ours, we want to make certain
  94. that everyone understands that there is no warranty for this free
  95. software.  If the software is modified by someone else and passed on, we
  96. want its recipients to know that what they have is not the original, so
  97. that any problems introduced by others will not reflect on the original
  98. authors' reputations.
  99.    The precise terms and conditions for copying, distribution and
  100. modification follow.
  101.                          TERMS AND CONDITIONS
  102.   1. This License Agreement applies to any program or other work which
  103.      contains a notice placed by the copyright holder saying it may be
  104.      distributed under the terms of this General Public License.  The
  105.      "Program", below, refers to any such program or work, and a "work
  106.      based on the Program" means either the Program or any work
  107.      containing the Program or a portion of it, either verbatim or with
  108.      modifications.  Each licensee is addressed as "you".
  109.   2. You may copy and distribute verbatim copies of the Program's source
  110.      code as you receive it, in any medium, provided that you
  111.      conspicuously and appropriately publish on each copy an
  112.      appropriate copyright notice and disclaimer of warranty; keep
  113.      intact all the notices that refer to this General Public License
  114.      and to the absence of any warranty; and give any other recipients
  115.      of the Program a copy of this General Public License along with
  116.      the Program.  You may charge a fee for the physical act of
  117.      transferring a copy.
  118.   3. You may modify your copy or copies of the Program or any portion of
  119.      it, and copy and distribute such modifications under the terms of
  120.      Paragraph 1 above, provided that you also do the following:
  121.         * cause the modified files to carry prominent notices stating
  122.           that you changed the files and the date of any change; and
  123.         * cause the whole of any work that you distribute or publish,
  124.           that in whole or in part contains the Program or any part
  125.           thereof, either with or without modifications, to be licensed
  126.           at no charge to all third parties under the terms of this
  127.           General Public License (except that you may choose to grant
  128.           warranty protection to some or all third parties, at your
  129.           option).
  130.         * If the modified program normally reads commands interactively
  131.           when run, you must cause it, when started running for such
  132.           interactive use in the simplest and most usual way, to print
  133.           or display an announcement including an appropriate copyright
  134.           notice and a notice that there is no warranty (or else,
  135.           saying that you provide a warranty) and that users may
  136.           redistribute the program under these conditions, and telling
  137.           the user how to view a copy of this General Public License.
  138.         * You may charge a fee for the physical act of transferring a
  139.           copy, and you may at your option offer warranty protection in
  140.           exchange for a fee.
  141.      Mere aggregation of another independent work with the Program (or
  142.      its derivative) on a volume of a storage or distribution medium
  143.      does not bring the other work under the scope of these terms.
  144.   4. You may copy and distribute the Program (or a portion or
  145.      derivative of it, under Paragraph 2) in object code or executable
  146.      form under the terms of Paragraphs 1 and 2 above provided that you
  147.      also do one of the following:
  148.         * accompany it with the complete corresponding machine-readable
  149.           source code, which must be distributed under the terms of
  150.           Paragraphs 1 and 2 above; or,
  151.         * accompany it with a written offer, valid for at least three
  152.           years, to give any third party free (except for a nominal
  153.           charge for the cost of distribution) a complete
  154.           machine-readable copy of the corresponding source code, to be
  155.           distributed under the terms of Paragraphs 1 and 2 above; or,
  156.         * accompany it with the information you received as to where the
  157.           corresponding source code may be obtained.  (This alternative
  158.           is allowed only for noncommercial distribution and only if you
  159.           received the program in object code or executable form alone.)
  160.      Source code for a work means the preferred form of the work for
  161.      making modifications to it.  For an executable file, complete
  162.      source code means all the source code for all modules it contains;
  163.      but, as a special exception, it need not include source code for
  164.      modules which are standard libraries that accompany the operating
  165.      system on which the executable file runs, or for standard header
  166.      files or definitions files that accompany that operating system.
  167.   5. You may not copy, modify, sublicense, distribute or transfer the
  168.      Program except as expressly provided under this General Public
  169.      License.  Any attempt otherwise to copy, modify, sublicense,
  170.      distribute or transfer the Program is void, and will automatically
  171.      terminate your rights to use the Program under this License.
  172.      However, parties who have received copies, or rights to use
  173.      copies, from you under this General Public License will not have
  174.      their licenses terminated so long as such parties remain in full
  175.      compliance.
  176.   6. By copying, distributing or modifying the Program (or any work
  177.      based on the Program) you indicate your acceptance of this license
  178.      to do so, and all its terms and conditions.
  179.   7. Each time you redistribute the Program (or any work based on the
  180.      Program), the recipient automatically receives a license from the
  181.      original licensor to copy, distribute or modify the Program
  182.      subject to these terms and conditions.  You may not impose any
  183.      further restrictions on the recipients' exercise of the rights
  184.      granted herein.
  185.   8. The Free Software Foundation may publish revised and/or new
  186.      versions of the General Public License from time to time.  Such
  187.      new versions will be similar in spirit to the present version, but
  188.      may differ in detail to address new problems or concerns.
  189.      Each version is given a distinguishing version number.  If the
  190.      Program specifies a version number of the license which applies to
  191.      it and "any later version", you have the option of following the
  192.      terms and conditions either of that version or of any later
  193.      version published by the Free Software Foundation.  If the Program
  194.      does not specify a version number of the license, you may choose
  195.      any version ever published by the Free Software Foundation.
  196.   9. If you wish to incorporate parts of the Program into other free
  197.      programs whose distribution conditions are different, write to the
  198.      author to ask for permission.  For software which is copyrighted
  199.      by the Free Software Foundation, write to the Free Software
  200.      Foundation; we sometimes make exceptions for this.  Our decision
  201.      will be guided by the two goals of preserving the free status of
  202.      all derivatives of our free software and of promoting the sharing
  203.      and reuse of software generally.
  204.                                 NO WARRANTY
  205.  10. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO
  206.      WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE
  207.      LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
  208.      HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
  209.      WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT
  210.      NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  211.      FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE
  212.      QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
  213.      PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
  214.      SERVICING, REPAIR OR CORRECTION.
  215.  11. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
  216.      WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY
  217.      MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE
  218.      LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
  219.      INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
  220.      INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
  221.      DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU
  222.      OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY
  223.      OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN
  224.      ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  225.                       END OF TERMS AND CONDITIONS
  226. Appendix: How to Apply These Terms to Your New Programs
  227. =======================================================
  228.    If you develop a new program, and you want it to be of the greatest
  229. possible use to humanity, the best way to achieve this is to make it
  230. free software which everyone can redistribute and change under these
  231. terms.
  232.    To do so, attach the following notices to the program.  It is safest
  233. to attach them to the start of each source file to most effectively
  234. convey the exclusion of warranty; and each file should have at least the
  235. "copyright" line and a pointer to where the full notice is found.
  236.      ONE LINE TO GIVE THE PROGRAM'S NAME AND A BRIEF IDEA OF WHAT IT DOES.
  237.      Copyright (C) 19YY  NAME OF AUTHOR
  238.      
  239.      This program is free software; you can redistribute it and/or modify
  240.      it under the terms of the GNU General Public License as published by
  241.      the Free Software Foundation; either version 1, or (at your option)
  242.      any later version.
  243.      
  244.      This program is distributed in the hope that it will be useful,
  245.      but WITHOUT ANY WARRANTY; without even the implied warranty of
  246.      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  247.      GNU General Public License for more details.
  248.      
  249.      You should have received a copy of the GNU General Public License
  250.      along with this program; if not, write to the Free Software
  251.      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  252.    Also add information on how to contact you by electronic and paper
  253. mail.
  254.    If the program is interactive, make it output a short notice like
  255. this when it starts in an interactive mode:
  256.      Gnomovision version 69, Copyright (C) 19YY NAME OF AUTHOR
  257.      Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
  258.      This is free software, and you are welcome to redistribute it
  259.      under certain conditions; type `show c' for details.
  260.    The hypothetical commands `show w' and `show c' should show the
  261. appropriate parts of the General Public License.  Of course, the
  262. commands you use may be called something other than `show w' and `show
  263. c'; they could even be mouse-clicks or menu items--whatever suits your
  264. program.
  265.    You should also get your employer (if you work as a programmer) or
  266. your school, if any, to sign a "copyright disclaimer" for the program,
  267. if necessary.  Here a sample; alter the names:
  268.      Yoyodyne, Inc., hereby disclaims all copyright interest in the
  269.      program `Gnomovision' (a program to direct compilers to make passes
  270.      at assemblers) written by James Hacker.
  271.      
  272.      SIGNATURE OF TY COON, 1 April 1989
  273.      Ty Coon, President of Vice
  274.    That's all there is to it!
  275. File: gdb.info,  Node: User Interface,  Next: Files,  Prev: License,  Up: Top
  276. GDB Input and Output Conventions
  277. ********************************
  278.    GDB is invoked with the shell command `gdb'.  Once started, it reads
  279. commands from the terminal until you tell it to exit.
  280.    A GDB command is a single line of input.  There is no limit on how
  281. long it can be.  It starts with a command name, which is followed by
  282. arguments whose meaning depends on the command name.  For example, the
  283. command `step' accepts an argument which is the number of times to step,
  284. as in `step 5'.  You can also use the `step' command with no arguments.
  285. Some command names do not allow any arguments.
  286.    GDB command names may always be abbreviated if the abbreviation is
  287. unambiguous.  Sometimes even ambiguous abbreviations are allowed; for
  288. example, `s' is specially defined as equivalent to `step' even though
  289. there are other commands whose names start with `s'.  Possible command
  290. abbreviations are often stated in the documentation of the individual
  291. commands.
  292.    A blank line as input to GDB means to repeat the previous command
  293. verbatim.  Certain commands do not allow themselves to be repeated this
  294. way; these are commands for which unintentional repetition might cause
  295. trouble and which you are unlikely to want to repeat.  Certain others
  296. (`list' and `x') act differently when repeated because that is more
  297. useful.
  298.    A line of input starting with `#' is a comment; it does nothing.
  299. This is useful mainly in command files (*Note Command Files::).
  300.    GDB indicates its readiness to read a command by printing a string
  301. called the "prompt".  This string is normally `(gdb)'.  You can change
  302. the prompt string with the `set prompt' command.  For instance, when
  303. debugging GDB with GDB, it is useful to change the prompt in one of the
  304. GDBs so that you tell which one you are talking to.
  305. `set prompt NEWPROMPT'
  306.      Directs GDB to use NEWPROMPT as its prompt string henceforth.
  307.    To exit GDB, use the `quit' command (abbreviated `q').  `Ctrl-c'
  308. will not exit from GDB, but rather will terminate the action of any GDB
  309. command that is in progress and return to GDB command level.  It is
  310. safe to type `Ctrl-c' at any time because GDB does not allow it to take
  311. effect until a time when it is safe.
  312.    Certain commands to GDB may produce large amounts of information
  313. output to the screen.  To help you read all of it, GDB pauses and asks
  314. you for input at the end of each page of output.  Type RET when you want
  315. to continue the output.  Normally GDB knows the size of the screen from
  316. on the termcap data base together with the value of the `TERM'
  317. environment variable; if this is not correct, you can override it with
  318. the `set screensize' command:
  319. `set screensize LPP'
  320. `set screensize LPP CPL'
  321.      Specify a screen height of LPP lines and (optionally) a width of
  322.      CPL characters.  If you omit CPL, the width does not change.
  323.      If you specify a height of zero lines, GDB will not pause during
  324.      output no matter how long the output is.  This is useful if output
  325.      is to a file or to an editor buffer.
  326.    Also, GDB may at times produce more information about its own
  327. workings than is of interest to the user.  Some of these informational
  328. messages can be turned on and off with the `set verbose' command:
  329. `set verbose off'
  330.      Disables GDB's output of certain informational messages.
  331. `set verbose on'
  332.      Re-enables GDB's output of certain informational messages.
  333.    Currently, the messages controlled by `set verbose' are those which
  334. announce that the symbol table for a source file is being read (*note
  335. File Commands::., in the description of the command `symbol-file').
  336. File: gdb.info,  Node: Files,  Next: Compilation,  Prev: User Interface,  Up: Top
  337. Specifying GDB's Files
  338. **********************
  339.    GDB needs to know the file name of the program to be debugged, both
  340. in order to read its symbol table and in order to start the program.  To
  341. debug a core dump of a previous run, GDB must be told the file name of
  342. the core dump.
  343. * Menu:
  344. * Arguments: File Arguments.   Specifying files with arguments
  345.                                 (when you start GDB).
  346. * Commands: File Commands.     Specifying files with GDB commands.
  347. File: gdb.info,  Node: File Arguments,  Next: File Commands,  Prev: Files,  Up: Files
  348. Specifying Files with Arguments
  349. ===============================
  350.    The usual way to specify the executable and core dump file names is
  351. with two command arguments given when you start GDB.  The first
  352. argument is used as the file for execution and symbols, and the second
  353. argument (if any) is used as the core dump file name.  Thus,
  354.      gdb progm core
  355. specifies `progm' as the executable program and `core' as a core dump
  356. file to examine.  (You do not need to have a core dump file if what you
  357. plan to do is debug the program interactively.)
  358.    *Note Options::, for full information on options and arguments for
  359. invoking GDB.
  360. File: gdb.info,  Node: File Commands,  Prev: File Arguments,  Up: Files
  361. Specifying Files with Commands
  362. ==============================
  363.    Usually you specify the files for GDB to work with by giving
  364. arguments when you invoke GDB.  But occasionally it is necessary to
  365. change to a different file during a GDB session.  Or you may run GDB
  366. and forget to specify the files you want to use.  In these situations
  367. the GDB commands to specify new files are useful.
  368. `exec-file FILENAME'
  369.      Specify that the program to be run is found in FILENAME.  If you
  370.      do not specify a directory and the file is not found in GDB's
  371.      working directory, GDB will use the environment variable `PATH' as
  372.      a list of directories to search, just as the shell does when
  373.      looking for a program to run.
  374. `symbol-file FILENAME'
  375.      Read symbol table information from file FILENAME.  `PATH' is
  376.      searched when necessary.  Most of the time you will use both the
  377.      `exec-file' and `symbol-file' commands on the same file.
  378.      `symbol-file' with no argument clears out GDB's symbol table.
  379.      The `symbol-file' command does not actually read the symbol table
  380.      in full right away.  Instead, it scans the symbol table quickly to
  381.      find which source files and which symbols are present.  The
  382.      details are read later, one source file at a time, when they are
  383.      needed.
  384.      The purpose of this two-stage reading strategy is to make GDB
  385.      start up faster.  For the most part, it is invisible except for
  386.      occasional messages telling you that the symbol table details for
  387.      a particular source file are being read.  (The `set verbose'
  388.      command controls whether these messages are printed; *note User
  389.      Interface::.).
  390.      However, you will sometimes see in backtraces lines for functions
  391.      in source files whose data has not been read in; these lines omit
  392.      some of the information, such as argument values, which cannot be
  393.      printed without full details of the symbol table.
  394.      When the symbol table is stored in COFF format, `symbol-file' does
  395.      read the symbol table data in full right away.  We haven't
  396.      bothered to implement the two-stage strategy for COFF.
  397. `core-file FILENAME'
  398.      Specify the whereabouts of a core dump file to be used as the
  399.      "contents of memory".  Note that the core dump contains only the
  400.      writable parts of memory; the read-only parts must come from the
  401.      executable file.
  402.      `core-file' with no argument specifies that no core file is to be
  403.      used.
  404.      Note that the core file is ignored when your program is actually
  405.      running under GDB.  So, if you have been running the program and
  406.      you wish to debug a core file instead, you must kill the
  407.      subprocess in which the program is running.  To do this, use the
  408.      `kill' command (*note Kill Process::.).
  409. `add-file FILENAME ADDRESS'
  410.      The `add-file' command reads additional symbol table information
  411.      from the file FILENAME.  You would use this when that file has
  412.      been dynamically loaded into the program that is running.  ADDRESS
  413.      should be the memory address at which the file has been loaded;
  414.      GDB cannot figure this out for itself.
  415.      The symbol table of the file FILENAME is added to the symbol table
  416.      originally read with the `symbol-file' command.  You can use the
  417.      `add-file' command any number of times; the new symbol data thus
  418.      read keeps adding to the old.  The `symbol-file' command forgets
  419.      all the symbol data GDB has read; that is the only time symbol
  420.      data is forgotten in GDB.
  421. `info files'
  422.      Print the names of the executable and core dump files currently in
  423.      use by GDB, and the file from which symbols were loaded.
  424.    While all three file-specifying commands allow both absolute and
  425. relative file names as arguments, GDB always converts the file name to
  426. an absolute one and remembers it that way.
  427.    The `symbol-file' command causes GDB to forget the contents of its
  428. convenience variables, the value history, and all breakpoints and
  429. auto-display expressions.  This is because they may contain pointers to
  430. the internal data recording symbols and data types, which are part of
  431. the old symbol table data being discarded inside GDB.
  432. File: gdb.info,  Node: Compilation,  Next: Running,  Prev: Files,  Up: Top
  433. Compiling Your Program for Debugging
  434. ************************************
  435.    In order to debug a program effectively, you need to ask for
  436. debugging information when you compile it.  This information in the
  437. object file describes the data type of each variable or function and
  438. the correspondence between source line numbers and addresses in the
  439. executable code.
  440.    To request debugging information, specify the `-g' option when you
  441. run the compiler.
  442.    The Unix C compiler is unable to handle the `-g' and `-O' options
  443. together.  This means that you cannot ask for optimization if you ask
  444. for debugger information.
  445.    The GNU C compiler supports `-g' with or without `-O', making it
  446. possible to debug optimized code.  We recommend that you *always* use
  447. `-g' whenever you compile a program.  You may think the program is
  448. correct, but there's no sense in pushing your luck.
  449.    GDB no longer supports the debugging information produced by giving
  450. the GNU C compiler the `-gg' option, so do not use this option.
  451. File: gdb.info,  Node: Running,  Next: Stopping,  Prev: Compilation,  Up: Top
  452. Running Your Program Under GDB
  453. ******************************
  454.    To start your program under GDB, use the `run' command.  The program
  455. must already have been specified using the `exec-file' command or with
  456. an argument to GDB (*note Files::.); what `run' does is create an
  457. inferior process, load the program into it, and set it in motion.
  458.    The execution of a program is affected by certain information it
  459. receives from its superior.  GDB provides ways to specify this
  460. information, which you must do before starting the program.  (You can
  461. change it after starting the program, but such changes do not affect
  462. the program unless you start it over again.)  This information may be
  463. divided into three categories:
  464. The arguments.
  465.      You specify the arguments to give the program as the arguments of
  466.      the `run' command.
  467. The environment.
  468.      The program normally inherits its environment from GDB, but you can
  469.      use the GDB commands `set environment' and `unset environment' to
  470.      change parts of the environment that will be given to the program.
  471. The working directory.
  472.      The program inherits its working directory from GDB.  You can set
  473.      GDB's working directory with the `cd' command in GDB.
  474.    After the `run' command, the debugger does nothing but wait for your
  475. program to stop.  *Note Stopping::.
  476.    Note that once your program has been started by the `run' command,
  477. you may evaluate expressions that involve calls to functions in the
  478. inferior.  *Note Expressions::.  If you wish to evaluate a function
  479. simply for its side affects, you may use the `set' command.  *Note
  480. Assignment::.
  481. * Menu:
  482. * Arguments::          Specifying the arguments for your program.
  483. * Environment::        Specifying the environment for your program.
  484. * Working Directory::  Specifying the working directory for giving
  485.                        to your program when it is run.
  486. * Input/Output::       Specifying the program's standard input and output.
  487. * Attach::             Debugging a process started outside GDB.
  488. * Kill Process::       Getting rid of the child process running your program.
  489. File: gdb.info,  Node: Arguments,  Next: Environment,  Prev: Running,  Up: Running
  490. Your Program's Arguments
  491. ========================
  492.    The arguments to your program are specified by the arguments of the
  493. `run' command.  They are passed to a shell, which expands wildcard
  494. characters and performs redirection of I/O, and thence to the program.
  495.    `run' with no arguments uses the same arguments used by the previous
  496. `run'.
  497.    The command `set args' can be used to specify the arguments to be
  498. used the next time the program is run.  If `set args' has no arguments,
  499. it means to use no arguments the next time the program is run.  If you
  500. have run your program with arguments and want to run it again with no
  501. arguments, this is the only way to do so.
  502. File: gdb.info,  Node: Environment,  Next: Working Directory,  Prev: Arguments,  Up: Running
  503. Your Program's Environment
  504. ==========================
  505.    The "environment" consists of a set of "environment variables" and
  506. their values.  Environment variables conventionally record such things
  507. as your user name, your home directory, your terminal type, and your
  508. search path for programs to run.  Usually you set up environment
  509. variables with the shell and they are inherited by all the other
  510. programs you run.  When debugging, it can be useful to try running the
  511. program with different environments without having to start the
  512. debugger over again.
  513. `info environment VARNAME'
  514.      Print the value of environment variable VARNAME to be given to
  515.      your program when it is started.  This command can be abbreviated
  516.      `i env VARNAME'.
  517. `info environment'
  518.      Print the names and values of all environment variables to be
  519.      given to your program when it is started.  This command can be
  520.      abbreviated `i env'.
  521. `set environment VARNAME VALUE'
  522. `set environment VARNAME = VALUE'
  523.      Sets environment variable VARNAME to VALUE, for your program only,
  524.      not for GDB itself.  VALUE may be any string; the values of
  525.      environment variables are just strings, and any interpretation is
  526.      supplied by your program itself.  The VALUE parameter is optional;
  527.      if it is eliminated, the variable is set to a null value.  This
  528.      command can be abbreviated as short as `set e'.
  529.      For example, this command:
  530.           set env USER = foo
  531.      tells the program, when subsequently run, to assume it is being run
  532.      on behalf of the user named `foo'.
  533. `delete environment VARNAME'
  534. `unset environment VARNAME'
  535.      Remove variable VARNAME from the environment to be passed to your
  536.      program.  This is different from `set env VARNAME =' because
  537.      `delete environment' leaves the variable with no value, which is
  538.      distinguishable from an empty value.  This command can be
  539.      abbreviated `d e'.
  540. File: gdb.info,  Node: Working Directory,  Next: Input/Output,  Prev: Environment,  Up: Running
  541. Your Program's Working Directory
  542. ================================
  543.    Each time you start your program with `run', it inherits its working
  544. directory from the current working directory of GDB.  GDB's working
  545. directory is initially whatever it inherited from its parent process
  546. (typically the shell), but you can specify a new working directory in
  547. GDB with the `cd' command.
  548.    The GDB working directory also serves as a default for the commands
  549. that specify files for GDB to operate on.  *Note Files::.
  550. `cd DIRECTORY'
  551.      Set GDB's working directory to DIRECTORY.
  552. `pwd'
  553.      Print GDB's working directory.
  554. File: gdb.info,  Node: Input/Output,  Next: Attach,  Prev: Working Directory,  Up: Running
  555. Your Program's Input and Output
  556. ===============================
  557.    By default, the program you run under GDB does input and output to
  558. the same terminal that GDB uses.
  559.    You can redirect the program's input and/or output using `sh'-style
  560. redirection commands in the `run' command.  For example,
  561.      run > outfile
  562. starts the program, diverting its output to the file `outfile'.
  563.    Another way to specify where the program should do input and output
  564. is with the `tty' command.  This command accepts a file name as
  565. argument, and causes this file to be the default for future `run'
  566. commands.  It also resets the controlling terminal for the child
  567. process, for future `run' commands.  For example,
  568.      tty /dev/ttyb
  569. directs that processes started with subsequent `run' commands default
  570. to do input and output on the terminal `/dev/ttyb' and have that as
  571. their controlling terminal.
  572.    An explicit redirection in `run' overrides the `tty' command's
  573. effect on input/output redirection, but not its effect on the
  574. controlling terminal.
  575.    When you use the `tty' command or redirect input in the `run'
  576. command, only the *input for your program* is affected.  The input for
  577. GDB still comes from your terminal.
  578. File: gdb.info,  Node: Attach,  Next: Kill Process,  Prev: Input/Output,  Up: Running
  579. Debugging an Already-Running Process
  580. ====================================
  581.    Some operating systems allow GDB to debug an already-running process
  582. that was started outside of GDB.  To do this, you use the `attach'
  583. command instead of the `run' command.
  584.    The `attach' command requires one argument, which is the process-id
  585. of the process you want to debug.  (The usual way to find out the
  586. process-id of the process is with the `ps' utility.)
  587.    The first thing GDB does after arranging to debug the process is to
  588. stop it.  You can examine and modify an attached process with all the
  589. GDB commands that ordinarily available when you start processes with
  590. `run'.  You can insert breakpoints; you can step and continue; you can
  591. modify storage.  If you would rather the process continue running, you
  592. may use the `continue' command after attaching GDB to the process.
  593.    When you have finished debugging the attached process, you can use
  594. the `detach' command to release it from GDB's control.  Detaching the
  595. process continues its execution.  After the `detach' command, that
  596. process and GDB become completely independent once more, and you are
  597. ready to `attach' another process or start one with `run'.
  598.    If you exit GDB or use the `run' command while you have an attached
  599. process, you kill that process.  You will be asked for confirmation if
  600. you try to do either of these things.
  601.    The `attach' command is also used to debug a remote machine via a
  602. serial connection.  *Note Attach::, for more info.
  603. File: gdb.info,  Node: Kill Process,  Prev: Attach,  Up: Running
  604. Killing the Child Process
  605. =========================
  606. `kill'
  607.      Kill the child process in which the program being debugged is
  608.      running under GDB.
  609.      This command is useful if you wish to debug a core dump instead.
  610.      GDB ignores any core dump file if it is actually running the
  611.      program, so the `kill' command is the only sure way to make sure
  612.      the core dump file is used once again.
  613.      It is also useful if you wish to run the program outside the
  614.      debugger for once and then go back to debugging it.
  615.      The `kill' command is also useful if you wish to recompile and
  616.      relink the program, since on many systems it is impossible to
  617.      modify an executable file which is running in a process.  But, in
  618.      this case, it is just as good to exit GDB, since you will need to
  619.      read a new symbol table after the program is recompiled if you
  620.      wish to debug the new version, and restarting GDB is the easiest
  621.      way to do that.
  622. File: gdb.info,  Node: Stopping,  Next: Stack,  Prev: Running,  Up: Top
  623. Stopping and Continuing
  624. ***********************
  625.    When you run a program normally, it runs until it terminates.  The
  626. principal purpose of using a debugger is so that you can stop it before
  627. that point; or so that if the program runs into trouble you can
  628. investigate and find out why.
  629. * Menu:
  630. * Signals::      Fatal signals in your program just stop it;
  631.                  then you can use GDB to see what is going on.
  632. * Breakpoints::  Breakpoints let you stop your program when it
  633.                  reaches a specified point in the code.
  634. * Continuing::   Resuming execution until the next signal or breakpoint.
  635. * Stepping::     Stepping runs the program a short distance and
  636.                  then stops it wherever it has come to.
  637. File: gdb.info,  Node: Signals,  Next: Breakpoints,  Prev: Stopping,  Up: Stopping
  638. Signals
  639. =======
  640.    A signal is an asynchronous event that can happen in a program.  The
  641. operating system defines the possible kinds of signals, and gives each
  642. kind a name and a number.  For example, `SIGINT' is the signal a program
  643. gets when you type `Ctrl-c'; `SIGSEGV' is the signal a program gets
  644. from referencing a place in memory far away from all the areas in use;
  645. `SIGALRM' occurs when the alarm clock timer goes off (which happens
  646. only if the program has requested an alarm).
  647.    Some signals, including `SIGALRM', are a normal part of the
  648. functioning of the program.  Others, such as `SIGSEGV', indicate
  649. errors; these signals are "fatal" (kill the program immediately) if the
  650. program has not specified in advance some other way to handle the
  651. signal.  `SIGINT' does not indicate an error in the program, but it is
  652. normally fatal so it can carry out the purpose of `Ctrl-c': to kill the
  653. program.
  654.    GDB has the ability to detect any occurrence of a signal in the
  655. program running under GDB's control.  You can tell GDB in advance what
  656. to do for each kind of signal.
  657.    Normally, GDB is set up to ignore non-erroneous signals like
  658. `SIGALRM' (so as not to interfere with their role in the functioning of
  659. the program) but to stop the program immediately whenever an error
  660. signal happens.  You can change these settings with the `handle'
  661. command.  You must specify which signal you are talking about with its
  662. number.
  663. `info signal'
  664.      Print a table of all the kinds of signals and how GDB has been
  665.      told to handle each one.  You can use this to see the signal
  666.      numbers of all the defined types of signals.
  667. `handle SIGNALNUM KEYWORDS...'
  668.      Change the way GDB handles signal SIGNALNUM.  The KEYWORDS say
  669.      what change to make.
  670.    To use the `handle' command you must know the code number of the
  671. signal you are concerned with.  To find the code number, type `info
  672. signal' which prints a table of signal names and numbers.
  673.    The keywords allowed by the handle command can be abbreviated.
  674. Their full names are
  675. `stop'
  676.      GDB should stop the program when this signal happens.  This implies
  677.      the `print' keyword as well.
  678. `print'
  679.      GDB should print a message when this signal happens.
  680. `nostop'
  681.      GDB should not stop the program when this signal happens.  It may
  682.      still print a message telling you that the signal has come in.
  683. `noprint'
  684.      GDB should not mention the occurrence of the signal at all.  This
  685.      implies the `nostop' keyword as well.
  686. `pass'
  687.      GDB should allow the program to see this signal; the program will
  688.      be able to handle the signal, or may be terminated if the signal
  689.      is fatal and not handled.
  690. `nopass'
  691.      GDB should not allow the program to see this signal.
  692.    When a signal has been set to stop the program, the program cannot
  693. see the signal until you continue.  It will see the signal then, if
  694. `pass' is in effect for the signal in question at that time.  In other
  695. words, after GDB reports a signal, you can use the `handle' command with
  696. `pass' or `nopass' to control whether that signal will be seen by the
  697. program when you later continue it.
  698.    You can also use the `signal' command to prevent the program from
  699. seeing a signal, or cause it to see a signal it normally would not see,
  700. or to give it any signal at any time.  *Note Signaling::.
  701. File: gdb.info,  Node: Breakpoints,  Next: Continuing,  Prev: Signals,  Up: Stopping
  702. Breakpoints
  703. ===========
  704.    A "breakpoint" makes your program stop whenever a certain point in
  705. the program is reached.  You set breakpoints explicitly with GDB
  706. commands, specifying the place where the program should stop by line
  707. number, function name or exact address in the program.  You can add
  708. various other conditions to control whether the program will stop.
  709.    Each breakpoint is assigned a number when it is created; these
  710. numbers are successive integers starting with 1.  In many of the
  711. commands for controlling various features of breakpoints you use the
  712. breakpoint number to say which breakpoint you want to change.  Each
  713. breakpoint may be "enabled" or "disabled"; if disabled, it has no
  714. effect on the program until you enable it again.
  715.    The command `info break' prints a list of all breakpoints set and not
  716. deleted, showing their numbers, where in the program they are, and any
  717. special features in use for them.  Disabled breakpoints are included in
  718. the list, but marked as disabled.  `info break' with a breakpoint number
  719. as argument lists only that breakpoint.  The convenience variable `$_'
  720. and the default examining-address for the `x' command are set to the
  721. address of the last breakpoint listed (*note Memory::.).
  722. * Menu:
  723. * Set Breaks::     How to establish breakpoints.
  724. * Delete Breaks::   How to remove breakpoints no longer needed.
  725. * Disabling::      How to disable breakpoints (turn them off temporarily).
  726. * Conditions::     Making extra conditions on whether to stop.
  727. * Break Commands:: Commands to be executed at a breakpoint.
  728. * Error in Breakpoints:: "Cannot insert breakpoints" error-why, what to do.
  729. File: gdb.info,  Node: Set Breaks,  Next: Delete Breaks,  Prev: Breakpoints,  Up: Breakpoints
  730. Setting Breakpoints
  731. -------------------
  732.    Breakpoints are set with the `break' command (abbreviated `b').  You
  733. have several ways to say where the breakpoint should go.
  734. `break FUNCTION'
  735.      Set a breakpoint at entry to function FUNCTION.
  736. `break +OFFSET'
  737. `break -OFFSET'
  738.      Set a breakpoint some number of lines forward or back from the
  739.      position at which execution stopped in the currently selected
  740.      frame.
  741. `break LINENUM'
  742.      Set a breakpoint at line LINENUM in the current source file.  That
  743.      file is the last file whose source text was printed.  This
  744.      breakpoint will stop the program just before it executes any of the
  745.      code on that line.
  746. `break FILENAME:LINENUM'
  747.      Set a breakpoint at line LINENUM in source file FILENAME.
  748. `break FILENAME:FUNCTION'
  749.      Set a breakpoint at entry to function FUNCTION found in file
  750.      FILENAME.  Specifying a file name as well as a function name is
  751.      superfluous except when multiple files contain similarly named
  752.      functions.
  753. `break *ADDRESS'
  754.      Set a breakpoint at address ADDRESS.  You can use this to set
  755.      breakpoints in parts of the program which do not have debugging
  756.      information or source files.
  757. `break'
  758.      Set a breakpoint at the next instruction to be executed in the
  759.      selected stack frame (*note Stack::.).  In any selected frame but
  760.      the innermost, this will cause the program to stop as soon as
  761.      control returns to that frame.  This is equivalent to a `finish'
  762.      command in the frame inside the selected frame.  If this is done
  763.      in the innermost frame, GDB will stop the next time it reaches the
  764.      current location; this may be useful inside of loops.
  765.      GDB normally ignores breakpoints when it resumes execution, until
  766.      at least one instruction has been executed.  If it did not do
  767.      this, you would be unable to proceed past a breakpoint without
  768.      first disabling the breakpoint.  This rule applies whether or not
  769.      the breakpoint already existed when the program stopped.
  770. `break ... if COND'
  771.      Set a breakpoint with condition COND; evaluate the expression COND
  772.      each time the breakpoint is reached, and stop only if the value is
  773.      nonzero.  `...' stands for one of the possible arguments described
  774.      above (or no argument) specifying where to break.  *Note
  775.      Conditions::, for more information on breakpoint conditions.
  776. `tbreak ARGS'
  777.      Set a breakpoint enabled only for one stop.  ARGS are the same as
  778.      in the `break' command, and the breakpoint is set in the same way,
  779.      but the breakpoint is automatically disabled the first time it is
  780.      hit.  *Note Disabling::.
  781.    GDB allows you to set any number of breakpoints at the same place in
  782. the program.  There is nothing silly or meaningless about this.  When
  783. the breakpoints are conditional, this is even useful (*note
  784. Conditions::.).
  785. File: gdb.info,  Node: Delete Breaks,  Next: Disabling,  Prev: Set Breaks,  Up: Breakpoints
  786. Deleting Breakpoints
  787. --------------------
  788.    It is often necessary to eliminate a breakpoint once it has done its
  789. job and you no longer want the program to stop there.  This is called
  790. "deleting" the breakpoint.  A breakpoint that has been deleted no
  791. longer exists in any sense; it is forgotten.
  792.    With the `clear' command you can delete breakpoints according to
  793. where they are in the program.  With the `delete' command you can delete
  794. individual breakpoints by specifying their breakpoint numbers.
  795.    It is not necessary to delete a breakpoint to proceed past it.  GDB
  796. automatically ignores breakpoints in the first instruction to be
  797. executed when you continue execution without changing the execution
  798. address.
  799. `clear'
  800.      Delete any breakpoints at the next instruction to be executed in
  801.      the selected stack frame (*note Selection::.).  When the innermost
  802.      frame is selected, this is a good way to delete a breakpoint that
  803.      the program just stopped at.
  804. `clear FUNCTION'
  805. `clear FILENAME:FUNCTION'
  806.      Delete any breakpoints set at entry to the function FUNCTION.
  807. `clear LINENUM'
  808. `clear FILENAME:LINENUM'
  809.      Delete any breakpoints set at or within the code of the specified
  810.      line.
  811. `delete BNUMS...'
  812.      Delete the breakpoints of the numbers specified as arguments.
  813. File: gdb.info,  Node: Disabling,  Next: Conditions,  Prev: Delete Breaks,  Up: Breakpoints
  814. Disabling Breakpoints
  815. ---------------------
  816.    Rather than deleting a breakpoint, you might prefer to "disable" it.
  817. This makes the breakpoint inoperative as if it had been deleted, but
  818. remembers the information on the breakpoint so that you can "enable" it
  819. again later.
  820.    You disable and enable breakpoints with the `enable' and `disable'
  821. commands, specifying one or more breakpoint numbers as arguments.  Use
  822. `info break' to print a list of breakpoints if you don't know which
  823. breakpoint numbers to use.
  824.    A breakpoint can have any of four different states of enablement:
  825.    * Enabled.  The breakpoint will stop the program.  A breakpoint made
  826.      with the `break' command starts out in this state.
  827.    * Disabled.  The breakpoint has no effect on the program.
  828.    * Enabled once.  The breakpoint will stop the program, but when it
  829.      does so it will become disabled.  A breakpoint made with the
  830.      `tbreak' command starts out in this state.
  831.    * Enabled for deletion.  The breakpoint will stop the program, but
  832.      immediately after it does so it will be deleted permanently.
  833.    You change the state of enablement of a breakpoint with the following
  834. commands:
  835. `disable breakpoints BNUMS...'
  836. `disable BNUMS...'
  837.      Disable the specified breakpoints.  A disabled breakpoint has no
  838.      effect but is not forgotten.  All options such as ignore-counts,
  839.      conditions and commands are remembered in case the breakpoint is
  840.      enabled again later.
  841. `enable breakpoints BNUMS...'
  842. `enable BNUMS...'
  843.      Enable the specified breakpoints.  They become effective once
  844.      again in stopping the program, until you specify otherwise.
  845. `enable breakpoints once BNUMS...'
  846. `enable once BNUMS...'
  847.      Enable the specified breakpoints temporarily.  Each will be
  848.      disabled again the next time it stops the program (unless you have
  849.      used one of these commands to specify a different state before
  850.      that time comes).
  851. `enable breakpoints delete BNUMS...'
  852. `enable delete BNUMS...'
  853.      Enable the specified breakpoints to work once and then die.  Each
  854.      of the breakpoints will be deleted the next time it stops the
  855.      program (unless you have used one of these commands to specify a
  856.      different state before that time comes).
  857.    Aside from the automatic disablement or deletion of a breakpoint
  858. when it stops the program, which happens only in certain states, the
  859. state of enablement of a breakpoint changes only when one of the
  860. commands above is used.
  861. File: gdb.info,  Node: Conditions,  Next: Break Commands,  Prev: Disabling,  Up: Breakpoints
  862. Break Conditions
  863. ----------------
  864.    The simplest sort of breakpoint breaks every time the program
  865. reaches a specified place.  You can also specify a "condition" for a
  866. breakpoint.  A condition is just a boolean expression in your
  867. programming language.  (*Note Expressions::).  A breakpoint with a
  868. condition evaluates the expression each time the program reaches it, and
  869. the program stops only if the condition is true.
  870.    Break conditions may have side effects, and may even call functions
  871. in your program.  These may sound like strange things to do, but their
  872. effects are completely predictable unless there is another enabled
  873. breakpoint at the same address.  (In that case, GDB might see the other
  874. breakpoint first and stop the program without checking the condition of
  875. this one.)  Note that breakpoint commands are usually more convenient
  876. and flexible for the purpose of performing side effects when a
  877. breakpoint is reached (*note Break Commands::.).
  878.    Break conditions can be specified when a breakpoint is set, by using
  879. `if' in the arguments to the `break' command.  *Note Set Breaks::.
  880. They can also be changed at any time with the `condition' command:
  881. `condition BNUM EXPRESSION'
  882.      Specify EXPRESSION as the break condition for breakpoint number
  883.      BNUM.  From now on, this breakpoint will stop the program only if
  884.      the value of EXPRESSION is true (nonzero, in C).  EXPRESSION is
  885.      not evaluated at the time the `condition' command is given.  *Note
  886.      Expressions::.
  887. `condition BNUM'
  888.      Remove the condition from breakpoint number BNUM.  It becomes an
  889.      ordinary unconditional breakpoint.
  890.    A special case of a breakpoint condition is to stop only when the
  891. breakpoint has been reached a certain number of times.  This is so
  892. useful that there is a special way to do it, using the "ignore count"
  893. of the breakpoint.  Every breakpoint has an ignore count, which is an
  894. integer.  Most of the time, the ignore count is zero, and therefore has
  895. no effect.  But if the program reaches a breakpoint whose ignore count
  896. is positive, then instead of stopping, it just decrements the ignore
  897. count by one and continues.  As a result, if the ignore count value is
  898. N, the breakpoint will not stop the next N times it is reached.
  899. `ignore BNUM COUNT'
  900.      Set the ignore count of breakpoint number BNUM to COUNT.  The next
  901.      COUNT times the breakpoint is reached, it will not stop.
  902.      To make the breakpoint stop the next time it is reached, specify a
  903.      count of zero.
  904. `cont COUNT'
  905.      Continue execution of the program, setting the ignore count of the
  906.      breakpoint that the program stopped at to COUNT minus one.  Thus,
  907.      the program will not stop at this breakpoint until the COUNT'th
  908.      time it is reached.
  909.      This command is allowed only when the program stopped due to a
  910.      breakpoint.  At other times, the argument to `cont' is ignored.
  911.    If a breakpoint has a positive ignore count and a condition, the
  912. condition is not checked.  Once the ignore count reaches zero, the
  913. condition will start to be checked.
  914.    Note that you could achieve the effect of the ignore count with a
  915. condition such as `$foo-- <= 0' using a debugger convenience variable
  916. that is decremented each time.  *Note Convenience Vars::.
  917. File: gdb.info,  Node: Break Commands,  Next: Error in Breakpoints,  Prev: Conditions,  Up: Breakpoints
  918. Commands Executed on Breaking
  919. -----------------------------
  920.    You can give any breakpoint a series of commands to execute when the
  921. program stops due to that breakpoint.  For example, you might want to
  922. print the values of certain expressions, or enable other breakpoints.
  923. `commands BNUM'
  924.      Specify commands for breakpoint number BNUM.  The commands
  925.      themselves appear on the following lines.  Type a line containing
  926.      just `end' to terminate the commands.
  927.      To remove all commands from a breakpoint, use the command
  928.      `commands' and follow it immediately by `end'; that is, give no
  929.      commands.
  930.      With no arguments, `commands' refers to the last breakpoint set.
  931.    It is possible for breakpoint commands to start the program up again.
  932. Simply use the `cont' command, or `step', or any other command to
  933. resume execution.  However, any remaining breakpoint commands are
  934. ignored.  When the program stops again, GDB will act according to the
  935. cause of that stop.
  936.    If the first command specified is `silent', the usual message about
  937. stopping at a breakpoint is not printed.  This may be desirable for
  938. breakpoints that are to print a specific message and then continue.  If
  939. the remaining commands too print nothing, you will see no sign that the
  940. breakpoint was reached at all.  `silent' is not really a command; it is
  941. meaningful only at the beginning of the commands for a breakpoint.
  942.    The commands `echo' and `output' that allow you to print precisely
  943. controlled output are often useful in silent breakpoints.  *Note
  944. Output::.
  945.    For example, here is how you could use breakpoint commands to print
  946. the value of `x' at entry to `foo' whenever it is positive.
  947.      break foo if x>0
  948.      commands
  949.      silent
  950.      echo x is\040
  951.      output x
  952.      echo \n
  953.      cont
  954.      end
  955.    One application for breakpoint commands is to correct one bug so you
  956. can test another.  Put a breakpoint just after the erroneous line of
  957. code, give it a condition to detect the case in which something
  958. erroneous has been done, and give it commands to assign correct values
  959. to any variables that need them.  End with the `cont' command so that
  960. the program does not stop, and start with the `silent' command so that
  961. no output is produced.  Here is an example:
  962.      break 403
  963.      commands
  964.      silent
  965.      set x = y + 4
  966.      cont
  967.      end
  968.    One deficiency in the operation of automatically continuing
  969. breakpoints under Unix appears when your program uses raw mode for the
  970. terminal.  GDB switches back to its own terminal modes (not raw) before
  971. executing commands, and then must switch back to raw mode when your
  972. program is continued.  This causes any pending terminal input to be
  973. lost.
  974.    In the GNU system, this will be fixed by changing the behavior of
  975. terminal modes.
  976.    Under Unix, when you have this problem, you might be able to get
  977. around it by putting your actions into the breakpoint condition instead
  978. of commands.  For example
  979.      condition 5  (x = y + 4), 0
  980. specifies a condition expression (*Note Expressions::) that will change
  981. `x' as needed, then always have the value 0 so the program will not
  982. stop.  Loss of input is avoided here because break conditions are
  983. evaluated without changing the terminal modes.  When you want to have
  984. nontrivial conditions for performing the side effects, the operators
  985. `&&', `||' and `?...:' may be useful.
  986. File: gdb.info,  Node: Error in Breakpoints,  Prev: Break Commands,  Up: Breakpoints
  987. "Cannot Insert Breakpoints" Error
  988. ---------------------------------
  989.    Under some operating systems, breakpoints cannot be used in a
  990. program if any other process is running that program.  Attempting to
  991. run or continue the program with a breakpoint in this case will cause
  992. GDB to stop it.
  993.    When this happens, you have three ways to proceed:
  994.   1. Remove or disable the breakpoints, then continue.
  995.   2. Suspend GDB, and copy the file containing the program to a new
  996.      name.  Resume GDB and use the `exec-file' command to specify that
  997.      GDB should run the program under that name.  Then start the
  998.      program again.
  999.   3. Relink the program so that the text segment is nonsharable, using
  1000.      the linker option `-N'.  The operating system limitation may not
  1001.      apply to nonsharable executables.
  1002. File: gdb.info,  Node: Continuing,  Next: Stepping,  Prev: Breakpoints,  Up: Stopping
  1003. Continuing
  1004. ==========
  1005.    After your program stops, most likely you will want it to run some
  1006. more if the bug you are looking for has not happened yet.
  1007. `cont'
  1008.      Continue running the program at the place where it stopped.
  1009.    If the program stopped at a breakpoint, the place to continue running
  1010. is the address of the breakpoint.  You might expect that continuing
  1011. would just stop at the same breakpoint immediately.  In fact, `cont'
  1012. takes special care to prevent that from happening.  You do not need to
  1013. delete the breakpoint to proceed through it after stopping at it.
  1014.    You can, however, specify an ignore-count for the breakpoint that the
  1015. program stopped at, by means of an argument to the `cont' command.
  1016. *Note Conditions::.
  1017.    If the program stopped because of a signal other than `SIGINT' or
  1018. `SIGTRAP', continuing will cause the program to see that signal.  You
  1019. may not want this to happen.  For example, if the program stopped due
  1020. to some sort of memory reference error, you might store correct values
  1021. into the erroneous variables and continue, hoping to see more
  1022. execution; but the program would probably terminate immediately as a
  1023. result of the fatal signal once it sees the signal.  To prevent this,
  1024. you can continue with `signal 0'.  *Note Signaling::.  You can also act
  1025. in advance to prevent the program from seeing certain kinds of signals,
  1026. using the `handle' command (*note Signals::.).
  1027. File: gdb.info,  Node: Stepping,  Prev: Continuing,  Up: Stopping
  1028. Stepping
  1029. ========
  1030.    "Stepping" means setting your program in motion for a limited time,
  1031. so that control will return automatically to the debugger after one
  1032. line of code or one machine instruction.  Breakpoints are active during
  1033. stepping and the program will stop for them even if it has not gone as
  1034. far as the stepping command specifies.
  1035. `step'
  1036.      Continue running the program until control reaches a different
  1037.      line, then stop it and return control to the debugger.  This
  1038.      command is abbreviated `s'.
  1039.      This command may be given when control is within a function for
  1040.      which there is no debugging information.  In that case, execution
  1041.      will proceed until control reaches a different function, or is
  1042.      about to return from this function.  An argument repeats this
  1043.      action.
  1044. `step COUNT'
  1045.      Continue running as in `step', but do so COUNT times.  If a
  1046.      breakpoint is reached or a signal not related to stepping occurs
  1047.      before COUNT steps, stepping stops right away.
  1048. `next'
  1049.      Similar to `step', but any function calls appearing within the
  1050.      line of code are executed without stopping.  Execution stops when
  1051.      control reaches a different line of code at the stack level which
  1052.      was executing when the `next' command was given.  This command is
  1053.      abbreviated `n'.
  1054.      An argument is a repeat count, as in `step'.
  1055.      `next' within a function without debugging information acts as does
  1056.      `step', but any function calls appearing within the code of the
  1057.      function are executed without stopping.
  1058. `finish'
  1059.      Continue running until just after the selected stack frame returns
  1060.      (or until there is some other reason to stop, such as a fatal
  1061.      signal or a breakpoint).  Print value returned by the selected
  1062.      stack frame (if any).
  1063.      Contrast this with the `return' command (*note Returning::.).
  1064. `until'
  1065.      This command is used to avoid single stepping through a loop more
  1066.      than once.  It is like the `next' command, except that when `until'
  1067.      encounters a jump, it automatically continues execution until the
  1068.      program counter is greater than the address of the jump.
  1069.      This means that when you reach the end of a loop after single
  1070.      stepping though it, `until' will cause the program to continue
  1071.      execution until the loop is exited.  In contrast, a `next' command
  1072.      at the end of a loop will simply step back to the beginning of the
  1073.      loop, which would force you to step through the next iteration.
  1074.      `until' always stops the program if it attempts to exit the current
  1075.      stack frame.
  1076.      `until' may produce somewhat counterintuitive results if the order
  1077.      of the source lines does not match the actual order of execution.
  1078.      For example, in a typical C `for'-loop, the third expression in the
  1079.      `for'-statement (the loop-step expression) is executed after the
  1080.      statements in the body of the loop, but is written before them.
  1081.      Therefore, the `until' command would appear to step back to the
  1082.      beginning of the loop when it advances to this expression.
  1083.      However, it has not really done so, not in terms of the actual
  1084.      machine code.
  1085.      Note that `until' with no argument works by means of single
  1086.      instruction stepping, and hence is slower than `until' with an
  1087.      argument.
  1088. `until LOCATION'
  1089.      Continue running the program until either the specified location is
  1090.      reached, or the current (innermost) stack frame returns.  This
  1091.      form of the command uses breakpoints, and hence is quicker than
  1092.      `until' without an argument.
  1093. `stepi'
  1094.      Execute one machine instruction, then stop and return to the
  1095.      debugger.
  1096.      It is often useful to do `display/i $pc' when stepping by machine
  1097.      instructions.  This will cause the next instruction to be executed
  1098.      to be displayed automatically at each stop.  *Note Auto Display::.
  1099.      An argument is a repeat count, as in `step'.
  1100. `nexti'
  1101.      Execute one machine instruction, but if it is a subroutine call,
  1102.      proceed until the subroutine returns.
  1103.      An argument is a repeat count, as in `next'.
  1104.    A typical technique for using stepping is to put a breakpoint (*note
  1105. Breakpoints::.) at the beginning of the function or the section of the
  1106. program in which a problem is believed to lie, and then step through
  1107. the suspect area, examining the variables that are interesting, until
  1108. the problem happens.
  1109.    The `cont' command can be used after stepping to resume execution
  1110. until the next breakpoint or signal.
  1111. File: gdb.info,  Node: Stack,  Next: Source,  Prev: Stopping,  Up: Top
  1112. Examining the Stack
  1113. *******************
  1114.    When your program has stopped, the first thing you need to know is
  1115. where it stopped and how it got there.
  1116.    Each time your program performs a function call, the information
  1117. about where in the program the call was made from is saved in a block
  1118. of data called a "stack frame".  The frame also contains the arguments
  1119. of the call and the local variables of the function that was called.
  1120. All the stack frames are allocated in a region of memory called the
  1121. "call stack".
  1122.    When your program stops, the GDB commands for examining the stack
  1123. allow you to see all of this information.
  1124.    One of the stack frames is "selected" by GDB and many GDB commands
  1125. refer implicitly to the selected frame.  In particular, whenever you ask
  1126. GDB for the value of a variable in the program, the value is found in
  1127. the selected frame.  There are special GDB commands to select whichever
  1128. frame you are interested in.
  1129.    When the program stops, GDB automatically selects the currently
  1130. executing frame and describes it briefly as the `frame' command does
  1131. (*note Info: Frame Info.).
  1132. * Menu:
  1133. * Frames::          Explanation of stack frames and terminology.
  1134. * Backtrace::       Summarizing many frames at once.
  1135. * Selection::       How to select a stack frame.
  1136. * Info: Frame Info, Commands to print information on stack frames.
  1137. File: gdb.info,  Node: Frames,  Next: Backtrace,  Prev: Stack,  Up: Stack
  1138. Stack Frames
  1139. ============
  1140.    The call stack is divided up into contiguous pieces called "stack
  1141. frames", or "frames" for short; each frame is the data associated with
  1142. one call to one function.  The frame contains the arguments given to
  1143. the function, the function's local variables, and the address at which
  1144. the function is executing.
  1145.    When your program is started, the stack has only one frame, that of
  1146. the function `main'.  This is called the "initial" frame or the
  1147. "outermost" frame.  Each time a function is called, a new frame is
  1148. made.  Each time a function returns, the frame for that function
  1149. invocation is eliminated.  If a function is recursive, there can be
  1150. many frames for the same function.  The frame for the function in which
  1151. execution is actually occurring is called the "innermost" frame.  This
  1152. is the most recently created of all the stack frames that still exist.
  1153.    Inside your program, stack frames are identified by their addresses.
  1154. A stack frame consists of many bytes, each of which has its own
  1155. address; each kind of computer has a convention for choosing one of
  1156. those bytes whose address serves as the address of the frame.  Usually
  1157. this address is kept in a register called the "frame pointer register"
  1158. while execution is going on in that frame.
  1159.    GDB assigns numbers to all existing stack frames, starting with zero
  1160. for the innermost frame, one for the frame that called it, and so on
  1161. upward.  These numbers do not really exist in your program; they are to
  1162. give you a way of talking about stack frames in GDB commands.
  1163.    Many GDB commands refer implicitly to one stack frame.  GDB records
  1164. a stack frame that is called the "selected" stack frame; you can select
  1165. any frame using one set of GDB commands, and then other commands will
  1166. operate on that frame.  When your program stops, GDB automatically
  1167. selects the innermost frame.
  1168.    Some functions can be compiled to run without a frame reserved for
  1169. them on the stack.  This is occasionally done with heavily used library
  1170. functions to save the frame setup time.  GDB has limited facilities for
  1171. dealing with these function invocations; if the innermost function
  1172. invocation has no stack frame, GDB will give it a virtual stack frame of
  1173. 0 and correctly allow tracing of the function call chain.  Results are
  1174. undefined if a function invocation besides the innermost one is
  1175. frameless.
  1176. File: gdb.info,  Node: Backtrace,  Next: Selection,  Prev: Frames,  Up: Stack
  1177. Backtraces
  1178. ==========
  1179.    A backtrace is a summary of how the program got where it is.  It
  1180. shows one line per frame, for many frames, starting with the currently
  1181. executing frame (frame zero), followed by its caller (frame one), and
  1182. on up the stack.
  1183. `backtrace'
  1184.      Print a backtrace of the entire stack: one line per frame for all
  1185.      frames in the stack.
  1186.      You can stop the backtrace at any time by typing the system
  1187.      interrupt character, normally `Control-C'.
  1188. `backtrace N'
  1189. `bt N'
  1190.      Similar, but print only the innermost N frames.
  1191. `backtrace -N'
  1192. `bt -N'
  1193.      Similar, but print only the outermost N frames.
  1194.    The names `where' and `info stack' are additional aliases for
  1195. `backtrace'.
  1196.    Every line in the backtrace shows the frame number, the function name
  1197. and the program counter value.
  1198.    If the function is in a source file whose symbol table data has been
  1199. fully read, the backtrace shows the source file name and line number, as
  1200. well as the arguments to the function.  (The program counter value is
  1201. omitted if it is at the beginning of the code for that line number.)
  1202.    If the source file's symbol data has not been fully read, just
  1203. scanned, this extra information is replaced with an ellipsis.  You can
  1204. force the symbol data for that frame's source file to be read by
  1205. selecting the frame.  (*Note Selection::).
  1206.    Here is an example of a backtrace.  It was made with the command `bt
  1207. 3', so it shows the innermost three frames.
  1208.      #0  rtx_equal_p (x=(rtx) 0x8e58c, y=(rtx) 0x1086c4) (/gp/rms/cc/rtlanal.c line 337)
  1209.      #1  0x246b0 in expand_call (...) (...)
  1210.      #2  0x21cfc in expand_expr (...) (...)
  1211.      (More stack frames follow...)
  1212. The functions `expand_call' and `expand_expr' are in a file whose
  1213. symbol details have not been fully read.  Full detail is available for
  1214. the function `rtx_equal_p', which is in the file `rtlanal.c'.  Its
  1215. arguments, named `x' and `y', are shown with their typed values.
  1216. File: gdb.info,  Node: Selection,  Next: Frame Info,  Prev: Backtrace,  Up: Stack
  1217. Selecting a Frame
  1218. =================
  1219.    Most commands for examining the stack and other data in the program
  1220. work on whichever stack frame is selected at the moment.  Here are the
  1221. commands for selecting a stack frame; all of them finish by printing a
  1222. brief description of the stack frame just selected.
  1223. `frame N'
  1224.      Select frame number N.  Recall that frame zero is the innermost
  1225.      (currently executing) frame, frame one is the frame that called the
  1226.      innermost one, and so on.  The highest-numbered frame is `main''s
  1227.      frame.
  1228. `frame ADDR'
  1229.      Select the frame at address ADDR.  This is useful mainly if the
  1230.      chaining of stack frames has been damaged by a bug, making it
  1231.      impossible for GDB to assign numbers properly to all frames.  In
  1232.      addition, this can be useful when the program has multiple stacks
  1233.      and switches between them.
  1234. `up N'
  1235.      Select the frame N frames up from the frame previously selected.
  1236.      For positive numbers N, this advances toward the outermost frame,
  1237.      to higher frame numbers, to frames that have existed longer.  N
  1238.      defaults to one.
  1239. `down N'
  1240.      Select the frame N frames down from the frame previously selected.
  1241.      For positive numbers N, this advances toward the innermost frame,
  1242.      to lower frame numbers, to frames that were created more recently.
  1243.      N defaults to one.
  1244.    All of these commands end by printing some information on the frame
  1245. that has been selected: the frame number, the function name, the
  1246. arguments, the source file and line number of execution in that frame,
  1247. and the text of that source line.  For example:
  1248.      #3  main (argc=3, argv=??, env=??) at main.c, line 67
  1249.      67        read_input_file (argv[i]);
  1250.    After such a printout, the `list' command with no arguments will
  1251. print ten lines centered on the point of execution in the frame.  *Note
  1252. List::.
  1253. File: gdb.info,  Node: Frame Info,  Prev: Selection,  Up: Stack
  1254. Information on a Frame
  1255. ======================
  1256.    There are several other commands to print information about the
  1257. selected stack frame.
  1258. `frame'
  1259.      This command prints a brief description of the selected stack
  1260.      frame.  It can be abbreviated `f'.  With an argument, this command
  1261.      is used to select a stack frame; with no argument, it does not
  1262.      change which frame is selected, but still prints the same
  1263.      information.
  1264. `info frame'
  1265.      This command prints a verbose description of the selected stack
  1266.      frame, including the address of the frame, the addresses of the
  1267.      next frame in (called by this frame) and the next frame out
  1268.      (caller of this frame), the address of the frame's arguments, the
  1269.      program counter saved in it (the address of execution in the
  1270.      caller frame), and which registers were saved in the frame.  The
  1271.      verbose description is useful when something has gone wrong that
  1272.      has made the stack format fail to fit the usual conventions.
  1273. `info frame ADDR'
  1274.      Print a verbose description of the frame at address ADDR, without
  1275.      selecting that frame.  The selected frame remains unchanged by
  1276.      this command.
  1277. `info args'
  1278.      Print the arguments of the selected frame, each on a separate line.
  1279. `info locals'
  1280.      Print the local variables of the selected frame, each on a separate
  1281.      line.  These are all variables declared static or automatic within
  1282.      all program blocks that execution in this frame is currently
  1283.      inside of.
  1284. File: gdb.info,  Node: Source,  Next: Data,  Prev: Stack,  Up: Top
  1285. Examining Source Files
  1286. **********************
  1287.    GDB knows which source files your program was compiled from, and can
  1288. print parts of their text.  When your program stops, GDB spontaneously
  1289. prints the line it stopped in.  Likewise, when you select a stack frame
  1290. (*note Selection::.), GDB prints the line which execution in that frame
  1291. has stopped in.  You can also print parts of source files by explicit
  1292. command.
  1293. * Menu:
  1294. * List::        Using the `list' command to print source files.
  1295. * Search::      Commands for searching source files.
  1296. * Source Path:: Specifying the directories to search for source files.
  1297. File: gdb.info,  Node: List,  Next: Search,  Prev: Source,  Up: Source
  1298. Printing Source Lines
  1299. =====================
  1300.    To print lines from a source file, use the `list' command
  1301. (abbreviated `l').  There are several ways to specify what part of the
  1302. file you want to print.
  1303.    Here are the forms of the `list' command most commonly used:
  1304. `list LINENUM'
  1305.      Print ten lines centered around line number LINENUM in the current
  1306.      source file.
  1307. `list FUNCTION'
  1308.      Print ten lines centered around the beginning of function FUNCTION.
  1309. `list'
  1310.      Print ten more lines.  If the last lines printed were printed with
  1311.      a `list' command, this prints ten lines following the last lines
  1312.      printed; however, if the last line printed was a solitary line
  1313.      printed as part of displaying a stack frame (*note Stack::.), this
  1314.      prints ten lines centered around that line.
  1315. `list -'
  1316.      Print ten lines just before the lines last printed.
  1317.    Repeating a `list' command with RET discards the argument, so it is
  1318. equivalent to typing just `list'.  This is more useful than listing the
  1319. same lines again.  An exception is made for an argument of `-'; that
  1320. argument is preserved in repetition so that each repetition moves up in
  1321. the file.
  1322.    In general, the `list' command expects you to supply zero, one or two
  1323. "linespecs".  Linespecs specify source lines; there are several ways of
  1324. writing them but the effect is always to specify some source line.
  1325. Here is a complete description of the possible arguments for `list':
  1326. `list LINESPEC'
  1327.      Print ten lines centered around the line specified by LINESPEC.
  1328. `list FIRST,LAST'
  1329.      Print lines from FIRST to LAST.  Both arguments are linespecs.
  1330. `list ,LAST'
  1331.      Print ten lines ending with LAST.
  1332. `list FIRST,'
  1333.      Print ten lines starting with FIRST.
  1334. `list +'
  1335.      Print ten lines just after the lines last printed.
  1336. `list -'
  1337.      Print ten lines just before the lines last printed.
  1338. `list'
  1339.      As described in the preceding table.
  1340.    Here are the ways of specifying a single source line--all the kinds
  1341. of linespec.
  1342. `LINENUM'
  1343.      Specifies line LINENUM of the current source file.  When a `list'
  1344.      command has two linespecs, this refers to the same source file as
  1345.      the first linespec.
  1346. `+OFFSET'
  1347.      Specifies the line OFFSET lines after the last line printed.  When
  1348.      used as the second linespec in a `list' command that has two, this
  1349.      specifies the line OFFSET lines down from the first linespec.
  1350. `-OFFSET'
  1351.      Specifies the line OFFSET lines before the last line printed.
  1352. `FILENAME:LINENUM'
  1353.      Specifies line LINENUM in the source file FILENAME.
  1354. `FUNCTION'
  1355.      Specifies the line of the open-brace that begins the body of the
  1356.      function FUNCTION.
  1357. `FILENAME:FUNCTION'
  1358.      Specifies the line of the open-brace that begins the body of the
  1359.      function FUNCTION in the file FILENAME.  The file name is needed
  1360.      with a function name only for disambiguation of identically named
  1361.      functions in different source files.
  1362. `*ADDRESS'
  1363.      Specifies the line containing the program address ADDRESS.
  1364.      ADDRESS may be any expression.
  1365.    One other command is used to map source lines to program addresses.
  1366. `info line LINENUM'
  1367.      Print the starting and ending addresses of the compiled code for
  1368.      source line LINENUM.
  1369.      The default examine address for the `x' command is changed to the
  1370.      starting address of the line, so that `x/i' is sufficient to begin
  1371.      examining the machine code (*note Memory::.).  Also, this address
  1372.      is saved as the value of the convenience variable `$_' (*note
  1373.      Convenience Vars::.).
  1374. File: gdb.info,  Node: Search,  Next: Source Path,  Prev: List,  Up: Source
  1375. Searching Source Files
  1376. ======================
  1377.    There are two commands for searching through the current source file
  1378. for a regular expression.
  1379.    The command `forward-search REGEXP' checks each line, starting with
  1380. the one following the last line listed, for a match for REGEXP.  It
  1381. lists the line that is found.  You can abbreviate the command name as
  1382. `fo'.
  1383.    The command `reverse-search REGEXP' checks each line, starting with
  1384. the one before the last line listed and going backward, for a match for
  1385. REGEXP.  It lists the line that is found.  You can abbreviate this
  1386. command with as little as `rev'.
  1387. File: gdb.info,  Node: Source Path,  Prev: Search,  Up: Source
  1388. Specifying Source Directories
  1389. =============================
  1390.    Executable programs do not record the directories of the source files
  1391. from which they were compiled, just the names.  GDB remembers a list of
  1392. directories to search for source files; this is called the "source
  1393. path".  Each time GDB wants a source file, it tries all the directories
  1394. in the list, in the order they are present in the list, until it finds a
  1395. file with the desired name.  Note that the executable search path is
  1396. not used for this purpose.  Neither is the current working directory,
  1397. unless it happens to be in the source path.
  1398.    When you start GDB, its source path contains just the current working
  1399. directory.  To add other directories, use the `directory' command.
  1400. `directory DIRNAMES...'
  1401.      Add directory DIRNAME to the end of the source path.  Several
  1402.      directory names may be given to this command, separated by
  1403.      whitespace or `:'.
  1404. `directory'
  1405.      Reset the source path to just the current working directory of GDB.
  1406.      This requires confirmation.
  1407.      Since this command deletes directories from the search path, it may
  1408.      change the directory in which a previously read source file will be
  1409.      discovered.  To make this work correctly, this command also clears
  1410.      out the tables GDB maintains about the source files it has already
  1411.      found.
  1412. `info directories'
  1413.      Print the source path: show which directories it contains.
  1414.    Because the `directory' command adds to the end of the source path,
  1415. it does not affect any file that GDB has already found.  If the source
  1416. path contains directories that you do not want, and these directories
  1417. contain misleading files with names matching your source files, the way
  1418. to correct the situation is as follows:
  1419.   1. Choose the directory you want at the beginning of the source path.
  1420.      Use the `cd' command to make that the current working directory.
  1421.   2. Use `directory' with no argument to reset the source path to just
  1422.      that directory.
  1423.   3. Use `directory' with suitable arguments to add any other
  1424.      directories you want in the source path.
  1425. File: gdb.info,  Node: Data,  Next: Symbols,  Prev: Source,  Up: Top
  1426. Examining Data
  1427. **************
  1428.    The usual way to examine data in your program is with the `print'
  1429. command (abbreviated `p').  It evaluates and prints the value of any
  1430. valid expression of the language the program is written in (for now, C).
  1431. You type
  1432.      print EXP
  1433. where EXP is any valid expression, and the value of EXP is printed in a
  1434. format appropriate to its data type.
  1435.    A more low-level way of examining data is with the `x' command.  It
  1436. examines data in memory at a specified address and prints it in a
  1437. specified format.
  1438. * Menu:
  1439. * Expressions::      Expressions that can be computed and printed.
  1440. * Variables::        Using your program's variables in expressions.
  1441. * Assignment::       Setting your program's variables.
  1442. * Arrays::           Examining part of memory as an array.
  1443. * Format options::   Controlling how structures and arrays are printed.
  1444. * Output formats::   Specifying formats for printing values.
  1445. * Memory::           Examining memory explicitly.
  1446. * Auto Display::     Printing certain expressions whenever program stops.
  1447. * Value History::    Referring to values previously printed.
  1448. * Convenience Vars:: Giving names to values for future reference.
  1449. * Registers::        Referring to and storing in machine registers.
  1450. File: gdb.info,  Node: Expressions,  Next: Variables,  Prev: Data,  Up: Data
  1451. Expressions
  1452. ===========
  1453.    Many different GDB commands accept an expression and compute its
  1454. value.  Any kind of constant, variable or operator defined by the
  1455. programming language you are using is legal in an expression in GDB.
  1456. This includes conditional expressions, function calls, casts and string
  1457. constants.  It unfortunately does not include symbols defined by
  1458. preprocessor `#define' commands.
  1459.    Casts are supported in all languages, not just in C, because it is so
  1460. useful to cast a number into a pointer so as to examine a structure at
  1461. that address in memory.
  1462.    GDB supports three kinds of operator in addition to those of
  1463. programming languages:
  1464.      `@' is a binary operator for treating parts of memory as arrays.
  1465.      *Note Arrays::, for more information.
  1466.      `::' allows you to specify a variable in terms of the file or
  1467.      function it is defined in.  *Note Variables::.
  1468. `{TYPE} ADDR'
  1469.      Refers to an object of type TYPE stored at address ADDR in memory.
  1470.      ADDR may be any expression whose value is an integer or pointer
  1471.      (but parentheses are required around nonunary operators, just as in
  1472.      a cast).  This construct is allowed regardless of what kind of
  1473.      data is officially supposed to reside at ADDR.
  1474. File: gdb.info,  Node: Variables,  Next: Arrays,  Prev: Expressions,  Up: Data
  1475. Program Variables
  1476. =================
  1477.    The most common kind of expression to use is the name of a variable
  1478. in your program.
  1479.    Variables in expressions are understood in the selected stack frame
  1480. (*note Selection::.); they must either be global (or static) or be
  1481. visible according to the scope rules of the programming language from
  1482. the point of execution in that frame.  This means that in the function
  1483.      foo (a)
  1484.           int a;
  1485.      {
  1486.        bar (a);
  1487.        {
  1488.          int b = test ();
  1489.          bar (b);
  1490.        }
  1491.      }
  1492. the variable `a' is usable whenever the program is executing within the
  1493. function `foo', but the variable `b' is visible only while the program
  1494. is executing inside the block in which `b' is declared.
  1495.    As a special exception, you can refer to a variable or function whose
  1496. scope is a single source file even if the current execution point is not
  1497. in this file.  But it is possible to have more than one such variable
  1498. or function with the same name (if they are in different source files).
  1499. In such a case, it is not defined which one you will get.  If you wish,
  1500. you can specify any one of them using the colon-colon construct:
  1501.      BLOCK::VARIABLE
  1502. Here BLOCK is the name of the source file whose variable you want.
  1503. File: gdb.info,  Node: Arrays,  Next: Format options,  Prev: Variables,  Up: Data
  1504. Artificial Arrays
  1505. =================
  1506.    It is often useful to print out several successive objects of the
  1507. same type in memory; a section of an array, or an array of dynamically
  1508. determined size for which only a pointer exists in the program.
  1509.    This can be done by constructing an "artificial array" with the
  1510. binary operator `@'.  The left operand of `@' should be the first
  1511. element of the desired array, as an individual object.  The right
  1512. operand should be the length of the array.  The result is an array
  1513. value whose elements are all of the type of the left argument.  The
  1514. first element is actually the left argument; the second element comes
  1515. from bytes of memory immediately following those that hold the first
  1516. element, and so on.  Here is an example.  If a program says
  1517.      int *array = (int *) malloc (len * sizeof (int));
  1518. you can print the contents of `array' with
  1519.      p *array@len
  1520.    The left operand of `@' must reside in memory.  Array values made
  1521. with `@' in this way behave just like other arrays in terms of
  1522. subscripting, and are coerced to pointers when used in expressions.
  1523. (It would probably appear in an expression via the value history, after
  1524. you had printed it out.)
  1525. File: gdb.info,  Node: Format options,  Next: Output formats,  Prev: Arrays,  Up: Data
  1526. Format options
  1527. ==============
  1528.    GDB provides a few ways to control how arrays and structures are
  1529. printed.
  1530. `info format'
  1531.      Display the current settings for the format options.
  1532. `set array-max NUMBER-OF-ELEMENTS'
  1533.      If GDB is printing a large array, it will stop printing after it
  1534.      has printed the number of elements set by the `set array-max'
  1535.      command.  This limit also applies to the display of strings.
  1536. `set prettyprint on'
  1537.      Cause GDB to print structures in an indented format with one
  1538.      member per line, like this:
  1539.           $1 = {
  1540.             next = 0x0,
  1541.             flags = {
  1542.               sweet = 1,
  1543.               sour = 1
  1544.             },
  1545.             meat = 0x54 "Pork"
  1546.           }
  1547. `set prettyprint off'
  1548.      Cause GDB to print structures in a compact format, like this:
  1549.           $1 = {next = 0x0, flags = {sweet = 1, sour = 1}, meat = 0x54 "Pork"}
  1550.      This is the default format.
  1551. `set unionprint on'
  1552.      Tell GDB to print unions which are contained in structures.  This
  1553.      is the default setting.
  1554. `set unionprint off'
  1555.      Tell GDB not to print unions which are contained in structures.
  1556.      For example, given the declarations
  1557.           typedef enum {Tree, Bug} Species;
  1558.           typedef enum {Big_tree, Acorn, Seedling} Tree_forms;
  1559.           typedef enum {Caterpiller, Cocoon, Butterfly} Bug_forms;
  1560.           
  1561.           struct thing {
  1562.             Species it;
  1563.             union {
  1564.               Tree_forms tree;
  1565.               Bug_forms bug;
  1566.             } form;
  1567.           };
  1568.           
  1569.           struct thing foo = {Tree, {Acorn}};
  1570.      with `set unionprint on' in effect `p foo' would print
  1571.           $1 = {it = Tree, form = {tree = Acorn, bug = Cocoon}}
  1572.      and with `set unionprint off' in effect it would print
  1573.           $1 = {it = Tree, form = {...}}
  1574. File: gdb.info,  Node: Output formats,  Next: Memory,  Prev: Format options,  Up: Data
  1575. Output formats
  1576. ==============
  1577.    GDB normally prints all values according to their data types.
  1578. Sometimes this is not what you want.  For example, you might want to
  1579. print a number in hex, or a pointer in decimal.  Or you might want to
  1580. view data in memory at a certain address as a character string or an
  1581. instruction.  These things can be done with "output formats".
  1582.    The simplest use of output formats is to say how to print a value
  1583. already computed.  This is done by starting the arguments of the
  1584. `print' command with a slash and a format letter.  The format letters
  1585. supported are:
  1586.      Regard the bits of the value as an integer, and print the integer
  1587.      in hexadecimal.
  1588.      Print as integer in signed decimal.
  1589.      Print as integer in unsigned decimal.
  1590.      Print as integer in octal.
  1591.      Print as an address, both absolute in hex and then relative to a
  1592.      symbol defined as an address below it.
  1593.      Regard as an integer and print it as a character constant.
  1594.      Regard the bits of the value as a floating point number and print
  1595.      using typical floating point syntax.
  1596.    For example, to print the program counter in hex (*note
  1597. Registers::.), type
  1598.      p/x $pc
  1599. Note that no space is required before the slash; this is because command
  1600. names in GDB cannot contain a slash.
  1601.    To reprint the last value in the value history with a different
  1602. format, you can use the `print' command with just a format and no
  1603. expression.  For example, `p/x' reprints the last value in hex.
  1604. File: gdb.info,  Node: Memory,  Next: Auto Display,  Prev: Output formats,  Up: Data
  1605. Examining Memory
  1606. ----------------
  1607.    The command `x' (for `examine') can be used to examine memory
  1608. without reference to the program's data types.  The format in which you
  1609. wish to examine memory is instead explicitly specified.  The allowable
  1610. formats are a superset of the formats described in the previous section.
  1611.    `x' is followed by a slash and an output format specification,
  1612. followed by an expression for an address.  The expression need not have
  1613. a pointer value (though it may); it is used as an integer, as the
  1614. address of a byte of memory.  *Note Expressions:: for more information
  1615. on expressions.  For example, `x/4xw $sp' prints the four words of
  1616. memory above the stack pointer in hexadecimal.
  1617.    The output format in this case specifies both how big a unit of
  1618. memory to examine and how to print the contents of that unit.  It is
  1619. done with one or two of the following letters:
  1620.    These letters specify just the size of unit to examine:
  1621.      Examine individual bytes.
  1622.      Examine halfwords (two bytes each).
  1623.      Examine words (four bytes each).
  1624.      Many assemblers and cpu designers still use `word' for a 16-bit
  1625.      quantity, as a holdover from specific predecessor machines of the
  1626.      1970's that really did use two-byte words.  But more generally the
  1627.      term `word' has always referred to the size of quantity that a
  1628.      machine normally operates on and stores in its registers.  This is
  1629.      32 bits for all the machines that GDB runs on.
  1630.      Examine giant words (8 bytes).
  1631.    These letters specify just the way to print the contents:
  1632.      Print as integers in unsigned hexadecimal.
  1633.      Print as integers in signed decimal.
  1634.      Print as integers in unsigned decimal.
  1635.      Print as integers in unsigned octal.
  1636.      Print as an address, both absolute in hex and then relative to a
  1637.      symbol defined as an address below it.
  1638.      Print as character constants.
  1639.      Print as floating point.  This works only with sizes `w' and `g'.
  1640.      Print a null-terminated string of characters.  The specified unit
  1641.      size is ignored; instead, the unit is however many bytes it takes
  1642.      to reach a null character (including the null character).
  1643.      Print a machine instruction in assembler syntax (or nearly).  The
  1644.      specified unit size is ignored; the number of bytes in an
  1645.      instruction varies depending on the type of machine, the opcode
  1646.      and the addressing modes used.
  1647.    If either the manner of printing or the size of unit fails to be
  1648. specified, the default is to use the same one that was used last.  If
  1649. you don't want to use any letters after the slash, you can omit the
  1650. slash as well.
  1651.    You can also omit the address to examine.  Then the address used is
  1652. just after the last unit examined.  This is why string and instruction
  1653. formats actually compute a unit-size based on the data: so that the
  1654. next string or instruction examined will start in the right place.  The
  1655. `print' command sometimes sets the default address for the `x' command;
  1656. when the value printed resides in memory, the default is set to examine
  1657. the same location.  `info line' also sets the default for `x', to the
  1658. address of the start of the machine code for the specified line and
  1659. `info breakpoints' sets it to the address of the last breakpoint listed.
  1660.    When you use RET to repeat an `x' command, it does not repeat
  1661. exactly the same: the address specified previously (if any) is ignored,
  1662. so that the repeated command examines the successive locations in memory
  1663. rather than the same ones.
  1664.    You can examine several consecutive units of memory with one command
  1665. by writing a repeat-count after the slash (before the format letters,
  1666. if any).  The repeat count must be a decimal integer.  It has the same
  1667. effect as repeating the `x' command that many times except that the
  1668. output may be more compact with several units per line.  For example,
  1669.      x/10i $pc
  1670. prints ten instructions starting with the one to be executed next in the
  1671. selected frame.  After doing this, you could print another ten following
  1672. instructions with
  1673.      x/10
  1674. in which the format and address are allowed to default.
  1675.    The addresses and contents printed by the `x' command are not put in
  1676. the value history because there is often too much of them and they would
  1677. get in the way.  Instead, GDB makes these values available for
  1678. subsequent use in expressions as values of the convenience variables
  1679. `$_' and `$__'.
  1680.    After an `x' command, the last address examined is available for use
  1681. in expressions in the convenience variable `$_'.  The contents of that
  1682. address, as examined, are available in the convenience variable `$__'.
  1683.    If the `x' command has a repeat count, the address and contents saved
  1684. are from the last memory unit printed; this is not the same as the last
  1685. address printed if several units were printed on the last line of
  1686. output.
  1687.    The specialized command `disassemble' is also provided to dump a
  1688. range of memory as machine instructions.  The default memory range is
  1689. the function surrounding the program counter of the selected frame.  A
  1690. single argument to this command is a program counter value; the function
  1691. surrounding this value will be dumped.  Two arguments specify a range of
  1692. addresss (first inclusive, second exclusive) to be dumped.
  1693. File: gdb.info,  Node: Auto Display,  Next: Value History,  Prev: Memory,  Up: Data
  1694. Automatic Display
  1695. =================
  1696.    If you find that you want to print the value of an expression
  1697. frequently (to see how it changes), you might want to add it to the
  1698. "automatic display list" so that GDB will print its value each time the
  1699. program stops.  Each expression added to the list is given a number to
  1700. identify it; to remove an expression from the list, you specify that
  1701. number.  The automatic display looks like this:
  1702.      2: foo = 38
  1703.      3: bar[5] = (struct hack *) 0x3804
  1704. showing item numbers, expressions and their current values.
  1705.    If the expression refers to local variables, then it does not make
  1706. sense outside the lexical context for which it was set up.  Such an
  1707. expression is printed only when execution is inside that lexical
  1708. context.  For example, if you give the command `display name' while
  1709. inside a function with an argument `name', then this argument will be
  1710. displayed whenever the program stops inside that function, but not when
  1711. it stops elsewhere (since this argument doesn't exist elsewhere).
  1712. `display EXP'
  1713.      Add the expression EXP to the list of expressions to display each
  1714.      time the program stops.  *Note Expressions::.
  1715. `display/FMT EXP'
  1716.      For FMT specifying only a display format and not a size or count,
  1717.      add the expression EXP to the auto-display list but arranges to
  1718.      display it each time in the specified format FMT.
  1719. `display/FMT ADDR'
  1720.      For FMT `i' or `s', or including a unit-size or a number of units,
  1721.      add the expression ADDR as a memory address to be examined each
  1722.      time the program stops.  Examining means in effect doing `x/FMT
  1723.      ADDR'.  *Note Memory::.
  1724. `undisplay DNUMS...'
  1725. `delete display DNUMS...'
  1726.      Remove item numbers DNUMS from the list of expressions to display.
  1727. `disable display DNUMS...'
  1728.      Disable the display of item numbers DNUMS.  A disabled display
  1729.      item is not printed automatically, but is not forgotten.  It may be
  1730.      reenabled later.
  1731. `enable display DNUMS...'
  1732.      Enable display of item numbers DNUMS.  It becomes effective once
  1733.      again in auto display of its expression, until you specify
  1734.      otherwise.
  1735. `display'
  1736.      Display the current values of the expressions on the list, just as
  1737.      is done when the program stops.
  1738. `info display'
  1739.      Print the list of expressions previously set up to display
  1740.      automatically, each one with its item number, but without showing
  1741.      the values.  This includes disabled expressions, which are marked
  1742.      as such.  It also includes expressions which would not be
  1743.      displayed right now because they refer to automatic variables not
  1744.      currently available.
  1745. File: gdb.info,  Node: Value History,  Next: Convenience Vars,  Prev: Auto Display,  Up: Data
  1746. Value History
  1747. =============
  1748.    Every value printed by the `print' command is saved for the entire
  1749. session in GDB's "value history" so that you can refer to it in other
  1750. expressions.
  1751.    The values printed are given "history numbers" for you to refer to
  1752. them by.  These are successive integers starting with 1.  `print' shows
  1753. you the history number assigned to a value by printing `$NUM = ' before
  1754. the value; here NUM is the history number.
  1755.    To refer to any previous value, use `$' followed by the value's
  1756. history number.  The output printed by `print' is designed to remind
  1757. you of this.  Just `$' refers to the most recent value in the history,
  1758. and `$$' refers to the value before that.
  1759.    For example, suppose you have just printed a pointer to a structure
  1760. and want to see the contents of the structure.  It suffices to type
  1761.      p *$
  1762.    If you have a chain of structures where the component `next' points
  1763. to the next one, you can print the contents of the next one with this:
  1764.      p *$.next
  1765. It might be useful to repeat this command many times by typing RET.
  1766.    Note that the history records values, not expressions.  If the value
  1767. of `x' is 4 and you type this command:
  1768.      print x
  1769.      set x=5
  1770. then the value recorded in the value history by the `print' command
  1771. remains 4 even though the value of `x' has changed.
  1772. `info values'
  1773.      Print the last ten values in the value history, with their item
  1774.      numbers.  This is like `p $$9' repeated ten times, except that
  1775.      `info values' does not change the history.
  1776. `info values N'
  1777.      Print ten history values centered on history item number N.
  1778. `info values +'
  1779.      Print ten history values just after the values last printed.
  1780. File: gdb.info,  Node: Convenience Vars,  Next: Registers,  Prev: Value History,  Up: Data
  1781. Convenience Variables
  1782. =====================
  1783.    GDB provides "convenience variables" that you can use within GDB to
  1784. hold on to a value and refer to it later.  These variables exist
  1785. entirely within GDB; they are not part of your program, and setting a
  1786. convenience variable has no effect on further execution of your
  1787. program.  That's why you can use them freely.
  1788.    Convenience variables have names starting with `$'.  Any name
  1789. starting with `$' can be used for a convenience variable, unless it is
  1790. one of the predefined set of register names (*note Registers::.).
  1791.    You can save a value in a convenience variable with an assignment
  1792. expression, just as you would set a variable in your program.  Example:
  1793.      set $foo = *object_ptr
  1794. would save in `$foo' the value contained in the object pointed to by
  1795. `object_ptr'.
  1796.    Using a convenience variable for the first time creates it; but its
  1797. value is `void' until you assign a new value.  You can alter the value
  1798. with another assignment at any time.
  1799.    Convenience variables have no fixed types.  You can assign a
  1800. convenience variable any type of value, even if it already has a value
  1801. of a different type.  The convenience variable as an expression has
  1802. whatever type its current value has.
  1803. `info convenience'
  1804.      Print a list of convenience variables used so far, and their
  1805.      values.  Abbreviated `i con'.
  1806.    One of the ways to use a convenience variable is as a counter to be
  1807. incremented or a pointer to be advanced.  For example:
  1808.      set $i = 0
  1809.      print bar[$i++]->contents
  1810.      ...repeat that command by typing RET.
  1811.    Some convenience variables are created automatically by GDB and given
  1812. values likely to be useful.
  1813.      The variable `$_' is automatically set by the `x' command to the
  1814.      last address examined (*note Memory::.).  Other commands which
  1815.      provide a default address for `x' to examine also set `$_' to that
  1816.      address; these commands include `info line' and `info breakpoint'.
  1817. `$__'
  1818.      The variable `$__' is automatically set by the `x' command to the
  1819.      value found in the last address examined.
  1820. File: gdb.info,  Node: Registers,  Prev: Convenience Vars,  Up: Data
  1821. Registers
  1822. =========
  1823.    Machine register contents can be referred to in expressions as
  1824. variables with names starting with `$'.  The names of registers are
  1825. different for each machine; use `info registers' to see the names used
  1826. on your machine.  The names `$pc' and `$sp' are used on all machines for
  1827. the program counter register and the stack pointer.  Often `$fp' is
  1828. used for a register that contains a pointer to the current stack frame,
  1829. and `$ps' is used for a register that contains the processor status.
  1830. These standard register names may be available on your machine even
  1831. though the `info registers' command displays them with a different
  1832. name.  For example, on the SPARC, `info registers' displays the
  1833. processor status register as `$psr' but you can also refer to it as
  1834. `$ps'.
  1835.    GDB always considers the contents of an ordinary register as an
  1836. integer when the register is examined in this way.  Some machines have
  1837. special registers which can hold nothing but floating point; these
  1838. registers are considered floating point.  There is no way to refer to
  1839. the contents of an ordinary register as floating point value (although
  1840. you can *print* it as a floating point value with `print/f $REGNAME').
  1841.    Some registers have distinct "raw" and "virtual" data formats.  This
  1842. means that the data format in which the register contents are saved by
  1843. the operating system is not the same one that your program normally
  1844. sees.  For example, the registers of the 68881 floating point
  1845. coprocessor are always saved in "extended" format, but all C programs
  1846. expect to work with "double" format.  In such cases, GDB normally works
  1847. with the virtual format only (the format that makes sense for your
  1848. program), but the `info registers' command prints the data in both
  1849. formats.
  1850.    Register values are relative to the selected stack frame (*note
  1851. Selection::.).  This means that you get the value that the register
  1852. would contain if all stack frames farther in were exited and their saved
  1853. registers restored.  In order to see the real contents of all registers,
  1854. you must select the innermost frame (with `frame 0').
  1855.    Some registers are never saved (typically those numbered zero or one)
  1856. because they are used for returning function values; for these
  1857. registers, relativization makes no difference.
  1858. `info registers'
  1859.      Print the names and relativized values of all registers.
  1860. `info registers REGNAME'
  1861.      Print the relativized value of register REGNAME.  REGNAME may be
  1862.      any register name valid on the machine you are using, with or
  1863.      without the initial `$'.
  1864. Examples
  1865. --------
  1866.    You could print the program counter in hex with
  1867.      p/x $pc
  1868. or print the instruction to be executed next with
  1869.      x/i $pc
  1870. or add four to the stack pointer with
  1871.      set $sp += 4
  1872. The last is a way of removing one word from the stack, on machines where
  1873. stacks grow downward in memory (most machines, nowadays).  This assumes
  1874. that the innermost stack frame is selected.  Setting `$sp' is not
  1875. allowed when other stack frames are selected.
  1876. File: gdb.info,  Node: Symbols,  Next: Altering,  Prev: Data,  Up: Top
  1877. Examining the Symbol Table
  1878. **************************
  1879.    The commands described in this section allow you to make inquiries
  1880. for information about the symbols (names of variables, functions and
  1881. types) defined in your program.  This information is found by GDB in
  1882. the symbol table loaded by the `symbol-file' command; it is inherent in
  1883. the text of your program and does not change as the program executes.
  1884. `whatis EXP'
  1885.      Print the data type of expression EXP.  EXP is not actually
  1886.      evaluated, and any side-effecting operations (such as assignments
  1887.      or function calls) inside it do not take place.  *Note
  1888.      Expressions::.
  1889. `whatis'
  1890.      Print the data type of `$', the last value in the value history.
  1891. `info address SYMBOL'
  1892.      Describe where the data for SYMBOL is stored.  For a register
  1893.      variable, this says which register it is kept in.  For a
  1894.      non-register local variable, this prints the stack-frame offset at
  1895.      which the variable is always stored.
  1896.      Note the contrast with `print &SYMBOL', which does not work at all
  1897.      for a register variables, and for a stack local variable prints
  1898.      the exact address of the current instantiation of the variable.
  1899. `ptype TYPENAME'
  1900.      Print a description of data type TYPENAME.  TYPENAME may be the
  1901.      name of a type, or for C code it may have the form `struct
  1902.      STRUCT-TAG', `union UNION-TAG' or `enum ENUM-TAG'.
  1903. `info sources'
  1904.      Print the names of all source files in the program for which there
  1905.      is debugging information.
  1906. `info functions'
  1907.      Print the names and data types of all defined functions.
  1908. `info functions REGEXP'
  1909.      Print the names and data types of all defined functions whose
  1910.      names contain a match for regular expression REGEXP.  Thus, `info
  1911.      fun step' finds all functions whose names include `step'; `info
  1912.      fun ^step' finds those whose names start with `step'.
  1913. `info variables'
  1914.      Print the names and data types of all variables that are declared
  1915.      outside of functions (i.e., except for local variables).
  1916. `info variables REGEXP'
  1917.      Print the names and data types of all variables (except for local
  1918.      variables) whose names contain a match for regular expression
  1919.      REGEXP.
  1920. `info types'
  1921.      Print all data types that are defined in the program.
  1922. `info types REGEXP'
  1923.      Print all data types that are defined in the program whose names
  1924.      contain a match for regular expression REGEXP.
  1925. `printsyms FILENAME'
  1926.      Write a complete dump of the debugger's symbol data into the file
  1927.      FILENAME.
  1928. File: gdb.info,  Node: Altering,  Next: Sequences,  Prev: Symbols,  Up: Top
  1929. Altering Execution
  1930. ******************
  1931.    Once you think you have find an error in the program, you might want
  1932. to find out for certain whether correcting the apparent error would
  1933. lead to correct results in the rest of the run.  You can find the
  1934. answer by experiment, using the GDB features for altering execution of
  1935. the program.
  1936.    For example, you can store new values into variables or memory
  1937. locations, give the program a signal, restart it at a different address,
  1938. or even return prematurely from a function to its caller.
  1939. * Menu:
  1940. * Assignment::    Altering variable values or memory contents.
  1941. * Jumping::       Altering control flow.
  1942. * Signaling::     Making signals happen in the program.
  1943. * Returning::     Making a function return prematurely.
  1944. File: gdb.info,  Node: Assignment,  Next: Jumping,  Prev: Altering,  Up: Altering
  1945. Assignment to Variables
  1946. =======================
  1947.    To alter the value of a variable, evaluate an assignment expression.
  1948. *Note Expressions::.  For example,
  1949.      print x=4
  1950. would store the value 4 into the variable `x', and then print the value
  1951. of the assignment expression (which is 4).
  1952.    All the assignment operators of C are supported, including the
  1953. incrementation operators `++' and `--', and combining assignments such
  1954. as `+=' and `<<='.
  1955.    If you are not interested in seeing the value of the assignment, use
  1956. the `set' command instead of the `print' command.  `set' is really the
  1957. same as `print' except that the expression's value is not printed and
  1958. is not put in the value history (*note Value History::.).  The
  1959. expression is evaluated only for side effects.
  1960.    Note that if the beginning of the argument string of the `set'
  1961. command appears identical to a `set' subcommand, it may be necessary to
  1962. use the `set variable' command.  This command is identical to `set'
  1963. except for its lack of subcommands.
  1964.    GDB allows more implicit conversions in assignments than C does; you
  1965. can freely store an integer value into a pointer variable or vice
  1966. versa, and any structure can be converted to any other structure that
  1967. is the same length or shorter.
  1968.    To store values into arbitrary places in memory, use the `{...}'
  1969. construct to generate a value of specified type at a specified address
  1970. (*note Expressions::.).  For example, `{int}0x83040' would refer to
  1971. memory location 0x83040 as an integer (which implies a certain size and
  1972. representation in memory), and
  1973.      set {int}0x83040 = 4
  1974.    would store the value 4 into that memory location.
  1975. File: gdb.info,  Node: Jumping,  Next: Signaling,  Prev: Assignment,  Up: Altering
  1976. Continuing at a Different Address
  1977. =================================
  1978.    Ordinarily, when you continue the program, you do so at the place
  1979. where it stopped, with the `cont' command.  You can instead continue at
  1980. an address of your own choosing, with the following commands:
  1981. `jump LINENUM'
  1982.      Resume execution at line number LINENUM.  Execution may stop
  1983.      immediately if there is a breakpoint there.
  1984.      The `jump' command does not change the current stack frame, or the
  1985.      stack pointer, or the contents of any memory location or any
  1986.      register other than the program counter.  If line LINENUM is in a
  1987.      different function from the one currently executing, the results
  1988.      may be bizarre if the two functions expect different patterns of
  1989.      arguments or of local variables.  For this reason, the `jump'
  1990.      command requests confirmation if the specified line is not in the
  1991.      function currently executing.  However, even bizarre results are
  1992.      predictable based on careful study of the machine-language code of
  1993.      the program.
  1994. `jump *ADDRESS'
  1995.      Resume execution at the instruction at address ADDRESS.
  1996.    You can get much the same effect as the `jump' command by storing a
  1997. new value into the register `$pc'.  The difference is that this does
  1998. not start the program running; it only changes the address where it
  1999. *will* run when it is continued.  For example,
  2000.      set $pc = 0x485
  2001. causes the next `cont' command or stepping command to execute at
  2002. address 0x485, rather than at the address where the program stopped.
  2003. *Note Stepping::.
  2004.    The most common occasion to use the `jump' command is when you have
  2005. stepped across a function call with `next', and found that the return
  2006. value is incorrect.  If all the relevant data appeared correct before
  2007. the function call, the error is probably in the function that just
  2008. returned.
  2009.    In general, your next step would now be to rerun the program and
  2010. execute up to this function call, and then step into it to see where it
  2011. goes astray.  But this may be time consuming.  If the function did not
  2012. have significant side effects, you could get the same information by
  2013. resuming execution just before the function call and stepping through
  2014. it.  To do this, first put a breakpoint on that function; then, use the
  2015. `jump' command to continue on the line with the function call.
  2016. File: gdb.info,  Node: Signaling,  Next: Returning,  Prev: Jumping,  Up: Altering
  2017. Giving the Program a Signal
  2018. ===========================
  2019. `signal SIGNALNUM'
  2020.      Resume execution where the program stopped, but give it
  2021.      immediately the signal number SIGNALNUM.
  2022.      Alternatively, if SIGNALNUM is zero, continue execution without
  2023.      giving a signal.  This is useful when the program stopped on
  2024.      account of a signal and would ordinary see the signal when resumed
  2025.      with the `cont' command; `signal 0' causes it to resume without a
  2026.      signal.
  2027. File: gdb.info,  Node: Returning,  Prev: Signaling,  Up: Altering
  2028. Returning from a Function
  2029. =========================
  2030.    You can cancel execution of a function call with the `return'
  2031. command.  This command has the effect of discarding the selected stack
  2032. frame (and all frames within it), so that control moves to the caller of
  2033. that function.  You can think of this as making the discarded frame
  2034. return prematurely.
  2035.    First select the stack frame that you wish to return from (*note
  2036. Selection::.).  Then type the `return' command.  If you wish to specify
  2037. the value to be returned, give that as an argument.
  2038.    This pops the selected stack frame (and any other frames inside of
  2039. it), leaving its caller as the innermost remaining frame.  That frame
  2040. becomes selected.  The specified value is stored in the registers used
  2041. for returning values of functions.
  2042.    The `return' command does not resume execution; it leaves the
  2043. program stopped in the state that would exist if the function had just
  2044. returned.  Contrast this with the `finish' command (*note Stepping::.),
  2045. which resumes execution until the selected stack frame returns
  2046. *naturally*.
  2047. File: gdb.info,  Node: Sequences,  Next: Options,  Prev: Altering,  Up: Top
  2048. Canned Sequences of Commands
  2049. ****************************
  2050.    GDB provides two ways to store sequences of commands for execution
  2051. as a unit: user-defined commands and command files.
  2052. * Menu:
  2053. * Define::         User-defined commands.
  2054. * Command Files::  Command files.
  2055. * Output::         Controlled output commands useful in
  2056.                    user-defined commands and command files.
  2057. File: gdb.info,  Node: Define,  Next: Command Files,  Prev: Sequences,  Up: Sequences
  2058. User-Defined Commands
  2059. =====================
  2060.    A "user-defined command" is a sequence of GDB commands to which you
  2061. assign a new name as a command.  This is done with the `define' command.
  2062. `define COMMANDNAME'
  2063.      Define a command named COMMANDNAME.  If there is already a command
  2064.      by that name, you are asked to confirm that you want to redefine
  2065.      it.
  2066.      The definition of the command is made up of other GDB command
  2067.      lines, which are given following the `define' command.  The end of
  2068.      these commands is marked by a line containing `end'.
  2069. `document COMMANDNAME'
  2070.      Give documentation to the user-defined command COMMANDNAME.  The
  2071.      command COMMANDNAME must already be defined.  This command reads
  2072.      lines of documentation just as `define' reads the lines of the
  2073.      command definition, ending with `end'.  After the `document'
  2074.      command is finished, `help' on command COMMANDNAME will print the
  2075.      documentation you have specified.
  2076.      You may use the `document' command again to change the
  2077.      documentation of a command.  Redefining the command with `define'
  2078.      does not change the documentation.
  2079.    User-defined commands do not take arguments.  When they are
  2080. executed, the commands of the definition are not printed.  An error in
  2081. any command stops execution of the user-defined command.
  2082.    Commands that would ask for confirmation if used interactively
  2083. proceed without asking when used inside a user-defined command.  Many
  2084. GDB commands that normally print messages to say what they are doing
  2085. omit the messages when used in user-defined command.
  2086. File: gdb.info,  Node: Command Files,  Next: Output,  Prev: Define,  Up: Sequences
  2087. Command Files
  2088. =============
  2089.    A command file for GDB is a file of lines that are GDB commands.
  2090. Comments (lines starting with `#') may also be included.  An empty line
  2091. in a command file does nothing; it does not mean to repeat the last
  2092. command, as it would from the terminal.
  2093.    When GDB starts, it automatically executes its "init files", command
  2094. files named `.gdbinit'.  GDB reads the init file (if any) in your home
  2095. directory and then the init file (if any) in the current working
  2096. directory.  (The init files are not executed if the `-nx' option is
  2097. given.)  You can also request the execution of a command file with the
  2098. `source' command:
  2099. `source FILENAME'
  2100.      Execute the command file FILENAME.
  2101.    The lines in a command file are executed sequentially.  They are not
  2102. printed as they are executed.  An error in any command terminates
  2103. execution of the command file.
  2104.    Commands that would ask for confirmation if used interactively
  2105. proceed without asking when used in a command file.  Many GDB commands
  2106. that normally print messages to say what they are doing omit the
  2107. messages when used in a command file.
  2108. File: gdb.info,  Node: Output,  Prev: Command Files,  Up: Sequences
  2109. Commands for Controlled Output
  2110. ==============================
  2111.    During the execution of a command file or a user-defined command,
  2112. the only output that appears is what is explicitly printed by the
  2113. commands of the definition.  This section describes three commands
  2114. useful for generating exactly the output you want.
  2115. `echo TEXT'
  2116.      Print TEXT.  Nonprinting characters can be included in TEXT using
  2117.      C escape sequences, such as `\n' to print a newline.  No newline
  2118.      will be printed unless you specify one. In addition to the
  2119.      standard C escape sequences a backslash followed by a space stands
  2120.      for a space.  This is useful for outputting a string with spaces
  2121.      at the beginning or the end, since leading and trailing spaces are
  2122.      trimmed from all arguments.  Thus, to print " and foo = ", use the
  2123.      command "echo \ and foo = \ ".
  2124.      A backslash at the end of TEXT can be used, as in C, to continue
  2125.      the command onto subsequent lines.  For example,
  2126.           echo This is some text\n\
  2127.           which is continued\n\
  2128.           onto several lines.\n
  2129.      produces the same output as
  2130.           echo This is some text\n
  2131.           echo which is continued\n
  2132.           echo onto several lines.\n
  2133. `output EXPRESSION'
  2134.      Print the value of EXPRESSION and nothing but that value: no
  2135.      newlines, no `$NN = '.  The value is not entered in the value
  2136.      history either.  *Note Expressions:: for more information on
  2137.      expressions.
  2138. `output/FMT EXPRESSION'
  2139.      Print the value of EXPRESSION in format FMT.  *Note Output
  2140.      formats::, for more information.
  2141. `printf STRING, EXPRESSIONS...'
  2142.      Print the values of the EXPRESSIONS under the control of STRING.
  2143.      The EXPRESSIONS are separated by commas and may be either numbers
  2144.      or pointers.  Their values are printed as specified by STRING,
  2145.      exactly as if the program were to execute
  2146.           printf (STRING, EXPRESSIONS...);
  2147.      For example, you can print two values in hex like this:
  2148.           printf "foo, bar-foo = 0x%x, 0x%x\n", foo, bar-foo
  2149.      The only backslash-escape sequences that you can use in the string
  2150.      are the simple ones that consist of backslash followed by a letter.
  2151. File: gdb.info,  Node: Options,  Next: Emacs,  Prev: Sequences,  Up: Top
  2152. Options and Arguments for GDB
  2153. *****************************
  2154.    When you invoke GDB, you can specify arguments telling it what files
  2155. to operate on and what other things to do.
  2156. * Menu:
  2157. * Mode Options::     Options controlling modes of operation.
  2158. * File Options::     Options to specify files (executable, coredump, commands)
  2159. * Other Arguments::  Any other arguments without options
  2160.             also specify files.
  2161. File: gdb.info,  Node: Mode Options,  Next: File Options,  Prev: Options,  Up: Options
  2162. Mode Options
  2163. ============
  2164. `-nx'
  2165.      Do not execute commands from the init files `.gdbinit'.  Normally,
  2166.      the commands in these files are executed after all the command
  2167.      options and arguments have been processed.  *Note Command Files::.
  2168.      "Quiet".  Do not print the usual introductory messages.
  2169. `-batch'
  2170.      Run in batch mode.  Exit with code 0 after processing all the
  2171.      command files specified with `-x' (and `.gdbinit', if not
  2172.      inhibited).  Exit with nonzero status if an error occurs in
  2173.      executing the GDB commands in the command files.
  2174. `-fullname'
  2175.      This option is used when Emacs runs GDB as a subprocess.  It tells
  2176.      GDB to output the full file name and line number in a standard,
  2177.      recognizable fashion each time a stack frame is displayed (which
  2178.      includes each time the program stops).  This recognizable format
  2179.      looks like two `\032' characters, followed by the file name, line
  2180.      number and character position separated by colons, and a newline.
  2181.      The Emacs-to-GDB interface program uses the two `\032' characters
  2182.      as a signal to display the source code for the frame.
  2183. File: gdb.info,  Node: File Options,  Next: Other Arguments,  Prev: Mode Options,  Up: Options
  2184. File-specifying Options
  2185. =======================
  2186.    All the options and command line arguments given are processed in
  2187. sequential order.  The order makes a difference when the `-x' option is
  2188. used.
  2189. `-s FILE'
  2190.      Read symbol table from file FILE.
  2191. `-e FILE'
  2192.      Use file FILE as the executable file to execute when appropriate,
  2193.      and for examining pure data in conjunction with a core dump.
  2194. `-se FILE'
  2195.      Read symbol table from file FILE and use it as the executable file.
  2196. `-c FILE'
  2197.      Use file FILE as a core dump to examine.
  2198. `-x FILE'
  2199.      Execute GDB commands from file FILE.
  2200. `-d DIRECTORY'
  2201.      Add DIRECTORY to the path to search for source files.
  2202. File: gdb.info,  Node: Other Arguments,  Prev: File Options,  Up: Options
  2203. Other Arguments
  2204. ===============
  2205.    If there are arguments to GDB that are not options or associated with
  2206. options, the first one specifies the symbol table and executable file
  2207. name (as if it were preceded by `-se') and the second one specifies a
  2208. core dump file name (as if it were preceded by `-c').
  2209. File: gdb.info,  Node: Emacs,  Next: Remote,  Prev: Options,  Up: Top
  2210. Using GDB under GNU Emacs
  2211. *************************
  2212.    A special interface allows you to use GNU Emacs to view (and edit)
  2213. the source files for the program you are debugging with GDB.
  2214.    To use this interface, use the command `M-x gdb' in Emacs.  Give the
  2215. executable file you want to debug as an argument.  This command starts
  2216. GDB as a subprocess of Emacs, with input and output through a newly
  2217. created Emacs buffer.
  2218.    Using GDB under Emacs is just like using GDB normally except for two
  2219. things:
  2220.    * All "terminal" input and output goes through the Emacs buffer.
  2221.      This applies both to GDB commands and their output, and to the
  2222.      input and output done by the program you are debugging.
  2223.      This is useful because it means that you can copy the text of
  2224.      previous commands and input them again; you can even use parts of
  2225.      the output in this way.
  2226.      All the facilities of Emacs's Shell mode are available for this
  2227.      purpose.
  2228.    * GDB displays source code through Emacs.  Each time GDB displays a
  2229.      stack frame, Emacs automatically finds the source file for that
  2230.      frame and puts an arrow (`=>') at the left margin of the current
  2231.      line.
  2232.      Explicit GDB `list' or search commands still produce output as
  2233.      usual, but you probably will have no reason to use them.
  2234.    In the GDB I/O buffer, you can use these special Emacs commands:
  2235. `M-s'
  2236.      Execute to another source line, like the GDB `step' command.
  2237. `M-n'
  2238.      Execute to next source line in this function, skipping all function
  2239.      calls, like the GDB `next' command.
  2240. `M-i'
  2241.      Execute one instruction, like the GDB `stepi' command.
  2242. `C-c C-f'
  2243.      Execute until exit from the selected stack frame, like the GDB
  2244.      `finish' command.
  2245. `M-c'
  2246.      Continue execution of the program, like the GDB `cont' command.
  2247. `M-u'
  2248.      Go up the number of frames indicated by the numeric argument
  2249.      (*note Numeric Arguments: (emacs)Arguments.), like the GDB `up'
  2250.      command.
  2251. `M-d'
  2252.      Go down the number of frames indicated by the numeric argument,
  2253.      like the GDB `down' command.
  2254.    In any source file, the Emacs command `C-x SPC' (`gdb-break') tells
  2255. GDB to set a breakpoint on the source line point is on.
  2256.    The source files displayed in Emacs are in ordinary Emacs buffers
  2257. which are visiting the source files in the usual way.  You can edit the
  2258. files with these buffers if you wish; but keep in mind that GDB
  2259. communicates with Emacs in terms of line numbers.  If you add or delete
  2260. lines from the text, the line numbers that GDB knows will cease to
  2261. correspond properly to the code.
  2262. File: gdb.info,  Node: Remote,  Next: Commands,  Prev: Emacs,  Up: Top
  2263. Remote Kernel Debugging
  2264. ***********************
  2265.    If you are trying to debug a program running on a machine that can't
  2266. run GDB in the usual way, it is often useful to use remote debugging.
  2267. For example, you might be debugging an operating system kernel, or
  2268. debugging a small system which does not have a general purpose
  2269. operating system powerful enough to run a full-featured debugger.
  2270. Currently GDB supports remote debugging over a serial connection.
  2271.    The program to be debugged on the remote machine needs to contain a
  2272. debugging device driver which talks to GDB over the serial line using
  2273. the protocol described below.  The same version of GDB that is used
  2274. ordinarily can be used for this.  Several sample remote debugging
  2275. drivers are distributed with GDB; see the `README' file in the GDB
  2276. distribution for more information.
  2277. * Menu:
  2278. * Remote Commands::       Commands used to start and finish remote debugging.
  2279.    For details of the communication protocol, see the comments in the
  2280. GDB source file `remote.c'.
  2281. File: gdb.info,  Node: Remote Commands,  Prev: Remote,  Up: Remote
  2282. Commands for Remote Debugging
  2283. =============================
  2284.    To start remote debugging, first run GDB and specify as an
  2285. executable file the program that is running in the remote machine.
  2286. This tells GDB how to find the program's symbols and the contents of
  2287. its pure text.  Then establish communication using the `attach' command
  2288. with a device name rather than a pid as an argument.  For example:
  2289.      attach /dev/ttyd
  2290. if the serial line is connected to the device named `/dev/ttyd'.  This
  2291. will stop the remote machine if it is not already stopped.
  2292.    Now you can use all the usual commands to examine and change data
  2293. and to step and continue the remote program.
  2294.    To resume the remote program and stop debugging it, use the `detach'
  2295. command.
  2296. File: gdb.info,  Node: Commands,  Next: Concepts,  Prev: Remote,  Up: Top
  2297. Command Index
  2298. *************
  2299. * Menu:
  2300. * $_:                                   Breakpoints.
  2301. * $_:                                   List.
  2302. * $_:                                   Memory.
  2303. * $__:                                  Memory.
  2304. * $$:                                   Value History.
  2305. * $:                                    Value History.
  2306. * .gdbinit:                             Command Files.
  2307. * abbreviation:                         User Interface.
  2308. * add-file:                             File Commands.
  2309. * arguments (to your program):          Arguments.
  2310. * artificial array:                     Arrays.
  2311. * assignment:                           Assignment.
  2312. * attach:                               Attach.
  2313. * attach:                               Attach.
  2314. * automatic display:                    Auto Display.
  2315. * backtrace:                            Backtrace.
  2316. * break:                                Set Breaks.
  2317. * breakpoint commands:                  Break Commands.
  2318. * breakpoint conditions:                Conditions.
  2319. * breakpoints:                          Breakpoints.
  2320. * bt:                                   Backtrace.
  2321. * call stack:                           Stack.
  2322. * cd:                                   Working Directory.
  2323. * clear:                                Delete Breaks.
  2324. * clearing breakpoint:                  Delete Breaks.
  2325. * command files:                        Command Files.
  2326. * condition:                            Conditions.
  2327. * conditional breakpoints:              Conditions.
  2328. * cont:                                 Continuing.
  2329. * controlling terminal:                 Input/Output.
  2330. * convenience variables:                Convenience Vars.
  2331. * core dump file:                       Files.
  2332. * core-file:                            File Commands.
  2333. * define:                               Define.
  2334. * delete:                               Delete Breaks.
  2335. * delete display:                       Auto Display.
  2336. * delete environment:                   Environment.
  2337. * deleting breakpoints:                 Delete Breaks.
  2338. * detach:                               Attach.
  2339. * directories for source files:         Source Path.
  2340. * directory:                            Source Path.
  2341. * disable:                              Disabling.
  2342. * disable breakpoints:                  Disabling.
  2343. * disable display:                      Auto Display.
  2344. * disabled breakpoints:                 Disabling.
  2345. * disassemble:                          Memory.
  2346. * display:                              Auto Display.
  2347. * display of expressions:               Auto Display.
  2348. * document:                             Define.
  2349. * down:                                 Selection.
  2350. * dynamic linking:                      File Commands.
  2351. * echo:                                 Output.
  2352. * enable:                               Disabling.
  2353. * enable breakpoints:                   Disabling.
  2354. * enable display:                       Auto Display.
  2355. * enabled breakpoints:                  Disabling.
  2356. * environment (of your program):        Environment.
  2357. * examining data:                       Data.
  2358. * examining memory:                     Memory.
  2359. * exec-file:                            File Commands.
  2360. * executable file:                      Files.
  2361. * exiting GDB:                          User Interface.
  2362. * expressions:                          Expressions.
  2363. * fatal signals:                        Signals.
  2364. * finish:                               Stepping.
  2365. * format options:                       Format options.
  2366. * formatted output:                     Output formats.
  2367. * forward-search:                       Search.
  2368. * frame:                                Frames.
  2369. * frame:                                Selection.
  2370. * frame number:                         Frames.
  2371. * frame pointer:                        Frames.
  2372. * frameless execution:                  Frames.
  2373. * handle:                               Signals.
  2374. * handling signals:                     Signals.
  2375. * history number:                       Value History.
  2376. * ignore:                               Conditions.
  2377. * ignore count (of breakpoint):         Conditions.
  2378. * info address:                         Symbols.
  2379. * info args:                            Frame Info.
  2380. * info break:                           Breakpoints.
  2381. * info convenience:                     Convenience Vars.
  2382. * info directories:                     Source Path.
  2383. * info display:                         Auto Display.
  2384. * info environment:                     Environment.
  2385. * info files:                           File Commands.
  2386. * info format:                          Format options.
  2387. * info frame:                           Frame Info.
  2388. * info functions:                       Symbols.
  2389. * info line:                            List.
  2390. * info locals:                          Frame Info.
  2391. * info registers:                       Registers.
  2392. * info signal:                          Signals.
  2393. * info sources:                         Symbols.
  2394. * info stack:                           Backtrace.
  2395. * info types:                           Symbols.
  2396. * info values:                          Value History.
  2397. * info variables:                       Symbols.
  2398. * init file:                            Command Files.
  2399. * initial frame:                        Frames.
  2400. * innermost frame:                      Frames.
  2401. * jump:                                 Jumping.
  2402. * kill:                                 Kill Process.
  2403. * linespec:                             List.
  2404. * list:                                 List.
  2405. * next:                                 Stepping.
  2406. * nexti:                                Stepping.
  2407. * ni:                                   Stepping.
  2408. * outermost frame:                      Frames.
  2409. * output:                               Output.
  2410. * output formats:                       Output formats.
  2411. * pauses in output:                     User Interface.
  2412. * print:                                Data.
  2413. * printf:                               Output.
  2414. * printing data:                        Data.
  2415. * printsyms:                            Symbols.
  2416. * prompt:                               User Interface.
  2417. * ptype:                                Symbols.
  2418. * pwd:                                  Working Directory.
  2419. * quit:                                 User Interface.
  2420. * redirection:                          Input/Output.
  2421. * registers:                            Registers.
  2422. * repeating commands:                   User Interface.
  2423. * return:                               Returning.
  2424. * returning from a function:            Returning.
  2425. * reverse-search:                       Search.
  2426. * run:                                  Running.
  2427. * running:                              Running.
  2428. * screen size:                          User Interface.
  2429. * searching:                            Search.
  2430. * selected frame:                       Frames.
  2431. * set:                                  Assignment.
  2432. * set args:                             Arguments.
  2433. * set array-max:                        Format options.
  2434. * set environment:                      Environment.
  2435. * set prettyprint:                      Format options.
  2436. * set prompt:                           User Interface.
  2437. * set screensize:                       User Interface.
  2438. * set unionprint:                       Format options.
  2439. * set variable:                         Assignment.
  2440. * set verbose:                          User Interface.
  2441. * setting variables:                    Assignment.
  2442. * si:                                   Stepping.
  2443. * signal:                               Signaling.
  2444. * signals:                              Signals.
  2445. * silent:                               Break Commands.
  2446. * source:                               Command Files.
  2447. * source path:                          Source Path.
  2448. * stack frame:                          Frames.
  2449. * step:                                 Stepping.
  2450. * stepi:                                Stepping.
  2451. * stepping:                             Stepping.
  2452. * symbol table:                         Files.
  2453. * symbol-file:                          File Commands.
  2454. * tbreak:                               Set Breaks.
  2455. * tty:                                  Input/Output.
  2456. * undisplay:                            Auto Display.
  2457. * unset environment:                    Environment.
  2458. * until:                                Stepping.
  2459. * up:                                   Selection.
  2460. * user-defined command:                 Define.
  2461. * value history:                        Value History.
  2462. * whatis:                               Symbols.
  2463. * where:                                Backtrace.
  2464. * word:                                 Memory.
  2465. * working directory (of your program):  Working Directory.
  2466. * x:                                    Memory.
  2467. File: gdb.info,  Node: Concepts,  Prev: Commands,  Up: Top
  2468. Concept Index
  2469. *************
  2470. * Menu:
  2471. * $_:                                   Breakpoints.
  2472. * $_:                                   List.
  2473. * $_:                                   Memory.
  2474. * $__:                                  Memory.
  2475. * $$:                                   Value History.
  2476. * $:                                    Value History.
  2477. * .gdbinit:                             Command Files.
  2478. * abbreviation:                         User Interface.
  2479. * add-file:                             File Commands.
  2480. * arguments (to your program):          Arguments.
  2481. * artificial array:                     Arrays.
  2482. * assignment:                           Assignment.
  2483. * attach:                               Attach.
  2484. * attach:                               Attach.
  2485. * automatic display:                    Auto Display.
  2486. * backtrace:                            Backtrace.
  2487. * break:                                Set Breaks.
  2488. * breakpoint commands:                  Break Commands.
  2489. * breakpoint conditions:                Conditions.
  2490. * breakpoints:                          Breakpoints.
  2491. * bt:                                   Backtrace.
  2492. * call stack:                           Stack.
  2493. * cd:                                   Working Directory.
  2494. * clear:                                Delete Breaks.
  2495. * clearing breakpoint:                  Delete Breaks.
  2496. * command files:                        Command Files.
  2497. * condition:                            Conditions.
  2498. * conditional breakpoints:              Conditions.
  2499. * cont:                                 Continuing.
  2500. * controlling terminal:                 Input/Output.
  2501. * convenience variables:                Convenience Vars.
  2502. * core dump file:                       Files.
  2503. * core-file:                            File Commands.
  2504. * define:                               Define.
  2505. * delete:                               Delete Breaks.
  2506. * delete display:                       Auto Display.
  2507. * delete environment:                   Environment.
  2508. * deleting breakpoints:                 Delete Breaks.
  2509. * detach:                               Attach.
  2510. * directories for source files:         Source Path.
  2511. * directory:                            Source Path.
  2512. * disable:                              Disabling.
  2513. * disable breakpoints:                  Disabling.
  2514. * disable display:                      Auto Display.
  2515. * disabled breakpoints:                 Disabling.
  2516. * disassemble:                          Memory.
  2517. * display:                              Auto Display.
  2518. * display of expressions:               Auto Display.
  2519. * document:                             Define.
  2520. * down:                                 Selection.
  2521. * dynamic linking:                      File Commands.
  2522. * echo:                                 Output.
  2523. * enable:                               Disabling.
  2524. * enable breakpoints:                   Disabling.
  2525. * enable display:                       Auto Display.
  2526. * enabled breakpoints:                  Disabling.
  2527. * environment (of your program):        Environment.
  2528. * examining data:                       Data.
  2529. * examining memory:                     Memory.
  2530. * exec-file:                            File Commands.
  2531. * executable file:                      Files.
  2532. * exiting GDB:                          User Interface.
  2533. * expressions:                          Expressions.
  2534. * fatal signals:                        Signals.
  2535. * finish:                               Stepping.
  2536. * format options:                       Format options.
  2537. * formatted output:                     Output formats.
  2538. * forward-search:                       Search.
  2539. * frame:                                Frames.
  2540. * frame:                                Selection.
  2541. * frame number:                         Frames.
  2542. * frame pointer:                        Frames.
  2543. * frameless execution:                  Frames.
  2544. * handle:                               Signals.
  2545. * handling signals:                     Signals.
  2546. * history number:                       Value History.
  2547. * ignore:                               Conditions.
  2548. * ignore count (of breakpoint):         Conditions.
  2549. * info address:                         Symbols.
  2550. * info args:                            Frame Info.
  2551. * info break:                           Breakpoints.
  2552. * info convenience:                     Convenience Vars.
  2553. * info directories:                     Source Path.
  2554. * info display:                         Auto Display.
  2555. * info environment:                     Environment.
  2556. * info files:                           File Commands.
  2557. * info format:                          Format options.
  2558. * info frame:                           Frame Info.
  2559. * info functions:                       Symbols.
  2560. * info line:                            List.
  2561. * info locals:                          Frame Info.
  2562. * info registers:                       Registers.
  2563. * info signal:                          Signals.
  2564. * info sources:                         Symbols.
  2565. * info stack:                           Backtrace.
  2566. * info types:                           Symbols.
  2567. * info values:                          Value History.
  2568. * info variables:                       Symbols.
  2569. * init file:                            Command Files.
  2570. * initial frame:                        Frames.
  2571. * innermost frame:                      Frames.
  2572. * jump:                                 Jumping.
  2573. * kill:                                 Kill Process.
  2574. * linespec:                             List.
  2575. * list:                                 List.
  2576. * next:                                 Stepping.
  2577. * nexti:                                Stepping.
  2578. * ni:                                   Stepping.
  2579. * outermost frame:                      Frames.
  2580. * output:                               Output.
  2581. * output formats:                       Output formats.
  2582. * pauses in output:                     User Interface.
  2583. * print:                                Data.
  2584. * printf:                               Output.
  2585. * printing data:                        Data.
  2586. * printsyms:                            Symbols.
  2587. * prompt:                               User Interface.
  2588. * ptype:                                Symbols.
  2589. * pwd:                                  Working Directory.
  2590. * quit:                                 User Interface.
  2591. * redirection:                          Input/Output.
  2592. * registers:                            Registers.
  2593. * repeating commands:                   User Interface.
  2594. * return:                               Returning.
  2595. * returning from a function:            Returning.
  2596. * reverse-search:                       Search.
  2597. * run:                                  Running.
  2598. * running:                              Running.
  2599. * screen size:                          User Interface.
  2600. * searching:                            Search.
  2601. * selected frame:                       Frames.
  2602. * set:                                  Assignment.
  2603. * set args:                             Arguments.
  2604. * set array-max:                        Format options.
  2605. * set environment:                      Environment.
  2606. * set prettyprint:                      Format options.
  2607. * set prompt:                           User Interface.
  2608. * set screensize:                       User Interface.
  2609. * set unionprint:                       Format options.
  2610. * set variable:                         Assignment.
  2611. * set verbose:                          User Interface.
  2612. * setting variables:                    Assignment.
  2613. * si:                                   Stepping.
  2614. * signal:                               Signaling.
  2615. * signals:                              Signals.
  2616. * silent:                               Break Commands.
  2617. * source:                               Command Files.
  2618. * source path:                          Source Path.
  2619. * stack frame:                          Frames.
  2620. * step:                                 Stepping.
  2621. * stepi:                                Stepping.
  2622. * stepping:                             Stepping.
  2623. * symbol table:                         Files.
  2624. * symbol-file:                          File Commands.
  2625. * tbreak:                               Set Breaks.
  2626. * tty:                                  Input/Output.
  2627. * undisplay:                            Auto Display.
  2628. * unset environment:                    Environment.
  2629. * until:                                Stepping.
  2630. * up:                                   Selection.
  2631. * user-defined command:                 Define.
  2632. * value history:                        Value History.
  2633. * whatis:                               Symbols.
  2634. * where:                                Backtrace.
  2635. * word:                                 Memory.
  2636. * working directory (of your program):  Working Directory.
  2637. * x:                                    Memory.
  2638. Tag Table:
  2639. Node: Top
  2640. Node: License
  2641. Node: User Interface
  2642. 16277
  2643. Node: Files
  2644. 19946
  2645. Node: File Arguments
  2646. 20503
  2647. Node: File Commands
  2648. 21222
  2649. Node: Compilation
  2650. 25475
  2651. Node: Running
  2652. 26564
  2653. Node: Arguments
  2654. 28735
  2655. Node: Environment
  2656. 29487
  2657. Node: Working Directory
  2658. 31503
  2659. Node: Input/Output
  2660. 32212
  2661. Node: Attach
  2662. 33517
  2663. Node: Kill Process
  2664. 35108
  2665. Node: Stopping
  2666. 36140
  2667. Node: Signals
  2668. 36947
  2669. Node: Breakpoints
  2670. 40357
  2671. Node: Set Breaks
  2672. 42078
  2673. Node: Delete Breaks
  2674. 45039
  2675. Node: Disabling
  2676. 46427
  2677. Node: Conditions
  2678. 48997
  2679. Node: Break Commands
  2680. 52346
  2681. Node: Error in Breakpoints
  2682. 55814
  2683. Node: Continuing
  2684. 56709
  2685. Node: Stepping
  2686. 58205
  2687. Node: Stack
  2688. 62807
  2689. Node: Frames
  2690. 64228
  2691. Node: Backtrace
  2692. 66667
  2693. Node: Selection
  2694. 68694
  2695. Node: Frame Info
  2696. 70637
  2697. Node: Source
  2698. 72203
  2699. Node: List
  2700. 72885
  2701. Node: Search
  2702. 76501
  2703. Node: Source Path
  2704. 77186
  2705. Node: Data
  2706. 79351
  2707. Node: Expressions
  2708. 80668
  2709. Node: Variables
  2710. 81996
  2711. Node: Arrays
  2712. 83323
  2713. Node: Format options
  2714. 84601
  2715. Node: Output formats
  2716. 86495
  2717. Node: Memory
  2718. 88109
  2719. Node: Auto Display
  2720. 93509
  2721. Node: Value History
  2722. 96226
  2723. Node: Convenience Vars
  2724. 98018
  2725. Node: Registers
  2726. 100207
  2727. Node: Symbols
  2728. 103298
  2729. Node: Altering
  2730. 105913
  2731. Node: Assignment
  2732. 106746
  2733. Node: Jumping
  2734. 108477
  2735. Node: Signaling
  2736. 110899
  2737. Node: Returning
  2738. 111460
  2739. Node: Sequences
  2740. 112605
  2741. Node: Define
  2742. 113068
  2743. Node: Command Files
  2744. 114749
  2745. Node: Output
  2746. 115949
  2747. Node: Options
  2748. 118214
  2749. Node: Mode Options
  2750. 118697
  2751. Node: File Options
  2752. 119925
  2753. Node: Other Arguments
  2754. 120688
  2755. Node: Emacs
  2756. 121066
  2757. Node: Remote
  2758. 123722
  2759. Node: Remote Commands
  2760. 124815
  2761. Node: Commands
  2762. 125635
  2763. Node: Concepts
  2764. 134378
  2765. End Tag Table
  2766.