From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>, Jiri Olsa <jolsa@redhat.com>
Cc: Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
LKML <linux-kernel@vger.kernel.org>,
Andi Kleen <ak@linux.intel.com>, Ian Rogers <irogers@google.com>
Subject: [PATCH 2/3] perf inject: Try chroot directory when reading build-id
Date: Fri, 28 Jan 2022 12:39:49 -0800 [thread overview]
Message-ID: <20220128203950.3371061-3-namhyung@kernel.org> (raw)
In-Reply-To: <20220128203950.3371061-1-namhyung@kernel.org>
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: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/builtin-inject.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index fbf43a454cba..3be581abbdb6 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -25,6 +25,7 @@
#include "util/synthetic-events.h"
#include "util/thread.h"
#include "util/namespaces.h"
+#include "util/util.h"
#include <linux/err.h>
#include <subcmd/parse-options.h>
@@ -550,6 +551,15 @@ static int dso__read_build_id(struct dso *dso)
nsinfo__mountns_enter(dso->nsinfo, &nsc);
if (filename__read_build_id(dso->long_name, &dso->bid) > 0)
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);
return dso->has_build_id ? 0 : -1;
--
2.35.0.rc2.247.g8bbb082509-goog
next prev parent reply other threads:[~2022-01-28 20:41 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-28 20:39 [PATCH 0/3] Handle chroot tasks properly (v1) Namhyung Kim
2022-01-28 20:39 ` [PATCH 1/3] perf tools: Try chroot'ed filename when opening dso/symbol Namhyung Kim
2022-01-28 20:39 ` Namhyung Kim [this message]
2022-01-28 20:39 ` [PATCH 3/3] perf annotate: Try chroot filename for objdump Namhyung Kim
2022-01-31 19:23 ` Jiri Olsa
2022-02-01 19:54 ` Namhyung Kim
2022-02-02 0:06 ` Arnaldo Carvalho de Melo
2022-02-01 1:16 ` [PATCH 0/3] Handle chroot tasks properly (v1) Andi Kleen
2022-02-01 20:01 ` Namhyung Kim
2022-02-02 0:11 ` Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220128203950.3371061-3-namhyung@kernel.org \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=irogers@google.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox