[rfc] Don't convert to/from an illegal FP type

Andrew Cagney ac131313@cygnus.com
Mon May 29 06:14:00 GMT 2000


Hello,

Really wierd one - freebsd x d10v started having regressions in the
fortran part of the testsuite.  Turns out that there were two problems:

	o	d10v didn't correctly specify
		TARGET_LONG_DOUBLE_FORMAT

	o	fbsd didn't specify
		HOST_LONG_DOUBLE_FORMAT

the double negative ended up with a positive - d10v's floating point
appeared to work perfectly :-)

The attatched makes findvar.c's FP conversions more robust.  I'll follow
with a d10v fix.

	Andrew
Mon May 29 23:08:26 2000  Andrew Cagney  <cagney@b1.cygnus.com>

	* findvar.c (store_floating, extract_floating): Check that the
 	target floating point type is valid before converting from it.

Index: findvar.c
===================================================================
RCS file: /cvs/src/src/gdb/findvar.c,v
retrieving revision 1.12
diff -p -r1.12 findvar.c
*** findvar.c	2000/05/28 01:12:27	1.12
--- findvar.c	2000/05/29 13:10:01
*************** extract_floating (void *addr, int len)
*** 310,316 ****
  {
    DOUBLEST dretval;
  
!   if (len * TARGET_CHAR_BIT == TARGET_FLOAT_BIT)
      {
        if (HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT)
  	{
--- 310,317 ----
  {
    DOUBLEST dretval;
  
!   if (len * TARGET_CHAR_BIT == TARGET_FLOAT_BIT
!       && TARGET_FLOAT_FORMAT != &floatformat_unknown)
      {
        if (HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT)
  	{
*************** extract_floating (void *addr, int len)
*** 322,328 ****
        else
  	floatformat_to_doublest (TARGET_FLOAT_FORMAT, addr, &dretval);
      }
!   else if (len * TARGET_CHAR_BIT == TARGET_DOUBLE_BIT)
      {
        if (HOST_DOUBLE_FORMAT == TARGET_DOUBLE_FORMAT)
  	{
--- 323,330 ----
        else
  	floatformat_to_doublest (TARGET_FLOAT_FORMAT, addr, &dretval);
      }
!   else if (len * TARGET_CHAR_BIT == TARGET_DOUBLE_BIT
! 	   && TARGET_DOUBLE_FORMAT != &floatformat_unknown)
      {
        if (HOST_DOUBLE_FORMAT == TARGET_DOUBLE_FORMAT)
  	{
*************** extract_floating (void *addr, int len)
*** 334,340 ****
        else
  	floatformat_to_doublest (TARGET_DOUBLE_FORMAT, addr, &dretval);
      }
!   else if (len * TARGET_CHAR_BIT == TARGET_LONG_DOUBLE_BIT)
      {
        if (HOST_LONG_DOUBLE_FORMAT == TARGET_LONG_DOUBLE_FORMAT)
  	{
--- 336,343 ----
        else
  	floatformat_to_doublest (TARGET_DOUBLE_FORMAT, addr, &dretval);
      }
!   else if (len * TARGET_CHAR_BIT == TARGET_LONG_DOUBLE_BIT
! 	   && TARGET_LONG_DOUBLE_FORMAT != &floatformat_unknown)
      {
        if (HOST_LONG_DOUBLE_FORMAT == TARGET_LONG_DOUBLE_FORMAT)
  	{
*************** extract_floating (void *addr, int len)
*** 357,363 ****
  void
  store_floating (void *addr, int len, DOUBLEST val)
  {
!   if (len * TARGET_CHAR_BIT == TARGET_FLOAT_BIT)
      {
        if (HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT)
  	{
--- 360,367 ----
  void
  store_floating (void *addr, int len, DOUBLEST val)
  {
!   if (len * TARGET_CHAR_BIT == TARGET_FLOAT_BIT
!       && TARGET_FLOAT_FORMAT != &floatformat_unknown)
      {
        if (HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT)
  	{
*************** store_floating (void *addr, int len, DOU
*** 368,374 ****
        else
  	floatformat_from_doublest (TARGET_FLOAT_FORMAT, &val, addr);
      }
!   else if (len * TARGET_CHAR_BIT == TARGET_DOUBLE_BIT)
      {
        if (HOST_DOUBLE_FORMAT == TARGET_DOUBLE_FORMAT)
  	{
--- 372,379 ----
        else
  	floatformat_from_doublest (TARGET_FLOAT_FORMAT, &val, addr);
      }
!   else if (len * TARGET_CHAR_BIT == TARGET_DOUBLE_BIT
! 	   && TARGET_DOUBLE_FORMAT != &floatformat_unknown)
      {
        if (HOST_DOUBLE_FORMAT == TARGET_DOUBLE_FORMAT)
  	{
*************** store_floating (void *addr, int len, DOU
*** 379,385 ****
        else
  	floatformat_from_doublest (TARGET_DOUBLE_FORMAT, &val, addr);
      }
!   else if (len * TARGET_CHAR_BIT == TARGET_LONG_DOUBLE_BIT)
      {
        if (HOST_LONG_DOUBLE_FORMAT == TARGET_LONG_DOUBLE_FORMAT)
  	memcpy (addr, &val, sizeof (val));
--- 384,391 ----
        else
  	floatformat_from_doublest (TARGET_DOUBLE_FORMAT, &val, addr);
      }
!   else if (len * TARGET_CHAR_BIT == TARGET_LONG_DOUBLE_BIT
! 	   && TARGET_LONG_DOUBLE_FORMAT != &floatformat_unknown)
      {
        if (HOST_LONG_DOUBLE_FORMAT == TARGET_LONG_DOUBLE_FORMAT)
  	memcpy (addr, &val, sizeof (val));


More information about the Gdb-patches mailing list