lkml.org 
[lkml]   [2013]   [Oct]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH V6 3/8] perf tools: add map__find_other_map_symbol()
Em Wed, Oct 09, 2013 at 03:01:13PM +0300, Adrian Hunter escreveu:
> 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>

Can you take a look at the following patch? Since we have an
addr_map_symbol struct and the method looks more appropriate to be at
the map_groups abstraction, I thought this is simpler, what do you
think?

This struct is used in the machine__resolve_{mem,bstack} functions.

- Arnaldo

diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 17ee458a0870..8f80463d9d46 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -371,6 +371,22 @@ struct symbol *map_groups__find_symbol_by_name(struct map_groups *mg,
return NULL;
}

+int map_groups__find_ams(struct addr_map_symbol *ams, symbol_filter_t filter)
+{
+ if (ams->addr < ams->map->start || ams->addr > ams->map->end) {
+ if (ams->map->groups == NULL)
+ return -1;
+ ams->map = map_groups__find(ams->map->groups, ams->map->type, ams->addr);
+ if (ams->map == NULL)
+ return -1;
+ }
+
+ ams->al_addr = ams->map->map_ip(ams->map, ams->addr);
+ ams->sym = map__find_symbol(ams->map, ams->al_addr, filter);
+
+ return ams->sym ? 0 : -1;
+}
+
size_t __map_groups__fprintf_maps(struct map_groups *mg,
enum map_type type, int verbose, FILE *fp)
{
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index 4886ca280536..0359b4a808f0 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -167,6 +167,10 @@ struct symbol *map_groups__find_symbol_by_name(struct map_groups *mg,
struct map **mapp,
symbol_filter_t filter);

+struct addr_map_symbol;
+
+int map_groups__find_ams(struct addr_map_symbol *ams, symbol_filter_t filter);
+
static inline
struct symbol *map_groups__find_function_by_name(struct map_groups *mg,
const char *name, struct map **mapp,

\
 
 \ /
  Last update: 2013-10-11 16:01    [W:0.177 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site