This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [RFA] mips: Fix "info registers" output


On Thu, Jun 21, 2001 at 07:31:15PM +0300, Eli Zaretskii wrote:
> 
> On Thu, 21 Jun 2001, Daniel Jacobowitz wrote:
> 
> >  - the decoding of double-precision arguments was completely broken. 
> > In addition to copying unallocated memory, and getting the byte order
> > wrong, we tried to decode two four-byte pointers to data instead of the
> > data itself.  Thus the doubles were generally 'nan'.
> > 
> >  - If the number of GPRs fit precisely on an integer number of rows,
> > blank space would be printed without even a trailing newline, and the
> > prompt would be mysteriously indented.
> 
> I cannot reproduce this on SGI Irix 6.5, which also uses mips-tdeps.c.  I 
> used a small throw-away FP program and all the FP registers printed 
> perfectly okay.  No NaNs at all.  info registers seems also okay.
> 
> Perhaps I didn't try exactly what you did.  Any further hints?

Really?  Hmm.  I looked over the code and it seemed that both branches
were wrong; however, I could be mistaken...

Aha!  Let me guess - Irix 6.5 is using the FP registers in 8 byte mode,
right?  There was indeed a bug on that path of the code, but it doesn't
actually affect the output.  We have this:

  raw_buffer[0] = (char *) alloca (REGISTER_RAW_SIZE (FP0_REGNUM));
  raw_buffer[1] = (char *) alloca (REGISTER_RAW_SIZE (FP0_REGNUM));
  dbl_buffer = (char *) alloca (2 * REGISTER_RAW_SIZE (FP0_REGNUM));

  /* Get the data in raw format.  */
  if (read_relative_register_raw_bytes (regnum, raw_buffer[HI]))
    error ("can't read register %d (%s)", regnum, REGISTER_NAME (regnum));

[snip]

      memcpy (dbl_buffer, raw_buffer[HI], 2 * REGISTER_RAW_SIZE (FP0_REGNUM));
      flt1 = unpack_double (builtin_type_float,
                            &raw_buffer[HI][offset], &inv1);
      doub = unpack_double (builtin_type_double, dbl_buffer, &inv3);

So we're copying 2 * 8 bytes out of an 8 byte buffer.  But float is
still 4 bytes and double still 8 bytes, so as long as we don't clobber
the stack we shouldn't see a real problem.


The real killer is on the other branch, size == 4:
      memcpy (dbl_buffer, raw_buffer, 2 * REGISTER_RAW_SIZE (FP0_REGNUM));

raw_buffer points to 8 bytes, sure enough - but they're both pointers
to four byte buffers before my patch.  That won't decode.


-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]