You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GDB_002fMI-Target-Manipulation.html 15KB

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