From c5516866e80f0d30806a8dc366b616aa3b4ff579 Mon Sep 17 00:00:00 2001 From: David Smith Date: Thu, 11 Oct 2012 10:55:58 -0500 Subject: [PATCH] Fixed PR14659 so that ptrace can be used on tasks probed with systemtap. * 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 | 8 ----- testsuite/systemtap.base/ptrace.exp | 46 +++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 testsuite/systemtap.base/ptrace.exp diff --git a/runtime/stp_utrace.c b/runtime/stp_utrace.c index d14475569..6a0735cdd 100644 --- a/runtime/stp_utrace.c +++ b/runtime/stp_utrace.c @@ -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 index 000000000..358d2646a --- /dev/null +++ b/testsuite/systemtap.base/ptrace.exp @@ -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" } -- 2.43.5