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">
12 Node:
<a name=
"GDB%2fMI%20Target%20Manipulation">GDB/MI Target Manipulation
</a>,
13 Next:
<a rel=
"next" accesskey=
"n" href=
"GDB-MI-Thread-Commands.html#GDB%2fMI%20Thread%20Commands">GDB/MI Thread Commands
</a>,
14 Previous:
<a rel=
"previous" accesskey=
"p" href=
"GDB-MI-Symbol-Query.html#GDB%2fMI%20Symbol%20Query">GDB/MI Symbol Query
</a>,
15 Up:
<a rel=
"up" accesskey=
"u" href=
"GDB-MI.html#GDB%2fMI">GDB/MI
</a>
19 <h3 class=
"section"><small>GDB/MI
</small> Target Manipulation Commands
</h3>
21 <h4 class=
"subheading">The
<code>-target-attach
</code> Command
</h4>
23 <h5 class=
"subsubheading">Synopsis
</h5>
25 <pre class=
"example"> -target-attach
<var>pid
</var> |
<var>file
</var>
28 <p>Attach to a process
<var>pid
</var> or a file
<var>file
</var> outside of GDB.
30 <h5 class=
"subsubheading">GDB command
</h5>
32 <p>The corresponding GDB command is
<code>attach
</code>.
34 <h5 class=
"subsubheading">Example
</h5>
38 <h4 class=
"subheading">The
<code>-target-compare-sections
</code> Command
</h4>
40 <h5 class=
"subsubheading">Synopsis
</h5>
42 <pre class=
"example"> -target-compare-sections [
<var>section
</var> ]
45 <p>Compare data of section
<var>section
</var> on target to the exec file.
46 Without the argument, all sections are compared.
48 <h5 class=
"subsubheading">GDB Command
</h5>
50 <p>The GDB equivalent is
<code>compare-sections
</code>.
52 <h5 class=
"subsubheading">Example
</h5>
56 <h4 class=
"subheading">The
<code>-target-detach
</code> Command
</h4>
58 <h5 class=
"subsubheading">Synopsis
</h5>
60 <pre class=
"example"> -target-detach
63 <p>Disconnect from the remote target. There's no output.
65 <h5 class=
"subsubheading">GDB command
</h5>
67 <p>The corresponding GDB command is
<code>detach
</code>.
69 <h5 class=
"subsubheading">Example
</h5>
71 <pre class=
"smallexample"> (gdb)
77 <h4 class=
"subheading">The
<code>-target-download
</code> Command
</h4>
79 <h5 class=
"subsubheading">Synopsis
</h5>
81 <pre class=
"example"> -target-download
84 <p>Loads the executable onto the remote target.
85 It prints out an update message every half second, which includes the fields:
88 <dt><code>section
</code>
89 <dd>The name of the section.
90 <br><dt><code>section-sent
</code>
91 <dd>The size of what has been sent so far for that section.
92 <br><dt><code>section-size
</code>
93 <dd>The size of the section.
94 <br><dt><code>total-sent
</code>
95 <dd>The total size of what was sent so far (the current and the previous sections).
96 <br><dt><code>total-size
</code>
97 <dd>The size of the overall executable to download.
100 <p>Each message is sent as status record (see
<a href=
"GDB-MI-Output-Syntax.html#GDB%2fMI%20Output%20Syntax"><small>GDB/MI
</small> Output Syntax
</a>).
102 <p>In addition, it prints the name and size of the sections, as they are
103 downloaded. These messages include the following fields:
106 <dt><code>section
</code>
107 <dd>The name of the section.
108 <br><dt><code>section-size
</code>
109 <dd>The size of the section.
110 <br><dt><code>total-size
</code>
111 <dd>The size of the overall executable to download.
114 <p>At the end, a summary is printed.
116 <h5 class=
"subsubheading">GDB Command
</h5>
118 <p>The corresponding GDB command is
<code>load
</code>.
120 <h5 class=
"subsubheading">Example
</h5>
122 <p>Note: each status message appears on a single line. Here the messages
123 have been broken down so that they can fit onto a page.
125 <pre class=
"smallexample"> (gdb)
127 +download,{
section=
".text",
section-size=
"6668",
total-size=
"9880"}
128 +download,{
section=
".text",
section-sent=
"512",
section-size=
"6668",
129 total-sent=
"512",
total-size=
"9880"}
130 +download,{
section=
".text",
section-sent=
"1024",
section-size=
"6668",
131 total-sent=
"1024",
total-size=
"9880"}
132 +download,{
section=
".text",
section-sent=
"1536",
section-size=
"6668",
133 total-sent=
"1536",
total-size=
"9880"}
134 +download,{
section=
".text",
section-sent=
"2048",
section-size=
"6668",
135 total-sent=
"2048",
total-size=
"9880"}
136 +download,{
section=
".text",
section-sent=
"2560",
section-size=
"6668",
137 total-sent=
"2560",
total-size=
"9880"}
138 +download,{
section=
".text",
section-sent=
"3072",
section-size=
"6668",
139 total-sent=
"3072",
total-size=
"9880"}
140 +download,{
section=
".text",
section-sent=
"3584",
section-size=
"6668",
141 total-sent=
"3584",
total-size=
"9880"}
142 +download,{
section=
".text",
section-sent=
"4096",
section-size=
"6668",
143 total-sent=
"4096",
total-size=
"9880"}
144 +download,{
section=
".text",
section-sent=
"4608",
section-size=
"6668",
145 total-sent=
"4608",
total-size=
"9880"}
146 +download,{
section=
".text",
section-sent=
"5120",
section-size=
"6668",
147 total-sent=
"5120",
total-size=
"9880"}
148 +download,{
section=
".text",
section-sent=
"5632",
section-size=
"6668",
149 total-sent=
"5632",
total-size=
"9880"}
150 +download,{
section=
".text",
section-sent=
"6144",
section-size=
"6668",
151 total-sent=
"6144",
total-size=
"9880"}
152 +download,{
section=
".text",
section-sent=
"6656",
section-size=
"6668",
153 total-sent=
"6656",
total-size=
"9880"}
154 +download,{
section=
".init",
section-size=
"28",
total-size=
"9880"}
155 +download,{
section=
".fini",
section-size=
"28",
total-size=
"9880"}
156 +download,{
section=
".data",
section-size=
"3156",
total-size=
"9880"}
157 +download,{
section=
".data",
section-sent=
"512",
section-size=
"3156",
158 total-sent=
"7236",
total-size=
"9880"}
159 +download,{
section=
".data",
section-sent=
"1024",
section-size=
"3156",
160 total-sent=
"7748",
total-size=
"9880"}
161 +download,{
section=
".data",
section-sent=
"1536",
section-size=
"3156",
162 total-sent=
"8260",
total-size=
"9880"}
163 +download,{
section=
".data",
section-sent=
"2048",
section-size=
"3156",
164 total-sent=
"8772",
total-size=
"9880"}
165 +download,{
section=
".data",
section-sent=
"2560",
section-size=
"3156",
166 total-sent=
"9284",
total-size=
"9880"}
167 +download,{
section=
".data",
section-sent=
"3072",
section-size=
"3156",
168 total-sent=
"9796",
total-size=
"9880"}
169 ^done,
address=
"0x10004",
load-size=
"9880",
transfer-rate=
"6586",
174 <h4 class=
"subheading">The
<code>-target-exec-status
</code> Command
</h4>
176 <h5 class=
"subsubheading">Synopsis
</h5>
178 <pre class=
"example"> -target-exec-status
181 <p>Provide information on the state of the target (whether it is running or
184 <h5 class=
"subsubheading">GDB Command
</h5>
186 <p>There's no equivalent GDB command.
188 <h5 class=
"subsubheading">Example
</h5>
192 <h4 class=
"subheading">The
<code>-target-list-available-targets
</code> Command
</h4>
194 <h5 class=
"subsubheading">Synopsis
</h5>
196 <pre class=
"example"> -target-list-available-targets
199 <p>List the possible targets to connect to.
201 <h5 class=
"subsubheading">GDB Command
</h5>
203 <p>The corresponding GDB command is
<code>help target
</code>.
205 <h5 class=
"subsubheading">Example
</h5>
209 <h4 class=
"subheading">The
<code>-target-list-current-targets
</code> Command
</h4>
211 <h5 class=
"subsubheading">Synopsis
</h5>
213 <pre class=
"example"> -target-list-current-targets
216 <p>Describe the current target.
218 <h5 class=
"subsubheading">GDB Command
</h5>
220 <p>The corresponding information is printed by
<code>info file
</code> (among
223 <h5 class=
"subsubheading">Example
</h5>
227 <h4 class=
"subheading">The
<code>-target-list-parameters
</code> Command
</h4>
229 <h5 class=
"subsubheading">Synopsis
</h5>
231 <pre class=
"example"> -target-list-parameters
234 <h5 class=
"subsubheading">GDB Command
</h5>
238 <h5 class=
"subsubheading">Example
</h5>
242 <h4 class=
"subheading">The
<code>-target-select
</code> Command
</h4>
244 <h5 class=
"subsubheading">Synopsis
</h5>
246 <pre class=
"example"> -target-select
<var>type
</var> <var>parameters
<small class=
"dots">...
</small></var>
249 <p>Connect GDB to the remote target. This command takes two args:
252 <dt><code></code><var>type
</var><code></code>
253 <dd>The type of target, for instance
<code>async
</code>,
<code>remote
</code>, etc.
254 <br><dt><code></code><var>parameters
</var><code></code>
255 <dd>Device names, host names and the like. See
<a href=
"Target-Commands.html#Target%20Commands">Commands for managing targets
</a>, for more details.
258 <p>The output is a connection notification, followed by the address at
259 which the target program is, in the following form:
261 <pre class=
"smallexample"> ^connected,
addr=
"<var>address</var>",
func=
"<var>function name</var>",
262 args=[
<var>arg list
</var>]
265 <h5 class=
"subsubheading">GDB Command
</h5>
267 <p>The corresponding GDB command is
<code>target
</code>.
269 <h5 class=
"subsubheading">Example
</h5>
271 <pre class=
"smallexample"> (gdb)
272 -target-select async /dev/ttya
273 ^connected,
addr=
"0xfe00a300",
func=
"??",args=[]