diff options
author | William Cohen <wcohen@redhat.com> | 2010-02-02 14:54:24 -0500 |
---|---|---|
committer | William Cohen <wcohen@redhat.com> | 2010-02-02 14:54:24 -0500 |
commit | 1c64350c56271d1dee13f813aa8c78ece33e3cd5 (patch) | |
tree | d7f9186f0036784b47e25aefe3915d743738fe70 /main.cxx | |
parent | 3963c62757e752712592ebda63137cc7c6be532d (diff) | |
parent | d0bfd2ac518333369a384d58882ff37d5288225f (diff) | |
download | systemtap-steved-1c64350c56271d1dee13f813aa8c78ece33e3cd5.tar.gz systemtap-steved-1c64350c56271d1dee13f813aa8c78ece33e3cd5.tar.xz systemtap-steved-1c64350c56271d1dee13f813aa8c78ece33e3cd5.zip |
Merge branch 'master' of ssh://sources.redhat.com/git/systemtap
Diffstat (limited to 'main.cxx')
-rw-r--r-- | main.cxx | 53 |
1 files changed, 41 insertions, 12 deletions
@@ -156,6 +156,26 @@ usage (systemtap_session& s, int exitcode) } +static void uniq_list(list<string>& l) +{ + list<string> r; + set<string> s; + + for (list<string>::iterator i = l.begin(); i != l.end(); ++i) { + s.insert(*i); + } + + for (list<string>::iterator i = l.begin(); i != l.end(); ++i) { + if (s.find(*i) != s.end()) { + s.erase(*i); + r.push_back(*i); + } + } + + l.clear(); + l.assign(r.begin(), r.end()); +} + static void printscript(systemtap_session& s, ostream& o) { @@ -211,8 +231,10 @@ printscript(systemtap_session& s, ostream& o) // Print the locals and arguments for -L mode only if (s.listing_mode_vars) { - map<string,unsigned> var_list; // format <"name:type",count> - map<string,unsigned> arg_list; + map<string,unsigned> var_count; // format <"name:type",count> + map<string,unsigned> arg_count; + list<string> var_list; + list<string> 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) { @@ -223,21 +245,28 @@ printscript(systemtap_session& s, ostream& o) stringstream tmps; vardecl* v = p->locals[j]; v->printsig (tmps); - var_list[tmps.str()]++; + var_count[tmps.str()]++; + var_list.push_back(tmps.str()); } // collect arguments of the probe if there - set<string> arg_set; + list<string> arg_set; p->getargs(arg_set); - for (set<string>::iterator ia=arg_set.begin(); ia!=arg_set.end(); ++ia) - arg_list[*ia]++; + for (list<string>::iterator ia=arg_set.begin(); ia!=arg_set.end(); ++ia) { + arg_count[*ia]++; + arg_list.push_back(*ia); + } } + + uniq_list(arg_list); + uniq_list(var_list); + // 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; + for (list<string>::iterator ir=var_list.begin(); ir!=var_list.end(); ++ir) + if (var_count.find(*ir)->second == it->second.size()) // print locals + o << " " << *ir; + for (list<string>::iterator ir=arg_list.begin(); ir!=arg_list.end(); ++ir) + if (arg_count.find(*ir)->second == it->second.size()) // print arguments + o << " " << *ir; } o << endl; } |