From: Masami Hiramatsu <mhiramat@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org
Subject: [PATCH 1/2] perf-probe: Ensure debuginfo's build-id is correct
Date: Mon, 18 Dec 2017 16:29:03 +0900 [thread overview]
Message-ID: <151358214328.25261.6660021248431426149.stgit@devbox> (raw)
In-Reply-To: <151358211494.25261.16134489192749792799.stgit@devbox>
Ensure that the build-id of debuginfo is correctly
matched to target build-id, if not, it warns user
to check the system debuginfo package is correctly
installed.
E.g. on such environment, you will see below warning.
======
# perf probe -l
WARN: There is a build-id mismatch between
/usr/lib/debug/usr/lib64/libc-2.25.so.debug
and
/usr/lib64/libc-2.25.so
Please check your system's debuginfo files for mismatches, e.g. check
the versions for the target package and debuginfo package.
probe_libc:malloc_get_state (on malloc_get_state@GLIBC_2.2.5 in /us
r/lib64/libc-2.25.so)
======
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
tools/perf/util/probe-finder.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index a5731de0e5eb..5bb71e056b21 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -119,9 +119,11 @@ enum dso_binary_type distro_dwarf_types[] = {
struct debuginfo *debuginfo__new(const char *path)
{
+ u8 bid[BUILD_ID_SIZE], bid2[BUILD_ID_SIZE];
enum dso_binary_type *type;
char buf[PATH_MAX], nil = '\0';
struct dso *dso;
+ bool have_build_id = false;
struct debuginfo *dinfo = NULL;
/* Try to open distro debuginfo files */
@@ -129,12 +131,28 @@ struct debuginfo *debuginfo__new(const char *path)
if (!dso)
goto out;
+ if (filename__read_build_id(path, bid, BUILD_ID_SIZE) > 0)
+ have_build_id = true;
+
for (type = distro_dwarf_types;
!dinfo && *type != DSO_BINARY_TYPE__NOT_FOUND;
type++) {
if (dso__read_binary_type_filename(dso, *type, &nil,
buf, PATH_MAX) < 0)
continue;
+
+ if (have_build_id) {
+ /* This can be fail because the file doesn't exist */
+ if (filename__read_build_id(buf, bid2,
+ BUILD_ID_SIZE) < 0)
+ continue;
+ if (memcmp(bid, bid2, BUILD_ID_SIZE)) {
+ pr_warning("WARN: There is a build-id mismatch between\n %s\n and\n %s\n"
+ "Please check your system's debuginfo files for mismatches, e.g. check the "
+ "versions for the target package and debuginfo package.\n", buf, path);
+ continue;
+ }
+ }
dinfo = __debuginfo__new(buf);
}
dso__put(dso);
next prev parent reply other threads:[~2017-12-18 7:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-18 7:28 [PATCH 0/2] perf-probe: Improve warning message for buildid mismatch Masami Hiramatsu
2017-12-18 7:29 ` Masami Hiramatsu [this message]
2018-01-04 16:17 ` [PATCH 1/2] perf-probe: Ensure debuginfo's build-id is correct Arnaldo Carvalho de Melo
2018-01-06 14:11 ` Masami Hiramatsu
2018-01-11 12:31 ` Masami Hiramatsu
2018-01-11 14:59 ` Arnaldo Carvalho de Melo
2018-01-11 15:06 ` Arnaldo Carvalho de Melo
2018-01-11 16:21 ` Masami Hiramatsu
2017-12-18 7:29 ` [PATCH 2/2] perf-probe: Skip searching debuginfo if we know no debuginfo Masami Hiramatsu
2017-12-29 2:52 ` [PATCH 0/2] perf-probe: Improve warning message for buildid mismatch Masami Hiramatsu
2018-01-03 6:51 ` Ravi Bangoria
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=151358214328.25261.6660021248431426149.stgit@devbox \
--to=mhiramat@kernel.org \
--cc=acme@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).