From 8562640b58b2469574918c2937fb1d4563b62485 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Thu, 24 May 2007 12:40:43 -0300 Subject: [PATCH] [LIB]: Rename type__find_tag_by_id to namespace__find_tag_by_id Go down the rabbit hole baby, oops, the namespace hole that is. Now we find types inside namespaces. Off to implement namespace__fprintf so that we can see more brunnetes and blondes out of the DWARF encoding 8) Signed-off-by: Arnaldo Carvalho de Melo --- dwarves.c | 20 +++++++++++--------- dwarves.h | 8 ++++++++ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/dwarves.c b/dwarves.c index a83442f..feb097b 100644 --- a/dwarves.c +++ b/dwarves.c @@ -569,23 +569,24 @@ static const char *tag__prefix(const struct cu *cu, const uint32_t tag) return ""; } -static struct tag *type__find_tag_by_id(const struct type *self, - const Dwarf_Off id) +static struct tag *namespace__find_tag_by_id(const struct namespace *self, + const Dwarf_Off id) { struct tag *pos; if (id == 0) return NULL; - type__for_each_tag(self, pos) { + namespace__for_each_tag(self, pos) { if (pos->id == id) return pos; - /* Look if we have types within types */ + /* Look for nested namespaces */ if (pos->tag == DW_TAG_structure_type || - pos->tag == DW_TAG_union_type) { + pos->tag == DW_TAG_union_type || + pos->tag == DW_TAG_namespace) { struct tag *tag = - type__find_tag_by_id(tag__type(pos), id); + namespace__find_tag_by_id(tag__namespace(pos), id); if (tag != NULL) return tag; } @@ -605,11 +606,12 @@ struct tag *cu__find_tag_by_id(const struct cu *self, const Dwarf_Off id) if (pos->id == id) return pos; - /* Look if we have types within types */ + /* Look for nested namespaces */ if (pos->tag == DW_TAG_structure_type || - pos->tag == DW_TAG_union_type) { + pos->tag == DW_TAG_union_type || + pos->tag == DW_TAG_namespace) { struct tag *tag = - type__find_tag_by_id(tag__type(pos), id); + namespace__find_tag_by_id(tag__namespace(pos), id); if (tag != NULL) return tag; } diff --git a/dwarves.h b/dwarves.h index edebbf2..c438efb 100644 --- a/dwarves.h +++ b/dwarves.h @@ -69,6 +69,14 @@ static inline struct namespace *tag__namespace(const struct tag *self) return (struct namespace *)self; } +/** + * namespace__for_each_tag - iterate thru all the tags + * @self: struct namespace instance to iterate + * @pos: struct tag iterator + */ +#define namespace__for_each_tag(self, pos) \ + list_for_each_entry(pos, &(self)->tags, node) + /** * struct type - base type for enumerations, structs and unions *