From cbbe8080060563441ba79ed4645e9b533a870409 Mon Sep 17 00:00:00 2001 From: hiramatu Date: Tue, 20 Nov 2007 21:03:16 +0000 Subject: 2007-11-20 Masami Hiramatsu 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. --- elaborate.cxx | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'elaborate.cxx') diff --git a/elaborate.cxx b/elaborate.cxx index aa6529fa..d3bbe28d 100644 --- a/elaborate.cxx +++ b/elaborate.cxx @@ -39,7 +39,8 @@ derived_probe::derived_probe (probe *p): { if (p) { - this->locations = p->locations; + this->locations = p->locations; + this->condition = deep_copy_visitor::deep_copy(p->condition); this->tok = p->tok; this->privileged = p->privileged; this->body = deep_copy_visitor::deep_copy(p->body); @@ -50,17 +51,41 @@ derived_probe::derived_probe (probe *p): derived_probe::derived_probe (probe *p, probe_point *l): base (p) { - if (l) - this->locations.push_back (l); - if (p) { + this->condition = deep_copy_visitor::deep_copy(p->condition); this->tok = p->tok; this->privileged = p->privileged; this->body = deep_copy_visitor::deep_copy(p->body); } + + if (l) + { + probe_point *pp = new probe_point (l->components, l->tok); + this->locations.push_back (pp); + this->add_condition (l->condition); + this->insert_condition_statement (); + } } +void +derived_probe::insert_condition_statement (void) +{ + if (this->condition) + { + if_statement *ifs = new if_statement (); + ifs->tok = this->tok; + ifs->thenblock = new next_statement (); + ifs->thenblock->tok = this->tok; + ifs->elseblock = NULL; + unary_expression *notex = new unary_expression (); + notex->op = "!"; + notex->tok = this->tok; + notex->operand = this->condition; + ifs->condition = notex; + body->statements.insert (body->statements.begin(), ifs); + } +} void derived_probe::printsig (ostream& o) const @@ -435,6 +460,8 @@ alias_expansion_builder // the token location of the alias, n->tok = location->tok; n->body->tok = location->tok; + // The new probe takes over condition. + n->add_condition (location->condition); // and statements representing the concatenation of the alias' // body with the use's. -- cgit