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) }
Showing the changes to scripts (1 of 1 file). Show all
Unified · Split
| @@ -220,6 +220,7 @@ DEFINE_PROCESS_UDATA_ATTRIBUTE(encoding) · 219 unmodified lines | ||
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | DEFINE_MATCH(formal_parameter) |
| 223 | +DEFINE_MATCH(subrange) | |
| 223 | 224 | |
| 224 | 225 | bool match_all(Dwarf_Die *die) |
| 225 | 226 | { |
| @@ -342,6 +343,33 @@ DEFINE_PROCESS_TYPE(shared) · 116 unmodified lines | ||
| 342 | 343 | DEFINE_PROCESS_TYPE(volatile) |
| 343 | 344 | DEFINE_PROCESS_TYPE(typedef) |
| 344 | 345 | |
| 346 | +static 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 | + | |
| 359 | +static 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 | + | |
| 345 | 373 | static void __process_subroutine_type(struct state *state, struct die *cache, |
| 346 | 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 | 465 | PROCESS_TYPE(volatile) |
| 438 | 466 | /* Subtypes */ |
| 439 | 467 | PROCESS_TYPE(formal_parameter) |
| 468 | + PROCESS_TYPE(subrange) | |
| 440 | 469 | /* Other types */ |
| 470 | + PROCESS_TYPE(array) | |
| 441 | 471 | PROCESS_TYPE(base) |
| 442 | 472 | PROCESS_TYPE(subroutine) |
| 443 | 473 | PROCESS_TYPE(typedef) |