From cc65946e3068f7b68a0aa437261c748c20445986 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Wed, 24 Jun 2020 14:14:33 -0300 Subject: [PATCH] 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 --- ctracer.c | 17 ----------------- dwarves.c | 17 +++++++++++++++++ dwarves.h | 2 ++ 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/ctracer.c b/ctracer.c index 15e537a..0098aa0 100644 --- a/ctracer.c +++ b/ctracer.c @@ -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) diff --git a/dwarves.c b/dwarves.c index eb7885f..f7e3120 100644 --- a/dwarves.c +++ b/dwarves.c @@ -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) diff --git a/dwarves.h b/dwarves.h index a772e57..7b409a4 100644 --- a/dwarves.h +++ b/dwarves.h @@ -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 *