dwarves: Introduce cu__find_enumeration_by_name()

We'll use it in an upcoming feature, to pretty print fields that albeit
not declared as an enum, have values coming from one.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2020-07-14 13:27:09 -03:00
parent 20051b7157
commit 163c330d31
2 changed files with 25 additions and 0 deletions

View File

@ -734,6 +734,30 @@ struct tag *cu__find_enumeration_by_sname_and_size(const struct cu *cu,
return NULL;
}
struct tag *cu__find_enumeration_by_name(const struct cu *cu, const char *name, type_id_t *idp)
{
uint32_t id;
struct tag *pos;
if (name == NULL)
return NULL;
cu__for_each_type(cu, id, pos) {
if (pos->tag == DW_TAG_enumeration_type) {
const struct type *type = tag__type(pos);
const char *tname = type__name(type, cu);
if (tname && strcmp(tname, name) == 0) {
if (idp != NULL)
*idp = id;
return pos;
}
}
}
return NULL;
}
struct tag *cu__find_struct_by_sname(const struct cu *cu, strings_t sname,
const int include_decls, type_id_t *idp)
{

View File

@ -348,6 +348,7 @@ struct tag *cu__find_base_type_by_sname_and_size(const struct cu *cu,
strings_t name,
uint16_t bit_size,
type_id_t *idp);
struct tag *cu__find_enumeration_by_name(const struct cu *cu, const char *name, type_id_t *idp);
struct tag *cu__find_enumeration_by_sname_and_size(const struct cu *cu,
strings_t sname,
uint16_t bit_size,