aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorMike Galbraith <efault@gmx.de>2009-07-02 02:09:46 -0400
committerIngo Molnar <mingo@elte.hu>2009-07-02 02:42:21 -0400
commit429764873cf3fc3e73142872a674bb27cda589c1 (patch)
treea7c11887ad7aa055f56276a14acbe004d0ead434 /tools/perf
parent6cfcc53ed4f3ecb9319e73a03f34f1eddcb644dd (diff)
perf_counter tools: Enable kernel module symbol loading in tools
Add the -m/--modules option to perf report and perf annotate, which enables live module symbol/image loading. To be used with -k/--vmlinux. (Also give perf annotate a -P/--full-paths option.) Signed-off-by: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> LKML-Reference: <1246514986.13293.48.camel@marge.simson.net> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-annotate.c25
-rw-r--r--tools/perf/builtin-report.c9
-rw-r--r--tools/perf/builtin-top.c12
3 files changed, 38 insertions, 8 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 88205686eb6e..08ea6c5329d9 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -43,6 +43,10 @@ static int dump_trace = 0;
43 43
44static int verbose; 44static int verbose;
45 45
46static int modules;
47
48static int full_paths;
49
46static int print_line; 50static int print_line;
47 51
48static unsigned long page_size; 52static unsigned long page_size;
@@ -171,7 +175,7 @@ static int load_kernel(void)
171 if (!kernel_dso) 175 if (!kernel_dso)
172 return -1; 176 return -1;
173 177
174 err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose, 0); 178 err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose, modules);
175 if (err <= 0) { 179 if (err <= 0) {
176 dso__delete(kernel_dso); 180 dso__delete(kernel_dso);
177 kernel_dso = NULL; 181 kernel_dso = NULL;
@@ -1268,19 +1272,25 @@ static void print_summary(char *filename)
1268 1272
1269static void annotate_sym(struct dso *dso, struct symbol *sym) 1273static void annotate_sym(struct dso *dso, struct symbol *sym)
1270{ 1274{
1271 char *filename = dso->name; 1275 char *filename = dso->name, *d_filename;
1272 u64 start, end, len; 1276 u64 start, end, len;
1273 char command[PATH_MAX*2]; 1277 char command[PATH_MAX*2];
1274 FILE *file; 1278 FILE *file;
1275 1279
1276 if (!filename) 1280 if (!filename)
1277 return; 1281 return;
1278 if (dso == kernel_dso) 1282 if (sym->module)
1283 filename = sym->module->path;
1284 else if (dso == kernel_dso)
1279 filename = vmlinux; 1285 filename = vmlinux;
1280 1286
1281 start = sym->obj_start; 1287 start = sym->obj_start;
1282 if (!start) 1288 if (!start)
1283 start = sym->start; 1289 start = sym->start;
1290 if (full_paths)
1291 d_filename = filename;
1292 else
1293 d_filename = basename(filename);
1284 1294
1285 end = start + sym->end - sym->start + 1; 1295 end = start + sym->end - sym->start + 1;
1286 len = sym->end - sym->start; 1296 len = sym->end - sym->start;
@@ -1291,13 +1301,14 @@ static void annotate_sym(struct dso *dso, struct symbol *sym)
1291 } 1301 }
1292 1302
1293 printf("\n\n------------------------------------------------\n"); 1303 printf("\n\n------------------------------------------------\n");
1294 printf(" Percent | Source code & Disassembly of %s\n", filename); 1304 printf(" Percent | Source code & Disassembly of %s\n", d_filename);
1295 printf("------------------------------------------------\n"); 1305 printf("------------------------------------------------\n");
1296 1306
1297 if (verbose >= 2) 1307 if (verbose >= 2)
1298 printf("annotating [%p] %30s : [%p] %30s\n", dso, dso->name, sym, sym->name); 1308 printf("annotating [%p] %30s : [%p] %30s\n", dso, dso->name, sym, sym->name);
1299 1309
1300 sprintf(command, "objdump --start-address=0x%016Lx --stop-address=0x%016Lx -dS %s", (u64)start, (u64)end, filename); 1310 sprintf(command, "objdump --start-address=0x%016Lx --stop-address=0x%016Lx -dS %s|grep -v %s",
1311 (u64)start, (u64)end, filename, filename);
1301 1312
1302 if (verbose >= 3) 1313 if (verbose >= 3)
1303 printf("doing: %s\n", command); 1314 printf("doing: %s\n", command);
@@ -1472,8 +1483,12 @@ static const struct option options[] = {
1472 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, 1483 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
1473 "dump raw trace in ASCII"), 1484 "dump raw trace in ASCII"),
1474 OPT_STRING('k', "vmlinux", &vmlinux, "file", "vmlinux pathname"), 1485 OPT_STRING('k', "vmlinux", &vmlinux, "file", "vmlinux pathname"),
1486 OPT_BOOLEAN('m', "modules", &modules,
1487 "load module symbols - WARNING: use only with -k and LIVE kernel"),
1475 OPT_BOOLEAN('l', "print-line", &print_line, 1488 OPT_BOOLEAN('l', "print-line", &print_line,
1476 "print matching source lines (may be slow)"), 1489 "print matching source lines (may be slow)"),
1490 OPT_BOOLEAN('P', "full-paths", &full_paths,
1491 "Don't shorten the displayed pathnames"),
1477 OPT_END() 1492 OPT_END()
1478}; 1493};
1479 1494
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 38d136fedfb9..b44476ca2398 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -46,6 +46,8 @@ static int dump_trace = 0;
46static int verbose; 46static int verbose;
47#define eprintf(x...) do { if (verbose) fprintf(stderr, x); } while (0) 47#define eprintf(x...) do { if (verbose) fprintf(stderr, x); } while (0)
48 48
49static int modules;
50
49static int full_paths; 51static int full_paths;
50 52
51static unsigned long page_size; 53static unsigned long page_size;
@@ -188,7 +190,7 @@ static int load_kernel(void)
188 if (!kernel_dso) 190 if (!kernel_dso)
189 return -1; 191 return -1;
190 192
191 err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose, 0); 193 err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose, modules);
192 if (err <= 0) { 194 if (err <= 0) {
193 dso__delete(kernel_dso); 195 dso__delete(kernel_dso);
194 kernel_dso = NULL; 196 kernel_dso = NULL;
@@ -648,6 +650,9 @@ sort__sym_print(FILE *fp, struct hist_entry *self)
648 ret += fprintf(fp, "[%c] %s", 650 ret += fprintf(fp, "[%c] %s",
649 self->dso == kernel_dso ? 'k' : 651 self->dso == kernel_dso ? 'k' :
650 self->dso == hypervisor_dso ? 'h' : '.', self->sym->name); 652 self->dso == hypervisor_dso ? 'h' : '.', self->sym->name);
653
654 if (self->sym->module)
655 ret += fprintf(fp, "\t[%s]", self->sym->module->name);
651 } else { 656 } else {
652 ret += fprintf(fp, "%#016llx", (u64)self->ip); 657 ret += fprintf(fp, "%#016llx", (u64)self->ip);
653 } 658 }
@@ -1710,6 +1715,8 @@ static const struct option options[] = {
1710 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, 1715 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
1711 "dump raw trace in ASCII"), 1716 "dump raw trace in ASCII"),
1712 OPT_STRING('k', "vmlinux", &vmlinux, "file", "vmlinux pathname"), 1717 OPT_STRING('k', "vmlinux", &vmlinux, "file", "vmlinux pathname"),
1718 OPT_BOOLEAN('m', "modules", &modules,
1719 "load module symbols - WARNING: use only with -k and LIVE kernel"),
1713 OPT_STRING('s', "sort", &sort_order, "key[,key2...]", 1720 OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
1714 "sort by key(s): pid, comm, dso, symbol, parent"), 1721 "sort by key(s): pid, comm, dso, symbol, parent"),
1715 OPT_BOOLEAN('P', "full-paths", &full_paths, 1722 OPT_BOOLEAN('P', "full-paths", &full_paths,
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 9bb25fc3d4ce..aa044ea1482b 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -66,6 +66,7 @@ static unsigned int page_size;
66static unsigned int mmap_pages = 16; 66static unsigned int mmap_pages = 16;
67static int freq = 0; 67static int freq = 0;
68static int verbose = 0; 68static int verbose = 0;
69static char *vmlinux = NULL;
69 70
70static char *sym_filter; 71static char *sym_filter;
71static unsigned long filter_start; 72static unsigned long filter_start;
@@ -265,7 +266,10 @@ static void print_sym_table(void)
265 printf("%9.1f %10ld - ", syme->weight, syme->snap_count); 266 printf("%9.1f %10ld - ", syme->weight, syme->snap_count);
266 267
267 color_fprintf(stdout, color, "%4.1f%%", pcnt); 268 color_fprintf(stdout, color, "%4.1f%%", pcnt);
268 printf(" - %016llx : %s\n", sym->start, sym->name); 269 printf(" - %016llx : %s", sym->start, sym->name);
270 if (sym->module)
271 printf("\t[%s]", sym->module->name);
272 printf("\n");
269 } 273 }
270} 274}
271 275
@@ -359,12 +363,13 @@ static int parse_symbols(void)
359{ 363{
360 struct rb_node *node; 364 struct rb_node *node;
361 struct symbol *sym; 365 struct symbol *sym;
366 int modules = vmlinux ? 1 : 0;
362 367
363 kernel_dso = dso__new("[kernel]", sizeof(struct sym_entry)); 368 kernel_dso = dso__new("[kernel]", sizeof(struct sym_entry));
364 if (kernel_dso == NULL) 369 if (kernel_dso == NULL)
365 return -1; 370 return -1;
366 371
367 if (dso__load_kernel(kernel_dso, NULL, symbol_filter, 1, 0) <= 0) 372 if (dso__load_kernel(kernel_dso, vmlinux, symbol_filter, verbose, modules) <= 0)
368 goto out_delete_dso; 373 goto out_delete_dso;
369 374
370 node = rb_first(&kernel_dso->syms); 375 node = rb_first(&kernel_dso->syms);
@@ -680,6 +685,7 @@ static const struct option options[] = {
680 "system-wide collection from all CPUs"), 685 "system-wide collection from all CPUs"),
681 OPT_INTEGER('C', "CPU", &profile_cpu, 686 OPT_INTEGER('C', "CPU", &profile_cpu,
682 "CPU to profile on"), 687 "CPU to profile on"),
688 OPT_STRING('k', "vmlinux", &vmlinux, "file", "vmlinux pathname"),
683 OPT_INTEGER('m', "mmap-pages", &mmap_pages, 689 OPT_INTEGER('m', "mmap-pages", &mmap_pages,
684 "number of mmap data pages"), 690 "number of mmap data pages"),
685 OPT_INTEGER('r', "realtime", &realtime_prio, 691 OPT_INTEGER('r', "realtime", &realtime_prio,
@@ -709,6 +715,8 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
709{ 715{
710 int counter; 716 int counter;
711 717
718 symbol__init();
719
712 page_size = sysconf(_SC_PAGE_SIZE); 720 page_size = sysconf(_SC_PAGE_SIZE);
713 721
714 argc = parse_options(argc, argv, options, top_usage, 0); 722 argc = parse_options(argc, argv, options, top_usage, 0);