Add support for expanding DWARF type modifiers, such as pointers, const values etc., and typedefs. These types all have DW_AT_type attribute pointing the underlying type, and thus produce similar output. Signed-off-by: Sami Tolvanen <samitolvanen@xxxxxxxxxx> --- tools/gendwarfksyms/gendwarfksyms.h | 3 ++ tools/gendwarfksyms/types.c | 54 +++++++++++++++++++++++++++-- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/tools/gendwarfksyms/gendwarfksyms.h b/tools/gendwarfksyms/gendwarfksyms.h index ea5a9fbda66f..d5ebfe405445 100644 --- a/tools/gendwarfksyms/gendwarfksyms.h +++ b/tools/gendwarfksyms/gendwarfksyms.h @@ -50,6 +50,9 @@ extern bool no_cache; __res; \ }) +/* Consistent aliases (DW_TAG_<type>_type) for DWARF tags */ +#define DW_TAG_typedef_type DW_TAG_typedef + /* * symbols.c */ diff --git a/tools/gendwarfksyms/types.c b/tools/gendwarfksyms/types.c index 78046c08be23..27169c77937f 100644 --- a/tools/gendwarfksyms/types.c +++ b/tools/gendwarfksyms/types.c @@ -189,6 +189,38 @@ static int process_type_attr(struct state *state, struct cached_die *cache, return check(process(state, cache, "base_type void")); } +/* Container types with DW_AT_type */ +static int __process_type(struct state *state, struct cached_die *cache, + Dwarf_Die *die, const char *type) +{ + check(process(state, cache, type)); + check(process_fqn(state, cache, die)); + check(process(state, cache, " {")); + check(process_type_attr(state, cache, die)); + check(process(state, cache, "}")); + check(process_byte_size_attr(state, cache, die)); + return check(process_alignment_attr(state, cache, die)); +} + +#define DEFINE_PROCESS_TYPE(type) \ + static int process_##type##_type( \ + struct state *state, struct cached_die *cache, Dwarf_Die *die) \ + { \ + return __process_type(state, cache, die, #type "_type "); \ + } + +DEFINE_PROCESS_TYPE(atomic) +DEFINE_PROCESS_TYPE(const) +DEFINE_PROCESS_TYPE(immutable) +DEFINE_PROCESS_TYPE(packed) +DEFINE_PROCESS_TYPE(pointer) +DEFINE_PROCESS_TYPE(reference) +DEFINE_PROCESS_TYPE(restrict) +DEFINE_PROCESS_TYPE(rvalue_reference) +DEFINE_PROCESS_TYPE(shared) +DEFINE_PROCESS_TYPE(volatile) +DEFINE_PROCESS_TYPE(typedef) + static int process_base_type(struct state *state, struct cached_die *cache, Dwarf_Die *die) { @@ -233,6 +265,11 @@ static void state_init(struct state *state) state->crc = 0xffffffff; } +#define PROCESS_TYPE(type) \ + case DW_TAG_##type##_type: \ + check(process_##type##_type(state, cache, die)); \ + break; + static int process_type(struct state *state, struct cached_die *parent, Dwarf_Die *die) { @@ -254,9 +291,20 @@ static int process_type(struct state *state, struct cached_die *parent, } switch (tag) { - case DW_TAG_base_type: - check(process_base_type(state, cache, die)); - break; + /* Type modifiers */ + PROCESS_TYPE(atomic) + PROCESS_TYPE(const) + PROCESS_TYPE(immutable) + PROCESS_TYPE(packed) + PROCESS_TYPE(pointer) + PROCESS_TYPE(reference) + PROCESS_TYPE(restrict) + PROCESS_TYPE(rvalue_reference) + PROCESS_TYPE(shared) + PROCESS_TYPE(volatile) + /* Other types */ + PROCESS_TYPE(base) + PROCESS_TYPE(typedef) default: debug("unimplemented type: %x", tag); break; -- 2.45.2.627.g7a2c4fd464-goog