File systemtap-test-dwarfless-probes-on-multiple-static-functions.patch of Package systemtap.2327
From: Hemant Kumar <hemant@linux.vnet.ibm.com>
Date: Mon Apr 20 15:59:23 2015 +0530
Subject: Test dwarfless probes on multiple static functions
Git-commit: 66ac435c7cb7b907642ebfd4daf4d84cdca242a3
References: FATE#319125
Signed-off-by: Tony Jones <tonyj@suse.de>
Test dwarfless probes on multiple static functions
This patch checks how many symbols were resolved instead of probing on
them which won't require us to go till pass 5. It runs the .stp script
till pass 2. This test can be run with:
make check RUNTESTFLAGS=multisym.exp
Signed-off-by: Hemant Kumar <hemant@linux.vnet.ibm.com>
diff --git a/testsuite/systemtap.base/multisym.exp b/testsuite/systemtap.base/multisym.exp
new file mode 100755
index 0000000..b8c96ce
--- /dev/null
+++ b/testsuite/systemtap.base/multisym.exp
@@ -0,0 +1,46 @@
+#!/usr/bin/expect
+
+set test "multisym"
+set testpath "$srcdir/$subdir"
+set script "$testpath/multisym.stp"
+
+# Test that two functions with the same name in the symbol table are
+# both found even when no DWARF information is available
+# As the resolution of the probes occur during pass 2, we don't need to go
+# all the way to pass 5
+# We need the number of resolutions during pass 2.
+
+set cmd [concat stap {-p 2 } $script]
+
+set res [target_compile ${testpath}/${test}_baz.c ${test}_baz.o object ""]
+if { $res != "" } {
+ verbose "target_compile failed: $res" 2
+ fail "unable to compile ${test}_baz.c"
+}
+
+set res [target_compile ${testpath}/${test}_main.c ${test}_main.o object ""]
+if { $res != "" } {
+ verbose "target_compile failed: $res" 2
+ fail "unable to compile ${test}_main.c"
+}
+
+set res [target_compile "${test}_baz.o ${test}_main.o" ${test} executable ""]
+if { $res != "" } {
+ verbose "target_compile failed: $res" 2
+ fail "unable to compile ${test}"
+}
+
+eval spawn $cmd
+set results 0
+expect {
+ -re {process\([a-z\/\"]+\)*} { incr results 1; exp_continue}
+}
+set res [wait -i $spawn_id]
+catch close
+set res [lindex $res 3]
+
+if {$res == 0 && $results == 4} {
+ pass "$test succeeded"
+ } else {
+ fail "$test failed"
+ }
diff --git a/testsuite/systemtap.base/multisym.stp b/testsuite/systemtap.base/multisym.stp
new file mode 100644
index 0000000..be30a15
--- /dev/null
+++ b/testsuite/systemtap.base/multisym.stp
@@ -0,0 +1 @@
+probe process("./multisym").function("foo") { printf ("hit") }
\ No newline at end of file
diff --git a/testsuite/systemtap.base/multisym_baz.c b/testsuite/systemtap.base/multisym_baz.c
new file mode 100644
index 0000000..297514a
--- /dev/null
+++ b/testsuite/systemtap.base/multisym_baz.c
@@ -0,0 +1,11 @@
+static int
+foo (int v)
+{
+ return v + 1;
+}
+
+int
+bar (int i)
+{
+ return foo (i - 1);
+}
diff --git a/testsuite/systemtap.base/multisym_main.c b/testsuite/systemtap.base/multisym_main.c
new file mode 100644
index 0000000..e857385
--- /dev/null
+++ b/testsuite/systemtap.base/multisym_main.c
@@ -0,0 +1,10 @@
+int foo (int v)
+{
+ return bar (v - 1);
+}
+
+int
+main (int argc, char **argv)
+{
+ return foo (argc);
+}