perf annotate: Try chroot filename for objdump
authorNamhyung Kim <namhyung@kernel.org>
Wed, 2 Feb 2022 07:08:28 +0000 (23:08 -0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 10 Feb 2022 18:34:13 +0000 (15:34 -0300)
Likewise, it should use a proper name in case the task runs under
chroot.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20220202070828.143303-5-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/annotate.c

index 8190a124b99d9d3ff0cb155330c60693bf2208ad..e4c641b240df4dcaeb52d8d822f9243a64b777f9 100644 (file)
@@ -33,6 +33,7 @@
 #include "string2.h"
 #include "util/event.h"
 #include "arch/common.h"
+#include "namespaces.h"
 #include <regex.h>
 #include <pthread.h>
 #include <linux/bitops.h>
@@ -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);