This is the mail archive of the gdb@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: What to do with extract/store floating()?


I wrote:

> Hello,
> 
> 
> At present GDB has the functions:
> 
>  DOUBLEST extract_floating (const void *in, int);
>  void store_floating (void *, int, DOUBLEST);
> 
> where that ``int'' parameter is the length of the floating-point value being extracted/stored in bytes(1).
> 
> These functions then map that length onto a target type and from there do a floating point conversion.  This leads to a convoluted double flip:
> 
> gdbtypes.c:
>     TYPE_LENGTH(type) = TARGET_DOUBLE_BIT / TARGET_CHAR_BIT;
> client code:
>     extract_floating (buf, TYPE_LENGTH (type));
> doublest.c:
>     if (length == TARGET_DOUBLE_BIT / TARGET_CHAR_BIT)
>       ..
> 
> 
> Originally I was going to replace all these with:
> 
>     floatformat_to_doublest()
> and floatformat_from_doublest()
> 
> however, in the light of the clarified meaning of ``struct type . length'', that initial change would be wrong (it is the total size of the type, the FP value is often smaller).
> 
> 
> I'm now considering changing things to:
> 
>  DOUBLEST extract_floating (const void *in, struct type *type);
>  void store_floating (void *, struct type *type, DOUBLEST);
> 
> store_floating(), for instance, would zero all TYPE_LENGTH(type) bytes and then store DOUBLEST based on TYPE_FLOATFORMAT().
> 
> 
> A variation on this (more incremental, less risk) would be to introduce new functions with the above signatures (extract_doublest() and store_doublest()?) and then deprecate the old extract_floating() and store_floating() functions.  A quick grep shows ~34 calls, 4 in core code and one in stabsread.c!
> 
> 
> Any preference?  I've a patch for the middle option but I'm not sure how correct it will be without testing. Pease don't ask if they are target or host bytes.

Given that no one expressed a preference I'm going with the last option. 
  Add functions:

DOUBLEST extract_doublest (const void *in, struct type *type);
void store_doublest (void *, struct type *type, DOUBLEST);

update the core to use them deprecating the old calls in target code.

	Andrew



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