diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-12-15 17:04:40 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-12-16 02:53:49 -0500 |
commit | 655000e7c75a559681ee7f15f6fa870c80ae3194 (patch) | |
tree | 69a56e19c818b0929dbea8d119fa133853c5ee80 /tools/perf/builtin-report.c | |
parent | 75be6cf48738aec68aac49b428423569492cfba3 (diff) |
perf symbols: Adopt the strlists for dso, comm
Will be used in perf diff too.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1260914682-29652-2-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/builtin-report.c')
-rw-r--r-- | tools/perf/builtin-report.c | 73 |
1 files changed, 32 insertions, 41 deletions
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index c349bdbb9474..03afac3b56ef 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -33,10 +33,6 @@ | |||
33 | 33 | ||
34 | static char const *input_name = "perf.data"; | 34 | static char const *input_name = "perf.data"; |
35 | 35 | ||
36 | static char *dso_list_str, *comm_list_str, *sym_list_str, | ||
37 | *col_width_list_str; | ||
38 | static struct strlist *dso_list, *comm_list, *sym_list; | ||
39 | |||
40 | static int force; | 36 | static int force; |
41 | static bool use_callchain; | 37 | static bool use_callchain; |
42 | 38 | ||
@@ -365,8 +361,9 @@ static size_t hist_entry__fprintf(FILE *fp, struct hist_entry *self, | |||
365 | 361 | ||
366 | static void dso__calc_col_width(struct dso *self) | 362 | static void dso__calc_col_width(struct dso *self) |
367 | { | 363 | { |
368 | if (!col_width_list_str && !field_sep && | 364 | if (!symbol_conf.col_width_list_str && !field_sep && |
369 | (!dso_list || strlist__has_entry(dso_list, self->name))) { | 365 | (!symbol_conf.dso_list || |
366 | strlist__has_entry(symbol_conf.dso_list, self->name))) { | ||
370 | unsigned int slen = strlen(self->name); | 367 | unsigned int slen = strlen(self->name); |
371 | if (slen > dsos__col_width) | 368 | if (slen > dsos__col_width) |
372 | dsos__col_width = slen; | 369 | dsos__col_width = slen; |
@@ -379,8 +376,9 @@ static void thread__comm_adjust(struct thread *self) | |||
379 | { | 376 | { |
380 | char *comm = self->comm; | 377 | char *comm = self->comm; |
381 | 378 | ||
382 | if (!col_width_list_str && !field_sep && | 379 | if (!symbol_conf.col_width_list_str && !field_sep && |
383 | (!comm_list || strlist__has_entry(comm_list, comm))) { | 380 | (!symbol_conf.comm_list || |
381 | strlist__has_entry(symbol_conf.comm_list, comm))) { | ||
384 | unsigned int slen = strlen(comm); | 382 | unsigned int slen = strlen(comm); |
385 | 383 | ||
386 | if (slen > comms__col_width) { | 384 | if (slen > comms__col_width) { |
@@ -442,7 +440,7 @@ static size_t perf_session__fprintf_hist_entries(struct perf_session *self, | |||
442 | struct rb_node *nd; | 440 | struct rb_node *nd; |
443 | size_t ret = 0; | 441 | size_t ret = 0; |
444 | unsigned int width; | 442 | unsigned int width; |
445 | char *col_width = col_width_list_str; | 443 | char *col_width = symbol_conf.col_width_list_str; |
446 | int raw_printing_style; | 444 | int raw_printing_style; |
447 | 445 | ||
448 | raw_printing_style = !strcmp(pretty_printing_style, "raw"); | 446 | raw_printing_style = !strcmp(pretty_printing_style, "raw"); |
@@ -468,7 +466,7 @@ static size_t perf_session__fprintf_hist_entries(struct perf_session *self, | |||
468 | } | 466 | } |
469 | width = strlen(se->header); | 467 | width = strlen(se->header); |
470 | if (se->width) { | 468 | if (se->width) { |
471 | if (col_width_list_str) { | 469 | if (symbol_conf.col_width_list_str) { |
472 | if (col_width) { | 470 | if (col_width) { |
473 | *se->width = atoi(col_width); | 471 | *se->width = atoi(col_width); |
474 | col_width = strchr(col_width, ','); | 472 | col_width = strchr(col_width, ','); |
@@ -587,7 +585,8 @@ static int process_sample_event(event_t *event, struct perf_session *session) | |||
587 | 585 | ||
588 | dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid); | 586 | dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid); |
589 | 587 | ||
590 | if (comm_list && !strlist__has_entry(comm_list, thread->comm)) | 588 | if (symbol_conf.comm_list && |
589 | !strlist__has_entry(symbol_conf.comm_list, thread->comm)) | ||
591 | return 0; | 590 | return 0; |
592 | 591 | ||
593 | cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; | 592 | cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; |
@@ -601,14 +600,15 @@ static int process_sample_event(event_t *event, struct perf_session *session) | |||
601 | if (al.map && !sort_dso.elide && !al.map->dso->slen_calculated) | 600 | if (al.map && !sort_dso.elide && !al.map->dso->slen_calculated) |
602 | dso__calc_col_width(al.map->dso); | 601 | dso__calc_col_width(al.map->dso); |
603 | 602 | ||
604 | if (dso_list && | 603 | if (symbol_conf.dso_list && |
605 | (!al.map || !al.map->dso || | 604 | (!al.map || !al.map->dso || |
606 | !(strlist__has_entry(dso_list, al.map->dso->short_name) || | 605 | !(strlist__has_entry(symbol_conf.dso_list, al.map->dso->short_name) || |
607 | (al.map->dso->short_name != al.map->dso->long_name && | 606 | (al.map->dso->short_name != al.map->dso->long_name && |
608 | strlist__has_entry(dso_list, al.map->dso->long_name))))) | 607 | strlist__has_entry(symbol_conf.dso_list, al.map->dso->long_name))))) |
609 | return 0; | 608 | return 0; |
610 | 609 | ||
611 | if (sym_list && al.sym && !strlist__has_entry(sym_list, al.sym->name)) | 610 | if (symbol_conf.sym_list && al.sym && |
611 | !strlist__has_entry(symbol_conf.sym_list, al.sym->name)) | ||
612 | return 0; | 612 | return 0; |
613 | 613 | ||
614 | if (perf_session__add_hist_entry(session, &al, data.callchain, data.period)) { | 614 | if (perf_session__add_hist_entry(session, &al, data.callchain, data.period)) { |
@@ -825,13 +825,13 @@ static const struct option options[] = { | |||
825 | OPT_CALLBACK_DEFAULT('g', "call-graph", NULL, "output_type,min_percent", | 825 | OPT_CALLBACK_DEFAULT('g', "call-graph", NULL, "output_type,min_percent", |
826 | "Display callchains using output_type and min percent threshold. " | 826 | "Display callchains using output_type and min percent threshold. " |
827 | "Default: fractal,0.5", &parse_callchain_opt, callchain_default_opt), | 827 | "Default: fractal,0.5", &parse_callchain_opt, callchain_default_opt), |
828 | OPT_STRING('d', "dsos", &dso_list_str, "dso[,dso...]", | 828 | OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]", |
829 | "only consider symbols in these dsos"), | 829 | "only consider symbols in these dsos"), |
830 | OPT_STRING('C', "comms", &comm_list_str, "comm[,comm...]", | 830 | OPT_STRING('C', "comms", &symbol_conf.comm_list_str, "comm[,comm...]", |
831 | "only consider symbols in these comms"), | 831 | "only consider symbols in these comms"), |
832 | OPT_STRING('S', "symbols", &sym_list_str, "symbol[,symbol...]", | 832 | OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]", |
833 | "only consider these symbols"), | 833 | "only consider these symbols"), |
834 | OPT_STRING('w', "column-widths", &col_width_list_str, | 834 | OPT_STRING('w', "column-widths", &symbol_conf.col_width_list_str, |
835 | "width[,width...]", | 835 | "width[,width...]", |
836 | "don't try to adjust column width, use these fixed values"), | 836 | "don't try to adjust column width, use these fixed values"), |
837 | OPT_STRING('t', "field-separator", &field_sep, "separator", | 837 | OPT_STRING('t', "field-separator", &field_sep, "separator", |
@@ -840,32 +840,25 @@ static const struct option options[] = { | |||
840 | OPT_END() | 840 | OPT_END() |
841 | }; | 841 | }; |
842 | 842 | ||
843 | static void setup_list(struct strlist **list, const char *list_str, | 843 | static void sort_entry__setup_elide(struct sort_entry *self, |
844 | struct sort_entry *se, const char *list_name, | 844 | struct strlist *list, |
845 | FILE *fp) | 845 | const char *list_name, FILE *fp) |
846 | { | 846 | { |
847 | if (list_str) { | 847 | if (list && strlist__nr_entries(list) == 1) { |
848 | *list = strlist__new(true, list_str); | 848 | fprintf(fp, "# %s: %s\n", list_name, strlist__entry(list, 0)->s); |
849 | if (!*list) { | 849 | self->elide = true; |
850 | fprintf(stderr, "problems parsing %s list\n", | ||
851 | list_name); | ||
852 | exit(129); | ||
853 | } | ||
854 | if (strlist__nr_entries(*list) == 1) { | ||
855 | fprintf(fp, "# %s: %s\n", list_name, | ||
856 | strlist__entry(*list, 0)->s); | ||
857 | se->elide = true; | ||
858 | } | ||
859 | } | 850 | } |
860 | } | 851 | } |
861 | 852 | ||
862 | int cmd_report(int argc, const char **argv, const char *prefix __used) | 853 | int cmd_report(int argc, const char **argv, const char *prefix __used) |
863 | { | 854 | { |
855 | argc = parse_options(argc, argv, options, report_usage, 0); | ||
856 | |||
857 | setup_pager(); | ||
858 | |||
864 | if (symbol__init() < 0) | 859 | if (symbol__init() < 0) |
865 | return -1; | 860 | return -1; |
866 | 861 | ||
867 | argc = parse_options(argc, argv, options, report_usage, 0); | ||
868 | |||
869 | setup_sorting(report_usage, options); | 862 | setup_sorting(report_usage, options); |
870 | 863 | ||
871 | if (parent_pattern != default_parent_pattern) { | 864 | if (parent_pattern != default_parent_pattern) { |
@@ -880,11 +873,9 @@ int cmd_report(int argc, const char **argv, const char *prefix __used) | |||
880 | if (argc) | 873 | if (argc) |
881 | usage_with_options(report_usage, options); | 874 | usage_with_options(report_usage, options); |
882 | 875 | ||
883 | setup_pager(); | 876 | sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list, "dso", stdout); |
884 | 877 | sort_entry__setup_elide(&sort_comm, symbol_conf.comm_list, "comm", stdout); | |
885 | setup_list(&dso_list, dso_list_str, &sort_dso, "dso", stdout); | 878 | sort_entry__setup_elide(&sort_sym, symbol_conf.sym_list, "symbol", stdout); |
886 | setup_list(&comm_list, comm_list_str, &sort_comm, "comm", stdout); | ||
887 | setup_list(&sym_list, sym_list_str, &sort_sym, "symbol", stdout); | ||
888 | 879 | ||
889 | if (field_sep && *field_sep == '.') { | 880 | if (field_sep && *field_sep == '.') { |
890 | fputs("'.' is the only non valid --field-separator argument\n", | 881 | fputs("'.' is the only non valid --field-separator argument\n", |