Target-Commands.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-2020 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Free Software" and "Free Software Needs
  8. Free Documentation", with the Front-Cover Texts being "A GNU Manual,"
  9. and with the Back-Cover Texts as in (a) below.
  10. (a) The FSF's Back-Cover Text is: "You are free to copy and modify
  11. this GNU Manual. Buying copies from GNU Press supports the FSF in
  12. developing GNU and promoting software freedom." -->
  13. <!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
  14. <head>
  15. <title>Debugging with GDB: Target Commands</title>
  16. <meta name="description" content="Debugging with GDB: Target Commands">
  17. <meta name="keywords" content="Debugging with GDB: Target Commands">
  18. <meta name="resource-type" content="document">
  19. <meta name="distribution" content="global">
  20. <meta name="Generator" content="makeinfo">
  21. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  22. <link href="index.html#Top" rel="start" title="Top">
  23. <link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
  24. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  25. <link href="Targets.html#Targets" rel="up" title="Targets">
  26. <link href="Byte-Order.html#Byte-Order" rel="next" title="Byte Order">
  27. <link href="Active-Targets.html#Active-Targets" rel="previous" title="Active Targets">
  28. <style type="text/css">
  29. <!--
  30. a.summary-letter {text-decoration: none}
  31. blockquote.smallquotation {font-size: smaller}
  32. div.display {margin-left: 3.2em}
  33. div.example {margin-left: 3.2em}
  34. div.indentedblock {margin-left: 3.2em}
  35. div.lisp {margin-left: 3.2em}
  36. div.smalldisplay {margin-left: 3.2em}
  37. div.smallexample {margin-left: 3.2em}
  38. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  39. div.smalllisp {margin-left: 3.2em}
  40. kbd {font-style:oblique}
  41. pre.display {font-family: inherit}
  42. pre.format {font-family: inherit}
  43. pre.menu-comment {font-family: serif}
  44. pre.menu-preformatted {font-family: serif}
  45. pre.smalldisplay {font-family: inherit; font-size: smaller}
  46. pre.smallexample {font-size: smaller}
  47. pre.smallformat {font-family: inherit; font-size: smaller}
  48. pre.smalllisp {font-size: smaller}
  49. span.nocodebreak {white-space:nowrap}
  50. span.nolinebreak {white-space:nowrap}
  51. span.roman {font-family:serif; font-weight:normal}
  52. span.sansserif {font-family:sans-serif; font-weight:normal}
  53. ul.no-bullet {list-style: none}
  54. -->
  55. </style>
  56. </head>
  57. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  58. <a name="Target-Commands"></a>
  59. <div class="header">
  60. <p>
  61. 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>
  62. </div>
  63. <hr>
  64. <a name="Commands-for-Managing-Targets"></a>
  65. <h3 class="section">19.2 Commands for Managing Targets</h3>
  66. <dl compact="compact">
  67. <dt><code>target <var>type</var> <var>parameters</var></code></dt>
  68. <dd><p>Connects the <small>GDB</small> host environment to a target machine or
  69. process. A target is typically a protocol for talking to debugging
  70. facilities. You use the argument <var>type</var> to specify the type or
  71. protocol of the target machine.
  72. </p>
  73. <p>Further <var>parameters</var> are interpreted by the target protocol, but
  74. typically include things like device names or host names to connect
  75. with, process numbers, and baud rates.
  76. </p>
  77. <p>The <code>target</code> command does not repeat if you press <tt class="key">RET</tt> again
  78. after executing the command.
  79. </p>
  80. <a name="index-help-target"></a>
  81. </dd>
  82. <dt><code>help target</code></dt>
  83. <dd><p>Displays the names of all targets available. To display targets
  84. currently selected, use either <code>info target</code> or <code>info files</code>
  85. (see <a href="Files.html#Files">Commands to Specify Files</a>).
  86. </p>
  87. </dd>
  88. <dt><code>help target <var>name</var></code></dt>
  89. <dd><p>Describe a particular target, including any parameters necessary to
  90. select it.
  91. </p>
  92. <a name="index-set-gnutarget"></a>
  93. </dd>
  94. <dt><code>set gnutarget <var>args</var></code></dt>
  95. <dd><p><small>GDB</small> uses its own library BFD to read your files. <small>GDB</small>
  96. knows whether it is reading an <em>executable</em>,
  97. a <em>core</em>, or a <em>.o</em> file; however, you can specify the file format
  98. with the <code>set gnutarget</code> command. Unlike most <code>target</code> commands,
  99. with <code>gnutarget</code> the <code>target</code> refers to a program, not a machine.
  100. </p>
  101. <blockquote>
  102. <p><em>Warning:</em> To specify a file format with <code>set gnutarget</code>,
  103. you must know the actual BFD name.
  104. </p></blockquote>
  105. <p>See <a href="Files.html#Files">Commands to Specify Files</a>.
  106. </p>
  107. <a name="index-show-gnutarget"></a>
  108. </dd>
  109. <dt><code>show gnutarget</code></dt>
  110. <dd><p>Use the <code>show gnutarget</code> command to display what file format
  111. <code>gnutarget</code> is set to read. If you have not set <code>gnutarget</code>,
  112. <small>GDB</small> will determine the file format for each file automatically,
  113. and <code>show gnutarget</code> displays &lsquo;<samp>The current BFD target is &quot;auto&quot;</samp>&rsquo;.
  114. </p></dd>
  115. </dl>
  116. <a name="index-common-targets"></a>
  117. <p>Here are some common targets (available, or not, depending on the GDB
  118. configuration):
  119. </p>
  120. <dl compact="compact">
  121. <dd><a name="index-target"></a>
  122. </dd>
  123. <dt><code>target exec <var>program</var></code></dt>
  124. <dd><a name="index-executable-file-target"></a>
  125. <p>An executable file. &lsquo;<samp>target exec <var>program</var></samp>&rsquo; is the same as
  126. &lsquo;<samp>exec-file <var>program</var></samp>&rsquo;.
  127. </p>
  128. </dd>
  129. <dt><code>target core <var>filename</var></code></dt>
  130. <dd><a name="index-core-dump-file-target"></a>
  131. <p>A core dump file. &lsquo;<samp>target core <var>filename</var></samp>&rsquo; is the same as
  132. &lsquo;<samp>core-file <var>filename</var></samp>&rsquo;.
  133. </p>
  134. </dd>
  135. <dt><code>target remote <var>medium</var></code></dt>
  136. <dd><a name="index-remote-target"></a>
  137. <p>A remote system connected to <small>GDB</small> via a serial line or network
  138. connection. This command tells <small>GDB</small> to use its own remote
  139. protocol over <var>medium</var> for debugging. See <a href="Remote-Debugging.html#Remote-Debugging">Remote Debugging</a>.
  140. </p>
  141. <p>For example, if you have a board connected to <samp>/dev/ttya</samp> on the
  142. machine running <small>GDB</small>, you could say:
  143. </p>
  144. <div class="smallexample">
  145. <pre class="smallexample">target remote /dev/ttya
  146. </pre></div>
  147. <p><code>target remote</code> supports the <code>load</code> command. This is only
  148. useful if you have some other way of getting the stub to the target
  149. system, and you can put it somewhere in memory where it won&rsquo;t get
  150. clobbered by the download.
  151. </p>
  152. </dd>
  153. <dt><code>target sim <span class="roman">[</span><var>simargs</var><span class="roman">]</span> &hellip;</code></dt>
  154. <dd><a name="index-built_002din-simulator-target"></a>
  155. <p>Builtin CPU simulator. <small>GDB</small> includes simulators for most architectures.
  156. In general,
  157. </p><div class="smallexample">
  158. <pre class="smallexample"> target sim
  159. load
  160. run
  161. </pre></div>
  162. <p>works; however, you cannot assume that a specific memory map, device
  163. drivers, or even basic I/O is available, although some simulators do
  164. provide these. For info about any processor-specific simulator details,
  165. see the appropriate section in <a href="Embedded-Processors.html#Embedded-Processors">Embedded
  166. Processors</a>.
  167. </p>
  168. </dd>
  169. <dt><code>target native</code></dt>
  170. <dd><a name="index-native-target"></a>
  171. <p>Setup for local/native process debugging. Useful to make the
  172. <code>run</code> command spawn native processes (likewise <code>attach</code>,
  173. etc.) even when <code>set auto-connect-native-target</code> is <code>off</code>
  174. (see <a href="Starting.html#set-auto_002dconnect_002dnative_002dtarget">set auto-connect-native-target</a>).
  175. </p>
  176. </dd>
  177. </dl>
  178. <p>Different targets are available on different configurations of <small>GDB</small>;
  179. your configuration may have more or fewer targets.
  180. </p>
  181. <p>Many remote targets require you to download the executable&rsquo;s code once
  182. you&rsquo;ve successfully established a connection. You may wish to control
  183. various aspects of this process.
  184. </p>
  185. <dl compact="compact">
  186. <dt><code>set hash</code></dt>
  187. <dd><a name="index-set-hash_002c-for-remote-monitors"></a>
  188. <a name="index-hash-mark-while-downloading"></a>
  189. <p>This command controls whether a hash mark &lsquo;<samp>#</samp>&rsquo; is displayed while
  190. downloading a file to the remote monitor. If on, a hash mark is
  191. displayed after each S-record is successfully downloaded to the
  192. monitor.
  193. </p>
  194. </dd>
  195. <dt><code>show hash</code></dt>
  196. <dd><a name="index-show-hash_002c-for-remote-monitors"></a>
  197. <p>Show the current status of displaying the hash mark.
  198. </p>
  199. </dd>
  200. <dt><code>set debug monitor</code></dt>
  201. <dd><a name="index-set-debug-monitor"></a>
  202. <a name="index-display-remote-monitor-communications"></a>
  203. <p>Enable or disable display of communications messages between
  204. <small>GDB</small> and the remote monitor.
  205. </p>
  206. </dd>
  207. <dt><code>show debug monitor</code></dt>
  208. <dd><a name="index-show-debug-monitor"></a>
  209. <p>Show the current status of displaying communications between
  210. <small>GDB</small> and the remote monitor.
  211. </p></dd>
  212. </dl>
  213. <dl compact="compact">
  214. <dd>
  215. <a name="index-load-filename-offset"></a>
  216. </dd>
  217. <dt><code>load <var>filename</var> <var>offset</var></code></dt>
  218. <dd><a name="load"></a><p>Depending on what remote debugging facilities are configured into
  219. <small>GDB</small>, the <code>load</code> command may be available. Where it exists, it
  220. is meant to make <var>filename</var> (an executable) available for debugging
  221. on the remote system&mdash;by downloading, or dynamic linking, for example.
  222. <code>load</code> also records the <var>filename</var> symbol table in <small>GDB</small>, like
  223. the <code>add-symbol-file</code> command.
  224. </p>
  225. <p>If your <small>GDB</small> does not have a <code>load</code> command, attempting to
  226. execute it gets the error message &ldquo;<code>You can't do that when your
  227. target is &hellip;</code>&rdquo;
  228. </p>
  229. <p>The file is loaded at whatever address is specified in the executable.
  230. For some object file formats, you can specify the load address when you
  231. link the program; for other formats, like a.out, the object file format
  232. specifies a fixed address.
  233. </p>
  234. <p>It is also possible to tell <small>GDB</small> to load the executable file at a
  235. specific offset described by the optional argument <var>offset</var>. When
  236. <var>offset</var> is provided, <var>filename</var> must also be provided.
  237. </p>
  238. <p>Depending on the remote side capabilities, <small>GDB</small> may be able to
  239. load programs into flash memory.
  240. </p>
  241. <p><code>load</code> does not repeat if you press <tt class="key">RET</tt> again after using it.
  242. </p></dd>
  243. </dl>
  244. <dl compact="compact">
  245. <dd>
  246. <a name="index-flash_002derase"></a>
  247. </dd>
  248. <dt><code>flash-erase</code></dt>
  249. <dd><a name="flash_002derase"></a>
  250. <p>Erases all known flash memory regions on the target.
  251. </p>
  252. </dd>
  253. </dl>
  254. <hr>
  255. <div class="header">
  256. <p>
  257. 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>
  258. </div>
  259. </body>
  260. </html>