From: John Baldwin <jhb@freebsd.org>
To: Luis Machado <lgustavo@codesourcery.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 1/4] Cleanups to FreeBSD/mips native register operations.
Date: Fri, 14 Apr 2017 18:02:00 -0000 [thread overview]
Message-ID: <1671472.AujrONiZJ6@ralph.baldwin.cx> (raw)
In-Reply-To: <8989db11-ec9e-33f8-ae97-fbd4518bdaef@codesourcery.com>
On Thursday, April 13, 2017 10:48:48 AM Luis Machado wrote:
> On 04/12/2017 01:37 PM, John Baldwin wrote:
> > Compare against the "raw" PC register number instead of the cooked
> > register number when determining if a register was handled by
> > PT_GETREGS. Previously the register fetch/store operations only tried
> > PT_GETREGS to fetch any individual register. The result was that
> > fetching or storing an individual register not covered by PT_GETREGS
> > (such as floating point registers) did not work.
> >
> > While here, remove an early exit to simplify the code flow from the
> > PT_GETREGS / PT_SETREGS case, and add a getfpregs_supplies similar to
> > getregs_supplies to describe the registers supplied by PT_GETFPREGS
> > and PT_SETFPREGS.
> >
> > gdb/ChangeLog:
> >
> > * mips-fbsd-nat.c (getregs_supplies): Fix upper bound comparison.
> > (getpfpregs_supplies): New function.
> > (mips_fbsd_fetch_inferior_registers): Remove early exit and use
> > getfpregs_supplies.
> > (mips_fbsd_store_inferior_registers): Likewise.
> > ---
> > gdb/ChangeLog | 8 ++++++++
> > gdb/mips-fbsd-nat.c | 26 ++++++++++++++------------
> > 2 files changed, 22 insertions(+), 12 deletions(-)
>
> Only a few nits.
>
> > diff --git a/gdb/mips-fbsd-nat.c b/gdb/mips-fbsd-nat.c
> > index 078df52db6..e2ed63e829 100644
> > --- a/gdb/mips-fbsd-nat.c
> > +++ b/gdb/mips-fbsd-nat.c
> > @@ -37,7 +37,16 @@ static bool
> > getregs_supplies (struct gdbarch *gdbarch, int regnum)
> > {
> > return (regnum >= MIPS_ZERO_REGNUM
> > - && regnum <= gdbarch_pc_regnum (gdbarch));
> > + && regnum <= mips_regnum (gdbarch)->pc);
> > +}
>
> Can the BSD backend override the pc value in gdbarch_pc_regnum (...) so
> it fits what is expected? Or is this a case where the cooked pc register
> number is still useful and we need to handle things differently for the
> raw pc register number?
The cooked value is too large. In particular, the existing range
right now goes from "0" to "cooked PC" which includes
"raw GP + raw FP + cooked GP". This means that a request for a raw
FP register will see 'getregs_supplies() return true and will try
to satisfy it via PT_GETREGS (which doesn't work). The end result is that
the register just isn't found.
> > +
> > +/* Determine if PT_GETFPREGS fetches this register. */
>
> Pedantically, "... fetches REGNUM".
>
> > @@ -47,9 +56,9 @@ static void
> > mips_fbsd_fetch_inferior_registers (struct target_ops *ops,
> > struct regcache *regcache, int regnum)
> > {
> > + struct gdbarch *gdbarch = get_regcache_arch (regcache);
> > pid_t pid = get_ptrace_pid (regcache_get_ptid (regcache));
> >
> > - struct gdbarch *gdbarch = get_regcache_arch (regcache);
> > if (regnum == -1 || getregs_supplies (gdbarch, regnum))
>
> With C++ we can leave the declaration closer to its use. Same in the
> other case below.
Yes, though in this case, gdbarch is actually used sooner than 'pid'. I
can revert these though.
> > @@ -58,12 +67,9 @@ mips_fbsd_fetch_inferior_registers (struct target_ops *ops,
> > perror_with_name (_("Couldn't get registers"));
> >
> > mips_fbsd_supply_gregs (regcache, regnum, ®s, sizeof (register_t));
> > - if (regnum != -1)
> > - return;
> > }
> >
> > - if (regnum == -1
> > - || regnum >= gdbarch_fp0_regnum (get_regcache_arch (regcache)))
> > + if (regnum == -1 || getfpregs_supplies (gdbarch, regnum))
>
> Does MIPS on fsbd handle vector registers? I ask this because regnum >=
> "fp0 regnum" may mean anything other than general purpose registers.
It does not, but I'm working on a research CPU that is an extension to MIPS
(CHERI) and it uses a third bank of registers that live above 'fp' with
a separate ptrace interface, etc. I don't know that the CHERI bits will ever
be upstreamed since it is a research design, but this newer check seems
strictly more correct as it only uses PT_GETFPREGS to fetch registers that
are actually supported (e.g. it won't try to use it to fetch fir which
FreeBSD doesn't export via PT_GETFPREGS).
> If there are vector (or higher-numbered registers), the new conditional
> block means something different compared to the old one.
I think that the new conditional is more correct in the case of higher
numbered registers as it means we don't try to use PT_GETFPREGS to
fetch a register it doesn't support.
> If not, then the change looks sane.
--
John Baldwin
next prev parent reply other threads:[~2017-04-14 18:02 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-12 18:37 [PATCH 0/4] Cleanups for MIPS registers (mostly FreeBSD-specific) John Baldwin
2017-04-12 18:37 ` [PATCH 3/4] Consistently use fprintf_filtered when displaying MIPS registers John Baldwin
2017-04-13 16:29 ` Luis Machado
2017-04-27 16:05 ` Pedro Alves
2017-04-28 16:52 ` John Baldwin
2017-04-12 18:37 ` [PATCH 1/4] Cleanups to FreeBSD/mips native register operations John Baldwin
2017-04-13 15:48 ` Luis Machado
2017-04-14 18:02 ` John Baldwin [this message]
2017-04-12 18:37 ` [PATCH 2/4] Use mips_regnum instead of constants for FreeBSD/mips " John Baldwin
2017-04-13 16:31 ` Luis Machado
2017-04-12 18:45 ` [PATCH 4/4] Don't throw an error in 'info registers' for unavailable MIPS GP registers John Baldwin
2017-04-13 16:37 ` Luis Machado
2017-04-14 18:02 ` John Baldwin
2017-04-15 16:02 ` Maciej W. Rozycki
2017-04-15 17:36 ` John Baldwin
2017-04-15 22:07 ` Maciej W. Rozycki
2017-04-17 18:27 ` John Baldwin
2017-04-18 21:33 ` Maciej W. Rozycki
2017-04-18 22:19 ` John Baldwin
2017-04-25 21:02 ` John Baldwin
2017-04-27 0:49 ` Maciej W. Rozycki
2017-04-27 15:50 ` Pedro Alves
2017-04-27 19:38 ` Maciej W. Rozycki
2017-04-28 13:51 ` Pedro Alves
2017-04-28 16:52 ` John Baldwin
2017-05-05 19:51 ` John Baldwin
2017-05-05 20:08 ` Maciej W. Rozycki
2017-06-12 18:47 ` John Baldwin
2017-06-15 23:50 ` Maciej W. Rozycki
2017-06-16 16:17 ` John Baldwin
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=1671472.AujrONiZJ6@ralph.baldwin.cx \
--to=jhb@freebsd.org \
--cc=gdb-patches@sourceware.org \
--cc=lgustavo@codesourcery.com \
/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