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: Problems with i386_register_convert_to_virtual


> > From: Robert Hoehne <robert.hoehne@gmx.net>
> > Date: Sun, 6 Aug 2000 00:54:05 +0200
> > 
> > void
> > i386_register_convert_to_virtual (int regnum, struct type *type,
> > 				  char *from, char *to)
> > {
> >   /* Copy straight over, but take care of the padding.  */
> >   memcpy (to, from, FPU_REG_RAW_SIZE);
> >   memset (to + FPU_REG_RAW_SIZE, 0, TYPE_LENGTH (type) - FPU_REG_RAW_SIZE);
> > }
> > 
> > -- snip --
> > 
> > When I see correct, this function assumes only to be called
> > for long double types.
> 
> Yes.
> 
> > But since this function is called using the
> > REGISTER_CONVERT_TO_VIRTUAL macro, it can get be called for any
> > (register) type.
> 
> Do we have any other registers that have different virtual and raw
> representations?  I thought that FP registers were the only ones.
> 
> I agree that it would be good to have some protection against invalid
> use of REGISTER_CONVERT_TO_VIRTUAL, but the case you are describing
> looks like a call to the wrong function, which valid code should not
> do.
> 

After more searching in the GDB code and docs, I found the macro
REGISTER_CONVERTIBLE which tells, if a register have different
raw and virtual sizes. This macro is also used for instance in findvar.c
to decide, if REGISTER_CONVERT_TO_VIRTUAL is called or a 
simple memcpy is done. In my Opionion either this should be documented
in the description for REGISTER_CONVERT_TO_VIRTUAL that
this macro should be called only, when REGISTER_CONVERTIBLE
returns true, or that logic should be included in the convert macro.

Robert
******************************************************
* email:   Robert Hoehne <robert.hoehne@gmx.net>     *
* Post:    Am Berg 3, D-09573 Dittmannsdorf, Germany *
* WWW:     http://www.tu-chemnitz.de/~sho/rho        *
******************************************************

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