From: Peter Zijlstra Date: Wed, 27 May 2009 18:20:23 +0000 (+0200) Subject: perf_counter: tools: report: Add vmlinux support X-Git-Tag: v2.6.31-rc1~383^2~182 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=450aaa2b2a1b006870ba68251fbb40b2387caade;p=karo-tx-linux.git perf_counter: tools: report: Add vmlinux support Allow to use vmlinux instead of kallsyms. Signed-off-by: Peter Zijlstra Cc: Paul Mackerras Cc: Corey Ashford Cc: Arnaldo Carvalho de Melo Cc: John Kacur Cc: Mike Galbraith LKML-Reference: <20090527182100.740018486@chello.nl> Signed-off-by: Ingo Molnar --- diff --git a/Documentation/perf_counter/builtin-report.c b/Documentation/perf_counter/builtin-report.c index a9ff49a4edea..3e87cbd3045a 100644 --- a/Documentation/perf_counter/builtin-report.c +++ b/Documentation/perf_counter/builtin-report.c @@ -19,6 +19,7 @@ #define SHOW_HV 4 static char const *input_name = "perf.data"; +static char *vmlinux = NULL; static int input; static int show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV; @@ -532,6 +533,39 @@ out_delete_dso: return -1; } +static int load_kernel(void) +{ + int fd, nr; + + if (!vmlinux) + goto kallsyms; + + fd = open(vmlinux, O_RDONLY); + if (fd < 0) + goto kallsyms; + + kernel_dso = dso__new("[kernel]"); + if (!kernel_dso) + goto fail_open; + + nr = dso__load_sym(kernel_dso, fd, vmlinux); + + if (nr <= 0) + goto fail_load; + + dsos__add(kernel_dso); + close(fd); + + return 0; + +fail_load: + dso__delete(kernel_dso); +fail_open: + close(fd); +kallsyms: + return load_kallsyms(); +} + struct map { struct list_head node; uint64_t start; @@ -850,7 +884,7 @@ static int __cmd_report(void) exit(0); } - if (load_kallsyms() < 0) { + if (load_kernel() < 0) { perror("failed to open kallsyms"); return EXIT_FAILURE; } @@ -1039,6 +1073,7 @@ static const struct option options[] = { "be more verbose (show symbol address, etc)"), OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, "dump raw trace in ASCII"), + OPT_STRING('k', "vmlinux", &vmlinux, "file", "vmlinux pathname"), OPT_END() };