]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Update configure machinery to detect PTRACE_GETREGS
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sat, 3 Aug 2013 20:34:58 +0000 (20:34 +0000)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sat, 3 Aug 2013 20:34:58 +0000 (20:34 +0000)
Using #ifdef PTRACE_GETREGS gives difficulties as in some
platforms (e.g. mips) PTRACE_GETREGS is not defined as a
preprocessor symbols unless linux/ptrace.h is included.
However, including linux/ptrace.h causes compilation error on some
other platforms

=> better detect that PTRACE_GETREGS can be used using the
configure machinery.

This should make vgdb PTRACE_GETREGS working again on
various platforms (x86/amd64/mips/...) as PTRACE_GETREGS
was disabled on all of these following r13471

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13482

configure.in
coregrind/vgdb.c

index 232ddcbc8bc5bc3db96f7311ad8d70b0d12dd9cb..6ac32b041020a28bb87e300495f796e306582d3b 100644 (file)
@@ -1040,6 +1040,25 @@ AC_MSG_RESULT([no])
 
 AM_CONDITIONAL([HAVE_GNU_STPNCPY], [test x$ac_have_gnu_stpncpy = xyes])
 
+# Check for PTRACE_GETREGS
+
+AC_MSG_CHECKING([for PTRACE_GETREGS])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <stddef.h>
+#include <sys/ptrace.h>
+#include <sys/user.h>
+]], [[
+  void *p;
+  long res = ptrace (PTRACE_GETREGS, 0, p, p);
+]])], [
+AC_MSG_RESULT([yes])
+AC_DEFINE([HAVE_PTRACE_GETREGS], 1,
+          [Define to 1 if you have the `PTRACE_GETREGS' ptrace request.])
+], [
+AC_MSG_RESULT([no])
+])
+
+
 # Check for CLOCK_MONOTONIC
 
 AC_MSG_CHECKING([for CLOCK_MONOTONIC])
index 2df024f246ef7218c770b2772956faf45cfb75b9..bfd9a75eba7f5db648f8a6bf1c2299406ff3f449 100644 (file)
@@ -691,7 +691,7 @@ static struct user user_save;
 //       runtime check not yet done.
 //   0 : PTRACE_GETREGS runtime check has failed.
 //   1 : PTRACE_GETREGS defined and runtime check ok.
-#ifdef PTRACE_GETREGS
+#ifdef HAVE_PTRACE_GETREGS
 static int has_working_ptrace_getregs = -1;
 #endif
 
@@ -702,7 +702,7 @@ static
 Bool getregs (int pid, void *regs, long regs_bsz)
 {
    DEBUG(1, "getregs regs_bsz %ld\n", regs_bsz);
-#  ifdef PTRACE_GETREGS
+#  ifdef HAVE_PTRACE_GETREGS
    if (has_working_ptrace_getregs) {
       // Platforms having GETREGS
       long res;
@@ -773,7 +773,7 @@ Bool setregs (int pid, void *regs, long regs_bsz)
    DEBUG(1, "setregs regs_bsz %ld\n", regs_bsz);
 // Note : the below is checking for GETREGS, not SETREGS
 // as if one is defined and working, the other one should also work.
-#  ifdef PTRACE_GETREGS
+#  ifdef HAVE_PTRACE_GETREGS
    if (has_working_ptrace_getregs) {
       // Platforms having SETREGS
       long res;