Go to the previous, next section.

Specifying a Debugging Target

A target is the execution environment occupied by your program. _if__(!_BARE__) Often, _GDBN__ runs in the same host environment as your program; in that case, the debugging target is specified as a side effect when you use the file or core commands. When you need more flexibility--for example, running _GDBN__ on a physically separate host, or controlling a standalone system over a serial port or a realtime system over a TCP/IP connection--you _fi__(!_BARE__) _if__(_BARE__) You _fi__(_BARE__) can use the target command to specify one of the target types configured for _GDBN__ (see section Commands for Managing Targets).

Active Targets

_if__(!_BARE__) There are three classes of targets: processes, core files, and executable files. _GDBN__ can work concurrently on up to three active targets, one in each class. This allows you to (for example) start a process and inspect its activity without abandoning your work on a core file.

If, for example, you execute `gdb a.out', then the executable file a.out is the only active target. If you designate a core file as well--presumably from a prior run that crashed and coredumped--then _GDBN__ has two active targets and will use them in tandem, looking first in the corefile target, then in the executable file, to satisfy requests for memory addresses. (Typically, these two classes of target are complementary, since core files contain only a program's read-write memory--variables and so on--plus machine status, while executable files contain only the program text and initialized data.) _fi__(!_BARE__)

When you type run, your executable file becomes an active process target as well. When a process target is active, all _GDBN__ commands requesting memory addresses refer to that target; addresses in an _if__(!_BARE__) active core file or _fi__(!_BARE__) executable file target are obscured while the process target is active.

_if__(_BARE__) Use the exec-file command to select a new executable target (see section Commands to Specify Files). _fi__(_BARE__) _if__(!_BARE__) Use the core-file and exec-file commands to select a new core file or executable target (see section Commands to Specify Files). To specify as a target a process that is already running, use the attach command (see section Debugging an Already-Running Process.). _fi__(!_BARE__)

Commands for Managing Targets

target type parameters
Connects the _GDBN__ host environment to a target machine or process. A target is typically a protocol for talking to debugging facilities. You use the argument type to specify the type or protocol of the target machine.

Further parameters are interpreted by the target protocol, but typically include things like device names or host names to connect with, process numbers, and baud rates.

The target command will not repeat if you press RET again after executing the command.

help target
Displays the names of all targets available. To display targets currently selected, use either info target or info files (see section Commands to Specify Files).

help target name
Describe a particular target, including any parameters necessary to select it.

Here are some common targets (available, or not, depending on the GDB configuration):

target exec prog
An executable file. `target exec prog' is the same as `exec-file prog'.

target core filename
A core dump file. `target core filename' is the same as `core-file filename'.

_if__(_REMOTESTUB__)

target remote dev
Remote serial target in GDB-specific protocol. The argument dev specifies what serial device to use for the connection (e.g. `/dev/ttya'). See section Remote Debugging. _fi__(_REMOTESTUB__)

_if__(_AMD29K__)

target amd-eb dev speed PROG
Remote PC-resident AMD EB29K board, attached over serial lines. dev is the serial device, as for target remote; speed allows you to specify the linespeed; and PROG is the name of the program to be debugged, as it appears to DOS on the PC. @xref{EB29K Remote, ,_GDBN__ with a Remote EB29K}.

_fi__(_AMD29K__) _if__(_H8__)

target hms
A Hitachi H8/300 board, attached via serial line to your host. Use special commands device and speed to control the serial line and the communications speed used. @xref{Hitachi H8/300 Remote,,_GDBN__ and the Hitachi H8/300}.

_fi__(_H8__) _if__(_I960__)

target nindy devicename
An Intel 960 board controlled by a Nindy Monitor. devicename is the name of the serial device to use for the connection, e.g. `/dev/ttya'. @xref{i960-Nindy Remote, ,_GDBN__ with a Remote i960 (Nindy)}.

_fi__(_I960__) _if__(_ST2000__)

target st2000 dev speed
A Tandem ST2000 phone switch, running Tandem's STDBUG protocol. dev is the name of the device attached to the ST2000 serial line; speed is the communication line speed. The arguments are not used if _GDBN__ is configured to connect to the ST2000 using TCP or Telnet. @xref{ST2000 Remote,,_GDBN__ with a Tandem ST2000}.

_fi__(_ST2000__) _if__(_VXWORKS__)

target vxworks machinename
A VxWorks system, attached via TCP/IP. The argument machinename is the target system's machine name or IP address. @xref{VxWorks Remote, ,_GDBN__ and VxWorks}. _fi__(_VXWORKS__)

_if__(_GENERIC__) Different targets are available on different configurations of _GDBN__; your configuration may have more or fewer targets. _fi__(_GENERIC__)

Remote Debugging

If you are trying to debug a program running on a machine that cannot run GDB in the usual way, it is often useful to use remote debugging. For example, you might use remote debugging on an operating system kernel, or on a small system which does not have a general purpose operating system powerful enough to run a full-featured debugger.

Some configurations of GDB have special serial or TCP/IP interfaces to make this work with particular debugging targets. In addition, GDB comes with a generic serial protocol (specific to GDB, but not specific to any particular target system) which you can use if you write the remote stubs--the code that will run on the remote system to communicate with GDB.

Other remote targets may be available in your configuration of GDB; use help targets to list them.

_if__(_GENERIC__) _dnl__ Text on starting up GDB in various specific cases; it goes up front _dnl__ in manuals configured for any of those particular situations, here _dnl__ otherwise. _include__(gdbinv-s.m4) _fi__(_GENERIC__)

Go to the previous, next section.