manpagez: man pages & more
info gdb
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.7 Debugging an Already-running Process

attach process-id

This command attaches to a running process—one that was started outside No value for GDBN. (info files shows your active targets.) The command takes as argument a process ID. The usual way to find out the process-id of a Unix process is with the ps utility, or with the ‘jobs -l’ shell command.

attach does not repeat if you press <RET> a second time after executing the command.

To use attach, your program must be running in an environment which supports processes; for example, attach does not work for programs on bare-board targets that lack an operating system. You must also have permission to send the process a signal.

When you use attach, the debugger finds the program running in the process first by looking in the current working directory, then (if the program is not found) by using the source file search path (see section Specifying Source Directories). You can also use the file command to load the program. See section Commands to Specify Files.

The first thing No value for GDBN does after arranging to debug the specified process is to stop it. You can examine and modify an attached process with all the No value for GDBN commands that are ordinarily available when you start processes with run. You can insert breakpoints; you can step and continue; you can modify storage. If you would rather the process continue running, you may use the continue command after attaching No value for GDBN to the process.

detach

When you have finished debugging the attached process, you can use the detach command to release it from No value for GDBN control. Detaching the process continues its execution. After the detach command, that process and No value for GDBN become completely independent once more, and you are ready to attach another process or start one with run. detach does not repeat if you press <RET> again after executing the command.

If you exit No value for GDBN while you have an attached process, you detach that process. If you use the run command, you kill that process. By default, No value for GDBN asks for confirmation if you try to do either of these things; you can control whether or not you need to confirm by using the set confirm command (see section Optional Warnings and Messages).


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]
© manpagez.com 2000-2017
Individual documents may contain additional copyright information.