diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-12-15 17:04:39 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-12-16 02:53:48 -0500 |
commit | 75be6cf48738aec68aac49b428423569492cfba3 (patch) | |
tree | d7f5ceb028361e8b725ba6f3b8219e66c7b89790 /tools/perf | |
parent | 7ef17aafc98406d01ebbf7fe98ef1332b70d20bb (diff) |
perf symbols: Make symbol_conf global
This simplifies a lot of functions, less stuff to be done by
tool writers.
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-1-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/builtin-annotate.c | 14 | ||||
-rw-r--r-- | tools/perf/builtin-buildid-list.c | 5 | ||||
-rw-r--r-- | tools/perf/builtin-diff.c | 8 | ||||
-rw-r--r-- | tools/perf/builtin-kmem.c | 5 | ||||
-rw-r--r-- | tools/perf/builtin-probe.c | 14 | ||||
-rw-r--r-- | tools/perf/builtin-record.c | 4 | ||||
-rw-r--r-- | tools/perf/builtin-report.c | 7 | ||||
-rw-r--r-- | tools/perf/builtin-sched.c | 5 | ||||
-rw-r--r-- | tools/perf/builtin-timechart.c | 5 | ||||
-rw-r--r-- | tools/perf/builtin-top.c | 6 | ||||
-rw-r--r-- | tools/perf/builtin-trace.c | 4 | ||||
-rw-r--r-- | tools/perf/util/session.c | 5 | ||||
-rw-r--r-- | tools/perf/util/session.h | 5 | ||||
-rw-r--r-- | tools/perf/util/symbol.c | 38 | ||||
-rw-r--r-- | tools/perf/util/symbol.h | 9 |
15 files changed, 54 insertions, 80 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 2e2855a685c6..e656e25f1c14 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c | |||
@@ -51,11 +51,6 @@ struct sym_priv { | |||
51 | struct sym_ext *ext; | 51 | struct sym_ext *ext; |
52 | }; | 52 | }; |
53 | 53 | ||
54 | static struct symbol_conf symbol_conf = { | ||
55 | .priv_size = sizeof(struct sym_priv), | ||
56 | .try_vmlinux_path = true, | ||
57 | }; | ||
58 | |||
59 | static const char *sym_hist_filter; | 54 | static const char *sym_hist_filter; |
60 | 55 | ||
61 | static int symbol_filter(struct map *map __used, struct symbol *sym) | 56 | static int symbol_filter(struct map *map __used, struct symbol *sym) |
@@ -464,10 +459,10 @@ static struct perf_event_ops event_ops = { | |||
464 | 459 | ||
465 | static int __cmd_annotate(void) | 460 | static int __cmd_annotate(void) |
466 | { | 461 | { |
467 | struct perf_session *session = perf_session__new(input_name, O_RDONLY, | ||
468 | force, &symbol_conf); | ||
469 | int ret; | 462 | int ret; |
463 | struct perf_session *session; | ||
470 | 464 | ||
465 | session = perf_session__new(input_name, O_RDONLY, force); | ||
471 | if (session == NULL) | 466 | if (session == NULL) |
472 | return -ENOMEM; | 467 | return -ENOMEM; |
473 | 468 | ||
@@ -523,7 +518,10 @@ static const struct option options[] = { | |||
523 | 518 | ||
524 | int cmd_annotate(int argc, const char **argv, const char *prefix __used) | 519 | int cmd_annotate(int argc, const char **argv, const char *prefix __used) |
525 | { | 520 | { |
526 | if (symbol__init(&symbol_conf) < 0) | 521 | symbol_conf.priv_size = sizeof(struct sym_priv); |
522 | symbol_conf.try_vmlinux_path = true; | ||
523 | |||
524 | if (symbol__init() < 0) | ||
527 | return -1; | 525 | return -1; |
528 | 526 | ||
529 | argc = parse_options(argc, argv, options, annotate_usage, 0); | 527 | argc = parse_options(argc, argv, options, annotate_usage, 0); |
diff --git a/tools/perf/builtin-buildid-list.c b/tools/perf/builtin-buildid-list.c index 7c36e4b2eccf..e693e6777af5 100644 --- a/tools/perf/builtin-buildid-list.c +++ b/tools/perf/builtin-buildid-list.c | |||
@@ -54,8 +54,9 @@ static int perf_file_section__process_buildids(struct perf_file_section *self, | |||
54 | static int __cmd_buildid_list(void) | 54 | static int __cmd_buildid_list(void) |
55 | { | 55 | { |
56 | int err = -1; | 56 | int err = -1; |
57 | struct perf_session *session = perf_session__new(input_name, O_RDONLY, | 57 | struct perf_session *session; |
58 | force, NULL); | 58 | |
59 | session = perf_session__new(input_name, O_RDONLY, force); | ||
59 | if (session == NULL) | 60 | if (session == NULL) |
60 | return -1; | 61 | return -1; |
61 | 62 | ||
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 0d528018ffb8..67328d106994 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c | |||
@@ -21,8 +21,6 @@ static char const *input_old = "perf.data.old", | |||
21 | static int force; | 21 | static int force; |
22 | static bool show_percent; | 22 | static bool show_percent; |
23 | 23 | ||
24 | struct symbol_conf symbol_conf; | ||
25 | |||
26 | static int perf_session__add_hist_entry(struct perf_session *self, | 24 | static int perf_session__add_hist_entry(struct perf_session *self, |
27 | struct addr_location *al, u64 count) | 25 | struct addr_location *al, u64 count) |
28 | { | 26 | { |
@@ -226,8 +224,8 @@ static int __cmd_diff(void) | |||
226 | int ret, i; | 224 | int ret, i; |
227 | struct perf_session *session[2]; | 225 | struct perf_session *session[2]; |
228 | 226 | ||
229 | session[0] = perf_session__new(input_old, O_RDONLY, force, &symbol_conf); | 227 | session[0] = perf_session__new(input_old, O_RDONLY, force); |
230 | session[1] = perf_session__new(input_new, O_RDONLY, force, &symbol_conf); | 228 | session[1] = perf_session__new(input_new, O_RDONLY, force); |
231 | if (session[0] == NULL || session[1] == NULL) | 229 | if (session[0] == NULL || session[1] == NULL) |
232 | return -ENOMEM; | 230 | return -ENOMEM; |
233 | 231 | ||
@@ -267,7 +265,7 @@ static const struct option options[] = { | |||
267 | 265 | ||
268 | int cmd_diff(int argc, const char **argv, const char *prefix __used) | 266 | int cmd_diff(int argc, const char **argv, const char *prefix __used) |
269 | { | 267 | { |
270 | if (symbol__init(&symbol_conf) < 0) | 268 | if (symbol__init() < 0) |
271 | return -1; | 269 | return -1; |
272 | 270 | ||
273 | setup_sorting(diff_usage, options); | 271 | setup_sorting(diff_usage, options); |
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index dda60869faad..e078797ab1f1 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c | |||
@@ -505,8 +505,7 @@ static void sort_result(void) | |||
505 | static int __cmd_kmem(void) | 505 | static int __cmd_kmem(void) |
506 | { | 506 | { |
507 | int err; | 507 | int err; |
508 | struct perf_session *session = perf_session__new(input_name, O_RDONLY, | 508 | struct perf_session *session = perf_session__new(input_name, O_RDONLY, 0); |
509 | 0, NULL); | ||
510 | if (session == NULL) | 509 | if (session == NULL) |
511 | return -ENOMEM; | 510 | return -ENOMEM; |
512 | 511 | ||
@@ -767,7 +766,7 @@ static int __cmd_record(int argc, const char **argv) | |||
767 | 766 | ||
768 | int cmd_kmem(int argc, const char **argv, const char *prefix __used) | 767 | int cmd_kmem(int argc, const char **argv, const char *prefix __used) |
769 | { | 768 | { |
770 | symbol__init(0); | 769 | symbol__init(); |
771 | 770 | ||
772 | argc = parse_options(argc, argv, kmem_options, kmem_usage, 0); | 771 | argc = parse_options(argc, argv, kmem_options, kmem_usage, 0); |
773 | 772 | ||
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c index 520b064b46d8..7e741f54d798 100644 --- a/tools/perf/builtin-probe.c +++ b/tools/perf/builtin-probe.c | |||
@@ -57,7 +57,6 @@ static struct { | |||
57 | int nr_probe; | 57 | int nr_probe; |
58 | struct probe_point probes[MAX_PROBES]; | 58 | struct probe_point probes[MAX_PROBES]; |
59 | struct strlist *dellist; | 59 | struct strlist *dellist; |
60 | struct symbol_conf conf; | ||
61 | struct perf_session *psession; | 60 | struct perf_session *psession; |
62 | struct map *kmap; | 61 | struct map *kmap; |
63 | } session; | 62 | } session; |
@@ -151,7 +150,7 @@ static const struct option options[] = { | |||
151 | OPT_BOOLEAN('v', "verbose", &verbose, | 150 | OPT_BOOLEAN('v', "verbose", &verbose, |
152 | "be more verbose (show parsed arguments, etc)"), | 151 | "be more verbose (show parsed arguments, etc)"), |
153 | #ifndef NO_LIBDWARF | 152 | #ifndef NO_LIBDWARF |
154 | OPT_STRING('k', "vmlinux", &session.conf.vmlinux_name, | 153 | OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name, |
155 | "file", "vmlinux pathname"), | 154 | "file", "vmlinux pathname"), |
156 | #endif | 155 | #endif |
157 | OPT_BOOLEAN('l', "list", &session.list_events, | 156 | OPT_BOOLEAN('l', "list", &session.list_events, |
@@ -224,13 +223,12 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used) | |||
224 | } | 223 | } |
225 | 224 | ||
226 | /* Initialize symbol maps for vmlinux */ | 225 | /* Initialize symbol maps for vmlinux */ |
227 | session.conf.sort_by_name = true; | 226 | symbol_conf.sort_by_name = true; |
228 | if (session.conf.vmlinux_name == NULL) | 227 | if (symbol_conf.vmlinux_name == NULL) |
229 | session.conf.try_vmlinux_path = true; | 228 | symbol_conf.try_vmlinux_path = true; |
230 | if (symbol__init(&session.conf) < 0) | 229 | if (symbol__init() < 0) |
231 | die("Failed to init symbol map."); | 230 | die("Failed to init symbol map."); |
232 | session.psession = perf_session__new(NULL, O_WRONLY, false, | 231 | session.psession = perf_session__new(NULL, O_WRONLY, false); |
233 | &session.conf); | ||
234 | if (session.psession == NULL) | 232 | if (session.psession == NULL) |
235 | die("Failed to init perf_session."); | 233 | die("Failed to init perf_session."); |
236 | session.kmap = map_groups__find_by_name(&session.psession->kmaps, | 234 | session.kmap = map_groups__find_by_name(&session.psession->kmaps, |
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 66979a5553b8..1da48a8fe9cc 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -451,7 +451,7 @@ static int __cmd_record(int argc, const char **argv) | |||
451 | exit(-1); | 451 | exit(-1); |
452 | } | 452 | } |
453 | 453 | ||
454 | session = perf_session__new(output_name, O_WRONLY, force, NULL); | 454 | session = perf_session__new(output_name, O_WRONLY, force); |
455 | if (session == NULL) { | 455 | if (session == NULL) { |
456 | pr_err("Not enough memory for reading perf file header\n"); | 456 | pr_err("Not enough memory for reading perf file header\n"); |
457 | return -1; | 457 | return -1; |
@@ -632,7 +632,7 @@ 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(0); | 635 | symbol__init(); |
636 | 636 | ||
637 | argc = parse_options(argc, argv, options, record_usage, | 637 | argc = parse_options(argc, argv, options, record_usage, |
638 | PARSE_OPT_STOP_AT_NON_OPTION); | 638 | PARSE_OPT_STOP_AT_NON_OPTION); |
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 40389c0e38c6..c349bdbb9474 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -52,9 +52,6 @@ static int exclude_other = 1; | |||
52 | 52 | ||
53 | static char callchain_default_opt[] = "fractal,0.5"; | 53 | static char callchain_default_opt[] = "fractal,0.5"; |
54 | 54 | ||
55 | static struct symbol_conf symbol_conf; | ||
56 | |||
57 | |||
58 | static size_t | 55 | static size_t |
59 | callchain__fprintf_left_margin(FILE *fp, int left_margin) | 56 | callchain__fprintf_left_margin(FILE *fp, int left_margin) |
60 | { | 57 | { |
@@ -705,7 +702,7 @@ static int __cmd_report(void) | |||
705 | int ret; | 702 | int ret; |
706 | struct perf_session *session; | 703 | struct perf_session *session; |
707 | 704 | ||
708 | session = perf_session__new(input_name, O_RDONLY, force, &symbol_conf); | 705 | session = perf_session__new(input_name, O_RDONLY, force); |
709 | if (session == NULL) | 706 | if (session == NULL) |
710 | return -ENOMEM; | 707 | return -ENOMEM; |
711 | 708 | ||
@@ -864,7 +861,7 @@ static void setup_list(struct strlist **list, const char *list_str, | |||
864 | 861 | ||
865 | int cmd_report(int argc, const char **argv, const char *prefix __used) | 862 | int cmd_report(int argc, const char **argv, const char *prefix __used) |
866 | { | 863 | { |
867 | if (symbol__init(&symbol_conf) < 0) | 864 | if (symbol__init() < 0) |
868 | return -1; | 865 | return -1; |
869 | 866 | ||
870 | argc = parse_options(argc, argv, options, report_usage, 0); | 867 | argc = parse_options(argc, argv, options, report_usage, 0); |
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index d67f274adba0..80209df6cfe8 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c | |||
@@ -1675,8 +1675,7 @@ static struct perf_event_ops event_ops = { | |||
1675 | static int read_events(void) | 1675 | static int read_events(void) |
1676 | { | 1676 | { |
1677 | int err; | 1677 | int err; |
1678 | struct perf_session *session = perf_session__new(input_name, O_RDONLY, | 1678 | struct perf_session *session = perf_session__new(input_name, O_RDONLY, 0); |
1679 | 0, NULL); | ||
1680 | if (session == NULL) | 1679 | if (session == NULL) |
1681 | return -ENOMEM; | 1680 | return -ENOMEM; |
1682 | 1681 | ||
@@ -1912,7 +1911,7 @@ int cmd_sched(int argc, const char **argv, const char *prefix __used) | |||
1912 | if (!strcmp(argv[0], "trace")) | 1911 | if (!strcmp(argv[0], "trace")) |
1913 | return cmd_trace(argc, argv, prefix); | 1912 | return cmd_trace(argc, argv, prefix); |
1914 | 1913 | ||
1915 | symbol__init(0); | 1914 | symbol__init(); |
1916 | if (!strncmp(argv[0], "rec", 3)) { | 1915 | if (!strncmp(argv[0], "rec", 3)) { |
1917 | return __cmd_record(argc, argv); | 1916 | return __cmd_record(argc, argv); |
1918 | } else if (!strncmp(argv[0], "lat", 3)) { | 1917 | } else if (!strncmp(argv[0], "lat", 3)) { |
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index ffd81e87ce69..9c98b7a2b19a 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c | |||
@@ -1050,8 +1050,7 @@ static struct perf_event_ops event_ops = { | |||
1050 | 1050 | ||
1051 | static int __cmd_timechart(void) | 1051 | static int __cmd_timechart(void) |
1052 | { | 1052 | { |
1053 | struct perf_session *session = perf_session__new(input_name, O_RDONLY, | 1053 | struct perf_session *session = perf_session__new(input_name, O_RDONLY, 0); |
1054 | 0, NULL); | ||
1055 | int ret; | 1054 | int ret; |
1056 | 1055 | ||
1057 | if (session == NULL) | 1056 | if (session == NULL) |
@@ -1138,7 +1137,7 @@ static const struct option options[] = { | |||
1138 | 1137 | ||
1139 | int cmd_timechart(int argc, const char **argv, const char *prefix __used) | 1138 | int cmd_timechart(int argc, const char **argv, const char *prefix __used) |
1140 | { | 1139 | { |
1141 | symbol__init(0); | 1140 | symbol__init(); |
1142 | 1141 | ||
1143 | argc = parse_options(argc, argv, options, timechart_usage, | 1142 | argc = parse_options(argc, argv, options, timechart_usage, |
1144 | PARSE_OPT_STOP_AT_NON_OPTION); | 1143 | PARSE_OPT_STOP_AT_NON_OPTION); |
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 296e809c2538..cd89b6d036b7 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -80,7 +80,6 @@ static int dump_symtab = 0; | |||
80 | static bool hide_kernel_symbols = false; | 80 | static bool hide_kernel_symbols = false; |
81 | static bool hide_user_symbols = false; | 81 | static bool hide_user_symbols = false; |
82 | static struct winsize winsize; | 82 | static struct winsize winsize; |
83 | static struct symbol_conf symbol_conf; | ||
84 | 83 | ||
85 | /* | 84 | /* |
86 | * Source | 85 | * Source |
@@ -1162,8 +1161,7 @@ static int __cmd_top(void) | |||
1162 | * FIXME: perf_session__new should allow passing a O_MMAP, so that all this | 1161 | * FIXME: perf_session__new should allow passing a O_MMAP, so that all this |
1163 | * mmap reading, etc is encapsulated in it. Use O_WRONLY for now. | 1162 | * mmap reading, etc is encapsulated in it. Use O_WRONLY for now. |
1164 | */ | 1163 | */ |
1165 | struct perf_session *session = perf_session__new(NULL, O_WRONLY, false, | 1164 | struct perf_session *session = perf_session__new(NULL, O_WRONLY, false); |
1166 | &symbol_conf); | ||
1167 | if (session == NULL) | 1165 | if (session == NULL) |
1168 | return -ENOMEM; | 1166 | return -ENOMEM; |
1169 | 1167 | ||
@@ -1284,7 +1282,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used) | |||
1284 | (nr_counters + 1) * sizeof(unsigned long)); | 1282 | (nr_counters + 1) * sizeof(unsigned long)); |
1285 | if (symbol_conf.vmlinux_name == NULL) | 1283 | if (symbol_conf.vmlinux_name == NULL) |
1286 | symbol_conf.try_vmlinux_path = true; | 1284 | symbol_conf.try_vmlinux_path = true; |
1287 | if (symbol__init(&symbol_conf) < 0) | 1285 | if (symbol__init() < 0) |
1288 | return -1; | 1286 | return -1; |
1289 | 1287 | ||
1290 | if (delay_secs < 1) | 1288 | if (delay_secs < 1) |
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 7e744f774047..07ad25ca654f 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -579,7 +579,7 @@ 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(0); | 582 | symbol__init(); |
583 | 583 | ||
584 | setup_scripting(); | 584 | setup_scripting(); |
585 | 585 | ||
@@ -588,7 +588,7 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used) | |||
588 | 588 | ||
589 | setup_pager(); | 589 | setup_pager(); |
590 | 590 | ||
591 | session = perf_session__new(input_name, O_RDONLY, 0, NULL); | 591 | session = perf_session__new(input_name, O_RDONLY, 0); |
592 | if (session == NULL) | 592 | if (session == NULL) |
593 | return -ENOMEM; | 593 | return -ENOMEM; |
594 | 594 | ||
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index ecd54bedfb1c..bceaa09f55a1 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -49,8 +49,7 @@ out_close: | |||
49 | return -1; | 49 | return -1; |
50 | } | 50 | } |
51 | 51 | ||
52 | struct perf_session *perf_session__new(const char *filename, int mode, | 52 | struct perf_session *perf_session__new(const char *filename, int mode, bool force) |
53 | bool force, struct symbol_conf *conf) | ||
54 | { | 53 | { |
55 | size_t len = filename ? strlen(filename) + 1 : 0; | 54 | size_t len = filename ? strlen(filename) + 1 : 0; |
56 | struct perf_session *self = zalloc(sizeof(*self) + len); | 55 | struct perf_session *self = zalloc(sizeof(*self) + len); |
@@ -69,7 +68,7 @@ struct perf_session *perf_session__new(const char *filename, int mode, | |||
69 | self->cwdlen = 0; | 68 | self->cwdlen = 0; |
70 | map_groups__init(&self->kmaps); | 69 | map_groups__init(&self->kmaps); |
71 | 70 | ||
72 | if (perf_session__create_kernel_maps(self, conf) < 0) | 71 | if (perf_session__create_kernel_maps(self) < 0) |
73 | goto out_delete; | 72 | goto out_delete; |
74 | 73 | ||
75 | if (mode == O_RDONLY && perf_session__open(self, force) < 0) | 74 | if (mode == O_RDONLY && perf_session__open(self, force) < 0) |
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index bdfc4b8eee7a..faf18a8e0311 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h | |||
@@ -10,7 +10,6 @@ | |||
10 | struct ip_callchain; | 10 | struct ip_callchain; |
11 | struct thread; | 11 | struct thread; |
12 | struct symbol; | 12 | struct symbol; |
13 | struct symbol_conf; | ||
14 | 13 | ||
15 | struct perf_session { | 14 | struct perf_session { |
16 | struct perf_header header; | 15 | struct perf_header header; |
@@ -26,7 +25,6 @@ struct perf_session { | |||
26 | int fd; | 25 | int fd; |
27 | int cwdlen; | 26 | int cwdlen; |
28 | char *cwd; | 27 | char *cwd; |
29 | bool use_modules; | ||
30 | bool use_callchain; | 28 | bool use_callchain; |
31 | char filename[0]; | 29 | char filename[0]; |
32 | }; | 30 | }; |
@@ -48,8 +46,7 @@ struct perf_event_ops { | |||
48 | bool full_paths; | 46 | bool full_paths; |
49 | }; | 47 | }; |
50 | 48 | ||
51 | struct perf_session *perf_session__new(const char *filename, int mode, | 49 | struct perf_session *perf_session__new(const char *filename, int mode, bool force); |
52 | bool force, struct symbol_conf *conf); | ||
53 | void perf_session__delete(struct perf_session *self); | 50 | void perf_session__delete(struct perf_session *self); |
54 | 51 | ||
55 | int perf_session__process_events(struct perf_session *self, | 52 | int perf_session__process_events(struct perf_session *self, |
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 185b9eec192b..17ce01269a91 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -33,11 +33,10 @@ static void dsos__add(struct list_head *head, struct dso *dso); | |||
33 | static struct map *map__new2(u64 start, struct dso *dso, enum map_type type); | 33 | static struct map *map__new2(u64 start, struct dso *dso, enum map_type type); |
34 | static int dso__load_kernel_sym(struct dso *self, struct map *map, | 34 | static int dso__load_kernel_sym(struct dso *self, struct map *map, |
35 | struct perf_session *session, symbol_filter_t filter); | 35 | struct perf_session *session, symbol_filter_t filter); |
36 | unsigned int symbol__priv_size; | ||
37 | static int vmlinux_path__nr_entries; | 36 | static int vmlinux_path__nr_entries; |
38 | static char **vmlinux_path; | 37 | static char **vmlinux_path; |
39 | 38 | ||
40 | static struct symbol_conf symbol_conf__defaults = { | 39 | struct symbol_conf symbol_conf = { |
41 | .use_modules = true, | 40 | .use_modules = true, |
42 | .try_vmlinux_path = true, | 41 | .try_vmlinux_path = true, |
43 | }; | 42 | }; |
@@ -130,13 +129,13 @@ static void map_groups__fixup_end(struct map_groups *self) | |||
130 | static struct symbol *symbol__new(u64 start, u64 len, const char *name) | 129 | static struct symbol *symbol__new(u64 start, u64 len, const char *name) |
131 | { | 130 | { |
132 | size_t namelen = strlen(name) + 1; | 131 | size_t namelen = strlen(name) + 1; |
133 | struct symbol *self = zalloc(symbol__priv_size + | 132 | struct symbol *self = zalloc(symbol_conf.priv_size + |
134 | sizeof(*self) + namelen); | 133 | sizeof(*self) + namelen); |
135 | if (self == NULL) | 134 | if (self == NULL) |
136 | return NULL; | 135 | return NULL; |
137 | 136 | ||
138 | if (symbol__priv_size) | 137 | if (symbol_conf.priv_size) |
139 | self = ((void *)self) + symbol__priv_size; | 138 | self = ((void *)self) + symbol_conf.priv_size; |
140 | 139 | ||
141 | self->start = start; | 140 | self->start = start; |
142 | self->end = len ? start + len - 1 : start; | 141 | self->end = len ? start + len - 1 : start; |
@@ -150,7 +149,7 @@ static struct symbol *symbol__new(u64 start, u64 len, const char *name) | |||
150 | 149 | ||
151 | static void symbol__delete(struct symbol *self) | 150 | static void symbol__delete(struct symbol *self) |
152 | { | 151 | { |
153 | free(((void *)self) - symbol__priv_size); | 152 | free(((void *)self) - symbol_conf.priv_size); |
154 | } | 153 | } |
155 | 154 | ||
156 | static size_t symbol__fprintf(struct symbol *self, FILE *fp) | 155 | static size_t symbol__fprintf(struct symbol *self, FILE *fp) |
@@ -471,7 +470,7 @@ static int dso__split_kallsyms(struct dso *self, struct map *map, | |||
471 | 470 | ||
472 | module = strchr(pos->name, '\t'); | 471 | module = strchr(pos->name, '\t'); |
473 | if (module) { | 472 | if (module) { |
474 | if (!session->use_modules) | 473 | if (!symbol_conf.use_modules) |
475 | goto discard_symbol; | 474 | goto discard_symbol; |
476 | 475 | ||
477 | *module++ = '\0'; | 476 | *module++ = '\0'; |
@@ -1740,34 +1739,27 @@ out_fail: | |||
1740 | return -1; | 1739 | return -1; |
1741 | } | 1740 | } |
1742 | 1741 | ||
1743 | int symbol__init(struct symbol_conf *conf) | 1742 | int symbol__init(void) |
1744 | { | 1743 | { |
1745 | const struct symbol_conf *pconf = conf ?: &symbol_conf__defaults; | ||
1746 | |||
1747 | elf_version(EV_CURRENT); | 1744 | elf_version(EV_CURRENT); |
1748 | symbol__priv_size = pconf->priv_size; | 1745 | if (symbol_conf.sort_by_name) |
1749 | if (pconf->sort_by_name) | 1746 | symbol_conf.priv_size += (sizeof(struct symbol_name_rb_node) - |
1750 | symbol__priv_size += (sizeof(struct symbol_name_rb_node) - | 1747 | sizeof(struct symbol)); |
1751 | sizeof(struct symbol)); | ||
1752 | 1748 | ||
1753 | if (pconf->try_vmlinux_path && vmlinux_path__init() < 0) | 1749 | if (symbol_conf.try_vmlinux_path && vmlinux_path__init() < 0) |
1754 | return -1; | 1750 | return -1; |
1755 | 1751 | ||
1756 | return 0; | 1752 | return 0; |
1757 | } | 1753 | } |
1758 | 1754 | ||
1759 | int perf_session__create_kernel_maps(struct perf_session *self, | 1755 | int perf_session__create_kernel_maps(struct perf_session *self) |
1760 | struct symbol_conf *conf) | ||
1761 | { | 1756 | { |
1762 | const struct symbol_conf *pconf = conf ?: &symbol_conf__defaults; | ||
1763 | |||
1764 | if (map_groups__create_kernel_maps(&self->kmaps, | 1757 | if (map_groups__create_kernel_maps(&self->kmaps, |
1765 | pconf->vmlinux_name) < 0) | 1758 | symbol_conf.vmlinux_name) < 0) |
1766 | return -1; | 1759 | return -1; |
1767 | 1760 | ||
1768 | self->use_modules = pconf->use_modules; | 1761 | if (symbol_conf.use_modules && |
1769 | 1762 | perf_session__create_module_maps(self) < 0) | |
1770 | if (pconf->use_modules && perf_session__create_module_maps(self) < 0) | ||
1771 | pr_debug("Failed to load list of modules for session %s, " | 1763 | pr_debug("Failed to load list of modules for session %s, " |
1772 | "continuing...\n", self->filename); | 1764 | "continuing...\n", self->filename); |
1773 | /* | 1765 | /* |
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 941ef331790e..766294735f93 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h | |||
@@ -57,11 +57,11 @@ struct symbol_conf { | |||
57 | const char *vmlinux_name; | 57 | const char *vmlinux_name; |
58 | }; | 58 | }; |
59 | 59 | ||
60 | extern unsigned int symbol__priv_size; | 60 | extern struct symbol_conf symbol_conf; |
61 | 61 | ||
62 | static inline void *symbol__priv(struct symbol *self) | 62 | static inline void *symbol__priv(struct symbol *self) |
63 | { | 63 | { |
64 | return ((void *)self) - symbol__priv_size; | 64 | return ((void *)self) - symbol_conf.priv_size; |
65 | } | 65 | } |
66 | 66 | ||
67 | struct addr_location { | 67 | struct addr_location { |
@@ -119,9 +119,8 @@ int sysfs__read_build_id(const char *filename, void *bf, size_t size); | |||
119 | bool dsos__read_build_ids(void); | 119 | bool dsos__read_build_ids(void); |
120 | int build_id__sprintf(u8 *self, int len, char *bf); | 120 | int build_id__sprintf(u8 *self, int len, char *bf); |
121 | 121 | ||
122 | int symbol__init(struct symbol_conf *conf); | 122 | int symbol__init(void); |
123 | int perf_session__create_kernel_maps(struct perf_session *self, | 123 | int perf_session__create_kernel_maps(struct perf_session *self); |
124 | struct symbol_conf *conf); | ||
125 | 124 | ||
126 | extern struct list_head dsos__user, dsos__kernel; | 125 | extern struct list_head dsos__user, dsos__kernel; |
127 | extern struct dso *vdso; | 126 | extern struct dso *vdso; |