Mark Wielaard 1f3b65
commit 7be84ee45ccc827a63353868558bed6c824b4a68
Mark Wielaard 1f3b65
Author: cborntra <cborntra@a5019735-40e9-0310-863c-91ae7b9d1cf9>
Mark Wielaard 1f3b65
Date:   Thu Nov 8 19:42:00 2012 +0000
Mark Wielaard 1f3b65
Mark Wielaard 1f3b65
    Add ptrace getreset testcase from Andreas Arnez
Mark Wielaard 1f3b65
    arnez AT  linux DOT vnet DOT ibm DOT com
Mark Wielaard 1f3b65
    
Mark Wielaard 1f3b65
    
Mark Wielaard 1f3b65
    
Mark Wielaard 1f3b65
    git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13110 a5019735-40e9-0310-863c-91ae7b9d1cf9
Mark Wielaard 1f3b65
Mark Wielaard 1f3b65
diff --git a/memcheck/tests/linux/getregset.c b/memcheck/tests/linux/getregset.c
Mark Wielaard 1f3b65
new file mode 100644
Mark Wielaard 1f3b65
index 0000000..70b5ce2
Mark Wielaard 1f3b65
--- /dev/null
Mark Wielaard 1f3b65
+++ b/memcheck/tests/linux/getregset.c
Mark Wielaard 1f3b65
@@ -0,0 +1,76 @@
Mark Wielaard 1f3b65
+/* -*- mode: C; c-basic-offset: 3; -*- */
Mark Wielaard 1f3b65
+
Mark Wielaard 1f3b65
+#include <assert.h>
Mark Wielaard 1f3b65
+#include <elf.h>
Mark Wielaard 1f3b65
+#include <stdio.h>
Mark Wielaard 1f3b65
+#include <stdlib.h>
Mark Wielaard 1f3b65
+#include <string.h>
Mark Wielaard 1f3b65
+#include <unistd.h>
Mark Wielaard 1f3b65
+
Mark Wielaard 1f3b65
+#include <sys/ptrace.h>
Mark Wielaard 1f3b65
+#include <sys/types.h>
Mark Wielaard 1f3b65
+#include <sys/uio.h>
Mark Wielaard 1f3b65
+#include <sys/user.h>
Mark Wielaard 1f3b65
+#include <sys/wait.h>
Mark Wielaard 1f3b65
+
Mark Wielaard 1f3b65
+static int
Mark Wielaard 1f3b65
+err_out(const char *msg)
Mark Wielaard 1f3b65
+{
Mark Wielaard 1f3b65
+   perror(msg);
Mark Wielaard 1f3b65
+   return 1;
Mark Wielaard 1f3b65
+}
Mark Wielaard 1f3b65
+
Mark Wielaard 1f3b65
+static int
Mark Wielaard 1f3b65
+non_empty(const char *buf, size_t len)
Mark Wielaard 1f3b65
+{
Mark Wielaard 1f3b65
+   size_t i;
Mark Wielaard 1f3b65
+   int c;
Mark Wielaard 1f3b65
+   volatile const char *p = buf;
Mark Wielaard 1f3b65
+
Mark Wielaard 1f3b65
+   for (i = 0; i != len; i++)
Mark Wielaard 1f3b65
+      c |= p[i];
Mark Wielaard 1f3b65
+   return c;
Mark Wielaard 1f3b65
+}
Mark Wielaard 1f3b65
+
Mark Wielaard 1f3b65
+static int
Mark Wielaard 1f3b65
+do_child(void)
Mark Wielaard 1f3b65
+{
Mark Wielaard 1f3b65
+   if (ptrace(PTRACE_TRACEME, 0, NULL, NULL) == -1)
Mark Wielaard 1f3b65
+      return err_out("ptrace traceme");
Mark Wielaard 1f3b65
+   raise(SIGUSR1);
Mark Wielaard 1f3b65
+   return 0;
Mark Wielaard 1f3b65
+}
Mark Wielaard 1f3b65
+
Mark Wielaard 1f3b65
+int
Mark Wielaard 1f3b65
+main(void)
Mark Wielaard 1f3b65
+{
Mark Wielaard 1f3b65
+   char buf[1024];
Mark Wielaard 1f3b65
+   struct iovec iov;
Mark Wielaard 1f3b65
+   pid_t cpid, pid;
Mark Wielaard 1f3b65
+   int status;
Mark Wielaard 1f3b65
+
Mark Wielaard 1f3b65
+   cpid = fork();
Mark Wielaard 1f3b65
+   if (cpid == -1)
Mark Wielaard 1f3b65
+      return err_out("fork");
Mark Wielaard 1f3b65
+   if (cpid == 0)
Mark Wielaard 1f3b65
+      return do_child();
Mark Wielaard 1f3b65
+
Mark Wielaard 1f3b65
+   pid = wait(&status);
Mark Wielaard 1f3b65
+   if (pid == -1)
Mark Wielaard 1f3b65
+      return err_out("wait");
Mark Wielaard 1f3b65
+
Mark Wielaard 1f3b65
+   /* Intentionally provide an uninitialized buffer to ptrace. */
Mark Wielaard 1f3b65
+   iov.iov_len = sizeof(buf);
Mark Wielaard 1f3b65
+   iov.iov_base = buf;
Mark Wielaard 1f3b65
+   if (ptrace(0x4204, cpid, NT_PRSTATUS, &iov) == -1)
Mark Wielaard 1f3b65
+      return err_out("ptrace getregset");
Mark Wielaard 1f3b65
+
Mark Wielaard 1f3b65
+   assert(iov.iov_base == buf);
Mark Wielaard 1f3b65
+   assert(iov.iov_len > 0 && iov.iov_len < sizeof(buf));
Mark Wielaard 1f3b65
+
Mark Wielaard 1f3b65
+   /* We're assuming here that NT_PRSTATUS never contains
Mark Wielaard 1f3b65
+      all-zeros. */
Mark Wielaard 1f3b65
+   assert(non_empty(buf, iov.iov_len));
Mark Wielaard 1f3b65
+   puts("OK");
Mark Wielaard 1f3b65
+   return 0;
Mark Wielaard 1f3b65
+}
Mark Wielaard 1f3b65
diff --git a/memcheck/tests/linux/getregset.stderr.exp b/memcheck/tests/linux/getregset.stderr.exp
Mark Wielaard 1f3b65
new file mode 100644
Mark Wielaard 1f3b65
index 0000000..e69de29
Mark Wielaard 1f3b65
diff --git a/memcheck/tests/linux/getregset.stdout.exp b/memcheck/tests/linux/getregset.stdout.exp
Mark Wielaard 1f3b65
new file mode 100644
Mark Wielaard 1f3b65
index 0000000..d86bac9
Mark Wielaard 1f3b65
--- /dev/null
Mark Wielaard 1f3b65
+++ b/memcheck/tests/linux/getregset.stdout.exp
Mark Wielaard 1f3b65
@@ -0,0 +1 @@
Mark Wielaard 1f3b65
+OK
Mark Wielaard 1f3b65
diff --git a/memcheck/tests/linux/getregset.vgtest b/memcheck/tests/linux/getregset.vgtest
Mark Wielaard 1f3b65
new file mode 100644
Mark Wielaard 1f3b65
index 0000000..73f52f7
Mark Wielaard 1f3b65
--- /dev/null
Mark Wielaard 1f3b65
+++ b/memcheck/tests/linux/getregset.vgtest
Mark Wielaard 1f3b65
@@ -0,0 +1,2 @@
Mark Wielaard 1f3b65
+prog: getregset
Mark Wielaard 1f3b65
+vgopts: -q
Mark Wielaard 1f3b65
\ No newline at end of file
Mark Wielaard 1f3b65
Mark Wielaard 1f3b65
commit e48a444c9dfdf8083da562e87521c54876f8edc3
Mark Wielaard 1f3b65
Author: cborntra <cborntra@a5019735-40e9-0310-863c-91ae7b9d1cf9>
Mark Wielaard 1f3b65
Date:   Thu Nov 8 20:10:10 2012 +0000
Mark Wielaard 1f3b65
Mark Wielaard 1f3b65
    add s390 specific fix for getregset
