Debugging with GDB Manual HP WDB v6.3 (5900-2180, August 2012)
13 Specifying a Debugging Target
A target is the execution environment occupied by your program.
Often, GDB 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. For HP-UX specific
information, see undefined [HP-UX Targets], page undefined. When you need more flexibility, for
example, running GDB on a physically separate host, or controlling a standalone system over a
serial port or a realtime system over a TCP/IP connection you can use the target command to
specify one of the target types configured for GDB (see “Commands for managing targets”
(page 101)).
13.1 Active targets
There are three classes of targets: processes, core files, and executable files. GDB can work
concurrently on up to three active targets, one in each class. This allows you, for example, to start
a process and inspect its activity without abandoning your work on a core file.
For example, if 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
GDB has two active targets and uses 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 the contents of the program read-write memory,
variables, machine status etc. While the executable files contain only the program text and initialized
data.)
When you type run, your executable file becomes an active process target as well. When a process
target is active, all GDB commands requesting memory addresses refer to that target; addresses
in an active core file or executable file target are obscured while the process target is active.
Use the core-file and exec-file commands to select a new core file or executable target (see
“Commands to specify files” (page 95)). To specify as a target a process that is already running,
use the attach command (see “Debugging a Running Process” (page 34)).
13.2 Commands for managing targets
target type parameters Connects the GDB 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 does 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 “Commands to specify files” (page 95)).
help target name Describe a particular target, including any parameters
necessary to select it.
set gnutarget args GDB uses its own library BFD to read your files. GDB knows
whether it is reading an executable, a core, or a .o file;
however, you can specify the file format with the set
gnutarget command. Unlike most target commands,
13.1 Active targets 101