From 0b113a7a70d617c5e67807c9a897b196db4b3b7a Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Wed, 8 Apr 2009 12:36:37 -0400 Subject: Do not do a partial name comparison for .label. * tapsets.cxx (dwflpp::iterate_over_cu_labels): Compare with strcmp not strncmp. --- testsuite/systemtap.base/labels.exp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/labels.exp b/testsuite/systemtap.base/labels.exp index 2f79a502..f389f08c 100644 --- a/testsuite/systemtap.base/labels.exp +++ b/testsuite/systemtap.base/labels.exp @@ -18,7 +18,7 @@ main () char *c; init_an_int: a = 2; -init_another_int: +init_an_int_again: b = 3; c = \"abc\"; ptr_inited: @@ -32,6 +32,7 @@ set fp [open $label_stppath "w"] puts $fp " probe process(\"labels.x\").function(\"main*@labels.c\").label(\"init_*\") {printf (\"VARS %s\\n\",\$\$vars)} probe process(\"labels.x\").function(\"main*@labels.c\").label(\"ptr_inited\") {printf (\"VARS %s\\n\",\$\$vars)} +probe process(\"labels.x\").function(\"main*@labels.c\").label(\"init_an_int\") {printf (\"init_an_int\\n\")} " close $fp @@ -55,12 +56,12 @@ spawn stap -c $label_exepath $label_stppath wait expect { -timeout 180 - -re {VARS a=0x0 b=0x0.*VARS a=0x2 b=0x0.*VARS a=0x2 b=0x3 c=0x[a-f01-9]} { incr ok; exp_continue } + -re {VARS a=0x0 b=0x0.*init_an_int.*VARS a=0x2 b=0x0.*VARS a=0x2 b=0x3 c=0x[a-f01-9]} { incr ok; exp_continue } timeout { fail "$test (timeout)" } eof { } } -if {$ok == 1} { pass "$test exe .label" } { fail "$test exe .label" } +if {$ok == 1} { pass "$test exe .label" } { fail "$test exe .label $ok" } # address of label in an executable @@ -68,7 +69,7 @@ set label_shpath "[pwd]/label.sh" set fp [open $label_shpath "w"] puts $fp " readelf --debug-dump $label_exepath | awk \" -/init_another_int/ {have_label=1} +/init_an_int_again/ {have_label=1} /DW_AT_low_pc/ {if (have_label) {print \$3;exit;}} \" " @@ -103,7 +104,7 @@ if { $res != "" } { # label in a shared object -spawn stap -p2 -l "process\(\"$label_sopath\"\).function\(\"\*\"\).label\(\"init_another_int\"\)" +spawn stap -p2 -l "process\(\"$label_sopath\"\).function\(\"\*\"\).label\(\"init_an_int_again\"\)" expect { -timeout 180 -re {process.*function} { incr ok; exp_continue } @@ -111,7 +112,7 @@ expect { eof { } } -if {$ok == 1} { pass "$test so .label" } { fail "$test so .label" } +if {$ok == 1} { pass "$test so .label" } { fail "$test so .label $ok" } # address of label in a shared object @@ -119,7 +120,7 @@ set label_shpath "[pwd]/label.sh" set fp [open $label_shpath "w"] puts $fp " readelf --debug-dump $label_sopath | awk \" -/init_another_int/ {have_label=1} +/init_an_int_again/ {have_label=1} /DW_AT_low_pc/ {if (have_label) {print \$3;exit;}} \" " -- cgit From e87251e16921a2d52a35212278e45f0c0af1cc5d Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Wed, 8 Apr 2009 17:19:04 -0400 Subject: Consider function when handling .label * tapsets.cxx(dwflpp::iterate_over_cu_labels): New parameter function. Do wildcard match for function. * testsuite/systemtap.base/labels.exp: Test .label function handling. --- testsuite/systemtap.base/labels.exp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/labels.exp b/testsuite/systemtap.base/labels.exp index f389f08c..268bb320 100644 --- a/testsuite/systemtap.base/labels.exp +++ b/testsuite/systemtap.base/labels.exp @@ -10,9 +10,16 @@ set label_flags "additional_flags=-g" set fp [open $label_srcpath "w"] puts $fp " int +foo () +{ +init_an_int: + return 1; +} +int main () { sleep(5); + foo(); int a = 0; int b = 0; char *c; @@ -30,9 +37,9 @@ close $fp set label_stppath "[pwd]/labels.stp" set fp [open $label_stppath "w"] puts $fp " -probe process(\"labels.x\").function(\"main*@labels.c\").label(\"init_*\") {printf (\"VARS %s\\n\",\$\$vars)} -probe process(\"labels.x\").function(\"main*@labels.c\").label(\"ptr_inited\") {printf (\"VARS %s\\n\",\$\$vars)} -probe process(\"labels.x\").function(\"main*@labels.c\").label(\"init_an_int\") {printf (\"init_an_int\\n\")} +probe process(\"labels.x\").function(\"main@labels.c\").label(\"init_*\") {printf (\"VARS %s\\n\",\$\$vars)} +probe process(\"labels.x\").function(\"main@labels.c\").label(\"ptr_inited\") {printf (\"VARS %s\\n\",\$\$vars)} +probe process(\"labels.x\").function(\"main@labels.c\").label(\"init_an_int\") {printf (\"init_an_int\\n\")} " close $fp -- cgit From 30450585dd7d50224abef863ed8bae0950740fdb Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Wed, 8 Apr 2009 18:11:34 +0200 Subject: Add main executable symbol uprobe to uprobes_lib.exp test. There was nothing wrong with the probe itself, but because the body was empty the compiler optimised away the actual call... * testsuite/systemtap.base/uprobes_lib.exp: Activate main exe probe, expect more output. * testsuite/systemtap.base/uprobes_lib.stp: Also probe main and main_lib. * testsuite/systemtap.base/uprobes_exe.c: Put some code in main_func. * testsuite/systemtap.base/uprobes_lib.c: Likewise for lib_func. --- testsuite/systemtap.base/uprobes_exe.c | 8 +++++--- testsuite/systemtap.base/uprobes_lib.c | 3 ++- testsuite/systemtap.base/uprobes_lib.exp | 13 ++++++++----- testsuite/systemtap.base/uprobes_lib.stp | 10 ++++++++-- 4 files changed, 23 insertions(+), 11 deletions(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/uprobes_exe.c b/testsuite/systemtap.base/uprobes_exe.c index 447434c6..b4811335 100644 --- a/testsuite/systemtap.base/uprobes_exe.c +++ b/testsuite/systemtap.base/uprobes_exe.c @@ -15,13 +15,15 @@ int lib_main (void); void main_func (int foo) { - ; // nothing here... + if (foo > 1) + main_func (foo - 1); + else + lib_main(); } int main (int argc, char *argv[], char *envp[]) { - main_func(1); - lib_main(); + main_func (3); return 0; } diff --git a/testsuite/systemtap.base/uprobes_lib.c b/testsuite/systemtap.base/uprobes_lib.c index c9d70625..25297b6b 100644 --- a/testsuite/systemtap.base/uprobes_lib.c +++ b/testsuite/systemtap.base/uprobes_lib.c @@ -10,7 +10,8 @@ void lib_func (int bar) { - ; // nothing here... + if (bar > 1) + lib_func (bar - 1); } void diff --git a/testsuite/systemtap.base/uprobes_lib.exp b/testsuite/systemtap.base/uprobes_lib.exp index 63ef957a..313c01b6 100644 --- a/testsuite/systemtap.base/uprobes_lib.exp +++ b/testsuite/systemtap.base/uprobes_lib.exp @@ -29,11 +29,14 @@ if { $res != "" } { pass "$test compile $testsrc" } -# XXX main_func needs another/extra test. Disabled for now. -# Enable (and in uprobes_lib.stp) after PR9940 is fixed. -# set ::result_string {main_func -# lib_func} -set ::result_string {lib_func} +set ::result_string {main +main_func +main_func +main_func +lib_main +lib_func +lib_func +lib_func} # Only run on make installcheck if {! [installtest_p]} { untested "$test"; return } diff --git a/testsuite/systemtap.base/uprobes_lib.stp b/testsuite/systemtap.base/uprobes_lib.stp index bc6cc249..459351a4 100644 --- a/testsuite/systemtap.base/uprobes_lib.stp +++ b/testsuite/systemtap.base/uprobes_lib.stp @@ -1,8 +1,14 @@ -/* - Not activated probe... Seems always skipped? +probe process("uprobes_exe").function("main") { + printf("main\n"); +} + probe process("uprobes_exe").function("main_func") { printf("main_func\n"); } -*/ + +probe process("libuprobes_lib.so").function("lib_main") { + printf("lib_main\n"); +} probe process("libuprobes_lib.so").function("lib_func") { printf("lib_func\n"); -- cgit From 18ac9f367a2e63335dfbdc8f5e8a97de4e40dbe4 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 9 Apr 2009 14:26:07 +0200 Subject: Add tests for probefunc(), usymname(), uaddr() versus shared libraries. * testsuite/systemtap.base/uprobes_uname.exp: New file. * testsuite/systemtap.base/uprobes_uname.stp: Likewise. --- testsuite/systemtap.base/uprobes_uname.exp | 46 ++++++++++++++++++++++++++++++ testsuite/systemtap.base/uprobes_uname.stp | 7 +++++ 2 files changed, 53 insertions(+) create mode 100644 testsuite/systemtap.base/uprobes_uname.exp create mode 100644 testsuite/systemtap.base/uprobes_uname.stp (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/uprobes_uname.exp b/testsuite/systemtap.base/uprobes_uname.exp new file mode 100644 index 00000000..65e1ff70 --- /dev/null +++ b/testsuite/systemtap.base/uprobes_uname.exp @@ -0,0 +1,46 @@ +set test "uprobes_uname" +set testpath "$srcdir/$subdir" +set testsrc "$testpath/uprobes_exe.c" +set testsrclib "$testpath/uprobes_lib.c" +set testexe "./uprobes_exe" +set testlibname "uprobes_lib" +set testlibdir "." +set testso "$testlibdir/lib${testlibname}.so" +set testflags "additional_flags=-g additional_flags=-O" +set testlibflags "$testflags additional_flags=-fPIC additional_flags=-shared" +set maintestflags "$testflags additional_flags=-L$testlibdir additional_flags=-l$testlibname additional_flags=-Wl,-rpath,$testlibdir" + +# Compile our test program and library. +set res [target_compile $testsrclib $testso executable $testlibflags] +if { $res != "" } { + verbose "target_compile for $testso failed: $res" 2 + fail "$test compile $testsrclib" + return +} else { + pass "$test compile $testsrclib" +} + +set res [target_compile $testsrc $testexe executable $maintestflags] +if { $res != "" } { + verbose "target_compile failed: $res" 2 + fail "$test compile $testsrc" + return +} else { + pass "$test compile $testsrc" +} + +set ::result_string {exe: main=main +exe: main_func=main_func +exe: main_func=main_func +exe: main_func=main_func +lib: lib_main=lib_main +lib: lib_func=lib_func +lib: lib_func=lib_func +lib: lib_func=lib_func} + +# Only run on make installcheck +if {! [installtest_p]} { untested "$test"; return } +if {! [utrace_p]} { untested $test; return } +stap_run2 $srcdir/$subdir/$test.stp -c $testexe + +#exec rm -f $testexe $testso diff --git a/testsuite/systemtap.base/uprobes_uname.stp b/testsuite/systemtap.base/uprobes_uname.stp new file mode 100644 index 00000000..a44d78d3 --- /dev/null +++ b/testsuite/systemtap.base/uprobes_uname.stp @@ -0,0 +1,7 @@ +probe process("uprobes_exe").function("*") { + printf("exe: %s=%s\n",probefunc(), usymname(uaddr())); +} + +probe process("libuprobes_lib.so").function("*") { + printf("lib: %s=%s\n",probefunc(), usymname(uaddr())); +} -- cgit From 412e8ec0dadbc0010c865f9a285a748b8d08c053 Mon Sep 17 00:00:00 2001 From: Wenji Huang Date: Thu, 9 Apr 2009 23:48:39 -0400 Subject: Make stmt_rel.exp have good compatibility --- testsuite/systemtap.base/stmt_rel.exp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/stmt_rel.exp b/testsuite/systemtap.base/stmt_rel.exp index ec12e484..619c91a5 100644 --- a/testsuite/systemtap.base/stmt_rel.exp +++ b/testsuite/systemtap.base/stmt_rel.exp @@ -33,7 +33,9 @@ expect { eof { } } -if { $ok == 3 } { +# bio_init drifts a bit in different kernels. +# maybe 3, 4 or 15 lines in it. +if { $ok >= 3 } { pass "$test wildcard" } else { fail "$test wildcard ($ok)" -- cgit From 8ca27b7dc58bf14e86cd40ae6246962fa580966d Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Mon, 13 Apr 2009 17:51:58 -0400 Subject: Improve -l output for .label * tapsets.cxx (iterate_over_cu_labels): Treat -l specially so the output of a .label can be improved. * labels.stp: Test -l --- testsuite/systemtap.base/labels.exp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/labels.exp b/testsuite/systemtap.base/labels.exp index 268bb320..88ed4619 100644 --- a/testsuite/systemtap.base/labels.exp +++ b/testsuite/systemtap.base/labels.exp @@ -55,8 +55,23 @@ if { $res != "" } { pass "compiling labels.c -g" } +# list of labels + +spawn stap -l "process(\"$label_exepath\").function(\"*\").label(\"*\")" + +wait +expect { + -timeout 180 + -re {process.*function.*labels.c:5...label..init_an_int.*process.*function.*labels.c:16...label..init_an_int.*process.*function.*labels.c:18...label..init_an_int_again} { incr ok; exp_continue } + timeout { fail "$test (timeout)" } + eof { } +} + +if {$ok == 1} { pass "$test -l .label" } { fail "$test -l .label $ok" } + # label in an executable +set ok 0 verbose -log "spawn stap -c $label_exepath $label_stppath" spawn stap -c $label_exepath $label_stppath -- cgit From b9c2e81cc7a62336ec1daf374cb3411add772ab4 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Mon, 13 Apr 2009 19:50:23 -0700 Subject: PR10067: fix bitfield access * tapsets.cxx (dwflpp::translate_components): Eliminate the extra die-dereference at the end of the loop (a regression from @casts). * runtime/loc2c-runtime.h (store_bitfield): Use the target as the representative type, since the base is always int64_t. Also be a bit more aggressive with masking and parentheses. * testsuite/systemtap.base/bitfield.*: New test for R/W bitfields. --- testsuite/systemtap.base/bitfield.exp | 3 +++ testsuite/systemtap.base/bitfield.stp | 46 +++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 testsuite/systemtap.base/bitfield.exp create mode 100644 testsuite/systemtap.base/bitfield.stp (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/bitfield.exp b/testsuite/systemtap.base/bitfield.exp new file mode 100644 index 00000000..16451369 --- /dev/null +++ b/testsuite/systemtap.base/bitfield.exp @@ -0,0 +1,3 @@ +# test that bitfield r/w works correctly +set test "bitfield" +stap_run $srcdir/$subdir/$test.stp no_load $all_pass_string -g diff --git a/testsuite/systemtap.base/bitfield.stp b/testsuite/systemtap.base/bitfield.stp new file mode 100644 index 00000000..c2ff4929 --- /dev/null +++ b/testsuite/systemtap.base/bitfield.stp @@ -0,0 +1,46 @@ +%{ +#include +static struct tcphdr foo = {0}; +%} + +function get_ptr:long() %{ THIS->__retvalue = (long)&foo; /* pure */ %} +function get_ack:long() %{ THIS->__retvalue = foo.ack; /* pure */ %} +function get_urg:long() %{ THIS->__retvalue = foo.urg; /* pure */ %} + +function check:long(ack:long, urg:long) { + ptr = get_ptr() + + /* set the bits with cast */ + @cast(ptr, "tcphdr")->ack = ack + @cast(ptr, "tcphdr")->urg = urg + + /* check that reading with embedded-C is ok */ + real_ack = get_ack() + real_urg = get_urg() + errors = (ack != real_ack) + (urg != real_urg) + + /* check that reading with a cast is ok */ + cast_ack = @cast(ptr, "tcphdr")->ack + cast_urg = @cast(ptr, "tcphdr")->urg + errors += (ack != cast_ack) + (urg != cast_urg) + + if (errors) + printf("bitfield had %d errors; expect(%d%d), real(%d%d), cast(%d%d)\n", + errors, ack, urg, real_ack, real_urg, cast_ack, cast_urg) + + return errors +} + +probe begin { + println("systemtap starting probe") + + errors = check(0, 0) + errors += check(0, 1) + errors += check(1, 0) + errors += check(1, 1) + + println("systemtap ending probe") + if (errors == 0) + println("systemtap test success") + exit() +} -- cgit