summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Brolley <brolley@redhat.com>2009-11-05 15:23:35 -0500
committerDave Brolley <brolley@redhat.com>2009-11-05 15:23:35 -0500
commitffe4285b81564e098aa7a2d056ff62a8700f321d (patch)
tree8b2145ec5de1929efd04c5d7207d659e93df4fbd
parentdcb95d9a7c3abc823699d7c096219f9e09ea5921 (diff)
parentc39cdd5565f718302057242bbfe50e71b69c4f4d (diff)
downloadsystemtap-steved-ffe4285b81564e098aa7a2d056ff62a8700f321d.tar.gz
systemtap-steved-ffe4285b81564e098aa7a2d056ff62a8700f321d.tar.xz
systemtap-steved-ffe4285b81564e098aa7a2d056ff62a8700f321d.zip
Merge branch 'master' of ssh://sources.redhat.com/git/systemtap
-rw-r--r--elaborate.h4
-rw-r--r--main.cxx46
-rw-r--r--tapset-mark.cxx10
-rw-r--r--tapsets.cxx20
4 files changed, 51 insertions, 29 deletions
diff --git a/elaborate.h b/elaborate.h
index fec62d59..30a02c5b 100644
--- a/elaborate.h
+++ b/elaborate.h
@@ -128,8 +128,8 @@ struct derived_probe: public probe
virtual void join_group (systemtap_session& s) = 0;
virtual probe_point* sole_location () const;
virtual void printsig (std::ostream &o) const;
- //for print arguments of probe if there
- virtual void printargs (std::ostream &o) const {}
+ // return arguments of probe if there
+ virtual void getargs (std::set<std::string> &arg_set) const {}
void printsig_nested (std::ostream &o) const;
virtual void collect_derivation_chain (std::vector<probe*> &probes_list);
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<string> seen;
+ // Record the alias and probe pointer as <name, set<derived_probe *> >
+ map<string,set<derived_probe *> > probe_list;
+ // Pre-process the probe alias
for (unsigned i=0; i<s.probes.size(); i++)
{
if (pending_interrupts) return;
@@ -198,24 +200,46 @@ printscript(systemtap_session& s, ostream& o)
// Now duplicate-eliminate. An alias may have expanded to
// several actual derived probe points, but we only want to
// print the alias head name once.
- if (seen.find (pp) == seen.end())
+ probe_list[pp].insert(p);
+ }
+
+ // print probe name and variables if there
+ for (map<string, set<derived_probe *> >::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<string,unsigned> var_list; // format <"name:type",count>
+ map<string,unsigned> arg_list;
+ // traverse set<derived_probe *> to collect all locals and arguments
+ for (set<derived_probe *>::iterator ix=it->second.begin(); ix!=it->second.end(); ++ix)
{
+ derived_probe* p = *ix;
+ // collect available locals of the probe
for (unsigned j=0; j<p->locals.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<string> arg_set;
+ p->getargs(arg_set);
+ for (set<string>::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<string,unsigned>::iterator ir=var_list.begin(); ir!=var_list.end(); ++ir)
+ if (ir->second == it->second.size()) // print locals
+ o << " " << ir->first;
+ for (map<string,unsigned>::iterator ir=arg_list.begin(); ir!=arg_list.end(); ++ir)
+ if (ir->second == it->second.size()) // print arguments
+ o << " " << ir->first;
}
+ o << endl;
}
}
else
diff --git a/tapset-mark.cxx b/tapset-mark.cxx
index fc9cb274..1ce3c919 100644
--- a/tapset-mark.cxx
+++ b/tapset-mark.cxx
@@ -59,7 +59,7 @@ struct mark_derived_probe: public derived_probe
void print_dupe_stamp (ostream& o);
void emit_probe_context_vars (translator_output* o);
void initialize_probe_context_vars (translator_output* o);
- void printargs (std::ostream &o) const;
+ void getargs (std::set<std::string> &arg_set) const;
void parse_probe_format ();
};
@@ -465,7 +465,7 @@ mark_derived_probe::initialize_probe_context_vars (translator_output* o)
}
void
-mark_derived_probe::printargs(std::ostream &o) const
+mark_derived_probe::getargs(std::set<std::string> &arg_set) const
{
for (unsigned i = 0; i < mark_args.size(); i++)
{
@@ -473,13 +473,13 @@ mark_derived_probe::printargs(std::ostream &o) const
switch (mark_args[i]->stp_type)
{
case pe_long:
- o << " " << localname << ":long";
+ arg_set.insert(localname+":long");
break;
case pe_string:
- o << " " << localname << ":string";
+ arg_set.insert(localname+":string");
break;
default:
- o << " " << localname << ":unknown";
+ arg_set.insert(localname+":unknown");
break;
}
}
diff --git a/tapsets.cxx b/tapsets.cxx
index 324237fa..d2c33349 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -356,7 +356,7 @@ struct dwarf_derived_probe: public derived_probe
void printsig (std::ostream &o) const;
virtual void join_group (systemtap_session& s);
void emit_probe_local_init(translator_output * o);
- void printargs(std::ostream &o) const;
+ void getargs(std::set<std::string> &arg_set) const;
// Pattern registration helpers.
static void register_statement_variants(match_node * root,
@@ -377,7 +377,7 @@ protected:
{}
private:
- string args;
+ set<string> args;
void saveargs(dwarf_query& q, Dwarf_Die* scope_die, dwarf_var_expanding_visitor& v);
};
@@ -2899,7 +2899,7 @@ dwarf_derived_probe::saveargs(dwarf_query& q, Dwarf_Die* scope_die, dwarf_var_ex
if (has_return &&
dwarf_attr_die (scope_die, DW_AT_type, &type_die) &&
dwarf_type_name(&type_die, type_name))
- argstream << " $return:" << type_name;
+ args.insert("$return:"+type_name);
Dwarf_Die arg;
vector<Dwarf_Die> scopes = q.dw.getscopes_die(scope_die);
@@ -2936,18 +2936,16 @@ dwarf_derived_probe::saveargs(dwarf_query& q, Dwarf_Die* scope_die, dwarf_var_ex
tsym->saved_conversion_error = 0;
v.require (tsym);
if (!tsym->saved_conversion_error)
- argstream << " $" << arg_name << ":" << type_name;
+ args.insert("$"+string(arg_name)+":"+type_name);
}
while (dwarf_siblingof (&arg, &arg) == 0);
-
- args = argstream.str();
}
void
-dwarf_derived_probe::printargs(std::ostream &o) const
+dwarf_derived_probe::getargs(std::set<std::string> &arg_set) const
{
- o << args;
+ arg_set.insert(args.begin(), args.end());
}
@@ -5408,7 +5406,7 @@ struct tracepoint_derived_probe: public derived_probe
vector <struct tracepoint_arg> args;
void build_args(dwflpp& dw, Dwarf_Die& func_die);
- void printargs (std::ostream &o) const;
+ void getargs (std::set<std::string> &arg_set) const;
void join_group (systemtap_session& s);
void print_dupe_stamp(ostream& o);
void emit_probe_context_vars (translator_output* o);
@@ -5786,11 +5784,11 @@ tracepoint_derived_probe::build_args(dwflpp& dw, Dwarf_Die& func_die)
}
void
-tracepoint_derived_probe::printargs(std::ostream &o) const
+tracepoint_derived_probe::getargs(std::set<std::string> &arg_set) const
{
for (unsigned i = 0; i < args.size(); ++i)
if (args[i].usable)
- o << " $" << args[i].name << ":" << args[i].c_type;
+ arg_set.insert("$"+args[i].name+":"+args[i].c_type);
}
void