Re: [PATCH 01/24] gdb: don't handle i386 k registers as pseudo registers

John Baldwin
2023-11-11T19:29:28Z

On 11/7/23 9:00 PM, Simon Marchi wrote:
> From: Simon Marchi <simon.marchi@efficios.com>
>
> I think that i386 k registers are raw registers, and therefore shouldn't
> be handled in the various functions handling pseudo registers.
>
> What tipped me off is the code in i386_pseudo_register_read_into_value:
>
> else if (i386_k_regnum_p (gdbarch, regnum))
> {
> regnum -= tdep->k0_regnum;
>
> /* Extract (always little endian). */
> status = regcache->raw_read (tdep->k0_regnum + regnum, raw_buf);
>
> We take regnum (the pseudo register number we want to read), subtract
> k0_regnum, add k0_regnum, and pass the result to raw_read. So we would
> end up calling raw_read with the same regnum as the function received
> which is supposedly a pseudo register number.
>
> Other hints are:
>
> - The command `maint print raw-registers` shows the k registers.
> - Printing $k0 doesn't cause i386_pseudo_register_read_into_value to be
> called.
> - There's code in i387-tdep.c to save/restore the k registers.

Also, the bottom of i386_gdbarch_init (where all of the pseudo register numbers
are allocated) doesn't allocate any pseudo register numbers for the k registers.
I think this bit of code in i386_gdbarch_init is the definitive set of what
counts as pseudo registers on i386/amd64.

> Remove handling of the k registers from:
>
> - i386_pseudo_register_read_into_value
> - i386_pseudo_register_write
> - i386_ax_pseudo_register_collect

Reviewed-by: John Baldwin <jhb@FreeBSD.org>

--
John Baldwin