提交 dc8d6ab2 编写于 作者: A Arnaldo Carvalho de Melo 提交者: Ingo Molnar

perf symbols: Use only --vmlinux if specified

Found while analysing a perf.data file collected on an ARM
machine where an explicitely specified vmlinux was being
disregarded.
Reported-by: NJamie Iles <jamie.iles@picochip.com>
Signed-off-by: NArnaldo 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: <1263904574-30732-2-git-send-email-acme@infradead.org>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
上级 f162f87a
...@@ -1572,7 +1572,7 @@ static int dso__load_vmlinux(struct dso *self, struct map *map, ...@@ -1572,7 +1572,7 @@ static int dso__load_vmlinux(struct dso *self, struct map *map,
return -1; return -1;
dso__set_loaded(self, map->type); dso__set_loaded(self, map->type);
err = dso__load_sym(self, map, session, self->long_name, fd, filter, 1, 0); err = dso__load_sym(self, map, session, vmlinux, fd, filter, 1, 0);
close(fd); close(fd);
return err; return err;
...@@ -1584,6 +1584,26 @@ static int dso__load_kernel_sym(struct dso *self, struct map *map, ...@@ -1584,6 +1584,26 @@ static int dso__load_kernel_sym(struct dso *self, struct map *map,
int err; int err;
const char *kallsyms_filename = NULL; const char *kallsyms_filename = NULL;
char *kallsyms_allocated_filename = NULL; char *kallsyms_allocated_filename = NULL;
/*
* Step 1: if the user specified a vmlinux filename, use it and only
* it, reporting errors to the user if it cannot be used.
*
* For instance, try to analyse an ARM perf.data file _without_ a
* build-id, or if the user specifies the wrong path to the right
* vmlinux file, obviously we can't fallback to another vmlinux (a
* x86_86 one, on the machine where analysis is being performed, say),
* or worse, /proc/kallsyms.
*
* If the specified file _has_ a build-id and there is a build-id
* section in the perf.data file, we will still do the expected
* validation in dso__load_vmlinux and will bail out if they don't
* match.
*/
if (symbol_conf.vmlinux_name != NULL) {
err = dso__load_vmlinux(self, map, session,
symbol_conf.vmlinux_name, filter);
goto out_try_fixup;
}
if (vmlinux_path != NULL) { if (vmlinux_path != NULL) {
int i; int i;
...@@ -1618,46 +1638,41 @@ static int dso__load_kernel_sym(struct dso *self, struct map *map, ...@@ -1618,46 +1638,41 @@ static int dso__load_kernel_sym(struct dso *self, struct map *map,
goto do_kallsyms; goto do_kallsyms;
} }
} }
/*
* Now look if we have it on the build-id cache in
* $HOME/.debug/[kernel.kallsyms].
*/
build_id__sprintf(self->build_id, sizeof(self->build_id), build_id__sprintf(self->build_id, sizeof(self->build_id),
sbuild_id); sbuild_id);
if (asprintf(&kallsyms_allocated_filename, if (asprintf(&kallsyms_allocated_filename,
"%s/.debug/[kernel.kallsyms]/%s", "%s/.debug/[kernel.kallsyms]/%s",
getenv("HOME"), sbuild_id) != -1) { getenv("HOME"), sbuild_id) == -1)
if (access(kallsyms_filename, F_OK)) { return -1;
kallsyms_filename = kallsyms_allocated_filename;
goto do_kallsyms; if (access(kallsyms_filename, F_OK)) {
}
free(kallsyms_allocated_filename); free(kallsyms_allocated_filename);
kallsyms_allocated_filename = NULL; return -1;
} }
goto do_vmlinux; kallsyms_filename = kallsyms_allocated_filename;
} } else {
/*
if (self->long_name[0] == '[') { * Last resort, if we don't have a build-id and couldn't find
* any vmlinux file, try the running kernel kallsyms table.
*/
kallsyms_filename = "/proc/kallsyms"; kallsyms_filename = "/proc/kallsyms";
goto do_kallsyms;
} }
do_vmlinux:
err = dso__load_vmlinux(self, map, session, self->long_name, filter);
if (err <= 0) {
if (self->has_build_id)
return -1;
pr_info("The file %s cannot be used, "
"trying to use /proc/kallsyms...", self->long_name);
do_kallsyms: do_kallsyms:
err = dso__load_kallsyms(self, kallsyms_filename, map, session, filter); err = dso__load_kallsyms(self, kallsyms_filename, map, session, filter);
if (err > 0 && kallsyms_filename == NULL) free(kallsyms_allocated_filename);
dso__set_long_name(self, strdup("[kernel.kallsyms]"));
free(kallsyms_allocated_filename);
}
out_try_fixup:
if (err > 0) { if (err > 0) {
out_fixup: out_fixup:
if (kallsyms_filename == NULL)
dso__set_long_name(self, strdup("[kernel.kallsyms]"));
map__fixup_start(map); map__fixup_start(map);
map__fixup_end(map); map__fixup_end(map);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册