From f28a8c28ce2ceed97bc4f4a19ffe8880bceb0682 Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Mon, 17 Nov 2008 11:34:50 -0500 Subject: Add static uprobe support (static library variant) --- testsuite/systemtap.base/static_uprobes.exp | 70 +++++++++++++++++++++++++++++ testsuite/systemtap.base/static_uprobes.stp | 17 +++++++ 2 files changed, 87 insertions(+) create mode 100644 testsuite/systemtap.base/static_uprobes.exp create mode 100644 testsuite/systemtap.base/static_uprobes.stp (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/static_uprobes.exp b/testsuite/systemtap.base/static_uprobes.exp new file mode 100644 index 00000000..75e8fd21 --- /dev/null +++ b/testsuite/systemtap.base/static_uprobes.exp @@ -0,0 +1,70 @@ +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 +#include \"sduprobes.h\" + +foo () +{ + STAP_PROBE(tstlabel,label1); +} + +bar (int i) +{ + if (i == 0) + i = 1000; + STAP_PROBE1(tstlabel,label2,i); +} + +baz (int i, char* s) +{ + if (i == 0) + i = 1000; + STAP_PROBE2(tstlabel,label3,i,s); +} + +buz () +{ +} + +main () +{ + sleep(5); + STAP_PROBE_START(); + _stap_probe_start (); // in lieu of setting SYSTEM_SDT + foo(); + bar(2); + baz(3,\"abc\"); +} +" +close $fp + +set res [target_compile $sup_srcpath $sup_exepath executable $sup_flags] +if { $res != "" } { + verbose "target_compile failed: $res" 2 + fail "unable to compile $sup_srcpath" + return +} else { + pass "compiling $sup_srcpath" +} + +set ok 0 +set env(SYSTEMTAP_SDT) 1 +spawn stap -c $sup_exepath $srcdir/$subdir/static_uprobes.stp +expect { + -timeout 180 + -re {In label1 probe} { incr ok; exp_continue } + -re {In label2 probe 0x2} { incr ok; exp_continue } + -re {In label3 probe 0x3 0x[0-9a-f][0-9a-f]} { incr ok; exp_continue } + timeout { fail "$test (timeout)" } + eof { } +} +wait + +if {$ok == 3} { pass "$test" } { fail "$test (Got $ok Expected 3)" } diff --git a/testsuite/systemtap.base/static_uprobes.stp b/testsuite/systemtap.base/static_uprobes.stp new file mode 100644 index 00000000..25e64a37 --- /dev/null +++ b/testsuite/systemtap.base/static_uprobes.stp @@ -0,0 +1,17 @@ +probe process("tstlabel.x").mark("label1") +{ + probe_str=user_string($probe) + printf("In %s probe\n", probe_str) +} + +probe process("tstlabel.x").mark("label2") +{ + probe_str=user_string($probe) + printf("In %s probe %#x\n", probe_str, $arg1) +} + +probe process("tstlabel.x").mark("label3") +{ + probe_str=user_string($probe) + printf("In %s probe %#x %#x\n", probe_str, $arg1, $arg2) +} -- cgit