aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/builtin-annotate.c5
-rw-r--r--tools/perf/util/map.c12
-rw-r--r--tools/perf/util/map.h9
3 files changed, 24 insertions, 2 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 4fc3899bf83a..28ea4e0c3658 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -189,7 +189,7 @@ static int parse_line(FILE *file, struct hist_entry *he, u64 len)
189 line_ip = -1; 189 line_ip = -1;
190 } 190 }
191 191
192 start = he->map->unmap_ip(he->map, sym->start); 192 start = map__rip_2objdump(he->map, sym->start);
193 193
194 if (line_ip != -1) { 194 if (line_ip != -1) {
195 const char *path = NULL; 195 const char *path = NULL;
@@ -397,7 +397,8 @@ static void annotate_sym(struct hist_entry *he)
397 dso, dso->long_name, sym, sym->name); 397 dso, dso->long_name, sym, sym->name);
398 398
399 sprintf(command, "objdump --start-address=0x%016Lx --stop-address=0x%016Lx -dS %s|grep -v %s", 399 sprintf(command, "objdump --start-address=0x%016Lx --stop-address=0x%016Lx -dS %s|grep -v %s",
400 map->unmap_ip(map, sym->start), map->unmap_ip(map, sym->end), 400 map__rip_2objdump(map, sym->start),
401 map__rip_2objdump(map, sym->end),
401 filename, filename); 402 filename, filename);
402 403
403 if (verbose >= 3) 404 if (verbose >= 3)
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index f6626cc3df2e..af5805f51314 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -210,3 +210,15 @@ size_t map__fprintf(struct map *self, FILE *fp)
210 return fprintf(fp, " %Lx-%Lx %Lx %s\n", 210 return fprintf(fp, " %Lx-%Lx %Lx %s\n",
211 self->start, self->end, self->pgoff, self->dso->name); 211 self->start, self->end, self->pgoff, self->dso->name);
212} 212}
213
214/*
215 * objdump wants/reports absolute IPs for ET_EXEC, and RIPs for ET_DYN.
216 * map->dso->adjust_symbols==1 for ET_EXEC-like cases.
217 */
218u64 map__rip_2objdump(struct map *map, u64 rip)
219{
220 u64 addr = map->dso->adjust_symbols ?
221 map->unmap_ip(map, rip) : /* RIP -> IP */
222 rip;
223 return addr;
224}
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index de048399d776..9cee9c788dbf 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -26,8 +26,12 @@ struct map {
26 u64 end; 26 u64 end;
27 enum map_type type; 27 enum map_type type;
28 u64 pgoff; 28 u64 pgoff;
29
30 /* ip -> dso rip */
29 u64 (*map_ip)(struct map *, u64); 31 u64 (*map_ip)(struct map *, u64);
32 /* dso rip -> ip */
30 u64 (*unmap_ip)(struct map *, u64); 33 u64 (*unmap_ip)(struct map *, u64);
34
31 struct dso *dso; 35 struct dso *dso;
32}; 36};
33 37
@@ -56,6 +60,11 @@ static inline u64 identity__map_ip(struct map *map __used, u64 ip)
56 return ip; 60 return ip;
57} 61}
58 62
63
64/* rip -> addr suitable for passing to `objdump --start-address=` */
65u64 map__rip_2objdump(struct map *map, u64 rip);
66
67
59struct symbol; 68struct symbol;
60struct mmap_event; 69struct mmap_event;
61 70