Commit 75d48c56 authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo

perf inject: Try chroot directory when reading build-id

When reading build-id from a DSO, it should consider if it's from a
chroot task.  In that case, the path is different so it needs to prepend
the root directory to access the file correctly.
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Acked-by: default avatarJiri 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-4-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 67fd1892
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "util/synthetic-events.h" #include "util/synthetic-events.h"
#include "util/thread.h" #include "util/thread.h"
#include "util/namespaces.h" #include "util/namespaces.h"
#include "util/util.h"
#include <linux/err.h> #include <linux/err.h>
#include <subcmd/parse-options.h> #include <subcmd/parse-options.h>
...@@ -550,6 +551,15 @@ static int dso__read_build_id(struct dso *dso) ...@@ -550,6 +551,15 @@ static int dso__read_build_id(struct dso *dso)
nsinfo__mountns_enter(dso->nsinfo, &nsc); nsinfo__mountns_enter(dso->nsinfo, &nsc);
if (filename__read_build_id(dso->long_name, &dso->bid) > 0) if (filename__read_build_id(dso->long_name, &dso->bid) > 0)
dso->has_build_id = true; dso->has_build_id = true;
else if (dso->nsinfo) {
char *new_name;
new_name = filename_with_chroot(dso->nsinfo->pid,
dso->long_name);
if (new_name && filename__read_build_id(new_name, &dso->bid) > 0)
dso->has_build_id = true;
free(new_name);
}
nsinfo__mountns_exit(&nsc); nsinfo__mountns_exit(&nsc);
return dso->has_build_id ? 0 : -1; return dso->has_build_id ? 0 : -1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment