aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/hist.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/hist.c')
-rw-r--r--tools/perf/util/hist.c36
1 files changed, 27 insertions, 9 deletions
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index f75c5f62401c..739c39fd0ade 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1,3 +1,4 @@
1#include "build-id.h"
1#include "util.h" 2#include "util.h"
2#include "hist.h" 3#include "hist.h"
3#include "session.h" 4#include "session.h"
@@ -662,7 +663,7 @@ size_t hists__fprintf(struct hists *self, struct hists *pair,
662 long displacement = 0; 663 long displacement = 0;
663 unsigned int width; 664 unsigned int width;
664 const char *sep = symbol_conf.field_sep; 665 const char *sep = symbol_conf.field_sep;
665 char *col_width = symbol_conf.col_width_list_str; 666 const char *col_width = symbol_conf.col_width_list_str;
666 667
667 init_rem_hits(); 668 init_rem_hits();
668 669
@@ -988,22 +989,35 @@ int hist_entry__annotate(struct hist_entry *self, struct list_head *head)
988 struct symbol *sym = self->ms.sym; 989 struct symbol *sym = self->ms.sym;
989 struct map *map = self->ms.map; 990 struct map *map = self->ms.map;
990 struct dso *dso = map->dso; 991 struct dso *dso = map->dso;
991 const char *filename = dso->long_name; 992 char *filename = dso__build_id_filename(dso, NULL, 0);
992 char command[PATH_MAX * 2]; 993 char command[PATH_MAX * 2];
993 FILE *file; 994 FILE *file;
995 int err = -1;
994 u64 len; 996 u64 len;
995 997
996 if (!filename) 998 if (filename == NULL) {
997 return -1; 999 if (dso->has_build_id) {
1000 pr_err("Can't annotate %s: not enough memory\n",
1001 sym->name);
1002 return -1;
1003 }
1004 /*
1005 * If we don't have build-ids, well, lets hope that this
1006 * DSO is the same as when 'perf record' ran.
1007 */
1008 filename = dso->long_name;
1009 }
998 1010
999 if (dso->origin == DSO__ORIG_KERNEL) { 1011 if (dso->origin == DSO__ORIG_KERNEL) {
1000 if (dso->annotate_warned) 1012 if (dso->annotate_warned) {
1001 return 0; 1013 err = 0;
1014 goto out_free_filename;
1015 }
1002 dso->annotate_warned = 1; 1016 dso->annotate_warned = 1;
1003 pr_err("Can't annotate %s: No vmlinux file was found in the " 1017 pr_err("Can't annotate %s: No vmlinux file was found in the "
1004 "path:\n", sym->name); 1018 "path:\n", sym->name);
1005 vmlinux_path__fprintf(stderr); 1019 vmlinux_path__fprintf(stderr);
1006 return -1; 1020 goto out_free_filename;
1007 } 1021 }
1008 1022
1009 pr_debug("%s: filename=%s, sym=%s, start=%#Lx, end=%#Lx\n", __func__, 1023 pr_debug("%s: filename=%s, sym=%s, start=%#Lx, end=%#Lx\n", __func__,
@@ -1025,14 +1039,18 @@ int hist_entry__annotate(struct hist_entry *self, struct list_head *head)
1025 1039
1026 file = popen(command, "r"); 1040 file = popen(command, "r");
1027 if (!file) 1041 if (!file)
1028 return -1; 1042 goto out_free_filename;
1029 1043
1030 while (!feof(file)) 1044 while (!feof(file))
1031 if (hist_entry__parse_objdump_line(self, file, head) < 0) 1045 if (hist_entry__parse_objdump_line(self, file, head) < 0)
1032 break; 1046 break;
1033 1047
1034 pclose(file); 1048 pclose(file);
1035 return 0; 1049 err = 0;
1050out_free_filename:
1051 if (dso->has_build_id)
1052 free(filename);
1053 return err;
1036} 1054}
1037 1055
1038void hists__inc_nr_events(struct hists *self, u32 type) 1056void hists__inc_nr_events(struct hists *self, u32 type)