From c39cdd5565f718302057242bbfe50e71b69c4f4d Mon Sep 17 00:00:00 2001 From: Wenji Huang Date: Wed, 4 Nov 2009 10:58:58 +0800 Subject: PR10466: print the set-intersection of variables retrieved from each branch * elaborate.h: Remove printargs and add getargs. * tapset-mark.cxx (mark_derived_probe): Ditto. * tapsets.cxx (dwarf_derived_probe,tracepoint_derived_probe): Ditto. * main.cxx (printscript): Make intersection before printing. --- main.cxx | 46 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 11 deletions(-) (limited to 'main.cxx') diff --git a/main.cxx b/main.cxx index c0ff3ba5..165b51c2 100644 --- a/main.cxx +++ b/main.cxx @@ -162,8 +162,10 @@ printscript(systemtap_session& s, ostream& o) if (s.listing_mode) { // We go through some heroic measures to produce clean output. - set seen; + // Record the alias and probe pointer as > + map > probe_list; + // Pre-process the probe alias for (unsigned i=0; i >::iterator it=probe_list.begin(); it!=probe_list.end(); ++it) + { + o << it->first; // probe name or alias + + // Print the locals and arguments for -L mode only + if (s.listing_mode_vars) { - o << pp; - // Print the locals for -L mode only - if (s.listing_mode_vars) + map var_list; // format <"name:type",count> + map arg_list; + // traverse set to collect all locals and arguments + for (set::iterator ix=it->second.begin(); ix!=it->second.end(); ++ix) { + derived_probe* p = *ix; + // collect available locals of the probe for (unsigned j=0; jlocals.size(); j++) { - o << " "; + stringstream tmps; vardecl* v = p->locals[j]; - v->printsig (o); + v->printsig (tmps); + var_list[tmps.str()]++; } - // Print arguments of probe if there - p->printargs(o); + // collect arguments of the probe if there + set arg_set; + p->getargs(arg_set); + for (set::iterator ia=arg_set.begin(); ia!=arg_set.end(); ++ia) + arg_list[*ia]++; } - o << endl; - seen.insert (pp); + // print the set-intersection only + for (map::iterator ir=var_list.begin(); ir!=var_list.end(); ++ir) + if (ir->second == it->second.size()) // print locals + o << " " << ir->first; + for (map::iterator ir=arg_list.begin(); ir!=arg_list.end(); ++ir) + if (ir->second == it->second.size()) // print arguments + o << " " << ir->first; } + o << endl; } } else -- cgit