diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-11-20 17:51:28 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-11-21 08:11:34 -0500 |
commit | fbd733b815a5a57d7eb0d904edc49d18fd12df5c (patch) | |
tree | 32f1cc08a2d77d2bd642d4982cf5b26006706bb9 /tools | |
parent | c338aee853db197e1855b393e6d6cc667784537f (diff) |
perf symbols: Check vmlinux buildid
E.g.:
[root@doppio linux-2.6-tip]# perf top -v --vmlinux
../build/tip/vmlinux > /dev/null build_id in vmlinux is
e96699725a47413a50c231864a8e7a8ced40a31b while expected is
18e7cc53db62a7d35e9d6f6c9ddc23017d38ee9a, ignoring it
I.e. perf top was told to use a vmlinux file that is not the one
currently running on the machine, it ignores it and falls back
to using /proc/kallsyms.
This solves many, at first, mysterious results when people have
a stale vmlinux file while keeping the default of trying to use
the vmlinux file in the current directory in things like 'perf
annotate' where the DWARF info is required and thus we can't use
just /proc/kallsyms.
Modules buildids are already being checked as of the previous
changeset in this series, because we are using the default
dso__load routine, that will look at a series of places looking
for the best file with a matching buildid, starting in the
-debuginfo directories.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1258757489-5978-5-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/symbol.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index cb086cbe6b10..9cf6dbcd158c 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -1334,13 +1334,37 @@ out_failure: | |||
1334 | static int dso__load_vmlinux(struct dso *self, struct map *map, | 1334 | static int dso__load_vmlinux(struct dso *self, struct map *map, |
1335 | const char *vmlinux, symbol_filter_t filter) | 1335 | const char *vmlinux, symbol_filter_t filter) |
1336 | { | 1336 | { |
1337 | int err, fd = open(vmlinux, O_RDONLY); | 1337 | int err = -1, fd; |
1338 | 1338 | ||
1339 | self->loaded = 1; | 1339 | if (self->has_build_id) { |
1340 | u8 build_id[BUILD_ID_SIZE]; | ||
1341 | |||
1342 | if (filename__read_build_id(vmlinux, build_id, | ||
1343 | sizeof(build_id)) < 0) { | ||
1344 | pr_debug("No build_id in %s, ignoring it\n", vmlinux); | ||
1345 | return -1; | ||
1346 | } | ||
1347 | if (!dso__build_id_equal(self, build_id)) { | ||
1348 | char expected_build_id[BUILD_ID_SIZE * 2 + 1], | ||
1349 | vmlinux_build_id[BUILD_ID_SIZE * 2 + 1]; | ||
1350 | |||
1351 | build_id__sprintf(self->build_id, | ||
1352 | sizeof(self->build_id), | ||
1353 | expected_build_id); | ||
1354 | build_id__sprintf(build_id, sizeof(build_id), | ||
1355 | vmlinux_build_id); | ||
1356 | pr_debug("build_id in %s is %s while expected is %s, " | ||
1357 | "ignoring it\n", vmlinux, vmlinux_build_id, | ||
1358 | expected_build_id); | ||
1359 | return -1; | ||
1360 | } | ||
1361 | } | ||
1340 | 1362 | ||
1363 | fd = open(vmlinux, O_RDONLY); | ||
1341 | if (fd < 0) | 1364 | if (fd < 0) |
1342 | return -1; | 1365 | return -1; |
1343 | 1366 | ||
1367 | self->loaded = 1; | ||
1344 | err = dso__load_sym(self, map, self->long_name, fd, filter, 1, 0); | 1368 | err = dso__load_sym(self, map, self->long_name, fd, filter, 1, 0); |
1345 | 1369 | ||
1346 | close(fd); | 1370 | close(fd); |