Re: [PATCH 06/14] perf annotate-data: Maintain variable type info

From: Namhyung Kim
Date: Tue Feb 06 2024 - 18:06:48 EST


On Fri, Feb 2, 2024 at 6:45 PM Ian Rogers <irogers@xxxxxxxxxx> wrote:
>
> On Fri, Feb 2, 2024 at 2:05 PM Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
> >
> > As it collected basic block and variable information in each scope, it
> > now can build a state table to find matching variable at the location.
> >
> > The struct type_state is to keep the type info saved in each register
> > and stack slot. The update_var_state() updates the table when it finds
> > variables in the current address. It expects die_collect_vars() filled
> > a list of variables with type info and starting address.
> >
> > Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
> > ---
> > tools/perf/util/annotate-data.c | 155 ++++++++++++++++++++++++++++++++
> > tools/perf/util/annotate-data.h | 29 ++++++
> > tools/perf/util/dwarf-aux.c | 4 +
> > 3 files changed, 188 insertions(+)
> >
> > diff --git a/tools/perf/util/annotate-data.c b/tools/perf/util/annotate-data.c
> > index b8e60c42af8c..f8768c224bcc 100644
> > --- a/tools/perf/util/annotate-data.c
> > +++ b/tools/perf/util/annotate-data.c
> > @@ -23,6 +23,57 @@
> > #include "symbol.h"
> > #include "symbol_conf.h"
> >
> > +/* Type information in a register, valid when ok is true */
> > +struct type_state_reg {
> > + Dwarf_Die type;
> > + bool ok;
> > + bool scratch;
> > +};
> > +
> > +/* Type information in a stack location, dynamically allocated */
> > +struct type_state_stack {
> > + struct list_head list;
> > + Dwarf_Die type;
> > + int offset;
> > + int size;
> > + bool compound;
> > +};
> > +
> > +/* FIXME: This should be arch-dependent */
> > +#define TYPE_STATE_MAX_REGS 16
>
> Perhaps 32, presumably 16 won't work on Arm64.

Right, but right now I'm targeting x86_64 only.
Maybe we can change it later when it supports Arm64.

Thanks,
Namhyung