hc
2023-11-06 15ade055295d13f95d49e3d99b09f3bbfb4a43e7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Copyright (C) 1988-2021 Free Software Foundation, Inc.
 
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Free Software" and "Free Software Needs
Free Documentation", with the Front-Cover Texts being "A GNU Manual,"
and with the Back-Cover Texts as in (a) below.
 
(a) The FSF's Back-Cover Text is: "You are free to copy and modify
this GNU Manual.  Buying copies from GNU Press supports the FSF in
developing GNU and promoting software freedom." -->
<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
<head>
<title>Debugging with GDB: GDB/MI Target Manipulation</title>
 
<meta name="description" content="Debugging with GDB: GDB/MI Target Manipulation">
<meta name="keywords" content="Debugging with GDB: GDB/MI Target Manipulation">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="GDB_002fMI.html#GDB_002fMI" rel="up" title="GDB/MI">
<link href="GDB_002fMI-File-Transfer-Commands.html#GDB_002fMI-File-Transfer-Commands" rel="next" title="GDB/MI File Transfer Commands">
<link href="GDB_002fMI-File-Commands.html#GDB_002fMI-File-Commands" rel="previous" title="GDB/MI File Commands">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
 
 
</head>
 
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="GDB_002fMI-Target-Manipulation"></a>
<div class="header">
<p>
Next: <a href="GDB_002fMI-File-Transfer-Commands.html#GDB_002fMI-File-Transfer-Commands" accesskey="n" rel="next">GDB/MI File Transfer Commands</a>, Previous: <a href="GDB_002fMI-File-Commands.html#GDB_002fMI-File-Commands" accesskey="p" rel="previous">GDB/MI File Commands</a>, Up: <a href="GDB_002fMI.html#GDB_002fMI" accesskey="u" rel="up">GDB/MI</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="GDB_002fMI-Target-Manipulation-Commands"></a>
<h3 class="section">27.20 <small>GDB/MI</small> Target Manipulation Commands</h3>
 
 
<a name="The-_002dtarget_002dattach-Command"></a>
<h4 class="subheading">The <code>-target-attach</code> Command</h4>
<a name="index-_002dtarget_002dattach"></a>
 
<a name="Synopsis-93"></a>
<h4 class="subsubheading">Synopsis</h4>
 
<div class="smallexample">
<pre class="smallexample"> -target-attach <var>pid</var> | <var>gid</var> | <var>file</var>
</pre></div>
 
<p>Attach to a process <var>pid</var> or a file <var>file</var> outside of
<small>GDB</small>, or a thread group <var>gid</var>.  If attaching to a thread
group, the id previously returned by 
&lsquo;<samp>-list-thread-groups --available</samp>&rsquo; must be used.
</p>
<a name="GDB-Command-75"></a>
<h4 class="subsubheading"><small>GDB</small> Command</h4>
 
<p>The corresponding <small>GDB</small> command is &lsquo;<samp>attach</samp>&rsquo;.
</p>
<a name="Example-75"></a>
<h4 class="subsubheading">Example</h4>
<div class="smallexample">
<pre class="smallexample">(gdb)
-target-attach 34
=thread-created,id=&quot;1&quot;
*stopped,thread-id=&quot;1&quot;,frame={addr=&quot;0xb7f7e410&quot;,func=&quot;bar&quot;,args=[]}
^done
(gdb)
</pre></div>
 
 
 
<a name="The-_002dtarget_002ddetach-Command"></a>
<h4 class="subheading">The <code>-target-detach</code> Command</h4>
<a name="index-_002dtarget_002ddetach"></a>
 
<a name="Synopsis-94"></a>
<h4 class="subsubheading">Synopsis</h4>
 
<div class="smallexample">
<pre class="smallexample"> -target-detach [ <var>pid</var> | <var>gid</var> ]
</pre></div>
 
<p>Detach from the remote target which normally resumes its execution.
If either <var>pid</var> or <var>gid</var> is specified, detaches from either
the specified process, or specified thread group.  There&rsquo;s no output.
</p>
<a name="GDB-Command-76"></a>
<h4 class="subsubheading"><small>GDB</small> Command</h4>
 
