From f249edcd5f135278e15ccafb497be520c325a5e4 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 5 Aug 2009 16:55:24 -0700 Subject: Don't spawn uprobes tests with sudo Using spawn with sudo doesn't work well, because the password prompt won't go to the correct TTY. The only reason that the uprobes tests needed to do this is so uprobes.ko could be built as root. Now instead, I've added a pre-check that will directly call the uprobes make with sudo (via the as_root proc). * testsuite/lib/systemtap.exp (uprobes_p): Check and build uprobes.ko. * testsuite/systemtap.base/uprobes.exp: Use uprobes_p; don't spawn sudo. * testsuite/systemtap.base/bz6850.exp: Ditto. * testsuite/systemtap.base/bz10078.exp: Ditto. * testsuite/systemtap.base/bz6905.exp: sudo isn't needed for -p2. --- testsuite/lib/systemtap.exp | 23 +++++++++++++++++++++++ testsuite/systemtap.base/bz10078.exp | 6 ++---- testsuite/systemtap.base/bz6850.exp | 6 ++---- testsuite/systemtap.base/bz6905.exp | 3 +-- testsuite/systemtap.base/uprobes.exp | 6 ++---- 5 files changed, 30 insertions(+), 14 deletions(-) diff --git a/testsuite/lib/systemtap.exp b/testsuite/lib/systemtap.exp index 76fd57bd..82afb6b7 100644 --- a/testsuite/lib/systemtap.exp +++ b/testsuite/lib/systemtap.exp @@ -26,6 +26,29 @@ proc utrace_p {} { } +proc uprobes_p {} { + global env + if {! [utrace_p]} { + return 0 + } + set uprobes $env(SYSTEMTAP_RUNTIME)/uprobes + set res [catch "exec make -q -C $uprobes uprobes.ko" output] + if {$res != 0} { + if {! [installtest_p]} { + # build as user in the source tree + verbose -log "exec make -C $uprobes" + set res [catch "exec make -C $uprobes" output] + verbose -log "OUT $output" + verbose -log "RC $res" + } else { + # build as root in the installed location + set res [as_root "make -C $uprobes"] + } + } + if {$res == 0} { return 1 } else { return 0 } +} + + proc print_systemtap_version {} { set version [exec /bin/uname -r] set location "/boot/vmlinux-$version" diff --git a/testsuite/systemtap.base/bz10078.exp b/testsuite/systemtap.base/bz10078.exp index cad3a3a8..8928a078 100644 --- a/testsuite/systemtap.base/bz10078.exp +++ b/testsuite/systemtap.base/bz10078.exp @@ -3,7 +3,7 @@ set test bz10078 catch {exec gcc -g -o $test $srcdir/$subdir/$test.c} err if {$err == "" && [file exists $test]} then { pass "$test compile" } else { fail "$test compile" } -if {![utrace_p]} { +if {![uprobes_p]} { catch {exec rm -f $test} untested "$test -p4" untested "$test -p5" @@ -19,9 +19,7 @@ if {! [installtest_p]} { return } -# Pick up the stap being tested. -set stapexe [exec /usr/bin/which stap] -spawn sudo $stapexe $srcdir/$subdir/$test.stp -c ./$test +spawn stap $srcdir/$subdir/$test.stp -c ./$test set ok 0 expect { -timeout 60 diff --git a/testsuite/systemtap.base/bz6850.exp b/testsuite/systemtap.base/bz6850.exp index 32ecdaf5..1b88ac10 100644 --- a/testsuite/systemtap.base/bz6850.exp +++ b/testsuite/systemtap.base/bz6850.exp @@ -3,7 +3,7 @@ set test bz6850 catch {exec gcc -g -o bz6850 $srcdir/$subdir/bz6850.c} err if {$err == "" && [file exists bz6850]} then { pass "$test compile" } else { fail "$test compile" } -if {![utrace_p]} { +if {![uprobes_p]} { catch {exec rm -f $test} untested "$test -p4" untested "$test -p5" @@ -19,9 +19,7 @@ if {! [installtest_p]} { return } -# Pick up the stap being tested. -set stapexe [exec /usr/bin/which stap] -spawn sudo $stapexe $srcdir/$subdir/bz6850.stp -c ./bz6850 +spawn stap $srcdir/$subdir/bz6850.stp -c ./bz6850 expect { -timeout 60 -re {[^\r\n]*called\r\n} { exp_continue } diff --git a/testsuite/systemtap.base/bz6905.exp b/testsuite/systemtap.base/bz6905.exp index 8119159e..20a846cc 100644 --- a/testsuite/systemtap.base/bz6905.exp +++ b/testsuite/systemtap.base/bz6905.exp @@ -9,8 +9,7 @@ if {![utrace_p]} { return } -set stapexe [exec /usr/bin/which stap] -spawn sudo $stapexe -p2 $srcdir/$subdir/$test.stp +spawn stap -p2 $srcdir/$subdir/$test.stp set hint 0 set probes 0 expect { diff --git a/testsuite/systemtap.base/uprobes.exp b/testsuite/systemtap.base/uprobes.exp index 6344cbf0..bdd620b3 100644 --- a/testsuite/systemtap.base/uprobes.exp +++ b/testsuite/systemtap.base/uprobes.exp @@ -18,7 +18,7 @@ if [file exists $path] then { pass "$test prep" } else { fail "$test prep" } catch {exec gcc -g -o jennie jennie.c} err if {$err == "" && [file exists jennie]} then { pass "$test compile" } else { fail "$test compile" } -if {![utrace_p]} { +if {! [uprobes_p]} { untested "$test -p4"; untested "$test -p5" catch {exec rm -f jennie.c jennie} return @@ -33,9 +33,7 @@ if {! [installtest_p]} { return } -# Pick up the stap being tested. -set stapexe [exec /usr/bin/which stap] -spawn sudo $stapexe $srcdir/$subdir/uprobes.stp -w -c "./jennie 1 2 3 4" +spawn stap $srcdir/$subdir/uprobes.stp -w -c "./jennie 1 2 3 4" set ok 0 expect { -re {^process[^\r\n]*jennie[^\r\n]*main[^\r\n]*argc=0x[1-5][^\r\n]*\r\n} { incr ok; exp_continue } -- cgit From 68d47ee749911aa9babdfe37efd85db115e316be Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 5 Aug 2009 17:56:44 -0700 Subject: Remove as_root calls from the printf testsuite Once upon a time, we would use sudo staprun, and so output files from "-o" were owned by root. For a while now we've used a setuid staprun instead, and the output files are created by stapio as the user. Thus, we don't need as_root to remove those files anymore. * testsuite/systemtap.printf/end1b.exp: Clean up without as_root. * testsuite/systemtap.printf/mixed_outb.exp: Ditto. * testsuite/systemtap.printf/out1b.exp: Ditto. * testsuite/systemtap.printf/out2b.exp: Ditto. * testsuite/systemtap.printf/out3b.exp: Ditto. --- testsuite/systemtap.printf/end1b.exp | 8 ++++---- testsuite/systemtap.printf/mixed_outb.exp | 8 ++++---- testsuite/systemtap.printf/out1b.exp | 8 ++++---- testsuite/systemtap.printf/out2b.exp | 8 ++++---- testsuite/systemtap.printf/out3b.exp | 8 ++++---- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/testsuite/systemtap.printf/end1b.exp b/testsuite/systemtap.printf/end1b.exp index 46cdc9c7..c3c9d4cf 100644 --- a/testsuite/systemtap.printf/end1b.exp +++ b/testsuite/systemtap.printf/end1b.exp @@ -18,24 +18,24 @@ if {[catch {exec mktemp -t staptestXXXXXX} tmpfile]} { if {[catch {exec stap -b -o $tmpfile $test} res]} { puts "stap failed: $res" fail $TEST_NAME - as_root "/bin/rm -f [glob ${tmpfile}*]" + eval [list exec /bin/rm -f] [glob "${tmpfile}*"] return } if {[catch {eval [list exec $stap_merge_path -o $tmpfile] [glob "${tmpfile}_*"]} res]} { puts "merge failed: $res" fail $TEST_NAME - as_root "/bin/rm -f [glob ${tmpfile}*]" + eval [list exec /bin/rm -f] [glob "${tmpfile}*"] return } if {[catch {exec cmp $tmpfile $srcdir/$subdir/large_output} res]} { puts "$res" fail $TEST_NAME - as_root "/bin/rm -f [glob ${tmpfile}*]" + eval [list exec /bin/rm -f] [glob "${tmpfile}*"] return } pass $TEST_NAME -as_root "/bin/rm -f [glob ${tmpfile}*]" +eval [list exec /bin/rm -f] [glob "${tmpfile}*"] diff --git a/testsuite/systemtap.printf/mixed_outb.exp b/testsuite/systemtap.printf/mixed_outb.exp index c15520b1..1225f9ce 100644 --- a/testsuite/systemtap.printf/mixed_outb.exp +++ b/testsuite/systemtap.printf/mixed_outb.exp @@ -18,24 +18,24 @@ if {[catch {exec mktemp -t staptestXXXXXX} tmpfile]} { if {[catch {exec stap -DMAXACTION=100000 -b -o $tmpfile $test} res]} { fail $TEST_NAME puts "stap failed: $res" - as_root "/bin/rm -f [glob ${tmpfile}*]" + eval [list exec /bin/rm -f] [glob "${tmpfile}*"] return } if {[catch {eval [list exec $stap_merge_path -o $tmpfile] [glob "${tmpfile}_*"]} res]} { puts "merge failed: $res" fail $TEST_NAME - as_root "/bin/rm -f [glob ${tmpfile}*]" + eval [list exec /bin/rm -f] [glob "${tmpfile}*"] return } if {[catch {exec cmp $tmpfile $srcdir/$subdir/large_output} res]} { puts "$res" fail $TEST_NAME - as_root "/bin/rm -f [glob ${tmpfile}*]" + eval [list exec /bin/rm -f] [glob "${tmpfile}*"] return } pass $TEST_NAME -as_root "/bin/rm -f [glob ${tmpfile}*]" +eval [list exec /bin/rm -f] [glob "${tmpfile}*"] diff --git a/testsuite/systemtap.printf/out1b.exp b/testsuite/systemtap.printf/out1b.exp index 24efbf4c..d09dadef 100644 --- a/testsuite/systemtap.printf/out1b.exp +++ b/testsuite/systemtap.printf/out1b.exp @@ -18,24 +18,24 @@ if {[catch {exec mktemp -t staptestXXXXXX} tmpfile]} { if {[catch {exec stap -b -o $tmpfile $test} res]} { fail $TEST_NAME puts "stap failed: $res" - as_root "/bin/rm -f [glob ${tmpfile}*]" + eval [list exec /bin/rm -f] [glob "${tmpfile}*"] return } if {[catch {eval [list exec $stap_merge_path -o $tmpfile] [glob "${tmpfile}_*"]} res]} { puts "merge failed: $res" fail $TEST_NAME - as_root "/bin/rm -f [glob ${tmpfile}*]" + eval [list exec /bin/rm -f] [glob "${tmpfile}*"] return } if {[catch {exec cmp $tmpfile $srcdir/$subdir/large_output} res]} { puts "$res" fail $TEST_NAME - as_root "/bin/rm -f [glob ${tmpfile}*]" + eval [list exec /bin/rm -f] [glob "${tmpfile}*"] return } pass $TEST_NAME -as_root "/bin/rm -f [glob ${tmpfile}*]" +eval [list exec /bin/rm -f] [glob "${tmpfile}*"] diff --git a/testsuite/systemtap.printf/out2b.exp b/testsuite/systemtap.printf/out2b.exp index 70a98ea2..bb732c42 100644 --- a/testsuite/systemtap.printf/out2b.exp +++ b/testsuite/systemtap.printf/out2b.exp @@ -18,24 +18,24 @@ if {[catch {exec mktemp -t staptestXXXXXX} tmpfile]} { if {[catch {exec stap -b -o $tmpfile $test} res]} { fail $TEST_NAME puts "stap failed: $res" - as_root "/bin/rm -f [glob ${tmpfile}*]" + eval [list exec /bin/rm -f] [glob "${tmpfile}*"] return } if {[catch {eval [list exec $stap_merge_path -o $tmpfile] [glob "${tmpfile}_*"]} res]} { puts "merge failed: $res" fail $TEST_NAME - as_root "/bin/rm -f [glob ${tmpfile}*]" + eval [list exec /bin/rm -f] [glob "${tmpfile}*"] return } if {[catch {exec cmp $tmpfile $srcdir/$subdir/large_output} res]} { puts "$res" fail $TEST_NAME - as_root "/bin/rm -f [glob ${tmpfile}*]" + eval [list exec /bin/rm -f] [glob "${tmpfile}*"] return } pass $TEST_NAME -as_root "/bin/rm -f [glob ${tmpfile}*]" +eval [list exec /bin/rm -f] [glob "${tmpfile}*"] diff --git a/testsuite/systemtap.printf/out3b.exp b/testsuite/systemtap.printf/out3b.exp index d49625e9..5d82512a 100644 --- a/testsuite/systemtap.printf/out3b.exp +++ b/testsuite/systemtap.printf/out3b.exp @@ -18,24 +18,24 @@ if {[catch {exec mktemp -t staptestXXXXXX} tmpfile]} { if {[catch {exec stap -DMAXACTION=100000 -b -o $tmpfile $test} res]} { fail $TEST_NAME puts "stap failed: $res" - as_root "/bin/rm -f [glob ${tmpfile}*]" + eval [list exec /bin/rm -f] [glob "${tmpfile}*"] return } if {[catch {eval [list exec $stap_merge_path -o $tmpfile] [glob "${tmpfile}_*"]} res]} { puts "merge failed: $res" fail $TEST_NAME - as_root "/bin/rm -f [glob ${tmpfile}*]" + eval [list exec /bin/rm -f] [glob "${tmpfile}*"] return } if {[catch {exec cmp $tmpfile $srcdir/$subdir/large_output} res]} { puts "$res" fail $TEST_NAME - as_root "/bin/rm -f [glob ${tmpfile}*]" + eval [list exec /bin/rm -f] [glob "${tmpfile}*"] return } pass $TEST_NAME -as_root "/bin/rm -f [glob ${tmpfile}*]" +eval [list exec /bin/rm -f] [glob "${tmpfile}*"] -- cgit From 3d9889977397098d14c5be50f1dfef1c3eeb508f Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 6 Aug 2009 10:41:46 +0200 Subject: PR10491 Don't assign to REG_IP if it isn't an lvalue (s390 and ia64). To fixup REG_IP to show the correct value after a [ku]probe trap we assigned the address of the actual instruction pointer of the probed instruction. That doesn't work on architectures, s390 and ia64, where REG_IP is not a simple lvalue. Just don't try to fixup the address in those cases. If this isn't enough, the uprobe_stmt_num.exp testcase will point this out. * runtime/regs.h: Define REG_IP_LVALUE for x86_64, i386, powerpc64 and arm. * tapsets.cxx (dwarf_derived_probe_group::emit_module_decls): Only fixup REG_IP when REG_IP_LVALUE is defined. (uprobe_derived_probe_group::emit_module_decls): Likewise. (kprobe_derived_probe_group::emit_module_decls): Likewise. --- runtime/regs.h | 5 +++++ tapsets.cxx | 30 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/runtime/regs.h b/runtime/regs.h index 123d7601..d80cdf0a 100644 --- a/runtime/regs.h +++ b/runtime/regs.h @@ -13,17 +13,20 @@ #if defined (STAPCONF_X86_UNIREGS) && (defined (__x86_64__) || defined (__i386__)) #define REG_IP(regs) regs->ip +#define REG_IP_LVALUE 1 #define REG_SP(regs) regs->sp #define REG_FP(regs) regs->bp #elif defined (__x86_64__) #define REG_IP(regs) regs->rip +#define REG_IP_LVALUE 1 #define REG_SP(regs) regs->rsp #elif defined (__i386__) #define REG_IP(regs) regs->eip +#define REG_IP_LVALUE 1 #define REG_SP(regs) regs->esp #define REG_FP(regs) regs->ebp @@ -34,12 +37,14 @@ #elif defined (__powerpc64__) #define REG_IP(regs) regs->nip +#define REG_IP_LVALUE 1 #define REG_SP(regs) regs->gpr[1] #define REG_LINK(regs) regs->link #elif defined (__arm__) #define REG_IP(regs) regs->ARM_pc +#define REG_IP_LVALUE 1 #define REG_SP(regs) regs->ARM_sp #define REG_LINK(regs) regs->ARM_lr diff --git a/tapsets.cxx b/tapsets.cxx index b1ca2998..66cb2383 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -3030,6 +3030,8 @@ dwarf_derived_probe_group::emit_module_decls (systemtap_session& s) // Make it look like the IP is set as it wouldn't have been replaced // by a breakpoint instruction when calling real probe handler. Reset // IP regs on return, so we don't confuse kprobes. PR10458 + // But only for architectures where REG_IP is a proper lvalue. PR10491 + s.op->newline() << "#ifdef REG_IP_LVALUE"; s.op->newline() << "{"; s.op->indent(1); s.op->newline() << "unsigned long kprobes_ip = REG_IP(c->regs);"; @@ -3037,6 +3039,9 @@ dwarf_derived_probe_group::emit_module_decls (systemtap_session& s) s.op->newline() << "(*sdp->ph) (c);"; s.op->newline() << "REG_IP(regs) = kprobes_ip;"; s.op->newline(-1) << "}"; + s.op->newline() << "#else"; + s.op->newline() << "(*sdp->ph) (c);"; + s.op->newline() << "#endif"; common_probe_entryfn_epilogue (s.op); s.op->newline() << "return 0;"; @@ -3064,6 +3069,8 @@ dwarf_derived_probe_group::emit_module_decls (systemtap_session& s) // Make it look like the IP is set as it wouldn't have been replaced // by a breakpoint instruction when calling real probe handler. Reset // IP regs on return, so we don't confuse kprobes. PR10458 + // But only for architectures where REG_IP is a proper lvalue. PR10491 + s.op->newline() << "#ifdef REG_IP_LVALUE"; s.op->newline() << "{"; s.op->indent(1); s.op->newline() << "unsigned long kprobes_ip = REG_IP(c->regs);"; @@ -3071,6 +3078,9 @@ dwarf_derived_probe_group::emit_module_decls (systemtap_session& s) s.op->newline() << "(*sdp->ph) (c);"; s.op->newline() << "REG_IP(regs) = kprobes_ip;"; s.op->newline(-1) << "}"; + s.op->newline() << "#else"; + s.op->newline() << "(*sdp->ph) (c);"; + s.op->newline() << "#endif"; common_probe_entryfn_epilogue (s.op); s.op->newline() << "return 0;"; @@ -4447,6 +4457,8 @@ uprobe_derived_probe_group::emit_module_decls (systemtap_session& s) // Make it look like the IP is set as it would in the actual user // task when calling real probe handler. Reset IP regs on return, so // we don't confuse uprobes. PR10458 + // But only for architectures where REG_IP is a proper lvalue. PR10491 + s.op->newline() << "#ifdef REG_IP_LVALUE"; s.op->newline() << "{"; s.op->indent(1); s.op->newline() << "unsigned long uprobes_ip = REG_IP(c->regs);"; @@ -4454,6 +4466,9 @@ uprobe_derived_probe_group::emit_module_decls (systemtap_session& s) s.op->newline() << "(*sups->ph) (c);"; s.op->newline() << "REG_IP(regs) = uprobes_ip;"; s.op->newline(-1) << "}"; + s.op->newline() << "#else"; + s.op->newline() << "(*sdp->ph) (c);"; + s.op->newline() << "#endif"; common_probe_entryfn_epilogue (s.op); s.op->newline(-1) << "}"; @@ -4470,6 +4485,8 @@ uprobe_derived_probe_group::emit_module_decls (systemtap_session& s) // Make it look like the IP is set as it would in the actual user // task when calling real probe handler. Reset IP regs on return, so // we don't confuse uprobes. PR10458 + // But only for architectures where REG_IP is a proper lvalue. PR10491 + s.op->newline() << "#ifdef REG_IP_LVALUE"; s.op->newline() << "{"; s.op->indent(1); s.op->newline() << "unsigned long uprobes_ip = REG_IP(c->regs);"; @@ -4477,6 +4494,9 @@ uprobe_derived_probe_group::emit_module_decls (systemtap_session& s) s.op->newline() << "(*sups->ph) (c);"; s.op->newline() << "REG_IP(regs) = uprobes_ip;"; s.op->newline(-1) << "}"; + s.op->newline() << "#else"; + s.op->newline() << "(*sdp->ph) (c);"; + s.op->newline() << "#endif"; common_probe_entryfn_epilogue (s.op); s.op->newline(-1) << "}"; @@ -4970,6 +4990,8 @@ kprobe_derived_probe_group::emit_module_decls (systemtap_session& s) // Make it look like the IP is set as it wouldn't have been replaced // by a breakpoint instruction when calling real probe handler. Reset // IP regs on return, so we don't confuse kprobes. PR10458 + // But only for architectures where REG_IP is a proper lvalue. PR10491 + s.op->newline() << "#ifdef REG_IP_LVALUE"; s.op->newline() << "{"; s.op->indent(1); s.op->newline() << "unsigned long kprobes_ip = REG_IP(c->regs);"; @@ -4977,6 +4999,9 @@ kprobe_derived_probe_group::emit_module_decls (systemtap_session& s) s.op->newline() << "(*sdp->ph) (c);"; s.op->newline() << "REG_IP(regs) = kprobes_ip;"; s.op->newline(-1) << "}"; + s.op->newline() << "#else"; + s.op->newline() << "(*sdp->ph) (c);"; + s.op->newline() << "#endif"; common_probe_entryfn_epilogue (s.op); s.op->newline() << "return 0;"; @@ -5004,6 +5029,8 @@ kprobe_derived_probe_group::emit_module_decls (systemtap_session& s) // Make it look like the IP is set as it wouldn't have been replaced // by a breakpoint instruction when calling real probe handler. Reset // IP regs on return, so we don't confuse kprobes. PR10458 + // But only for architectures where REG_IP is a proper lvalue. PR10491 + s.op->newline() << "#ifdef REG_IP_LVALUE"; s.op->newline() << "{"; s.op->indent(1); s.op->newline() << "unsigned long kprobes_ip = REG_IP(c->regs);"; @@ -5011,6 +5038,9 @@ kprobe_derived_probe_group::emit_module_decls (systemtap_session& s) s.op->newline() << "(*sdp->ph) (c);"; s.op->newline() << "REG_IP(regs) = kprobes_ip;"; s.op->newline(-1) << "}"; + s.op->newline() << "#else"; + s.op->newline() << "(*sdp->ph) (c);"; + s.op->newline() << "#endif"; common_probe_entryfn_epilogue (s.op); s.op->newline() << "return 0;"; -- cgit From 9b988eff8c29377e658606a85f371ceb9acfef7d Mon Sep 17 00:00:00 2001 From: Wenji Huang Date: Wed, 5 Aug 2009 22:58:46 -0400 Subject: PR10294: support wider range for statement probe * dwflpp.cxx (iterate_over_srcfile_lines): Add pattern parameter. * dwflpp.h (iterate_over_srcfile_lines): Ditto. * testsuite/systemtap.base/bz10294.c: Test case. * testsuite/systemtap.base/bz10294.stp: Ditto. * testsuite/systemtap.base/bz6905.exp: Deleted. * testsuite/systemtap.base/statement.exp: Merge bz10294 with bz6905. --- dwflpp.cxx | 8 +++++-- dwflpp.h | 1 + tapsets.cxx | 4 ++-- testsuite/systemtap.base/bz10294.c | 21 +++++++++++++++++++ testsuite/systemtap.base/bz10294.stp | 4 ++++ testsuite/systemtap.base/bz6905.exp | 24 --------------------- testsuite/systemtap.base/statement.exp | 38 ++++++++++++++++++++++++++++++++++ 7 files changed, 72 insertions(+), 28 deletions(-) create mode 100644 testsuite/systemtap.base/bz10294.c create mode 100644 testsuite/systemtap.base/bz10294.stp delete mode 100644 testsuite/systemtap.base/bz6905.exp create mode 100644 testsuite/systemtap.base/statement.exp diff --git a/dwflpp.cxx b/dwflpp.cxx index 6ede1d68..ff62265f 100644 --- a/dwflpp.cxx +++ b/dwflpp.cxx @@ -784,6 +784,7 @@ dwflpp::iterate_over_srcfile_lines (char const * srcfile, enum line_t line_type, void (* callback) (const dwarf_line_t& line, void * arg), + const std::string& func_pattern, void *data) { Dwarf_Line **srcsp = NULL; @@ -811,7 +812,10 @@ dwflpp::iterate_over_srcfile_lines (char const * srcfile, else if (line_type == RANGE) { /* correct lineno */ int start_lineno; - function_line (&start_lineno); + if (name_has_wildcard(func_pattern)) /* PR10294: wider range like statement("*@foo.c") */ + start_lineno = lineno; + else + function_line (&start_lineno); lineno = lineno < start_lineno ? start_lineno : lineno; if (lineno > lines[1]) { /* invalid line range */ stringstream advice; @@ -849,7 +853,7 @@ dwflpp::iterate_over_srcfile_lines (char const * srcfile, if (lineno != l || line_probed.second == false || nsrcs > 1) continue; dwarf_lineaddr (srcsp [0], &line_addr); - if (dwarf_haspc (function, line_addr) != 1) + if (!function_name_matches(func_pattern) && dwarf_haspc (function, line_addr) != 1) break; } diff --git a/dwflpp.h b/dwflpp.h index 3cada4f8..f6305bcf 100644 --- a/dwflpp.h +++ b/dwflpp.h @@ -213,6 +213,7 @@ struct dwflpp enum line_t line_type, void (* callback) (const dwarf_line_t& line, void * arg), + const std::string& func_pattern, void *data); void iterate_over_labels (Dwarf_Die *begin_die, diff --git a/tapsets.cxx b/tapsets.cxx index 66cb2383..c953dd78 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -1452,7 +1452,7 @@ query_cu (Dwarf_Die * cudie, void * arg) for (set::const_iterator i = q->filtered_srcfiles.begin(); i != q->filtered_srcfiles.end(); ++i) q->dw.iterate_over_srcfile_lines (*i, q->line, q->has_statement_str, - q->line_type, query_srcfile_label, q); + q->line_type, query_srcfile_label, q->function, q); } else if ((q->has_statement_str || q->has_function_str) && (q->spec_type == function_file_and_line)) @@ -1462,7 +1462,7 @@ query_cu (Dwarf_Die * cudie, void * arg) for (set::const_iterator i = q->filtered_srcfiles.begin(); i != q->filtered_srcfiles.end(); ++i) q->dw.iterate_over_srcfile_lines (*i, q->line, q->has_statement_str, - q->line_type, query_srcfile_line, q); + q->line_type, query_srcfile_line, q->function, q); } else { diff --git a/testsuite/systemtap.base/bz10294.c b/testsuite/systemtap.base/bz10294.c new file mode 100644 index 00000000..1ea9a0d9 --- /dev/null +++ b/testsuite/systemtap.base/bz10294.c @@ -0,0 +1,21 @@ +int func_a(int a) +{ + a = a + 1; + return a; +} + + +int func_b(int b) +{ + b = b + 2; + return b; +} + +int main() +{ + int a; + + a = func_a(1); + a = a + func_b(a); + return 0; +} diff --git a/testsuite/systemtap.base/bz10294.stp b/testsuite/systemtap.base/bz10294.stp new file mode 100644 index 00000000..0a18c45f --- /dev/null +++ b/testsuite/systemtap.base/bz10294.stp @@ -0,0 +1,4 @@ +#! stap -p2 +probe process("./bz10294").statement("*@bz10294.c:10-10") { + printf("ok") +} diff --git a/testsuite/systemtap.base/bz6905.exp b/testsuite/systemtap.base/bz6905.exp deleted file mode 100644 index 20a846cc..00000000 --- a/testsuite/systemtap.base/bz6905.exp +++ /dev/null @@ -1,24 +0,0 @@ -set test bz6905 - -catch {exec gcc -g -o $test $srcdir/$subdir/$test.c} err -if {$err == "" && [file exists $test]} then { pass "$test compile" } else { fail "$test compile" } - -if {![utrace_p]} { - catch {exec rm -f $test} - untested "$test -p2" - return -} - -spawn stap -p2 $srcdir/$subdir/$test.stp -set hint 0 -set probes 0 -expect { - -timeout 60 - -re "# probes" { incr hint; exp_continue } - -re {process.*statement.*} { incr probes; exp_continue } - timeout { fail "$test (timeout)" } - eof { } -} -wait -if { $hint == 1 && $probes > 0 } then { pass "$test -p2" } else { fail "$test -p2 ($probes)" } -exec rm -f $test diff --git a/testsuite/systemtap.base/statement.exp b/testsuite/systemtap.base/statement.exp new file mode 100644 index 00000000..d8fce8d8 --- /dev/null +++ b/testsuite/systemtap.base/statement.exp @@ -0,0 +1,38 @@ +set test bz6905 + +catch {exec gcc -g -o $test $srcdir/$subdir/$test.c} err +if {$err == "" && [file exists $test]} then { pass "$test compile" } else { fail "$test compile" } + +spawn stap -p2 $srcdir/$subdir/$test.stp +set hint 0 +set probes 0 +expect { + -timeout 60 + -re "# probes" { incr hint; exp_continue } + -re {process.*statement.*} { incr probes; exp_continue } + timeout { fail "$test (timeout)" } + eof { } +} +wait +if { $hint == 1 && $probes > 0 } then { pass "$test -p2" } else { fail "$test -p2 ($probes)" } +exec rm -f $test + +set test bz10294 + +catch {exec gcc -g -o $test $srcdir/$subdir/$test.c} err +if {$err == "" && [file exists $test]} then { pass "$test compile" } else { fail "$test compile" } + +spawn stap -p2 $srcdir/$subdir/$test.stp +set hint 0 +set probes 0 +expect { + -timeout 60 + -re "# probes" { incr hint; exp_continue } + -re {process.*statement.*} { incr probes; exp_continue } + timeout { fail "$test (timeout)" } + eof { } +} +wait +if { $hint == 1 && $probes == 1 } then { pass "$test -p2" } else { fail "$test -p2 ($probes)" } +exec rm -f $test + -- cgit From 70f2bd1fc3db8e2b555234d45e6bc3856d8afee5 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 6 Aug 2009 17:46:27 +0200 Subject: RH515870 Error message about missing module uprobes when updating. Fix 3>&1 typo. * systemtap.spec: Use 2>&1 to redirect error messages. --- systemtap.spec | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/systemtap.spec b/systemtap.spec index 03e9419c..860e4332 100644 --- a/systemtap.spec +++ b/systemtap.spec @@ -281,13 +281,13 @@ exit 0 %post # Remove any previously-built uprobes.ko materials -(make -C /usr/share/systemtap/runtime/uprobes clean) >/dev/null 3>&1 || true -(/sbin/rmmod uprobes) >/dev/null 3>&1 || true +(make -C /usr/share/systemtap/runtime/uprobes clean) >/dev/null 2>&1 || true +(/sbin/rmmod uprobes) >/dev/null 2>&1 || true %preun # Ditto -(make -C /usr/share/systemtap/runtime/uprobes clean) >/dev/null 3>&1 || true -(/sbin/rmmod uprobes) >/dev/null 3>&1 || true +(make -C /usr/share/systemtap/runtime/uprobes clean) >/dev/null 2>&1 || true +(/sbin/rmmod uprobes) >/dev/null 2>&1 || true %files %defattr(-,root,root) -- cgit From cab97f033153b93d1d26388a25a65052cf36fc8d Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Thu, 6 Aug 2009 14:27:48 -0400 Subject: Fix missing strlen compile error. StapParser.cxx (#include cstring): New. --- grapher/StapParser.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/grapher/StapParser.cxx b/grapher/StapParser.cxx index 693be919..d70c75b6 100644 --- a/grapher/StapParser.cxx +++ b/grapher/StapParser.cxx @@ -3,6 +3,7 @@ #include #include #include +#include namespace systemtap { -- cgit