Re: [PATCH v1 03/11] perf dwarf-aux: Preserve typedefs in match_var_offset
From: Namhyung Kim
Date: Tue Feb 10 2026 - 21:24:34 EST
On Mon, Jan 26, 2026 at 09:04:56PM -0500, Zecheng Li wrote:
> From: Zecheng Li <zecheng@xxxxxxxxxx>
>
> Since we are skipping the check_variable, we need to preserve typedefs
> in match_var_offset to match the results by __die_get_real_type. Also
> move the (offset == 0) branch after the is_pointer check to ensure the
> correct type is used, fixing cases where an incorrect pointer type was
> chosen when the access offset was 0.
Can you move the patch 1 after this so that it doesn't get the temporary
regression? Maybe it doesn't matter much whether it sees a typedef or
an underlying type, but it'd be better to keep it consistent if it's not
too hard. :)
Thanks,
Namhyung
>
> Signed-off-by: Zecheng Li <zecheng@xxxxxxxxxx>
> Signed-off-by: Zecheng Li <zli94@xxxxxxxx>
> ---
> tools/perf/util/dwarf-aux.c | 21 ++++++++++++---------
> 1 file changed, 12 insertions(+), 9 deletions(-)
>
> diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
> index 96cfcbd40c45..ce816aefa95b 100644
> --- a/tools/perf/util/dwarf-aux.c
> +++ b/tools/perf/util/dwarf-aux.c
> @@ -1420,26 +1420,29 @@ static bool match_var_offset(Dwarf_Die *die_mem, struct find_var_data *data,
> s64 addr_offset, s64 addr_type, bool is_pointer)
> {
> Dwarf_Word size;
> + Dwarf_Die ptr_die;
> + Dwarf_Die *ptr_type;
> s64 offset = addr_offset - addr_type;
>
> - if (offset == 0) {
> - /* Update offset relative to the start of the variable */
> - data->offset = 0;
> - return true;
> - }
> -
> if (offset < 0)
> return false;
>
> - if (die_get_real_type(die_mem, &data->type) == NULL)
> + if (__die_get_real_type(die_mem, &data->type) == NULL)
> return false;
>
> - if (is_pointer && dwarf_tag(&data->type) == DW_TAG_pointer_type) {
> + ptr_type = die_get_pointer_type(&data->type, &ptr_die);
> + if (is_pointer && ptr_type) {
> /* Get the target type of the pointer */
> - if (die_get_real_type(&data->type, &data->type) == NULL)
> + if (__die_get_real_type(ptr_type, &data->type) == NULL)
> return false;
> }
>
> + if (offset == 0) {
> + /* Update offset relative to the start of the variable */
> + data->offset = 0;
> + return true;
> + }
> +
> if (dwarf_aggregate_size(&data->type, &size) < 0)
> return false;
>
> --
> 2.52.0
>