This is the mail archive of the
mailing list for the GDB project.
Re: Memory corruption for host double format different from target double format
- From: Mark Kettenis <mark dot kettenis at xs4all dot nl>
- To: uweigand at de dot ibm dot com
- Cc: yao at codesourcery dot com, gdb-patches at sourceware dot org, thomas at codesourcery dot com, gdb at sourceware dot org
- Date: Fri, 10 Aug 2012 16:31:47 +0200 (CEST)
- Subject: Re: Memory corruption for host double format different from target double format
- References: <201208101256.q7ACukE5013146@d06av02.portsmouth.uk.ibm.com>
> Date: Fri, 10 Aug 2012 14:56:46 +0200 (CEST)
> From: "Ulrich Weigand" <email@example.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
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.