| Debugging a Program With dbx |
Debugging Child Processes
This chapter describes how to debug a child process.
dbxhas several facilities to help you debug processes that create children using thefork(2) andexec(2) functions.This chapter is organized into the following sections:
- Attaching to Child Processes
- Following the exec Function
- Following the fork Function
- Interacting with Events
Attaching to Child Processes
You can attach to a running child process in one of the following ways.
When starting
dbx:
$dbxprognamepidFrom the command line:
(dbx)debugprognamepidYou can substitute progname with the name - (minus sign), so that
dbxfinds the executable associated with the given process id (pid). After using a-, a subsequentruncommand orreruncommand does not work becausedbxdoes not know the full path name of the executable.You can also attach to a running child process using the Sun WorkShop Debugging window. (See "Attaching to a Running Process" in the Using the Debugging window section of the Sun WorkShop online help.)
Following the
execFunctionIf a child process executes a new program using the
exec(2)function or one of its variations, the process id does not change, but the process image does.dbxautomatically takes note of a call to theexec()function and does an implicit reload of the newly executed program.The original name of the executable is saved in
$oprog. To return to it, usedebug $oprog.Following the
forkFunctionIf a child process calls the
vfork(),fork(1), orfork(2)function, the process id changes, but the process image stays the same. Depending on how thedbxenvironment variablefollow_fork_modeis set,dbxdoes one of the following.
Interacting with Events
All breakpoints and other events are deleted for any
exec()orfork()process. You can override the deletion for forked processes by setting thedbxenvironment variablefollow_fork_inherittoon, or make the events permanent using the-perm eventspecmodifier. For more information on using event specification modifiers, see Chapter 6.
|
Sun Microsystems, Inc. Copyright information. All rights reserved. Feedback |
Library | Contents | Previous | Next | Index |