public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>
Subject: [PATCHv2 3/4] gdbserver: add gdbserver support for vFile::stat packet
Date: Thu, 13 Jun 2024 11:29:39 +0100	[thread overview]
Message-ID: <31d5c393eb5880b8c5d4684ab66196962b9b1a33.1718274353.git.aburgess@redhat.com> (raw)
In-Reply-To: <cover.1718274353.git.aburgess@redhat.com>

After the previous two commits, this commit adds support for the
vFile::stat packet to gdbserver.  This is pretty similar to the
handling for vFile::fstat, but instead calls 'lstat'.

There's still no users of target_fileio_stat in GDB, that will come in
a later commit.
---
 gdbserver/hostio.cc | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/gdbserver/hostio.cc b/gdbserver/hostio.cc
index c5ae35ab7dd..cc47d6869d3 100644
--- a/gdbserver/hostio.cc
+++ b/gdbserver/hostio.cc
@@ -486,6 +486,42 @@ handle_fstat (char *own_buf, int *new_packet_len)
     write_enn (own_buf);
 }
 
+static void
+handle_stat (char *own_buf, int *new_packet_len)
+{
+  int bytes_sent;
+  char *p;
+  struct stat st;
+  struct fio_stat fst;
+  char filename[HOSTIO_PATH_MAX];
+
+  p = own_buf + strlen ("vFile:stat:");
+
+  if (require_filename (&p, filename)
+      || require_end (p))
+    {
+      hostio_packet_error (own_buf);
+      return;
+    }
+
+  if (lstat (filename, &st) == -1)
+    {
+      hostio_error (own_buf);
+      return;
+    }
+
+  host_to_fileio_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)
 {
@@ -603,6 +639,8 @@ handle_vFile (char *own_buf, int packet_len, int *new_packet_len)
     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:stat:"))
+    handle_stat (own_buf, new_packet_len);
   else if (startswith (own_buf, "vFile:close:"))
     handle_close (own_buf);
   else if (startswith (own_buf, "vFile:unlink:"))
-- 
2.25.4


  parent reply	other threads:[~2024-06-13 10:29 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-05 13:15 [PATCH 0/8] Extension for looking up debug info by build-id Andrew Burgess
2024-06-05 13:15 ` [PATCH 1/8] gdb/fileio: fix errno for packets where an attachment is expected Andrew Burgess
2024-06-06 16:49   ` Tom Tromey
2024-06-11 19:52     ` Andrew Burgess
2024-06-05 13:15 ` [PATCH 2/8] gdb: avoid duplicate search in build_id_to_bfd_suffix Andrew Burgess
2024-06-06 16:49   ` Tom Tromey
2024-06-11 19:52     ` Andrew Burgess
2024-06-05 13:15 ` [PATCH 3/8] gdb: warn of slow remote file reading only after a successful open Andrew Burgess
2024-06-06 16:58   ` Tom Tromey
2024-06-11 19:52     ` Andrew Burgess
2024-06-05 13:15 ` [PATCH 4/8] gdb: convert separate-debug-file to new(ish) debug scheme Andrew Burgess
2024-06-06 16:54   ` Tom Tromey
2024-06-11 19:52     ` Andrew Burgess
2024-06-05 13:15 ` [PATCH 5/8] gdb: add target_fileio_stat, but no implementations yet Andrew Burgess
2024-06-05 13:15 ` [PATCH 6/8] gdb: add GDB side target_ops::fileio_stat implementation Andrew Burgess
2024-06-05 14:21   ` Eli Zaretskii
2024-06-05 13:15 ` [PATCH 7/8] gdbserver: add gdbserver support for vFile::stat packet Andrew Burgess
2024-06-05 13:15 ` [PATCH 8/8] gdb: check for multiple matching build-id files Andrew Burgess
2024-06-13 10:29 ` [PATCH 0/8] Extension for looking up debug info by build-id Andrew Burgess
2024-06-13 10:29   ` [PATCHv2 1/4] gdb: add target_fileio_stat, but no implementations yet Andrew Burgess
2024-06-13 10:29   ` [PATCHv2 2/4] gdb: add GDB side target_ops::fileio_stat implementation Andrew Burgess
2024-06-13 10:29   ` Andrew Burgess [this message]
2024-06-13 10:29   ` [PATCHv2 4/4] gdb: check for multiple matching build-id files Andrew Burgess

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=31d5c393eb5880b8c5d4684ab66196962b9b1a33.1718274353.git.aburgess@redhat.com \
    --to=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /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).