]> sourceware.org Git - systemtap.git/commitdiff
Fixed PR14659 so that ptrace can be used on tasks probed with systemtap.
authorDavid Smith <dsmith@redhat.com>
Thu, 11 Oct 2012 15:55:58 +0000 (10:55 -0500)
committerDavid Smith <dsmith@redhat.com>
Thu, 11 Oct 2012 15:55:58 +0000 (10:55 -0500)
* runtime/stp_utrace.c (utrace_set_events): No longer set
  TIF_SYSCALL_TRACE on the target task.
  (utrace_reset): No longer clear TIF_SYSCALL_TRACE on the target task.
* testsuite/systemtap.base/ptrace.exp: New testcase.

runtime/stp_utrace.c
testsuite/systemtap.base/ptrace.exp [new file with mode: 0644]

index d144755698a7ed43a404cd59a8779b06dc4089a3..6a0735cdde16072494f0a462c00eb8155ed8ed19 100644 (file)
@@ -809,11 +809,6 @@ int utrace_set_events(struct task_struct *target,
        engine->flags = events | (engine->flags & ENGINE_STOP);
        utrace->utrace_flags |= events;
 
-       /* FIXME: Hmm, unsure about calling set_tsk_thread_flag()... */
-       if ((events & UTRACE_EVENT_SYSCALL) &&
-           !(old_utrace_flags & UTRACE_EVENT_SYSCALL))
-               set_tsk_thread_flag(target, TIF_SYSCALL_TRACE);
-
        ret = 0;
        if ((old_flags & ~events) && target != current &&
            !task_is_stopped_or_traced(target) && !target->exit_state) {
@@ -953,9 +948,6 @@ static bool utrace_reset(struct task_struct *task, struct utrace *utrace)
                 */
                BUG_ON(utrace->death);
                flags &= UTRACE_EVENT(REAP);
-       } else if (!(flags & UTRACE_EVENT_SYSCALL) &&
-                  test_tsk_thread_flag(task, TIF_SYSCALL_TRACE)) {
-               clear_tsk_thread_flag(task, TIF_SYSCALL_TRACE);
        }
 
        if (!flags) {
diff --git a/testsuite/systemtap.base/ptrace.exp b/testsuite/systemtap.base/ptrace.exp
new file mode 100644 (file)
index 0000000..358d264
--- /dev/null
@@ -0,0 +1,46 @@
+# Make sure we can use ptrace() on a process probed with systemtap.
+
+set TEST_NAME "ptrace"
+if {![utrace_p]} {
+    untested "$TEST_NAME : no kernel utrace support found"
+    return
+} elseif {![installtest_p]} {
+    untested $TEST_NAME
+    return
+}
+
+# Test process.begin
+set subcmd {strace -e read true}
+set TEST_NAME "ptrace (begin)"
+set script {probe process.begin { next }}
+set cmd {stap -e $script -c $subcmd}
+set output_found 0
+eval spawn $cmd
+expect {
+    -timeout 180
+    -re {^read\(\d+, .+\) = \d+\r\n\+\+\+ exited with 0 \+\+\+\r\n} {
+       set output_found 1
+       exp_continue
+    }
+}
+catch close
+wait
+if { $output_found } { pass "$TEST_NAME" } else { fail "$TEST_NAME" }
+
+# The never probe won't get hit, but including 'print_ubacktrace()' will
+# enable task_finder and vma tracking.
+set TEST_NAME "ptrace (never)"
+set script {probe never{print_ubacktrace()}}
+set cmd {stap -e $script -c $subcmd}
+set output_found 0
+eval spawn $cmd
+expect {
+    -timeout 180
+    -re {^read\(\d+, .+\) = \d+\r\n\+\+\+ exited with 0 \+\+\+\r\n} {
+       set output_found 1
+       exp_continue
+    }
+}
+catch close
+wait
+if { $output_found } { pass "$TEST_NAME" } else { fail "$TEST_NAME" }
This page took 0.0349 seconds and 5 git commands to generate.