summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2010-03-09 15:32:58 -0800
committerJosh Stone <jistone@redhat.com>2010-03-09 15:32:58 -0800
commitc0f562688ae877000f46058f748a8b986679863e (patch)
treefc543785fd32f7071ba0b7e0952e3cad9736804c
parent985adad37f66be2b1796641360296b7632c7f290 (diff)
downloadsystemtap-steved-c0f562688ae877000f46058f748a8b986679863e.tar.gz
systemtap-steved-c0f562688ae877000f46058f748a8b986679863e.tar.xz
systemtap-steved-c0f562688ae877000f46058f748a8b986679863e.zip
PR11360: Make @defined and -L play nice
The constant-folding is now enabled for s.listing_mode_vars, despite all other optimizations being disabled. This is needed so we can prune any invalid branches that are gated by @defined. * elaborate.cxx (semantic_pass): Leave the optimization decision to the optimization passes themselves. (semantic_pass_optimize1): Predicate most optimizations, but enable the constant-folding for listing_mode_vars too. (semantic_pass_optimize2): Predicate all (1) optimizations. * testsuite/semok/defined_list_vars.stp: New test.
-rw-r--r--elaborate.cxx26
-rwxr-xr-xtestsuite/semok/defined_list_vars.stp18
2 files changed, 35 insertions, 9 deletions
diff --git a/elaborate.cxx b/elaborate.cxx
index 59110c75..07a2ed61 100644
--- a/elaborate.cxx
+++ b/elaborate.cxx
@@ -1494,10 +1494,10 @@ semantic_pass (systemtap_session& s)
if (rc == 0) rc = semantic_pass_symbols (s);
if (rc == 0) rc = semantic_pass_conditions (s);
- if (rc == 0 && ! s.unoptimized) rc = semantic_pass_optimize1 (s);
+ if (rc == 0) rc = semantic_pass_optimize1 (s);
if (rc == 0) rc = semantic_pass_types (s);
if (rc == 0) add_global_var_display (s);
- if (rc == 0 && ! s.unoptimized) rc = semantic_pass_optimize2 (s);
+ if (rc == 0) rc = semantic_pass_optimize2 (s);
if (rc == 0) rc = semantic_pass_vars (s);
if (rc == 0) rc = semantic_pass_stats (s);
@@ -3663,12 +3663,19 @@ semantic_pass_optimize1 (systemtap_session& s)
relaxed_p = true; // until proven otherwise
- semantic_pass_opt1 (s, relaxed_p);
- semantic_pass_opt2 (s, relaxed_p, iterations); // produce some warnings only on iteration=0
- semantic_pass_opt3 (s, relaxed_p);
- semantic_pass_opt4 (s, relaxed_p);
- semantic_pass_opt5 (s, relaxed_p);
- semantic_pass_const_fold (s, relaxed_p);
+ if (!s.unoptimized)
+ {
+ semantic_pass_opt1 (s, relaxed_p);
+ semantic_pass_opt2 (s, relaxed_p, iterations); // produce some warnings only on iteration=0
+ semantic_pass_opt3 (s, relaxed_p);
+ semantic_pass_opt4 (s, relaxed_p);
+ semantic_pass_opt5 (s, relaxed_p);
+ }
+
+ // For listing mode, we need const-folding regardless of optimization so
+ // that @defined expressions can be properly resolved. PR11360
+ if (!s.unoptimized || s.listing_mode_vars)
+ semantic_pass_const_fold (s, relaxed_p);
iterations ++;
}
@@ -3692,7 +3699,8 @@ semantic_pass_optimize2 (systemtap_session& s)
if (pending_interrupts) break;
relaxed_p = true; // until proven otherwise
- semantic_pass_opt6 (s, relaxed_p);
+ if (!s.unoptimized)
+ semantic_pass_opt6 (s, relaxed_p);
}
return rc;
diff --git a/testsuite/semok/defined_list_vars.stp b/testsuite/semok/defined_list_vars.stp
new file mode 100755
index 00000000..7f73ff05
--- /dev/null
+++ b/testsuite/semok/defined_list_vars.stp
@@ -0,0 +1,18 @@
+#! /bin/sh
+
+# PR11360 - Make sure that @defined and -L play well together.
+#
+# The test shouldn't be dependent on the implementation of syscall.poll, in
+# case that evolves, so I'm recreating the problematic condition here.
+#
+# NB: This is abusing the fact that -l/-L work by wrapping the input string
+# with "probe " and "{}"
+
+stap -L '
+my_syscall.poll = kernel.function("SyS_poll").call !,
+ kernel.function("sys_poll").call
+{
+ timeout = (@defined($timeout_msecs) ? $timeout_msecs : $timeout)
+}
+probe my_syscall.poll
+' | grep " timeout:long"