dwarves: Adopt tag__is_base_type() from ctrace.c

We'll need it in pahole when pretty printing raw data as structs, etc.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2020-06-24 14:14:33 -03:00
parent d8079c6d37
commit cc65946e30
3 changed files with 19 additions and 17 deletions

View File

@ -346,23 +346,6 @@ static void class__emit_class_state_collector(struct class *class,
fputs("}\n\n", fp_collector);
}
static int tag__is_base_type(const struct tag *tag, const struct cu *cu)
{
switch (tag->tag) {
case DW_TAG_base_type:
return 1;
case DW_TAG_typedef: {
const struct tag *type = cu__type(cu, tag->type);
if (type == NULL)
return 0;
return tag__is_base_type(type, cu);
}
}
return 0;
}
static struct class *class__clone_base_types(const struct tag *tag,
struct cu *cu,
const char *new_class_name)

View File

@ -35,6 +35,23 @@
#define min(x, y) ((x) < (y) ? (x) : (y))
int tag__is_base_type(const struct tag *tag, const struct cu *cu)
{
switch (tag->tag) {
case DW_TAG_base_type:
return 1;
case DW_TAG_typedef: {
const struct tag *type = cu__type(cu, tag->type);
if (type == NULL)
return 0;
return tag__is_base_type(type, cu);
}
}
return 0;
}
const char *cu__string(const struct cu *cu, strings_t s)
{
if (cu->dfops && cu->dfops->strings__ptr)

View File

@ -912,6 +912,8 @@ static __pure inline int tag__is_class_member(const struct tag *tag)
return tag->tag == DW_TAG_member;
}
int tag__is_base_type(const struct tag *tag, const struct cu *cu);
/**
* struct type - base type for enumerations, structs and unions
*