aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-annotate.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2009-11-24 09:05:15 -0500
committerIngo Molnar <mingo@elte.hu>2009-11-24 10:37:02 -0500
commitb32d133aec5dc882cf783a293f393bfb3f4379e1 (patch)
tree41fc56a4aaec8892a235ffd530b36278d147dc4e /tools/perf/builtin-annotate.c
parent7cc017edb9459193d3b581155a14029e4bef0c49 (diff)
perf symbols: Simplify symbol machinery setup
And also express its configuration toggles via a struct. Now all one has to do is to call symbol__init(NULL) if the defaults are OK, or pass a struct symbol_conf pointer with the desired configuration. If a tool uses kernel_maps__find_symbol() to look at the kernel and modules mappings for a symbol but didn't call symbol__init() first, that will generate a one time warning too, alerting the subcommand developer that symbol__init() must be called. 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: <1259071517-3242-2-git-send-email-acme@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/builtin-annotate.c')
-rw-r--r--tools/perf/builtin-annotate.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 59b6123abec2..cd97c2b1cc3b 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -34,11 +34,9 @@ static int input;
34static int full_paths; 34static int full_paths;
35 35
36static int print_line; 36static int print_line;
37static bool use_modules;
38 37
39static unsigned long page_size; 38static unsigned long page_size;
40static unsigned long mmap_window = 32; 39static unsigned long mmap_window = 32;
41const char *vmlinux_name;
42 40
43struct sym_hist { 41struct sym_hist {
44 u64 sum; 42 u64 sum;
@@ -56,6 +54,11 @@ struct sym_priv {
56 struct sym_ext *ext; 54 struct sym_ext *ext;
57}; 55};
58 56
57static struct symbol_conf symbol_conf = {
58 .priv_size = sizeof(struct sym_priv),
59 .try_vmlinux_path = true,
60};
61
59static const char *sym_hist_filter; 62static const char *sym_hist_filter;
60 63
61static int symbol_filter(struct map *map __used, struct symbol *sym) 64static int symbol_filter(struct map *map __used, struct symbol *sym)
@@ -586,11 +589,6 @@ static int __cmd_annotate(void)
586 exit(0); 589 exit(0);
587 } 590 }
588 591
589 if (kernel_maps__init(vmlinux_name, true, use_modules) < 0) {
590 pr_err("failed to create kernel maps for symbol resolution\b");
591 return -1;
592 }
593
594remap: 592remap:
595 buf = (char *)mmap(NULL, page_size * mmap_window, PROT_READ, 593 buf = (char *)mmap(NULL, page_size * mmap_window, PROT_READ,
596 MAP_SHARED, input, offset); 594 MAP_SHARED, input, offset);
@@ -691,8 +689,9 @@ static const struct option options[] = {
691 "be more verbose (show symbol address, etc)"), 689 "be more verbose (show symbol address, etc)"),
692 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, 690 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
693 "dump raw trace in ASCII"), 691 "dump raw trace in ASCII"),
694 OPT_STRING('k', "vmlinux", &vmlinux_name, "file", "vmlinux pathname"), 692 OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
695 OPT_BOOLEAN('m', "modules", &use_modules, 693 "file", "vmlinux pathname"),
694 OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules,
696 "load module symbols - WARNING: use only with -k and LIVE kernel"), 695 "load module symbols - WARNING: use only with -k and LIVE kernel"),
697 OPT_BOOLEAN('l', "print-line", &print_line, 696 OPT_BOOLEAN('l', "print-line", &print_line,
698 "print matching source lines (may be slow)"), 697 "print matching source lines (may be slow)"),
@@ -718,7 +717,8 @@ static void setup_sorting(void)
718 717
719int cmd_annotate(int argc, const char **argv, const char *prefix __used) 718int cmd_annotate(int argc, const char **argv, const char *prefix __used)
720{ 719{
721 symbol__init(sizeof(struct sym_priv)); 720 if (symbol__init(&symbol_conf) < 0)
721 return -1;
722 722
723 page_size = getpagesize(); 723 page_size = getpagesize();
724 724