From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cagney To: Mark Kettenis Cc: gdb-patches@sources.redhat.com Subject: Re: [rfc/patch] extract/store typed floating () Date: Sun, 23 Sep 2001 13:06:00 -0000 Message-id: <3BAE40CB.9080702@cygnus.com> References: <3BAA6F4A.1000508@cygnus.com> X-SW-Source: 2001-09/msg00309.html > > 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.