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.

Host-I_002fO-Packets.html 11KB

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