[PATCH 1/2] Use PTRACE_SUNDETACH everywhere on SPARC and SPARC64

James Clarke jrtc27 at jrtc27.com
Mon Aug 29 23:50:33 UTC 2016


SPARC has a different PTRACE_DETACH value correctly defined in sys/ptrace.h,
but linux/ptrace.h clobbers it with the standard one. PTRACE_SUNDETACH is
also defined to the correct value by sys/ptrace.h, so use that instead.

* pthread.h [SPARC || SPARC64]: Define PTRACE_DETACH as PTRACE_SUNDETACH.
* strace.c (detach) [SPARC]: Remove PTRACE_DETACH definition and use the
one from pthread.h.
---
 ptrace.h | 8 ++++++++
 strace.c | 4 ----
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/ptrace.h b/ptrace.h
index 0f3b022..e5c0fec 100644
--- a/ptrace.h
+++ b/ptrace.h
@@ -67,6 +67,14 @@ extern long ptrace(int, int, char *, long);
 # undef ptrace_peeksiginfo_args
 #endif
 
+#if defined(SPARC) || defined(SPARC64)
+/* SPARC has a different PTRACE_DETACH value correctly defined in sys/ptrace.h,
+ * but linux/ptrace.h clobbers it with the standard one. PTRACE_SUNDETACH is
+ * also defined to the correct value by sys/ptrace.h, so use that instead. */
+# undef PTRACE_DETACH
+# define PTRACE_DETACH PTRACE_SUNDETACH
+#endif
+
 #ifndef PTRACE_EVENT_FORK
 # define PTRACE_EVENT_FORK	1
 #endif
diff --git a/strace.c b/strace.c
index 0ee43cf..a4b999e 100644
--- a/strace.c
+++ b/strace.c
@@ -836,10 +836,6 @@ detach(struct tcb *tcp)
 	 * before detaching.  Arghh.  We go through hoops
 	 * to make a clean break of things.
 	 */
-#if defined(SPARC)
-# undef PTRACE_DETACH
-# define PTRACE_DETACH PTRACE_SUNDETACH
-#endif
 
 	if (!(tcp->flags & TCB_ATTACHED))
 		goto drop;
-- 
2.9.3





More information about the Strace-devel mailing list