From: Gary Benson <gbenson@redhat.com>
To: gdb-patches@sourceware.org
Cc: Pedro Alves <palves@redhat.com>, Eli Zaretskii <eliz@gnu.org>
Subject: [PATCH 3/3 v3] Implement vFile:fstat: packet in gdbserver
Date: Wed, 11 Mar 2015 13:40:00 -0000 [thread overview]
Message-ID: <1426081190-9381-4-git-send-email-gbenson@redhat.com> (raw)
In-Reply-To: <20150311131601.GA5952@blade.nx>
This patch adds a new packet "vFile:fstat:" to gdbserver.
This can be used by clients to retrieve information about
open files.
This was patch 2/3 in the original series, but it's been
moved to the end. Also, all documentation has been moved
into what is now patch 2/3, the patch that adds the GDB side.
handle_fstat has been updated to fail with E01 if the response
doesn't fit in a single packet.
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.
---
gdb/gdbserver/ChangeLog | 9 +++++++++
gdb/gdbserver/hostio.c | 41 +++++++++++++++++++++++++++++++++++++++++
gdb/gdbserver/server.c | 2 ++
3 files changed, 52 insertions(+), 0 deletions(-)
diff --git a/gdb/gdbserver/hostio.c b/gdb/gdbserver/hostio.c
index ec29eb9..df43e27 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))
+ strcpy (own_buf, "E01");
+}
+
+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:"))
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 4189877..4d8faa3 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -2082,6 +2082,8 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
if (target_supports_stopped_by_hw_breakpoint ())
strcat (own_buf, ";hwbreak+");
+ strcat (own_buf, ";vFile:fstat+");
+
return;
}
--
1.7.1
next prev parent reply other threads:[~2015-03-11 13:39 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-09 11:58 [PATCH 0/3] Properly implement remote_bfd_iovec_stat Gary Benson
2015-03-09 11:58 ` [PATCH 1/3] Move remote_fileio_to_fio_stat to gdb/common Gary Benson
2015-03-10 18:30 ` Pedro Alves
2015-03-09 11:58 ` [PATCH 2/3] Add vFile:fstat: packet to gdbserver Gary Benson
2015-03-10 18:31 ` Pedro Alves
2015-03-11 10:33 ` [PATCH 2/3 v2] Implement vFile:fstat: packet in gdbserver Gary Benson
2015-03-11 11:35 ` Pedro Alves
2015-03-11 16:00 ` Eli Zaretskii
2015-03-09 11:58 ` [PATCH 3/3] Implement remote_bfd_iovec_stat using vFile:fstat Gary Benson
2015-03-09 16:17 ` Eli Zaretskii
2015-03-10 9:32 ` Gary Benson
2015-03-10 16:40 ` Eli Zaretskii
2015-03-10 11:20 ` [PATCH 3/3 v2] " Gary Benson
2015-03-10 15:51 ` [PATCH 3/3 v3] " Gary Benson
2015-03-10 18:31 ` Pedro Alves
2015-03-10 18:36 ` Pedro Alves
2015-03-11 10:23 ` Gary Benson
2015-03-11 11:22 ` Pedro Alves
2015-03-11 12:58 ` [PATCH 3/3 v4] Implement remote_bfd_iovec_stat Gary Benson
2015-03-11 13:15 ` Pedro Alves
2015-03-11 13:16 ` Gary Benson
2015-03-11 13:39 ` [PATCH 0/3 v2] Gary Benson
2015-03-11 18:04 ` [PATCH 0/3 v2] Properly implement remote_bfd_iovec_stat Gary Benson
2015-03-11 13:40 ` [PATCH 2/3 v5] Implement remote_bfd_iovec_stat Gary Benson
2015-03-11 13:52 ` Pedro Alves
2015-03-11 13:40 ` Gary Benson [this message]
2015-03-11 13:53 ` [PATCH 3/3 v3] Implement vFile:fstat: packet in gdbserver Pedro Alves
2015-03-11 13:40 ` [PATCH 1/3] Move remote_fileio_to_fio_stat to gdb/common Gary Benson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1426081190-9381-4-git-send-email-gbenson@redhat.com \
--to=gbenson@redhat.com \
--cc=eliz@gnu.org \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).