[RFA] mips: Fix "info registers" output
Andrew Cagney
ac131313@cygnus.com
Sat Mar 9 18:05:00 GMT 2002
> Meanwhile, Andrew, is this trivial fix OK? It just makes us decode the
> actual register values instead of two host pointers in our call to
> unpack_double.
I suspect the code was more broken then you thought!
If my memory is correct, the value is always stored LE in the register
pair. The code manages to do a double swap and consequently doesn't
correctly re-order the registers in the dbl_buffer.
It is also really broken when a 32 bit ABI is on a 64 bit ISA. (It very
nearly corrupts the stack).
> /* copy the two floats into one double, and unpack both */
> - memcpy (dbl_buffer, raw_buffer, 2 * REGISTER_RAW_SIZE (FP0_REGNUM));
> flt1 = unpack_double (builtin_type_float, raw_buffer[HI], &inv1);
> flt2 = unpack_double (builtin_type_float, raw_buffer[LO], &inv2);
> + memcpy (dbl_buffer, raw_buffer[HI], REGISTER_RAW_SIZE (FP0_REGNUM));
> + memcpy (dbl_buffer + REGISTER_RAW_SIZE (FP0_REGNUM),
> + raw_buffer[LO], REGISTER_RAW_SIZE (FP0_REGNUM));
> doub = unpack_double (builtin_type_double, dbl_buffer, &inv3);
>
I suspect a bigger improvement would look something like (I'm still not
100% sure of what goes where with BE/LE though :-)
if (!FP_REGISTER_DOUBLE)
char *raw_buffer[2];
char *dbl_buffer;
raw_buffer[0] = alloca; [1] = alloca; dbl_buffer = alloca;
read_relative_register(regnum+0, raw_buffer[0])
read_relative_register(regnum+1, raw_buffer[1])
if (BE)
reg_offset = (REGISTER_RAW_SIZE() == 8) ? 4 : 0;
type_float = builtin_type_ieee_single_big
type_double = builtin_type_ieee_double_big
memcpy dbl_buffer+4, raw_buffer[0] + reg_offset, 4);
memcpy dbl_buffer+0, raw_buffer[1] + reg_offset, 4);
else
reg_offset = 0
type_float = builtin_type_ieee_single_little
type_double = builtin_type_ieee_double_little
memcpy dbl_buffer+0, raw_buffer[0] + reg_offset, 4);
memcpy dbl_buffer+4, raw_buffer[1] + reg_offset, 4);
flt0 = unpack_double (type_float, raw_buffer[0] + reg_offset, &inv)
flt1 = unpack_double (type_float, raw_buffer[1] + reg_offset, &inv)
doub = unpack_double (type_double, dbl_buffer, &inv3)
Andrew
More information about the Gdb-patches
mailing list