This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[PATCH] PR23599 Bugfix: the embeddedcode info pass incorrectly skipped unused functions
- From: "Yichun Zhang (agentzh)" <yichun at openresty dot com>
- To: systemtap at sourceware dot org
- Cc: "Yichun Zhang (agentzh)" <yichun at openresty dot com>
- Date: Sat, 15 Sep 2018 18:16:21 -0700
- Subject: [PATCH] PR23599 Bugfix: the embeddedcode info pass incorrectly skipped unused functions
This bug led to kernel module compilation errors when using tapset
functions like usym* in unoptimized stap translation mode (i.e., stap
-u).
---
elaborate.cxx | 4 +++
testsuite/systemtap.base/usym_unoptimize.exp | 34 ++++++++++++++++++++++++++
testsuite/systemtap.base/usym_unoptimize_1.stp | 8 ++++++
testsuite/systemtap.base/usym_unoptimize_2.stp | 8 ++++++
4 files changed, 54 insertions(+)
create mode 100644 testsuite/systemtap.base/usym_unoptimize.exp
create mode 100644 testsuite/systemtap.base/usym_unoptimize_1.stp
create mode 100644 testsuite/systemtap.base/usym_unoptimize_2.stp
diff --git a/elaborate.cxx b/elaborate.cxx
index 4a8af5f88..f34c3c01b 100644
--- a/elaborate.cxx
+++ b/elaborate.cxx
@@ -1736,6 +1736,10 @@ void embeddedcode_info_pass (systemtap_session& s)
embeddedcode_info eci (s);
for (unsigned i=0; i<s.probes.size(); i++)
s.probes[i]->body->visit (& eci);
+
+ for (map<string,functiondecl*>::iterator it = s.functions.begin();
+ it != s.functions.end(); it++)
+ it->second->body->visit (& eci);
}
// ------------------------------------------------------------------------
diff --git a/testsuite/systemtap.base/usym_unoptimize.exp b/testsuite/systemtap.base/usym_unoptimize.exp
new file mode 100644
index 000000000..4c6e075c9
--- /dev/null
+++ b/testsuite/systemtap.base/usym_unoptimize.exp
@@ -0,0 +1,34 @@
+set test "usym_unoptimize"
+set testpath "$srcdir/$subdir"
+
+if {! [installtest_p]} { untested "$test"; return }
+
+# --- TEST 1 ---
+
+set subtest1 "TEST 1: PR23506: using usymname() alone breaks unoptimized stap translation"
+set test_name "$test: $subtest1"
+
+set exit_code [run_cmd_2way "stap -u '$srcdir/$subdir/${test}_1.stp'" out stderr]
+set exp_out "0xdeadbeef
+hey
+"
+is "${test_name}: stdout" $out $exp_out
+is "${test_name}: exit code" $exit_code 0
+if {$stderr ne ""} {
+ send_log "stderr:\n$stderr"
+}
+
+# --- TEST 2 ---
+
+set subtest2 "TEST 2: PR23506: using usymdata() alone breaks unoptimized stap translation"
+set test_name "$test: $subtest2"
+
+set exit_code [run_cmd_2way "stap -u '$srcdir/$subdir/${test}_2.stp'" out stderr]
+set exp_out "0xdeadbeef
+hey
+"
+is "${test_name}: stdout" $out $exp_out
+is "${test_name}: exit code" $exit_code 0
+if {$stderr ne ""} {
+ send_log "stderr:\n$stderr"
+}
diff --git a/testsuite/systemtap.base/usym_unoptimize_1.stp b/testsuite/systemtap.base/usym_unoptimize_1.stp
new file mode 100644
index 000000000..4a91f519f
--- /dev/null
+++ b/testsuite/systemtap.base/usym_unoptimize_1.stp
@@ -0,0 +1,8 @@
+function foo(a) {
+ println(usymname(a));
+}
+
+probe oneshot {
+ foo(0xdeadbeef);
+ println("hey");
+}
diff --git a/testsuite/systemtap.base/usym_unoptimize_2.stp b/testsuite/systemtap.base/usym_unoptimize_2.stp
new file mode 100644
index 000000000..0a3ef06dc
--- /dev/null
+++ b/testsuite/systemtap.base/usym_unoptimize_2.stp
@@ -0,0 +1,8 @@
+function foo(a) {
+ println(usymdata(a));
+}
+
+probe oneshot {
+ foo(0xdeadbeef);
+ println("hey");
+}
--
2.11.0.295.gd7dffce