lkml.org 
[lkml]   [2013]   [Sep]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH V2 05/10] perf tools: add map__find_other_map_symbol()
Date
Add a function to find a symbol using an ip that
might be on a different map.

Signed-off-by: Adrian Hunter <adrian.hunter@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


\
 
 \ /
  Last update: 2013-09-22 12:41    [W:0.097 / U:2.712 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site