perf_counter tools: Add --dsos parameter to 'perf report'
PATCH 1/3 perf_counter tools: Add --dsos parameter to 'perf report'
So that we can filter by dso. Symbols in other dsos won't be accounted for.
Cc Mike Galbraith <[email protected]>
Cc Peter Zijlstra <[email protected]>
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/Documentation/perf-report.txt | 4 + tools/perf/Makefile | 2 + tools/perf/builtin-report.c | 16 +++ tools/perf/util/strlist.c | 184 ++++++++++++++++++++++++++++++ tools/perf/util/strlist.h | 32 +++++ 5 files changed, 238 insertions(+), 0 deletions(-) create mode 100644 tools/perf/util/strlist.c create mode 100644 tools/perf/util/strlist.h
tools/perf/Documentation/perf-report.txt +4 -0
@@ -20,6 +20,10 @@ OPTIONS -i:: --input=:: Input file name. (default: perf.data) +-d:: +--dsos=:: + Only consider symbols in these dsos. CSV that understands + file://filename entries. SEE ALSO --------
tools/perf/Makefile +2 -0
@@ -301,6 +301,7 @@ LIB_H += util/util.h LIB_H += util/help.h LIB_H += util/strbuf.h LIB_H += util/string.h +LIB_H += util/strlist.h LIB_H += util/run-command.h LIB_H += util/sigchain.h LIB_H += util/symbol.h
@@ -322,6 +323,7 @@ LIB_OBJS += util/run-command.o LIB_OBJS += util/quote.o LIB_OBJS += util/strbuf.o LIB_OBJS += util/string.o +LIB_OBJS += util/strlist.o LIB_OBJS += util/usage.o LIB_OBJS += util/wrapper.o LIB_OBJS += util/sigchain.o
tools/perf/builtin-report.c +16 -0
@@ -16,6 +16,7 @@#include "util/symbol.h" #include "util/string.h" #include "util/callchain.h" +#include "util/strlist.h" #include "perf.h" #include "util/header.h"
@@ -32,6 +33,8 @@ static char *vmlinux = NULL;static char default_sort_order[] ="comm,dso" ;static char *sort_order = default_sort_order; +static char *dso_list_str; +static struct strlist *dso_list;static int input;static int show_mask =SHOW_KERNEL |SHOW_USER |SHOW_HV ;
@@ -1272,6 +1275,9 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)if (show & show_mask) {struct symbol *sym =resolve_symbol (thread, &map, &dso, &ip); +if (dso_list && dso && dso->name && !strlist__has_entry (dso_list, dso->name)) +return 0 ; +if (hist_entry__add (thread, map, dso, sym, ip, chain, level, period)) {eprintf ("problem incrementing symbol count, skipping event\n" );return -1 ;
@@ -1659,6 +1665,8 @@ static const struct option options[] = {OPT_BOOLEAN ('x' ,"exclude-other" , &exclude_other,"Only display entries with parent-match" ),OPT_BOOLEAN ('c' ,"callchain" , &callchain,"Display callchains" ), +OPT_STRING ('d' ,"dsos" , &dso_list_str,"dso[,dso...]" , +"only consider symbols in these dsos" ), OPT_END() };
@@ -1698,6 +1706,14 @@ int cmd_report(int argc, const char **argv, const char *prefix)if (argc)usage_with_options (report_usage, options); +if (dso_list_str) { + dso_list =strlist__new (true, dso_list_str); +if (!dso_list) { +fprintf (stderr,"problems parsing dso list\n" ); +exit (129 ); + } + } +setup_pager ();return __cmd_report ();
tools/perf/util/strlist.c new file +184 -0
184 lines not on this page · raw message
tools/perf/util/strlist.h new file +32 -0
@@ -0,0 +1,32 @@ +#ifndef STRLIST_H_ +#define STRLIST_H_ + +#include "rbtree.h" +#include <stdbool.h> + +struct str_node { +struct rb_node rb_node; +const char *s; +}; + +struct strlist { +struct rb_root entries; +bool dupstr; +}; + +struct strlist *strlist__new (bool dupstr,const char *slist); +void strlist__delete (struct strlist *self); + +void strlist__remove (struct strlist *self,struct str_node *sn); +int strlist__load (struct strlist *self,const char *filename); +int strlist__add (struct strlist *self,const char *str); + +bool strlist__has_entry (struct strlist *self,const char *entry); + +static inline bool strlist__empty (const struct strlist *self) +{ +return rb_first (&self->entries) ==NULL ; +} + +int strlist__parse_list (struct strlist *self,const char *s); +#endif /* STRLIST_H_ */
Signature · 1 line
1.6.2.5