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 133)).

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 125)). To specify as a target a process that is already running, use the attach command (see “Debugging a Running Process” (page 44)).

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

13.1 Active targets 133