Skip Navigation Links | |
Exit Print View | |
Oracle Solaris Studio 12.3: Debugging a Program With dbx Oracle Solaris Studio 12.3 Information Library |
4. Viewing and Navigating To Code
5. Controlling Program Execution
Continuing Execution of a Program
To Resume Program Execution at a Specific Line
Using Ctrl+C to Stop a Process
6. Setting Breakpoints and Traces
8. Evaluating and Displaying Data
11. Debugging Multithreaded Applications
16. Debugging Fortran Using dbx
17. Debugging a Java Application With dbx
18. Debugging at the Machine-Instruction Level
19. Using dbx With the Korn Shell
You might need to debug a program that is already running. You would attach to a running process if:
You wanted to debug a running server, and you did not want to stop or kill it.
You wanted to debug a running program that has a graphical user interface, and you didn’t want to restart it.
Your program was 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 from 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.
To attach dbx to a process that is already running, type:
(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.