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
<!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: Target Commands</title>
 
<meta name="description" content="Debugging with GDB: Target Commands">
<meta name="keywords" content="Debugging with GDB: Target Commands">
<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="Targets.html#Targets" rel="up" title="Targets">
<link href="Byte-Order.html#Byte-Order" rel="next" title="Byte Order">
<link href="Active-Targets.html#Active-Targets" rel="previous" title="Active Targets">
<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="Target-Commands"></a>
<div class="header">
<p>
Next: <a href="Byte-Order.html#Byte-Order" accesskey="n" rel="next">Byte Order</a>, Previous: <a href="Active-Targets.html#Active-Targets" accesskey="p" rel="previous">Active Targets</a>, Up: <a href="Targets.html#Targets" accesskey="u" rel="up">Targets</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="Commands-for-Managing-Targets"></a>
<h3 class="section">19.2 Commands for Managing Targets</h3>
 
<dl compact="compact">
<dt><code>target <var>type</var> <var>parameters</var></code></dt>
<dd><p>Connects the <small>GDB</small> host environment to a target machine or
process.  A target is typically a protocol for talking to debugging
facilities.  You use the argument <var>type</var> to specify the type or
protocol of the target machine.
</p>
<p>Further <var>parameters</var> are interpreted by the target protocol, but
typically include things like device names or host names to connect
with, process numbers, and baud rates.
</p>
<p>The <code>target</code> command does not repeat if you press <tt class="key">RET</tt> again
after executing the command.
</p>
<a name="index-help-target"></a>
</dd>
<dt><code>help target</code></dt>
<dd><p>Displays the names of all targets available.  To display targets
currently selected, use either <code>info target</code> or <code>info files</code>
(see <a href="Files.html#Files">Commands to Specify Files</a>).
</p>
</dd>
<dt><code>help target <var>name</var></code></dt>
<dd><p>Describe a particular target, including any parameters necessary to
select it.
</p>
<a name="index-set-gnutarget"></a>
</dd>
<dt><code>set gnutarget <var>args</var></code></dt>
<dd><p><small>GDB</small> uses its own library BFD to read your files.  <small>GDB</small>
knows whether it is reading an <em>executable</em>,
a <em>core</em>, or a <em>.o</em> file; however, you can specify the file format
with the <code>set gnutarget</code> command.  Unlike most <code>target</code> commands,
with <code>gnutarget</code> the <code>target</code> refers to a program, not a machine.
</p>
<blockquote>
<p><em>Warning:</em> To specify a file format with <code>set gnutarget</code>,
you must know the actual BFD name.
</p></blockquote>
 
<p>See <a href="Files.html#Files">Commands to Specify Files</a>.
</p>
<a name="index-show-gnutarget"></a>
</dd>
<dt><code>show gnutarget</code></dt>
<dd><p>Use the <code>show gnutarget</code> command to display what file format
<code>gnutarget</code> is set to read.  If you have not set <code>gnutarget</code>,
<small>GDB</small> will determine the file format for each file automatically,
and <code>show gnutarget</code> displays &lsquo;<samp>The current BFD target is &quot;auto&quot;</samp>&rsquo;.
</p></dd>
</dl>
 
<a name="index-common-targets"></a>
<p>Here are some common targets (available, or not, depending on the GDB
configuration):
</p>
<dl compact="compact">
<dd><a name="index-target"></a>
</dd>
<dt><code>target exec <var>program</var></code></dt>
<dd><a name="index-executable-file-target"></a>
<p>An executable file.  &lsquo;<samp>target exec <var>program</var></samp>&rsquo; is the same as
&lsquo;<samp>exec-file <var>program</var></samp>&rsquo;.
</p>
</dd>
<dt><code>target core <var>filename</var></code></dt>
<dd><a name="index-core-dump-file-target"></a>
<p>A core dump file.  &lsquo;<samp>target core <var>filename</var></samp>&rsquo; is the same as
&lsquo;<samp>core-file <var>filename</var></samp>&rsquo;.
</p>
</dd>
<dt><code>target remote <var>medium</var></code></dt>
<dd><a name="index-remote-target"></a>
<p>A remote system connected to <small>GDB</small> via a serial line or network
connection.  This command tells <small>GDB</small> to use its own remote
protocol over <var>medium</var> for debugging.  See <a href="Remote-Debugging.html#Remote-Debugging">Remote Debugging</a>.
</p>
<p>For example, if you have a board connected to <samp>/dev/ttya</samp> on the
machine running <small>GDB</small>, you could say:
</p>
<div class="smallexample">
<pre class="smallexample">target remote /dev/ttya
</pre></div>
 
