[binutils-gdb] gdb: rename target_fileio_stat to target_fileio_lstat

Andrew Burgess aburgess@sourceware.org
Tue Jun 17 20:25:03 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5d56040293f7960148b1846cbb67521a65bb195e

commit 5d56040293f7960148b1846cbb67521a65bb195e
Author: Andrew Burgess <aburgess@redhat.com>
Date:   Wed Jun 11 16:10:26 2025 +0100

    gdb: rename target_fileio_stat to target_fileio_lstat
    
    In the following commits I added the target_fileio_stat function, and
    the target_ops::fileio_stat member function:
    
      * 08a115cc1c4 gdb: add target_fileio_stat, but no implementations yet
      * 3055e3d2f13 gdb: add GDB side target_ops::fileio_stat implementation
      * 6d45af96ea5 gdbserver: add gdbserver support for vFile::stat packet
      * 22836ca8859 gdb: check for multiple matching build-id files
    
    Unfortunately, I messed up when adding this API.  The actual
    underlying call is lstat, not stat.
    
    This commit tries to clear up some of the confusion by renaming things
    to target_fileio_lstat and target_ops::fileio_lstat.
    
    After this change the function names now match the underlying
    implementation.
    
    One problem remains though.  In order to support target_fileio_stat
    for remote target the above patches added the vFile:stat packet to GDB
    and gdbserver.  The implementation of this packet still does an lstat
    though, which is a bit of a shame.  I'm going to try and fix that in
    later commits.
    
    This commit is just a rename within GDB, there should be no user
    visible changes.
    
    Approved-By: Tom Tromey <tom@tromey.com>

Diff:
---
 gdb/build-id.c  |  4 ++--
 gdb/inf-child.c |  6 +++---
 gdb/inf-child.h |  4 ++--
 gdb/remote.c    | 28 ++++++++++++++--------------
 gdb/target.c    | 12 ++++++------
 gdb/target.h    |  8 ++++----
 6 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/gdb/build-id.c b/gdb/build-id.c