<p>The corresponding <small>GDB</small> command is &lsquo;<samp>detach</samp>&rsquo;.
</p>
<a name="Example-76"></a>
<h4 class="subsubheading">Example</h4>
 
<div class="smallexample">
<pre class="smallexample">(gdb)
-target-detach
^done
(gdb)
</pre></div>
 
 
<a name="The-_002dtarget_002ddisconnect-Command"></a>
<h4 class="subheading">The <code>-target-disconnect</code> Command</h4>
<a name="index-_002dtarget_002ddisconnect"></a>
 
<a name="Synopsis-95"></a>
<h4 class="subsubheading">Synopsis</h4>
 
<div class="smallexample">
<pre class="smallexample"> -target-disconnect
</pre></div>
 
<p>Disconnect from the remote target.  There&rsquo;s no output and the target is
generally not resumed.
</p>
<a name="GDB-Command-77"></a>
<h4 class="subsubheading"><small>GDB</small> Command</h4>
 
<p>The corresponding <small>GDB</small> command is &lsquo;<samp>disconnect</samp>&rsquo;.
</p>
<a name="Example-77"></a>
<h4 class="subsubheading">Example</h4>
 
<div class="smallexample">
<pre class="smallexample">(gdb)
-target-disconnect
^done
(gdb)
</pre></div>
 
 
<a name="The-_002dtarget_002ddownload-Command"></a>
<h4 class="subheading">The <code>-target-download</code> Command</h4>
<a name="index-_002dtarget_002ddownload"></a>
 
<a name="Synopsis-96"></a>
<h4 class="subsubheading">Synopsis</h4>
 
<div class="smallexample">
<pre class="smallexample"> -target-download
</pre></div>
 
<p>Loads the executable onto the remote target.
It prints out an update message every half second, which includes the fields:
</p>
<dl compact="compact">
<dt>&lsquo;<samp>section</samp>&rsquo;</dt>
<dd><p>The name of the section.
</p></dd>
<dt>&lsquo;<samp>section-sent</samp>&rsquo;</dt>
<dd><p>The size of what has been sent so far for that section.
</p></dd>
<dt>&lsquo;<samp>section-size</samp>&rsquo;</dt>
<dd><p>The size of the section.
</p></dd>
<dt>&lsquo;<samp>total-sent</samp>&rsquo;</dt>
<dd><p>The total size of what was sent so far (the current and the previous sections).
</p></dd>
<dt>&lsquo;<samp>total-size</samp>&rsquo;</dt>
<dd><p>The size of the overall executable to download.
</p></dd>
</dl>
 
<p>Each message is sent as status record (see <a href="GDB_002fMI-Output-Syntax.html#GDB_002fMI-Output-Syntax"><small>GDB/MI</small> Output Syntax</a>).
</p>
<p>In addition, it prints the name and size of the sections, as they are
downloaded.  These messages include the following fields:
</p>
<dl compact="compact">
<dt>&lsquo;<samp>section</samp>&rsquo;</dt>
<dd><p>The name of the section.
</p></dd>
<dt>&lsquo;<samp>section-size</samp>&rsquo;</dt>
<dd><p>The size of the section.
</p></dd>
<dt>&lsquo;<samp>total-size</samp>&rsquo;</dt>
<dd><p>The size of the overall executable to download.
</p></dd>
</dl>
 
<p>At the end, a summary is printed.
</p>
<a name="GDB-Command-78"></a>
<h4 class="subsubheading"><small>GDB</small> Command</h4>
 
<p>The corresponding <small>GDB</small> command is &lsquo;<samp>load</samp>&rsquo;.
</p>
<a name="Example-78"></a>
<h4 class="subsubheading">Example</h4>
 
