Skip to contentSkip to conversation

perf symbols: take in account symfs setting when reading file build ID

PATCH New Victor Kamensky 2 participants 2 messages Feb 6, 2017 – Feb 10, 2017 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf symbols: take in account symfs setting when reading file build ID

After 5baecbc 'perf symbols: we can now read separate debug-info files based on a build ID' and when --symfs option is used perf failed to pick up symbols for file with the same name between host and sysroot specified by --symfs option. One can see message like this:

bin/bash with build id 26f0062cb6950d4d1ab0fd9c43eae8b10ca42062 not found, continuing without symbols

It happens because code added by 5baecbc opens files directly by dso->long_name without symbol_conf.symfs consideration, which as result picks one from the host. It reads its build ID and later even code finds another proper file in directory pointed by --symfs perf ignores it because build id mismatches.

Fix is to use __symbol__join_symfs to adjust file name according to --symfs setting. If no --symfs passed the operation would noop and picks the same host file as before.

Also note in latter tree after 5baecbc commit additional check for '!dso->has_build_id' was added, so to observe error condition 'perf record' should run with --no-buildid, so perf.data itself would not have build id for target binary in buildid perf section and 'perf report' will pass '!dso->has_build_id' condition. Or target binary should not have build id, but the same binary on host has build id, again '!dso->has_build_id' will pass in this case and incorrect build id could be read if --symfs is used.

Fixes 5baecbcd9c9a ("perf symbols: we can now read separate debug-info files based on a build ID")
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Dima Kogan <[email protected]>
Cc Kan Liang <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Alexander Shishkin <[email protected]>
Cc Masami Hiramatsu <[email protected]>
Cc Wang Nan <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Chris Phlipot <[email protected]>
Cc He Kuang <[email protected]>
Cc Adrian Hunter <[email protected]>
---
 tools/perf/util/symbol.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
tools/perf/util/symbol.c +4 -2
index dc93940..70e389bc 100644
@@ -1460,9 +1460,11 @@ int dso__load(struct dso *dso, struct map *map)
 	 * DSO_BINARY_TYPE__BUILDID_DEBUGINFO to work
 	 */
 	if (!dso->has_build_id &&
-	    is_regular_file(dso->long_name) &&
-	    filename__read_build_id(dso->long_name, build_id, BUILD_ID_SIZE) > 0)
+	    is_regular_file(dso->long_name)) {
+	    __symbol__join_symfs(name, PATH_MAX, dso->long_name);
+	    if (filename__read_build_id(name, build_id, BUILD_ID_SIZE) > 0)
 		dso__set_build_id(dso, build_id);
+	}
 
 	/*
 	 * Iterate over candidate debug images.
Signature · 1 line
2.7.4
#1 lore raw

[tip:perf/core] perf symbols: Take into account symfs setting when reading file build ID

perf symbols: Take into account symfs setting when reading file build ID
Commit-ID:  9b200653518ea9ccc331b204c7d555d2440570d1
Gitweb:     http://git.kernel.org/tip/9b200653518ea9ccc331b204c7d555d2440570d1
Author:     Victor Kamensky <[email protected]>
AuthorDate: Mon, 6 Feb 2017 15:48:28 -0800
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 8 Feb 2017 09:28:55 -0300

perf symbols: Take into account symfs setting when reading file build ID

After commit 5baecbcd9c9a ("perf symbols: we can now read separate debug-info files based on a build ID") and when --symfs option is used perf failed to pick up symbols for file with the same name between host and sysroot specified by --symfs option. One can see message like this:

bin/bash with build id 26f0062cb6950d4d1ab0fd9c43eae8b10ca42062 not found, continuing without symbols

It happens because code added by 5baecbcd9c9a opens files directly by dso->long_name without symbol_conf.symfs consideration, which as result picks one from the host. It reads its build ID and later even code finds another proper file in directory pointed by --symfs perf ignores it because build id mismatches.

Fix is to use __symbol__join_symfs to adjust file name according to --symfs setting. If no --symfs passed the operation would noop and picks the same host file as before.

Also note in latter tree after 5baecbcd9c9a commit additional check for '!dso->has_build_id' was added, so to observe error condition 'perf record' should run with --no-buildid, so perf.data itself would not have build id for target binary in buildid perf section and 'perf report' will pass '!dso->has_build_id' condition. Or target binary should not have build id, but the same binary on host has build id, again '!dso->has_build_id' will pass in this case and incorrect build id could be read if --symfs is used.

Cc Adrian Hunter <[email protected]>
Cc Alexander Shishkin <[email protected]>
Cc Chris Phlipot <[email protected]>
Cc Dima Kogan <[email protected]>
Cc He Kuang <[email protected]>
Cc Kan Liang <[email protected]>
Cc Masami Hiramatsu <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Wang Nan <[email protected]>
Fixes 5baecbcd9c9a ("perf symbols: we can now read separate debug-info files based on a build ID")
---
 tools/perf/util/symbol.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
tools/perf/util/symbol.c +4 -2
index dc93940..70e389b 100644
@@ -1460,9 +1460,11 @@ int dso__load(struct dso *dso, struct map *map)
 	 * DSO_BINARY_TYPE__BUILDID_DEBUGINFO to work
 	 */
 	if (!dso->has_build_id &&
-	    is_regular_file(dso->long_name) &&
-	    filename__read_build_id(dso->long_name, build_id, BUILD_ID_SIZE) > 0)
+	    is_regular_file(dso->long_name)) {
+	    __symbol__join_symfs(name, PATH_MAX, dso->long_name);
+	    if (filename__read_build_id(name, build_id, BUILD_ID_SIZE) > 0)
 		dso__set_build_id(dso, build_id);
+	}
 
 	/*
 	 * Iterate over candidate debug images.