Debugging a Program With dbx

Attaching dbx to a Running Process

You may need to debug a program that is already running. You might attach to a running process if:

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:

  1. 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.

  2. 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.