Go to the previous, next section.
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).
_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__)
target type parameters
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
info target
or info files
(see section Commands to Specify Files).
help target name
Here are some common targets (available, or not, depending on the GDB configuration):
target exec prog
target core filename
_if__(_REMOTESTUB__)
target remote dev
_if__(_AMD29K__)
target amd-eb dev speed PROG
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
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
_fi__(_I960__) _if__(_ST2000__)
target st2000 dev speed
_fi__(_ST2000__) _if__(_VXWORKS__)
target vxworks machinename
_if__(_GENERIC__) Different targets are available on different configurations of _GDBN__; your configuration may have more or fewer targets. _fi__(_GENERIC__)
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.