diff options
author | Namhyung Kim <namhyung@kernel.org> | 2017-06-08 03:31:01 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-06-08 14:38:41 -0400 |
commit | 3619ef76b37d4803bc9daee9d03d82c8526db378 (patch) | |
tree | f56d049b9c428c4b2c2c1b9dd64399548272dd58 /tools/perf/util/annotate.c | |
parent | 14fc42fa1b3e7ea5160c84d0e686a3a0c1ffe619 (diff) |
perf annotate: Fix symbolic link of build-id cache
The commit 6ebd2547dd24 ("perf annotate: Fix a bug following symbolic
link of a build-id file") changed to use dirname to follow the symlink.
But it only considers new-style build-id cache names so old names fail
on readlink() and force to use system path which might not available.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Taeung Song <treeze.taeung@gmail.com>
Cc: Wang Nan <wangnan0@huawei.com>
Cc: kernel-team@lge.com
Fixes: 6ebd2547dd24 ("perf annotate: Fix a bug following symbolic link of a build-id file")
Link: http://lkml.kernel.org/r/20170608073109.30699-2-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/annotate.c')
-rw-r--r-- | tools/perf/util/annotate.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 1367d7e35242..df4486c3a2fa 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c | |||
@@ -1321,6 +1321,7 @@ static int dso__disassemble_filename(struct dso *dso, char *filename, size_t fil | |||
1321 | char linkname[PATH_MAX]; | 1321 | char linkname[PATH_MAX]; |
1322 | char *build_id_filename; | 1322 | char *build_id_filename; |
1323 | char *build_id_path = NULL; | 1323 | char *build_id_path = NULL; |
1324 | char *pos; | ||
1324 | 1325 | ||
1325 | if (dso->symtab_type == DSO_BINARY_TYPE__KALLSYMS && | 1326 | if (dso->symtab_type == DSO_BINARY_TYPE__KALLSYMS && |
1326 | !dso__is_kcore(dso)) | 1327 | !dso__is_kcore(dso)) |
@@ -1340,7 +1341,14 @@ static int dso__disassemble_filename(struct dso *dso, char *filename, size_t fil | |||
1340 | if (!build_id_path) | 1341 | if (!build_id_path) |
1341 | return -1; | 1342 | return -1; |
1342 | 1343 | ||
1343 | dirname(build_id_path); | 1344 | /* |
1345 | * old style build-id cache has name of XX/XXXXXXX.. while | ||
1346 | * new style has XX/XXXXXXX../{elf,kallsyms,vdso}. | ||
1347 | * extract the build-id part of dirname in the new style only. | ||
1348 | */ | ||
1349 | pos = strrchr(build_id_path, '/'); | ||
1350 | if (pos && strlen(pos) < SBUILD_ID_SIZE - 2) | ||
1351 | dirname(build_id_path); | ||
1344 | 1352 | ||
1345 | if (dso__is_kcore(dso) || | 1353 | if (dso__is_kcore(dso) || |
1346 | readlink(build_id_path, linkname, sizeof(linkname)) < 0 || | 1354 | readlink(build_id_path, linkname, sizeof(linkname)) < 0 || |