hc
2024-03-22 a0752693d998599af469473b8dc239ef973a012f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Copyright (C) 1988-2021 Free Software Foundation, Inc.
 
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Free Software" and "Free Software Needs
Free Documentation", with the Front-Cover Texts being "A GNU Manual,"
and with the Back-Cover Texts as in (a) below.
 
(a) The FSF's Back-Cover Text is: "You are free to copy and modify
this GNU Manual.  Buying copies from GNU Press supports the FSF in
developing GNU and promoting software freedom." -->
<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
<head>
<title>Debugging with GDB: Host I/O Packets</title>
 
<meta name="description" content="Debugging with GDB: Host I/O Packets">
<meta name="keywords" content="Debugging with GDB: Host I/O Packets">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Remote-Protocol.html#Remote-Protocol" rel="up" title="Remote Protocol">
<link href="Interrupts.html#Interrupts" rel="next" title="Interrupts">
<link href="Tracepoint-Packets.html#Tracepoint-Packets" rel="previous" title="Tracepoint Packets">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
 
 
</head>
 
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Host-I_002fO-Packets"></a>
<div class="header">
<p>
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>
</div>
<hr>
<a name="Host-I_002fO-Packets-1"></a>
<h3 class="section">E.7 Host I/O Packets</h3>
<a name="index-Host-I_002fO_002c-remote-protocol"></a>
<a name="index-file-transfer_002c-remote-protocol"></a>
 
<p>The <em>Host I/O</em> packets allow <small>GDB</small> to perform I/O
operations on the far side of a remote link.  For example, Host I/O is
used to upload and download files to a remote target with its own
filesystem.  Host I/O uses the same constant values and data structure
layout as the target-initiated File-I/O protocol.  However, the
Host I/O packets are structured differently.  The target-initiated
protocol relies on target memory to store parameters and buffers.
Host I/O requests are initiated by <small>GDB</small>, and the
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.
</p>
<p>The Host I/O request packets all encode a single operation along with
its arguments.  They have this format:
</p>
<dl compact="compact">
<dt>&lsquo;<samp>vFile:<var>operation</var>: <var>parameter</var>&hellip;</samp>&rsquo;</dt>
<dd><p><var>operation</var> is the name of the particular request; the target
should compare the entire packet name up to the second colon when checking
for a supported operation.  The format of <var>parameter</var> depends on
the operation.  Numbers are always passed in hexadecimal.  Negative
numbers have an explicit minus sign (i.e. two&rsquo;s complement is not
used).  Strings (e.g. filenames) are encoded as a series of
hexadecimal bytes.  The last argument to a system call may be a
buffer of escaped binary data (see <a href="Overview.html#Binary-Data">Binary Data</a>).
</p>
</dd>
</dl>
 
<p>The valid responses to Host I/O packets are:
</p>
<dl compact="compact">
<dt>&lsquo;<samp>F <var>result</var> [, <var>errno</var>] [; <var>attachment</var>]</samp>&rsquo;</dt>
<dd><p><var>result</var> is the integer value returned by this operation, usually
non-negative for success and -1 for errors.  If an error has occured,
<var>errno</var> will be included in the result specifying a
value defined by the File-I/O protocol (see <a href="errno-Values.html#errno-Values">errno Values</a>).  For
operations which return data, <var>attachment</var> supplies the data as a
binary buffer.  Binary buffers in response packets are escaped in the
normal way (see <a href="Overview.html#Binary-Data">Binary Data</a>).  See the individual packet
documentation for the interpretation of <var>result</var> and
<var>attachment</var>.
</p>
</dd>
<dt>&lsquo;<samp><!-- /@w --></samp>&rsquo;</dt>
<dd><p>An empty response indicates that this operation is not recognized.
</p>
</dd>
</dl>
 
