diff options
author | hiramatu <hiramatu> | 2007-11-20 21:03:16 +0000 |
---|---|---|
committer | hiramatu <hiramatu> | 2007-11-20 21:03:16 +0000 |
commit | cbbe8080060563441ba79ed4645e9b533a870409 (patch) | |
tree | c40367e5311e9e80f0ad30a2edbc3362946193d8 /staptree.cxx | |
parent | 57b1f4642f87f69b58705f2a7c2f92de1348b0cc (diff) | |
download | systemtap-steved-cbbe8080060563441ba79ed4645e9b533a870409.tar.gz systemtap-steved-cbbe8080060563441ba79ed4645e9b533a870409.tar.xz systemtap-steved-cbbe8080060563441ba79ed4645e9b533a870409.zip |
2007-11-20 Masami Hiramatsu <mhiramat@redhat.com>
PR 4935.
* parse.cxx (parser::parse_probe_point): Parse "if" condition
following probe point.
* staptree.h (probe_point): Add "condition" field.
(probe): Add "condition" field and "add_condition" method.
(deep_copy_visitor): Add "deep_copy" method for the expression.
* staptree.cxx (probe_point::probe_point): Initalize it.
(probe::add_condition): Implement it.
(probe::print): Output "condition" field.
(probe::str): Ditto.
(deep_copy_visitor::deep_copy): Implement it.
* elaborate.h (derived_probe): Add "insert_condition_statement"
method.
* elaborate.cxx (derived_probe::derived_probe): Initialize "condition"
field, and insert a condition check routine on the top of body.
(derived_probe::insert_condition_statement): Implement it.
(alias_expansion_builder::build): Pass the condition from the alias
referer to new alias.
* tapsets.cxx (be_derived_probe): Remove unused constructor.
(dwarf_derived_probe::dwarf_derived_probe): Insert a condition check
routine on the top of body.
(mark_derived_probe::mark_derived_probe): Ditto.
(mark_builder::build): Pass the base location to mark_derived_probe.
Diffstat (limited to 'staptree.cxx')
-rw-r--r-- | staptree.cxx | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/staptree.cxx b/staptree.cxx index 8b702306..42fc8c24 100644 --- a/staptree.cxx +++ b/staptree.cxx @@ -75,12 +75,13 @@ symboldecl::~symboldecl () probe_point::probe_point (std::vector<component*> const & comps, const token * t): - components(comps), tok(t), optional (false), sufficient (false) + components(comps), tok(t), optional (false), sufficient (false), + condition (NULL) { } probe_point::probe_point (): - tok (0), optional (false), sufficient (false) + tok (0), optional (false), sufficient (false), condition (NULL) { } @@ -897,6 +898,26 @@ probe::collect_derivation_chain (std::vector<derived_probe*> &probes_list) probes_list.push_back((derived_probe*)this); } +void +probe::add_condition (expression* e) +{ + if (e) + { + if (this->condition) + { + logical_and_expr *la = new logical_and_expr (); + la->op = "&&"; + la->left = this->condition; + la->right = e; + la->tok = e->tok; + this->condition = la; + } + else + { + this->condition = e; + } + } +} void probe_point::print (ostream& o) const { @@ -912,6 +933,8 @@ void probe_point::print (ostream& o) const o << "!"; else if (optional) // sufficient implies optional o << "?"; + if (condition) + o<< " if (" << *condition << ")"; } string probe_point::str () @@ -929,6 +952,8 @@ string probe_point::str () o << "!"; else if (optional) // sufficient implies optional o << "?"; + if (condition) + o<< " if (" << *condition << ")"; return o.str(); } @@ -2355,3 +2380,12 @@ deep_copy_visitor::deep_copy (statement* s) require <statement*> (&v, &n, s); return n; } + +expression* +deep_copy_visitor::deep_copy (expression* s) +{ + expression* n; + deep_copy_visitor v; + require <expression*> (&v, &n, s); + return n; +} |