<p>Note: each status message appears on a single line.  Here the messages
have been broken down so that they can fit onto a page.
</p>
<div class="smallexample">
<pre class="smallexample">(gdb)
-target-download
+download,{section=&quot;.text&quot;,section-size=&quot;6668&quot;,total-size=&quot;9880&quot;}
+download,{section=&quot;.text&quot;,section-sent=&quot;512&quot;,section-size=&quot;6668&quot;,
total-sent=&quot;512&quot;,total-size=&quot;9880&quot;}
+download,{section=&quot;.text&quot;,section-sent=&quot;1024&quot;,section-size=&quot;6668&quot;,
total-sent=&quot;1024&quot;,total-size=&quot;9880&quot;}
+download,{section=&quot;.text&quot;,section-sent=&quot;1536&quot;,section-size=&quot;6668&quot;,
total-sent=&quot;1536&quot;,total-size=&quot;9880&quot;}
+download,{section=&quot;.text&quot;,section-sent=&quot;2048&quot;,section-size=&quot;6668&quot;,
total-sent=&quot;2048&quot;,total-size=&quot;9880&quot;}
+download,{section=&quot;.text&quot;,section-sent=&quot;2560&quot;,section-size=&quot;6668&quot;,
total-sent=&quot;2560&quot;,total-size=&quot;9880&quot;}
+download,{section=&quot;.text&quot;,section-sent=&quot;3072&quot;,section-size=&quot;6668&quot;,
total-sent=&quot;3072&quot;,total-size=&quot;9880&quot;}
+download,{section=&quot;.text&quot;,section-sent=&quot;3584&quot;,section-size=&quot;6668&quot;,
total-sent=&quot;3584&quot;,total-size=&quot;9880&quot;}
+download,{section=&quot;.text&quot;,section-sent=&quot;4096&quot;,section-size=&quot;6668&quot;,
total-sent=&quot;4096&quot;,total-size=&quot;9880&quot;}
+download,{section=&quot;.text&quot;,section-sent=&quot;4608&quot;,section-size=&quot;6668&quot;,
total-sent=&quot;4608&quot;,total-size=&quot;9880&quot;}
+download,{section=&quot;.text&quot;,section-sent=&quot;5120&quot;,section-size=&quot;6668&quot;,
total-sent=&quot;5120&quot;,total-size=&quot;9880&quot;}
+download,{section=&quot;.text&quot;,section-sent=&quot;5632&quot;,section-size=&quot;6668&quot;,
total-sent=&quot;5632&quot;,total-size=&quot;9880&quot;}
+download,{section=&quot;.text&quot;,section-sent=&quot;6144&quot;,section-size=&quot;6668&quot;,
total-sent=&quot;6144&quot;,total-size=&quot;9880&quot;}
+download,{section=&quot;.text&quot;,section-sent=&quot;6656&quot;,section-size=&quot;6668&quot;,
total-sent=&quot;6656&quot;,total-size=&quot;9880&quot;}
+download,{section=&quot;.init&quot;,section-size=&quot;28&quot;,total-size=&quot;9880&quot;}
+download,{section=&quot;.fini&quot;,section-size=&quot;28&quot;,total-size=&quot;9880&quot;}
+download,{section=&quot;.data&quot;,section-size=&quot;3156&quot;,total-size=&quot;9880&quot;}
+download,{section=&quot;.data&quot;,section-sent=&quot;512&quot;,section-size=&quot;3156&quot;,
total-sent=&quot;7236&quot;,total-size=&quot;9880&quot;}
+download,{section=&quot;.data&quot;,section-sent=&quot;1024&quot;,section-size=&quot;3156&quot;,
total-sent=&quot;7748&quot;,total-size=&quot;9880&quot;}
+download,{section=&quot;.data&quot;,section-sent=&quot;1536&quot;,section-size=&quot;3156&quot;,
total-sent=&quot;8260&quot;,total-size=&quot;9880&quot;}
+download,{section=&quot;.data&quot;,section-sent=&quot;2048&quot;,section-size=&quot;3156&quot;,
total-sent=&quot;8772&quot;,total-size=&quot;9880&quot;}
+download,{section=&quot;.data&quot;,section-sent=&quot;2560&quot;,section-size=&quot;3156&quot;,
total-sent=&quot;9284&quot;,total-size=&quot;9880&quot;}
+download,{section=&quot;.data&quot;,section-sent=&quot;3072&quot;,section-size=&quot;3156&quot;,
total-sent=&quot;9796&quot;,total-size=&quot;9880&quot;}
^done,address=&quot;0x10004&quot;,load-size=&quot;9880&quot;,transfer-rate=&quot;6586&quot;,
write-rate=&quot;429&quot;
(gdb)
</pre></div>
 
 
 
