aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-top.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-top.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-top.c')
-rw-r--r--tools/perf/builtin-top.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index b9a321fd184e..a21247543fc1 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -79,7 +79,7 @@ static int dump_symtab = 0;
79static bool hide_kernel_symbols = false; 79static bool hide_kernel_symbols = false;
80static bool hide_user_symbols = false; 80static bool hide_user_symbols = false;
81static struct winsize winsize; 81static struct winsize winsize;
82const char *vmlinux_name; 82struct symbol_conf symbol_conf;
83 83
84/* 84/*
85 * Source 85 * Source
@@ -128,7 +128,7 @@ struct sym_entry {
128 128
129static inline struct symbol *sym_entry__symbol(struct sym_entry *self) 129static inline struct symbol *sym_entry__symbol(struct sym_entry *self)
130{ 130{
131 return ((void *)self) + symbol__priv_size; 131 return ((void *)self) + symbol_conf.priv_size;
132} 132}
133 133
134static void get_term_dimensions(struct winsize *ws) 134static void get_term_dimensions(struct winsize *ws)
@@ -695,7 +695,7 @@ static void print_mapped_keys(void)
695 695
696 fprintf(stdout, "\t[f] profile display filter (count). \t(%d)\n", count_filter); 696 fprintf(stdout, "\t[f] profile display filter (count). \t(%d)\n", count_filter);
697 697
698 if (vmlinux_name) { 698 if (symbol_conf.vmlinux_name) {
699 fprintf(stdout, "\t[F] annotate display filter (percent). \t(%d%%)\n", sym_pcnt_filter); 699 fprintf(stdout, "\t[F] annotate display filter (percent). \t(%d%%)\n", sym_pcnt_filter);
700 fprintf(stdout, "\t[s] annotate symbol. \t(%s)\n", name?: "NULL"); 700 fprintf(stdout, "\t[s] annotate symbol. \t(%s)\n", name?: "NULL");
701 fprintf(stdout, "\t[S] stop annotation.\n"); 701 fprintf(stdout, "\t[S] stop annotation.\n");
@@ -732,7 +732,7 @@ static int key_mapped(int c)
732 case 'F': 732 case 'F':
733 case 's': 733 case 's':
734 case 'S': 734 case 'S':
735 return vmlinux_name ? 1 : 0; 735 return symbol_conf.vmlinux_name ? 1 : 0;
736 default: 736 default:
737 break; 737 break;
738 } 738 }
@@ -1261,7 +1261,8 @@ static const struct option options[] = {
1261 "system-wide collection from all CPUs"), 1261 "system-wide collection from all CPUs"),
1262 OPT_INTEGER('C', "CPU", &profile_cpu, 1262 OPT_INTEGER('C', "CPU", &profile_cpu,
1263 "CPU to profile on"), 1263 "CPU to profile on"),
1264 OPT_STRING('k', "vmlinux", &vmlinux_name, "file", "vmlinux pathname"), 1264 OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
1265 "file", "vmlinux pathname"),
1265 OPT_BOOLEAN('K', "hide_kernel_symbols", &hide_kernel_symbols, 1266 OPT_BOOLEAN('K', "hide_kernel_symbols", &hide_kernel_symbols,
1266 "hide kernel symbols"), 1267 "hide kernel symbols"),
1267 OPT_INTEGER('m', "mmap-pages", &mmap_pages, 1268 OPT_INTEGER('m', "mmap-pages", &mmap_pages,
@@ -1295,7 +1296,7 @@ static const struct option options[] = {
1295 1296
1296int cmd_top(int argc, const char **argv, const char *prefix __used) 1297int cmd_top(int argc, const char **argv, const char *prefix __used)
1297{ 1298{
1298 int counter, err; 1299 int counter;
1299 1300
1300 page_size = sysconf(_SC_PAGE_SIZE); 1301 page_size = sysconf(_SC_PAGE_SIZE);
1301 1302
@@ -1313,15 +1314,16 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
1313 if (!nr_counters) 1314 if (!nr_counters)
1314 nr_counters = 1; 1315 nr_counters = 1;
1315 1316
1316 symbol__init(sizeof(struct sym_entry) + 1317 symbol_conf.priv_size = (sizeof(struct sym_entry) +
1317 (nr_counters + 1) * sizeof(unsigned long)); 1318 (nr_counters + 1) * sizeof(unsigned long));
1319 if (symbol_conf.vmlinux_name == NULL)
1320 symbol_conf.try_vmlinux_path = true;
1321 if (symbol__init(&symbol_conf) < 0)
1322 return -1;
1318 1323
1319 if (delay_secs < 1) 1324 if (delay_secs < 1)
1320 delay_secs = 1; 1325 delay_secs = 1;
1321 1326
1322 err = kernel_maps__init(vmlinux_name, !vmlinux_name, true);
1323 if (err < 0)
1324 return err;
1325 parse_source(sym_filter_entry); 1327 parse_source(sym_filter_entry);
1326 1328
1327 /* 1329 /*