Mark Wielaard 1f3b65
    
Mark Wielaard 1f3b65
    
Mark Wielaard 1f3b65
    git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13112 a5019735-40e9-0310-863c-91ae7b9d1cf9
Mark Wielaard 1f3b65
Mark Wielaard 1f3b65
diff --git a/coregrind/m_syswrap/priv_syswrap-linux.h b/coregrind/m_syswrap/priv_syswrap-linux.h
Mark Wielaard 1f3b65
index 6638f14..ea043d7 100644
Mark Wielaard 1f3b65
--- a/coregrind/m_syswrap/priv_syswrap-linux.h
Mark Wielaard 1f3b65
+++ b/coregrind/m_syswrap/priv_syswrap-linux.h
Mark Wielaard 1f3b65
@@ -290,6 +290,11 @@ extern void ML_(linux_POST_sys_msgctl)     ( TId, UW, UW, UW, UW );
Mark Wielaard 1f3b65
 extern void ML_(linux_PRE_sys_getsockopt)  ( TId, UW, UW, UW, UW, UW );
Mark Wielaard 1f3b65
 extern void ML_(linux_POST_sys_getsockopt) ( TId, SR, UW, UW, UW, UW, UW );
Mark Wielaard 1f3b65
 
Mark Wielaard 1f3b65
+// Linux-specific (but non-arch-specific) ptrace wrapper helpers
Mark Wielaard 1f3b65
+extern void ML_(linux_PRE_getregset) ( ThreadId, long, long );
Mark Wielaard 1f3b65
+extern void ML_(linux_PRE_setregset) ( ThreadId, long, long );
Mark Wielaard 1f3b65
+extern void ML_(linux_POST_getregset)( ThreadId, long, long );
Mark Wielaard 1f3b65
+
Mark Wielaard 1f3b65
 #undef TId
