]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: rename target_fileio_stat to target_fileio_lstat
authorAndrew Burgess <aburgess@redhat.com>
Wed, 11 Jun 2025 15:10:26 +0000 (16:10 +0100)
committerAndrew Burgess <aburgess@redhat.com>
Tue, 17 Jun 2025 20:21:32 +0000 (21:21 +0100)
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>
gdb/build-id.c
gdb/inf-child.c
gdb/inf-child.h
gdb/remote.c
gdb/target.c
gdb/target.h

index 02602affed7cca83706bb8088678a23bca8ee860..f1375626f1b5250908381bfc8693d153d51ecaf7 100644 (file)
@@ -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)
                {
index 016f30ac03c10838d7f912f897c975e9cb76ad4c..57ad0b4d774981c7815cac873c6e441448b123f9 100644 (file)
@@ -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;
 
index 79b51579f3016ee2365e7a6dfc2dc1d5e307f25b..70de39328743e80bacfe774365fbb697fdd95d54 100644 (file)
@@ -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,
index 1c49cdf0fc0a9750c7cf537434857e86e57ddda7..92d428c63d0778e28066b4730bf2dad3234b6c8d 100644 (file)
@@ -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.  */
index 522bed8e939cc6bc098b3607b117017ee48540d2..a854a9832047a9efc60ac50ea3df5daaa4f3b041 100644 (file)
@@ -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;
index 2d3bac77bd2af53b689c785a66da15c01692b43a..365e894efe6918db9653218b178c9a36206829b1 100644 (file)
@@ -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).  */