From: Pedro Alves <palves@redhat.com>
To: "Jose E. Marchesi" <jose.marchesi@oracle.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] [SPARC] callfuncs.exp: avoid spurious register differences in sparc64 targets.
Date: Thu, 19 Nov 2015 17:28:00 -0000 [thread overview]
Message-ID: <564E06D5.3020800@redhat.com> (raw)
In-Reply-To: <87r3jlx5y5.fsf@oracle.com>
On 11/19/2015 05:19 PM, Jose E. Marchesi wrote:
>
> > + -re "^pstate\[ \t\]+\[^\r\n\]+\r\n" {
> > + if [istarget "sparc64-*-linux-gnu"] {
> > + # Filter out the pstate register, since in sparc64
> > + # targets the Linux kernel disables pstate.PEF when
> > + # returning from traps, giving spurious differences.
>
> Isn't this a kernel bug? It sounds like it's impossible to debug FPU
> code if you e.g. step over FPU instructions?
>
> No, it is not a kernel bug. It is a consequence of how the sparc
> kernel port handles the restoring of FP registers clobbered by kernel
> code. As far as I understand it:
>
> When an user program uses the FPU in any way (any instruction
> referencing FP registers for example) a fp_disabled trap is triggered
> and the kernel enables the FPU so the user program can happily continue
> executing FPU instructions.
>
> If at some point the user program traps into the kernel (syscall, or
> whatever) with the FPU activated the kernel saves whatever FP registers
> it may clobber in the corresponding thread struct. Then it disables the
> FPU and returns to the user program.
>
> Then, if the user program uses the FPU again, another fp_disabled trap
> is triggered, and the kernel will both re-activate the FPU and restore
> all the "dirty" FP registers that were clobbered in the previous trap.
Thanks for the explanation.
So until the program re-activates the FPU, when the user displays the FP
registers, gdb actually shows the fpu registers as saved in the thread
struct, right? Not the values clobbered by the kernel? I'd guess so,
otherwise people would have noticed the breakage sooner, and assuming
the kernel does use FPU instructions itself, then you'd get other
spurious register differences with callfuncs.exp too. Patch is OK
assuming that.
Still sounds to me that it'd be better if ptrace traps left the FPU
activated if it was activate on entry, on principle of minimizing
program perturbation with a ptrace observer though ...
Thanks,
Pedro Alves
next prev parent reply other threads:[~2015-11-19 17:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-19 15:55 Jose E. Marchesi
2015-11-19 16:18 ` Pedro Alves
2015-11-19 17:12 ` Jose E. Marchesi
2015-11-19 17:28 ` Pedro Alves [this message]
2015-11-20 10:29 ` Jose E. Marchesi
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=564E06D5.3020800@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=jose.marchesi@oracle.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).