Re: Memory corruption for host double format different from target double format

Mark Kettenis
2012-08-10T14:32:14Z

> Date: Fri, 10 Aug 2012 14:56:46 +0200 (CEST)
> From: "Ulrich Weigand" <uweigand@de.ibm.com>
>
> Yao Qi wrote:
> > On Friday, August 10, 2012 11:32:53 AM Thomas Schwinge wrote:
> > > That is, if set_gdbarch_double_format has not been called, it will
> > > default to floatformats_ieee_double -- even though set_gdbarch_double_bit
> > > may have been called setting it unequal to the 64-bit double format.
> > > Hmm, and gdbarch.c:verify_gdbarch has the following comment on top of it:
> > > Ensure that all values in a GDBARCH are reasonable. ;-)
> >
> > Looks like some checking like this is missing?
> >
> > gdbarch->float_format->totalsize <= gdbarch->float_bit
> > gdbarch->double_format->totalsize <= gdbarch->double_bit
>
> In fact, I'd prefer to make gdbarch_double_format etc. *mandatory*
> and gdbarch_double_bit etc. optional, defaulting to the format size.
> (Currently, _bit is mandatory and _format is optional.)
>
> This would mean that nearly all calls to set_gdbarch_double_bit
> could go away, with the exception of special cases like "long double"
> on i386 ...

Initializing _bit based on _format by default makes sense, but I don't
think this is easy to implement given the way how the gdbarch.c code
is generated.

Making _format mandatory doesn't make sense to me though. I'd say
that ieee_single and ieee_double are perfectly reasonable defaults for
float_format and double_format.

> [ I guess we could also hunt down and remove the final few places
> that still create a TYPE_CODE_FLT with no format set; then the
> floatflormat_from_length routine could go away completely. ]

I don't think that's possible. Many (all?) debug formats only
encode the size of floating-point variables.