Skip to contentSkip to conversation

perf tools: Add symfs option for off-box analysis using specified tree

PATCH Superseded David Ahern 2 participants 2 messages Dec 9, 2010 perf events

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 perf tools: Add symfs option for off-box analysis using specified tree

The symfs argument allows analysis of perf.data file using a locally accessible filesystem tree with debug symbols - e.g., tree created during image builds, sshfs mount, loop mounted KVM disk images, USB keys, initrds, etc. Anything with an OS tree can be analyzed from anywhere without the need to populate a local data store with build-ids.

v1 --> v2: removed symfs changes from builtin-annotate.c
fixed tab/space inconsistencies changed new strlen() to symbol_conf.symfs[0] added symfs option to Documentation files

---
 tools/perf/Documentation/perf-diff.txt      |    2 +
 tools/perf/Documentation/perf-report.txt    |    3 ++
 tools/perf/Documentation/perf-timechart.txt |    2 +
 tools/perf/builtin-diff.c                   |    2 +
 tools/perf/builtin-report.c                 |    2 +
 tools/perf/builtin-timechart.c              |    2 +
 tools/perf/util/hist.c                      |   14 ++++++--
 tools/perf/util/symbol.c                    |   50 +++++++++++++++++++--------
 tools/perf/util/symbol.h                    |    1 +
 9 files changed, 60 insertions(+), 18 deletions(-)
tools/perf/Documentation/perf-diff.txt +2 -0
index 6a9ec2b..74d7481 100644
@@ -66,6 +66,8 @@ OPTIONS
 --force::
        Don't complain, do it.
 
+--symfs=<directory>::
+        Look for files with symbols relative to this directory.
 
 SEE ALSO
 --------
tools/perf/Documentation/perf-report.txt +3 -0
index 59a1f57..9ed6079 100644
@@ -113,6 +113,9 @@ OPTIONS
 --force::
         Don't complain, do it.
 
+--symfs=<directory>::
+        Look for files with symbols relative to this directory.
+
 SEE ALSO
 --------
 linkperf:perf-stat[1]
tools/perf/Documentation/perf-timechart.txt +2 -0
index 4b17883..d7b79e2 100644
@@ -38,6 +38,8 @@ OPTIONS
 --process::
         Select the processes to display, by name or PID
 
+--symfs=<directory>::
+        Look for files with symbols relative to this directory.
 
 SEE ALSO
 --------
tools/perf/builtin-diff.c +2 -0
index 5e1a043..71126a6 100644
@@ -192,6 +192,8 @@ static const struct option options[] = {
 	OPT_STRING('t', "field-separator", &symbol_conf.field_sep, "separator",
 		   "separator for columns, no spaces will be added between "
 		   "columns '.' is reserved."),
+	OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
+		    "Look for files with symbols relative to this directory"),
 	OPT_END()
 };
 
tools/perf/builtin-report.c +2 -0
index 904519f..57b0f49 100644
@@ -479,6 +479,8 @@ static const struct option options[] = {
 		   "columns '.' is reserved."),
 	OPT_BOOLEAN('U', "hide-unresolved", &hide_unresolved,
 		    "Only display entries resolved to a symbol"),
+	OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
+		    "Look for files with symbols relative to this directory"),
 	OPT_END()
 };
 
tools/perf/builtin-timechart.c +2 -0
index d2fc461..965aa4e 100644
@@ -1021,6 +1021,8 @@ static const struct option options[] = {
 	OPT_CALLBACK('p', "process", NULL, "process",
 		      "process selector. Pass a pid or process name.",
 		       parse_process),
+	OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
+		    "Look for files with symbols relative to this directory"),
 	OPT_END()
 };
 
tools/perf/util/hist.c +11 -3
index 2022e87..b6f9f3b 100644
@@ -1092,6 +1092,12 @@ int hist_entry__annotate(struct hist_entry *self, struct list_head *head,
 	FILE *file;
 	int err = 0;
 	u64 len;
+	char symfs_filename[PATH_MAX];
+
+	if (filename) {
+		snprintf(symfs_filename, sizeof(symfs_filename), "%s%s",
+			 symbol_conf.symfs, filename);
+	}
 
 	if (filename == NULL) {
 		if (dso->has_build_id) {
@@ -1100,9 +1106,9 @@ int hist_entry__annotate(struct hist_entry *self, struct list_head *head,
 			return -ENOMEM;
 		}
 		goto fallback;
-	} else if (readlink(filename, command, sizeof(command)) < 0 ||
+	} else if (readlink(symfs_filename, command, sizeof(command)) < 0 ||
 		   strstr(command, "[kernel.kallsyms]") ||
-		   access(filename, R_OK)) {
+		   access(symfs_filename, R_OK)) {
 		free(filename);
 fallback:
 		/*
@@ -1111,6 +1117,8 @@ fallback:
 		 * DSO is the same as when 'perf record' ran.
 		 */
 		filename = dso->long_name;
+		snprintf(symfs_filename, sizeof(symfs_filename), "%s%s",
+			 symbol_conf.symfs, filename);
 		free_filename = false;
 	}
 
@@ -1137,7 +1145,7 @@ fallback:
 		 "objdump --start-address=0x%016Lx --stop-address=0x%016Lx -dS -C %s|grep -v %s|expand",
 		 map__rip_2objdump(map, sym->start),
 		 map__rip_2objdump(map, sym->end),
-		 filename, filename);
+		 symfs_filename, filename);
 
 	pr_debug("Executing: %s\n", command);
 
tools/perf/util/symbol.c +35 -15

115 lines not on this page · raw message

tools/perf/util/symbol.h +1 -0
index 038f220..bbe90d1 100644
@@ -85,6 +85,7 @@ struct symbol_conf {
        struct strlist	*dso_list,
 			*comm_list,
 			*sym_list;
+	const char	*symfs;
 };
 
 extern struct symbol_conf symbol_conf;
Signature · 1 line
1.7.2.3
#1 lore raw

Em Wed, Dec 08, 2010 at 07:33:40PM -0700, David Ahern escreveu:

Quoted 7 lines

The symfs argument allows analysis of perf.data file using a locally accessible filesystem tree with debug symbols - e.g., tree created during image builds, sshfs mount, loop mounted KVM disk images, USB keys, initrds, etc. Anything with an OS tree can be analyzed from anywhere without the need to populate a local data store with build-ids.

Quoted 6 lines

v1 --> v2: removed symfs changes from builtin-annotate.c
fixed tab/space inconsistencies changed new strlen() to symbol_conf.symfs[0] added symfs option to Documentation files

So I tried it now with:

perf report --symfs /

Which should be equivalent to the common case:

perf report

Bu kernel symbols didn't got resolved, can you please check this?

- Arnaldo