From: Arnaldo Carvalho de Melo Date: Sun, 23 May 2010 22:12:25 +0000 (-0300) Subject: perf annotate: Fix up usage of the build id cache X-Git-Tag: firefly_0821_release~9833^2~1617^2~7 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=44bf460649a9b91f291176097e9d7e846e8c001e;p=firefly-linux-kernel-4.4.55.git perf annotate: Fix up usage of the build id cache It was assuming that the cache was always available and also wasn't checking if the file found in the build id cache was just a kallsyms file, that is not supported by objdump for disassembly. Reported-by: Ingo Molnar Cc: Frédéric Weisbecker Cc: Mike Galbraith Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Cc: Tom Zanussi LKML-Reference: Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 682a6d88862c..cbf7eae2ce09 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -990,6 +990,7 @@ int hist_entry__annotate(struct hist_entry *self, struct list_head *head) struct map *map = self->ms.map; struct dso *dso = map->dso; char *filename = dso__build_id_filename(dso, NULL, 0); + bool free_filename = true; char command[PATH_MAX * 2]; FILE *file; int err = 0; @@ -1001,11 +1002,19 @@ int hist_entry__annotate(struct hist_entry *self, struct list_head *head) sym->name); return -ENOMEM; } + goto fallback; + } else if (readlink(filename, command, sizeof(command)) < 0 || + strstr(command, "[kernel.kallsyms]") || + access(filename, R_OK)) { + free(filename); +fallback: /* - * If we don't have build-ids, well, lets hope that this + * If we don't have build-ids or the build-id file isn't in the + * cache, or is just a kallsyms file, well, lets hope that this * DSO is the same as when 'perf record' ran. */ filename = dso->long_name; + free_filename = false; } if (dso->origin == DSO__ORIG_KERNEL) { @@ -1045,7 +1054,7 @@ int hist_entry__annotate(struct hist_entry *self, struct list_head *head) pclose(file); out_free_filename: - if (dso->has_build_id) + if (free_filename) free(filename); return err; }