Add a function to find a symbol using an ip that
might be on a different map.

Signed-off-by: Adrian Hunter <adrian.hun...@intel.com>
---
 tools/perf/util/map.c | 27 +++++++++++++++++++++++++++
 tools/perf/util/map.h |  2 ++
 2 files changed, 29 insertions(+)

diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 4f6680d..beedeef 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -213,6 +213,33 @@ struct symbol *map__find_symbol_by_name(struct map *map, 
const char *name,
        return dso__find_symbol_by_name(map->dso, map->type, name);
 }
 
+struct symbol *map__find_other_map_symbol(struct map **map_ptr, u64 *ip_ptr,
+                                         symbol_filter_t filter)
+{
+       struct map *map = *map_ptr;
+       u64 ip = *ip_ptr;
+       struct map *sym_map = NULL;
+       struct symbol *sym;
+
+       if (ip >= map->start && ip <= map->end)
+               sym_map = map;
+       else if (map->groups)
+               sym_map = map_groups__find(map->groups, map->type, ip);
+
+       if (!sym_map)
+               return NULL;
+
+       ip = sym_map->map_ip(sym_map, ip);
+
+       sym = map__find_symbol(sym_map, ip, filter);
+       if (sym) {
+               *map_ptr = sym_map;
+               *ip_ptr = ip;
+       }
+
+       return sym;
+}
+
 struct map *map__clone(struct map *map)
 {
        return memdup(map, sizeof(*map));
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index 4886ca2..b7b494c 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -106,6 +106,8 @@ struct symbol *map__find_symbol(struct map *map,
                                u64 addr, symbol_filter_t filter);
 struct symbol *map__find_symbol_by_name(struct map *map, const char *name,
                                        symbol_filter_t filter);
+struct symbol *map__find_other_map_symbol(struct map **map_ptr, u64 *ip_ptr,
+                                         symbol_filter_t filter);
 void map__fixup_start(struct map *map);
 void map__fixup_end(struct map *map);
 
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to