All of lore.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Ian Rogers <irogers@google.com>
Cc: Zecheng Li <zecheng@google.com>,
	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>,
	Adrian Hunter <adrian.hunter@intel.com>,
	"Liang, Kan" <kan.liang@linux.intel.com>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Zecheng Li <zli94@ncsu.edu>, Xu Liu <xliuprof@google.com>,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 3/6] perf dwarf-aux: Better type matching for stack variables
Date: Sat, 26 Jul 2025 17:22:03 -0700	[thread overview]
Message-ID: <aIVxK-xXxmHXzLTV@google.com> (raw)
In-Reply-To: <CAP-5=fWbKj6fjxTccpszgMoVCc17e+2ZmixU5B3W0WU5wo_zDg@mail.gmail.com>

On Fri, Jul 25, 2025 at 06:17:33PM -0700, Ian Rogers wrote:
> On Fri, Jul 25, 2025 at 1:28 PM Zecheng Li <zecheng@google.com> wrote:
> >
> > Utilizes the previous is_breg_access_indirect function to determine if
> > the stack location stores the variable itself or the struct it points
> > to.
> >
> > If the DWARF expression shows DW_OP_stack_value without DW_OP_deref, it
> > indicates the variable value is the reg + offset itself, and the stack
> > location it points to is the dereferenced type.
> >
> > Signed-off-by: Zecheng Li <zecheng@google.com>
> > ---
> >  tools/perf/util/dwarf-aux.c | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> >
> > diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
> > index 814c96ea509f..4039dbd2b8c0 100644
> > --- a/tools/perf/util/dwarf-aux.c
> > +++ b/tools/perf/util/dwarf-aux.c
> > @@ -1635,6 +1635,14 @@ static int __die_collect_vars_cb(Dwarf_Die *die_mem, void *arg)
> >         if (die_get_real_type(die_mem, &type_die) == NULL)
> >                 return DIE_FIND_CB_SIBLING;
> >
> > +       if ((ops->atom == DW_OP_fbreg || ops->atom == DW_OP_breg7) &&
> 
> A comment saying the significance of DW_OP_fbreg and DW_OP_breg7 would
> be useful, for example, why not DW_OP_breg6? Isn't breg7 going to be
> x86 specific?

Good point!  Right, it's x86 specific and we cannot hard-code.  It needs
a way to indicate this register is a stack pointer on the target arch.
Please see the instruction tracking code which checks state->stack_reg.
 
On x86_64, DWARF reg 7 is RSP.  If RBP is used as a frame pointer, it's
probably using DW_OP_fbreg expression.

> 
> > +           dwarf_tag(&type_die) == DW_TAG_pointer_type &&
> > +           is_breg_access_indirect(ops, nops)) {

Maybe it needs to check the register inside is_breg_access_indirect().

Thanks,
Namhyung


> > +               /* Get the target type of the pointer */
> > +               if (die_get_real_type(&type_die, &type_die) == NULL)
> > +                       return DIE_FIND_CB_SIBLING;
> > +       }
> > +
> >         vt = malloc(sizeof(*vt));
> >         if (vt == NULL)
> >                 return DIE_FIND_CB_END;
> > --
> > 2.50.1.470.g6ba607880d-goog
> >

  reply	other threads:[~2025-07-27  0:22 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-25 20:28 [PATCH v1 0/6] perf tools: Some improvements on data type profiler Zecheng Li
2025-07-25 20:28 ` [PATCH v1 1/6] perf dwarf-aux: Use signed comparison in match_var_offset Zecheng Li
2025-07-26  0:58   ` Ian Rogers
2025-07-26 23:56     ` Namhyung Kim
2025-07-25 20:28 ` [PATCH v1 2/6] perf dwarf-aux: More accurate variable type match for breg Zecheng Li
2025-07-27  0:14   ` Namhyung Kim
2025-07-25 20:28 ` [PATCH v1 3/6] perf dwarf-aux: Better type matching for stack variables Zecheng Li
2025-07-26  1:17   ` Ian Rogers
2025-07-27  0:22     ` Namhyung Kim [this message]
2025-07-25 20:28 ` [PATCH v1 4/6] perf annotate: Skip annotating data types to lea instructions Zecheng Li
2025-07-26  1:19   ` Ian Rogers
2025-07-25 20:28 ` [PATCH v1 5/6] perf dwarf-aux: Find pointer type to a type Zecheng Li
2025-07-27  0:24   ` Namhyung Kim
2025-07-25 20:28 ` [PATCH v1 6/6] perf annotate: Track arithmetic instructions on pointers Zecheng Li
2025-07-27  0:32   ` Namhyung Kim

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=aIVxK-xXxmHXzLTV@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=jolsa@kernel.org \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mhiramat@kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.