[PATCH] Include <linux/ptrace.h> also if <sys/reg.h> exists

Maarten ter Huurne maarten at treewalker.org
Sun Oct 19 23:02:48 UTC 2014


This fixes compilation with musl libc.
This approach was already used in process.c, so I assume it is safe.

Signed-off-by: Maarten ter Huurne <maarten at treewalker.org>
---
 The compilation error I ran into when compiling with musl for ARM:

 signal.c: In function 'sys_sigreturn':
 signal.c:735:3: error: invalid use of undefined type 'struct pt_regs'
   if (umove(tcp, arm_regs.ARM_sp, &uc) < 0)
   ^

 The actual definition of struct pt_regs is in <asm/ptrace.h> but the
 approach below is more similar to the existing code, so I thought it
 would have less risk of breaking other systems.

diff -ru strace-4.9.orig/signal.c strace-4.9/signal.c
--- strace-4.9.orig/signal.c	2014-08-15 01:29:09.000000000 +0200
+++ strace-4.9/signal.c	2014-10-19 18:56:17.742425660 +0200
@@ -37,7 +37,9 @@
 
 #ifdef HAVE_SYS_REG_H
 # include <sys/reg.h>
-#elif defined(HAVE_LINUX_PTRACE_H)
+#endif
+
+#ifdef HAVE_LINUX_PTRACE_H
 # undef PTRACE_SYSCALL
 # ifdef HAVE_STRUCT_IA64_FPREG
 #  define ia64_fpreg XXX_ia64_fpreg
diff -ru strace-4.9.orig/syscall.c strace-4.9/syscall.c
--- strace-4.9.orig/syscall.c	2014-06-04 18:28:04.000000000 +0200
+++ strace-4.9/syscall.c	2014-10-19 18:56:50.165364765 +0200
@@ -37,7 +37,9 @@
 
 #ifdef HAVE_SYS_REG_H
 # include <sys/reg.h>
-#elif defined(HAVE_LINUX_PTRACE_H)
+#endif
+
+#ifdef HAVE_LINUX_PTRACE_H
 # undef PTRACE_SYSCALL
 # ifdef HAVE_STRUCT_IA64_FPREG
 #  define ia64_fpreg XXX_ia64_fpreg
diff -ru strace-4.9.orig/util.c strace-4.9/util.c
--- strace-4.9.orig/util.c	2014-08-07 02:30:26.000000000 +0200
+++ strace-4.9/util.c	2014-10-19 18:57:16.548501540 +0200
@@ -46,7 +46,9 @@
 
 #ifdef HAVE_SYS_REG_H
 # include <sys/reg.h>
-#elif defined(HAVE_LINUX_PTRACE_H)
+#endif
+
+#ifdef HAVE_LINUX_PTRACE_H
 # undef PTRACE_SYSCALL
 # ifdef HAVE_STRUCT_IA64_FPREG
 #  define ia64_fpreg XXX_ia64_fpreg




More information about the Strace-devel mailing list