<a name="GDB-Command-79"></a>
<h4 class="subsubheading"><small>GDB</small> Command</h4>
 
<p>No equivalent.
</p>
<a name="Example-79"></a>
<h4 class="subsubheading">Example</h4>
<p>N.A.
</p>
<a name="The-_002dtarget_002dflash_002derase-Command"></a>
<h4 class="subheading">The <code>-target-flash-erase</code> Command</h4>
<a name="index-_002dtarget_002dflash_002derase"></a>
 
<a name="Synopsis-97"></a>
<h4 class="subsubheading">Synopsis</h4>
 
<div class="smallexample">
<pre class="smallexample"> -target-flash-erase
</pre></div>
 
<p>Erases all known flash memory regions on the target.
</p>
<p>The corresponding <small>GDB</small> command is &lsquo;<samp>flash-erase</samp>&rsquo;.
</p>
<p>The output is a list of flash regions that have been erased, with starting
addresses and memory region sizes.
</p>
<div class="smallexample">
<pre class="smallexample">(gdb)
-target-flash-erase
^done,erased-regions={address=&quot;0x0&quot;,size=&quot;0x40000&quot;}
(gdb)
</pre></div>
 
<a name="The-_002dtarget_002dselect-Command"></a>
<h4 class="subheading">The <code>-target-select</code> Command</h4>
<a name="index-_002dtarget_002dselect"></a>
 
<a name="Synopsis-98"></a>
<h4 class="subsubheading">Synopsis</h4>
 
<div class="smallexample">
<pre class="smallexample"> -target-select <var>type</var> <var>parameters &hellip;</var>
</pre></div>
 
<p>Connect <small>GDB</small> to the remote target.  This command takes two args:
</p>
<dl compact="compact">
<dt>&lsquo;<samp><var>type</var></samp>&rsquo;</dt>
<dd><p>The type of target, for instance &lsquo;<samp>remote</samp>&rsquo;, etc.
</p></dd>
<dt>&lsquo;<samp><var>parameters</var></samp>&rsquo;</dt>
<dd><p>Device names, host names and the like.  See <a href="Target-Commands.html#Target-Commands">Commands for Managing Targets</a>, for more details.
</p></dd>
</dl>
 
<p>The output is a connection notification, followed by the address at
which the target program is, in the following form:
</p>
<div class="smallexample">
<pre class="smallexample">^connected,addr=&quot;<var>address</var>&quot;,func=&quot;<var>function name</var>&quot;,
  args=[<var>arg list</var>]
</pre></div>
 
<a name="GDB-Command-80"></a>
<h4 class="subsubheading"><small>GDB</small> Command</h4>
 
<p>The corresponding <small>GDB</small> command is &lsquo;<samp>target</samp>&rsquo;.
</p>
<a name="Example-80"></a>
<h4 class="subsubheading">Example</h4>
 
<div class="smallexample">
<pre class="smallexample">(gdb)
-target-select remote /dev/ttya
^connected,addr=&quot;0xfe00a300&quot;,func=&quot;??&quot;,args=[]
(gdb)
</pre></div>
 
<hr>
<div class="header">
<p>
Next: <a href="GDB_002fMI-File-Transfer-Commands.html#GDB_002fMI-File-Transfer-Commands" accesskey="n" rel="next">GDB/MI File Transfer Commands</a>, Previous: <a href="GDB_002fMI-File-Commands.html#GDB_002fMI-File-Commands" accesskey="p" rel="previous">GDB/MI File Commands</a>, Up: <a href="GDB_002fMI.html#GDB_002fMI" accesskey="u" rel="up">GDB/MI</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>
 
 
 
</body>
</html>