This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] [SPARC] callfuncs.exp: avoid spurious register differences in sparc64 targets.
- From: jose dot marchesi at oracle dot com (Jose E. Marchesi)
- To: Pedro Alves <palves at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Fri, 20 Nov 2015 11:37:18 +0100
- Subject: Re: [PATCH] [SPARC] callfuncs.exp: avoid spurious register differences in sparc64 targets.
- Authentication-results: sourceware.org; auth=none
- References: <87ziyam0yh dot fsf at oracle dot com> <564DF643 dot 6000407 at redhat dot com> <87r3jlx5y5 dot fsf at oracle dot com> <564E06D5 dot 3020800 at redhat dot com>
> > + -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.
Right. PTRACE_GETREGS[64] always fetches the floating-point registers
saved in the thread struct save area (if a thread is ptracing itself it
saves the registers in the save area first). At the point GDB ptraces
the target process everything is saved.
Patch is OK assuming that.
Pushed.
Thanks.