Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Chapter 18. 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. 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 (refer to Section 18.2 Commands for managing targets).

18.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 to (for example) 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 a program's read-write memory--variables and so on--plus machine status, while 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 (refer to Section 17.1 Commands to specify files). To specify as a target a process that is already running, use the attach command (refer to Section 6.7 Debugging an already-running process).

 
 
  Published under the terms of the GNU General Public License Design by Interspire