Re: RFC: partially available registers

Pedro Alves
2011-07-22T19:10:43Z

On Friday 22 July 2011 19:55:31, Tom Tromey wrote:
> >>>>> "Pedro" == Pedro Alves <pedro@codesourcery.com> writes:
>
> Pedro> Ah, that's it then. I was curious to know why were the
> Pedro> upper parts of the ymm unavailable.
>
> amd64_linux_fetch_inferior_registers calls ptrace(PTRACE_GETREGSET)
> to fetch the registers. Then it passes this to amd64_supply_xsave,
> which calls i387_supply_xsave. This function then decodes the "XCR0"
> flag and determines that the upper parts were not supplied by the
> kernel; that is, we take the true branch here:
>
> if ((clear_bv & I386_XSTATE_AVX))
> p = NULL;
> else
> p = regs;

Ah, thanks. With a bit more context:

case avxh:
if ((clear_bv & I386_XSTATE_AVX))
p = NULL;
else
p = XSAVE_AVXH_ADDR (tdep, regs, regnum);
regcache_raw_supply (regcache, regnum, p);
return;

regcache_raw_supply with p=NULL means the register
is unavailable. But before the <unavailable> stuff,
it meant "supply the register as 0". I seem to remember
discussing this AVX stuff with H.J., and coming to the
conclusion that what want is really 0, but maybe not.
gdbserver is explicitly zeroing in this case, instead
of returning unavailable, see
gdbserver/i387-fp.c:i387_xsave_to_cache.

What does it really mean when you have an AVX
capable machine, but I386_XSTATE_AVX is clear?

Whatever the answer, we need to fix one of native
gdb or gdbserver for consistency.

--
Pedro Alves