From 37ae3931d6eff955f75319d99f507688cef054e5 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 24 Sep 2010 15:16:36 -0700 Subject: [PATCH] Simplify the '?' removal for STP_TIMING Add a new flag to probe_point::print() so the extra details can be avoided. This skips '?', '!', and any conditionals as well. * staptree.cxx (probe_point::print): Make the extras optional. (probe_point::str): Pass along the choice of extras. * translate.cxx (c_unparser::emit_module_exit): Let the print routine skip the extra flags, rather than trying to strip them out manually. --- staptree.cxx | 8 +++++--- staptree.h | 4 ++-- translate.cxx | 26 ++++++++------------------ 3 files changed, 15 insertions(+), 23 deletions(-) diff --git a/staptree.cxx b/staptree.cxx index 37416e3df..367396ba8 100644 --- a/staptree.cxx +++ b/staptree.cxx @@ -1120,7 +1120,7 @@ probe::collect_derivation_chain (std::vector &probes_list) } -void probe_point::print (ostream& o) const +void probe_point::print (ostream& o, bool print_extras) const { for (unsigned i=0; iarg) o << "(" << *c->arg << ")"; } + if (!print_extras) + return; if (sufficient) o << "!"; else if (optional) // sufficient implies optional @@ -1138,10 +1140,10 @@ void probe_point::print (ostream& o) const o<< " if (" << *condition << ")"; } -string probe_point::str () +string probe_point::str (bool print_extras) const { ostringstream o; - print(o); + print(o, print_extras); return o.str(); } diff --git a/staptree.h b/staptree.h index 647aa0e8d..2edbec738 100644 --- a/staptree.h +++ b/staptree.h @@ -680,11 +680,11 @@ struct probe_point bool optional; bool sufficient; expression* condition; - void print (std::ostream& o) const; + void print (std::ostream& o, bool print_extras=true) const; probe_point (); probe_point(const probe_point& pp); probe_point(std::vector const & comps); - std::string str(); + std::string str(bool print_extras=true) const; }; std::ostream& operator << (std::ostream& o, const probe_point& k); diff --git a/translate.cxx b/translate.cxx index 73cfa6eb3..9ce3e2b84 100644 --- a/translate.cxx +++ b/translate.cxx @@ -1445,14 +1445,9 @@ c_unparser::emit_module_exit () for (unsigned i=0; iprobes.size(); i++) { vector reference_point; - const probe* p = session->probes[i]; + const derived_probe* p = session->probes[i]; const string &nm = p->name; - string::iterator it; - string call = session->probes[i]->sole_location()->str(); - it = call.end()-1; - if(*it=='?') - call.erase(it); - //checking and erasing any trailing '?' + string call = p->sole_location()->str(false); // no ?,!,etc session->probes[i]->collect_derivation_chain(reference_point); // NB: check for null stat object o->newline() << "if (likely (time_" << nm << ")) {"; @@ -1470,19 +1465,14 @@ c_unparser::emit_module_exit () o->newline() << "_stp_printf (\"%s, (%s), hits: %lld, cycles: %lldmin/%lldavg/%lldmax,\","; o->newline() << "probe_point, decl_location, (long long) stats->count, " << "(long long) stats->min, (long long) avg, (long long) stats->max);"; - for(unsigned int j=0; jlocations[0]->str(); - it1 = call_derivation.end()-1; - if(*it1=='?') - call_derivation.erase(it1); - //checking for ? again - o->newline() << "_stp_printf(\" from: \");"; - o->newline() << "_stp_printf("; - o->line() << lex_cast_qstring(call_derivation) << ");"; + const probe_point *pp = reference_point[j]->locations[0]; + o->newline() << "_stp_printf(\" from: %s\", " + << lex_cast_qstring(pp->str(false)) // no ?,!,etc + << ");"; } - o->newline() << "_stp_printf(\" \\n\");"; + o->newline() << "_stp_printf(\"\\n\");"; o->newline(-1) << "}"; o->newline() << "_stp_stat_del (time_" << nm << ");"; o->newline(-1) << "}"; -- 2.43.5