[04/11] gdb/linux-record: Fix readdir and getdents handling

Message ID 1445118081-10908-5-git-send-email-koriakin@0x04.net
State New, archived
Headers

Commit Message

Marcin Koƛcielnicki Oct. 17, 2015, 9:41 p.m. UTC
  getdents buffer size is given in bytes, not dirent entries (which have
variable size anyway).  We don't need size_dirent and size_dirent64 for
this reason.

readdir, on the other hand, needs size of old_linux_dirent, which is
a somewhat different structure.  Accordingly, rename size_dirent
to size_old_dirent.
---
 gdb/aarch64-linux-tdep.c |  3 +--
 gdb/amd64-linux-tdep.c   |  8 ++++----
 gdb/arm-linux-tdep.c     |  3 +--
 gdb/i386-linux-tdep.c    |  3 +--
 gdb/linux-record.c       | 19 +++----------------
 gdb/linux-record.h       |  3 +--
 gdb/ppc-linux-tdep.c     |  6 ++----
 7 files changed, 13 insertions(+), 32 deletions(-)
  

Patch

diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
index 57cb973..0a3fbb3 100644
--- a/gdb/aarch64-linux-tdep.c
+++ b/gdb/aarch64-linux-tdep.c
@@ -1009,8 +1009,7 @@  aarch64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   aarch64_linux_record_tdep.size_old_gid_t = 2;
   aarch64_linux_record_tdep.size_old_uid_t = 2;
   aarch64_linux_record_tdep.size_fd_set = 128;
-  aarch64_linux_record_tdep.size_dirent = 280;
-  aarch64_linux_record_tdep.size_dirent64 = 280;
+  aarch64_linux_record_tdep.size_old_dirent = 280;
   aarch64_linux_record_tdep.size_statfs = 120;
   aarch64_linux_record_tdep.size_statfs64 = 120;
   aarch64_linux_record_tdep.size_sockaddr = 16;
diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
index 3bca3c8..0b068c3 100644
--- a/gdb/amd64-linux-tdep.c
+++ b/gdb/amd64-linux-tdep.c
@@ -1905,8 +1905,8 @@  amd64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
      but sys_getresuid.  */
   amd64_linux_record_tdep.size_old_uid_t = 2;
   amd64_linux_record_tdep.size_fd_set = 128;
-  amd64_linux_record_tdep.size_dirent = 280;
-  amd64_linux_record_tdep.size_dirent64 = 280;
+  /* ADM64 doesn't need this size because it doesn't have sys_readdir. */
+  amd64_linux_record_tdep.size_old_dirent = 280;
   amd64_linux_record_tdep.size_statfs = 120;
   amd64_linux_record_tdep.size_statfs64 = 120;
   amd64_linux_record_tdep.size_sockaddr = 16;
@@ -2121,8 +2121,8 @@  amd64_x32_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
      but sys_getresuid.  */
   amd64_x32_linux_record_tdep.size_old_uid_t = 2;
   amd64_x32_linux_record_tdep.size_fd_set = 128;
-  amd64_x32_linux_record_tdep.size_dirent = 280;
-  amd64_x32_linux_record_tdep.size_dirent64 = 280;
+  /* ADM64 doesn't need this size because it doesn't have sys_readdir. */
+  amd64_x32_linux_record_tdep.size_old_dirent = 268;
   amd64_x32_linux_record_tdep.size_statfs = 120;
   amd64_x32_linux_record_tdep.size_statfs64 = 120;
   amd64_x32_linux_record_tdep.size_sockaddr = 16;
diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c
index 88d818d..a820e74 100644
--- a/gdb/arm-linux-tdep.c
+++ b/gdb/arm-linux-tdep.c
@@ -1496,8 +1496,7 @@  arm_linux_init_abi (struct gdbarch_info info,
   arm_linux_record_tdep.size_old_gid_t = 2;
   arm_linux_record_tdep.size_old_uid_t = 2;
   arm_linux_record_tdep.size_fd_set = 128;
-  arm_linux_record_tdep.size_dirent = 268;
-  arm_linux_record_tdep.size_dirent64 = 276;
+  arm_linux_record_tdep.size_old_dirent = 268;
   arm_linux_record_tdep.size_statfs = 64;
   arm_linux_record_tdep.size_statfs64 = 84;
   arm_linux_record_tdep.size_sockaddr = 16;
diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c
index 0bf2cdc..8847ad3 100644
--- a/gdb/i386-linux-tdep.c
+++ b/gdb/i386-linux-tdep.c
@@ -815,8 +815,7 @@  i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   i386_linux_record_tdep.size_old_gid_t = 2;
   i386_linux_record_tdep.size_old_uid_t = 2;
   i386_linux_record_tdep.size_fd_set = 128;
-  i386_linux_record_tdep.size_dirent = 268;
-  i386_linux_record_tdep.size_dirent64 = 276;
+  i386_linux_record_tdep.size_old_dirent = 268;
   i386_linux_record_tdep.size_statfs = 64;
   i386_linux_record_tdep.size_statfs64 = 84;
   i386_linux_record_tdep.size_sockaddr = 16;
diff --git a/gdb/linux-record.c b/gdb/linux-record.c
index d1e02f4..e950e8d 100644
--- a/gdb/linux-record.c
+++ b/gdb/linux-record.c
@@ -689,7 +689,7 @@  record_linux_system_call (enum gdb_syscall syscall,
     case gdb_old_readdir:
       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
       if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
-					 tdep->size_dirent))
+					 tdep->size_old_dirent))
         return -1;
       break;
 
@@ -1344,14 +1344,14 @@  Do you want to stop the program?"),
       break;
 
     case gdb_sys_getdents:
+    case gdb_sys_getdents64:
       {
         ULONGEST count;
 
         regcache_raw_read_unsigned (regcache, tdep->arg2,
                                     &tmpulongest);
         regcache_raw_read_unsigned (regcache, tdep->arg3, &count);
-        if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
-					   tdep->size_dirent * count))
+        if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest, count))
           return -1;
       }
       break;
@@ -1745,19 +1745,6 @@  Do you want to stop the program?"),
     case gdb_sys_madvise:
       break;
 
-    case gdb_sys_getdents64:
-      {
-        ULONGEST count;
-
-        regcache_raw_read_unsigned (regcache, tdep->arg2,
-                                    &tmpulongest);
-        regcache_raw_read_unsigned (regcache, tdep->arg3, &count);
-        if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
-					   tdep->size_dirent64 * count))
-          return -1;
-      }
-      break;
-
     case gdb_sys_fcntl64:
       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
       if (tmpulongest == tdep->fcntl_F_GETLK64)
diff --git a/gdb/linux-record.h b/gdb/linux-record.h
index 839bd31..9af0bdb 100644
--- a/gdb/linux-record.h
+++ b/gdb/linux-record.h
@@ -39,8 +39,7 @@  struct linux_record_tdep
   int size_old_gid_t;
   int size_old_uid_t;
   int size_fd_set;
-  int size_dirent;
-  int size_dirent64;
+  int size_old_dirent;
   int size_statfs;
   int size_statfs64;
   int size_sockaddr;
diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
index 896f410..cf71cf3 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -1432,8 +1432,7 @@  ppc_init_linux_record_tdep (struct linux_record_tdep *record_tdep,
       record_tdep->size_old_gid_t = 4;
       record_tdep->size_old_uid_t = 4;
       record_tdep->size_fd_set = 128;
-      record_tdep->size_dirent = 280;
-      record_tdep->size_dirent64 = 280;
+      record_tdep->size_old_dirent = 280;
       record_tdep->size_statfs = 120;
       record_tdep->size_statfs64 = 120;
       record_tdep->size_sockaddr = 16;
@@ -1499,8 +1498,7 @@  ppc_init_linux_record_tdep (struct linux_record_tdep *record_tdep,
       record_tdep->size_old_gid_t = 4;
       record_tdep->size_old_uid_t = 4;
       record_tdep->size_fd_set = 128;
-      record_tdep->size_dirent = 268;
-      record_tdep->size_dirent64 = 280;
+      record_tdep->size_old_dirent = 268;
       record_tdep->size_statfs = 64;
       record_tdep->size_statfs64 = 88;
       record_tdep->size_sockaddr = 16;