From cc9ee6059e4d3fb51c0695a8a57f75eb988a1786 Mon Sep 17 00:00:00 2001 From: fche Date: Mon, 5 Sep 2005 22:00:43 +0000 Subject: 2005-09-05 Frank Ch. Eigler PR 1172. * staptree.h, staptree.cxx: Make all ::print*(), operator<< functions take const staptree objects. (literal_string::print): \-prefix double-quotes. * translate.cxx (emit_common_header): Add context probe_point field. Switch to atomic_t busy flags. (emit_module_exit): Use atomic operations for busy flag. (visit_*): Use lex_cast_qstring for last_stmt strings. * tapsets.cxx (lex_cast_quoted): \-prefix double-quotes too. (*::emit_probe_entries): Populate probe_point. Use atomic operations for busy flag. * tapset/context.stp (pp): New function. * stapfuncs.5.in: Document it. * testsuite/buildok/context_test.stp: Test it. --- staptree.cxx | 82 ++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 44 insertions(+), 38 deletions(-) (limited to 'staptree.cxx') diff --git a/staptree.cxx b/staptree.cxx index 8af920d6..47a5cd0c 100644 --- a/staptree.cxx +++ b/staptree.cxx @@ -168,27 +168,32 @@ operator << (ostream& o, const exp_type& e) // ------------------------------------------------------------------------ // parse tree printing -ostream& operator << (ostream& o, expression& k) +ostream& operator << (ostream& o, const expression& k) { k.print (o); return o; } -void literal_string::print (ostream& o) +void literal_string::print (ostream& o) const { - // XXX: quote special chars - o << '"' << value << '"'; + o << '"'; + for (unsigned i=0; iindexes.size(); i++) @@ -212,13 +217,13 @@ void array_in::print (ostream& o) o << "] in " << operand->base; } -void post_crement::print (ostream& o) +void post_crement::print (ostream& o) const { o << '(' << *operand << ")" << op; } -void ternary_expression::print (ostream& o) +void ternary_expression::print (ostream& o) const { o << "(" << *cond << ")?(" << *truevalue << "):(" @@ -226,13 +231,13 @@ void ternary_expression::print (ostream& o) } -void symbol::print (ostream& o) +void symbol::print (ostream& o) const { o << name; } -void target_symbol::print (std::ostream& o) +void target_symbol::print (std::ostream& o) const { o << base_name; for (unsigned i = 0; i < components.size(); ++i) @@ -250,7 +255,7 @@ void target_symbol::print (std::ostream& o) } -void vardecl::print (ostream& o) +void vardecl::print (ostream& o) const { o << name; if (arity > 0 || index_types.size() > 0) @@ -258,7 +263,7 @@ void vardecl::print (ostream& o) } -void vardecl::printsig (ostream& o) +void vardecl::printsig (ostream& o) const { o << name << ":" << type; if (index_types.size() > 0) @@ -271,7 +276,7 @@ void vardecl::printsig (ostream& o) } -void functiondecl::print (ostream& o) +void functiondecl::print (ostream& o) const { o << "function " << name << " ("; for (unsigned i=0; iprint (o); @@ -347,7 +352,7 @@ void for_loop::print (ostream& o) } -void foreach_loop::print (ostream& o) +void foreach_loop::print (ostream& o) const { o << "foreach (["; for (unsigned i=0; i const & aliases): probe (), alias_names (aliases) { } -void probe_alias::printsig (ostream& o) +void probe_alias::printsig (ostream& o) const { for (unsigned i=0; i