diff options
author | Frank Ch. Eigler <fche@elastic.org> | 2010-02-23 20:31:00 -0500 |
---|---|---|
committer | Frank Ch. Eigler <fche@elastic.org> | 2010-02-23 20:31:00 -0500 |
commit | 30263a7389d5c2712536b74656193708bbc64d49 (patch) | |
tree | b10b72dd3db455abf95a8ab21c540069c0143860 /staptree.cxx | |
parent | d6c273473f7bea4d696c95ca48d55ca26e25ab2f (diff) | |
download | systemtap-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 'staptree.cxx')
-rw-r--r-- | staptree.cxx | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/staptree.cxx b/staptree.cxx index 7a335fc3..9a69d11b 100644 --- a/staptree.cxx +++ b/staptree.cxx @@ -332,6 +332,12 @@ void cast_op::print (ostream& o) const } +void defined_op::print (ostream& o) const +{ + o << "@defined(" << *operand << ")"; +} + + void vardecl::print (ostream& o) const { o << name; @@ -1300,6 +1306,14 @@ cast_op::visit (visitor* u) u->visit_cast_op(this); } + +void +defined_op::visit (visitor* u) +{ + u->visit_defined_op(this); +} + + void arrayindex::visit (visitor* u) { @@ -1675,6 +1689,13 @@ traversing_visitor::visit_cast_op (cast_op* e) } void +traversing_visitor::visit_defined_op (defined_op* e) +{ + e->operand->visit (this); +} + + +void traversing_visitor::visit_arrayindex (arrayindex* e) { for (unsigned i=0; i<e->indexes.size(); i++) @@ -1789,6 +1810,14 @@ varuse_collecting_visitor::visit_cast_op (cast_op *e) } void +varuse_collecting_visitor::visit_defined_op (defined_op *e) +{ + // XXX + functioncall_traversing_visitor::visit_defined_op (e); +} + + +void varuse_collecting_visitor::visit_print_format (print_format* e) { // NB: Instead of being top-level statements, "print" and "printf" @@ -2181,6 +2210,13 @@ throwing_visitor::visit_cast_op (cast_op* e) } void +throwing_visitor::visit_defined_op (defined_op* e) +{ + throwone (e->tok); +} + + +void throwing_visitor::visit_arrayindex (arrayindex* e) { throwone (e->tok); @@ -2423,6 +2459,13 @@ update_visitor::visit_cast_op (cast_op* e) } void +update_visitor::visit_defined_op (defined_op* e) +{ + replace (e->operand); + provide (e); +} + +void update_visitor::visit_arrayindex (arrayindex* e) { replace (e->base); @@ -2660,6 +2703,12 @@ deep_copy_visitor::visit_cast_op (cast_op* e) } void +deep_copy_visitor::visit_defined_op (defined_op* e) +{ + update_visitor::visit_defined_op(new defined_op(*e)); +} + +void deep_copy_visitor::visit_arrayindex (arrayindex* e) { update_visitor::visit_arrayindex(new arrayindex(*e)); |