]> granicus.if.org Git - strace/commitdiff
Enable usage of PTRACE_SEIZE
authorDenys Vlasenko <vda.linux@googlemail.com>
Tue, 10 Jul 2012 14:36:32 +0000 (16:36 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Tue, 10 Jul 2012 14:36:32 +0000 (16:36 +0200)
* defs.h: Define USE_SEIZE to 1. Remove PTRACE_SEIZE_DEVEL
and PTRACE_EVENT_STOP1.
* strace.c (ptrace_attach_or_seize): Replace PTRACE_SEIZE_DEVEL
with 0.
(trace): Do not check for PTRACE_EVENT_STOP1.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
defs.h
strace.c

diff --git a/defs.h b/defs.h
index 9979fcbd96a5c0d0813d5dccee9d2d46b5979122..7814bbd1234d5572aa0c555f0e56a196573a4556 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -300,8 +300,10 @@ extern long ptrace(int, int, char *, long);
 # define PTRACE_EVENT_EXIT     6
 #endif
 
-/* Experimental code using PTRACE_SEIZE can be enabled here: */
-//# define USE_SEIZE 1
+/* Experimental code using PTRACE_SEIZE can be enabled here.
+ * This needs Linux kernel 3.4.x or later to work.
+ */
+#define USE_SEIZE 1
 
 #ifdef USE_SEIZE
 # undef PTRACE_SEIZE
@@ -310,11 +312,8 @@ extern long ptrace(int, int, char *, long);
 # define PTRACE_INTERRUPT      0x4207
 # undef PTRACE_LISTEN
 # define PTRACE_LISTEN         0x4208
-# undef PTRACE_SEIZE_DEVEL
-# define PTRACE_SEIZE_DEVEL    0x80000000
 # undef PTRACE_EVENT_STOP
-# define PTRACE_EVENT_STOP     7
-# define PTRACE_EVENT_STOP1    128
+# define PTRACE_EVENT_STOP     128
 #endif
 
 #if defined(I386)
index 9d7ee7b31c3aff38694ab9e188dbea5d02c0f54c..e6d6d687f64a3a965e98387841655796a6ecb6be 100644 (file)
--- a/strace.c
+++ b/strace.c
@@ -335,7 +335,7 @@ ptrace_attach_or_seize(int pid)
        int r;
        if (!use_seize)
                return ptrace(PTRACE_ATTACH, pid, 0, 0);
-       r = ptrace(PTRACE_SEIZE, pid, 0, PTRACE_SEIZE_DEVEL);
+       r = ptrace(PTRACE_SEIZE, pid, 0, 0);
        if (r)
                return r;
        r = ptrace(PTRACE_INTERRUPT, pid, 0, 0);
@@ -1382,7 +1382,7 @@ test_ptrace_seize(void)
         * attaching tracee continues to run unless a trap condition occurs.
         * PTRACE_SEIZE doesn't affect signal or group stop state.
         */
-       if (ptrace(PTRACE_SEIZE, pid, 0, PTRACE_SEIZE_DEVEL) == 0) {
+       if (ptrace(PTRACE_SEIZE, pid, 0, 0) == 0) {
                post_attach_sigstop = 0; /* this sets use_seize to 1 */
        } else if (debug_flag) {
                fprintf(stderr, "PTRACE_SEIZE doesn't work\n");
@@ -2074,7 +2074,7 @@ trace(void)
                if (event != 0) {
                        /* Ptrace event */
 #ifdef USE_SEIZE
-                       if (event == PTRACE_EVENT_STOP || event == PTRACE_EVENT_STOP1) {
+                       if (event == PTRACE_EVENT_STOP) {
                                /*
                                 * PTRACE_INTERRUPT-stop or group-stop.
                                 * PTRACE_INTERRUPT-stop has sig == SIGTRAP here.