Mark Wielaard 1f3b65
 #undef UW
Mark Wielaard 1f3b65
 #undef SR
Mark Wielaard 1f3b65
diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c
Mark Wielaard 1f3b65
index cec1c20..18bb548 100644
Mark Wielaard 1f3b65
--- a/coregrind/m_syswrap/syswrap-linux.c
Mark Wielaard 1f3b65
+++ b/coregrind/m_syswrap/syswrap-linux.c
Mark Wielaard 1f3b65
@@ -7230,6 +7230,46 @@ ML_(linux_POST_sys_getsockopt) ( ThreadId tid,
Mark Wielaard 1f3b65
    }
Mark Wielaard 1f3b65
 }
Mark Wielaard 1f3b65
 
Mark Wielaard 1f3b65
+/* ---------------------------------------------------------------------
Mark Wielaard 1f3b65
+   ptrace wrapper helpers
Mark Wielaard 1f3b65
+   ------------------------------------------------------------------ */
Mark Wielaard 1f3b65
+
Mark Wielaard 1f3b65
+void
Mark Wielaard 1f3b65
+ML_(linux_PRE_getregset) ( ThreadId tid, long arg3, long arg4 )
Mark Wielaard 1f3b65
+{
Mark Wielaard 1f3b65
+   struct vki_iovec *iov = (struct vki_iovec *) arg4;
Mark Wielaard 1f3b65
+
Mark Wielaard 1f3b65
+   PRE_MEM_READ("ptrace(getregset iovec->iov_base)",
Mark Wielaard 1f3b65
+		(unsigned long) &iov->iov_base, sizeof(iov->iov_base));
Mark Wielaard 1f3b65
+   PRE_MEM_READ("ptrace(getregset iovec->iov_len)",
Mark Wielaard 1f3b65
+		(unsigned long) &iov->iov_len, sizeof(iov->iov_len));
Mark Wielaard 1f3b65
+   PRE_MEM_WRITE("ptrace(getregset *(iovec->iov_base))",
Mark Wielaard 1f3b65
+		 (unsigned long) iov->iov_base, iov->iov_len);
Mark Wielaard 1f3b65
+}
Mark Wielaard 1f3b65
+
Mark Wielaard 1f3b65
+void
Mark Wielaard 1f3b65
+ML_(linux_PRE_setregset) ( ThreadId tid, long arg3, long arg4 )
Mark Wielaard 1f3b65
+{
Mark Wielaard 1f3b65
+   struct vki_iovec *iov = (struct vki_iovec *) arg4;
Mark Wielaard 1f3b65
+
Mark Wielaard 1f3b65
+   PRE_MEM_READ("ptrace(setregset iovec->iov_base)",
Mark Wielaard 1f3b65
+		(unsigned long) &iov->iov_base, sizeof(iov->iov_base));
Mark Wielaard 1f3b65
+   PRE_MEM_READ("ptrace(setregset iovec->iov_len)",
Mark Wielaard 1f3b65
+		(unsigned long) &iov->iov_len, sizeof(iov->iov_len));
Mark Wielaard 1f3b65
+   PRE_MEM_READ("ptrace(setregset *(iovec->iov_base))",
Mark Wielaard 1f3b65
+		(unsigned long) iov->iov_base, iov->iov_len);
Mark Wielaard 1f3b65
+}
Mark Wielaard 1f3b65
+
Mark Wielaard 1f3b65
+void
Mark Wielaard 1f3b65
+ML_(linux_POST_getregset) ( ThreadId tid, long arg3, long arg4 )
Mark Wielaard 1f3b65
+{
Mark Wielaard 1f3b65
+   struct vki_iovec *iov = (struct vki_iovec *) arg4;
Mark Wielaard 1f3b65
+
Mark Wielaard 1f3b65
+   /* XXX: The actual amount of data written by the kernel might be
Mark Wielaard 1f3b65
+      less than iov_len, depending on the regset (arg3). */
Mark Wielaard 1f3b65
+   POST_MEM_WRITE((unsigned long) iov->iov_base, iov->iov_len);
Mark Wielaard 1f3b65
+}
Mark Wielaard 1f3b65
+
Mark Wielaard 1f3b65
 #undef PRE
Mark Wielaard 1f3b65
 #undef POST
Mark Wielaard 1f3b65
 
Mark Wielaard 1f3b65
diff --git a/coregrind/m_syswrap/syswrap-s390x-linux.c b/coregrind/m_syswrap/syswrap-s390x-linux.c
Mark Wielaard 1f3b65
index 10d83e7..84c2f29 100644
Mark Wielaard 1f3b65
--- a/coregrind/m_syswrap/syswrap-s390x-linux.c
Mark Wielaard 1f3b65
+++ b/coregrind/m_syswrap/syswrap-s390x-linux.c
Mark Wielaard 1f3b65
@@ -345,10 +345,13 @@ DECL_TEMPLATE(s390x_linux, sys_sigreturn);
Mark Wielaard 1f3b65
 DECL_TEMPLATE(s390x_linux, sys_rt_sigreturn);
