diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-10-19 17:17:57 -0200 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-10-20 07:55:51 +0200 |
commit | ed52ce2e3c33dc7626a40fa2da766d1a6460e543 (patch) | |
tree | 037f7791b8f493b1adc27d9f9692922ed886844e /tools/perf/util | |
parent | bbe2987bea26a684ff11d887dfc4cf39b22c27a2 (diff) | |
download | blackbird-op-linux-ed52ce2e3c33dc7626a40fa2da766d1a6460e543.tar.gz blackbird-op-linux-ed52ce2e3c33dc7626a40fa2da766d1a6460e543.zip |
perf tools: Add ->unmap_ip operation to struct map
We need this because we get section relative addresses when
reading the symtabs, but when a tool like 'perf annotate' needs
to match these address to what 'objdump -dS' produces we need
the address + section back again.
So in annotate now we look at the 'struct hist_entry' instances
(that weren't really being used) so that we iterate only over
the symbols that had some hit and get the map where that
particular hit happened so that we can get the right address to
match with annotate.
Verified that at least:
perf annotate mmap_read_counter # Uses the ~/bin/perf binary
perf annotate --vmlinux /home/acme/git/build/perf/vmlinux intel_pmu_enable_all
on a 'perf record perf top' session seems to work.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Mike Galbraith <efault@gmx.de>
LKML-Reference: <1255979877-12533-1-git-send-email-acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util')
-rw-r--r-- | tools/perf/util/event.h | 8 | ||||
-rw-r--r-- | tools/perf/util/map.c | 6 | ||||
-rw-r--r-- | tools/perf/util/symbol.c | 8 |
3 files changed, 16 insertions, 6 deletions
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index c2e62be62798..6b5be56a8271 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -82,6 +82,7 @@ struct map { u64 end; u64 pgoff; u64 (*map_ip)(struct map *, u64); + u64 (*unmap_ip)(struct map *, u64); struct dso *dso; }; @@ -90,7 +91,12 @@ static inline u64 map__map_ip(struct map *map, u64 ip) return ip - map->start + map->pgoff; } -static inline u64 vdso__map_ip(struct map *map __used, u64 ip) +static inline u64 map__unmap_ip(struct map *map, u64 ip) +{ + return ip + map->start - map->pgoff; +} + +static inline u64 identity__map_ip(struct map *map __used, u64 ip) { return ip; } diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index 804e02382739..4e203d144f9e 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c @@ -54,9 +54,11 @@ static int strcommon(const char *pathname, char *cwd, int cwdlen) goto out_delete; if (self->dso == vdso || anon) - self->map_ip = vdso__map_ip; - else + self->map_ip = self->unmap_ip = identity__map_ip; + else { self->map_ip = map__map_ip; + self->unmap_ip = map__unmap_ip; + } } return self; out_delete: diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index faa84f5d4f54..3350119f6909 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -337,7 +337,7 @@ static int kernel_maps__split_kallsyms(symbol_filter_t filter, int use_modules) return -1; } - map->map_ip = vdso__map_ip; + map->map_ip = map->unmap_ip = identity__map_ip; kernel_maps__insert(map); ++kernel_range; } @@ -790,7 +790,8 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name, dso__delete(curr_dso); goto out_elf_end; } - curr_map->map_ip = vdso__map_ip; + curr_map->map_ip = identity__map_ip; + curr_map->unmap_ip = identity__map_ip; curr_dso->origin = DSO__ORIG_KERNEL; kernel_maps__insert(curr_map); dsos__add(curr_dso); @@ -1158,6 +1159,7 @@ static struct map *map__new2(u64 start, struct dso *dso) self->pgoff = 0; self->dso = dso; self->map_ip = map__map_ip; + self->unmap_ip = map__unmap_ip; RB_CLEAR_NODE(&self->rb_node); } return self; @@ -1259,7 +1261,7 @@ int dsos__load_kernel(const char *vmlinux, unsigned int sym_priv_size, if (kernel_map == NULL) goto out_delete_dso; - kernel_map->map_ip = vdso__map_ip; + kernel_map->map_ip = kernel_map->unmap_ip = identity__map_ip; if (use_modules && dsos__load_modules(sym_priv_size) < 0) { fprintf(stderr, "Failed to load list of modules in use! " |