aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2010-03-26 11:30:40 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2010-04-02 15:27:43 -0400
commit7e5e1b1404c30db5f6bc3f5203b6c21c1d244f99 (patch)
tree1203765ed3e60af2ba7682677ed2553c6226f058
parentc6e718ff8cdcf5e7855077687720b37c4a07650a (diff)
perf symbols: map_groups__find_symbol must return the map too
Tools need to know from which map in the map_group a symbol was resolved to, so that, for isntance, we can annotate kernel modules symbols by getting its precise name, etc. Also add the _by_name variants for completeness. Cc: Frédéric Weisbecker <fweisbec@gmail.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>
-rw-r--r--tools/perf/builtin-kmem.c3
-rw-r--r--tools/perf/util/map.c28
-rw-r--r--tools/perf/util/map.h23
3 files changed, 48 insertions, 6 deletions
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 924a9518931a..32edb6a86876 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -369,7 +369,8 @@ static void __print_result(struct rb_root *root, struct perf_session *session,
369 if (is_caller) { 369 if (is_caller) {
370 addr = data->call_site; 370 addr = data->call_site;
371 if (!raw_ip) 371 if (!raw_ip)
372 sym = map_groups__find_function(&session->kmaps, addr, NULL); 372 sym = map_groups__find_function(&session->kmaps,
373 addr, NULL, NULL);
373 } else 374 } else
374 addr = data->ptr; 375 addr = data->ptr;
375 376
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index e21f98001734..37913b241bdf 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -268,12 +268,38 @@ void map_groups__flush(struct map_groups *self)
268 268
269struct symbol *map_groups__find_symbol(struct map_groups *self, 269struct symbol *map_groups__find_symbol(struct map_groups *self,
270 enum map_type type, u64 addr, 270 enum map_type type, u64 addr,
271 struct map **mapp,
271 symbol_filter_t filter) 272 symbol_filter_t filter)
272{ 273{
273 struct map *map = map_groups__find(self, type, addr); 274 struct map *map = map_groups__find(self, type, addr);
274 275
275 if (map != NULL) 276 if (map != NULL) {
277 if (mapp != NULL)
278 *mapp = map;
276 return map__find_symbol(map, map->map_ip(map, addr), filter); 279 return map__find_symbol(map, map->map_ip(map, addr), filter);
280 }
281
282 return NULL;
283}
284
285struct symbol *map_groups__find_symbol_by_name(struct map_groups *self,
286 enum map_type type,
287 const char *name,
288 struct map **mapp,
289 symbol_filter_t filter)
290{
291 struct rb_node *nd;
292
293 for (nd = rb_first(&self->maps[type]); nd; nd = rb_next(nd)) {
294 struct map *pos = rb_entry(nd, struct map, rb_node);
295 struct symbol *sym = map__find_symbol_by_name(pos, name, filter);
296
297 if (sym == NULL)
298 continue;
299 if (mapp != NULL)
300 *mapp = pos;
301 return sym;
302 }
277 303
278 return NULL; 304 return NULL;
279} 305}
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index 4e7a11da8ffe..2031278cc06a 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -119,13 +119,28 @@ static inline struct map *map_groups__find(struct map_groups *self,
119 119
120struct symbol *map_groups__find_symbol(struct map_groups *self, 120struct symbol *map_groups__find_symbol(struct map_groups *self,
121 enum map_type type, u64 addr, 121 enum map_type type, u64 addr,
122 struct map **mapp,
122 symbol_filter_t filter); 123 symbol_filter_t filter);
123 124
124static inline struct symbol *map_groups__find_function(struct map_groups *self, 125struct symbol *map_groups__find_symbol_by_name(struct map_groups *self,
125 u64 addr, 126 enum map_type type,
126 symbol_filter_t filter) 127 const char *name,
128 struct map **mapp,
129 symbol_filter_t filter);
130
131static inline
132struct symbol *map_groups__find_function(struct map_groups *self, u64 addr,
133 struct map **mapp, symbol_filter_t filter)
134{
135 return map_groups__find_symbol(self, MAP__FUNCTION, addr, mapp, filter);
136}
137
138static inline
139struct symbol *map_groups__find_function_by_name(struct map_groups *self,
140 const char *name, struct map **mapp,
141 symbol_filter_t filter)
127{ 142{
128 return map_groups__find_symbol(self, MAP__FUNCTION, addr, filter); 143 return map_groups__find_symbol_by_name(self, MAP__FUNCTION, name, mapp, filter);
129} 144}
130 145
131int map_groups__fixup_overlappings(struct map_groups *self, struct map *map, 146int map_groups__fixup_overlappings(struct map_groups *self, struct map *map,