summaryrefslogtreecommitdiffstats
path: root/elaborate.cxx
diff options
context:
space:
mode:
authorFrank Ch. Eigler <fche@elastic.org>2010-02-23 20:31:00 -0500
committerFrank Ch. Eigler <fche@elastic.org>2010-02-23 20:31:00 -0500
commit30263a7389d5c2712536b74656193708bbc64d49 (patch)
treeb10b72dd3db455abf95a8ab21c540069c0143860 /elaborate.cxx
parentd6c273473f7bea4d696c95ca48d55ca26e25ab2f (diff)
downloadsystemtap-steved-30263a7389d5c2712536b74656193708bbc64d49.tar.gz
systemtap-steved-30263a7389d5c2712536b74656193708bbc64d49.tar.xz
systemtap-steved-30263a7389d5c2712536b74656193708bbc64d49.zip
PR11005: @defined($tvar) predicate, part 1
* staptree.h (defined_op): New class. * all files: Extend all visitors as appropriate, mostly dummy/pass-through implementation. * parse.cxx (parse_target_symbol): New function, factored out of parse_symbol(). (parse_define_op): New function. * NEWS: Mention it. * parse.h: Corresponding changes. * tapsets.cxx (var_expanding_visitor::visit_defined_op): Implement @defined() semantics. (dwarf_var_expanding_visitor::visit_target_symbol): Adjust. * tapset-utrace.c (visit_target_symbol_arg): Avoid crashes on $argZZZ. * tapsets.cxx (sdt_var_expanding_visitor): Ditto. * semok/thirtysix.stp: New test.
Diffstat (limited to 'elaborate.cxx')
-rw-r--r--elaborate.cxx26
1 files changed, 26 insertions, 0 deletions
diff --git a/elaborate.cxx b/elaborate.cxx
index 88a856c2..127e0bda 100644
--- a/elaborate.cxx
+++ b/elaborate.cxx
@@ -1243,6 +1243,7 @@ semantic_pass_symbols (systemtap_session& s)
}
+
// Keep unread global variables for probe end value display.
void add_global_var_display (systemtap_session& s)
{
@@ -2609,6 +2610,7 @@ struct void_statement_reducer: public update_visitor
void visit_print_format (print_format* e);
void visit_target_symbol (target_symbol* e);
void visit_cast_op (cast_op* e);
+ void visit_defined_op (defined_op* e);
// these are a bit hairy to grok due to the intricacies of indexables and
// stats, so I'm chickening out and skipping them...
@@ -2947,6 +2949,23 @@ void_statement_reducer::visit_cast_op (cast_op* e)
}
+void
+void_statement_reducer::visit_defined_op (defined_op* e)
+{
+ // When the result of a @defined operation isn't needed, just elide
+ // it entirely. Its operand $expression must already be
+ // side-effect-free.
+
+ if (session.verbose>2)
+ clog << "Eliding unused check " << *e->tok << endl;
+
+ relaxed_p = false;
+ e = 0;
+ provide (e);
+}
+
+
+
void semantic_pass_opt5 (systemtap_session& s, bool& relaxed_p)
{
// Let's simplify statements with unused computed values.
@@ -3576,6 +3595,13 @@ typeresolution_info::visit_target_symbol (target_symbol* e)
void
+typeresolution_info::visit_defined_op (defined_op* e)
+{
+ throw semantic_error("unexpected @defined", e->tok);
+}
+
+
+void
typeresolution_info::visit_cast_op (cast_op* e)
{
// Like target_symbol, a cast_op shouldn't survive this far