In This Book

2

Attaching the Debugger to a Running Process

To debug a running process, you must either have the same user ID as the target program or you must be logged in as root.

Using the File Menu

To attach to a running pro cess from the debugger menu bar:

1.If the debugger's current directory is not the same as the directory that contains the target process, change it using File:Change Working Directory .

2.Enter the name of the process in the (): parameter input box.

3.Select File:Debug Running Process() .

Using the debug Command

From the command input box, enter the debug command with the -attachoption, specifying a process ID. The ps(1) command displays process IDs.

If the debugger's current directory is not the same as the directory that contains the target process, use either the object program pathname argument or the -wdoption to the debug command.

You can set breakpoints in the main program of an attached process. On HP-UX systems, you cannot set breakpoints in shared libraries used by the program unless you run

/usr/lib/pxdb -s on executable ￿le

on the program before executing it. See \Debugging Shared Libraries" in Chapter 8 for more information on debugging shared libraries.

When you attach to a running process, the process ma y be executing in k ernel code (for example, if it is w aiting for input). In this case, no source ￿le appears in the source ￿le displa y area, and the debugger issues a w arning message.

You may ￿nd it helpful to use the tb and environment commands to place y ou in the source code. The tb command displays a traceback of the call/return stack. From the tracebac k you can ￿nd a frame associated with a procedure in

Compiling, Loading, and Executing the Target Program 2-7