This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH RESEND] gdb: xtensa: fix register counters for xtensa-linux


On Sat, Jan 12, 2019 at 9:56 PM Simon Marchi <simon.marchi@ericsson.com> wrote:
>
> On 2019-01-12 8:42 p.m., Max Filippov wrote:
> > Commit 37d9e0623102 ("gdb: xtensa: handle privileged registers") changed
> > how the tdep->num_regs and tdep->num_pseudo_regs are calculated, but
> > didn't update these numbers in the gdbarch for the xtensa-linux target.
> > As a result xtensa-linux-gdb behaves as xtensa-elf-gdb and cannot
> > communicate with the linux gdbserver.
> > Fix tdep->num_pseudo_regs calculation and call set_gdbarch_num_regs and
> > set_gdbarch_num_pseudo_regs in xtensa_linux_init_abi.
> >
> > gdb/
> > 2018-11-16  Max Filippov  <jcmvbkbc@gmail.com>
> >
> >       * xtensa-linux-tdep.c (xtensa_linux_init_abi): Update
> >       tdep->num_pseudo_regs. Add calls to set_gdbarch_num_regs and
> >       set_gdbarch_num_pseudo_regs.
> > ---
> >  gdb/xtensa-linux-tdep.c | 8 +++++++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/gdb/xtensa-linux-tdep.c b/gdb/xtensa-linux-tdep.c
> > index 1764b953a00b..796143c6699b 100644
> > --- a/gdb/xtensa-linux-tdep.c
> > +++ b/gdb/xtensa-linux-tdep.c
> > @@ -101,7 +101,13 @@ xtensa_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
> >    struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
> >
> >    if (tdep->num_nopriv_regs < tdep->num_regs)
> > -    tdep->num_regs = tdep->num_nopriv_regs;
> > +    {
> > +      tdep->num_pseudo_regs += tdep->num_regs - tdep->num_nopriv_regs;
> > +      tdep->num_regs = tdep->num_nopriv_regs;
> > +
> > +      set_gdbarch_num_regs (gdbarch, tdep->num_regs);
> > +      set_gdbarch_num_pseudo_regs (gdbarch, tdep->num_pseudo_regs);
> > +    }
> >
> >    linux_init_abi (info, gdbarch);
> >
> >
>
> Hi Max.
>
> I am just a bit puzzled by the num_pseudo_regs computation (especially the +=).
> Can you explain it quickly?

In the original code (prior to 37d9e0623102) num_regs was the smallest of
the number of the first pseudo register or the first privileged register, and
num_pseudo_regs was the total number of registers minus num_regs.
The register table is constructed so that pseudo registers are always at the
end of it, so num_regs was always equal to num_nonpriv_regs.
I'd like to restore this in xtensa-linux gdb, and what I do is I increase
num_pseudo_regs by the difference of num_regs and num_nonpriv regs
and set num_regs equal to num_nonpriv_regs to maintain the above equations.

-- 
Thanks.
-- Max


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]