set test "sduprobes" if {![installtest_p]} {untested $test; return} # Compile a C program to use as the user-space probing target set sup_srcpath "[pwd]/static_uprobes.c" set sup_exepath "[pwd]/static_uprobes.x" set sup_flags "additional_flags=-iquote$env(SYSTEMTAP_RUNTIME) additional_flags=-L$env(CRASH_LIBDIR) additional_flags=-lsduprobes" set fp [open $sup_srcpath "w"] puts $fp " #include #define USE_STAP_PROBE 1 #include \"static_uprobes.h\" foo () { STAP_PROBE(static_uprobes,test_probe_1); } bar (int i) { if (i == 0) i = 1000; STAP_PROBE1(static_uprobes,test_probe_2,i); } baz (int i, char* s) { STAP_PROBE1(static_uprobes,test_probe_0,i); if (i == 0) i = 1000; STATIC_UPROBES_TEST_PROBE_3(i,s); } buz (int parm) { } main () { sleep(5); foo(); bar(2); baz(3,\"abc\"); buz(4); } " close $fp # set res [target_compile $sup_srcpath $sup_exepath executable $sup_flags] # if { $res != "" } { # verbose "target_compile failed: $res" 2 # fail "compiling static_uprobes.c" # return # } else { # pass "compiling static_uprobes.c" # } set fp [open "[pwd]/static_uprobes.stp" "w"] puts $fp " probe process(\"static_uprobes.x\").mark(\"test_probe_0\") { printf(\"In test_probe_0 probe %#x\\n\", \$arg1) } probe process(\"static_uprobes.x\").mark(\"test_probe_1\") { printf(\"In test_probe_1 probe\\n\") } probe process(\"static_uprobes.x\").mark(\"test_probe_2\") { printf(\"In test_probe_2 probe %#x\\n\", \$arg1) } probe process(\"static_uprobes.x\").mark(\"test_probe_3\") { printf(\"In test_probe_3 probe %#x %#x\\n\", \$arg1, \$arg2) } " close $fp # Try to find utrace_attach symbol in /proc/kallsyms # copy from utrace_p5.exp set utrace_support_found 0 set path "/proc/kallsyms" if {! [catch {exec grep -q utrace_attach $path} dummy]} { set utrace_support_found 1 } if {$utrace_support_found == 0} { untested "$test"; return } set ok 0 # verbose -log "spawn stap -c $sup_exepath [pwd]/static_uprobes.stp" # spawn stap -c $sup_exepath [pwd]/static_uprobes.stp # expect { # -timeout 180 # -re {In test_probe_1 probe} { incr ok; exp_continue } # -re {In test_probe_2 probe 0x2} { incr ok; exp_continue } # -re {In test_probe_0 probe 0x3} { incr ok; exp_continue } # -re {In test_probe_3 probe 0x3 0x[0-9a-f][0-9a-f]} { incr ok; exp_continue } # timeout { fail "$test (timeout)" } # eof { } # } # if {$ok == 4} { pass "$test" } { fail "$test ($ok)" } set ok 0 # Now do a debuginfo style probe of the above test set fp [open "[pwd]/static_uprobes.sh" "w"] puts $fp " ed $sup_srcpath <