summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZecheng Li <zli94@ncsu.edu>2026-03-09 20:55:18 +0300
committerNamhyung Kim <namhyung@kernel.org>2026-03-20 00:42:29 +0300
commit6ffc3d0d3db5fb6c88fcb69eb355e9cc839a860c (patch)
treedba1a1511fe9386db9e1ba2dd2bde4eef33f5a78
parent69953f9c65856fc9438fc2ad4b9fd8255a2e47da (diff)
downloadlinux-6ffc3d0d3db5fb6c88fcb69eb355e9cc839a860c.tar.xz
perf dwarf-aux: Handle array types in die_get_member_type
When a struct member is an array type, die_get_member_type() would stop iterating since array types weren't handled in the loop. This caused accesses to array elements within structs to not resolve properly. Add array type handling by resolving the array to its element type and calculating the offset within an element using modulo arithmetic This improves type annotation coverage for struct members that are arrays. Signed-off-by: Zecheng Li <zli94@ncsu.edu> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
-rw-r--r--tools/perf/util/dwarf-aux.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
index 1484aa756826..1feefc329154 100644
--- a/tools/perf/util/dwarf-aux.c
+++ b/tools/perf/util/dwarf-aux.c
@@ -2127,13 +2127,28 @@ Dwarf_Die *die_get_member_type(Dwarf_Die *type_die, int offset,
tag = dwarf_tag(&mb_type);
- if (tag == DW_TAG_structure_type || tag == DW_TAG_union_type) {
+ if (tag == DW_TAG_structure_type || tag == DW_TAG_union_type ||
+ tag == DW_TAG_array_type) {
Dwarf_Word loc;
/* Update offset for the start of the member struct */
if (die_get_data_member_location(member, &loc) == 0)
offset -= loc;
}
+
+ /* Handle array types: resolve to the element type by one level */
+ if (tag == DW_TAG_array_type) {
+ Dwarf_Word size;
+
+ if (die_get_real_type(&mb_type, &mb_type) == NULL)
+ return NULL;
+
+ if (dwarf_aggregate_size(&mb_type, &size) < 0)
+ return NULL;
+
+ offset = offset % size;
+ tag = dwarf_tag(&mb_type);
+ }
}
*die_mem = mb_type;
return die_mem;