gdb/linux-record: Fix [gs]etgroups16 syscall
authorMarcin Kościelnicki <koriakin@0x04.net>
Fri, 30 Oct 2015 15:51:59 +0000 (15:51 +0000)
committerPedro Alves <palves@redhat.com>
Fri, 30 Oct 2015 15:51:59 +0000 (15:51 +0000)
Memory size for getgroups16 needs to be multiplied by entry count, and only
needs recording if the pointer is non-NULL.  setgroups16, on the other hand,
doesn't write to user memory and doesn't need special handling at all.

gdb/ChangeLog:

* linux-record.c (record_linux_system_call): Fix [gs]etgroups16.

gdb/ChangeLog
gdb/linux-record.c

index 413e12c6c4a876b539010c4a96f70ff7650b3f06..a6d007191a67c20df320cd8a2f6b5b046c91a9df 100644 (file)
@@ -1,3 +1,7 @@
+2015-10-30  Marcin Kościelnicki  <koriakin@0x04.net>
+
+       * linux-record.c (record_linux_system_call): Fix [gs]etgroups16.
+
 2015-10-30  Marcin Kościelnicki  <koriakin@0x04.net>
 
        * aarch64-linux-tdep.c (aarch64_linux_init_abi): Add size_time_t.
index dbd8f14a79a039c2dda0c0216694f7a78d0e3df0..25cbda1afcfd1cbb6a544906e8b08076330e2f28 100644 (file)
@@ -628,16 +628,19 @@ record_linux_system_call (enum gdb_syscall syscall,
 
     case gdb_sys_getgroups16:
       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
-      if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
-                                        tdep->size_old_gid_t))
-        return -1;
+      if (tmpulongest)
+        {
+          ULONGEST gidsetsize;
+
+          regcache_raw_read_unsigned (regcache, tdep->arg1,
+                                      &gidsetsize);
+          tmpint = tdep->size_old_gid_t * (int) gidsetsize;
+          if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest, tmpint))
+            return -1;
+        }
       break;
 
     case gdb_sys_setgroups16:
-      regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
-      if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
-                                        tdep->size_old_gid_t))
-        return -1;
       break;
 
     case gdb_old_select: