summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--staptree.cxx6
-rwxr-xr-xtestsuite/transok/tval-opt.stp9
3 files changed, 20 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 853fc83b..cd80930a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-03-06 Frank Ch. Eigler <fche@elastic.org>
+
+ PR 2425
+ * staptree.cxx (varuse_collecting_visitor::visit_embeddedcode):
+ Realize that $var-setter functions have side-effects.
+ * testsuite/transok/tval-opt.stp: New test.
+
2006-03-06 Martin Hunt <hunt@redhat.com>
* buildrun.cxx (run_pass): Add "-u username".
diff --git a/staptree.cxx b/staptree.cxx
index 6669e9ae..708d7b87 100644
--- a/staptree.cxx
+++ b/staptree.cxx
@@ -1480,7 +1480,7 @@ void
varuse_collecting_visitor::visit_embeddedcode (embeddedcode *s)
{
// In order to elide unused but correct functions generated to
- // get/set $target variables, we encode our knowledge that such
+ // get $target variables, we encode our knowledge that such
// functions are side-effect-free. We tell them apart from ordinary
// tapset embedded-C functions by the naming prefix. XXX Something
// apart from this heuristic would be nice. XXX Similarly, some
@@ -1489,8 +1489,9 @@ varuse_collecting_visitor::visit_embeddedcode (embeddedcode *s)
assert (current_function); // only they get embedded code
string name = current_function->name;
- if (name.length() > 6 && name.substr(0, 6) == "_tvar_")
+ if (name.length() > 10 && name.substr(0, 10) == "_tvar_get_")
return;
+ // NB: setter functions naturally have side-effects
embedded_seen = true;
}
@@ -1549,6 +1550,7 @@ varuse_collecting_visitor::visit_symbol (symbol *e)
// NB: stat_op need not be overridden, since it will get to
// visit_symbol and only as a possible rvalue.
+
void
varuse_collecting_visitor::visit_arrayindex (arrayindex *e)
{
diff --git a/testsuite/transok/tval-opt.stp b/testsuite/transok/tval-opt.stp
new file mode 100755
index 00000000..4f1c0b06
--- /dev/null
+++ b/testsuite/transok/tval-opt.stp
@@ -0,0 +1,9 @@
+#! /bin/sh
+
+set -e
+
+script='probe kernel.function("kbd_keycode") { if ($keycode==50) $keycode=49 }'
+s1=`./stap -p3 -g -e "$script" | sum`
+s2=`./stap -p3 -g -u -e "$script" | sum`
+
+test x"$s1" == x"$s2"