aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2009-12-15 17:04:40 -0500
committerIngo Molnar <mingo@elte.hu>2009-12-16 02:53:49 -0500
commit655000e7c75a559681ee7f15f6fa870c80ae3194 (patch)
tree69a56e19c818b0929dbea8d119fa133853c5ee80 /tools
parent75be6cf48738aec68aac49b428423569492cfba3 (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')
-rw-r--r--tools/perf/builtin-annotate.c4
-rw-r--r--tools/perf/builtin-diff.c9
-rw-r--r--tools/perf/builtin-kmem.c4
-rw-r--r--tools/perf/builtin-record.c6
-rw-r--r--tools/perf/builtin-report.c73
-rw-r--r--tools/perf/builtin-timechart.c4
-rw-r--r--tools/perf/builtin-trace.c4
-rw-r--r--tools/perf/util/symbol.c33
-rw-r--r--tools/perf/util/symbol.h9
9 files changed, 89 insertions, 57 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index e656e25f1c14..645d58058431 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -518,14 +518,14 @@ static const struct option options[] = {
518 518
519int cmd_annotate(int argc, const char **argv, const char *prefix __used) 519int cmd_annotate(int argc, const char **argv, const char *prefix __used)
520{ 520{
521 argc = parse_options(argc, argv, options, annotate_usage, 0);
522
521 symbol_conf.priv_size = sizeof(struct sym_priv); 523 symbol_conf.priv_size = sizeof(struct sym_priv);
522 symbol_conf.try_vmlinux_path = true; 524 symbol_conf.try_vmlinux_path = true;
523 525
524 if (symbol__init() < 0) 526 if (symbol__init() < 0)
525 return -1; 527 return -1;
526 528
527 argc = parse_options(argc, argv, options, annotate_usage, 0);
528
529 setup_sorting(annotate_usage, options); 529 setup_sorting(annotate_usage, options);
530 530
531 if (argc) { 531 if (argc) {
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 67328d106994..4fde60655341 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -265,11 +265,6 @@ static const struct option options[] = {
265 265
266int cmd_diff(int argc, const char **argv, const char *prefix __used) 266int cmd_diff(int argc, const char **argv, const char *prefix __used)
267{ 267{
268 if (symbol__init() < 0)
269 return -1;
270
271 setup_sorting(diff_usage, options);
272
273 argc = parse_options(argc, argv, options, diff_usage, 0); 268 argc = parse_options(argc, argv, options, diff_usage, 0);
274 if (argc) { 269 if (argc) {
275 if (argc > 2) 270 if (argc > 2)
@@ -281,6 +276,10 @@ int cmd_diff(int argc, const char **argv, const char *prefix __used)
281 input_new = argv[0]; 276 input_new = argv[0];
282 } 277 }
283 278
279 if (symbol__init() < 0)
280 return -1;
281
282 setup_sorting(diff_usage, options);
284 setup_pager(); 283 setup_pager();
285 return __cmd_diff(); 284 return __cmd_diff();
286} 285}
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index e078797ab1f1..fc21ad79dd83 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -766,13 +766,13 @@ static int __cmd_record(int argc, const char **argv)
766 766
767int cmd_kmem(int argc, const char **argv, const char *prefix __used) 767int cmd_kmem(int argc, const char **argv, const char *prefix __used)
768{ 768{
769 symbol__init();
770
771 argc = parse_options(argc, argv, kmem_options, kmem_usage, 0); 769 argc = parse_options(argc, argv, kmem_options, kmem_usage, 0);
772 770
773 if (!argc) 771 if (!argc)
774 usage_with_options(kmem_usage, kmem_options); 772 usage_with_options(kmem_usage, kmem_options);
775 773
774 symbol__init();
775
776 if (!strncmp(argv[0], "rec", 3)) { 776 if (!strncmp(argv[0], "rec", 3)) {
777 return __cmd_record(argc, argv); 777 return __cmd_record(argc, argv);
778 } else if (!strcmp(argv[0], "stat")) { 778 } else if (!strcmp(argv[0], "stat")) {
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 1da48a8fe9cc..65301c5ca1de 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -632,13 +632,13 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
632{ 632{
633 int counter; 633 int counter;
634 634
635 symbol__init();
636
637 argc = parse_options(argc, argv, options, record_usage, 635 argc = parse_options(argc, argv, options, record_usage,
638 PARSE_OPT_STOP_AT_NON_OPTION); 636 PARSE_OPT_STOP_AT_NON_OPTION);
639 if (!argc && target_pid == -1 && !system_wide) 637 if (!argc && target_pid == -1 && !system_wide)
640 usage_with_options(record_usage, options); 638 usage_with_options(record_usage, options);
641 639
640 symbol__init();
641
642 if (!nr_counters) { 642 if (!nr_counters) {
643 nr_counters = 1; 643 nr_counters = 1;
644 attrs[0].type = PERF_TYPE_HARDWARE; 644 attrs[0].type = PERF_TYPE_HARDWARE;
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
34static char const *input_name = "perf.data"; 34static char const *input_name = "perf.data";
35 35
36static char *dso_list_str, *comm_list_str, *sym_list_str,
37 *col_width_list_str;
38static struct strlist *dso_list, *comm_list, *sym_list;
39
40static int force; 36static int force;
41static bool use_callchain; 37static bool use_callchain;
42 38
@@ -365,8 +361,9 @@ static size_t hist_entry__fprintf(FILE *fp, struct hist_entry *self,
365 361
366static void dso__calc_col_width(struct dso *self) 362static 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
843static void setup_list(struct strlist **list, const char *list_str, 843static 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
862int cmd_report(int argc, const char **argv, const char *prefix __used) 853int 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",
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index 9c98b7a2b19a..a589a43112d6 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -1137,11 +1137,11 @@ static const struct option options[] = {
1137 1137
1138int cmd_timechart(int argc, const char **argv, const char *prefix __used) 1138int cmd_timechart(int argc, const char **argv, const char *prefix __used)
1139{ 1139{
1140 symbol__init();
1141
1142 argc = parse_options(argc, argv, options, timechart_usage, 1140 argc = parse_options(argc, argv, options, timechart_usage,
1143 PARSE_OPT_STOP_AT_NON_OPTION); 1141 PARSE_OPT_STOP_AT_NON_OPTION);
1144 1142
1143 symbol__init();
1144
1145 if (argc && !strncmp(argv[0], "rec", 3)) 1145 if (argc && !strncmp(argv[0], "rec", 3))
1146 return __cmd_record(argc, argv); 1146 return __cmd_record(argc, argv);
1147 else if (argc) 1147 else if (argc)
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 07ad25ca654f..e2285e28720f 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -579,13 +579,13 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used)
579 exit(-1); 579 exit(-1);
580 } 580 }
581 581
582 symbol__init();
583
584 setup_scripting(); 582 setup_scripting();
585 583
586 argc = parse_options(argc, argv, options, annotate_usage, 584 argc = parse_options(argc, argv, options, annotate_usage,
587 PARSE_OPT_STOP_AT_NON_OPTION); 585 PARSE_OPT_STOP_AT_NON_OPTION);
588 586
587 if (symbol__init() < 0)
588 return -1;
589 setup_pager(); 589 setup_pager();
590 590
591 session = perf_session__new(input_name, O_RDONLY, 0); 591 session = perf_session__new(input_name, O_RDONLY, 0);
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 17ce01269a91..164286ace7df 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1,6 +1,7 @@
1#include "util.h" 1#include "util.h"
2#include "../perf.h" 2#include "../perf.h"
3#include "session.h" 3#include "session.h"
4#include "sort.h"
4#include "string.h" 5#include "string.h"
5#include "symbol.h" 6#include "symbol.h"
6#include "thread.h" 7#include "thread.h"
@@ -1739,6 +1740,20 @@ out_fail:
1739 return -1; 1740 return -1;
1740} 1741}
1741 1742
1743static int setup_list(struct strlist **list, const char *list_str,
1744 const char *list_name)
1745{
1746 if (list_str == NULL)
1747 return 0;
1748
1749 *list = strlist__new(true, list_str);
1750 if (!*list) {
1751 pr_err("problems parsing %s list\n", list_name);
1752 return -1;
1753 }
1754 return 0;
1755}
1756
1742int symbol__init(void) 1757int symbol__init(void)
1743{ 1758{
1744 elf_version(EV_CURRENT); 1759 elf_version(EV_CURRENT);
@@ -1749,7 +1764,25 @@ int symbol__init(void)
1749 if (symbol_conf.try_vmlinux_path && vmlinux_path__init() < 0) 1764 if (symbol_conf.try_vmlinux_path && vmlinux_path__init() < 0)
1750 return -1; 1765 return -1;
1751 1766
1767 if (setup_list(&symbol_conf.dso_list,
1768 symbol_conf.dso_list_str, "dso") < 0)
1769 return -1;
1770
1771 if (setup_list(&symbol_conf.comm_list,
1772 symbol_conf.comm_list_str, "comm") < 0)
1773 goto out_free_dso_list;
1774
1775 if (setup_list(&symbol_conf.sym_list,
1776 symbol_conf.sym_list_str, "symbol") < 0)
1777 goto out_free_comm_list;
1778
1752 return 0; 1779 return 0;
1780
1781out_free_dso_list:
1782 strlist__delete(symbol_conf.dso_list);
1783out_free_comm_list:
1784 strlist__delete(symbol_conf.comm_list);
1785 return -1;
1753} 1786}
1754 1787
1755int perf_session__create_kernel_maps(struct perf_session *self) 1788int perf_session__create_kernel_maps(struct perf_session *self)
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 766294735f93..d61f35074997 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -49,12 +49,21 @@ struct symbol {
49 char name[0]; 49 char name[0];
50}; 50};
51 51
52struct strlist;
53
52struct symbol_conf { 54struct symbol_conf {
53 unsigned short priv_size; 55 unsigned short priv_size;
54 bool try_vmlinux_path, 56 bool try_vmlinux_path,
55 use_modules, 57 use_modules,
56 sort_by_name; 58 sort_by_name;
57 const char *vmlinux_name; 59 const char *vmlinux_name;
60 char *dso_list_str,
61 *comm_list_str,
62 *sym_list_str,
63 *col_width_list_str;
64 struct strlist *dso_list,
65 *comm_list,
66 *sym_list;
58}; 67};
59 68
60extern struct symbol_conf symbol_conf; 69extern struct symbol_conf symbol_conf;