Mark Wielaard 1f3b65
 DECL_TEMPLATE(s390x_linux, sys_fadvise64);
Mark Wielaard 1f3b65
 
Mark Wielaard 1f3b65
-// PEEK TEXT,DATA and USER are common to all architectures
Mark Wielaard 1f3b65
-// PEEKUSR_AREA and POKEUSR_AREA are special, having a memory area
Mark Wielaard 1f3b65
-// containing the real addr, data, and len field pointed to by ARG3
Mark Wielaard 1f3b65
-// instead of ARG4
Mark Wielaard 1f3b65
+/* PEEK TEXT,DATA and USER are common to all architectures.
Mark Wielaard 1f3b65
+   PEEKUSR_AREA and POKEUSR_AREA are special, having a memory area
Mark Wielaard 1f3b65
+   containing the real addr, data, and len field pointed to by ARG3
Mark Wielaard 1f3b65
+   instead of ARG4.
Mark Wielaard 1f3b65
+   GETREGSET and SETREGSET use a struct iovec (pointed to by ARG4) for
Mark Wielaard 1f3b65
+   the address and size of the user buffer. */
Mark Wielaard 1f3b65
+
Mark Wielaard 1f3b65
 PRE(sys_ptrace)
Mark Wielaard 1f3b65
 {
Mark Wielaard 1f3b65
    PRINT("sys_ptrace ( %ld, %ld, %#lx, %#lx )", ARG1,ARG2,ARG3,ARG4);
Mark Wielaard 1f3b65
@@ -404,6 +407,12 @@ PRE(sys_ptrace)
Mark Wielaard 1f3b65
                        pa->vki_process_addr, pa->vki_len);
Mark Wielaard 1f3b65
          break;
Mark Wielaard 1f3b65
       }
Mark Wielaard 1f3b65
+   case VKI_PTRACE_GETREGSET:
Mark Wielaard 1f3b65
+      ML_(linux_PRE_getregset)(tid, ARG3, ARG4);
Mark Wielaard 1f3b65
+      break;
Mark Wielaard 1f3b65
+   case VKI_PTRACE_SETREGSET:
Mark Wielaard 1f3b65
+      ML_(linux_PRE_setregset)(tid, ARG3, ARG4);
Mark Wielaard 1f3b65
+      break;
Mark Wielaard 1f3b65
    default:
Mark Wielaard 1f3b65
       break;
Mark Wielaard 1f3b65
    }
Mark Wielaard 1f3b65
@@ -432,7 +441,11 @@ POST(sys_ptrace)
Mark Wielaard 1f3b65
 
Mark Wielaard 1f3b65
 	 pa = (vki_ptrace_area *) ARG3;
Mark Wielaard 1f3b65
          POST_MEM_WRITE(pa->vki_process_addr, pa->vki_len);
Mark Wielaard 1f3b65
+	 break;
Mark Wielaard 1f3b65
       }
Mark Wielaard 1f3b65
+   case VKI_PTRACE_GETREGSET:
Mark Wielaard 1f3b65
+      ML_(linux_POST_getregset)(tid, ARG3, ARG4);
Mark Wielaard 1f3b65
+      break;
Mark Wielaard 1f3b65
    default:
Mark Wielaard 1f3b65
       break;
Mark Wielaard 1f3b65
    }
