Host-I_002fO-Packets.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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: Host I/O Packets</title>
  16. <meta name="description" content="Debugging with GDB: Host I/O Packets">
  17. <meta name="keywords" content="Debugging with GDB: Host I/O 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="Interrupts.html#Interrupts" rel="next" title="Interrupts">
  27. <link href="Tracepoint-Packets.html#Tracepoint-Packets" rel="previous" title="Tracepoint 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="Host-I_002fO-Packets"></a>
  59. <div class="header">
  60. <p>
  61. Next: <a href="Interrupts.html#Interrupts" accesskey="n" rel="next">Interrupts</a>, Previous: <a href="Tracepoint-Packets.html#Tracepoint-Packets" accesskey="p" rel="previous">Tracepoint 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="Host-I_002fO-Packets-1"></a>
  65. <h3 class="section">E.7 Host I/O Packets</h3>
  66. <a name="index-Host-I_002fO_002c-remote-protocol"></a>
  67. <a name="index-file-transfer_002c-remote-protocol"></a>
  68. <p>The <em>Host I/O</em> packets allow <small>GDB</small> to perform I/O
  69. operations on the far side of a remote link. For example, Host I/O is
  70. used to upload and download files to a remote target with its own
  71. filesystem. Host I/O uses the same constant values and data structure
  72. layout as the target-initiated File-I/O protocol. However, the
  73. Host I/O packets are structured differently. The target-initiated
  74. protocol relies on target memory to store parameters and buffers.
  75. Host I/O requests are initiated by <small>GDB</small>, and the
  76. target&rsquo;s memory is not involved. 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 on the target-initiated protocol.
  77. </p>
  78. <p>The Host I/O request packets all encode a single operation along with
  79. its arguments. They have this format:
  80. </p>
  81. <dl compact="compact">
  82. <dt>&lsquo;<samp>vFile:<var>operation</var>: <var>parameter</var>&hellip;</samp>&rsquo;</dt>
  83. <dd><p><var>operation</var> is the name of the particular request; the target
  84. should compare the entire packet name up to the second colon when checking
  85. for a supported operation. The format of <var>parameter</var> depends on
  86. the operation. Numbers are always passed in hexadecimal. Negative
  87. numbers have an explicit minus sign (i.e. two&rsquo;s complement is not
  88. used). Strings (e.g. filenames) are encoded as a series of
  89. hexadecimal bytes. The last argument to a system call may be a
  90. buffer of escaped binary data (see <a href="Overview.html#Binary-Data">Binary Data</a>).
  91. </p>
  92. </dd>
  93. </dl>
  94. <p>The valid responses to Host I/O packets are:
  95. </p>
  96. <dl compact="compact">
  97. <dt>&lsquo;<samp>F <var>result</var> [, <var>errno</var>] [; <var>attachment</var>]</samp>&rsquo;</dt>
  98. <dd><p><var>result</var> is the integer value returned by this operation, usually
  99. non-negative for success and -1 for errors. If an error has occured,
  100. <var>errno</var> will be included in the result specifying a
  101. value defined by the File-I/O protocol (see <a href="Errno-Values.html#Errno-Values">Errno Values</a>). For
  102. operations which return data, <var>attachment</var> supplies the data as a
  103. binary buffer. Binary buffers in response packets are escaped in the
  104. normal way (see <a href="Overview.html#Binary-Data">Binary Data</a>). See the individual packet
  105. documentation for the interpretation of <var>result</var> and
  106. <var>attachment</var>.
  107. </p>
  108. </dd>
  109. <dt>&lsquo;<samp><!-- /@w --></samp>&rsquo;</dt>
  110. <dd><p>An empty response indicates that this operation is not recognized.
  111. </p>
  112. </dd>
  113. </dl>
  114. <p>These are the supported Host I/O operations:
  115. </p>
  116. <dl compact="compact">
  117. <dt>&lsquo;<samp>vFile:open: <var>filename</var>, <var>flags</var>, <var>mode</var></samp>&rsquo;</dt>
  118. <dd><p>Open a file at <var>filename</var> and return a file descriptor for it, or
  119. return -1 if an error occurs. The <var>filename</var> is a string,
  120. <var>flags</var> is an integer indicating a mask of open flags
  121. (see <a href="Open-Flags.html#Open-Flags">Open Flags</a>), and <var>mode</var> is an integer indicating a mask
  122. of mode bits to use if the file is created (see <a href="mode_005ft-Values.html#mode_005ft-Values">mode_t Values</a>).
  123. See <a href="open.html#open">open</a>, for details of the open flags and mode values.
  124. </p>
  125. </dd>
  126. <dt>&lsquo;<samp>vFile:close: <var>fd</var></samp>&rsquo;</dt>
  127. <dd><p>Close the open file corresponding to <var>fd</var> and return 0, or
  128. -1 if an error occurs.
  129. </p>
  130. </dd>
  131. <dt>&lsquo;<samp>vFile:pread: <var>fd</var>, <var>count</var>, <var>offset</var></samp>&rsquo;</dt>
  132. <dd><p>Read data from the open file corresponding to <var>fd</var>. Up to
  133. <var>count</var> bytes will be read from the file, starting at <var>offset</var>
  134. relative to the start of the file. The target may read fewer bytes;
  135. common reasons include packet size limits and an end-of-file
  136. condition. The number of bytes read is returned. Zero should only be
  137. returned for a successful read at the end of the file, or if
  138. <var>count</var> was zero.
  139. </p>
  140. <p>The data read should be returned as a binary attachment on success.
  141. If zero bytes were read, the response should include an empty binary
  142. attachment (i.e. a trailing semicolon). The return value is the
  143. number of target bytes read; the binary attachment may be longer if
  144. some characters were escaped.
  145. </p>
  146. </dd>
  147. <dt>&lsquo;<samp>vFile:pwrite: <var>fd</var>, <var>offset</var>, <var>data</var></samp>&rsquo;</dt>
  148. <dd><p>Write <var>data</var> (a binary buffer) to the open file corresponding
  149. to <var>fd</var>. Start the write at <var>offset</var> from the start of the
  150. file. Unlike many <code>write</code> system calls, there is no
  151. separate <var>count</var> argument; the length of <var>data</var> in the
  152. packet is used. &lsquo;<samp>vFile:pwrite</samp>&rsquo; returns the number of bytes written,
  153. which may be shorter than the length of <var>data</var>, or -1 if an
  154. error occurred.
  155. </p>
  156. </dd>
  157. <dt>&lsquo;<samp>vFile:fstat: <var>fd</var></samp>&rsquo;</dt>
  158. <dd><p>Get information about the open file corresponding to <var>fd</var>.
  159. On success the information is returned as a binary attachment
  160. and the return value is the size of this attachment in bytes.
  161. If an error occurs the return value is -1. The format of the
  162. returned binary attachment is as described in <a href="struct-stat.html#struct-stat">struct stat</a>.
  163. </p>
  164. </dd>
  165. <dt>&lsquo;<samp>vFile:unlink: <var>filename</var></samp>&rsquo;</dt>
  166. <dd><p>Delete the file at <var>filename</var> on the target. Return 0,
  167. or -1 if an error occurs. The <var>filename</var> is a string.
  168. </p>
  169. </dd>
  170. <dt>&lsquo;<samp>vFile:readlink: <var>filename</var></samp>&rsquo;</dt>
  171. <dd><p>Read value of symbolic link <var>filename</var> on the target. Return
  172. the number of bytes read, or -1 if an error occurs.
  173. </p>
  174. <p>The data read should be returned as a binary attachment on success.
  175. If zero bytes were read, the response should include an empty binary
  176. attachment (i.e. a trailing semicolon). The return value is the
  177. number of target bytes read; the binary attachment may be longer if
  178. some characters were escaped.
  179. </p>
  180. </dd>
  181. <dt>&lsquo;<samp>vFile:setfs: <var>pid</var></samp>&rsquo;</dt>
  182. <dd><p>Select the filesystem on which <code>vFile</code> operations with
  183. <var>filename</var> arguments will operate. This is required for
  184. <small>GDB</small> to be able to access files on remote targets where
  185. the remote stub does not share a common filesystem with the
  186. inferior(s).
  187. </p>
  188. <p>If <var>pid</var> is nonzero, select the filesystem as seen by process
  189. <var>pid</var>. If <var>pid</var> is zero, select the filesystem as seen by
  190. the remote stub. Return 0 on success, or -1 if an error occurs.
  191. If <code>vFile:setfs:</code> indicates success, the selected filesystem
  192. remains selected until the next successful <code>vFile:setfs:</code>
  193. operation.
  194. </p>
  195. </dd>
  196. </dl>
  197. <hr>
  198. <div class="header">
  199. <p>
  200. Next: <a href="Interrupts.html#Interrupts" accesskey="n" rel="next">Interrupts</a>, Previous: <a href="Tracepoint-Packets.html#Tracepoint-Packets" accesskey="p" rel="previous">Tracepoint 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>
  201. </div>
  202. </body>
  203. </html>