dwarves: Introduce cu__find_type_by_name
To look at all the 'struct type' descendants, like enums, typedefs, structs, unions, etc. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
88d99562e5
commit
ded5d36f9c
31
dwarves.c
31
dwarves.c
|
@ -732,6 +732,37 @@ found:
|
|||
|
||||
}
|
||||
|
||||
struct tag *cu__find_type_by_name(const struct cu *cu, const char *name, const int include_decls, type_id_t *idp)
|
||||
{
|
||||
if (cu == NULL || name == NULL)
|
||||
return NULL;
|
||||
|
||||
uint32_t id;
|
||||
struct tag *pos;
|
||||
cu__for_each_type(cu, id, pos) {
|
||||
struct type *type;
|
||||
|
||||
if (!tag__is_type(pos))
|
||||
continue;
|
||||
|
||||
type = tag__type(pos);
|
||||
const char *tname = type__name(type, cu);
|
||||
if (tname && strcmp(tname, name) == 0) {
|
||||
if (!type->declaration)
|
||||
goto found;
|
||||
|
||||
if (include_decls)
|
||||
goto found;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
found:
|
||||
if (idp != NULL)
|
||||
*idp = id;
|
||||
return pos;
|
||||
}
|
||||
|
||||
static struct tag *__cu__find_struct_by_name(const struct cu *cu, const char *name,
|
||||
const int include_decls, bool unions, type_id_t *idp)
|
||||
{
|
||||
|
|
|
@ -120,6 +120,7 @@ struct tag *cus__find_struct_by_name(const struct cus *cus, struct cu **cu,
|
|||
type_id_t *id);
|
||||
struct tag *cus__find_struct_or_union_by_name(const struct cus *cus, struct cu **cu,
|
||||
const char *name, const int include_decls, type_id_t *id);
|
||||
struct tag *cu__find_type_by_name(const struct cu *cu, const char *name, const int include_decls, type_id_t *idp);
|
||||
struct function *cus__find_function_at_addr(const struct cus *cus,
|
||||
uint64_t addr, struct cu **cu);
|
||||
void cus__for_each_cu(struct cus *cus, int (*iterator)(struct cu *cu, void *cookie),
|
||||
|
|
Loading…
Reference in New Issue