Mark Wielaard 1f3b65
diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h
Mark Wielaard 1f3b65
index 64ba6a4..cee687d 100644
Mark Wielaard 1f3b65
--- a/include/vki/vki-linux.h
Mark Wielaard 1f3b65
+++ b/include/vki/vki-linux.h
Mark Wielaard 1f3b65
@@ -2251,6 +2251,8 @@ typedef __vki_kernel_uid32_t vki_qid_t; /* Type in which we store ids in memory
Mark Wielaard 1f3b65
 #define VKI_PTRACE_GETEVENTMSG	0x4201
Mark Wielaard 1f3b65
 #define VKI_PTRACE_GETSIGINFO	0x4202
Mark Wielaard 1f3b65
 #define VKI_PTRACE_SETSIGINFO	0x4203
Mark Wielaard 1f3b65
+#define VKI_PTRACE_GETREGSET	0x4204
Mark Wielaard 1f3b65
+#define VKI_PTRACE_SETREGSET	0x4205
Mark Wielaard 1f3b65
 
Mark Wielaard 1f3b65
 //----------------------------------------------------------------------
Mark Wielaard 1f3b65
 // From linux-2.6.14/include/sound/asound.h
Mark Wielaard 1f3b65
diff --git a/memcheck/tests/linux/getregset.c b/memcheck/tests/linux/getregset.c
Mark Wielaard 1f3b65
index 70b5ce2..3a67663 100644
Mark Wielaard 1f3b65
--- a/memcheck/tests/linux/getregset.c
Mark Wielaard 1f3b65
+++ b/memcheck/tests/linux/getregset.c
Mark Wielaard 1f3b65
@@ -24,7 +24,7 @@ static int
Mark Wielaard 1f3b65
 non_empty(const char *buf, size_t len)
Mark Wielaard 1f3b65
 {
Mark Wielaard 1f3b65
    size_t i;
Mark Wielaard 1f3b65
-   int c;
Mark Wielaard 1f3b65
+   int c = 0;
Mark Wielaard 1f3b65
    volatile const char *p = buf;
Mark Wielaard 1f3b65
 
Mark Wielaard 1f3b65
    for (i = 0; i != len; i++)
Mark Wielaard 1f3b65
Mark Wielaard 1f3b65
commit b2cd1bc0abb95119df1b9b8e6dcc71e48b828a94
Mark Wielaard 1f3b65
Author: cborntra <cborntra@a5019735-40e9-0310-863c-91ae7b9d1cf9>
Mark Wielaard 1f3b65
Date:   Thu Nov 8 20:27:05 2012 +0000
Mark Wielaard 1f3b65
Mark Wielaard 1f3b65
    also wire up arm, x86 and amd64 regarding ptrace regsets
Mark Wielaard 1f3b65
    original patch from
Mark Wielaard 1f3b65
    Andreas Arnez <arnez AT  linux DOT vnet DOT ibm DOT com>
Mark Wielaard 1f3b65
    
Mark Wielaard 1f3b65
    Seems that ppc and mips dont have ptrace support....
Mark Wielaard 1f3b65
    
Mark Wielaard 1f3b65
    
Mark Wielaard 1f3b65
    
Mark Wielaard 1f3b65
    git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13113 a5019735-40e9-0310-863c-91ae7b9d1cf9
Mark Wielaard 1f3b65
Mark Wielaard 1f3b65
diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c b/coregrind/m_syswrap/syswrap-amd64-linux.c
Mark Wielaard 1f3b65
index 035f7b8..2f2b0a4 100644
Mark Wielaard 1f3b65
--- a/coregrind/m_syswrap/syswrap-amd64-linux.c
Mark Wielaard 1f3b65
+++ b/coregrind/m_syswrap/syswrap-amd64-linux.c
Mark Wielaard 1f3b65
@@ -617,6 +617,12 @@ PRE(sys_ptrace)
Mark Wielaard 1f3b65
    case VKI_PTRACE_SETSIGINFO:
Mark Wielaard 1f3b65
       PRE_MEM_READ( "ptrace(setsiginfo)", ARG4, sizeof(vki_siginfo_t));
Mark Wielaard 1f3b65
       break;
Mark Wielaard 1f3b65
+   case VKI_PTRACE_GETREGSET:
Mark Wielaard 1f3b65
+      ML_(linux_PRE_getregset)(tid, ARG3, ARG4);
Mark Wielaard 1f3b65
+      break;
Mark Wielaard 1f3b65
+   case VKI_PTRACE_SETREGSET:
Mark Wielaard 1f3b65
+      ML_(linux_PRE_setregset)(tid, ARG3, ARG4);
Mark Wielaard 1f3b65
+      break;
Mark Wielaard 1f3b65
    default:
Mark Wielaard 1f3b65
       break;
Mark Wielaard 1f3b65
    }
Mark Wielaard 1f3b65
@@ -645,6 +651,9 @@ POST(sys_ptrace)
Mark Wielaard 1f3b65
        */
Mark Wielaard 1f3b65
       POST_MEM_WRITE( ARG4, sizeof(vki_siginfo_t));
Mark Wielaard 1f3b65
       break;
Mark Wielaard 1f3b65
+   case VKI_PTRACE_GETREGSET:
Mark Wielaard 1f3b65
+      ML_(linux_POST_getregset)(tid, ARG3, ARG4);
Mark Wielaard 1f3b65
+      break;
Mark Wielaard 1f3b65
    default:
Mark Wielaard 1f3b65
       break;
Mark Wielaard 1f3b65
    }
Mark Wielaard 1f3b65
diff --git a/coregrind/m_syswrap/syswrap-arm-linux.c b/coregrind/m_syswrap/syswrap-arm-linux.c
Mark Wielaard 1f3b65
index 27ecc8c..f60d771 100644
Mark Wielaard 1f3b65
--- a/coregrind/m_syswrap/syswrap-arm-linux.c
Mark Wielaard 1f3b65
+++ b/coregrind/m_syswrap/syswrap-arm-linux.c
Mark Wielaard 1f3b65
@@ -1110,6 +1110,12 @@ PRE(sys_ptrace)
Mark Wielaard 1f3b65
    case VKI_PTRACE_SETSIGINFO:
Mark Wielaard 1f3b65
       PRE_MEM_READ( "ptrace(setsiginfo)", ARG4, sizeof(vki_siginfo_t));
Mark Wielaard 1f3b65
       break;
