Oracle® Solaris Studio 12.4: Debugging a Program With dbx

Exit Print View

Updated: January 2015
 
 

Attaching dbx to a Running Process

    You might need to debug a program that is already running. You would attach to a running process in the following situations:

  • You want to debug a running server, and you do not want to stop or kill it.

  • You want to debug a running program that has a graphical user interface, and you do not want to restart it.

  • Your program is looping indefinitely, and you want to debug it without killing it.

You can attach dbx to a running program by using the program’s process ID number as an argument to the dbx debug command.

Once you have debugged the program, you can then use the detach command to take the program out of the control of dbx without terminating the process.

If you quit dbx after attaching it to a running process, dbx implicitly detaches before terminating.

To attach dbx to a program that is running independently of dbx, you can use either the attach command or the debug command:

(dbx) debug program-name process-ID

or

(dbx) attach process-ID

You can substitute a – (dash) for the program name. dbx automatically finds the program associated with the process ID and loads it.

For more information, see debug Command and attach Command.

If dbx is not running, start dbx by typing:

% dbx program-name process-id

After you have attached dbx to a program, the program stops executing. You can examine it as you would any program loaded into dbx. You can use any event management or process control command to debug it.

    When you attach dbx to a new process while you are debugging an existing process, the following occurs:

  • If you started the process you are currently debugging with a run command, then dbx terminates that process before attaching to the new process.

  • If you started debugging the current process with an attach command or by specifying the process ID on the command line then dbx detaches from the current process before attaching to the new process.

If the process to which you are attaching dbx is stopped due to a SIGSTOP signal, SIGTSTOP signal, SIGTTIN signal, or SIGTTOUT signal, the attach succeeds with a message like the following:

dbx76: warning: Process is stopped due to signal SIGSTOP

The process is inspectable, but to resume it you need to send it a SIGCONT signal with the cont command:.

(dbx) cont -sig cont

You can use runtime checking on an attached process with certain exceptions. See Using Runtime Checking on an Attached Process.