From: John Baldwin <jhb@freebsd.org>
To: "Maciej W. Rozycki" <macro@imgtec.com>
Cc: Luis Machado <lgustavo@codesourcery.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 4/4] Don't throw an error in 'info registers' for unavailable MIPS GP registers.
Date: Sat, 15 Apr 2017 17:36:00 -0000 [thread overview]
Message-ID: <4515312.rZ8DjEE4Ue@ralph.baldwin.cx> (raw)
In-Reply-To: <alpine.DEB.2.00.1704151651360.25796@tp.orcam.me.uk>
On Saturday, April 15, 2017 05:02:23 PM Maciej W. Rozycki wrote:
> On Fri, 14 Apr 2017, John Baldwin wrote:
>
> > > What is the output you're getting in this case?
> >
> > On FreeBSD (which doesn't support fir) I now get this:
>
> If the register is not ever supplied, then you need a target description
> that does not include it. The rest of code will then handle it correctly.
No, mips-tdep.c requires fir to be included in the description:
static struct gdbarch *
mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
...
/* Check any target description for validity. */
if (tdesc_has_registers (info.target_desc))
{
...
valid_p
&= tdesc_numbered_register (feature, tdesc_data,
mips_regnum.fp_implementation_revision,
"fir");
if (!valid_p)
{
tdesc_data_cleanup (tdesc_data);
return NULL;
}
...
}
...
}
Thus, any target description that doesn't include fir is rejected. I will
change FreeBSD to export fir via ptrace() and core dumps at some point,
but it doesn't currently.
Note that Linux doesn't supply a valid fir from core dumps either (it just
hardcodes it as zero):
linux-mips-tdep.c:
void
mips_supply_fpregset (struct regcache *regcache,
const mips_elf_fpregset_t *fpregsetp)
{
...
char zerobuf[MAX_REGISTER_SIZE];
memset (zerobuf, 0, MAX_REGISTER_SIZE);
...
/* FIXME: how can we supply FCRIR? The ABI doesn't tell us. */
regcache_raw_supply (regcache,
mips_regnum (gdbarch)->fp_implementation_revision,
zerobuf);
}
> > It was more dire on a target that doesn't supply all registers. For example,
> > I have an out of tree target for FreeBSD kernels and stopped threads in
> > FreeBSD's kernel only supply a subset of GPRs. Without the patch examining
> > registers for a stopped thread looks like this:
>
> Why can't the remaining general registers be read or written -- is that a
> bug in the kernel?
>
> That sort of defeats the point of debugging, where you'd expect to be
> able to poke at any register that is at debuggee's disposal (so not
> supplying FIR can be considered a bug too). A program's variable could
> live in such an inaccessible register for example.
This isn't about the user thread state. When a user thread enters the kernel
due to an exception, system call, etc. then all registers are saved and are
available to the debugger. This is about debugging kernel threads in the kernel
itself. During a context switch, only a subset of registers are explicitly
saved in the thread's control block on FreeBSD (generally callee-save registers).
Caller-save registers can be found by unwinding the stack.
--
John Baldwin
next prev parent reply other threads:[~2017-04-15 17:36 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 2/4] Use mips_regnum instead of constants for FreeBSD/mips register operations John Baldwin
2017-04-13 16:31 ` Luis Machado
2017-04-12 18:37 ` [PATCH 1/4] Cleanups to FreeBSD/mips native " John Baldwin
2017-04-13 15:48 ` Luis Machado
2017-04-14 18:02 ` 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: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 [this message]
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=4515312.rZ8DjEE4Ue@ralph.baldwin.cx \
--to=jhb@freebsd.org \
--cc=gdb-patches@sourceware.org \
--cc=lgustavo@codesourcery.com \
--cc=macro@imgtec.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