Mark Wielaard 1f3b65
+   case VKI_PTRACE_GETREGSET:
Mark Wielaard 1f3b65
+      ML_(linux_PRE_getregset)(tid, ARG3, ARG4);
Mark Wielaard 1f3b65
+      break;
Mark Wielaard 1f3b65
+   case VKI_PTRACE_SETREGSET:
Mark Wielaard 1f3b65
+      ML_(linux_PRE_setregset)(tid, ARG3, ARG4);
Mark Wielaard 1f3b65
+      break;
Mark Wielaard 1f3b65
    default:
Mark Wielaard 1f3b65
       break;
Mark Wielaard 1f3b65
    }
Mark Wielaard 1f3b65
@@ -1149,6 +1155,9 @@ POST(sys_ptrace)
Mark Wielaard 1f3b65
        */
Mark Wielaard 1f3b65
       POST_MEM_WRITE( ARG4, sizeof(vki_siginfo_t));
Mark Wielaard 1f3b65
       break;
Mark Wielaard 1f3b65
+   case VKI_PTRACE_GETREGSET:
Mark Wielaard 1f3b65
+      ML_(linux_POST_getregset)(tid, ARG3, ARG4);
Mark Wielaard 1f3b65
+      break;
Mark Wielaard 1f3b65
    default:
Mark Wielaard 1f3b65
       break;
Mark Wielaard 1f3b65
    }
Mark Wielaard 1f3b65
diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c
Mark Wielaard 1f3b65
index 8f47efd..b9f94b6 100644
Mark Wielaard 1f3b65
--- a/coregrind/m_syswrap/syswrap-x86-linux.c
Mark Wielaard 1f3b65
+++ b/coregrind/m_syswrap/syswrap-x86-linux.c
Mark Wielaard 1f3b65
@@ -1139,6 +1139,12 @@ PRE(sys_ptrace)
Mark Wielaard 1f3b65
    case VKI_PTRACE_SETSIGINFO:
Mark Wielaard 1f3b65
       PRE_MEM_READ( "ptrace(setsiginfo)", ARG4, sizeof(vki_siginfo_t));
Mark Wielaard 1f3b65
       break;
Mark Wielaard 1f3b65
+   case VKI_PTRACE_GETREGSET:
Mark Wielaard 1f3b65
+      ML_(linux_PRE_getregset)(tid, ARG3, ARG4);
Mark Wielaard 1f3b65
+      break;
Mark Wielaard 1f3b65
+   case VKI_PTRACE_SETREGSET:
Mark Wielaard 1f3b65
+      ML_(linux_PRE_setregset)(tid, ARG3, ARG4);
Mark Wielaard 1f3b65
+      break;
Mark Wielaard 1f3b65
    default:
Mark Wielaard 1f3b65
       break;
Mark Wielaard 1f3b65
    }
Mark Wielaard 1f3b65
@@ -1170,6 +1176,9 @@ POST(sys_ptrace)
Mark Wielaard 1f3b65
        */
Mark Wielaard 1f3b65
       POST_MEM_WRITE( ARG4, sizeof(vki_siginfo_t));
Mark Wielaard 1f3b65
       break;
Mark Wielaard 1f3b65
+   case VKI_PTRACE_GETREGSET:
Mark Wielaard 1f3b65
+      ML_(linux_POST_getregset)(tid, ARG3, ARG4);
Mark Wielaard 1f3b65
+      break;
Mark Wielaard 1f3b65
    default:
Mark Wielaard 1f3b65
       break;
Mark Wielaard 1f3b65
    }
Mark Wielaard 1f3b65
Mark Wielaard 1f3b65
commit 49cc754d63a30accef06cd9a18315051b206373c
Mark Wielaard 1f3b65
Author: cborntra <cborntra@a5019735-40e9-0310-863c-91ae7b9d1cf9>
Mark Wielaard 1f3b65
Date:   Fri Nov 9 08:06:14 2012 +0000
Mark Wielaard 1f3b65
Mark Wielaard 1f3b65
    GETREGSET was introduced with 2.6.33.
Mark Wielaard 1f3b65
    
Mark Wielaard 1f3b65
    
Mark Wielaard 1f3b65
    git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13115 a5019735-40e9-0310-863c-91ae7b9d1cf9
Mark Wielaard 1f3b65
Mark Wielaard 1f3b65
diff --git a/memcheck/tests/linux/getregset.vgtest b/memcheck/tests/linux/getregset.vgtest
Mark Wielaard 1f3b65
index 73f52f7..14be523 100644
Mark Wielaard 1f3b65
--- a/memcheck/tests/linux/getregset.vgtest
Mark Wielaard 1f3b65
+++ b/memcheck/tests/linux/getregset.vgtest
Mark Wielaard 1f3b65
@@ -1,2 +1,4 @@
Mark Wielaard 1f3b65
 prog: getregset
