Initial bulk commit for "Git on MSys"
[msysgit/historical-msysgit.git] / mingw / info / gdb / Attach.html
blobedd1ee9bf113871dfe93935744e2634350440baf
1 <html lang="en">
2 <head>
3 <title>Debugging with GDB</title>
4 <meta http-equiv="Content-Type" content="text/html">
5 <meta name="description" content="Debugging with GDB">
6 <meta name="generator" content="makeinfo 4.3">
7 <link href="http://www.gnu.org/software/texinfo/" rel="generator-home">
8 </head>
9 <body>
10 <div class="node">
11 <p>
12 Node:<a name="Attach">Attach</a>,
13 Next:<a rel="next" accesskey="n" href="Kill-Process.html#Kill%20Process">Kill Process</a>,
14 Previous:<a rel="previous" accesskey="p" href="Input-Output.html#Input%2fOutput">Input/Output</a>,
15 Up:<a rel="up" accesskey="u" href="Running.html#Running">Running</a>
16 <hr><br>
17 </div>
19 <h3 class="section">Debugging an already-running process</h3>
21 <dl>
22 <dt><code>attach </code><var>process-id</var><code></code>
23 <dd>This command attaches to a running process--one that was started
24 outside GDB. (<code>info files</code> shows your active
25 targets.) The command takes as argument a process ID. The usual way to
26 find out the process-id of a Unix process is with the <code>ps</code> utility,
27 or with the <code>jobs -l</code> shell command.
29 <p><code>attach</code> does not repeat if you press &lt;RET&gt; a second time after
30 executing the command.
31 </dl>
33 <p>To use <code>attach</code>, your program must be running in an environment
34 which supports processes; for example, <code>attach</code> does not work for
35 programs on bare-board targets that lack an operating system. You must
36 also have permission to send the process a signal.
38 <p>When you use <code>attach</code>, the debugger finds the program running in
39 the process first by looking in the current working directory, then (if
40 the program is not found) by using the source file search path
41 (see <a href="Source-Path.html#Source%20Path">Specifying source directories</a>). You can also use
42 the <code>file</code> command to load the program. See <a href="Files.html#Files">Commands to Specify Files</a>.
44 <p>The first thing GDB does after arranging to debug the specified
45 process is to stop it. You can examine and modify an attached process
46 with all the GDB commands that are ordinarily available when
47 you start processes with <code>run</code>. You can insert breakpoints; you
48 can step and continue; you can modify storage. If you would rather the
49 process continue running, you may use the <code>continue</code> command after
50 attaching GDB to the process.
52 <dl>
53 <dt><code>detach</code>
54 <dd>When you have finished debugging the attached process, you can use the
55 <code>detach</code> command to release it from GDB control. Detaching
56 the process continues its execution. After the <code>detach</code> command,
57 that process and GDB become completely independent once more, and you
58 are ready to <code>attach</code> another process or start one with <code>run</code>.
59 <code>detach</code> does not repeat if you press &lt;RET&gt; again after
60 executing the command.
61 </dl>
63 <p>If you exit GDB or use the <code>run</code> command while you have an
64 attached process, you kill that process. By default, GDB asks
65 for confirmation if you try to do either of these things; you can
66 control whether or not you need to confirm by using the <code>set
67 confirm</code> command (see <a href="Messages-Warnings.html#Messages%2fWarnings">Optional warnings and messages</a>).
69 </body></html>