HPlogo HP/DDE Debugger User's Guide: HP 9000 Series 700/800 Computers > Chapter 2 Compiling, Loading, and Executing the Target Program

Attaching the Debugger to a Running Process

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Glossary

 » Index

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 process 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 -attach option, 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 -wd option 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_file

on the program before executing it. See “Debugging Shared Libraries ” for more information on debugging shared libraries.

When you attach to a running process, the process may be executing in kernel code (for example, if it is waiting for input). In this case, no source file appears in the source file display area, and the debugger issues a warning message.

You may find it helpful to use the tb and environment commands to place you in the source code. The tb command displays a traceback of the call/return stack. From the traceback you can find a frame associated with a procedure in the source code. Use the frame block qualifier, `main(n), from the traceback as an argument to the environment command. For example:

debug -attach 1189
Attached to process 1189; initializing "/home/smith/progs/and".
Stopped at: `va(800b8658) (800B8658)
step
(Warning) Unable to determine statement boundaries;
stepping 1 instruction.
Stepped to: read+0010 (800B8658)
tb
`main(7): Stopped at: read+0010 (800B8658)
`main(6): Called from: _filbuf+0100 (800A5CC0)
`main(5): Called from: _doscan+0a78 (80096D2C)
`main(4): Called from: _scanf+0024 (8007E8F4)
`main(3): Called from: \\and\main\12 (00001DCC)
`main(2): Called from: _start+0068 (80041D5C)
`main: Called from: $START$+0094 (0000177C)
env `main(3)
Environment: \\and\main\12 (00001DCC) (frame `main(3))
Stopped at: read+0010 (800B8658)
breakpoint 13
go

If you get a Permission denied error message when you attach to a running process, it is likely that you are running either the debugger or the target process over an NFS link. The relevant file system may be mounted with the default intr option. You must mount the file system with the nointr option to resolve this problem. Use a command like the following to mount the file system containing the debugger:

$ mount -o nointr[,other_options] system:/opt/langtools /tools

Use a command like the following to mount the file system containing the target process:

$ mount -o nointr[,other_options] system:/test_area /test

It is probably easier to create an auxiliary mount for the file system than to unmount and remount it.