Skip to contentSkip to conversation

perf report: Allow user to specify path to kallsyms file

PATCH In review David Ahern 2 participants 3 messages Dec 8, 2010 – Dec 9, 2010 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf report: Allow user to specify path to kallsyms file

This is useful for analyzing a perf data file on a different system than the one data was collected on and still include symbols from loaded kernel modules in the output.

---
 tools/perf/builtin-report.c |    2 ++
 tools/perf/util/symbol.c    |    9 +++++++--
 tools/perf/util/symbol.h    |    1 +
 3 files changed, 10 insertions(+), 2 deletions(-)
tools/perf/builtin-report.c +2 -0
index 904519f..b6a2a89 100644
@@ -443,6 +443,8 @@ static const struct option options[] = {
 		    "dump raw trace in ASCII"),
 	OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
 		   "file", "vmlinux pathname"),
+	OPT_STRING(0, "kallsyms", &symbol_conf.kallsyms_name,
+		   "file", "kallsyms pathname"),
 	OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
 	OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules,
 		    "load module symbols - WARNING: use only with -k and LIVE kernel"),
tools/perf/util/symbol.c +7 -2
index a348906..f40c076 100644
@@ -1830,8 +1830,8 @@ static int dso__load_kernel_sym(struct dso *self, struct map *map,
 	const char *kallsyms_filename = NULL;
 	char *kallsyms_allocated_filename = NULL;
 	/*
-	 * Step 1: if the user specified a vmlinux filename, use it and only
-	 * it, reporting errors to the user if it cannot be used.
+	 * Step 1: if the user specified a kallsyms or vmlinux filename, use
+	 * it and only it, reporting errors to the user if it cannot be used.
 	 *
 	 * For instance, try to analyse an ARM perf.data file _without_ a
 	 * build-id, or if the user specifies the wrong path to the right
@@ -1844,6 +1844,11 @@ static int dso__load_kernel_sym(struct dso *self, struct map *map,
 	 * validation in dso__load_vmlinux and will bail out if they don't
 	 * match.
 	 */
+	if (symbol_conf.kallsyms_name != NULL) {
+		kallsyms_filename = symbol_conf.kallsyms_name;
+		goto do_kallsyms;
+	}
+
 	if (symbol_conf.vmlinux_name != NULL) {
 		err = dso__load_vmlinux(self, map,
 					symbol_conf.vmlinux_name, filter);
tools/perf/util/symbol.h +1 -0
index 038f220..12defbe 100644
@@ -72,6 +72,7 @@ struct symbol_conf {
 			show_cpu_utilization,
 			initialized;
 	const char	*vmlinux_name,
+			*kallsyms_name,
 			*source_prefix,
 			*field_sep;
 	const char	*default_guest_vmlinux_name,
Signature · 1 line
1.7.2.3
#1 lore raw

Em Tue, Dec 07, 2010 at 07:39:46PM -0700, David Ahern escreveu:

Quoted 3 lines

This is useful for analyzing a perf data file on a different system than the one data was collected on and still include symbols from loaded kernel modules in the output.

Applied and also added the relevant entry to tools/perf/Documentation/perf-report.txt, please do that next time you add some new command line option.

- Arnaldo

#2 lore raw
In reply to David Ahern
Commit-ID:  b226a5a72901bc9c73d639ea2e53e6c304bf3b74
Gitweb:     http://git.kernel.org/tip/b226a5a72901bc9c73d639ea2e53e6c304bf3b74
Author:     David Ahern <[email protected]>
AuthorDate: Tue, 7 Dec 2010 19:39:46 -0700
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 9 Dec 2010 11:07:07 -0200

perf report: Allow user to specify path to kallsyms file

This is useful for analyzing a perf data file on a different system than the one data was collected on and still include symbols from loaded kernel modules in the output.

Commiter note: Updated the man page accordingly.

LKML-Reference: <[email protected]>

---
 tools/perf/Documentation/perf-report.txt |    3 +++
 tools/perf/builtin-report.c              |    2 ++
 tools/perf/util/symbol.c                 |    9 +++++++--
 tools/perf/util/symbol.h                 |    1 +
 4 files changed, 13 insertions(+), 2 deletions(-)
tools/perf/Documentation/perf-report.txt +3 -0
index 59a1f57..fefea77 100644
@@ -104,6 +104,9 @@ OPTIONS
 --vmlinux=<file>::
         vmlinux pathname
 
+--kallsyms=<file>::
+        kallsyms pathname
+
 -m::
 --modules::
         Load module symbols. WARNING: This should only be used with -k and
tools/perf/builtin-report.c +2 -0
index 904519f..b6a2a89 100644
@@ -443,6 +443,8 @@ static const struct option options[] = {
 		    "dump raw trace in ASCII"),
 	OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
 		   "file", "vmlinux pathname"),
+	OPT_STRING(0, "kallsyms", &symbol_conf.kallsyms_name,
+		   "file", "kallsyms pathname"),
 	OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
 	OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules,
 		    "load module symbols - WARNING: use only with -k and LIVE kernel"),
tools/perf/util/symbol.c +7 -2
index a348906..f40c076 100644
@@ -1830,8 +1830,8 @@ static int dso__load_kernel_sym(struct dso *self, struct map *map,
 	const char *kallsyms_filename = NULL;
 	char *kallsyms_allocated_filename = NULL;
 	/*
-	 * Step 1: if the user specified a vmlinux filename, use it and only
-	 * it, reporting errors to the user if it cannot be used.
+	 * Step 1: if the user specified a kallsyms or vmlinux filename, use
+	 * it and only it, reporting errors to the user if it cannot be used.
 	 *
 	 * For instance, try to analyse an ARM perf.data file _without_ a
 	 * build-id, or if the user specifies the wrong path to the right
@@ -1844,6 +1844,11 @@ static int dso__load_kernel_sym(struct dso *self, struct map *map,
 	 * validation in dso__load_vmlinux and will bail out if they don't
 	 * match.
 	 */
+	if (symbol_conf.kallsyms_name != NULL) {
+		kallsyms_filename = symbol_conf.kallsyms_name;
+		goto do_kallsyms;
+	}
+
 	if (symbol_conf.vmlinux_name != NULL) {
 		err = dso__load_vmlinux(self, map,
 					symbol_conf.vmlinux_name, filter);
tools/perf/util/symbol.h +1 -0
index 038f220..12defbe 100644
@@ -72,6 +72,7 @@ struct symbol_conf {
 			show_cpu_utilization,
 			initialized;
 	const char	*vmlinux_name,
+			*kallsyms_name,
 			*source_prefix,
 			*field_sep;
 	const char	*default_guest_vmlinux_name,