From: Namhyung Kim <namhyung@kernel.org>
To: Zecheng Li <zli94@ncsu.edu>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
James Clark <james.clark@linaro.org>,
xliuprof@google.com, linux-perf-users@vger.kernel.org,
linux-kernel@vger.kernel.org, Zecheng Li <zecheng@google.com>
Subject: Re: [PATCH v1 03/11] perf dwarf-aux: Preserve typedefs in match_var_offset
Date: Tue, 10 Feb 2026 18:23:40 -0800 [thread overview]
Message-ID: <aYvoLPbk82HUR23S@google.com> (raw)
In-Reply-To: <20260127020617.2804780-4-zli94@ncsu.edu>
On Mon, Jan 26, 2026 at 09:04:56PM -0500, Zecheng Li wrote:
> From: Zecheng Li <zecheng@google.com>
>
> 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@google.com>
> Signed-off-by: Zecheng Li <zli94@ncsu.edu>
> ---
> 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
>
next prev parent reply other threads:[~2026-02-11 2:23 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-27 2:04 [PATCH v1 00/11] perf tools: Improvements to data type profiler Zecheng Li
2026-01-27 2:04 ` [PATCH v1 01/11] perf dwarf-aux: Skip check_variable for die_find_variable_by_reg Zecheng Li
2026-02-11 2:08 ` Namhyung Kim
2026-01-27 2:04 ` [PATCH v1 02/11] perf dwarf-aux: Add die_get_pointer_type to get pointer types Zecheng Li
2026-02-11 2:17 ` Namhyung Kim
2026-01-27 2:04 ` [PATCH v1 03/11] perf dwarf-aux: Preserve typedefs in match_var_offset Zecheng Li
2026-02-11 2:23 ` Namhyung Kim [this message]
2026-01-27 2:04 ` [PATCH v1 04/11] perf annotate-data: Improve type comparison from different scopes Zecheng Li
2026-02-11 2:25 ` Namhyung Kim
2026-01-27 2:04 ` [PATCH v1 05/11] perf dwarf-aux: Handle array types in die_get_member_type Zecheng Li
2026-01-27 2:04 ` [PATCH v1 06/11] perf annotate-data: Collect global variables without name Zecheng Li
2026-02-11 2:29 ` Namhyung Kim
2026-01-27 2:05 ` [PATCH v1 07/11] perf annotate-data: Handle global variable access with const register Zecheng Li
2026-02-11 2:37 ` Namhyung Kim
2026-01-27 2:05 ` [PATCH v1 08/11] perf annotate-data: Add invalidate_reg_state() helper for x86 Zecheng Li
2026-02-11 2:38 ` Namhyung Kim
2026-01-27 2:05 ` [PATCH v1 09/11] perf annotate-data: Invalidate caller-saved regs for all calls Zecheng Li
2026-01-27 2:05 ` [PATCH v1 10/11] perf annotate-data: Use DWARF location ranges to preserve reg state Zecheng Li
2026-01-27 2:05 ` [PATCH v1 11/11] perf dwarf-aux: Collect all variable locations for insn tracking Zecheng Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aYvoLPbk82HUR23S@google.com \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=xliuprof@google.com \
--cc=zecheng@google.com \
--cc=zli94@ncsu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox