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.h | |
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.h')
-rw-r--r-- | staptree.h | 22 |
1 files changed, 18 insertions, 4 deletions
@@ -1,5 +1,5 @@ // -*- C++ -*- -// Copyright (C) 2005-2009 Red Hat Inc. +// Copyright (C) 2005-2010 Red Hat Inc. // Copyright (C) 2006 Intel Corporation. // // This file is part of systemtap, and is free software. You can @@ -254,7 +254,7 @@ struct target_symbol: public symbol bool addressof; std::string base_name; std::vector<component> components; - std::string probe_context_var; + std::string probe_context_var; // NB: this being set implies that target_symbol is *resolved* semantic_error* saved_conversion_error; target_symbol(): addressof(false), saved_conversion_error (0) {} void print (std::ostream& o) const; @@ -276,6 +276,14 @@ struct cast_op: public target_symbol }; +struct defined_op: public expression +{ + target_symbol *operand; + void print (std::ostream& o) const; + void visit (visitor* u); +}; + + struct arrayindex: public expression { std::vector<expression*> indexes; @@ -718,6 +726,7 @@ struct visitor virtual void visit_stat_op (stat_op* e) = 0; virtual void visit_hist_op (hist_op* e) = 0; virtual void visit_cast_op (cast_op* e) = 0; + virtual void visit_defined_op (defined_op* e) = 0; }; @@ -759,6 +768,7 @@ struct traversing_visitor: public visitor void visit_stat_op (stat_op* e); void visit_hist_op (hist_op* e); void visit_cast_op (cast_op* e); + void visit_defined_op (defined_op* e); }; @@ -801,6 +811,7 @@ struct varuse_collecting_visitor: public functioncall_traversing_visitor void visit_post_crement (post_crement *e); void visit_foreach_loop (foreach_loop *s); void visit_cast_op (cast_op* e); + void visit_defined_op (defined_op* e); bool side_effect_free (); bool side_effect_free_wrt (const std::set<vardecl*>& vars); @@ -851,6 +862,7 @@ struct throwing_visitor: public visitor void visit_stat_op (stat_op* e); void visit_hist_op (hist_op* e); void visit_cast_op (cast_op* e); + void visit_defined_op (defined_op* e); }; // A visitor similar to a traversing_visitor, but with the ability to rewrite @@ -865,7 +877,7 @@ struct update_visitor: public visitor { src->visit(this); assert(!targets.empty()); - dst = static_cast<T*>(targets.top()); + dst = static_cast<T*>(targets.top()); // XXX: danger will robinson: not typesafe! targets.pop(); assert(clearok || dst); } @@ -874,7 +886,7 @@ struct update_visitor: public visitor template <typename T> void provide (T* src) { - targets.push(static_cast<void*>(src)); + targets.push(static_cast<void*>(src)); // XXX: not typesafe! } template <typename T> void replace (T*& src, bool clearok=false) @@ -917,6 +929,7 @@ struct update_visitor: public visitor virtual void visit_stat_op (stat_op* e); virtual void visit_hist_op (hist_op* e); virtual void visit_cast_op (cast_op* e); + virtual void visit_defined_op (defined_op* e); private: std::stack<void *> targets; @@ -972,6 +985,7 @@ struct deep_copy_visitor: public update_visitor virtual void visit_stat_op (stat_op* e); virtual void visit_hist_op (hist_op* e); virtual void visit_cast_op (cast_op* e); + virtual void visit_defined_op (defined_op* e); }; #endif // STAPTREE_H |