Mark Wielaard 1f3b65
-vgopts: -q
Mark Wielaard 1f3b65
\ No newline at end of file
Mark Wielaard 1f3b65
+vgopts: -q
Mark Wielaard 1f3b65
+prereq: ../../../tests/os_test linux 2.6.33
Mark Wielaard 1f3b65
+
Mark Wielaard 1f3b65
commit a9a475d568840ecdfcc312cc4b02c29e20b81fab
Mark Wielaard 1f3b65
Author: cborntra <cborntra@a5019735-40e9-0310-863c-91ae7b9d1cf9>
Mark Wielaard 1f3b65
Date:   Thu Nov 8 19:46:29 2012 +0000
Mark Wielaard 1f3b65
Mark Wielaard 1f3b65
    wire up testcase
Mark Wielaard 1f3b65
    
Mark Wielaard 1f3b65
    
Mark Wielaard 1f3b65
    git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13111 a5019735-40e9-0310-863c-91ae7b9d1cf9
Mark Wielaard 1f3b65
Mark Wielaard 1f3b65
diff --git a/memcheck/tests/linux/Makefile.am b/memcheck/tests/linux/Makefile.am
Mark Wielaard 1f3b65
index b59afae..5885ab0 100644
Mark Wielaard 1f3b65
--- a/memcheck/tests/linux/Makefile.am
Mark Wielaard 1f3b65
+++ b/memcheck/tests/linux/Makefile.am
Mark Wielaard 1f3b65
@@ -16,11 +16,13 @@ EXTRA_DIST = \
Mark Wielaard 1f3b65
 	syslog-syscall.vgtest syslog-syscall.stderr.exp \
Mark Wielaard 1f3b65
 	timerfd-syscall.vgtest timerfd-syscall.stderr.exp \
Mark Wielaard 1f3b65
 	with-space.stderr.exp with-space.stdout.exp with-space.vgtest \
Mark Wielaard 1f3b65
-	proc-auxv.vgtest proc-auxv.stderr.exp
Mark Wielaard 1f3b65
+	proc-auxv.vgtest proc-auxv.stderr.exp getregset.vgtest \
Mark Wielaard 1f3b65
+	getregset.stderr.exp getregset.stdout.exp
Mark Wielaard 1f3b65
 
Mark Wielaard 1f3b65
 check_PROGRAMS = \
Mark Wielaard 1f3b65
 	brk \
Mark Wielaard 1f3b65
 	capget \
Mark Wielaard 1f3b65
+	getregset \
Mark Wielaard 1f3b65
 	lsframe1 \
Mark Wielaard 1f3b65
 	lsframe2 \
Mark Wielaard 1f3b65
 	sigqueue \
Mark Wielaard 1f3b65
--- valgrind-3.8.1/memcheck/tests/linux/Makefile.in.orig	2013-02-19 15:22:18.550589954 +0100
Mark Wielaard 1f3b65
+++ valgrind-3.8.1/memcheck/tests/linux/Makefile.in	2013-02-19 15:22:30.941543855 +0100
Mark Wielaard 1f3b65
@@ -54,11 +54,11 @@
Mark Wielaard 1f3b65
 @VGCONF_HAVE_PLATFORM_SEC_TRUE@am__append_2 = -DVGA_SEC_@VGCONF_ARCH_SEC@=1  \
Mark Wielaard 1f3b65
 @VGCONF_HAVE_PLATFORM_SEC_TRUE@		-DVGP_SEC_@VGCONF_ARCH_PRI@_@VGCONF_OS@=1
Mark Wielaard 1f3b65
 
Mark Wielaard 1f3b65
-check_PROGRAMS = brk$(EXEEXT) capget$(EXEEXT) lsframe1$(EXEEXT) \
Mark Wielaard 1f3b65
-	lsframe2$(EXEEXT) sigqueue$(EXEEXT) stack_changes$(EXEEXT) \
Mark Wielaard 1f3b65
-	stack_switch$(EXEEXT) syscalls-2007$(EXEEXT) \
Mark Wielaard 1f3b65
-	syslog-syscall$(EXEEXT) timerfd-syscall$(EXEEXT) \
Mark Wielaard 1f3b65
-	proc-auxv$(EXEEXT)
Mark Wielaard 1f3b65
+check_PROGRAMS = brk$(EXEEXT) capget$(EXEEXT) getregset$(EXEEXT) \
Mark Wielaard 1f3b65
+	lsframe1$(EXEEXT) lsframe2$(EXEEXT) sigqueue$(EXEEXT) \
Mark Wielaard 1f3b65
+	stack_changes$(EXEEXT) stack_switch$(EXEEXT) \
Mark Wielaard 1f3b65
+	syscalls-2007$(EXEEXT) syslog-syscall$(EXEEXT) \
Mark Wielaard 1f3b65
+	timerfd-syscall$(EXEEXT) proc-auxv$(EXEEXT)
Mark Wielaard 1f3b65
 subdir = memcheck/tests/linux
Mark Wielaard 1f3b65
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
Mark Wielaard 1f3b65
 am__aclocal_m4_deps = $(top_srcdir)/configure.in
Mark Wielaard 1f3b65
@@ -74,6 +74,9 @@
Mark Wielaard 1f3b65
 capget_SOURCES = capget.c
Mark Wielaard 1f3b65
 capget_OBJECTS = capget.$(OBJEXT)
