diff options
author | Adrian Hunter <adrian.hunter@intel.com> | 2013-10-14 06:43:44 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-10-14 11:21:18 -0400 |
commit | 1d5077bdd9a10c4297cded139989bb9ee2998a6c (patch) | |
tree | 2d072c0a31e42cdeba837f85058f39b5b034f06c /tools/perf/util/map.c | |
parent | fc1b691d7651d9496e912de7e0fc73a5be3294af (diff) |
perf annotate: Another fix for annotate_browser__callq()
The target address is provided by objdump and is not necessary a memory
address. Add a helper to get the correct address.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1381747424-3557-8-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/map.c')
-rw-r--r-- | tools/perf/util/map.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index 9dea404de3fa..ef5bc913ca7a 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c | |||
@@ -252,10 +252,16 @@ size_t map__fprintf_dsoname(struct map *map, FILE *fp) | |||
252 | return fprintf(fp, "%s", dsoname); | 252 | return fprintf(fp, "%s", dsoname); |
253 | } | 253 | } |
254 | 254 | ||
255 | /* | 255 | /** |
256 | * map__rip_2objdump - convert symbol start address to objdump address. | ||
257 | * @map: memory map | ||
258 | * @rip: symbol start address | ||
259 | * | ||
256 | * objdump wants/reports absolute IPs for ET_EXEC, and RIPs for ET_DYN. | 260 | * objdump wants/reports absolute IPs for ET_EXEC, and RIPs for ET_DYN. |
257 | * map->dso->adjust_symbols==1 for ET_EXEC-like cases except ET_REL which is | 261 | * map->dso->adjust_symbols==1 for ET_EXEC-like cases except ET_REL which is |
258 | * relative to section start. | 262 | * relative to section start. |
263 | * | ||
264 | * Return: Address suitable for passing to "objdump --start-address=" | ||
259 | */ | 265 | */ |
260 | u64 map__rip_2objdump(struct map *map, u64 rip) | 266 | u64 map__rip_2objdump(struct map *map, u64 rip) |
261 | { | 267 | { |
@@ -268,6 +274,29 @@ u64 map__rip_2objdump(struct map *map, u64 rip) | |||
268 | return map->unmap_ip(map, rip); | 274 | return map->unmap_ip(map, rip); |
269 | } | 275 | } |
270 | 276 | ||
277 | /** | ||
278 | * map__objdump_2mem - convert objdump address to a memory address. | ||
279 | * @map: memory map | ||
280 | * @ip: objdump address | ||
281 | * | ||
282 | * Closely related to map__rip_2objdump(), this function takes an address from | ||
283 | * objdump and converts it to a memory address. Note this assumes that @map | ||
284 | * contains the address. To be sure the result is valid, check it forwards | ||
285 | * e.g. map__rip_2objdump(map->map_ip(map, map__objdump_2mem(map, ip))) == ip | ||
286 | * | ||
287 | * Return: Memory address. | ||
288 | */ | ||
289 | u64 map__objdump_2mem(struct map *map, u64 ip) | ||
290 | { | ||
291 | if (!map->dso->adjust_symbols) | ||
292 | return map->unmap_ip(map, ip); | ||
293 | |||
294 | if (map->dso->rel) | ||
295 | return map->unmap_ip(map, ip + map->pgoff); | ||
296 | |||
297 | return ip; | ||
298 | } | ||
299 | |||
271 | void map_groups__init(struct map_groups *mg) | 300 | void map_groups__init(struct map_groups *mg) |
272 | { | 301 | { |
273 | int i; | 302 | int i; |