Stop-Reply-Packets.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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: Stop Reply Packets</title>
  16. <meta name="description" content="Debugging with GDB: Stop Reply Packets">
  17. <meta name="keywords" content="Debugging with GDB: Stop Reply 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="General-Query-Packets.html#General-Query-Packets" rel="next" title="General Query Packets">
  27. <link href="Packets.html#Packets" rel="previous" title="Packets">
  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="Stop-Reply-Packets"></a>
  59. <div class="header">
  60. <p>
  61. Next: <a href="General-Query-Packets.html#General-Query-Packets" accesskey="n" rel="next">General Query Packets</a>, Previous: <a href="Packets.html#Packets" accesskey="p" rel="previous">Packets</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="Stop-Reply-Packets-1"></a>
  65. <h3 class="section">E.3 Stop Reply Packets</h3>
  66. <a name="index-stop-reply-packets"></a>
  67. <p>The &lsquo;<samp>C</samp>&rsquo;, &lsquo;<samp>c</samp>&rsquo;, &lsquo;<samp>S</samp>&rsquo;, &lsquo;<samp>s</samp>&rsquo;, &lsquo;<samp>vCont</samp>&rsquo;,
  68. &lsquo;<samp>vAttach</samp>&rsquo;, &lsquo;<samp>vRun</samp>&rsquo;, &lsquo;<samp>vStopped</samp>&rsquo;, and &lsquo;<samp>?</samp>&rsquo; packets can
  69. receive any of the below as a reply. Except for &lsquo;<samp>?</samp>&rsquo;
  70. and &lsquo;<samp>vStopped</samp>&rsquo;, that reply is only returned
  71. when the target halts. In the below the exact meaning of <em>signal
  72. number</em> is defined by the header <samp>include/gdb/signals.h</samp> in the
  73. <small>GDB</small> source code.
  74. </p>
  75. <p>In non-stop mode, the server will simply reply &lsquo;<samp>OK</samp>&rsquo; to commands
  76. such as &lsquo;<samp>vCont</samp>&rsquo;; any stop will be the subject of a future
  77. notification. See <a href="Remote-Non_002dStop.html#Remote-Non_002dStop">Remote Non-Stop</a>.
  78. </p>
  79. <p>As in the description of request packets, we include spaces in the
  80. reply templates for clarity; these are not part of the reply packet&rsquo;s
  81. syntax. No <small>GDB</small> stop reply packet uses spaces to separate its
  82. components.
  83. </p>
  84. <dl compact="compact">
  85. <dt>&lsquo;<samp>S <var>AA</var></samp>&rsquo;</dt>
  86. <dd><p>The program received signal number <var>AA</var> (a two-digit hexadecimal
  87. number). This is equivalent to a &lsquo;<samp>T</samp>&rsquo; response with no
  88. <var>n</var>:<var>r</var> pairs.
  89. </p>
  90. </dd>
  91. <dt>&lsquo;<samp>T <var>AA</var> <var>n1</var>:<var>r1</var>;<var>n2</var>:<var>r2</var>;&hellip;</samp>&rsquo;</dt>
  92. <dd><a name="index-T-packet-reply"></a>
  93. <p>The program received signal number <var>AA</var> (a two-digit hexadecimal
  94. number). This is equivalent to an &lsquo;<samp>S</samp>&rsquo; response, except that the
  95. &lsquo;<samp><var>n</var>:<var>r</var></samp>&rsquo; pairs can carry values of important registers
  96. and other information directly in the stop reply packet, reducing
  97. round-trip latency. Single-step and breakpoint traps are reported
  98. this way. Each &lsquo;<samp><var>n</var>:<var>r</var></samp>&rsquo; pair is interpreted as follows:
  99. </p>
  100. <ul>
  101. <li> If <var>n</var> is a hexadecimal number, it is a register number, and the
  102. corresponding <var>r</var> gives that register&rsquo;s value. The data <var>r</var> is a
  103. series of bytes in target byte order, with each byte given by a
  104. two-digit hex number.
  105. </li><li> If <var>n</var> is &lsquo;<samp>thread</samp>&rsquo;, then <var>r</var> is the <var>thread-id</var> of
  106. the stopped thread, as specified in <a href="Packets.html#thread_002did-syntax">thread-id syntax</a>.
  107. </li><li> If <var>n</var> is &lsquo;<samp>core</samp>&rsquo;, then <var>r</var> is the hexadecimal number of
  108. the core on which the stop event was detected.
  109. </li><li> If <var>n</var> is a recognized <em>stop reason</em>, it describes a more
  110. specific event that stopped the target. The currently defined stop
  111. reasons are listed below. The <var>aa</var> should be &lsquo;<samp>05</samp>&rsquo;, the trap
  112. signal. At most one stop reason should be present.
  113. </li><li> Otherwise, <small>GDB</small> should ignore this &lsquo;<samp><var>n</var>:<var>r</var></samp>&rsquo; pair
  114. and go on to the next; this allows us to extend the protocol in the
  115. future.
  116. </li></ul>
  117. <p>The currently defined stop reasons are:
  118. </p>
  119. <dl compact="compact">
  120. <dt>&lsquo;<samp>watch</samp>&rsquo;</dt>
  121. <dt>&lsquo;<samp>rwatch</samp>&rsquo;</dt>
  122. <dt>&lsquo;<samp>awatch</samp>&rsquo;</dt>
  123. <dd><p>The packet indicates a watchpoint hit, and <var>r</var> is the data address, in
  124. hex.
  125. </p>
  126. </dd>
  127. <dt>&lsquo;<samp>syscall_entry</samp>&rsquo;</dt>
  128. <dt>&lsquo;<samp>syscall_return</samp>&rsquo;</dt>
  129. <dd><p>The packet indicates a syscall entry or return, and <var>r</var> is the
  130. syscall number, in hex.
  131. </p>
  132. <a name="index-shared-library-events_002c-remote-reply"></a>
  133. </dd>
  134. <dt>&lsquo;<samp>library</samp>&rsquo;</dt>
  135. <dd><p>The packet indicates that the loaded libraries have changed.
  136. <small>GDB</small> should use &lsquo;<samp>qXfer:libraries:read</samp>&rsquo; to fetch a new
  137. list of loaded libraries. The <var>r</var> part is ignored.
  138. </p>
  139. <a name="index-replay-log-events_002c-remote-reply"></a>
  140. </dd>
  141. <dt>&lsquo;<samp>replaylog</samp>&rsquo;</dt>
  142. <dd><p>The packet indicates that the target cannot continue replaying
  143. logged execution events, because it has reached the end (or the
  144. beginning when executing backward) of the log. The value of <var>r</var>
  145. will be either &lsquo;<samp>begin</samp>&rsquo; or &lsquo;<samp>end</samp>&rsquo;. See <a href="Reverse-Execution.html#Reverse-Execution">Reverse Execution</a>,
  146. for more information.
  147. </p>
  148. </dd>
  149. <dt>&lsquo;<samp>swbreak</samp>&rsquo;</dt>
  150. <dd><a name="swbreak-stop-reason"></a><p>The packet indicates a software breakpoint instruction was executed,
  151. irrespective of whether it was <small>GDB</small> that planted the
  152. breakpoint or the breakpoint is hardcoded in the program. The <var>r</var>
  153. part must be left empty.
  154. </p>
  155. <p>On some architectures, such as x86, at the architecture level, when a
  156. breakpoint instruction executes the program counter points at the
  157. breakpoint address plus an offset. On such targets, the stub is
  158. responsible for adjusting the PC to point back at the breakpoint
  159. address.
  160. </p>
  161. <p>This packet should not be sent by default; older <small>GDB</small> versions
  162. did not support it. <small>GDB</small> requests it, by supplying an
  163. appropriate &lsquo;<samp>qSupported</samp>&rsquo; feature (see <a href="General-Query-Packets.html#qSupported">qSupported</a>). The
  164. remote stub must also supply the appropriate &lsquo;<samp>qSupported</samp>&rsquo; feature
  165. indicating support.
  166. </p>
  167. <p>This packet is required for correct non-stop mode operation.
  168. </p>
  169. </dd>
  170. <dt>&lsquo;<samp>hwbreak</samp>&rsquo;</dt>
  171. <dd><p>The packet indicates the target stopped for a hardware breakpoint.
  172. The <var>r</var> part must be left empty.
  173. </p>
  174. <p>The same remarks about &lsquo;<samp>qSupported</samp>&rsquo; and non-stop mode above
  175. apply.
  176. </p>
  177. <a name="index-fork-events_002c-remote-reply"></a>
  178. </dd>
  179. <dt>&lsquo;<samp>fork</samp>&rsquo;</dt>
  180. <dd><p>The packet indicates that <code>fork</code> was called, and <var>r</var>
  181. is the thread ID of the new child process. Refer to
  182. <a href="Packets.html#thread_002did-syntax">thread-id syntax</a> for the format of the <var>thread-id</var>
  183. field. This packet is only applicable to targets that support
  184. fork events.
  185. </p>
  186. <p>This packet should not be sent by default; older <small>GDB</small> versions
  187. did not support it. <small>GDB</small> requests it, by supplying an
  188. appropriate &lsquo;<samp>qSupported</samp>&rsquo; feature (see <a href="General-Query-Packets.html#qSupported">qSupported</a>). The
  189. remote stub must also supply the appropriate &lsquo;<samp>qSupported</samp>&rsquo; feature
  190. indicating support.
  191. </p>
  192. <a name="index-vfork-events_002c-remote-reply"></a>
  193. </dd>
  194. <dt>&lsquo;<samp>vfork</samp>&rsquo;</dt>
  195. <dd><p>The packet indicates that <code>vfork</code> was called, and <var>r</var>
  196. is the thread ID of the new child process. Refer to
  197. <a href="Packets.html#thread_002did-syntax">thread-id syntax</a> for the format of the <var>thread-id</var>
  198. field. This packet is only applicable to targets that support
  199. vfork events.
  200. </p>
  201. <p>This packet should not be sent by default; older <small>GDB</small> versions
  202. did not support it. <small>GDB</small> requests it, by supplying an
  203. appropriate &lsquo;<samp>qSupported</samp>&rsquo; feature (see <a href="General-Query-Packets.html#qSupported">qSupported</a>). The
  204. remote stub must also supply the appropriate &lsquo;<samp>qSupported</samp>&rsquo; feature
  205. indicating support.
  206. </p>
  207. <a name="index-vforkdone-events_002c-remote-reply"></a>
  208. </dd>
  209. <dt>&lsquo;<samp>vforkdone</samp>&rsquo;</dt>
  210. <dd><p>The packet indicates that a child process created by a vfork
  211. has either called <code>exec</code> or terminated, so that the
  212. address spaces of the parent and child process are no longer
  213. shared. The <var>r</var> part is ignored. This packet is only
  214. applicable to targets that support vforkdone events.
  215. </p>
  216. <p>This packet should not be sent by default; older <small>GDB</small> versions
  217. did not support it. <small>GDB</small> requests it, by supplying an
  218. appropriate &lsquo;<samp>qSupported</samp>&rsquo; feature (see <a href="General-Query-Packets.html#qSupported">qSupported</a>). The
  219. remote stub must also supply the appropriate &lsquo;<samp>qSupported</samp>&rsquo; feature
  220. indicating support.
  221. </p>
  222. <a name="index-exec-events_002c-remote-reply"></a>
  223. </dd>
  224. <dt>&lsquo;<samp>exec</samp>&rsquo;</dt>
  225. <dd><p>The packet indicates that <code>execve</code> was called, and <var>r</var>
  226. is the absolute pathname of the file that was executed, in hex.
  227. This packet is only applicable to targets that support exec events.
  228. </p>
  229. <p>This packet should not be sent by default; older <small>GDB</small> versions
  230. did not support it. <small>GDB</small> requests it, by supplying an
  231. appropriate &lsquo;<samp>qSupported</samp>&rsquo; feature (see <a href="General-Query-Packets.html#qSupported">qSupported</a>). The
  232. remote stub must also supply the appropriate &lsquo;<samp>qSupported</samp>&rsquo; feature
  233. indicating support.
  234. </p>
  235. <a name="index-thread-create-event_002c-remote-reply"></a>
  236. <a name="thread-create-event"></a></dd>
  237. <dt>&lsquo;<samp>create</samp>&rsquo;</dt>
  238. <dd><p>The packet indicates that the thread was just created. The new thread
  239. is stopped until <small>GDB</small> sets it running with a resumption packet
  240. (see <a href="Packets.html#vCont-packet">vCont packet</a>). This packet should not be sent by default;
  241. <small>GDB</small> requests it with the <a href="General-Query-Packets.html#QThreadEvents">QThreadEvents</a> packet. See
  242. also the &lsquo;<samp>w</samp>&rsquo; (see <a href="#thread-exit-event">thread exit event</a>) remote reply below. The
  243. <var>r</var> part is ignored.
  244. </p>
  245. </dd>
  246. </dl>
  247. </dd>
  248. <dt>&lsquo;<samp>W <var>AA</var></samp>&rsquo;</dt>
  249. <dt>&lsquo;<samp>W <var>AA</var> ; process:<var>pid</var></samp>&rsquo;</dt>
  250. <dd><p>The process exited, and <var>AA</var> is the exit status. This is only
  251. applicable to certain targets.
  252. </p>
  253. <p>The second form of the response, including the process ID of the
  254. exited process, can be used only when <small>GDB</small> has reported
  255. support for multiprocess protocol extensions; see <a href="General-Query-Packets.html#multiprocess-extensions">multiprocess extensions</a>. Both <var>AA</var> and <var>pid</var> are formatted as big-endian
  256. hex strings.
  257. </p>
  258. </dd>
  259. <dt>&lsquo;<samp>X <var>AA</var></samp>&rsquo;</dt>
  260. <dt>&lsquo;<samp>X <var>AA</var> ; process:<var>pid</var></samp>&rsquo;</dt>
  261. <dd><p>The process terminated with signal <var>AA</var>.
  262. </p>
  263. <p>The second form of the response, including the process ID of the
  264. terminated process, can be used only when <small>GDB</small> has reported
  265. support for multiprocess protocol extensions; see <a href="General-Query-Packets.html#multiprocess-extensions">multiprocess extensions</a>. Both <var>AA</var> and <var>pid</var> are formatted as big-endian
  266. hex strings.
  267. </p>
  268. <a name="thread-exit-event"></a><a name="index-thread-exit-event_002c-remote-reply"></a>
  269. </dd>
  270. <dt>&lsquo;<samp>w <var>AA</var> ; <var>tid</var></samp>&rsquo;</dt>
  271. <dd>
  272. <p>The thread exited, and <var>AA</var> is the exit status. This response
  273. should not be sent by default; <small>GDB</small> requests it with the
  274. <a href="General-Query-Packets.html#QThreadEvents">QThreadEvents</a> packet. See also <a href="#thread-create-event">thread create event</a> above.
  275. <var>AA</var> is formatted as a big-endian hex string.
  276. </p>
  277. </dd>
  278. <dt>&lsquo;<samp>N</samp>&rsquo;</dt>
  279. <dd><p>There are no resumed threads left in the target. In other words, even
  280. though the process is alive, the last resumed thread has exited. For
  281. example, say the target process has two threads: thread 1 and thread
  282. 2. The client leaves thread 1 stopped, and resumes thread 2, which
  283. subsequently exits. At this point, even though the process is still
  284. alive, and thus no &lsquo;<samp>W</samp>&rsquo; stop reply is sent, no thread is actually
  285. executing either. The &lsquo;<samp>N</samp>&rsquo; stop reply thus informs the client
  286. that it can stop waiting for stop replies. This packet should not be
  287. sent by default; older <small>GDB</small> versions did not support it.
  288. <small>GDB</small> requests it, by supplying an appropriate
  289. &lsquo;<samp>qSupported</samp>&rsquo; feature (see <a href="General-Query-Packets.html#qSupported">qSupported</a>). The remote stub must
  290. also supply the appropriate &lsquo;<samp>qSupported</samp>&rsquo; feature indicating
  291. support.
  292. </p>
  293. </dd>
  294. <dt>&lsquo;<samp>O <var>XX</var>&hellip;</samp>&rsquo;</dt>
  295. <dd><p>&lsquo;<samp><var>XX</var>&hellip;</samp>&rsquo; is hex encoding of <small>ASCII</small> data, to be
  296. written as the program&rsquo;s console output. This can happen at any time
  297. while the program is running and the debugger should continue to wait
  298. for &lsquo;<samp>W</samp>&rsquo;, &lsquo;<samp>T</samp>&rsquo;, etc. This reply is not permitted in non-stop mode.
  299. </p>
  300. </dd>
  301. <dt>&lsquo;<samp>F <var>call-id</var>,<var>parameter</var>&hellip;</samp>&rsquo;</dt>
  302. <dd><p><var>call-id</var> is the identifier which says which host system call should
  303. be called. This is just the name of the function. Translation into the
  304. correct system call is only applicable as it&rsquo;s defined in <small>GDB</small>.
  305. See <a href="File_002dI_002fO-Remote-Protocol-Extension.html#File_002dI_002fO-Remote-Protocol-Extension">File-I/O Remote Protocol Extension</a>, for a list of implemented
  306. system calls.
  307. </p>
  308. <p>&lsquo;<samp><var>parameter</var>&hellip;</samp>&rsquo; is a list of parameters as defined for
  309. this very system call.
  310. </p>
  311. <p>The target replies with this packet when it expects <small>GDB</small> to
  312. call a host system call on behalf of the target. <small>GDB</small> replies
  313. with an appropriate &lsquo;<samp>F</samp>&rsquo; packet and keeps up waiting for the next
  314. reply packet from the target. The latest &lsquo;<samp>C</samp>&rsquo;, &lsquo;<samp>c</samp>&rsquo;, &lsquo;<samp>S</samp>&rsquo;
  315. or &lsquo;<samp>s</samp>&rsquo; action is expected to be continued. See <a href="File_002dI_002fO-Remote-Protocol-Extension.html#File_002dI_002fO-Remote-Protocol-Extension">File-I/O Remote Protocol Extension</a>, for more details.
  316. </p>
  317. </dd>
  318. </dl>
  319. <hr>
  320. <div class="header">
  321. <p>
  322. Next: <a href="General-Query-Packets.html#General-Query-Packets" accesskey="n" rel="next">General Query Packets</a>, Previous: <a href="Packets.html#Packets" accesskey="p" rel="previous">Packets</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>
  323. </div>
  324. </body>
  325. </html>