<p><code>target remote</code> supports the <code>load</code> command.  This is only
useful if you have some other way of getting the stub to the target
system, and you can put it somewhere in memory where it won&rsquo;t get
clobbered by the download.
</p>
</dd>
<dt><code>target sim <span class="roman">[</span><var>simargs</var><span class="roman">]</span> &hellip;</code></dt>
<dd><a name="index-built_002din-simulator-target"></a>
<p>Builtin CPU simulator.  <small>GDB</small> includes simulators for most architectures.
In general,
</p><div class="smallexample">
<pre class="smallexample">        target sim
        load
        run
</pre></div>
<p>works; however, you cannot assume that a specific memory map, device
drivers, or even basic I/O is available, although some simulators do
provide these.  For info about any processor-specific simulator details,
see the appropriate section in <a href="Embedded-Processors.html#Embedded-Processors">Embedded
Processors</a>.
</p>
</dd>
<dt><code>target native</code></dt>
<dd><a name="index-native-target"></a>
<p>Setup for local/native process debugging.  Useful to make the
<code>run</code> command spawn native processes (likewise <code>attach</code>,
etc.) even when <code>set auto-connect-native-target</code> is <code>off</code>
(see <a href="Starting.html#set-auto_002dconnect_002dnative_002dtarget">set auto-connect-native-target</a>).
</p>
</dd>
</dl>
 
<p>Different targets are available on different configurations of <small>GDB</small>;
your configuration may have more or fewer targets.
</p>
<p>Many remote targets require you to download the executable&rsquo;s code once
you&rsquo;ve successfully established a connection.  You may wish to control
various aspects of this process.
</p>
<dl compact="compact">
<dt><code>set hash</code></dt>
<dd><a name="index-set-hash_002c-for-remote-monitors"></a>
<a name="index-hash-mark-while-downloading"></a>
<p>This command controls whether a hash mark &lsquo;<samp>#</samp>&rsquo; is displayed while
downloading a file to the remote monitor.  If on, a hash mark is
displayed after each S-record is successfully downloaded to the
monitor.
</p>
</dd>
<dt><code>show hash</code></dt>
<dd><a name="index-show-hash_002c-for-remote-monitors"></a>
<p>Show the current status of displaying the hash mark.
</p>
</dd>
<dt><code>set debug monitor</code></dt>
<dd><a name="index-set-debug-monitor"></a>
<a name="index-display-remote-monitor-communications"></a>
<p>Enable or disable display of communications messages between
<small>GDB</small> and the remote monitor.
</p>
</dd>
<dt><code>show debug monitor</code></dt>
<dd><a name="index-show-debug-monitor"></a>
<p>Show the current status of displaying communications between
<small>GDB</small> and the remote monitor.
</p></dd>
</dl>
 
<dl compact="compact">
<dd>
<a name="index-load-filename-offset"></a>
</dd>
<dt><code>load <var>filename</var> <var>offset</var></code></dt>
<dd><a name="load"></a><p>Depending on what remote debugging facilities are configured into
<small>GDB</small>, the <code>load</code> command may be available.  Where it exists, it
is meant to make <var>filename</var> (an executable) available for debugging
on the remote system&mdash;by downloading, or dynamic linking, for example.
<code>load</code> also records the <var>filename</var> symbol table in <small>GDB</small>, like
the <code>add-symbol-file</code> command.
</p>
<p>If your <small>GDB</small> does not have a <code>load</code> command, attempting to
execute it gets the error message &ldquo;<code>You can't do that when your
target is &hellip;</code>&rdquo;
</p>
<p>The file is loaded at whatever address is specified in the executable.
For some object file formats, you can specify the load address when you
link the program; for other formats, like a.out, the object file format
specifies a fixed address.
</p>
<p>It is also possible to tell <small>GDB</small> to load the executable file at a
specific offset described by the optional argument <var>offset</var>.  When
<var>offset</var> is provided, <var>filename</var> must also be provided.
</p>
<p>Depending on the remote side capabilities, <small>GDB</small> may be able to
load programs into flash memory.
</p>
<p><code>load</code> does not repeat if you press <tt class="key">RET</tt> again after using it.
</p></dd>
</dl>
 
<dl compact="compact">
<dd>
<a name="index-flash_002derase"></a>
</dd>
<dt><code>flash-erase</code></dt>
<dd><a name="flash_002derase"></a>
<p>Erases all known flash memory regions on the target.
</p>
</dd>
</dl>
 
<hr>
<div class="header">
<p>
Next: <a href="Byte-Order.html#Byte-Order" accesskey="n" rel="next">Byte Order</a>, Previous: <a href="Active-Targets.html#Active-Targets" accesskey="p" rel="previous">Active Targets</a>, Up: <a href="Targets.html#Targets" accesskey="u" rel="up">Targets</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>