[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260127020617.2804780-6-zli94@ncsu.edu>
Date: Mon, 26 Jan 2026 21:04:58 -0500
From: Zecheng Li <zli94@...u.edu>
To: Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Namhyung Kim <namhyung@...nel.org>
Cc: Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>,
Ian Rogers <irogers@...gle.com>,
Adrian Hunter <adrian.hunter@...el.com>,
James Clark <james.clark@...aro.org>,
Zecheng Li <zli94@...u.edu>,
xliuprof@...gle.com,
linux-perf-users@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v1 05/11] 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@...u.edu>
---
tools/perf/util/dwarf-aux.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
index ce816aefa95b..ee72b7a4a65d 100644
--- a/tools/perf/util/dwarf-aux.c
+++ b/tools/perf/util/dwarf-aux.c
@@ -2125,13 +2125,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;
--
2.52.0
Powered by blists - more mailing lists