• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/toolchains/hndtools-armeabi-2013.11/share/doc/arm-arm-none-eabi/html/gdb/
1<html lang="en">
2<head>
3<title>Attach - 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.13">
7<link title="Top" rel="start" href="index.html#Top">
8<link rel="up" href="Running.html#Running" title="Running">
9<link rel="prev" href="Input_002fOutput.html#Input_002fOutput" title="Input/Output">
10<link rel="next" href="Kill-Process.html#Kill-Process" title="Kill Process">
11<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
12<!--
13Copyright (C) 1988-2013 Free Software Foundation, Inc.
14
15Permission is granted to copy, distribute and/or modify this document
16under the terms of the GNU Free Documentation License, Version 1.3 or
17any later version published by the Free Software Foundation; with the
18Invariant Sections being ``Free Software'' and ``Free Software Needs
19Free Documentation'', with the Front-Cover Texts being ``A GNU Manual,''
20and with the Back-Cover Texts as in (a) below.
21
22(a) The FSF's Back-Cover Text is: ``You are free to copy and modify
23this GNU Manual.  Buying copies from GNU Press supports the FSF in
24developing GNU and promoting software freedom.''
25-->
26<meta http-equiv="Content-Style-Type" content="text/css">
27<style type="text/css"><!--
28  pre.display { font-family:inherit }
29  pre.format  { font-family:inherit }
30  pre.smalldisplay { font-family:inherit; font-size:smaller }
31  pre.smallformat  { font-family:inherit; font-size:smaller }
32  pre.smallexample { font-size:smaller }
33  pre.smalllisp    { font-size:smaller }
34  span.sc    { font-variant:small-caps }
35  span.roman { font-family:serif; font-weight:normal; } 
36  span.sansserif { font-family:sans-serif; font-weight:normal; } 
37--></style>
38<link rel="stylesheet" type="text/css" href="../cs.css">
39</head>
40<body>
41<div class="node">
42<a name="Attach"></a>
43<p>
44Next:&nbsp;<a rel="next" accesskey="n" href="Kill-Process.html#Kill-Process">Kill Process</a>,
45Previous:&nbsp;<a rel="previous" accesskey="p" href="Input_002fOutput.html#Input_002fOutput">Input/Output</a>,
46Up:&nbsp;<a rel="up" accesskey="u" href="Running.html#Running">Running</a>
47<hr>
48</div>
49
50<h3 class="section">4.7 Debugging an Already-running Process</h3>
51
52<p><a name="index-attach-141"></a><a name="index-attach-142"></a>
53     <dl>
54<dt><code>attach </code><var>process-id</var><dd>This command attaches to a running process&mdash;one that was started
55outside <span class="sc">gdb</span>.  (<code>info files</code> shows your active
56targets.)  The command takes as argument a process ID.  The usual way to
57find out the <var>process-id</var> of a Unix process is with the <code>ps</code> utility,
58or with the &lsquo;<samp><span class="samp">jobs -l</span></samp>&rsquo; shell command.
59
60     <p><code>attach</code> does not repeat if you press &lt;RET&gt; a second time after
61executing the command. 
62</dl>
63
64   <p>To use <code>attach</code>, your program must be running in an environment
65which supports processes; for example, <code>attach</code> does not work for
66programs on bare-board targets that lack an operating system.  You must
67also have permission to send the process a signal.
68
69   <p>When you use <code>attach</code>, the debugger finds the program running in
70the process first by looking in the current working directory, then (if
71the program is not found) by using the source file search path
72(see <a href="Source-Path.html#Source-Path">Specifying Source Directories</a>).  You can also use
73the <code>file</code> command to load the program.  See <a href="Files.html#Files">Commands to Specify Files</a>.
74
75   <p>The first thing <span class="sc">gdb</span> does after arranging to debug the specified
76process is to stop it.  You can examine and modify an attached process
77with all the <span class="sc">gdb</span> commands that are ordinarily available when
78you start processes with <code>run</code>.  You can insert breakpoints; you
79can step and continue; you can modify storage.  If you would rather the
80process continue running, you may use the <code>continue</code> command after
81attaching <span class="sc">gdb</span> to the process.
82
83     
84<a name="index-detach-143"></a>
85<dl><dt><code>detach</code><dd>When you have finished debugging the attached process, you can use the
86<code>detach</code> command to release it from <span class="sc">gdb</span> control.  Detaching
87the process continues its execution.  After the <code>detach</code> command,
88that process and <span class="sc">gdb</span> become completely independent once more, and you
89are ready to <code>attach</code> another process or start one with <code>run</code>. 
90<code>detach</code> does not repeat if you press &lt;RET&gt; again after
91executing the command. 
92</dl>
93
94   <p>If you exit <span class="sc">gdb</span> while you have an attached process, you detach
95that process.  If you use the <code>run</code> command, you kill that process. 
96By default, <span class="sc">gdb</span> asks for confirmation if you try to do either of these
97things; you can control whether or not you need to confirm by using the
98<code>set confirm</code> command (see <a href="Messages_002fWarnings.html#Messages_002fWarnings">Optional Warnings and Messages</a>).
99
100   </body></html>
101
102