Debian Codegraph @

doc/SystemTap_Beginners_Guide/testsuite/systemtap.base/ptrace.exp

raw
1 # Make sure we can use ptrace() on a process probed with systemtap.
2
3 set TEST_NAME "ptrace"
4 if {![uprobes_p]} {
5 untested "$TEST_NAME : no uprobes support found"
6 return
7 } elseif {![installtest_p]} {
8 untested $TEST_NAME
9 return
10 }
11
12 # Does 'strace' exist on this system? If not, not much point in going
13 # on further.
14 if {[catch { exec which strace } res]} {
15 fail "$TEST_NAME find 'strace'"
16 return
17 }
18 pass "$TEST_NAME find 'strace'"
19
20 # Test process.begin
21 set subcmd {strace -e read true}
22 set TEST_NAME "ptrace (begin)"
23 set script {probe process.begin { next }}
24 set cmd {stap -e $script -c $subcmd}
25 set output_found 0
26 eval spawn $cmd
27 expect {
28 -timeout 180
29 -re {^read\(\d+, .+\) = \d+\r\n} {
30 set output_found 1
31 exp_continue
32 }
33 }
34 catch close
35 wait
36 if { $output_found } { pass "$TEST_NAME" } else { fail "$TEST_NAME" }
37
38 # The never probe won't get hit, but including 'print_ubacktrace()'
39 # will enable task_finder and vma tracking.
40 set TEST_NAME "ptrace (never)"
41 set script {probe never{print_ubacktrace()}}
42 set cmd {stap -e $script -c $subcmd}
43 set output_found 0
44 eval spawn $cmd
45 expect {
46 -timeout 180
47 -re {^read\(\d+, .+\) = \d+\r\n} {
48 set output_found 1
49 exp_continue
50 }
51 }
52 catch close
53 wait
54 if { $output_found } { pass "$TEST_NAME" } else { fail "$TEST_NAME" }