Packets.html 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000
  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: Packets</title>
  16. <meta name="description" content="Debugging with GDB: Packets">
  17. <meta name="keywords" content="Debugging with GDB: Packets">
  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="Remote-Protocol.html#Remote-Protocol" rel="up" title="Remote Protocol">
  26. <link href="Stop-Reply-Packets.html#Stop-Reply-Packets" rel="next" title="Stop Reply Packets">
  27. <link href="Overview.html#Overview" rel="previous" title="Overview">
  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="Packets"></a>
  59. <div class="header">
  60. <p>
  61. Next: <a href="Stop-Reply-Packets.html#Stop-Reply-Packets" accesskey="n" rel="next">Stop Reply Packets</a>, Previous: <a href="Overview.html#Overview" accesskey="p" rel="previous">Overview</a>, Up: <a href="Remote-Protocol.html#Remote-Protocol" accesskey="u" rel="up">Remote Protocol</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="Packets-1"></a>
  65. <h3 class="section">E.2 Packets</h3>
  66. <p>The following table provides a complete list of all currently defined
  67. <var>command</var>s and their corresponding response <var>data</var>.
  68. See <a href="File_002dI_002fO-Remote-Protocol-Extension.html#File_002dI_002fO-Remote-Protocol-Extension">File-I/O Remote Protocol Extension</a>, for details about the File
  69. I/O extension of the remote protocol.
  70. </p>
  71. <p>Each packet&rsquo;s description has a template showing the packet&rsquo;s overall
  72. syntax, followed by an explanation of the packet&rsquo;s meaning. We
  73. include spaces in some of the templates for clarity; these are not
  74. part of the packet&rsquo;s syntax. No <small>GDB</small> packet uses spaces to
  75. separate its components. For example, a template like &lsquo;<samp>foo
  76. <var>bar</var> <var>baz</var></samp>&rsquo; describes a packet beginning with the three ASCII
  77. bytes &lsquo;<samp>foo</samp>&rsquo;, followed by a <var>bar</var>, followed directly by a
  78. <var>baz</var>. <small>GDB</small> does not transmit a space character between the
  79. &lsquo;<samp>foo</samp>&rsquo; and the <var>bar</var>, or between the <var>bar</var> and the
  80. <var>baz</var>.
  81. </p>
  82. <a name="index-thread_002did_002c-in-remote-protocol"></a>
  83. <a name="thread_002did-syntax"></a><p>Several packets and replies include a <var>thread-id</var> field to identify
  84. a thread. Normally these are positive numbers with a target-specific
  85. interpretation, formatted as big-endian hex strings. A <var>thread-id</var>
  86. can also be a literal &lsquo;<samp>-1</samp>&rsquo; to indicate all threads, or &lsquo;<samp>0</samp>&rsquo; to
  87. pick any thread.
  88. </p>
  89. <p>In addition, the remote protocol supports a multiprocess feature in
  90. which the <var>thread-id</var> syntax is extended to optionally include both
  91. process and thread ID fields, as &lsquo;<samp>p<var>pid</var>.<var>tid</var></samp>&rsquo;.
  92. The <var>pid</var> (process) and <var>tid</var> (thread) components each have the
  93. format described above: a positive number with target-specific
  94. interpretation formatted as a big-endian hex string, literal &lsquo;<samp>-1</samp>&rsquo;
  95. to indicate all processes or threads (respectively), or &lsquo;<samp>0</samp>&rsquo; to
  96. indicate an arbitrary process or thread. Specifying just a process, as
  97. &lsquo;<samp>p<var>pid</var></samp>&rsquo;, is equivalent to &lsquo;<samp>p<var>pid</var>.-1</samp>&rsquo;. It is an
  98. error to specify all processes but a specific thread, such as
  99. &lsquo;<samp>p-1.<var>tid</var></samp>&rsquo;. Note that the &lsquo;<samp>p</samp>&rsquo; prefix is <em>not</em> used
  100. for those packets and replies explicitly documented to include a process
  101. ID, rather than a <var>thread-id</var>.
  102. </p>
  103. <p>The multiprocess <var>thread-id</var> syntax extensions are only used if both
  104. <small>GDB</small> and the stub report support for the &lsquo;<samp>multiprocess</samp>&rsquo;
  105. feature using &lsquo;<samp>qSupported</samp>&rsquo;. See <a href="General-Query-Packets.html#multiprocess-extensions">multiprocess extensions</a>, for
  106. more information.
  107. </p>
  108. <p>Note that all packet forms beginning with an upper- or lower-case
  109. letter, other than those described here, are reserved for future use.
  110. </p>
  111. <p>Here are the packet descriptions.
  112. </p>
  113. <dl compact="compact">
  114. <dt>&lsquo;<samp>!</samp>&rsquo;</dt>
  115. <dd><a name="index-_0021-packet"></a>
  116. <a name="extended-mode"></a><p>Enable extended mode. In extended mode, the remote server is made
  117. persistent. The &lsquo;<samp>R</samp>&rsquo; packet is used to restart the program being
  118. debugged.
  119. </p>
  120. <p>Reply:
  121. </p><dl compact="compact">
  122. <dt>&lsquo;<samp>OK</samp>&rsquo;</dt>
  123. <dd><p>The remote target both supports and has enabled extended mode.
  124. </p></dd>
  125. </dl>
  126. </dd>
  127. <dt>&lsquo;<samp>?</samp>&rsquo;</dt>
  128. <dd><a name="index-_003f-packet"></a>
  129. <a name="g_t_003f-packet"></a><p>Indicate the reason the target halted. The reply is the same as for
  130. step and continue. This packet has a special interpretation when the
  131. target is in non-stop mode; see <a href="Remote-Non_002dStop.html#Remote-Non_002dStop">Remote Non-Stop</a>.
  132. </p>
  133. <p>Reply:
  134. See <a href="Stop-Reply-Packets.html#Stop-Reply-Packets">Stop Reply Packets</a>, for the reply specifications.
  135. </p>
  136. </dd>
  137. <dt>&lsquo;<samp>A <var>arglen</var>,<var>argnum</var>,<var>arg</var>,&hellip;</samp>&rsquo;</dt>
  138. <dd><a name="index-A-packet"></a>
  139. <p>Initialized <code>argv[]</code> array passed into program. <var>arglen</var>
  140. specifies the number of bytes in the hex encoded byte stream
  141. <var>arg</var>. See <code>gdbserver</code> for more details.
  142. </p>
  143. <p>Reply:
  144. </p><dl compact="compact">
  145. <dt>&lsquo;<samp>OK</samp>&rsquo;</dt>
  146. <dd><p>The arguments were set.
  147. </p></dd>
  148. <dt>&lsquo;<samp>E <var>NN</var></samp>&rsquo;</dt>
  149. <dd><p>An error occurred.
  150. </p></dd>
  151. </dl>
  152. </dd>
  153. <dt>&lsquo;<samp>b <var>baud</var></samp>&rsquo;</dt>
  154. <dd><a name="index-b-packet"></a>
  155. <p>(Don&rsquo;t use this packet; its behavior is not well-defined.)
  156. Change the serial line speed to <var>baud</var>.
  157. </p>
  158. <p>JTC: <em>When does the transport layer state change? When it&rsquo;s
  159. received, or after the ACK is transmitted. In either case, there are
  160. problems if the command or the acknowledgment packet is dropped.</em>
  161. </p>
  162. <p>Stan: <em>If people really wanted to add something like this, and get
  163. it working for the first time, they ought to modify ser-unix.c to send
  164. some kind of out-of-band message to a specially-setup stub and have the
  165. switch happen &quot;in between&quot; packets, so that from remote protocol&rsquo;s point
  166. of view, nothing actually happened.</em>
  167. </p>
  168. </dd>
  169. <dt>&lsquo;<samp>B <var>addr</var>,<var>mode</var></samp>&rsquo;</dt>
  170. <dd><a name="index-B-packet"></a>
  171. <p>Set (<var>mode</var> is &lsquo;<samp>S</samp>&rsquo;) or clear (<var>mode</var> is &lsquo;<samp>C</samp>&rsquo;) a
  172. breakpoint at <var>addr</var>.
  173. </p>
  174. <p>Don&rsquo;t use this packet. Use the &lsquo;<samp>Z</samp>&rsquo; and &lsquo;<samp>z</samp>&rsquo; packets instead
  175. (see <a href="#insert-breakpoint-or-watchpoint-packet">insert breakpoint or watchpoint packet</a>).
  176. </p>
  177. <a name="index-bc-packet"></a>
  178. <a name="bc"></a></dd>
  179. <dt>&lsquo;<samp>bc</samp>&rsquo;</dt>
  180. <dd><p>Backward continue. Execute the target system in reverse. No parameter.
  181. See <a href="Reverse-Execution.html#Reverse-Execution">Reverse Execution</a>, for more information.
  182. </p>
  183. <p>Reply:
  184. See <a href="Stop-Reply-Packets.html#Stop-Reply-Packets">Stop Reply Packets</a>, for the reply specifications.
  185. </p>
  186. <a name="index-bs-packet"></a>
  187. <a name="bs"></a></dd>
  188. <dt>&lsquo;<samp>bs</samp>&rsquo;</dt>
  189. <dd><p>Backward single step. Execute one instruction in reverse. No parameter.
  190. See <a href="Reverse-Execution.html#Reverse-Execution">Reverse Execution</a>, for more information.
  191. </p>
  192. <p>Reply:
  193. See <a href="Stop-Reply-Packets.html#Stop-Reply-Packets">Stop Reply Packets</a>, for the reply specifications.
  194. </p>
  195. </dd>
  196. <dt>&lsquo;<samp>c <span class="roman">[</span><var>addr</var><span class="roman">]</span></samp>&rsquo;</dt>
  197. <dd><a name="index-c-packet"></a>
  198. <p>Continue at <var>addr</var>, which is the address to resume. If <var>addr</var>
  199. is omitted, resume at current address.
  200. </p>
  201. <p>This packet is deprecated for multi-threading support. See <a href="#vCont-packet">vCont packet</a>.
  202. </p>
  203. <p>Reply:
  204. See <a href="Stop-Reply-Packets.html#Stop-Reply-Packets">Stop Reply Packets</a>, for the reply specifications.
  205. </p>
  206. </dd>
  207. <dt>&lsquo;<samp>C <var>sig</var><span class="roman">[</span>;<var>addr</var><span class="roman">]</span></samp>&rsquo;</dt>
  208. <dd><a name="index-C-packet"></a>
  209. <p>Continue with signal <var>sig</var> (hex signal number). If
  210. &lsquo;<samp>;<var>addr</var></samp>&rsquo; is omitted, resume at same address.
  211. </p>
  212. <p>This packet is deprecated for multi-threading support. See <a href="#vCont-packet">vCont packet</a>.
  213. </p>
  214. <p>Reply:
  215. See <a href="Stop-Reply-Packets.html#Stop-Reply-Packets">Stop Reply Packets</a>, for the reply specifications.
  216. </p>
  217. </dd>
  218. <dt>&lsquo;<samp>d</samp>&rsquo;</dt>
  219. <dd><a name="index-d-packet"></a>
  220. <p>Toggle debug flag.
  221. </p>
  222. <p>Don&rsquo;t use this packet; instead, define a general set packet
  223. (see <a href="General-Query-Packets.html#General-Query-Packets">General Query Packets</a>).
  224. </p>
  225. </dd>
  226. <dt>&lsquo;<samp>D</samp>&rsquo;</dt>
  227. <dt>&lsquo;<samp>D;<var>pid</var></samp>&rsquo;</dt>
  228. <dd><a name="index-D-packet"></a>
  229. <p>The first form of the packet is used to detach <small>GDB</small> from the
  230. remote system. It is sent to the remote target
  231. before <small>GDB</small> disconnects via the <code>detach</code> command.
  232. </p>
  233. <p>The second form, including a process ID, is used when multiprocess
  234. protocol extensions are enabled (see <a href="General-Query-Packets.html#multiprocess-extensions">multiprocess extensions</a>), to
  235. detach only a specific process. The <var>pid</var> is specified as a
  236. big-endian hex string.
  237. </p>
  238. <p>Reply:
  239. </p><dl compact="compact">
  240. <dt>&lsquo;<samp>OK</samp>&rsquo;</dt>
  241. <dd><p>for success
  242. </p></dd>
  243. <dt>&lsquo;<samp>E <var>NN</var></samp>&rsquo;</dt>
  244. <dd><p>for an error
  245. </p></dd>
  246. </dl>
  247. </dd>
  248. <dt>&lsquo;<samp>F <var>RC</var>,<var>EE</var>,<var>CF</var>;<var>XX</var></samp>&rsquo;</dt>
  249. <dd><a name="index-F-packet"></a>
  250. <p>A reply from <small>GDB</small> to an &lsquo;<samp>F</samp>&rsquo; packet sent by the target.
  251. This is part of the File-I/O protocol extension. See <a href="File_002dI_002fO-Remote-Protocol-Extension.html#File_002dI_002fO-Remote-Protocol-Extension">File-I/O Remote Protocol Extension</a>, for the specification.
  252. </p>
  253. </dd>
  254. <dt>&lsquo;<samp>g</samp>&rsquo;</dt>
  255. <dd><a name="read-registers-packet"></a><a name="index-g-packet"></a>
  256. <p>Read general registers.
  257. </p>
  258. <p>Reply:
  259. </p><dl compact="compact">
  260. <dt>&lsquo;<samp><var>XX&hellip;</var></samp>&rsquo;</dt>
  261. <dd><p>Each byte of register data is described by two hex digits. The bytes
  262. with the register are transmitted in target byte order. The size of
  263. each register and their position within the &lsquo;<samp>g</samp>&rsquo; packet are
  264. determined by the <small>GDB</small> internal gdbarch functions
  265. <code>DEPRECATED_REGISTER_RAW_SIZE</code> and <code>gdbarch_register_name</code>.
  266. </p>
  267. <p>When reading registers from a trace frame (see <a href="Analyze-Collected-Data.html#Analyze-Collected-Data">Using the Collected Data</a>), the stub may also return a string of
  268. literal &lsquo;<samp>x</samp>&rsquo;&rsquo;s in place of the register data digits, to indicate
  269. that the corresponding register has not been collected, thus its value
  270. is unavailable. For example, for an architecture with 4 registers of
  271. 4 bytes each, the following reply indicates to <small>GDB</small> that
  272. registers 0 and 2 have not been collected, while registers 1 and 3
  273. have been collected, and both have zero value:
  274. </p>
  275. <div class="smallexample">
  276. <pre class="smallexample">-&gt; <code>g</code>
  277. &lt;- <code>xxxxxxxx00000000xxxxxxxx00000000</code>
  278. </pre></div>
  279. </dd>
  280. <dt>&lsquo;<samp>E <var>NN</var></samp>&rsquo;</dt>
  281. <dd><p>for an error.
  282. </p></dd>
  283. </dl>
  284. </dd>
  285. <dt>&lsquo;<samp>G <var>XX&hellip;</var></samp>&rsquo;</dt>
  286. <dd><a name="index-G-packet"></a>
  287. <p>Write general registers. See <a href="#read-registers-packet">read registers packet</a>, for a
  288. description of the <var>XX&hellip;</var> data.
  289. </p>
  290. <p>Reply:
  291. </p><dl compact="compact">
  292. <dt>&lsquo;<samp>OK</samp>&rsquo;</dt>
  293. <dd><p>for success
  294. </p></dd>
  295. <dt>&lsquo;<samp>E <var>NN</var></samp>&rsquo;</dt>
  296. <dd><p>for an error
  297. </p></dd>
  298. </dl>
  299. </dd>
  300. <dt>&lsquo;<samp>H <var>op</var> <var>thread-id</var></samp>&rsquo;</dt>
  301. <dd><a name="index-H-packet"></a>
  302. <p>Set thread for subsequent operations (&lsquo;<samp>m</samp>&rsquo;, &lsquo;<samp>M</samp>&rsquo;, &lsquo;<samp>g</samp>&rsquo;,
  303. &lsquo;<samp>G</samp>&rsquo;, et.al.). Depending on the operation to be performed, <var>op</var>
  304. should be &lsquo;<samp>c</samp>&rsquo; for step and continue operations (note that this
  305. is deprecated, supporting the &lsquo;<samp>vCont</samp>&rsquo; command is a better
  306. option), and &lsquo;<samp>g</samp>&rsquo; for other operations. The thread designator
  307. <var>thread-id</var> has the format and interpretation described in
  308. <a href="#thread_002did-syntax">thread-id syntax</a>.
  309. </p>
  310. <p>Reply:
  311. </p><dl compact="compact">
  312. <dt>&lsquo;<samp>OK</samp>&rsquo;</dt>
  313. <dd><p>for success
  314. </p></dd>
  315. <dt>&lsquo;<samp>E <var>NN</var></samp>&rsquo;</dt>
  316. <dd><p>for an error
  317. </p></dd>
  318. </dl>
  319. </dd>
  320. <dt>&lsquo;<samp>i <span class="roman">[</span><var>addr</var><span class="roman">[</span>,<var>nnn</var><span class="roman">]]</span></samp>&rsquo;</dt>
  321. <dd><a name="cycle-step-packet"></a><a name="index-i-packet"></a>
  322. <p>Step the remote target by a single clock cycle. If &lsquo;<samp>,<var>nnn</var></samp>&rsquo; is
  323. present, cycle step <var>nnn</var> cycles. If <var>addr</var> is present, cycle
  324. step starting at that address.
  325. </p>
  326. </dd>
  327. <dt>&lsquo;<samp>I</samp>&rsquo;</dt>
  328. <dd><a name="index-I-packet"></a>
  329. <p>Signal, then cycle step. See <a href="#step-with-signal-packet">step with signal packet</a>. See <a href="#cycle-step-packet">cycle step packet</a>.
  330. </p>
  331. </dd>
  332. <dt>&lsquo;<samp>k</samp>&rsquo;</dt>
  333. <dd><a name="index-k-packet"></a>
  334. <p>Kill request.
  335. </p>
  336. <p>The exact effect of this packet is not specified.
  337. </p>
  338. <p>For a bare-metal target, it may power cycle or reset the target
  339. system. For that reason, the &lsquo;<samp>k</samp>&rsquo; packet has no reply.
  340. </p>
  341. <p>For a single-process target, it may kill that process if possible.
  342. </p>
  343. <p>A multiple-process target may choose to kill just one process, or all
  344. that are under <small>GDB</small>&rsquo;s control. For more precise control, use
  345. the vKill packet (see <a href="#vKill-packet">vKill packet</a>).
  346. </p>
  347. <p>If the target system immediately closes the connection in response to
  348. &lsquo;<samp>k</samp>&rsquo;, <small>GDB</small> does not consider the lack of packet
  349. acknowledgment to be an error, and assumes the kill was successful.
  350. </p>
  351. <p>If connected using <kbd>target extended-remote</kbd>, and the target does
  352. not close the connection in response to a kill request, <small>GDB</small>
  353. probes the target state as if a new connection was opened
  354. (see <a href="#g_t_003f-packet">? packet</a>).
  355. </p>
  356. </dd>
  357. <dt>&lsquo;<samp>m <var>addr</var>,<var>length</var></samp>&rsquo;</dt>
  358. <dd><a name="index-m-packet"></a>
  359. <p>Read <var>length</var> addressable memory units starting at address <var>addr</var>
  360. (see <a href="Memory.html#addressable-memory-unit">addressable memory unit</a>). Note that <var>addr</var> may not be aligned to
  361. any particular boundary.
  362. </p>
  363. <p>The stub need not use any particular size or alignment when gathering
  364. data from memory for the response; even if <var>addr</var> is word-aligned
  365. and <var>length</var> is a multiple of the word size, the stub is free to
  366. use byte accesses, or not. For this reason, this packet may not be
  367. suitable for accessing memory-mapped I/O devices.
  368. <a name="index-alignment-of-remote-memory-accesses"></a>
  369. <a name="index-size-of-remote-memory-accesses"></a>
  370. <a name="index-memory_002c-alignment-and-size-of-remote-accesses"></a>
  371. </p>
  372. <p>Reply:
  373. </p><dl compact="compact">
  374. <dt>&lsquo;<samp><var>XX&hellip;</var></samp>&rsquo;</dt>
  375. <dd><p>Memory contents; each byte is transmitted as a two-digit hexadecimal number.
  376. The reply may contain fewer addressable memory units than requested if the
  377. server was able to read only part of the region of memory.
  378. </p></dd>
  379. <dt>&lsquo;<samp>E <var>NN</var></samp>&rsquo;</dt>
  380. <dd><p><var>NN</var> is errno
  381. </p></dd>
  382. </dl>
  383. </dd>
  384. <dt>&lsquo;<samp>M <var>addr</var>,<var>length</var>:<var>XX&hellip;</var></samp>&rsquo;</dt>
  385. <dd><a name="index-M-packet"></a>
  386. <p>Write <var>length</var> addressable memory units starting at address <var>addr</var>
  387. (see <a href="Memory.html#addressable-memory-unit">addressable memory unit</a>). The data is given by <var>XX&hellip;</var>; each
  388. byte is transmitted as a two-digit hexadecimal number.
  389. </p>
  390. <p>Reply:
  391. </p><dl compact="compact">
  392. <dt>&lsquo;<samp>OK</samp>&rsquo;</dt>
  393. <dd><p>for success
  394. </p></dd>
  395. <dt>&lsquo;<samp>E <var>NN</var></samp>&rsquo;</dt>
  396. <dd><p>for an error (this includes the case where only part of the data was
  397. written).
  398. </p></dd>
  399. </dl>
  400. </dd>
  401. <dt>&lsquo;<samp>p <var>n</var></samp>&rsquo;</dt>
  402. <dd><a name="index-p-packet"></a>
  403. <p>Read the value of register <var>n</var>; <var>n</var> is in hex.
  404. See <a href="#read-registers-packet">read registers packet</a>, for a description of how the returned
  405. register value is encoded.
  406. </p>
  407. <p>Reply:
  408. </p><dl compact="compact">
  409. <dt>&lsquo;<samp><var>XX&hellip;</var></samp>&rsquo;</dt>
  410. <dd><p>the register&rsquo;s value
  411. </p></dd>
  412. <dt>&lsquo;<samp>E <var>NN</var></samp>&rsquo;</dt>
  413. <dd><p>for an error
  414. </p></dd>
  415. <dt>&lsquo;<samp><!-- /@w --></samp>&rsquo;</dt>
  416. <dd><p>Indicating an unrecognized <var>query</var>.
  417. </p></dd>
  418. </dl>
  419. </dd>
  420. <dt>&lsquo;<samp>P <var>n&hellip;</var>=<var>r&hellip;</var></samp>&rsquo;</dt>
  421. <dd><a name="write-register-packet"></a><a name="index-P-packet"></a>
  422. <p>Write register <var>n&hellip;</var> with value <var>r&hellip;</var>. The register
  423. number <var>n</var> is in hexadecimal, and <var>r&hellip;</var> contains two hex
  424. digits for each byte in the register (target byte order).
  425. </p>
  426. <p>Reply:
  427. </p><dl compact="compact">
  428. <dt>&lsquo;<samp>OK</samp>&rsquo;</dt>
  429. <dd><p>for success
  430. </p></dd>
  431. <dt>&lsquo;<samp>E <var>NN</var></samp>&rsquo;</dt>
  432. <dd><p>for an error
  433. </p></dd>
  434. </dl>
  435. </dd>
  436. <dt>&lsquo;<samp>q <var>name</var> <var>params</var>&hellip;</samp>&rsquo;</dt>
  437. <dt>&lsquo;<samp>Q <var>name</var> <var>params</var>&hellip;</samp>&rsquo;</dt>
  438. <dd><a name="index-q-packet"></a>
  439. <a name="index-Q-packet"></a>
  440. <p>General query (&lsquo;<samp>q</samp>&rsquo;) and set (&lsquo;<samp>Q</samp>&rsquo;). These packets are
  441. described fully in <a href="General-Query-Packets.html#General-Query-Packets">General Query Packets</a>.
  442. </p>
  443. </dd>
  444. <dt>&lsquo;<samp>r</samp>&rsquo;</dt>
  445. <dd><a name="index-r-packet"></a>
  446. <p>Reset the entire system.
  447. </p>
  448. <p>Don&rsquo;t use this packet; use the &lsquo;<samp>R</samp>&rsquo; packet instead.
  449. </p>
  450. </dd>
  451. <dt>&lsquo;<samp>R <var>XX</var></samp>&rsquo;</dt>
  452. <dd><a name="index-R-packet"></a>
  453. <p>Restart the program being debugged. The <var>XX</var>, while needed, is ignored.
  454. This packet is only available in extended mode (see <a href="#extended-mode">extended mode</a>).
  455. </p>
  456. <p>The &lsquo;<samp>R</samp>&rsquo; packet has no reply.
  457. </p>
  458. </dd>
  459. <dt>&lsquo;<samp>s <span class="roman">[</span><var>addr</var><span class="roman">]</span></samp>&rsquo;</dt>
  460. <dd><a name="index-s-packet"></a>
  461. <p>Single step, resuming at <var>addr</var>. If
  462. <var>addr</var> is omitted, resume at same address.
  463. </p>
  464. <p>This packet is deprecated for multi-threading support. See <a href="#vCont-packet">vCont packet</a>.
  465. </p>
  466. <p>Reply:
  467. See <a href="Stop-Reply-Packets.html#Stop-Reply-Packets">Stop Reply Packets</a>, for the reply specifications.
  468. </p>
  469. </dd>
  470. <dt>&lsquo;<samp>S <var>sig</var><span class="roman">[</span>;<var>addr</var><span class="roman">]</span></samp>&rsquo;</dt>
  471. <dd><a name="step-with-signal-packet"></a><a name="index-S-packet"></a>
  472. <p>Step with signal. This is analogous to the &lsquo;<samp>C</samp>&rsquo; packet, but
  473. requests a single-step, rather than a normal resumption of execution.
  474. </p>
  475. <p>This packet is deprecated for multi-threading support. See <a href="#vCont-packet">vCont packet</a>.
  476. </p>
  477. <p>Reply:
  478. See <a href="Stop-Reply-Packets.html#Stop-Reply-Packets">Stop Reply Packets</a>, for the reply specifications.
  479. </p>
  480. </dd>
  481. <dt>&lsquo;<samp>t <var>addr</var>:<var>PP</var>,<var>MM</var></samp>&rsquo;</dt>
  482. <dd><a name="index-t-packet"></a>
  483. <p>Search backwards starting at address <var>addr</var> for a match with pattern
  484. <var>PP</var> and mask <var>MM</var>, both of which are are 4 byte long.
  485. There must be at least 3 digits in <var>addr</var>.
  486. </p>
  487. </dd>
  488. <dt>&lsquo;<samp>T <var>thread-id</var></samp>&rsquo;</dt>
  489. <dd><a name="index-T-packet"></a>
  490. <p>Find out if the thread <var>thread-id</var> is alive. See <a href="#thread_002did-syntax">thread-id syntax</a>.
  491. </p>
  492. <p>Reply:
  493. </p><dl compact="compact">
  494. <dt>&lsquo;<samp>OK</samp>&rsquo;</dt>
  495. <dd><p>thread is still alive
  496. </p></dd>
  497. <dt>&lsquo;<samp>E <var>NN</var></samp>&rsquo;</dt>
  498. <dd><p>thread is dead
  499. </p></dd>
  500. </dl>
  501. </dd>
  502. <dt>&lsquo;<samp>v</samp>&rsquo;</dt>
  503. <dd><p>Packets starting with &lsquo;<samp>v</samp>&rsquo; are identified by a multi-letter name,
  504. up to the first &lsquo;<samp>;</samp>&rsquo; or &lsquo;<samp>?</samp>&rsquo; (or the end of the packet).
  505. </p>
  506. </dd>
  507. <dt>&lsquo;<samp>vAttach;<var>pid</var></samp>&rsquo;</dt>
  508. <dd><a name="index-vAttach-packet"></a>
  509. <p>Attach to a new process with the specified process ID <var>pid</var>.
  510. The process ID is a
  511. hexadecimal integer identifying the process. In all-stop mode, all
  512. threads in the attached process are stopped; in non-stop mode, it may be
  513. attached without being stopped if that is supported by the target.
  514. </p>
  515. <p>This packet is only available in extended mode (see <a href="#extended-mode">extended mode</a>).
  516. </p>
  517. <p>Reply:
  518. </p><dl compact="compact">
  519. <dt>&lsquo;<samp>E <var>nn</var></samp>&rsquo;</dt>
  520. <dd><p>for an error
  521. </p></dd>
  522. <dt>&lsquo;<samp><span class="roman">Any stop packet</span></samp>&rsquo;</dt>
  523. <dd><p>for success in all-stop mode (see <a href="Stop-Reply-Packets.html#Stop-Reply-Packets">Stop Reply Packets</a>)
  524. </p></dd>
  525. <dt>&lsquo;<samp>OK</samp>&rsquo;</dt>
  526. <dd><p>for success in non-stop mode (see <a href="Remote-Non_002dStop.html#Remote-Non_002dStop">Remote Non-Stop</a>)
  527. </p></dd>
  528. </dl>
  529. </dd>
  530. <dt>&lsquo;<samp>vCont<span class="roman">[</span>;<var>action</var><span class="roman">[</span>:<var>thread-id</var><span class="roman">]]</span>&hellip;</samp>&rsquo;</dt>
  531. <dd><a name="index-vCont-packet"></a>
  532. <a name="vCont-packet"></a><p>Resume the inferior, specifying different actions for each thread.
  533. </p>
  534. <p>For each inferior thread, the leftmost action with a matching
  535. <var>thread-id</var> is applied. Threads that don&rsquo;t match any action
  536. remain in their current state. Thread IDs are specified using the
  537. syntax described in <a href="#thread_002did-syntax">thread-id syntax</a>. If multiprocess
  538. extensions (see <a href="General-Query-Packets.html#multiprocess-extensions">multiprocess extensions</a>) are supported, actions
  539. can be specified to match all threads in a process by using the
  540. &lsquo;<samp>p<var>pid</var>.-1</samp>&rsquo; form of the <var>thread-id</var>. An action with no
  541. <var>thread-id</var> matches all threads. Specifying no actions is an
  542. error.
  543. </p>
  544. <p>Currently supported actions are:
  545. </p>
  546. <dl compact="compact">
  547. <dt>&lsquo;<samp>c</samp>&rsquo;</dt>
  548. <dd><p>Continue.
  549. </p></dd>
  550. <dt>&lsquo;<samp>C <var>sig</var></samp>&rsquo;</dt>
  551. <dd><p>Continue with signal <var>sig</var>. The signal <var>sig</var> should be two hex digits.
  552. </p></dd>
  553. <dt>&lsquo;<samp>s</samp>&rsquo;</dt>
  554. <dd><p>Step.
  555. </p></dd>
  556. <dt>&lsquo;<samp>S <var>sig</var></samp>&rsquo;</dt>
  557. <dd><p>Step with signal <var>sig</var>. The signal <var>sig</var> should be two hex digits.
  558. </p></dd>
  559. <dt>&lsquo;<samp>t</samp>&rsquo;</dt>
  560. <dd><p>Stop.
  561. </p></dd>
  562. <dt>&lsquo;<samp>r <var>start</var>,<var>end</var></samp>&rsquo;</dt>
  563. <dd><p>Step once, and then keep stepping as long as the thread stops at
  564. addresses between <var>start</var> (inclusive) and <var>end</var> (exclusive).
  565. The remote stub reports a stop reply when either the thread goes out
  566. of the range or is stopped due to an unrelated reason, such as hitting
  567. a breakpoint. See <a href="Continuing-and-Stepping.html#range-stepping">range stepping</a>.
  568. </p>
  569. <p>If the range is empty (<var>start</var> == <var>end</var>), then the action
  570. becomes equivalent to the &lsquo;<samp>s</samp>&rsquo; action. In other words,
  571. single-step once, and report the stop (even if the stepped instruction
  572. jumps to <var>start</var>).
  573. </p>
  574. <p>(A stop reply may be sent at any point even if the PC is still within
  575. the stepping range; for example, it is valid to implement this packet
  576. in a degenerate way as a single instruction step operation.)
  577. </p>
  578. </dd>
  579. </dl>
  580. <p>The optional argument <var>addr</var> normally associated with the
  581. &lsquo;<samp>c</samp>&rsquo;, &lsquo;<samp>C</samp>&rsquo;, &lsquo;<samp>s</samp>&rsquo;, and &lsquo;<samp>S</samp>&rsquo; packets is
  582. not supported in &lsquo;<samp>vCont</samp>&rsquo;.
  583. </p>
  584. <p>The &lsquo;<samp>t</samp>&rsquo; action is only relevant in non-stop mode
  585. (see <a href="Remote-Non_002dStop.html#Remote-Non_002dStop">Remote Non-Stop</a>) and may be ignored by the stub otherwise.
  586. A stop reply should be generated for any affected thread not already stopped.
  587. When a thread is stopped by means of a &lsquo;<samp>t</samp>&rsquo; action,
  588. the corresponding stop reply should indicate that the thread has stopped with
  589. signal &lsquo;<samp>0</samp>&rsquo;, regardless of whether the target uses some other signal
  590. as an implementation detail.
  591. </p>
  592. <p>The server must ignore &lsquo;<samp>c</samp>&rsquo;, &lsquo;<samp>C</samp>&rsquo;, &lsquo;<samp>s</samp>&rsquo;, &lsquo;<samp>S</samp>&rsquo;, and
  593. &lsquo;<samp>r</samp>&rsquo; actions for threads that are already running. Conversely,
  594. the server must ignore &lsquo;<samp>t</samp>&rsquo; actions for threads that are already
  595. stopped.
  596. </p>
  597. <p><em>Note:</em> In non-stop mode, a thread is considered running until
  598. <small>GDB</small> acknowledges an asynchronous stop notification for it with
  599. the &lsquo;<samp>vStopped</samp>&rsquo; packet (see <a href="Remote-Non_002dStop.html#Remote-Non_002dStop">Remote Non-Stop</a>).
  600. </p>
  601. <p>The stub must support &lsquo;<samp>vCont</samp>&rsquo; if it reports support for
  602. multiprocess extensions (see <a href="General-Query-Packets.html#multiprocess-extensions">multiprocess extensions</a>).
  603. </p>
  604. <p>Reply:
  605. See <a href="Stop-Reply-Packets.html#Stop-Reply-Packets">Stop Reply Packets</a>, for the reply specifications.
  606. </p>
  607. </dd>
  608. <dt>&lsquo;<samp>vCont?</samp>&rsquo;</dt>
  609. <dd><a name="index-vCont_003f-packet"></a>
  610. <p>Request a list of actions supported by the &lsquo;<samp>vCont</samp>&rsquo; packet.
  611. </p>
  612. <p>Reply:
  613. </p><dl compact="compact">
  614. <dt>&lsquo;<samp>vCont<span class="roman">[</span>;<var>action</var>&hellip;<span class="roman">]</span></samp>&rsquo;</dt>
  615. <dd><p>The &lsquo;<samp>vCont</samp>&rsquo; packet is supported. Each <var>action</var> is a supported
  616. command in the &lsquo;<samp>vCont</samp>&rsquo; packet.
  617. </p></dd>
  618. <dt>&lsquo;<samp><!-- /@w --></samp>&rsquo;</dt>
  619. <dd><p>The &lsquo;<samp>vCont</samp>&rsquo; packet is not supported.
  620. </p></dd>
  621. </dl>
  622. <a name="vCtrlC-packet"></a></dd>
  623. <dt>&lsquo;<samp>vCtrlC</samp>&rsquo;</dt>
  624. <dd><a name="index-vCtrlC-packet"></a>
  625. <p>Interrupt remote target as if a control-C was pressed on the remote
  626. terminal. This is the equivalent to reacting to the <code>^C</code>
  627. (&lsquo;<samp>\003</samp>&rsquo;, the control-C character) character in all-stop mode
  628. while the target is running, except this works in non-stop mode.
  629. See <a href="Interrupts.html#interrupting-remote-targets">interrupting remote targets</a>, for more info on the all-stop
  630. variant.
  631. </p>
  632. <p>Reply:
  633. </p><dl compact="compact">
  634. <dt>&lsquo;<samp>E <var>nn</var></samp>&rsquo;</dt>
  635. <dd><p>for an error
  636. </p></dd>
  637. <dt>&lsquo;<samp>OK</samp>&rsquo;</dt>
  638. <dd><p>for success
  639. </p></dd>
  640. </dl>
  641. </dd>
  642. <dt>&lsquo;<samp>vFile:<var>operation</var>:<var>parameter</var>&hellip;</samp>&rsquo;</dt>
  643. <dd><a name="index-vFile-packet"></a>
  644. <p>Perform a file operation on the target system. For details,
  645. see <a href="Host-I_002fO-Packets.html#Host-I_002fO-Packets">Host I/O Packets</a>.
  646. </p>
  647. </dd>
  648. <dt>&lsquo;<samp>vFlashErase:<var>addr</var>,<var>length</var></samp>&rsquo;</dt>
  649. <dd><a name="index-vFlashErase-packet"></a>
  650. <p>Direct the stub to erase <var>length</var> bytes of flash starting at
  651. <var>addr</var>. The region may enclose any number of flash blocks, but
  652. its start and end must fall on block boundaries, as indicated by the
  653. flash block size appearing in the memory map (see <a href="Memory-Map-Format.html#Memory-Map-Format">Memory Map Format</a>). <small>GDB</small> groups flash memory programming operations
  654. together, and sends a &lsquo;<samp>vFlashDone</samp>&rsquo; request after each group; the
  655. stub is allowed to delay erase operation until the &lsquo;<samp>vFlashDone</samp>&rsquo;
  656. packet is received.
  657. </p>
  658. <p>Reply:
  659. </p><dl compact="compact">
  660. <dt>&lsquo;<samp>OK</samp>&rsquo;</dt>
  661. <dd><p>for success
  662. </p></dd>
  663. <dt>&lsquo;<samp>E <var>NN</var></samp>&rsquo;</dt>
  664. <dd><p>for an error
  665. </p></dd>
  666. </dl>
  667. </dd>
  668. <dt>&lsquo;<samp>vFlashWrite:<var>addr</var>:<var>XX&hellip;</var></samp>&rsquo;</dt>
  669. <dd><a name="index-vFlashWrite-packet"></a>
  670. <p>Direct the stub to write data to flash address <var>addr</var>. The data
  671. is passed in binary form using the same encoding as for the &lsquo;<samp>X</samp>&rsquo;
  672. packet (see <a href="Overview.html#Binary-Data">Binary Data</a>). The memory ranges specified by
  673. &lsquo;<samp>vFlashWrite</samp>&rsquo; packets preceding a &lsquo;<samp>vFlashDone</samp>&rsquo; packet must
  674. not overlap, and must appear in order of increasing addresses
  675. (although &lsquo;<samp>vFlashErase</samp>&rsquo; packets for higher addresses may already
  676. have been received; the ordering is guaranteed only between
  677. &lsquo;<samp>vFlashWrite</samp>&rsquo; packets). If a packet writes to an address that was
  678. neither erased by a preceding &lsquo;<samp>vFlashErase</samp>&rsquo; packet nor by some other
  679. target-specific method, the results are unpredictable.
  680. </p>
  681. <p>Reply:
  682. </p><dl compact="compact">
  683. <dt>&lsquo;<samp>OK</samp>&rsquo;</dt>
  684. <dd><p>for success
  685. </p></dd>
  686. <dt>&lsquo;<samp>E.memtype</samp>&rsquo;</dt>
  687. <dd><p>for vFlashWrite addressing non-flash memory
  688. </p></dd>
  689. <dt>&lsquo;<samp>E <var>NN</var></samp>&rsquo;</dt>
  690. <dd><p>for an error
  691. </p></dd>
  692. </dl>
  693. </dd>
  694. <dt>&lsquo;<samp>vFlashDone</samp>&rsquo;</dt>
  695. <dd><a name="index-vFlashDone-packet"></a>
  696. <p>Indicate to the stub that flash programming operation is finished.
  697. The stub is permitted to delay or batch the effects of a group of
  698. &lsquo;<samp>vFlashErase</samp>&rsquo; and &lsquo;<samp>vFlashWrite</samp>&rsquo; packets until a
  699. &lsquo;<samp>vFlashDone</samp>&rsquo; packet is received. The contents of the affected
  700. regions of flash memory are unpredictable until the &lsquo;<samp>vFlashDone</samp>&rsquo;
  701. request is completed.
  702. </p>
  703. </dd>
  704. <dt>&lsquo;<samp>vKill;<var>pid</var></samp>&rsquo;</dt>
  705. <dd><a name="index-vKill-packet"></a>
  706. <a name="vKill-packet"></a><p>Kill the process with the specified process ID <var>pid</var>, which is a
  707. hexadecimal integer identifying the process. This packet is used in
  708. preference to &lsquo;<samp>k</samp>&rsquo; when multiprocess protocol extensions are
  709. supported; see <a href="General-Query-Packets.html#multiprocess-extensions">multiprocess extensions</a>.
  710. </p>
  711. <p>Reply:
  712. </p><dl compact="compact">
  713. <dt>&lsquo;<samp>E <var>nn</var></samp>&rsquo;</dt>
  714. <dd><p>for an error
  715. </p></dd>
  716. <dt>&lsquo;<samp>OK</samp>&rsquo;</dt>
  717. <dd><p>for success
  718. </p></dd>
  719. </dl>
  720. </dd>
  721. <dt>&lsquo;<samp>vMustReplyEmpty</samp>&rsquo;</dt>
  722. <dd><a name="index-vMustReplyEmpty-packet"></a>
  723. <p>The correct reply to an unknown &lsquo;<samp>v</samp>&rsquo; packet is to return the empty
  724. string, however, some older versions of <code>gdbserver</code> would
  725. incorrectly return &lsquo;<samp>OK</samp>&rsquo; for unknown &lsquo;<samp>v</samp>&rsquo; packets.
  726. </p>
  727. <p>The &lsquo;<samp>vMustReplyEmpty</samp>&rsquo; is used as a feature test to check how
  728. <code>gdbserver</code> handles unknown packets, it is important that this
  729. packet be handled in the same way as other unknown &lsquo;<samp>v</samp>&rsquo; packets.
  730. If this packet is handled differently to other unknown &lsquo;<samp>v</samp>&rsquo;
  731. packets then it is possible that <small>GDB</small> may run into problems in
  732. other areas, specifically around use of &lsquo;<samp>vFile:setfs:</samp>&rsquo;.
  733. </p>
  734. </dd>
  735. <dt>&lsquo;<samp>vRun;<var>filename</var><span class="roman">[</span>;<var>argument</var><span class="roman">]</span>&hellip;</samp>&rsquo;</dt>
  736. <dd><a name="index-vRun-packet"></a>
  737. <p>Run the program <var>filename</var>, passing it each <var>argument</var> on its
  738. command line. The file and arguments are hex-encoded strings. If
  739. <var>filename</var> is an empty string, the stub may use a default program
  740. (e.g. the last program run). The program is created in the stopped
  741. state.
  742. </p>
  743. <p>This packet is only available in extended mode (see <a href="#extended-mode">extended mode</a>).
  744. </p>
  745. <p>Reply:
  746. </p><dl compact="compact">
  747. <dt>&lsquo;<samp>E <var>nn</var></samp>&rsquo;</dt>
  748. <dd><p>for an error
  749. </p></dd>
  750. <dt>&lsquo;<samp><span class="roman">Any stop packet</span></samp>&rsquo;</dt>
  751. <dd><p>for success (see <a href="Stop-Reply-Packets.html#Stop-Reply-Packets">Stop Reply Packets</a>)
  752. </p></dd>
  753. </dl>
  754. </dd>
  755. <dt>&lsquo;<samp>vStopped</samp>&rsquo;</dt>
  756. <dd><a name="index-vStopped-packet"></a>
  757. <p>See <a href="Notification-Packets.html#Notification-Packets">Notification Packets</a>.
  758. </p>
  759. </dd>
  760. <dt>&lsquo;<samp>X <var>addr</var>,<var>length</var>:<var>XX&hellip;</var></samp>&rsquo;</dt>
  761. <dd><a name="X-packet"></a><a name="index-X-packet"></a>
  762. <p>Write data to memory, where the data is transmitted in binary.
  763. Memory is specified by its address <var>addr</var> and number of addressable memory
  764. units <var>length</var> (see <a href="Memory.html#addressable-memory-unit">addressable memory unit</a>);
  765. &lsquo;<samp><var>XX</var>&hellip;</samp>&rsquo; is binary data (see <a href="Overview.html#Binary-Data">Binary Data</a>).
  766. </p>
  767. <p>Reply:
  768. </p><dl compact="compact">
  769. <dt>&lsquo;<samp>OK</samp>&rsquo;</dt>
  770. <dd><p>for success
  771. </p></dd>
  772. <dt>&lsquo;<samp>E <var>NN</var></samp>&rsquo;</dt>
  773. <dd><p>for an error
  774. </p></dd>
  775. </dl>
  776. </dd>
  777. <dt>&lsquo;<samp>z <var>type</var>,<var>addr</var>,<var>kind</var></samp>&rsquo;</dt>
  778. <dt>&lsquo;<samp>Z <var>type</var>,<var>addr</var>,<var>kind</var></samp>&rsquo;</dt>
  779. <dd><a name="insert-breakpoint-or-watchpoint-packet"></a><a name="index-z-packet"></a>
  780. <a name="index-Z-packets"></a>
  781. <p>Insert (&lsquo;<samp>Z</samp>&rsquo;) or remove (&lsquo;<samp>z</samp>&rsquo;) a <var>type</var> breakpoint or
  782. watchpoint starting at address <var>address</var> of kind <var>kind</var>.
  783. </p>
  784. <p>Each breakpoint and watchpoint packet <var>type</var> is documented
  785. separately.
  786. </p>
  787. <p><em>Implementation notes: A remote target shall return an empty string
  788. for an unrecognized breakpoint or watchpoint packet <var>type</var>. A
  789. remote target shall support either both or neither of a given
  790. &lsquo;<samp>Z<var>type</var>&hellip;</samp>&rsquo; and &lsquo;<samp>z<var>type</var>&hellip;</samp>&rsquo; packet pair. To
  791. avoid potential problems with duplicate packets, the operations should
  792. be implemented in an idempotent way.</em>
  793. </p>
  794. </dd>
  795. <dt>&lsquo;<samp>z0,<var>addr</var>,<var>kind</var></samp>&rsquo;</dt>
  796. <dt>&lsquo;<samp>Z0,<var>addr</var>,<var>kind</var><span class="roman">[</span>;<var>cond_list</var>&hellip;<span class="roman">]</span><span class="roman">[</span>;cmds:<var>persist</var>,<var>cmd_list</var>&hellip;<span class="roman">]</span></samp>&rsquo;</dt>
  797. <dd><a name="index-z0-packet"></a>
  798. <a name="index-Z0-packet"></a>
  799. <p>Insert (&lsquo;<samp>Z0</samp>&rsquo;) or remove (&lsquo;<samp>z0</samp>&rsquo;) a software breakpoint at address
  800. <var>addr</var> of type <var>kind</var>.
  801. </p>
  802. <p>A software breakpoint is implemented by replacing the instruction at
  803. <var>addr</var> with a software breakpoint or trap instruction. The
  804. <var>kind</var> is target-specific and typically indicates the size of the
  805. breakpoint in bytes that should be inserted. E.g., the <small>ARM</small> and
  806. <small>MIPS</small> can insert either a 2 or 4 byte breakpoint. Some
  807. architectures have additional meanings for <var>kind</var>
  808. (see <a href="Architecture_002dSpecific-Protocol-Details.html#Architecture_002dSpecific-Protocol-Details">Architecture-Specific Protocol Details</a>); if no
  809. architecture-specific value is being used, it should be &lsquo;<samp>0</samp>&rsquo;.
  810. <var>kind</var> is hex-encoded. <var>cond_list</var> is an optional list of
  811. conditional expressions in bytecode form that should be evaluated on
  812. the target&rsquo;s side. These are the conditions that should be taken into
  813. consideration when deciding if the breakpoint trigger should be
  814. reported back to <small>GDB</small>.
  815. </p>
  816. <p>See also the &lsquo;<samp>swbreak</samp>&rsquo; stop reason (see <a href="Stop-Reply-Packets.html#swbreak-stop-reason">swbreak stop reason</a>)
  817. for how to best report a software breakpoint event to <small>GDB</small>.
  818. </p>
  819. <p>The <var>cond_list</var> parameter is comprised of a series of expressions,
  820. concatenated without separators. Each expression has the following form:
  821. </p>
  822. <dl compact="compact">
  823. <dt>&lsquo;<samp>X <var>len</var>,<var>expr</var></samp>&rsquo;</dt>
  824. <dd><p><var>len</var> is the length of the bytecode expression and <var>expr</var> is the
  825. actual conditional expression in bytecode form.
  826. </p>
  827. </dd>
  828. </dl>
  829. <p>The optional <var>cmd_list</var> parameter introduces commands that may be
  830. run on the target, rather than being reported back to <small>GDB</small>.
  831. The parameter starts with a numeric flag <var>persist</var>; if the flag is
  832. nonzero, then the breakpoint may remain active and the commands
  833. continue to be run even when <small>GDB</small> disconnects from the target.
  834. Following this flag is a series of expressions concatenated with no
  835. separators. Each expression has the following form:
  836. </p>
  837. <dl compact="compact">
  838. <dt>&lsquo;<samp>X <var>len</var>,<var>expr</var></samp>&rsquo;</dt>
  839. <dd><p><var>len</var> is the length of the bytecode expression and <var>expr</var> is the
  840. actual commands expression in bytecode form.
  841. </p>
  842. </dd>
  843. </dl>
  844. <p><em>Implementation note: It is possible for a target to copy or move
  845. code that contains software breakpoints (e.g., when implementing
  846. overlays). The behavior of this packet, in the presence of such a
  847. target, is not defined.</em>
  848. </p>
  849. <p>Reply:
  850. </p><dl compact="compact">
  851. <dt>&lsquo;<samp>OK</samp>&rsquo;</dt>
  852. <dd><p>success
  853. </p></dd>
  854. <dt>&lsquo;<samp><!-- /@w --></samp>&rsquo;</dt>
  855. <dd><p>not supported
  856. </p></dd>
  857. <dt>&lsquo;<samp>E <var>NN</var></samp>&rsquo;</dt>
  858. <dd><p>for an error
  859. </p></dd>
  860. </dl>
  861. </dd>
  862. <dt>&lsquo;<samp>z1,<var>addr</var>,<var>kind</var></samp>&rsquo;</dt>
  863. <dt>&lsquo;<samp>Z1,<var>addr</var>,<var>kind</var><span class="roman">[</span>;<var>cond_list</var>&hellip;<span class="roman">]</span><span class="roman">[</span>;cmds:<var>persist</var>,<var>cmd_list</var>&hellip;<span class="roman">]</span></samp>&rsquo;</dt>
  864. <dd><a name="index-z1-packet"></a>
  865. <a name="index-Z1-packet"></a>
  866. <p>Insert (&lsquo;<samp>Z1</samp>&rsquo;) or remove (&lsquo;<samp>z1</samp>&rsquo;) a hardware breakpoint at
  867. address <var>addr</var>.
  868. </p>
  869. <p>A hardware breakpoint is implemented using a mechanism that is not
  870. dependent on being able to modify the target&rsquo;s memory. The
  871. <var>kind</var>, <var>cond_list</var>, and <var>cmd_list</var> arguments have the
  872. same meaning as in &lsquo;<samp>Z0</samp>&rsquo; packets.
  873. </p>
  874. <p><em>Implementation note: A hardware breakpoint is not affected by code
  875. movement.</em>
  876. </p>
  877. <p>Reply:
  878. </p><dl compact="compact">
  879. <dt>&lsquo;<samp>OK</samp>&rsquo;</dt>
  880. <dd><p>success
  881. </p></dd>
  882. <dt>&lsquo;<samp><!-- /@w --></samp>&rsquo;</dt>
  883. <dd><p>not supported
  884. </p></dd>
  885. <dt>&lsquo;<samp>E <var>NN</var></samp>&rsquo;</dt>
  886. <dd><p>for an error
  887. </p></dd>
  888. </dl>
  889. </dd>
  890. <dt>&lsquo;<samp>z2,<var>addr</var>,<var>kind</var></samp>&rsquo;</dt>
  891. <dt>&lsquo;<samp>Z2,<var>addr</var>,<var>kind</var></samp>&rsquo;</dt>
  892. <dd><a name="index-z2-packet"></a>
  893. <a name="index-Z2-packet"></a>
  894. <p>Insert (&lsquo;<samp>Z2</samp>&rsquo;) or remove (&lsquo;<samp>z2</samp>&rsquo;) a write watchpoint at <var>addr</var>.
  895. The number of bytes to watch is specified by <var>kind</var>.
  896. </p>
  897. <p>Reply:
  898. </p><dl compact="compact">
  899. <dt>&lsquo;<samp>OK</samp>&rsquo;</dt>
  900. <dd><p>success
  901. </p></dd>
  902. <dt>&lsquo;<samp><!-- /@w --></samp>&rsquo;</dt>
  903. <dd><p>not supported
  904. </p></dd>
  905. <dt>&lsquo;<samp>E <var>NN</var></samp>&rsquo;</dt>
  906. <dd><p>for an error
  907. </p></dd>
  908. </dl>
  909. </dd>
  910. <dt>&lsquo;<samp>z3,<var>addr</var>,<var>kind</var></samp>&rsquo;</dt>
  911. <dt>&lsquo;<samp>Z3,<var>addr</var>,<var>kind</var></samp>&rsquo;</dt>
  912. <dd><a name="index-z3-packet"></a>
  913. <a name="index-Z3-packet"></a>
  914. <p>Insert (&lsquo;<samp>Z3</samp>&rsquo;) or remove (&lsquo;<samp>z3</samp>&rsquo;) a read watchpoint at <var>addr</var>.
  915. The number of bytes to watch is specified by <var>kind</var>.
  916. </p>
  917. <p>Reply:
  918. </p><dl compact="compact">
  919. <dt>&lsquo;<samp>OK</samp>&rsquo;</dt>
  920. <dd><p>success
  921. </p></dd>
  922. <dt>&lsquo;<samp><!-- /@w --></samp>&rsquo;</dt>
  923. <dd><p>not supported
  924. </p></dd>
  925. <dt>&lsquo;<samp>E <var>NN</var></samp>&rsquo;</dt>
  926. <dd><p>for an error
  927. </p></dd>
  928. </dl>
  929. </dd>
  930. <dt>&lsquo;<samp>z4,<var>addr</var>,<var>kind</var></samp>&rsquo;</dt>
  931. <dt>&lsquo;<samp>Z4,<var>addr</var>,<var>kind</var></samp>&rsquo;</dt>
  932. <dd><a name="index-z4-packet"></a>
  933. <a name="index-Z4-packet"></a>
  934. <p>Insert (&lsquo;<samp>Z4</samp>&rsquo;) or remove (&lsquo;<samp>z4</samp>&rsquo;) an access watchpoint at <var>addr</var>.
  935. The number of bytes to watch is specified by <var>kind</var>.
  936. </p>
  937. <p>Reply:
  938. </p><dl compact="compact">
  939. <dt>&lsquo;<samp>OK</samp>&rsquo;</dt>
  940. <dd><p>success
  941. </p></dd>
  942. <dt>&lsquo;<samp><!-- /@w --></samp>&rsquo;</dt>
  943. <dd><p>not supported
  944. </p></dd>
  945. <dt>&lsquo;<samp>E <var>NN</var></samp>&rsquo;</dt>
  946. <dd><p>for an error
  947. </p></dd>
  948. </dl>
  949. </dd>
  950. </dl>
  951. <hr>
  952. <div class="header">
  953. <p>
  954. Next: <a href="Stop-Reply-Packets.html#Stop-Reply-Packets" accesskey="n" rel="next">Stop Reply Packets</a>, Previous: <a href="Overview.html#Overview" accesskey="p" rel="previous">Overview</a>, Up: <a href="Remote-Protocol.html#Remote-Protocol" accesskey="u" rel="up">Remote Protocol</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>
  955. </div>
  956. </body>
  957. </html>