add s390 specific fix for getregset
authorcborntra <cborntra@a5019735-40e9-0310-863c-91ae7b9d1cf9>
Thu, 8 Nov 2012 20:10:10 +0000 (20:10 +0000)
committercborntra <cborntra@a5019735-40e9-0310-863c-91ae7b9d1cf9>
Thu, 8 Nov 2012 20:10:10 +0000 (20:10 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13112 a5019735-40e9-0310-863c-91ae7b9d1cf9

coregrind/m_syswrap/priv_syswrap-linux.h
coregrind/m_syswrap/syswrap-linux.c
coregrind/m_syswrap/syswrap-s390x-linux.c
include/vki/vki-linux.h
memcheck/tests/linux/getregset.c

index 6638f14ef17de6fad2b9fb0d0df00fd22124d639..ea043d7e30def735b4893b88ca1716aa1c2f8c81 100644 (file)
@@ -290,6 +290,11 @@ extern void ML_(linux_POST_sys_msgctl)     ( TId, UW, UW, UW, UW );
 extern void ML_(linux_PRE_sys_getsockopt)  ( TId, UW, UW, UW, UW, UW );
 extern void ML_(linux_POST_sys_getsockopt) ( TId, SR, UW, UW, UW, UW, UW );
 
+// Linux-specific (but non-arch-specific) ptrace wrapper helpers
+extern void ML_(linux_PRE_getregset) ( ThreadId, long, long );
+extern void ML_(linux_PRE_setregset) ( ThreadId, long, long );
+extern void ML_(linux_POST_getregset)( ThreadId, long, long );
+
 #undef TId
 #undef UW
 #undef SR
index cec1c2004865e4cf231abc304a75295fad482e52..18bb548bab7bc2533800c88829f980cf5711f318 100644 (file)
@@ -7230,6 +7230,46 @@ ML_(linux_POST_sys_getsockopt) ( ThreadId tid,
    }
 }
 
+/* ---------------------------------------------------------------------
+   ptrace wrapper helpers
+   ------------------------------------------------------------------ */
+
+void
+ML_(linux_PRE_getregset) ( ThreadId tid, long arg3, long arg4 )
+{
+   struct vki_iovec *iov = (struct vki_iovec *) arg4;
+
+   PRE_MEM_READ("ptrace(getregset iovec->iov_base)",
+               (unsigned long) &iov->iov_base, sizeof(iov->iov_base));
+   PRE_MEM_READ("ptrace(getregset iovec->iov_len)",
+               (unsigned long) &iov->iov_len, sizeof(iov->iov_len));
+   PRE_MEM_WRITE("ptrace(getregset *(iovec->iov_base))",
+                (unsigned long) iov->iov_base, iov->iov_len);
+}
+
+void
+ML_(linux_PRE_setregset) ( ThreadId tid, long arg3, long arg4 )
+{
+   struct vki_iovec *iov = (struct vki_iovec *) arg4;
+
+   PRE_MEM_READ("ptrace(setregset iovec->iov_base)",
+               (unsigned long) &iov->iov_base, sizeof(iov->iov_base));
+   PRE_MEM_READ("ptrace(setregset iovec->iov_len)",
+               (unsigned long) &iov->iov_len, sizeof(iov->iov_len));
+   PRE_MEM_READ("ptrace(setregset *(iovec->iov_base))",
+               (unsigned long) iov->iov_base, iov->iov_len);
+}
+
+void
+ML_(linux_POST_getregset) ( ThreadId tid, long arg3, long arg4 )
+{
+   struct vki_iovec *iov = (struct vki_iovec *) arg4;
+
+   /* XXX: The actual amount of data written by the kernel might be
+      less than iov_len, depending on the regset (arg3). */
+   POST_MEM_WRITE((unsigned long) iov->iov_base, iov->iov_len);
+}
+
 #undef PRE
 #undef POST
 
index 10d83e73db4ce374357b30ce68c90493d896e8bf..84c2f293aa43a6cb1715a2c34528b81866eadf5b 100644 (file)
@@ -345,10 +345,13 @@ DECL_TEMPLATE(s390x_linux, sys_sigreturn);
 DECL_TEMPLATE(s390x_linux, sys_rt_sigreturn);
 DECL_TEMPLATE(s390x_linux, sys_fadvise64);
 
-// PEEK TEXT,DATA and USER are common to all architectures
-// PEEKUSR_AREA and POKEUSR_AREA are special, having a memory area
-// containing the real addr, data, and len field pointed to by ARG3
-// instead of ARG4
+/* PEEK TEXT,DATA and USER are common to all architectures.
+   PEEKUSR_AREA and POKEUSR_AREA are special, having a memory area
+   containing the real addr, data, and len field pointed to by ARG3
+   instead of ARG4.
+   GETREGSET and SETREGSET use a struct iovec (pointed to by ARG4) for
+   the address and size of the user buffer. */
+
 PRE(sys_ptrace)
 {
    PRINT("sys_ptrace ( %ld, %ld, %#lx, %#lx )", ARG1,ARG2,ARG3,ARG4);
@@ -404,6 +407,12 @@ PRE(sys_ptrace)
                        pa->vki_process_addr, pa->vki_len);
          break;
       }
+   case VKI_PTRACE_GETREGSET:
+      ML_(linux_PRE_getregset)(tid, ARG3, ARG4);
+      break;
+   case VKI_PTRACE_SETREGSET:
+      ML_(linux_PRE_setregset)(tid, ARG3, ARG4);
+      break;
    default:
       break;
    }
@@ -432,7 +441,11 @@ POST(sys_ptrace)
 
         pa = (vki_ptrace_area *) ARG3;
          POST_MEM_WRITE(pa->vki_process_addr, pa->vki_len);
+        break;
       }
+   case VKI_PTRACE_GETREGSET:
+      ML_(linux_POST_getregset)(tid, ARG3, ARG4);
+      break;
    default:
       break;
    }
index 64ba6a4efdfee6599eac1af214ecf69bbd4f5695..cee687dc3dc4783a9108b718a3d24e73477b3f60 100644 (file)
@@ -2251,6 +2251,8 @@ typedef __vki_kernel_uid32_t vki_qid_t; /* Type in which we store ids in memory
 #define VKI_PTRACE_GETEVENTMSG 0x4201
 #define VKI_PTRACE_GETSIGINFO  0x4202
 #define VKI_PTRACE_SETSIGINFO  0x4203
+#define VKI_PTRACE_GETREGSET   0x4204
+#define VKI_PTRACE_SETREGSET   0x4205
 
 //----------------------------------------------------------------------
 // From linux-2.6.14/include/sound/asound.h
index 70b5ce2b368c5aad081eaf57ff692126fe0b89b0..3a6766305ffde0c0a0508f14026b3043380818d1 100644 (file)
@@ -24,7 +24,7 @@ static int
 non_empty(const char *buf, size_t len)
 {
    size_t i;
-   int c;
+   int c = 0;
    volatile const char *p = buf;
 
    for (i = 0; i != len; i++)