[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 <acme@ghostprotocols.net>
This commit is contained in:
Arnaldo Carvalho de Melo 2007-05-24 12:40:43 -03:00
parent 2b47267e23
commit 8562640b58
2 changed files with 19 additions and 9 deletions

View File

@ -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;
}

View File

@ -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
*