diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-04-01 20:24:38 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-04-02 15:28:25 -0400 |
commit | 71cf8b8ff7d6a79af086be9e4c72628da9d62d58 (patch) | |
tree | 8a8d6f97995133971d8f8bec3f4a885070ce103f /tools/perf | |
parent | e727ca73f85d4c5be3547eda674168219d1c22d8 (diff) |
perf kmem: Fixup the symbol address before using it
We get absolute addresses in the events, but relative ones from the
symbol subsystem, so calculate the absolute address by asking for the
map where the symbol was found, that has the place where the DSO was
actually loaded.
For the core kernel this poses no problems if the kernel is not
relocated by things like kexec, or if we use /proc/kallsyms, but for
modules we were getting really large, negative offsets.
LKML-Reference: <new-submission>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/builtin-kmem.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 7cbb5eb15101..513aa8a55db6 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c | |||
@@ -363,6 +363,7 @@ static void __print_result(struct rb_root *root, struct perf_session *session, | |||
363 | struct alloc_stat *data = rb_entry(next, struct alloc_stat, | 363 | struct alloc_stat *data = rb_entry(next, struct alloc_stat, |
364 | node); | 364 | node); |
365 | struct symbol *sym = NULL; | 365 | struct symbol *sym = NULL; |
366 | struct map *map; | ||
366 | char buf[BUFSIZ]; | 367 | char buf[BUFSIZ]; |
367 | u64 addr; | 368 | u64 addr; |
368 | 369 | ||
@@ -370,13 +371,13 @@ static void __print_result(struct rb_root *root, struct perf_session *session, | |||
370 | addr = data->call_site; | 371 | addr = data->call_site; |
371 | if (!raw_ip) | 372 | if (!raw_ip) |
372 | sym = map_groups__find_function(&session->kmaps, | 373 | sym = map_groups__find_function(&session->kmaps, |
373 | addr, NULL, NULL); | 374 | addr, &map, NULL); |
374 | } else | 375 | } else |
375 | addr = data->ptr; | 376 | addr = data->ptr; |
376 | 377 | ||
377 | if (sym != NULL) | 378 | if (sym != NULL) |
378 | snprintf(buf, sizeof(buf), "%s+%Lx", sym->name, | 379 | snprintf(buf, sizeof(buf), "%s+%Lx", sym->name, |
379 | addr - sym->start); | 380 | addr - map->unmap_ip(map, sym->start)); |
380 | else | 381 | else |
381 | snprintf(buf, sizeof(buf), "%#Lx", addr); | 382 | snprintf(buf, sizeof(buf), "%#Lx", addr); |
382 | printf(" %-34s |", buf); | 383 | printf(" %-34s |", buf); |