History

gendwarfksyms: Expand array_type

Add support for expanding DW_TAG_array_type, and the subrange type indicating array size. Example source code: const char *s[34]; Output with --dump-dies: variable array_type[34] { pointer_type { const_type { base_type char byte_size(1) encoding(6) } } byte_size(8) }

Sami Tolvanen committed 1 year ago

Commit c772f1d1 parent 220a0851 file · +30 −0Browse files

Unified · Split

scripts/gendwarfksyms/dwarf.c+30−0
@@ -220,6 +220,7 @@ DEFINE_PROCESS_UDATA_ATTRIBUTE(encoding) · 219 unmodified lines
220 }220 }
221 221
222DEFINE_MATCH(formal_parameter)222DEFINE_MATCH(formal_parameter)
223DEFINE_MATCH(subrange)
223 224
224bool match_all(Dwarf_Die *die)225bool match_all(Dwarf_Die *die)
225{226{
@@ -342,6 +343,33 @@ DEFINE_PROCESS_TYPE(shared) · 116 unmodified lines
342DEFINE_PROCESS_TYPE(volatile)343DEFINE_PROCESS_TYPE(volatile)
343DEFINE_PROCESS_TYPE(typedef)344DEFINE_PROCESS_TYPE(typedef)
344 345
346static void process_subrange_type(struct state *state, struct die *cache,
347 Dwarf_Die *die)
348{
349 Dwarf_Word count = 0;
350
351 if (get_udata_attr(die, DW_AT_count, &count))
352 process_fmt(cache, "[%" PRIu64 "]", count);
353 else if (get_udata_attr(die, DW_AT_upper_bound, &count))
354 process_fmt(cache, "[%" PRIu64 "]", count + 1);
355 else
356 process(cache, "[]");
357}
358
359static void process_array_type(struct state *state, struct die *cache,
360 Dwarf_Die *die)
361{
362 process(cache, "array_type");
363 /* Array size */
364 check(process_die_container(state, cache, die, process_type,
365 match_subrange_type));
366 process(cache, " {");
367 process_linebreak(cache, 1);
368 process_type_attr(state, cache, die);
369 process_linebreak(cache, -1);
370 process(cache, "}");
371}
372
345static void __process_subroutine_type(struct state *state, struct die *cache,373static void __process_subroutine_type(struct state *state, struct die *cache,
346 Dwarf_Die *die, const char *type)374 Dwarf_Die *die, const char *type)
347{375{
@@ -437,7 +465,9 @@ static int process_type(struct state *state, struct die *parent, Dwarf_Die *die) · 89 unmodified lines
437 PROCESS_TYPE(volatile)465 PROCESS_TYPE(volatile)
438 /* Subtypes */466 /* Subtypes */
439 PROCESS_TYPE(formal_parameter)467 PROCESS_TYPE(formal_parameter)
468 PROCESS_TYPE(subrange)
440 /* Other types */469 /* Other types */
470 PROCESS_TYPE(array)
441 PROCESS_TYPE(base)471 PROCESS_TYPE(base)
442 PROCESS_TYPE(subroutine)472 PROCESS_TYPE(subroutine)
443 PROCESS_TYPE(typedef)473 PROCESS_TYPE(typedef)