Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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)
}

Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

authored by

Sami Tolvanen and committed by
Masahiro Yamada
c772f1d1 220a0857

+30
+30
scripts/gendwarfksyms/dwarf.c
··· 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 { ··· 343 342 DEFINE_PROCESS_TYPE(volatile) 344 343 DEFINE_PROCESS_TYPE(typedef) 345 344 345 + static void process_subrange_type(struct state *state, struct die *cache, 346 + Dwarf_Die *die) 347 + { 348 + Dwarf_Word count = 0; 349 + 350 + if (get_udata_attr(die, DW_AT_count, &count)) 351 + process_fmt(cache, "[%" PRIu64 "]", count); 352 + else if (get_udata_attr(die, DW_AT_upper_bound, &count)) 353 + process_fmt(cache, "[%" PRIu64 "]", count + 1); 354 + else 355 + process(cache, "[]"); 356 + } 357 + 358 + static void process_array_type(struct state *state, struct die *cache, 359 + Dwarf_Die *die) 360 + { 361 + process(cache, "array_type"); 362 + /* Array size */ 363 + check(process_die_container(state, cache, die, process_type, 364 + match_subrange_type)); 365 + process(cache, " {"); 366 + process_linebreak(cache, 1); 367 + process_type_attr(state, cache, die); 368 + process_linebreak(cache, -1); 369 + process(cache, "}"); 370 + } 371 + 346 372 static void __process_subroutine_type(struct state *state, struct die *cache, 347 373 Dwarf_Die *die, const char *type) 348 374 { ··· 465 437 PROCESS_TYPE(volatile) 466 438 /* Subtypes */ 467 439 PROCESS_TYPE(formal_parameter) 440 + PROCESS_TYPE(subrange) 468 441 /* Other types */ 442 + PROCESS_TYPE(array) 469 443 PROCESS_TYPE(base) 470 444 PROCESS_TYPE(subroutine) 471 445 PROCESS_TYPE(typedef)