<p>These are the supported Host I/O operations:
</p>
<dl compact="compact">
<dt>&lsquo;<samp>vFile:open: <var>filename</var>, <var>flags</var>, <var>mode</var></samp>&rsquo;</dt>
<dd><p>Open a file at <var>filename</var> and return a file descriptor for it, or
return -1 if an error occurs.  The <var>filename</var> is a string,
<var>flags</var> is an integer indicating a mask of open flags
(see <a href="Open-Flags.html#Open-Flags">Open Flags</a>), and <var>mode</var> is an integer indicating a mask
of mode bits to use if the file is created (see <a href="mode_005ft-Values.html#mode_005ft-Values">mode_t Values</a>).
See <a href="open.html#open">open</a>, for details of the open flags and mode values.
</p>
</dd>
<dt>&lsquo;<samp>vFile:close: <var>fd</var></samp>&rsquo;</dt>
<dd><p>Close the open file corresponding to <var>fd</var> and return 0, or
-1 if an error occurs.
</p>
</dd>
<dt>&lsquo;<samp>vFile:pread: <var>fd</var>, <var>count</var>, <var>offset</var></samp>&rsquo;</dt>
<dd><p>Read data from the open file corresponding to <var>fd</var>.  Up to
<var>count</var> bytes will be read from the file, starting at <var>offset</var>
relative to the start of the file.  The target may read fewer bytes;
common reasons include packet size limits and an end-of-file
condition.  The number of bytes read is returned.  Zero should only be
returned for a successful read at the end of the file, or if
<var>count</var> was zero.
</p>
<p>The data read should be returned as a binary attachment on success.
If zero bytes were read, the response should include an empty binary
attachment (i.e. a trailing semicolon).  The return value is the
number of target bytes read; the binary attachment may be longer if
some characters were escaped.
</p>
</dd>
<dt>&lsquo;<samp>vFile:pwrite: <var>fd</var>, <var>offset</var>, <var>data</var></samp>&rsquo;</dt>
<dd><p>Write <var>data</var> (a binary buffer) to the open file corresponding
to <var>fd</var>.  Start the write at <var>offset</var> from the start of the
file.  Unlike many <code>write</code> system calls, there is no
separate <var>count</var> argument; the length of <var>data</var> in the
packet is used.  &lsquo;<samp>vFile:pwrite</samp>&rsquo; returns the number of bytes written,
which may be shorter than the length of <var>data</var>, or -1 if an
error occurred.
</p>
</dd>
<dt>&lsquo;<samp>vFile:fstat: <var>fd</var></samp>&rsquo;</dt>
<dd><p>Get information about the open file corresponding to <var>fd</var>.
On success the information is returned as a binary attachment
and the return value is the size of this attachment in bytes.
If an error occurs the return value is -1.  The format of the
returned binary attachment is as described in <a href="struct-stat.html#struct-stat">struct stat</a>.
</p>
</dd>
<dt>&lsquo;<samp>vFile:unlink: <var>filename</var></samp>&rsquo;</dt>
<dd><p>Delete the file at <var>filename</var> on the target.  Return 0,
or -1 if an error occurs.  The <var>filename</var> is a string.
</p>
</dd>
<dt>&lsquo;<samp>vFile:readlink: <var>filename</var></samp>&rsquo;</dt>
<dd><p>Read value of symbolic link <var>filename</var> on the target.  Return
the number of bytes read, or -1 if an error occurs.
</p>
<p>The data read should be returned as a binary attachment on success.
If zero bytes were read, the response should include an empty binary
attachment (i.e. a trailing semicolon).  The return value is the
number of target bytes read; the binary attachment may be longer if
some characters were escaped.
</p>
</dd>
<dt>&lsquo;<samp>vFile:setfs: <var>pid</var></samp>&rsquo;</dt>
<dd><p>Select the filesystem on which <code>vFile</code> operations with
<var>filename</var> arguments will operate.  This is required for
<small>GDB</small> to be able to access files on remote targets where
the remote stub does not share a common filesystem with the
inferior(s).
</p>
<p>If <var>pid</var> is nonzero, select the filesystem as seen by process
<var>pid</var>.  If <var>pid</var> is zero, select the filesystem as seen by
the remote stub.  Return 0 on success, or -1 if an error occurs.
If <code>vFile:setfs:</code> indicates success, the selected filesystem
remains selected until the next successful <code>vFile:setfs:</code>
operation.
</p>
</dd>
</dl>
 
<hr>
<div class="header">
<p>
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>
</div>
 
 
 
</body>
</html>