From 40b0c5fd2455fc1e5da585f62a95eda99f7aa0b6 Mon Sep 17 00:00:00 2001 From: Namhyung Kim Date: Tue, 1 Feb 2022 23:08:28 -0800 Subject: [PATCH] perf annotate: Try chroot filename for objdump Likewise, it should use a proper name in case the task runs under chroot. Signed-off-by: Namhyung Kim Acked-by: Jiri Olsa Cc: Andi Kleen Cc: Ian Rogers Cc: Peter Zijlstra Link: http://lore.kernel.org/lkml/20220202070828.143303-5-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/annotate.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 8190a124b99d..e4c641b240df 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -33,6 +33,7 @@ #include "string2.h" #include "util/event.h" #include "arch/common.h" +#include "namespaces.h" #include #include #include @@ -1696,6 +1697,15 @@ fallback: * DSO is the same as when 'perf record' ran. */ __symbol__join_symfs(filename, filename_size, dso->long_name); + + if (access(filename, R_OK) && errno == ENOENT && dso->nsinfo) { + char *new_name = filename_with_chroot(dso->nsinfo->pid, + filename); + if (new_name) { + strlcpy(filename, new_name, filename_size); + free(new_name); + } + } } free(build_id_path);