GDB_002fMI-Target-Manipulation.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  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: GDB/MI Target Manipulation</title>
  16. <meta name="description" content="Debugging with GDB: GDB/MI Target Manipulation">
  17. <meta name="keywords" content="Debugging with GDB: GDB/MI Target Manipulation">
  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="GDB_002fMI.html#GDB_002fMI" rel="up" title="GDB/MI">
  26. <link href="GDB_002fMI-File-Transfer-Commands.html#GDB_002fMI-File-Transfer-Commands" rel="next" title="GDB/MI File Transfer Commands">
  27. <link href="GDB_002fMI-File-Commands.html#GDB_002fMI-File-Commands" rel="previous" title="GDB/MI File Commands">
  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="GDB_002fMI-Target-Manipulation"></a>
  59. <div class="header">
  60. <p>
  61. 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>
  62. </div>
  63. <hr>
  64. <a name="GDB_002fMI-Target-Manipulation-Commands"></a>
  65. <h3 class="section">27.20 <small>GDB/MI</small> Target Manipulation Commands</h3>
  66. <a name="The-_002dtarget_002dattach-Command"></a>
  67. <h4 class="subheading">The <code>-target-attach</code> Command</h4>
  68. <a name="index-_002dtarget_002dattach"></a>
  69. <a name="Synopsis-93"></a>
  70. <h4 class="subsubheading">Synopsis</h4>
  71. <div class="smallexample">
  72. <pre class="smallexample"> -target-attach <var>pid</var> | <var>gid</var> | <var>file</var>
  73. </pre></div>
  74. <p>Attach to a process <var>pid</var> or a file <var>file</var> outside of
  75. <small>GDB</small>, or a thread group <var>gid</var>. If attaching to a thread
  76. group, the id previously returned by
  77. &lsquo;<samp>-list-thread-groups --available</samp>&rsquo; must be used.
  78. </p>
  79. <a name="GDB-Command-75"></a>
  80. <h4 class="subsubheading"><small>GDB</small> Command</h4>
  81. <p>The corresponding <small>GDB</small> command is &lsquo;<samp>attach</samp>&rsquo;.
  82. </p>
  83. <a name="Example-75"></a>
  84. <h4 class="subsubheading">Example</h4>
  85. <div class="smallexample">
  86. <pre class="smallexample">(gdb)
  87. -target-attach 34
  88. =thread-created,id=&quot;1&quot;
  89. *stopped,thread-id=&quot;1&quot;,frame={addr=&quot;0xb7f7e410&quot;,func=&quot;bar&quot;,args=[]}
  90. ^done
  91. (gdb)
  92. </pre></div>
  93. <a name="The-_002dtarget_002ddetach-Command"></a>
  94. <h4 class="subheading">The <code>-target-detach</code> Command</h4>
  95. <a name="index-_002dtarget_002ddetach"></a>
  96. <a name="Synopsis-94"></a>
  97. <h4 class="subsubheading">Synopsis</h4>
  98. <div class="smallexample">
  99. <pre class="smallexample"> -target-detach [ <var>pid</var> | <var>gid</var> ]
  100. </pre></div>
  101. <p>Detach from the remote target which normally resumes its execution.
  102. If either <var>pid</var> or <var>gid</var> is specified, detaches from either
  103. the specified process, or specified thread group. There&rsquo;s no output.
  104. </p>
  105. <a name="GDB-Command-76"></a>
  106. <h4 class="subsubheading"><small>GDB</small> Command</h4>
  107. <p>The corresponding <small>GDB</small> command is &lsquo;<samp>detach</samp>&rsquo;.
  108. </p>
  109. <a name="Example-76"></a>
  110. <h4 class="subsubheading">Example</h4>
  111. <div class="smallexample">
  112. <pre class="smallexample">(gdb)
  113. -target-detach
  114. ^done
  115. (gdb)
  116. </pre></div>
  117. <a name="The-_002dtarget_002ddisconnect-Command"></a>
  118. <h4 class="subheading">The <code>-target-disconnect</code> Command</h4>
  119. <a name="index-_002dtarget_002ddisconnect"></a>
  120. <a name="Synopsis-95"></a>
  121. <h4 class="subsubheading">Synopsis</h4>
  122. <div class="smallexample">
  123. <pre class="smallexample"> -target-disconnect
  124. </pre></div>
  125. <p>Disconnect from the remote target. There&rsquo;s no output and the target is
  126. generally not resumed.
  127. </p>
  128. <a name="GDB-Command-77"></a>
  129. <h4 class="subsubheading"><small>GDB</small> Command</h4>
  130. <p>The corresponding <small>GDB</small> command is &lsquo;<samp>disconnect</samp>&rsquo;.
  131. </p>
  132. <a name="Example-77"></a>
  133. <h4 class="subsubheading">Example</h4>
  134. <div class="smallexample">
  135. <pre class="smallexample">(gdb)
  136. -target-disconnect
  137. ^done
  138. (gdb)
  139. </pre></div>
  140. <a name="The-_002dtarget_002ddownload-Command"></a>
  141. <h4 class="subheading">The <code>-target-download</code> Command</h4>
  142. <a name="index-_002dtarget_002ddownload"></a>
  143. <a name="Synopsis-96"></a>
  144. <h4 class="subsubheading">Synopsis</h4>
  145. <div class="smallexample">
  146. <pre class="smallexample"> -target-download
  147. </pre></div>
  148. <p>Loads the executable onto the remote target.
  149. It prints out an update message every half second, which includes the fields:
  150. </p>
  151. <dl compact="compact">
  152. <dt>&lsquo;<samp>section</samp>&rsquo;</dt>
  153. <dd><p>The name of the section.
  154. </p></dd>
  155. <dt>&lsquo;<samp>section-sent</samp>&rsquo;</dt>
  156. <dd><p>The size of what has been sent so far for that section.
  157. </p></dd>
  158. <dt>&lsquo;<samp>section-size</samp>&rsquo;</dt>
  159. <dd><p>The size of the section.
  160. </p></dd>
  161. <dt>&lsquo;<samp>total-sent</samp>&rsquo;</dt>
  162. <dd><p>The total size of what was sent so far (the current and the previous sections).
  163. </p></dd>
  164. <dt>&lsquo;<samp>total-size</samp>&rsquo;</dt>
  165. <dd><p>The size of the overall executable to download.
  166. </p></dd>
  167. </dl>
  168. <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>).
  169. </p>
  170. <p>In addition, it prints the name and size of the sections, as they are
  171. downloaded. These messages include the following fields:
  172. </p>
  173. <dl compact="compact">
  174. <dt>&lsquo;<samp>section</samp>&rsquo;</dt>
  175. <dd><p>The name of the section.
  176. </p></dd>
  177. <dt>&lsquo;<samp>section-size</samp>&rsquo;</dt>
  178. <dd><p>The size of the section.
  179. </p></dd>
  180. <dt>&lsquo;<samp>total-size</samp>&rsquo;</dt>
  181. <dd><p>The size of the overall executable to download.
  182. </p></dd>
  183. </dl>
  184. <p>At the end, a summary is printed.
  185. </p>
  186. <a name="GDB-Command-78"></a>
  187. <h4 class="subsubheading"><small>GDB</small> Command</h4>
  188. <p>The corresponding <small>GDB</small> command is &lsquo;<samp>load</samp>&rsquo;.
  189. </p>
  190. <a name="Example-78"></a>
  191. <h4 class="subsubheading">Example</h4>
  192. <p>Note: each status message appears on a single line. Here the messages
  193. have been broken down so that they can fit onto a page.
  194. </p>
  195. <div class="smallexample">
  196. <pre class="smallexample">(gdb)
  197. -target-download
  198. +download,{section=&quot;.text&quot;,section-size=&quot;6668&quot;,total-size=&quot;9880&quot;}
  199. +download,{section=&quot;.text&quot;,section-sent=&quot;512&quot;,section-size=&quot;6668&quot;,
  200. total-sent=&quot;512&quot;,total-size=&quot;9880&quot;}
  201. +download,{section=&quot;.text&quot;,section-sent=&quot;1024&quot;,section-size=&quot;6668&quot;,
  202. total-sent=&quot;1024&quot;,total-size=&quot;9880&quot;}
  203. +download,{section=&quot;.text&quot;,section-sent=&quot;1536&quot;,section-size=&quot;6668&quot;,
  204. total-sent=&quot;1536&quot;,total-size=&quot;9880&quot;}
  205. +download,{section=&quot;.text&quot;,section-sent=&quot;2048&quot;,section-size=&quot;6668&quot;,
  206. total-sent=&quot;2048&quot;,total-size=&quot;9880&quot;}
  207. +download,{section=&quot;.text&quot;,section-sent=&quot;2560&quot;,section-size=&quot;6668&quot;,
  208. total-sent=&quot;2560&quot;,total-size=&quot;9880&quot;}
  209. +download,{section=&quot;.text&quot;,section-sent=&quot;3072&quot;,section-size=&quot;6668&quot;,
  210. total-sent=&quot;3072&quot;,total-size=&quot;9880&quot;}
  211. +download,{section=&quot;.text&quot;,section-sent=&quot;3584&quot;,section-size=&quot;6668&quot;,
  212. total-sent=&quot;3584&quot;,total-size=&quot;9880&quot;}
  213. +download,{section=&quot;.text&quot;,section-sent=&quot;4096&quot;,section-size=&quot;6668&quot;,
  214. total-sent=&quot;4096&quot;,total-size=&quot;9880&quot;}
  215. +download,{section=&quot;.text&quot;,section-sent=&quot;4608&quot;,section-size=&quot;6668&quot;,
  216. total-sent=&quot;4608&quot;,total-size=&quot;9880&quot;}
  217. +download,{section=&quot;.text&quot;,section-sent=&quot;5120&quot;,section-size=&quot;6668&quot;,
  218. total-sent=&quot;5120&quot;,total-size=&quot;9880&quot;}
  219. +download,{section=&quot;.text&quot;,section-sent=&quot;5632&quot;,section-size=&quot;6668&quot;,
  220. total-sent=&quot;5632&quot;,total-size=&quot;9880&quot;}
  221. +download,{section=&quot;.text&quot;,section-sent=&quot;6144&quot;,section-size=&quot;6668&quot;,
  222. total-sent=&quot;6144&quot;,total-size=&quot;9880&quot;}
  223. +download,{section=&quot;.text&quot;,section-sent=&quot;6656&quot;,section-size=&quot;6668&quot;,
  224. total-sent=&quot;6656&quot;,total-size=&quot;9880&quot;}
  225. +download,{section=&quot;.init&quot;,section-size=&quot;28&quot;,total-size=&quot;9880&quot;}
  226. +download,{section=&quot;.fini&quot;,section-size=&quot;28&quot;,total-size=&quot;9880&quot;}
  227. +download,{section=&quot;.data&quot;,section-size=&quot;3156&quot;,total-size=&quot;9880&quot;}
  228. +download,{section=&quot;.data&quot;,section-sent=&quot;512&quot;,section-size=&quot;3156&quot;,
  229. total-sent=&quot;7236&quot;,total-size=&quot;9880&quot;}
  230. +download,{section=&quot;.data&quot;,section-sent=&quot;1024&quot;,section-size=&quot;3156&quot;,
  231. total-sent=&quot;7748&quot;,total-size=&quot;9880&quot;}
  232. +download,{section=&quot;.data&quot;,section-sent=&quot;1536&quot;,section-size=&quot;3156&quot;,
  233. total-sent=&quot;8260&quot;,total-size=&quot;9880&quot;}
  234. +download,{section=&quot;.data&quot;,section-sent=&quot;2048&quot;,section-size=&quot;3156&quot;,
  235. total-sent=&quot;8772&quot;,total-size=&quot;9880&quot;}
  236. +download,{section=&quot;.data&quot;,section-sent=&quot;2560&quot;,section-size=&quot;3156&quot;,
  237. total-sent=&quot;9284&quot;,total-size=&quot;9880&quot;}
  238. +download,{section=&quot;.data&quot;,section-sent=&quot;3072&quot;,section-size=&quot;3156&quot;,
  239. total-sent=&quot;9796&quot;,total-size=&quot;9880&quot;}
  240. ^done,address=&quot;0x10004&quot;,load-size=&quot;9880&quot;,transfer-rate=&quot;6586&quot;,
  241. write-rate=&quot;429&quot;
  242. (gdb)
  243. </pre></div>
  244. <a name="GDB-Command-79"></a>
  245. <h4 class="subsubheading"><small>GDB</small> Command</h4>
  246. <p>No equivalent.
  247. </p>
  248. <a name="Example-79"></a>
  249. <h4 class="subsubheading">Example</h4>
  250. <p>N.A.
  251. </p>
  252. <a name="The-_002dtarget_002dflash_002derase-Command"></a>
  253. <h4 class="subheading">The <code>-target-flash-erase</code> Command</h4>
  254. <a name="index-_002dtarget_002dflash_002derase"></a>
  255. <a name="Synopsis-97"></a>
  256. <h4 class="subsubheading">Synopsis</h4>
  257. <div class="smallexample">
  258. <pre class="smallexample"> -target-flash-erase
  259. </pre></div>
  260. <p>Erases all known flash memory regions on the target.
  261. </p>
  262. <p>The corresponding <small>GDB</small> command is &lsquo;<samp>flash-erase</samp>&rsquo;.
  263. </p>
  264. <p>The output is a list of flash regions that have been erased, with starting
  265. addresses and memory region sizes.
  266. </p>
  267. <div class="smallexample">
  268. <pre class="smallexample">(gdb)
  269. -target-flash-erase
  270. ^done,erased-regions={address=&quot;0x0&quot;,size=&quot;0x40000&quot;}
  271. (gdb)
  272. </pre></div>
  273. <a name="The-_002dtarget_002dselect-Command"></a>
  274. <h4 class="subheading">The <code>-target-select</code> Command</h4>
  275. <a name="index-_002dtarget_002dselect"></a>
  276. <a name="Synopsis-98"></a>
  277. <h4 class="subsubheading">Synopsis</h4>
  278. <div class="smallexample">
  279. <pre class="smallexample"> -target-select <var>type</var> <var>parameters &hellip;</var>
  280. </pre></div>
  281. <p>Connect <small>GDB</small> to the remote target. This command takes two args:
  282. </p>
  283. <dl compact="compact">
  284. <dt>&lsquo;<samp><var>type</var></samp>&rsquo;</dt>
  285. <dd><p>The type of target, for instance &lsquo;<samp>remote</samp>&rsquo;, etc.
  286. </p></dd>
  287. <dt>&lsquo;<samp><var>parameters</var></samp>&rsquo;</dt>
  288. <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.
  289. </p></dd>
  290. </dl>
  291. <p>The output is a connection notification, followed by the address at
  292. which the target program is, in the following form:
  293. </p>
  294. <div class="smallexample">
  295. <pre class="smallexample">^connected,addr=&quot;<var>address</var>&quot;,func=&quot;<var>function name</var>&quot;,
  296. args=[<var>arg list</var>]
  297. </pre></div>
  298. <a name="GDB-Command-80"></a>
  299. <h4 class="subsubheading"><small>GDB</small> Command</h4>
  300. <p>The corresponding <small>GDB</small> command is &lsquo;<samp>target</samp>&rsquo;.
  301. </p>
  302. <a name="Example-80"></a>
  303. <h4 class="subsubheading">Example</h4>
  304. <div class="smallexample">
  305. <pre class="smallexample">(gdb)
  306. -target-select remote /dev/ttya
  307. ^connected,addr=&quot;0xfe00a300&quot;,func=&quot;??&quot;,args=[]
  308. (gdb)
  309. </pre></div>
  310. <hr>
  311. <div class="header">
  312. <p>
  313. 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>
  314. </div>
  315. </body>
  316. </html>