Mark Wielaard 1f3b65
 capget_LDADD = $(LDADD)
Mark Wielaard 1f3b65
+getregset_SOURCES = getregset.c
Mark Wielaard 1f3b65
+getregset_OBJECTS = getregset.$(OBJEXT)
Mark Wielaard 1f3b65
+getregset_LDADD = $(LDADD)
Mark Wielaard 1f3b65
 lsframe1_SOURCES = lsframe1.c
Mark Wielaard 1f3b65
 lsframe1_OBJECTS = lsframe1.$(OBJEXT)
Mark Wielaard 1f3b65
 lsframe1_LDADD = $(LDADD)
Mark Wielaard 1f3b65
@@ -110,12 +113,12 @@
Mark Wielaard 1f3b65
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
Mark Wielaard 1f3b65
 CCLD = $(CC)
Mark Wielaard 1f3b65
 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
Mark Wielaard 1f3b65
-SOURCES = brk.c capget.c lsframe1.c lsframe2.c proc-auxv.c sigqueue.c \
Mark Wielaard 1f3b65
-	stack_changes.c stack_switch.c syscalls-2007.c \
Mark Wielaard 1f3b65
-	syslog-syscall.c timerfd-syscall.c
Mark Wielaard 1f3b65
-DIST_SOURCES = brk.c capget.c lsframe1.c lsframe2.c proc-auxv.c \
Mark Wielaard 1f3b65
+SOURCES = brk.c capget.c getregset.c lsframe1.c lsframe2.c proc-auxv.c \
Mark Wielaard 1f3b65
 	sigqueue.c stack_changes.c stack_switch.c syscalls-2007.c \
Mark Wielaard 1f3b65
 	syslog-syscall.c timerfd-syscall.c
Mark Wielaard 1f3b65
+DIST_SOURCES = brk.c capget.c getregset.c lsframe1.c lsframe2.c \
Mark Wielaard 1f3b65
+	proc-auxv.c sigqueue.c stack_changes.c stack_switch.c \
Mark Wielaard 1f3b65
+	syscalls-2007.c syslog-syscall.c timerfd-syscall.c
Mark Wielaard 1f3b65
 ETAGS = etags
Mark Wielaard 1f3b65
 CTAGS = ctags
Mark Wielaard 1f3b65
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
Mark Wielaard 1f3b65
@@ -409,7 +412,8 @@
Mark Wielaard 1f3b65
 	syslog-syscall.vgtest syslog-syscall.stderr.exp \
Mark Wielaard 1f3b65
 	timerfd-syscall.vgtest timerfd-syscall.stderr.exp \
Mark Wielaard 1f3b65
 	with-space.stderr.exp with-space.stdout.exp with-space.vgtest \
Mark Wielaard 1f3b65
-	proc-auxv.vgtest proc-auxv.stderr.exp
Mark Wielaard 1f3b65
+	proc-auxv.vgtest proc-auxv.stderr.exp getregset.vgtest \
Mark Wielaard 1f3b65
+	getregset.stderr.exp getregset.stdout.exp
Mark Wielaard 1f3b65
 
Mark Wielaard 1f3b65
 stack_switch_LDADD = -lpthread
Mark Wielaard 1f3b65
 timerfd_syscall_LDADD = -lrt
Mark Wielaard 1f3b65
@@ -456,6 +460,9 @@
Mark Wielaard 1f3b65
 capget$(EXEEXT): $(capget_OBJECTS) $(capget_DEPENDENCIES) 
Mark Wielaard 1f3b65
 	@rm -f capget$(EXEEXT)
Mark Wielaard 1f3b65
 	$(LINK) $(capget_OBJECTS) $(capget_LDADD) $(LIBS)
Mark Wielaard 1f3b65
+getregset$(EXEEXT): $(getregset_OBJECTS) $(getregset_DEPENDENCIES) 
Mark Wielaard 1f3b65
+	@rm -f getregset$(EXEEXT)
Mark Wielaard 1f3b65
+	$(LINK) $(getregset_OBJECTS) $(getregset_LDADD) $(LIBS)
Mark Wielaard 1f3b65
 lsframe1$(EXEEXT): $(lsframe1_OBJECTS) $(lsframe1_DEPENDENCIES) 
Mark Wielaard 1f3b65
 	@rm -f lsframe1$(EXEEXT)
Mark Wielaard 1f3b65
 	$(LINK) $(lsframe1_OBJECTS) $(lsframe1_LDADD) $(LIBS)
Mark Wielaard 1f3b65
@@ -492,6 +499,7 @@
Mark Wielaard 1f3b65
 
Mark Wielaard 1f3b65
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/brk.Po@am__quote@
Mark Wielaard 1f3b65
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/capget.Po@am__quote@
Mark Wielaard 1f3b65
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getregset.Po@am__quote@
Mark Wielaard 1f3b65
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lsframe1.Po@am__quote@
Mark Wielaard 1f3b65
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lsframe2.Po@am__quote@
Mark Wielaard 1f3b65
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proc-auxv.Po@am__quote@