home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / unix / info / gdb.i05 < prev    next >
Encoding:
GNU Info File  |  1993-06-12  |  50.4 KB  |  1,258 lines

  1. This is Info file gdb.info, produced by Makeinfo-1.47 from the input
  2. file gdb-all.tex.
  3.  
  4. START-INFO-DIR-ENTRY
  5. * Gdb: (gdb).                   The GNU debugger.
  6. END-INFO-DIR-ENTRY
  7.    This file documents the GNU debugger GDB.
  8.  
  9.    This is Edition 4.06, October 1992, of `Debugging with GDB: the GNU
  10. Source-Level Debugger' for GDB Version 4.7.
  11.  
  12.    Copyright (C) 1988, 1989, 1990, 1991, 1992 Free Software Foundation,
  13. Inc.
  14.  
  15.    Permission is granted to make and distribute verbatim copies of this
  16. manual provided the copyright notice and this permission notice are
  17. preserved on all copies.
  18.  
  19.    Permission is granted to copy and distribute modified versions of
  20. this manual under the conditions for verbatim copying, provided also
  21. that the section entitled "GNU General Public License" is included
  22. exactly as in the original, and provided that the entire resulting
  23. derived work is distributed under the terms of a permission notice
  24. identical to this one.
  25.  
  26.    Permission is granted to copy and distribute translations of this
  27. manual into another language, under the above conditions for modified
  28. versions, except that the section entitled "GNU General Public License"
  29. may be included in a translation approved by the Free Software
  30. Foundation instead of in the original English.
  31.  
  32. 
  33. File: gdb.info,  Node: Returning,  Next: Calling,  Prev: Signaling,  Up: Altering
  34.  
  35. Returning from a Function
  36. =========================
  37.  
  38. `return'
  39. `return EXPRESSION'
  40.      You can cancel execution of a function call with the `return'
  41.      command.  If you give an EXPRESSION argument, its value is used as
  42.      the function's return value.
  43.  
  44.    When you use `return', GDB discards the selected stack frame (and
  45. all frames within it).  You can think of this as making the discarded
  46. frame return prematurely.  If you wish to specify a value to be
  47. returned, give that value as the argument to `return'.
  48.  
  49.    This pops the selected stack frame (*note Selecting a Frame:
  50. Selection.), and any other frames inside of it, leaving its caller as
  51. the innermost remaining frame.  That frame becomes selected.  The
  52. specified value is stored in the registers used for returning values of
  53. functions.
  54.  
  55.    The `return' command does not resume execution; it leaves the
  56. program stopped in the state that would exist if the function had just
  57. returned.  In contrast, the `finish' command (*note Continuing and
  58. Stepping: Continuing and Stepping.) resumes execution until the
  59. selected stack frame returns naturally.
  60.  
  61. 
  62. File: gdb.info,  Node: Calling,  Next: Patching,  Prev: Returning,  Up: Altering
  63.  
  64. Calling your Program's Functions
  65. ================================
  66.  
  67. `call EXPR'
  68.      Evaluate the expression EXPR without displaying `void' returned
  69.      values.
  70.  
  71.    You can use this variant of the `print' command if you want to
  72. execute a function from your program, but without cluttering the output
  73. with `void' returned values.  The result is printed and saved in the
  74. value history, if it is not void.
  75.  
  76. 
  77. File: gdb.info,  Node: Patching,  Prev: Calling,  Up: Altering
  78.  
  79. Patching your Program
  80. =====================
  81.  
  82.    By default, GDB opens the file containing your program's executable
  83. code (or the corefile) read-only.  This prevents accidental alterations
  84. to machine code; but it also prevents you from intentionally patching
  85. your program's binary.
  86.  
  87.    If you'd like to be able to patch the binary, you can specify that
  88. explicitly with the `set write' command.  For example, you might want
  89. to turn on internal debugging flags, or even to make emergency repairs.
  90.  
  91. `set write on'
  92. `set write off'
  93.      If you specify `set write on', GDB will open executable and core
  94.      files for both reading and writing; if you specify `set write off'
  95.      (the default), GDB will open them read-only.
  96.  
  97.      If you have already loaded a file, you must load it again (using
  98.      the `exec-file' or `core-file' command) after changing `set
  99.      write', for your new setting to take effect.
  100.  
  101. `show write'
  102.      Display whether executable files and core files will be opened for
  103.      writing as well as reading.
  104.  
  105. 
  106. File: gdb.info,  Node: GDB Files,  Next: Targets,  Prev: Altering,  Up: Top
  107.  
  108. GDB's Files
  109. ***********
  110.  
  111.    GDB needs to know the file name of the program to be debugged, both
  112. in order to read its symbol table and in order to start your program.
  113. To debug a core dump of a previous run, GDB must be told the file name
  114. of the core dump.
  115.  
  116. * Menu:
  117.  
  118. * Files::                       Commands to Specify Files
  119. * Symbol Errors::               Errors Reading Symbol Files
  120.  
  121. 
  122. File: gdb.info,  Node: Files,  Next: Symbol Errors,  Up: GDB Files
  123.  
  124. Commands to Specify Files
  125. =========================
  126.  
  127.    The usual way to specify executable and core dump file names is with
  128. the command arguments given when you start GDB, (*note Getting In and
  129. Out of GDB: Invocation..
  130.  
  131.    Occasionally it is necessary to change to a different file during a
  132. GDB session.  Or you may run GDB and forget to specify a file you want
  133. to use.  In these situations the GDB commands to specify new files are
  134. useful.
  135.  
  136. `file FILENAME'
  137.      Use FILENAME as the program to be debugged.  It is read for its
  138.      symbols and for the contents of pure memory.  It is also the
  139.      program executed when you use the `run' command.  If you do not
  140.      specify a directory and the file is not found in GDB's working
  141.      directory, GDB uses the environment variable `PATH' as a list of
  142.      directories to search, just as the shell does when looking for a
  143.      program to run.  You can change the value of this variable, for
  144.      both GDB and your program, using the `path' command.
  145.  
  146.      On systems with memory-mapped files, an auxiliary symbol table file
  147.      `FILENAME.syms' may be available for FILENAME.  If it is, GDB will
  148.      map in the symbol table from `FILENAME.syms', starting up more
  149.      quickly.  See the descriptions of the options `-mapped' and
  150.      `-readnow' (available on the command line, and with the commands
  151.      `file', `symbol-file', or `add-symbol-file'), for more information.
  152.  
  153. `file'
  154.      `file' with no argument makes GDB discard any information it has
  155.      on both executable file and the symbol table.
  156.  
  157. `exec-file [ FILENAME ]'
  158.      Specify that the program to be run (but not the symbol table) is
  159.      found in FILENAME.  GDB will search the environment variable `PATH'
  160.      if necessary to locate your program.  Omitting FILENAME means to
  161.      discard information on the executable file.
  162.  
  163. `symbol-file [ FILENAME ]'
  164.      Read symbol table information from file FILENAME.  `PATH' is
  165.      searched when necessary.  Use the `file' command to get both symbol
  166.      table and program to run from the same file.
  167.  
  168.      `symbol-file' with no argument clears out GDB's information on your
  169.      program's symbol table.
  170.  
  171.      The `symbol-file' command causes GDB to forget the contents of its
  172.      convenience variables, the value history, and all breakpoints and
  173.      auto-display expressions.  This is because they may contain
  174.      pointers to the internal data recording symbols and data types,
  175.      which are part of the old symbol table data being discarded inside
  176.      GDB.
  177.  
  178.      `symbol-file' will not repeat if you press RET again after
  179.      executing it once.
  180.  
  181.      When GDB is configured for a particular environment, it will
  182.      understand debugging information in whatever format is the standard
  183.      generated for that environment; you may use either a GNU compiler,
  184.      or other compilers that adhere to the local conventions.  Best
  185.      results are usually obtained from GNU compilers; for example,
  186.      using `gcc' you can generate debugging information for optimized
  187.      code.
  188.  
  189.      On some kinds of object files, the `symbol-file' command does not
  190.      normally read the symbol table in full right away.  Instead, it
  191.      scans the symbol table quickly to find which source files and
  192.      which symbols are present.  The details are read later, one source
  193.      file at a time, as they are needed.
  194.  
  195.      The purpose of this two-stage reading strategy is to make GDB
  196.      start up faster.  For the most part, it is invisible except for
  197.      occasional pauses while the symbol table details for a particular
  198.      source file are being read.  (The `set verbose' command can turn
  199.      these pauses into messages if desired. *Note Optional Warnings and
  200.      Messages: Messages/Warnings.)
  201.  
  202.      When the symbol table is stored in COFF format, `symbol-file' does
  203.      read the symbol table data in full right away.  We have not
  204.      implemented the two-stage strategy for COFF yet.
  205.  
  206. `symbol-file FILENAME [ -readnow ] [ -mapped ]'
  207. `file FILENAME [ -readnow ] [ -mapped ]'
  208.      You can override the GDB two-stage strategy for reading symbol
  209.      tables by using the `-readnow' option with any of the commands that
  210.      load symbol table information, if you want to be sure GDB has the
  211.      entire symbol table available.
  212.  
  213.      If memory-mapped files are available on your system through the
  214.      `mmap' system call, you can use another option, `-mapped', to
  215.      cause GDB to write the symbols for your program into a reusable
  216.      file.  Future GDB debugging sessions will map in symbol information
  217.      from this auxiliary symbol file (if the program hasn't changed),
  218.      rather than spending time reading the symbol table from the
  219.      executable program.  Using the `-mapped' option has the same
  220.      effect as starting GDB with the `-mapped' command-line option.
  221.  
  222.      You can use both options together, to make sure the auxiliary
  223.      symbol file has all the symbol information for your program.
  224.  
  225.      The `.syms' file is specific to the host machine on which GDB is
  226.      run. It holds an exact image of GDB's internal symbol table.  It
  227.      cannot be shared across multiple host platforms.
  228.  
  229.      The auxiliary symbol file for a program called MYPROG is called
  230.      `MYPROG.syms'.  Once this file exists (so long as it is newer than
  231.      the corresponding executable), GDB will always attempt to use it
  232.      when you debug MYPROG; no special options or commands are needed.
  233.  
  234. `core-file [ FILENAME ]'
  235.      Specify the whereabouts of a core dump file to be used as the
  236.      "contents of memory".  Traditionally, core files contain only some
  237.      parts of the address space of the process that generated them; GDB
  238.      can access the executable file itself for other parts.
  239.  
  240.      `core-file' with no argument specifies that no core file is to be
  241.      used.
  242.  
  243.      Note that the core file is ignored when your program is actually
  244.      running under GDB.  So, if you have been running your program and
  245.      you wish to debug a core file instead, you must kill the
  246.      subprocess in which the program is running.  To do this, use the
  247.      `kill' command (*note Killing the Child Process: Kill Process.).
  248.  
  249. `load FILENAME'
  250.      Depending on what remote debugging facilities are configured into
  251.      GDB, the `load' command may be available.  Where it exists, it is
  252.      meant to make FILENAME (an executable) available for debugging on
  253.      the remote system--by downloading, or dynamic linking, for example.
  254.      `load' also records FILENAME's symbol table in GDB, like the
  255.      `add-symbol-file' command.
  256.  
  257.      If `load' is not available on your GDB, attempting to execute it
  258.      gets the error message "`You can't do that when your target is
  259.      ...'"
  260.  
  261.      On VxWorks, `load' will dynamically link FILENAME on the current
  262.      target system as well as adding its symbols in GDB.
  263.  
  264.      With the Nindy interface to an Intel 960 board, `load' will
  265.      download FILENAME to the 960 as well as adding its symbols in GDB.
  266.  
  267.      When you select remote debugging to a Hitachi H8/300 board (*note
  268.      GDB and the Hitachi H8/300: Hitachi H8/300 Remote.), the `load'
  269.      command downloads your program to the H8/300 and also opens it as
  270.      the current executable target for GDB on your host (like the
  271.      `file' command).
  272.  
  273.      `load' will not repeat if you press RET again after using it.
  274.  
  275. `add-symbol-file FILENAME ADDRESS'
  276. `add-symbol-file FILENAME ADDRESS [ -readnow ] [ -mapped ]'
  277.      The `add-symbol-file' command reads additional symbol table
  278.      information from the file FILENAME.  You would use this command
  279.      when FILENAME has been dynamically loaded (by some other means)
  280.      into the program that is running.  ADDRESS should be the memory
  281.      address at which the file has been loaded; GDB cannot figure this
  282.      out for itself.
  283.  
  284.      The symbol table of the file FILENAME is added to the symbol table
  285.      originally read with the `symbol-file' command.  You can use the
  286.      `add-symbol-file' command any number of times; the new symbol data
  287.      thus read keeps adding to the old.  To discard all old symbol data
  288.      instead, use the `symbol-file' command.
  289.  
  290.      `add-symbol-file' will not repeat if you press RET after using it.
  291.  
  292.      You can use the `-mapped' and `-readnow' options just as with the
  293.      `symbol-file' command, to change how GDB manages the symbol table
  294.      information for FILENAME.
  295.  
  296. `info files'
  297. `info target'
  298.      `info files' and `info target' are synonymous; both print the
  299.      current targets (*note Specifying a Debugging Target: Targets.),
  300.      including the names of the executable and core dump files
  301.      currently in use by GDB, and the files from which symbols were
  302.      loaded.  The command `help targets' lists all possible targets
  303.      rather than current ones.
  304.  
  305.    All file-specifying commands allow both absolute and relative file
  306. names as arguments.  GDB always converts the file name to an absolute
  307. path name and remembers it that way.
  308.  
  309.    GDB supports SunOS, SVR4, and IBM RS/6000 shared libraries. GDB
  310. automatically loads symbol definitions from shared libraries when you
  311. use the `run' command, or when you examine a core file. (Before you
  312. issue the `run' command, GDB will not understand references to a
  313. function in a shared library, however--unless you are debugging a core
  314. file).
  315.  
  316. `info share'
  317. `info sharedlibrary'
  318.      Print the names of the shared libraries which are currently loaded.
  319.  
  320. `sharedlibrary REGEX'
  321. `share REGEX'
  322.      This is an obsolescent command; you can use it to explicitly load
  323.      shared object library symbols for files matching a UNIX regular
  324.      expression, but as with files loaded automatically, it will only
  325.      load shared libraries required by your program for a core file or
  326.      after typing `run'.  If REGEX is omitted all shared libraries
  327.      required by your program are loaded.
  328.  
  329. 
  330. File: gdb.info,  Node: Symbol Errors,  Prev: Files,  Up: GDB Files
  331.  
  332. Errors Reading Symbol Files
  333. ===========================
  334.  
  335.    While reading a symbol file, GDB will occasionally encounter
  336. problems, such as symbol types it does not recognize, or known bugs in
  337. compiler output.  By default, GDB does not notify you of such problems,
  338. since they are relatively common and primarily of interest to people
  339. debugging compilers.  If you are interested in seeing information about
  340. ill-constructed symbol tables, you can either ask GDB to print only one
  341. message about each such type of problem, no matter how many times the
  342. problem occurs; or you can ask GDB to print more messages, to see how
  343. many times the problems occur, with the `set complaints' command (*note
  344. Optional Warnings and Messages: Messages/Warnings.).
  345.  
  346.    The messages currently printed, and their meanings, are:
  347.  
  348. `inner block not inside outer block in SYMBOL'
  349.      The symbol information shows where symbol scopes begin and end
  350.      (such as at the start of a function or a block of statements). 
  351.      This error indicates that an inner scope block is not fully
  352.      contained in its outer scope blocks.
  353.  
  354.      GDB circumvents the problem by treating the inner block as if it
  355.      had the same scope as the outer block.  In the error message,
  356.      SYMBOL may be shown as "`(don't know)'" if the outer block is not a
  357.      function.
  358.  
  359. `block at ADDRESS out of order'
  360.      The symbol information for symbol scope blocks should occur in
  361.      order of increasing addresses.  This error indicates that it does
  362.      not do so.
  363.  
  364.      GDB does not circumvent this problem, and will have trouble
  365.      locating symbols in the source file whose symbols being read. 
  366.      (You can often determine what source file is affected by
  367.      specifying `set verbose on'.  *Note Optional Warnings and
  368.      Messages: Messages/Warnings.)
  369.  
  370. `bad block start address patched'
  371.      The symbol information for a symbol scope block has a start address
  372.      smaller than the address of the preceding source line.  This is
  373.      known to occur in the SunOS 4.1.1 (and earlier) C compiler.
  374.  
  375.      GDB circumvents the problem by treating the symbol scope block as
  376.      starting on the previous source line.
  377.  
  378. `bad string table offset in symbol N'
  379.      Symbol number N contains a pointer into the string table which is
  380.      larger than the size of the string table.
  381.  
  382.      GDB circumvents the problem by considering the symbol to have the
  383.      name `foo', which may cause other problems if many symbols end up
  384.      with this name.
  385.  
  386. `unknown symbol type `0xNN''
  387.      The symbol information contains new data types that GDB does not
  388.      yet know how to read.  `0xNN' is the symbol type of the
  389.      misunderstood information, in hexadecimal.
  390.  
  391.      GDB circumvents the error by ignoring this symbol information. 
  392.      This will usually allow your program to be debugged, though
  393.      certain symbols will not be accessible.  If you encounter such a
  394.      problem and feel like debugging it, you can debug `gdb' with
  395.      itself, breakpoint on `complain', then go up to the function
  396.      `read_dbx_symtab' and examine `*bufp' to see the symbol.
  397.  
  398. `stub type has NULL name'
  399.      GDB could not find the full definition for a struct or class.
  400.  
  401. `const/volatile indicator missing (ok if using g++ v1.x), got...'
  402.      The symbol information for a C++ member function is missing some
  403.      information that recent versions of the compiler should have output
  404.      for it.
  405.  
  406. `info mismatch between compiler and debugger'
  407.      GDB could not parse a type specification output by the compiler.
  408.  
  409. 
  410. File: gdb.info,  Node: Targets,  Next: Controlling GDB,  Prev: GDB Files,  Up: Top
  411.  
  412. Specifying a Debugging Target
  413. *****************************
  414.  
  415.    A "target" is the execution environment occupied by your program.
  416. Often, GDB runs in the same host environment as your program; in that
  417. case, the debugging target is specified as a side effect when you use
  418. the `file' or `core' commands.  When you need more flexibility--for
  419. example, running GDB on a physically separate host, or controlling a
  420. standalone system over a serial port or a realtime system over a TCP/IP
  421. connection--you can use the `target' command to specify one of the
  422. target types configured for GDB (*note Commands for Managing Targets:
  423. Target Commands.).
  424.  
  425. * Menu:
  426.  
  427. * Active Targets::              Active Targets
  428. * Target Commands::             Commands for Managing Targets
  429. * Remote::                      Remote Debugging
  430.  
  431. 
  432. File: gdb.info,  Node: Active Targets,  Next: Target Commands,  Up: Targets
  433.  
  434. Active Targets
  435. ==============
  436.  
  437.    There are three classes of targets: processes, core files, and
  438. executable files.  GDB can work concurrently on up to three active
  439. targets, one in each class.  This allows you to (for example) start a
  440. process and inspect its activity without abandoning your work on a core
  441. file.
  442.  
  443.    If, for example, you execute `gdb a.out', then the executable file
  444. `a.out' is the only active target.  If you designate a core file as
  445. well--presumably from a prior run that crashed and coredumped--then GDB
  446. has two active targets and will use them in tandem, looking first in
  447. the corefile target, then in the executable file, to satisfy requests
  448. for memory addresses.  (Typically, these two classes of target are
  449. complementary, since core files contain only a program's read-write
  450. memory--variables and so on--plus machine status, while executable
  451. files contain only the program text and initialized data.)
  452.  
  453.    When you type `run', your executable file becomes an active process
  454. target as well.  When a process target is active, all GDB commands
  455. requesting memory addresses refer to that target; addresses in an
  456. active core file or executable file target are obscured while the
  457. process target is active.
  458.  
  459.    Use the `core-file' and `exec-file' commands to select a new core
  460. file or executable target (*note Commands to Specify Files: Files.). 
  461. To specify as a target a process that is already running, use the
  462. `attach' command (*note Debugging an Already-Running Process: Attach..).
  463.  
  464. 
  465. File: gdb.info,  Node: Target Commands,  Next: Remote,  Prev: Active Targets,  Up: Targets
  466.  
  467. Commands for Managing Targets
  468. =============================
  469.  
  470. `target TYPE PARAMETERS'
  471.      Connects the GDB host environment to a target machine or process. 
  472.      A target is typically a protocol for talking to debugging
  473.      facilities.  You use the argument TYPE to specify the type or
  474.      protocol of the target machine.
  475.  
  476.      Further PARAMETERS are interpreted by the target protocol, but
  477.      typically include things like device names or host names to connect
  478.      with, process numbers, and baud rates.
  479.  
  480.      The `target' command will not repeat if you press RET again after
  481.      executing the command.
  482.  
  483. `help target'
  484.      Displays the names of all targets available.  To display targets
  485.      currently selected, use either `info target' or `info files'
  486.      (*note Commands to Specify Files: Files.).
  487.  
  488. `help target NAME'
  489.      Describe a particular target, including any parameters necessary to
  490.      select it.
  491.  
  492.    Here are some common targets (available, or not, depending on the GDB
  493. configuration):
  494.  
  495. `target exec PROG'
  496.      An executable file.  `target exec PROG' is the same as `exec-file
  497.      PROG'.
  498.  
  499. `target core FILENAME'
  500.      A core dump file.  `target core FILENAME' is the same as
  501.      `core-file FILENAME'.
  502.  
  503. `target remote DEV'
  504.      Remote serial target in GDB-specific protocol.  The argument DEV
  505.      specifies what serial device to use for the connection (e.g.
  506.      `/dev/ttya'). *Note Remote Debugging: Remote.
  507.  
  508. `target amd-eb DEV SPEED PROG'
  509.      Remote PC-resident AMD EB29K board, attached over serial lines.
  510.      DEV is the serial device, as for `target remote'; SPEED allows you
  511.      to specify the linespeed; and PROG is the name of the program to
  512.      be debugged, as it appears to DOS on the PC. *Note GDB with a
  513.      Remote EB29K: EB29K Remote.
  514.  
  515. `target hms'
  516.      A Hitachi H8/300 board, attached via serial line to your host.  Use
  517.      special commands `device' and `speed' to control the serial line
  518.      and the communications speed used. *Note GDB and the Hitachi
  519.      H8/300: Hitachi H8/300 Remote.
  520.  
  521. `target nindy DEVICENAME'
  522.      An Intel 960 board controlled by a Nindy Monitor.  DEVICENAME is
  523.      the name of the serial device to use for the connection, e.g.
  524.      `/dev/ttya'.  *Note GDB with a Remote i960 (Nindy): i960-Nindy
  525.      Remote.
  526.  
  527. `target st2000 DEV SPEED'
  528.      A Tandem ST2000 phone switch, running Tandem's STDBUG protocol. 
  529.      DEV is the name of the device attached to the ST2000 serial line;
  530.      SPEED is the communication line speed.  The arguments are not used
  531.      if GDB is configured to connect to the ST2000 using TCP or Telnet.
  532.      *Note GDB with a Tandem ST2000: ST2000 Remote.
  533.  
  534. `target vxworks MACHINENAME'
  535.      A VxWorks system, attached via TCP/IP.  The argument MACHINENAME
  536.      is the target system's machine name or IP address. *Note GDB and
  537.      VxWorks: VxWorks Remote.
  538.  
  539.    Different targets are available on different configurations of GDB;
  540. your configuration may have more or fewer targets.
  541.  
  542. 
  543. File: gdb.info,  Node: Remote,  Prev: Target Commands,  Up: Targets
  544.  
  545. Remote Debugging
  546. ================
  547.  
  548.    If you are trying to debug a program running on a machine that
  549. cannot run GDB in the usual way, it is often useful to use remote
  550. debugging.  For example, you might use remote debugging on an operating
  551. system kernel, or on a small system which does not have a general
  552. purpose operating system powerful enough to run a full-featured
  553. debugger.
  554.  
  555.    Some configurations of GDB have special serial or TCP/IP interfaces
  556. to make this work with particular debugging targets.  In addition, GDB
  557. comes with a generic serial protocol (specific to GDB, but not specific
  558. to any particular target system) which you can use if you write the
  559. remote stubs--the code that will run on the remote system to
  560. communicate with GDB.
  561.  
  562.    Other remote targets may be available in your configuration of GDB;
  563. use `help targets' to list them.
  564.  
  565. * Menu:
  566.  
  567. * Remote Serial::               GDB remote serial protocol
  568. * i960-Nindy Remote::        GDB with a remote i960 (Nindy)
  569. * EB29K Remote::        GDB with a remote EB29K
  570. * VxWorks Remote::        GDB and VxWorks
  571. * ST2000 Remote::               GDB with a Tandem ST2000
  572. * Hitachi H8/300 Remote::       GDB and the Hitachi H8/300
  573.  
  574. 
  575. File: gdb.info,  Node: Remote Serial,  Next: i960-Nindy Remote,  Up: Remote
  576.  
  577. The GDB remote serial protocol
  578. ------------------------------
  579.  
  580.    To debug a program running on another machine (the debugging
  581. "target" machine), you must first arrange for all the usual
  582. prerequisites for the program to run by itself.  For example, for a C
  583. program, you need
  584.  
  585.   1. A startup routine to set up the C runtime environment; these
  586.      usually have a name like `crt0'.  The startup routine may be
  587.      supplied by your hardware supplier, or you may have to write your
  588.      own.
  589.  
  590.   2. You probably need a C subroutine library to support your program's
  591.      subroutine calls, notably managing input and output.
  592.  
  593.   3. A way of getting your program to the other machine--for example, a
  594.      download program.  These are often supplied by the hardware
  595.      manufacturer, but you may have to write your own from hardware
  596.      documentation.
  597.  
  598.    The next step is to arrange for your program to use a serial port to
  599. communicate with the machine where GDB is running (the "host" machine).
  600.  In general terms, the scheme looks like this:
  601.  
  602. *On the host,*
  603.      GDB already understands how to use this protocol; when everything
  604.      else is set up, you can simply use the `target remote' command
  605.      (*note Specifying a Debugging Target: Targets.).
  606.  
  607. *On the target,*
  608.      you must link with your program a few special-purpose subroutines
  609.      that implement the GDB remote serial protocol.  The file
  610.      containing these subroutines is called  a "debugging stub".
  611.  
  612.    The debugging stub is specific to the architecture of the remote
  613. machine; for example, use `sparc-stub.c' to debug programs on SPARC
  614. boards.
  615.  
  616.    These working remote stubs are distributed with GDB:
  617.  
  618. `sparc-stub.c'
  619.      For SPARC architectures.
  620.  
  621. `m68k-stub.c'
  622.      For Motorola 680x0 architectures.
  623.  
  624. `i386-stub.c'
  625.      For Intel 386 and compatible architectures.
  626.  
  627.    The `README' file in the GDB distribution may list other recently
  628. added stubs.
  629.  
  630. * Menu:
  631.  
  632. * stub contents::       What the stub can do for you
  633. * bootstrapping::       What you must do for the stub
  634. * debug session::       Putting it all together
  635. * protocol::            Outline of the communication protocol
  636.  
  637. 
  638. File: gdb.info,  Node: stub contents,  Next: bootstrapping,  Up: Remote Serial
  639.  
  640. What the stub can do for you
  641. ............................
  642.  
  643.    The debugging stub for your architecture supplies these three
  644. subroutines:
  645.  
  646. `set_debug_traps'
  647.      This routine arranges to transfer control to `handle_exception'
  648.      when your program stops.  You must call this subroutine explicitly
  649.      near the beginning of your program.
  650.  
  651. `handle_exception'
  652.      This is the central workhorse, but your program never calls it
  653.      explicitly--the setup code arranges for `handle_exception' to run
  654.      when a trap is triggered.
  655.  
  656.      `handle_exception' takes control when your program stops during
  657.      execution (for example, on a breakpoint), and mediates
  658.      communications with GDB on the host machine.  This is where the
  659.      communications protocol is implemented; `handle_exception' acts as
  660.      the GDB representative on the target machine; it begins by sending
  661.      summary information on the state of your program, then continues
  662.      to execute, retrieving and transmitting any information GDB needs,
  663.      until you execute a GDB command that makes your program resume; at
  664.      that point, `handle_exception' returns control to your own code on
  665.      the target machine.
  666.  
  667. `breakpoint'
  668.      Use this auxiliary subroutine to make your program contain a
  669.      breakpoint.  Depending on the particular situation, this may be
  670.      the only way for GDB to get control.  For instance, if your target
  671.      machine has some sort of interrupt button, you won't need to call
  672.      this; pressing the interrupt button will transfer control to
  673.      `handle_exception'--in efect, to GDB.  On some machines, simply
  674.      receiving characters on the serial port may also trigger a trap;
  675.      again, in that situation, you don't need to call `breakpoint' from
  676.      your own program--simply running `target remote' from the host GDB
  677.      session will get control.
  678.  
  679.      Call `breakpoint' if none of these is true, or if you simply want
  680.      to make certain your program stops at a predetermined point for the
  681.      start of your debugging session.
  682.  
  683. 
  684. File: gdb.info,  Node: bootstrapping,  Next: debug session,  Prev: stub contents,  Up: Remote Serial
  685.  
  686. What you must do for the stub
  687. .............................
  688.  
  689.    The debugging stubs that come with GDB are set up for a particular
  690. chip architecture, but they have no information about the rest of your
  691. debugging target machine.  To allow the stub to work, you must supply
  692. these special low-level subroutines:
  693.  
  694. `int getDebugChar()'
  695.      Write this subroutine to read a single character from the serial
  696.      port. It may be identical to `getchar' for your target system; a
  697.      different name is used to allow you to distinguish the two if you
  698.      wish.
  699.  
  700. `void putDebugChar(int)'
  701.      Write this subroutine to write a single character to the serial
  702.      port. It may be identical to `putchar' for your target system; a
  703.      different name is used to allow you to distinguish the two if you
  704.      wish.
  705.  
  706. `void flush_i_cache()'
  707.      Write this subroutine to flush the instruction cache, if any, on
  708.      your target machine.  If there is no instruction cache, this
  709.      subroutine may be a no-op.
  710.  
  711.      On target machines that have instruction caches, GDB requires this
  712.      function to make certain that the state of your program is stable.
  713.  
  714. You must also make sure this library routine is available:
  715.  
  716. `void *memset(void *, int, int)'
  717.      This is the standard library function `memset' that sets an area of
  718.      memory to a known value.  If you have one of the free versions of
  719.      `libc.a', `memset' can be found there; otherwise, you must either
  720.      obtain it from your hardware manufacturer, or write your own.
  721.  
  722.    If you do not use the GNU C compiler, you may need other standard
  723. library subroutines as well; this will vary from one stub to another,
  724. but in general the stubs are likely to use any of the common library
  725. subroutines which `gcc' generates as inline code.
  726.  
  727. 
  728. File: gdb.info,  Node: debug session,  Next: protocol,  Prev: bootstrapping,  Up: Remote Serial
  729.  
  730. Putting it all together
  731. .......................
  732.  
  733.    In summary, when your program is ready to debug, you must follow
  734. these steps.
  735.  
  736.   1. Make sure you have the supporting low-level routines:
  737.      `getDebugChar', `putDebugChar', `flush_i_cache', `memset'.
  738.  
  739.   2. Insert these lines near the top of your program:
  740.  
  741.           set_debug_traps();
  742.           breakpoint();
  743.  
  744.   3. Compile and link together: your program, the GDB debugging stub for
  745.      your target architecture, and the supporting subroutines.
  746.  
  747.   4. Make sure you have a serial connection between your target machine
  748.      and the GDB host, and identify the serial port used for this on
  749.      the host.
  750.  
  751.   5. Download your program to your target machine (or get it there by
  752.      whatever means the manufacturer provides), and start it.
  753.  
  754.   6. To start remote debugging, run GDB on the host machine, and specify
  755.      as an executable file the program that is running in the remote
  756.      machine. This tells GDB how to find your program's symbols and the
  757.      contents of its pure text.
  758.  
  759.      Then establish communication using the `target remote' command.
  760.      Its argument is the name of the device you're using to control the
  761.      target machine.  For example:
  762.  
  763.           target remote /dev/ttyb
  764.  
  765.      if the serial line is connected to the device named `/dev/ttyb'.
  766.  
  767.  
  768.    Now you can use all the usual commands to examine and change data
  769. and to step and continue the remote program.
  770.  
  771.    To resume the remote program and stop debugging it, use the `detach'
  772. command.
  773.  
  774. 
  775. File: gdb.info,  Node: protocol,  Prev: debug session,  Up: Remote Serial
  776.  
  777. Outline of the communication protocol
  778. .....................................
  779.  
  780.    The stub files provided with GDB implement the target side of the
  781. communication protocol, and the GDB side is implemented in the GDB
  782. source file `remote.c'.  Normally, you can simply allow these
  783. subroutines to communicate, and ignore the details.  (If you're
  784. implementing your own stub file, you can still ignore the details: start
  785. with one of the existing stub files.  `sparc-stub.c' is the best
  786. organized, and therefore the easiest to read.)
  787.  
  788.    However, there may be occasions when you need to know something about
  789. the protocol--for example, if there is only one serial port to your
  790. target machine, you might want your program to do something special if
  791. it recognizes a packet meant for GDB.
  792.  
  793.    All GDB commands and responses (other than acknowledgements, which
  794. are single characters) are sent as a packet which includes a checksum. 
  795. A packet is introduced with the character `$', and ends with the
  796. character `#' followed by a two-digit checksum:
  797.  
  798.      $PACKET INFO#CHECKSUM
  799.  
  800. CHECKSUM is computed as the modulo 256 sum of the PACKET INFO
  801. characters.
  802.  
  803.    When either the host or the target machine receives a packet, the
  804. first response expected is an acknowledgement: a single character,
  805. either `+' (to indicate the package was received correctly) or `-' (to
  806. request retransmission).
  807.  
  808.    The host (GDB) sends commands, and the target (the debugging stub
  809. incorporated in your program) sends data in response.  The target also
  810. sends data when your program stops.
  811.  
  812.    Command packets are distinguished by their first character, which
  813. identifies the kind of command.
  814.  
  815.    These are the commands currently supported:
  816.  
  817. `g'
  818.      Requests the values of CPU registers.
  819.  
  820. `G'
  821.      Sets the values of CPU registers.
  822.  
  823. `mADDR,COUNT'
  824.      Read COUNT bytes at location ADDR.
  825.  
  826. `MADDR,COUNT:...'
  827.      Write COUNT bytes at location ADDR.
  828.  
  829. `c'
  830. `cADDR'
  831.      Resume execution at the current address (or at ADDR if supplied).
  832.  
  833. `s'
  834. `sADDR'
  835.      Step the target program for one instruction, from either the
  836.      current program counter or from ADDR if supplied.
  837.  
  838. `k'
  839.      Kill the target program.
  840.  
  841. `?'
  842.      Report the most recent signal.  To allow you to take advantage of
  843.      the GDB signal handling commands, one of the functions of the
  844.      debugging stub is to report CPU traps as the corresponding POSIX
  845.      signal values.
  846.  
  847.    If you have trouble with the serial connection, you can use the
  848. command `set remotedebug'.  This makes GDB report on all packets sent
  849. back and forth across the serial line to the remote machine.  The
  850. packet-debugging information is printed on the GDB standard output
  851. stream.  `set remotedebug off' turns it off, and `show remotedebug'
  852. will show you its current state.
  853.  
  854. 
  855. File: gdb.info,  Node: i960-Nindy Remote,  Next: EB29K Remote,  Prev: Remote Serial,  Up: Remote
  856.  
  857. GDB with a Remote i960 (Nindy)
  858. ------------------------------
  859.  
  860.    "Nindy" is a ROM Monitor program for Intel 960 target systems.  When
  861. GDB is configured to control a remote Intel 960 using Nindy, you can
  862. tell GDB how to connect to the 960 in several ways:
  863.  
  864.    * Through command line options specifying serial port, version of the
  865.      Nindy protocol, and communications speed;
  866.  
  867.    * By responding to a prompt on startup;
  868.  
  869.    * By using the `target' command at any point during your GDB
  870.      session.  *Note Commands for Managing Targets: Target Commands.
  871.  
  872. * Menu:
  873.  
  874. * Nindy Startup::               Startup with Nindy
  875. * Nindy Options::               Options for Nindy
  876. * Nindy reset::                 Nindy Reset Command
  877.  
  878. 
  879. File: gdb.info,  Node: Nindy Startup,  Next: Nindy Options,  Up: i960-Nindy Remote
  880.  
  881. Startup with Nindy
  882. ..................
  883.  
  884.    If you simply start `gdb' without using any command-line options,
  885. you are prompted for what serial port to use, *before* you reach the
  886. ordinary GDB prompt:
  887.  
  888.      Attach /dev/ttyNN -- specify NN, or "quit" to quit:
  889.  
  890. Respond to the prompt with whatever suffix (after `/dev/tty')
  891. identifies the serial port you want to use.  You can, if you choose,
  892. simply start up with no Nindy connection by responding to the prompt
  893. with an empty line.  If you do this, and later wish to attach to Nindy,
  894. use `target' (*note Commands for Managing Targets: Target Commands.).
  895.  
  896. 
  897. File: gdb.info,  Node: Nindy Options,  Next: Nindy reset,  Prev: Nindy Startup,  Up: i960-Nindy Remote
  898.  
  899. Options for Nindy
  900. .................
  901.  
  902.    These are the startup options for beginning your GDB session with a
  903. Nindy-960 board attached:
  904.  
  905. `-r PORT'
  906.      Specify the serial port name of a serial interface to be used to
  907.      connect to the target system.  This option is only available when
  908.      GDB is configured for the Intel 960 target architecture.  You may
  909.      specify PORT as any of: a full pathname (e.g. `-r /dev/ttya'), a
  910.      device name in `/dev' (e.g. `-r ttya'), or simply the unique
  911.      suffix for a specific `tty' (e.g. `-r a').
  912.  
  913. `-O'
  914.      (An uppercase letter "O", not a zero.)  Specify that GDB should use
  915.      the "old" Nindy monitor protocol to connect to the target system.
  916.      This option is only available when GDB is configured for the Intel
  917.      960 target architecture.
  918.  
  919.           *Warning:* if you specify `-O', but are actually trying to
  920.           connect to a target system that expects the newer protocol,
  921.           the connection will fail, appearing to be a speed mismatch. 
  922.           GDB will repeatedly attempt to reconnect at several different
  923.           line speeds.  You can abort this process with an interrupt.
  924.  
  925. `-brk'
  926.      Specify that GDB should first send a `BREAK' signal to the target
  927.      system, in an attempt to reset it, before connecting to a Nindy
  928.      target.
  929.  
  930.           *Warning:* Many target systems do not have the hardware that
  931.           this requires; it only works with a few boards.
  932.  
  933.    The standard `-b' option controls the line speed used on the serial
  934. port.
  935.  
  936. 
  937. File: gdb.info,  Node: Nindy reset,  Prev: Nindy Options,  Up: i960-Nindy Remote
  938.  
  939. Nindy Reset Command
  940. ...................
  941.  
  942. `reset'
  943.      For a Nindy target, this command sends a "break" to the remote
  944.      target system; this is only useful if the target has been equipped
  945.      with a circuit to perform a hard reset (or some other interesting
  946.      action) when a break is detected.
  947.  
  948. 
  949. File: gdb.info,  Node: EB29K Remote,  Next: VxWorks Remote,  Prev: i960-Nindy Remote,  Up: Remote
  950.  
  951. GDB with a Remote EB29K
  952. -----------------------
  953.  
  954.    To use GDB from a Unix system to run programs on AMD's EB29K board
  955. in a PC, you must first connect a serial cable between the PC and a
  956. serial port on the Unix system.  In the following, we assume you've
  957. hooked the cable between the PC's `COM1' port and `/dev/ttya' on the
  958. Unix system.
  959.  
  960. * Menu:
  961.  
  962. * Comms (EB29K)::               Communications Setup
  963. * gdb-EB29K::                   EB29K cross-debugging
  964. * Remote Log::                  Remote Log
  965.  
  966. 
  967. File: gdb.info,  Node: Comms (EB29K),  Next: gdb-EB29K,  Up: EB29K Remote
  968.  
  969. Communications Setup
  970. ....................
  971.  
  972.    The next step is to set up the PC's port, by doing something like the
  973. following in DOS on the PC:
  974.  
  975.      C:\> MODE com1:9600,n,8,1,none
  976.  
  977. This example--run on an MS DOS 4.0 system--sets the PC port to 9600
  978. bps, no parity, eight data bits, one stop bit, and no "retry" action;
  979. you must match the communications parameters when establishing the Unix
  980. end of the connection as well.
  981.  
  982.    To give control of the PC to the Unix side of the serial line, type
  983. the following at the DOS console:
  984.  
  985.      C:\> CTTY com1
  986.  
  987. (Later, if you wish to return control to the DOS console, you can use
  988. the command `CTTY con'--but you must send it over the device that had
  989. control, in our example over the `COM1' serial line).
  990.  
  991.    From the Unix host, use a communications program such as `tip' or
  992. `cu' to communicate with the PC; for example,
  993.  
  994.      cu -s 9600 -l /dev/ttya
  995.  
  996. The `cu' options shown specify, respectively, the linespeed and the
  997. serial port to use.  If you use `tip' instead, your command line may
  998. look something like the following:
  999.  
  1000.      tip -9600 /dev/ttya
  1001.  
  1002. Your system may define a different name where our example uses
  1003. `/dev/ttya' as the argument to `tip'.  The communications parameters,
  1004. including which port to use, are associated with the `tip' argument in
  1005. the "remote" descriptions file--normally the system table `/etc/remote'.
  1006.  
  1007.    Using the `tip' or `cu' connection, change the DOS working directory
  1008. to the directory containing a copy of your 29K program, then start the
  1009. PC program `EBMON' (an EB29K control program supplied with your board
  1010. by AMD).  You should see an initial display from `EBMON' similar to the
  1011. one that follows, ending with the `EBMON' prompt `#'--
  1012.  
  1013.      C:\> G:
  1014.      
  1015.      G:\> CD \usr\joe\work29k
  1016.      
  1017.      G:\USR\JOE\WORK29K> EBMON
  1018.      Am29000 PC Coprocessor Board Monitor, version 3.0-18
  1019.      Copyright 1990 Advanced Micro Devices, Inc.
  1020.      Written by Gibbons and Associates, Inc.
  1021.      
  1022.      Enter '?' or 'H' for help
  1023.      
  1024.      PC Coprocessor Type   = EB29K
  1025.      I/O Base              = 0x208
  1026.      Memory Base           = 0xd0000
  1027.      
  1028.      Data Memory Size      = 2048KB
  1029.      Available I-RAM Range = 0x8000 to 0x1fffff
  1030.      Available D-RAM Range = 0x80002000 to 0x801fffff
  1031.      
  1032.      PageSize              = 0x400
  1033.      Register Stack Size   = 0x800
  1034.      Memory Stack Size     = 0x1800
  1035.      
  1036.      CPU PRL               = 0x3
  1037.      Am29027 Available     = No
  1038.      Byte Write Available  = Yes
  1039.      
  1040.      # ~.
  1041.  
  1042.    Then exit the `cu' or `tip' program (done in the example by typing
  1043. `~.' at the `EBMON' prompt).  `EBMON' will keep running, ready for GDB
  1044. to take over.
  1045.  
  1046.    For this example, we've assumed what is probably the most convenient
  1047. way to make sure the same 29K program is on both the PC and the Unix
  1048. system: a PC/NFS connection that establishes "drive `G:'" on the PC as
  1049. a file system on the Unix host.  If you do not have PC/NFS or something
  1050. similar connecting the two systems, you must arrange some other
  1051. way--perhaps floppy-disk transfer--of getting the 29K program from the
  1052. Unix system to the PC; GDB will *not* download it over the serial line.
  1053.  
  1054. 
  1055. File: gdb.info,  Node: gdb-EB29K,  Next: Remote Log,  Prev: Comms (EB29K),  Up: EB29K Remote
  1056.  
  1057. EB29K cross-debugging
  1058. .....................
  1059.  
  1060.    Finally, `cd' to the directory containing an image of your 29K
  1061. program on the Unix system, and start GDB--specifying as argument the
  1062. name of your 29K program:
  1063.  
  1064.      cd /usr/joe/work29k
  1065.      gdb myfoo
  1066.  
  1067.    Now you can use the `target' command:
  1068.  
  1069.      target amd-eb /dev/ttya 9600 MYFOO
  1070.  
  1071. In this example, we've assumed your program is in a file called
  1072. `myfoo'.  Note that the filename given as the last argument to `target
  1073. amd-eb' should be the name of the program as it appears to DOS. In our
  1074. example this is simply `MYFOO', but in general it can include a DOS
  1075. path, and depending on your transfer mechanism may not resemble the
  1076. name on the Unix side.
  1077.  
  1078.    At this point, you can set any breakpoints you wish; when you are
  1079. ready to see your program run on the 29K board, use the GDB command
  1080. `run'.
  1081.  
  1082.    To stop debugging the remote program, use the GDB `detach' command.
  1083.  
  1084.    To return control of the PC to its console, use `tip' or `cu' once
  1085. again, after your GDB session has concluded, to attach to `EBMON'.  You
  1086. can then type the command `q' to shut down `EBMON', returning control
  1087. to the DOS command-line interpreter. Type `CTTY con' to return command
  1088. input to the main DOS console, and type `~.' to leave `tip' or `cu'.
  1089.  
  1090. 
  1091. File: gdb.info,  Node: Remote Log,  Prev: gdb-EB29K,  Up: EB29K Remote
  1092.  
  1093. Remote Log
  1094. ..........
  1095.  
  1096.    The `target amd-eb' command creates a file `eb.log' in the current
  1097. working directory, to help debug problems with the connection. `eb.log'
  1098. records all the output from `EBMON', including echoes of the commands
  1099. sent to it.  Running `tail -f' on this file in another window often
  1100. helps to understand trouble with `EBMON', or unexpected events on the
  1101. PC side of the connection.
  1102.  
  1103. 
  1104. File: gdb.info,  Node: ST2000 Remote,  Next: Hitachi H8/300 Remote,  Prev: VxWorks Remote,  Up: Remote
  1105.  
  1106. GDB with a Tandem ST2000
  1107. ------------------------
  1108.  
  1109.    To connect your ST2000 to the host system, see the manufacturer's
  1110. manual.  Once the ST2000 is physically attached, you can run
  1111.  
  1112.      target st2000 DEV SPEED
  1113.  
  1114. to establish it as your debugging environment.
  1115.  
  1116.    The `load' and `attach' commands are *not* defined for this target;
  1117. you must load your program into the ST2000 as you normally would for
  1118. standalone operation.  GDB will read debugging information (such as
  1119. symbols) from a separate, debugging version of the program available on
  1120. your host computer.
  1121.  
  1122.    These auxiliary GDB commands are available to help you with the
  1123. ST2000 environment:
  1124.  
  1125. `st2000 COMMAND'
  1126.      Send a COMMAND to the STDBUG monitor.  See the manufacturer's
  1127.      manual for available commands.
  1128.  
  1129. `connect'
  1130.      Connect the controlling terminal to the STDBUG command monitor. 
  1131.      When you are done interacting with STDBUG, typing either of two
  1132.      character sequences will get you back to the GDB command prompt:
  1133.      `RET~.' (Return, followed by tilde and period) or `RET~C-d'
  1134.      (Return, followed by tilde and control-D).
  1135.  
  1136. 
  1137. File: gdb.info,  Node: VxWorks Remote,  Next: ST2000 Remote,  Prev: EB29K Remote,  Up: Remote
  1138.  
  1139. GDB and VxWorks
  1140. ---------------
  1141.  
  1142.    GDB enables developers to spawn and debug tasks running on networked
  1143. VxWorks targets from a Unix host.  Already-running tasks spawned from
  1144. the VxWorks shell can also be debugged.  GDB uses code that runs on
  1145. both the UNIX host and on the VxWorks target.  The program `gdb' is
  1146. installed and executed on the UNIX host.
  1147.  
  1148.    The following information on connecting to VxWorks was current when
  1149. this manual was produced; newer releases of VxWorks may use revised
  1150. procedures.
  1151.  
  1152.    The remote debugging interface (RDB) routines are installed and
  1153. executed on the VxWorks target.  These routines are included in the
  1154. VxWorks library `rdb.a' and are incorporated into the system image when
  1155. source-level debugging is enabled in the VxWorks configuration.
  1156.  
  1157.    If you wish, you can define `INCLUDE_RDB' in the VxWorks
  1158. configuration file `configAll.h' to include the RDB interface routines
  1159. and spawn the source debugging task `tRdbTask' when VxWorks is booted. 
  1160. For more information on configuring and remaking VxWorks, see the
  1161. manufacturer's manual.
  1162.  
  1163.    Once you have included the RDB interface in your VxWorks system image
  1164. and set your Unix execution search path to find GDB, you are ready to
  1165. run GDB.  From your UNIX host, type:
  1166.  
  1167.      % gdb
  1168.  
  1169.    GDB will come up showing the prompt:
  1170.  
  1171.      (gdb)
  1172.  
  1173. * Menu:
  1174.  
  1175. * VxWorks connection::          Connecting to VxWorks
  1176. * VxWorks download::            VxWorks Download
  1177. * VxWorks attach::              Running Tasks
  1178.  
  1179. 
  1180. File: gdb.info,  Node: VxWorks connection,  Next: VxWorks download,  Up: VxWorks Remote
  1181.  
  1182. Connecting to VxWorks
  1183. .....................
  1184.  
  1185.    The GDB command `target' lets you connect to a VxWorks target on the
  1186. network.  To connect to a target whose host name is "`tt'", type:
  1187.  
  1188.      (gdb) target vxworks tt
  1189.  
  1190.    GDB will display a message similar to the following:
  1191.  
  1192.      Attaching remote machine across net... Success!
  1193.  
  1194.    GDB will then attempt to read the symbol tables of any object modules
  1195. loaded into the VxWorks target since it was last booted.  GDB locates
  1196. these files by searching the directories listed in the command search
  1197. path (*note Your Program's Environment: Environment.); if it fails to
  1198. find an object file, it will display a message such as:
  1199.  
  1200.      prog.o: No such file or directory.
  1201.  
  1202.    This will cause the `target' command to abort.  When this happens,
  1203. you should add the appropriate directory to the search path, with the
  1204. GDB command `path', and execute the `target' command again.
  1205.  
  1206. 
  1207. File: gdb.info,  Node: VxWorks download,  Next: VxWorks attach,  Prev: VxWorks connection,  Up: VxWorks Remote
  1208.  
  1209. VxWorks Download
  1210. ................
  1211.  
  1212.    If you have connected to the VxWorks target and you want to debug an
  1213. object that has not yet been loaded, you can use the GDB `load' command
  1214. to download a file from UNIX to VxWorks incrementally.  The object file
  1215. given as an argument to the `load' command is actually opened twice:
  1216. first by the VxWorks target in order to download the code, then by GDB
  1217. in order to read the symbol table.  This can lead to problems if the
  1218. current working directories on the two systems differ. It is simplest
  1219. to set the working directory on both systems to the directory in which
  1220. the object file resides, and then to reference the file by its name,
  1221. without any path.  Thus, to load a program `prog.o', residing in
  1222. `wherever/vw/demo/rdb', on VxWorks type:
  1223.  
  1224.      -> cd "wherever/vw/demo/rdb"
  1225.  
  1226.    On GDB type:
  1227.  
  1228.      (gdb) cd wherever/vw/demo/rdb
  1229.      (gdb) load prog.o
  1230.  
  1231.    GDB will display a response similar to the following:
  1232.  
  1233.      Reading symbol data from wherever/vw/demo/rdb/prog.o... done.
  1234.  
  1235.    You can also use the `load' command to reload an object module after
  1236. editing and recompiling the corresponding source file.  Note that this
  1237. will cause GDB to delete all currently-defined breakpoints,
  1238. auto-displays, and convenience variables, and to clear the value
  1239. history.  (This is necessary in order to preserve the integrity of
  1240. debugger data structures that reference the target system's symbol
  1241. table.)
  1242.  
  1243. 
  1244. File: gdb.info,  Node: VxWorks attach,  Prev: VxWorks download,  Up: VxWorks Remote
  1245.  
  1246. Running Tasks
  1247. .............
  1248.  
  1249.    You can also attach to an existing task using the `attach' command as
  1250. follows:
  1251.  
  1252.      (gdb) attach TASK
  1253.  
  1254. where TASK is the VxWorks hexadecimal task ID.  The task can be running
  1255. or suspended when you attach to it.  If running, it will be suspended at
  1256. the time of attachment.
  1257.  
  1258.