You may need to debug a program that is already running. You might attach to a running process if:
You want to debug a running server and you do not want to stop or kill it.
You want to debug a running GUI program, and you don't 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 pid 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 under the control of dbx without terminating the process.
If you quit dbx after having attached it to a running process, dbx implicitly detaches before terminating.
To attach dbx to a program that is running independently of dbx:
If dbx is already running, type:
(dbx) debug program_name process_ID
You can substitute a -(dash) for the program_name; dbx automatically finds the program associated with the pid and loads it.
If dbx is not running, start dbx by typingt:
% dbx program_name process_ID
After you have attached dbx to a program, the program stops executing. You can examine it as you normally would any program loaded into dbx. You can use any event management or process control command to debug it.