perf symbols: Add map_groups__find_ams()
authorArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 14 Oct 2013 10:43:38 +0000 (13:43 +0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 14 Oct 2013 13:29:02 +0000 (10:29 -0300)
Add a function to find a symbol using an ip that might be on a different
map.

Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1381747424-3557-2-git-send-email-adrian.hunter@intel.com
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/map.c
tools/perf/util/map.h

index 17ee458a0870940b7e2f715a66b7f6bab4f599b1..9dea404de3fae244e090fdfdd9d3a07120bc8335 100644 (file)
@@ -371,6 +371,23 @@ 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)
 {
index 4886ca2805361df87a57c9f4406ed5c38fe418b5..0359b4a808f06478cbb2027d76fff6261594f799 100644 (file)
@@ -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,