aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/perf/util/hist.c13
1 files changed, 11 insertions, 2 deletions
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)
990 struct map *map = self->ms.map; 990 struct map *map = self->ms.map;
991 struct dso *dso = map->dso; 991 struct dso *dso = map->dso;
992 char *filename = dso__build_id_filename(dso, NULL, 0); 992 char *filename = dso__build_id_filename(dso, NULL, 0);
993 bool free_filename = true;
993 char command[PATH_MAX * 2]; 994 char command[PATH_MAX * 2];
994 FILE *file; 995 FILE *file;
995 int err = 0; 996 int err = 0;
@@ -1001,11 +1002,19 @@ int hist_entry__annotate(struct hist_entry *self, struct list_head *head)
1001 sym->name); 1002 sym->name);
1002 return -ENOMEM; 1003 return -ENOMEM;
1003 } 1004 }
1005 goto fallback;
1006 } else if (readlink(filename, command, sizeof(command)) < 0 ||
1007 strstr(command, "[kernel.kallsyms]") ||
1008 access(filename, R_OK)) {
1009 free(filename);
1010fallback:
1004 /* 1011 /*
1005 * If we don't have build-ids, well, lets hope that this 1012 * If we don't have build-ids or the build-id file isn't in the
1013 * cache, or is just a kallsyms file, well, lets hope that this
1006 * DSO is the same as when 'perf record' ran. 1014 * DSO is the same as when 'perf record' ran.
1007 */ 1015 */
1008 filename = dso->long_name; 1016 filename = dso->long_name;
1017 free_filename = false;
1009 } 1018 }
1010 1019
1011 if (dso->origin == DSO__ORIG_KERNEL) { 1020 if (dso->origin == DSO__ORIG_KERNEL) {
@@ -1045,7 +1054,7 @@ int hist_entry__annotate(struct hist_entry *self, struct list_head *head)
1045 1054
1046 pclose(file); 1055 pclose(file);
1047out_free_filename: 1056out_free_filename:
1048 if (dso->has_build_id) 1057 if (free_filename)
1049 free(filename); 1058 free(filename);
1050 return err; 1059 return err;
1051} 1060}