[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aP0LkimOCj389dNl@google.com>
Date: Sat, 25 Oct 2025 10:40:34 -0700
From: Namhyung Kim <namhyung@...nel.org>
To: Zecheng Li <zecheng@...gle.com>
Cc: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
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>,
Masami Hiramatsu <mhiramat@...nel.org>,
Xu Liu <xliuprof@...gle.com>, linux-perf-users@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 7/9] perf dwarf-aux: Preserve typedefs in
match_var_offset
On Mon, Oct 13, 2025 at 06:16:04PM +0000, Zecheng Li wrote:
> 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.
>
> Signed-off-by: Zecheng Li <zecheng@...gle.com>
> ---
> tools/perf/util/dwarf-aux.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
> index b57cdc8860f0..b2189de07daf 100644
> --- a/tools/perf/util/dwarf-aux.c
> +++ b/tools/perf/util/dwarf-aux.c
> @@ -1395,24 +1395,24 @@ static bool match_var_offset(Dwarf_Die *die_mem, struct find_var_data *data,
> Dwarf_Word size;
> 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 the type was a typedef of a pointer, then the following check for a
pointer cannot detect the target type.
Thanks,
Namhyung
>
> if (is_pointer && dwarf_tag(&data->type) == DW_TAG_pointer_type) {
> /* Get the target type of the pointer */
> - if (die_get_real_type(&data->type, &data->type) == NULL)
> + if (__die_get_real_type(&data->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.51.0.788.g6d19910ace-goog
>
Powered by blists - more mailing lists