Messages in this thread Patch in this message | | | From | Srikar Dronamraju <> | Date | Wed, 25 Aug 2010 19:13:57 +0530 | Subject | [PATCHv11 2.6.36-rc2-tip 13/15] 13: perf: Loop thro each of the maps in a map_group. |
| |
Introduces map_groups_for_each_map that iterates over a map_group. This is useful while listing functions through perf-probe.
Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com> Suggested-by: Arnaldo Carvalho de Melo <acme@infradead.org> --- tools/perf/util/map.h | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h index 7857579..45b5f50 100644 --- a/tools/perf/util/map.h +++ b/tools/perf/util/map.h @@ -54,6 +54,33 @@ struct map_groups { struct machine *machine; }; +/* For map_groups iteration */ +static inline struct map *map__first(struct map_groups *self, + enum map_type type) +{ + struct rb_node *rn = rb_first(&self->maps[type]); + return rn ? rb_entry(rn, struct map, rb_node) : NULL; +} + +static inline struct map *map__next(struct map *map) +{ + struct rb_node *rn; + if (!map) + return NULL; + rn = rb_next(&map->rb_node); + return rn ? rb_entry(rn, struct map, rb_node) : NULL; +} + +/** + * map_groups__for_each_map - iterate over a map_group + * @pos: the &struct map to use as a loop cursor. + * @type: the map type. + * @self: the &struct map_groups for loop. + */ +#define map_groups__for_each_map(pos, type, self) \ + for (pos = map__first(self, type); pos; \ + pos = map__next(pos)) + /* Native host kernel uses -1 as pid index in machine */ #define HOST_KERNEL_ID (-1) #define DEFAULT_GUEST_KERNEL_ID (0)
| |