aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/annotate.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/annotate.c')
-rw-r--r--tools/perf/util/annotate.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 22cd1dbe724b..11af5f0d56cc 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1307,6 +1307,7 @@ static int dso__disassemble_filename(struct dso *dso, char *filename, size_t fil
1307{ 1307{
1308 char linkname[PATH_MAX]; 1308 char linkname[PATH_MAX];
1309 char *build_id_filename; 1309 char *build_id_filename;
1310 char *build_id_path = NULL;
1310 1311
1311 if (dso->symtab_type == DSO_BINARY_TYPE__KALLSYMS && 1312 if (dso->symtab_type == DSO_BINARY_TYPE__KALLSYMS &&
1312 !dso__is_kcore(dso)) 1313 !dso__is_kcore(dso))
@@ -1322,8 +1323,14 @@ static int dso__disassemble_filename(struct dso *dso, char *filename, size_t fil
1322 goto fallback; 1323 goto fallback;
1323 } 1324 }
1324 1325
1326 build_id_path = strdup(filename);
1327 if (!build_id_path)
1328 return -1;
1329
1330 dirname(build_id_path);
1331
1325 if (dso__is_kcore(dso) || 1332 if (dso__is_kcore(dso) ||
1326 readlink(filename, linkname, sizeof(linkname)) < 0 || 1333 readlink(build_id_path, linkname, sizeof(linkname)) < 0 ||
1327 strstr(linkname, DSO__NAME_KALLSYMS) || 1334 strstr(linkname, DSO__NAME_KALLSYMS) ||
1328 access(filename, R_OK)) { 1335 access(filename, R_OK)) {
1329fallback: 1336fallback:
@@ -1335,6 +1342,7 @@ fallback:
1335 __symbol__join_symfs(filename, filename_size, dso->long_name); 1342 __symbol__join_symfs(filename, filename_size, dso->long_name);
1336 } 1343 }
1337 1344
1345 free(build_id_path);
1338 return 0; 1346 return 0;
1339} 1347}
1340 1348
@@ -1663,18 +1671,23 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map,
1663 src_line->nr_pcnt = nr_pcnt; 1671 src_line->nr_pcnt = nr_pcnt;
1664 1672
1665 for (k = 0; k < nr_pcnt; k++) { 1673 for (k = 0; k < nr_pcnt; k++) {
1674 double percent = 0.0;
1675
1666 h = annotation__histogram(notes, evidx + k); 1676 h = annotation__histogram(notes, evidx + k);
1667 src_line->samples[k].percent = 100.0 * h->addr[i] / h->sum; 1677 if (h->sum)
1678 percent = 100.0 * h->addr[i] / h->sum;
1668 1679
1669 if (src_line->samples[k].percent > percent_max) 1680 if (percent > percent_max)
1670 percent_max = src_line->samples[k].percent; 1681 percent_max = percent;
1682 src_line->samples[k].percent = percent;
1671 } 1683 }
1672 1684
1673 if (percent_max <= 0.5) 1685 if (percent_max <= 0.5)
1674 goto next; 1686 goto next;
1675 1687
1676 offset = start + i; 1688 offset = start + i;
1677 src_line->path = get_srcline(map->dso, offset, NULL, false); 1689 src_line->path = get_srcline(map->dso, offset, NULL,
1690 false, true);
1678 insert_source_line(&tmp_root, src_line); 1691 insert_source_line(&tmp_root, src_line);
1679 1692
1680 next: 1693 next: