DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
dbXtra and dbxtra

Debugging child processes

ptrace(S) allows processes to be traced by processes other than their parent. dbXtra/dbxtra uses this feature to allow you to debug the child process when a process forks. On prior releases of the debuggers, when a debugged process forked, the child ran to completion. You can now control what happens by setting the $fork variable. This command must be typed into the interaction window in on of the following ways:


set $fork="parent"
This is the default, and acts like previous releases. The child runs to completion, while the parent remains under debugger control.

set $fork="child"
The parent will be released from the debugger, and the debugger will take control of the child. The parent will run normally to completion. Note that the child will not completely terminate after an exit(S) call until you quit the debugger.

set $fork="push"
The parent will be suspended, and a new debugger will take control of the child. When the child completes, and you quit the child's debugger, debugging of the parent will resume.

set $fork="both"
For dbXtra only, a new instance of the debugger and screen interface will be created to debug the child. Both debugger and their controlled processes will be active simultaneously.

set $fork="prompt"
dbx will prompt for one of the above choices after each fork.

The following comments apply to the set $fork="both" option.

The debugger stops the child right after the fork, before it has executed any code. Be sure to set breakpoints in the child before you allow it to continue. If you rerun the child, the original child process exits with SIGTRAP as the terminating signal. This is the result the parent process will get from wait(S). If the parent is in wait, the wait will return as soon as you say rerun. This is rarely what you want to do.

The parent continues running normally after the fork, although it is under the control of the debugger. If you want it to stop, be sure to set a breakpoint in the code the parent will run so that it stops.

It can be confusing to debug two processes at the same time. Using the set $fork="push" is simpler if it will do the job for you.

When the child exits, you are notified in the debugger message window. You must exit the child dbXtra before the child process actually terminates. If the parent is going to wait(S) for the child, the wait(S) will not complete until this happens.

If the child process has not executed an exec(S) system call, quitting the debugger (either from the menu, or a quit command) will cause the dbx controlling the parent process to exit as well. This causes the entire debugging session to terminate, and the parent dbXtra to issue an error message.

The workaround is to go to another window, and kill(C) (SIGTERM works) the child screen manager process, that is, the instance of dbXtra that is associated with the child process. This instance of dbXtra will have a dbx as its parent process.

This will cause the child and its debugger to terminate, and things will operate normally from there.

If the child has executed an exec(S), it seems that you can quit the child debugger normally.


Next topic: Attaching to a running process
Previous topic: The dbXtra and dbxtra cc command

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003