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: [rfc/patch] extract/store typed floating ()


> 
> I'm not sure whether zeroing out the buffer in store_typed_floating()
> is desirable.  I've (almost) convinced myself that it isn't.  Here's a
> part of a comment that I added to the doublest.c in my current tree:
> 
>       /* ...
> 
>          It is debatable whether we should zero out any remaining
>          bytes in the target buffer, when converting from a type that
>          has a smaller length than the target type.  Right now we
>          don't do that.  A typical case where this situation arises is
>          when we convert a i387 floating-point register to a `long
>          double' in memory.  On the target, that operation only stores
>          the first 10 bytes, and leaves alone the remaining 2 bytes.
>          It makes sense to mimick this behaviour here.  */
> 
> This comment comes from a function convert_floating() that I intend to
> add to doublest.c.  I'll submit a patch after you've checked yours in.

Don't forget that the routines are expecting to manipulate a GDB 
internal buffer freshly allocated from the heap and not target memory. 
Failing to initialize it would leave it containing complete garbage 
(perhaphs I should set it to 0xdeadbeef).  That garbage would then be 
written back to the target since (well from memory) GDB writes all 
length bytes from a value buffer.

To ``do the write thing'', I suspect ``struct value'' and the value <-> 
memory transfer routines would all need to be modified so that they only 
write a sub-section of the buffer.  Other ideas also come to mind: 
edit_typed_floating() that edits an floating point buffer in place; add 
an ``old buffer'' parameter that can be used to optionally initialize 
unused bytes; or use  the raw floatformat routines(1) where needed.

The case that would worry me is with i387 registers.  For that, I think 
the target should just specify the 10 byte FP type so that GDB won't 
touch any padding bytes.

Andrew

(1) Would need to fix the problem of TYPE_FLOATFORMAT not always being 
initialized.



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