diff options
author | Gary Benson <gbenson@redhat.com> | 2015-03-11 17:53:57 +0000 |
---|---|---|
committer | Gary Benson <gbenson@redhat.com> | 2015-03-11 17:53:57 +0000 |
commit | aa9e327f1e8552cd47cc8f4b9daa782930469e60 (patch) | |
tree | c9ce4249a117987bf6682e8a10028b2f59e89df3 /gdb/gdbserver/hostio.c | |
parent | 0a93529c56714b1da3d7106d3e0300764f8bb81c (diff) | |
download | gdb-aa9e327f1e8552cd47cc8f4b9daa782930469e60.zip gdb-aa9e327f1e8552cd47cc8f4b9daa782930469e60.tar.gz gdb-aa9e327f1e8552cd47cc8f4b9daa782930469e60.tar.bz2 |
Implement vFile:fstat: in gdbserver
This commit implements the "vFile:fstat:" packet in gdbserver.
gdb/gdbserver/ChangeLog:
* hostio.c (sys/types.h): New include.
(sys/stat.h): Likewise.
(common-remote-fileio.h): Likewise.
(handle_fstat): New function.
(handle_vFile): Handle vFile:fstat packets.
* server.c (handle_query): Report vFile:fstat as supported.
Diffstat (limited to 'gdb/gdbserver/hostio.c')
-rw-r--r-- | gdb/gdbserver/hostio.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/gdb/gdbserver/hostio.c b/gdb/gdbserver/hostio.c index ec29eb9..aa659e2 100644 --- a/gdb/gdbserver/hostio.c +++ b/gdb/gdbserver/hostio.c @@ -25,6 +25,9 @@ #include <fcntl.h> #include <limits.h> #include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> +#include "common-remote-fileio.h" extern int remote_debug; @@ -412,6 +415,42 @@ handle_pwrite (char *own_buf, int packet_len) } static void +handle_fstat (char *own_buf, int *new_packet_len) +{ + int fd, bytes_sent; + char *p; + struct stat st; + struct fio_stat fst; + + p = own_buf + strlen ("vFile:fstat:"); + + if (require_int (&p, &fd) + || require_valid_fd (fd) + || require_end (p)) + { + hostio_packet_error (own_buf); + return; + } + + if (fstat (fd, &st) == -1) + { + hostio_error (own_buf); + return; + } + + remote_fileio_to_fio_stat (&st, &fst); + + bytes_sent = hostio_reply_with_data (own_buf, + (char *) &fst, sizeof (fst), + new_packet_len); + + /* If the response does not fit into a single packet, do not attempt + to return a partial response, but simply fail. */ + if (bytes_sent < sizeof (fst)) + write_enn (own_buf); +} + +static void handle_close (char *own_buf) { int fd, ret; @@ -517,6 +556,8 @@ handle_vFile (char *own_buf, int packet_len, int *new_packet_len) handle_pread (own_buf, new_packet_len); else if (startswith (own_buf, "vFile:pwrite:")) handle_pwrite (own_buf, packet_len); + else if (startswith (own_buf, "vFile:fstat:")) + handle_fstat (own_buf, new_packet_len); else if (startswith (own_buf, "vFile:close:")) handle_close (own_buf); else if (startswith (own_buf, "vFile:unlink:")) |