[PATCH v4 0/3] perf annotate-data: Support flexible array types

From: Namhyung Kim

Date: Wed Sep 16 2026 - 02:19:31 EST


Hello,

The flexible arrays are dynamically allocated with different size. So checking
with the original type size won't match and cannot find the type if the offset
is bigger than the size. This patch series detects those flex-arrays and allows
accesses beyong the original size.

I'm not sure what's the best way to add test codes for data type profiling as it
seems we need to add a lot more workloads for different cases. Probably we may
want to split the workloads as separate binaries.

v4 changes)

* update last member even if the offset is same
* handle type qualifiers in die_has_flex_array()
* add zero-length array members as flexible arrays
* check return value of strbuf_init() for type name

v3: https://lore.kernel.org/r/20260915064035.1970175-1-namhyung@xxxxxxxxxx

* patch 1 was merged!
* check if last member is found
* check member location when finding flex-array
* ensure member typename is initiailized
* fix a bug to pass a wrong type in check_variable()
* fix a typo in a comment

v2: https://lore.kernel.org/r/20260914064535.1671939-1-namhyung@xxxxxxxxxx

* fix missing index increment in the histogram
* support flex array in union types
* add recursion check in die_has_flex_array()
* check negative index arrays properly
* avoid divide-by-zero when the size is unknown

v1: https://lore.kernel.org/r/20260912054706.1475583-1-namhyung@xxxxxxxxxx

Thanks,
Namhyung


Cc: Zecheng Li <zli94@xxxxxxxx>
Cc: Yanbo Zhao <yzhao62@xxxxxxxx>
Cc: Tengda Wu <wutengda@xxxxxxxxxxxxxxx>
Cc: Shuai Xue <xueshuai@xxxxxxxxxxxxxxxxx>

Namhyung Kim (3):
perf dwarf-aux: Add die_has_flex_array() helper
perf annotate-date: Allow out-of-size access for flex-array types
perf annotate-data: Adjust type offset for flex-array

tools/perf/util/annotate-data.c | 146 ++++++++++++++++++++++++--------
tools/perf/util/annotate-data.h | 2 +
tools/perf/util/dwarf-aux.c | 107 +++++++++++++++++++++++
tools/perf/util/dwarf-aux.h | 3 +
4 files changed, 221 insertions(+), 37 deletions(-)

--
2.55.0.1032.g73a4cd73de-goog