index 02602affed7..f1375626f1b 100644
--- a/gdb/build-id.c
+++ b/gdb/build-id.c
@@ -128,8 +128,8 @@ build_id_to_debug_bfd_1 (const std::string &original_link,
 	  if (supports_target_stat != TRIBOOL_FALSE)
 	    {
 	      struct stat sb;
-	      int res = target_fileio_stat (nullptr, link_on_target, &sb,
-					    &target_errno);
+	      int res = target_fileio_lstat (nullptr, link_on_target, &sb,
+					     &target_errno);
 
 	      if (res != 0 && target_errno != FILEIO_ENOSYS)
 		{
diff --git a/gdb/inf-child.c b/gdb/inf-child.c
index 016f30ac03c..57ad0b4d774 100644
--- a/gdb/inf-child.c
+++ b/gdb/inf-child.c
@@ -322,11 +322,11 @@ inf_child_target::fileio_fstat (int fd, struct stat *sb, fileio_error *target_er
   return ret;
 }
 
-/* Implementation of to_fileio_stat.  */
+/* Implementation of to_fileio_lstat.  */
 
 int
-inf_child_target::fileio_stat (struct inferior *inf, const char *filename,
-			       struct stat *sb, fileio_error *target_errno)
+inf_child_target::fileio_lstat (struct inferior *inf, const char *filename,
+				struct stat *sb, fileio_error *target_errno)
 {
   int ret;
 
diff --git a/gdb/inf-child.h b/gdb/inf-child.h
index 79b51579f30..70de3932874 100644
--- a/gdb/inf-child.h
+++ b/gdb/inf-child.h
@@ -81,8 +81,8 @@ public:
   int fileio_pread (int fd, gdb_byte *read_buf, int len,
 		    ULONGEST offset, fileio_error *target_errno) override;
   int fileio_fstat (int fd, struct stat *sb, fileio_error *target_errno) override;
-  int fileio_stat (struct inferior *inf, const char *filename,
-		   struct stat *sb, fileio_error *target_errno) override;
+  int fileio_lstat (struct inferior *inf, const char *filename,
+		    struct stat *sb, fileio_error *target_errno) override;
   int fileio_close (int fd, fileio_error *target_errno) override;
   int fileio_unlink (struct inferior *inf,
 		     const char *filename,
diff --git a/gdb/remote.c b/gdb/remote.c
index 1c49cdf0fc0..92d428c63d0 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -1023,8 +1023,8 @@ public:
 
   int fileio_fstat (int fd, struct stat *sb, fileio_error *target_errno) override;
 
-  int fileio_stat (struct inferior *inf, const char *filename,
-		   struct stat *sb, fileio_error *target_errno) override;
+  int fileio_lstat (struct inferior *inf, const char *filename,
+		    struct stat *sb, fileio_error *target_errno) override;
 
   int fileio_close (int fd, fileio_error *target_errno) override;
 
@@ -13149,7 +13149,7 @@ remote_target::fileio_readlink (struct inferior *inf, const char *filename,
   return ret;
 }
 
-/* Helper function to handle ::fileio_fstat and ::fileio_stat result
+/* Helper function to handle ::fileio_fstat and ::fileio_lstat result
    processing.  When this function is called the remote syscall has been
    performed and we know we didn't get an error back.
 
@@ -13160,10 +13160,10 @@ remote_target::fileio_readlink (struct inferior *inf, const char *filename,
    data) is to be placed in ST.  */
 
 static int
-fileio_process_fstat_and_stat_reply (const char *attachment,
-				     int attachment_len,
-				     int expected_len,
-				     struct stat *st)
+fileio_process_fstat_and_lstat_reply (const char *attachment,
+				      int attachment_len,
+				      int expected_len,
+				      struct stat *st)
 {
   struct fio_stat fst;
 
@@ -13225,15 +13225,15 @@ remote_target::fileio_fstat (int fd, struct stat *st, fileio_error *remote_errno
       return 0;
     }
 
-  return fileio_process_fstat_and_stat_reply (attachment, attachment_len,
-					      ret, st);
+  return fileio_process_fstat_and_lstat_reply (attachment, attachment_len,
+					       ret, st);
 }
 
-/* Implementation of to_fileio_stat.  */
+/* Implementation of to_fileio_lstat.  */
 
 int
-remote_target::fileio_stat (struct inferior *inf, const char *filename,
-			    struct stat *st, fileio_error *remote_errno)
+remote_target::fileio_lstat (struct inferior *inf, const char *filename,
+			     struct stat *st, fileio_error *remote_errno)
 {
   struct remote_state *rs = get_remote_state ();
   char *p = rs->buf.data ();
@@ -13258,8 +13258,8 @@ remote_target::fileio_stat (struct inferior *inf, const char *filename,
   if (ret < 0)
     return ret;
 
-  return fileio_process_fstat_and_stat_reply (attachment, attachment_len,
-					      ret, st);
+  return fileio_process_fstat_and_lstat_reply (attachment, attachment_len,
+					       ret, st);
 }
 
 /* Implementation of to_filesystem_is_local.  */
diff --git a/gdb/target.c b/gdb/target.c
index 522bed8e939..a854a983204 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -3204,8 +3204,8 @@ target_ops::fileio_fstat (int fd, struct stat *sb, fileio_error *target_errno)
 }
 
 int
-target_ops::fileio_stat (struct inferior *inf, const char *filename,
-			 struct stat *sb, fileio_error *target_errno)
+target_ops::fileio_lstat (struct inferior *inf, const char *filename,
+			  struct stat *sb, fileio_error *target_errno)
 {
   *target_errno = FILEIO_ENOSYS;
   return -1;
@@ -3331,17 +3331,17 @@ target_fileio_fstat (int fd, struct stat *sb, fileio_error *target_errno)
 /* See target.h.  */
 
 int
-target_fileio_stat (struct inferior *inf, const char *filename,
-		    struct stat *sb, fileio_error *target_errno)
+target_fileio_lstat (struct inferior *inf, const char *filename,
+		     struct stat *sb, fileio_error *target_errno)
 {
   for (target_ops *t = default_fileio_target (); t != NULL; t = t->beneath ())
     {
-      int ret = t->fileio_stat (inf, filename, sb, target_errno);
+      int ret = t->fileio_lstat (inf, filename, sb, target_errno);
 
       if (ret == -1 && *target_errno == FILEIO_ENOSYS)
 	continue;
 
-      target_debug_printf_nofunc ("target_fileio_stat (%s) = %d (%d)",
+      target_debug_printf_nofunc ("target_fileio_lstat (%s) = %d (%d)",
 				  filename, ret,
 				  ret != -1 ? 0 : *target_errno);
       return ret;
diff --git a/gdb/target.h b/gdb/target.h
index 2d3bac77bd2..365e894efe6 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -1016,8 +1016,8 @@ struct target_ops
        filesystem seen by the debugger (GDB or, for remote targets, the
        remote stub).  Return 0 on success, or -1 if an error occurs (and
        set *TARGET_ERRNO).  */
-    virtual int fileio_stat (struct inferior *inf, const char *filename,
-			     struct stat *sb, fileio_error *target_errno);
+    virtual int fileio_lstat (struct inferior *inf, const char *filename,
+			      struct stat *sb, fileio_error *target_errno);
 
     /* Close FD on the target.  Return 0, or -1 if an error occurs
        (and set *TARGET_ERRNO).  */
@@ -2256,8 +2256,8 @@ extern int target_fileio_fstat (int fd, struct stat *sb,
    filesystem seen by the debugger (GDB or, for remote targets, the remote
    stub).  Return 0 on success, or -1 if an error occurs (and set
    *TARGET_ERRNO).  */
-extern int target_fileio_stat (struct inferior *inf, const char *filename,
-			       struct stat *sb, fileio_error *target_errno);
+extern int target_fileio_lstat (struct inferior *inf, const char *filename,
+				struct stat *sb, fileio_error *target_errno);
 
 /* Close FD on the target.  Return 0, or -1 if an error occurs
    (and set *TARGET_ERRNO).  */


More information about the Gdb-cvs mailing list