Bring IEEE_FLOAT under gdbarch's control.
authorJim Blandy <jimb@codesourcery.com>
Fri, 14 Apr 2000 19:14:19 +0000 (19:14 +0000)
committerJim Blandy <jimb@codesourcery.com>
Fri, 14 Apr 2000 19:14:19 +0000 (19:14 +0000)
* gdbarch.sh (IEEE_FLOAT): New entry.
* gdbarch.c, gdbarch.h: Regenerated.
* valprint.c (IEEE_FLOAT): Provide a default #definition for this.
(print_floating): Use IEEE_FLOAT as if it were an expression; use
the code specific to IEEE-format numbers whenever the value of
IEEE_FLOAT is non-zero.
* config/a29k/tm-a29k.h, config/alpha/tm-alpha.h,
config/arc/tm-arc.h, config/arm/tm-arm.h, config/fr30/tm-fr30.h,
config/h8300/tm-h8300.h, config/i386/tm-i386.h,
config/i960/tm-i960.h, config/m88k/tm-m88k.h,
config/mips/tm-mips.h, config/pa/tm-hppa.h,
config/sparc/tm-sparc.h, config/delta/tm-delta.h,
config/frv/tm-frv.h (IEEE_FLOAT): For all ports that #define
IEEE_FLOAT, make sure they give it the value (1).

21 files changed:
gdb/config/a29k/tm-a29k.h
gdb/config/alpha/tm-alpha.h
gdb/config/arc/tm-arc.h
gdb/config/arm/tm-arm.h
gdb/config/fr30/tm-fr30.h
gdb/config/h8300/tm-h8300.h
gdb/config/h8500/tm-h8500.h
gdb/config/i386/tm-i386.h
gdb/config/i960/tm-i960.h
gdb/config/m68k/tm-m68k.h
gdb/config/m88k/tm-m88k.h
gdb/config/mips/tm-mips.h
gdb/config/pa/tm-hppa.h
gdb/config/sh/tm-sh.h
gdb/config/sparc/tm-sparc.h
gdb/config/w65/tm-w65.h
gdb/config/z8k/tm-z8k.h
gdb/gdbarch.c
gdb/gdbarch.h
gdb/gdbarch.sh
gdb/valprint.c

index 25a5bea74d0eaea3a0ddedf5b3f319c2919bedbe..7a884a4b563a9394dec686989031e2f04c39560a 100644 (file)
@@ -31,7 +31,7 @@
 #define TARGET_BYTE_ORDER BIG_ENDIAN
 
 /* Floating point uses IEEE representations.  */
-#define IEEE_FLOAT
+#define IEEE_FLOAT (1)
 
 /* Recognize our magic number.  */
 #define BADMAG(x) ((x).f_magic != 0572)
index d63dcc1296d1f3ccf31fe9430e3105089e0873c8..37559936923d4153b54f82bdea1658c1d90603a2 100644 (file)
@@ -42,7 +42,7 @@ struct symbol;
 #define TARGET_PTR_BIT 64
 
 /* Floating point is IEEE compliant */
-#define IEEE_FLOAT
+#define IEEE_FLOAT (1)
 
 /* Number of traps that happen between exec'ing the shell 
  * to run an inferior, and when we finally get to 
index 34fabaf4f3a5115679d99cb9fc637ed79652d74c..a6531a51adcdd655b70b6447a6f4045c6720c2ee 100644 (file)
@@ -26,7 +26,7 @@
 #define        TARGET_BYTE_ORDER_SELECTABLE
 
 /* We have IEEE floating point, if we have any float at all.  */
-#define IEEE_FLOAT
+#define IEEE_FLOAT (1)
 
 /* Offset from address of function to start of its code.
    Zero on most machines.  */
index e64b77633dd8f0cd5b96263e500657b86f077724..ed8e80c7d582feb1bff22c5f1a2f5d18592f82d0 100644 (file)
@@ -31,7 +31,7 @@ struct value;
 #define TARGET_BYTE_ORDER_DEFAULT      LITTLE_ENDIAN
 
 /* IEEE format floating point.  */
-#define IEEE_FLOAT
+#define IEEE_FLOAT (1)
 #define TARGET_DOUBLE_FORMAT  (target_byte_order == BIG_ENDIAN \
                               ? &floatformat_ieee_double_big    \
                               : &floatformat_ieee_double_littlebyte_bigword)
index d289f6e3450d6a5804b8184d2fd537ccdb2909b9..69c85aacaa66828e993c425346da9729663db35c 100644 (file)
@@ -186,7 +186,7 @@ extern void fr30_store_return_value PARAMS ((struct type * type, char *valbuf));
 #define TARGET_FR30
 
 /* IEEE format floating point */
-#define IEEE_FLOAT
+#define IEEE_FLOAT (1)
 
 /* Define other aspects of the stack frame.  */
 
index 44b5e0d3e7aba4ae3028ba0151aa134bdefca902..8ee68162ff3e0e85adc0c7c5d621c2c82c151ed5 100644 (file)
@@ -50,7 +50,7 @@ extern int h8300smode;
 
 extern void h8300_init_extra_frame_info ();
 
-#define IEEE_FLOAT
+#define IEEE_FLOAT (1)
 /* Define the bit, byte, and word ordering of the machine.  */
 #define TARGET_BYTE_ORDER BIG_ENDIAN
 #undef TARGET_INT_BIT
index eb21a5c6fb1777a24659096348b3d20cfa98ea85..070ac275042dc4278cf68007899a5919eaa3d041 100644 (file)
@@ -22,7 +22,7 @@
 
 #define GDB_TARGET_IS_H8500
 
-#define IEEE_FLOAT 1
+#define IEEE_FLOAT (1)
 
 /* Define the bit, byte, and word ordering of the machine.  */
 
index bcb99fced4178e511152f55dfc44fd9a92d1ab41..33cb7f687b06dab49138762b9ebf364c18b7bdc0 100644 (file)
@@ -44,7 +44,7 @@ struct type;
 /* Used for example in valprint.c:print_floating() to enable checking
    for NaN's */
 
-#define IEEE_FLOAT
+#define IEEE_FLOAT (1)
 
 /* Number of traps that happen between exec'ing the shell to run an
    inferior, and when we finally get to the inferior code.  This is 2
index 73bb8dbfff46e1f8c9fe0ac14e599960ccbcd30f..1c25118d7919bd5f3ca8e5f8ec1fe5f2ac83f4bb 100644 (file)
@@ -40,7 +40,7 @@
 
 /* We have IEEE floating point, if we have any float at all.  */
 
-#define IEEE_FLOAT
+#define IEEE_FLOAT (1)
 
 /* Offset from address of function to start of its code.
    Zero on most machines.  */
index c3574ee0a9a04d465ae4b8ed49095c3a9941056f..03cf9b38f10085db55c5525c31503b77d12782df 100644 (file)
@@ -20,7 +20,7 @@
 
 /* Generic 68000 stuff, to be included by other tm-*.h files.  */
 
-#define IEEE_FLOAT 1
+#define IEEE_FLOAT (1)
 
 /* Define the bit, byte, and word ordering of the machine.  */
 #define TARGET_BYTE_ORDER BIG_ENDIAN
index 1acb83e9584a309492a6ace92a948cbb61c3821e..6effedc4436c690c571836c2c663886333295050 100644 (file)
@@ -43,7 +43,7 @@
        init_extra_frame_info (fromleaf, fi)
 extern void init_extra_frame_info ();
 
-#define IEEE_FLOAT
+#define IEEE_FLOAT (1)
 
 /* Offset from address of function to start of its code.
    Zero on most machines.  */
index 3b8330fb0e8569bbbb240a9f8cc7bb009c2116df..2f52fbe9815d2571576538374635e99c2165663f 100644 (file)
@@ -58,7 +58,7 @@ struct value;
 #endif
 
 /* Floating point is IEEE compliant */
-#define IEEE_FLOAT
+#define IEEE_FLOAT (1)
 
 /* The name of the usual type of MIPS processor that is in the target
    system.  */
index 9307fa567212cb88a8bd4c174940b77d337a62bc..975820a86ecc16fee6b09ad9e428c64c89f5e123 100644 (file)
@@ -53,7 +53,7 @@ struct inferior_status;
 
 /* Watch out for NaNs */
 
-#define IEEE_FLOAT
+#define IEEE_FLOAT (1)
 
 /* On the PA, any pass-by-value structure > 8 bytes is actually
    passed via a pointer regardless of its type or the compiler
index a3367131180ce163ba9e8d8595168c4d15142115..ad26ec17faca6550d497401512a3d8d81b962e21 100644 (file)
@@ -27,7 +27,7 @@ struct type;
 
 #define GDB_TARGET_IS_SH
 
-#define IEEE_FLOAT 1
+#define IEEE_FLOAT (1)
 
 /* Define the bit, byte, and word ordering of the machine.  */
 
index 5419ecb88e25302ab4fc537b882b73a7b99ee904..29cf746ee1bbdc7f931ef820885c5b7e2c889dde 100644 (file)
@@ -28,7 +28,7 @@ struct value;
 #define TARGET_BYTE_ORDER BIG_ENDIAN
 
 /* Floating point is IEEE compatible.  */
-#define IEEE_FLOAT
+#define IEEE_FLOAT (1)
 
 /* If an argument is declared "register", Sun cc will keep it in a register,
    never saving it onto the stack.  So we better not believe the "p" symbol
index b1fe4eddcebcb8ebc789ea4afa2473332b069e36..c8da6bf875c6c28c33ce7fcdcec945d8b0c33b1d 100644 (file)
@@ -22,7 +22,7 @@
 
 #define GDB_TARGET_IS_W65
 
-#define IEEE_FLOAT 1
+#define IEEE_FLOAT (1)
 
 /* Define the bit, byte, and word ordering of the machine.  */
 
index f781e0a868e38dfbd017c34012d0432e2cb36aa4..9cc12ec843a296a68a26f5127ad5c3b6d1a65393 100644 (file)
@@ -18,7 +18,7 @@
    Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#define IEEE_FLOAT 1
+#define IEEE_FLOAT (1)
 
 #undef TARGET_INT_BIT
 #undef TARGET_LONG_BIT
index a1b02ace829e4c3cdfae53131242f7a8fe22d990..6b587608f10516cb4b3bf35c306fd1f8d523e6ef 100644 (file)
@@ -135,6 +135,7 @@ struct gdbarch
   int float_bit;
   int double_bit;
   int long_double_bit;
+  int ieee_float;
   gdbarch_read_pc_ftype *read_pc;
   gdbarch_write_pc_ftype *write_pc;
   gdbarch_read_fp_ftype *read_fp;
@@ -273,6 +274,7 @@ struct gdbarch startup_gdbarch = {
   0,
   0,
   0,
+  0,
   generic_get_saved_register,
   0,
   0,
@@ -335,6 +337,7 @@ gdbarch_alloc (const struct gdbarch_info *info,
 
   /* Force the explicit initialization of these. */
   gdbarch->bfd_vma_bit = TARGET_ARCHITECTURE->bits_per_address;
+  gdbarch->ieee_float = 1;
   gdbarch->num_regs = -1;
   gdbarch->sp_regnum = -1;
   gdbarch->fp_regnum = -1;
@@ -423,6 +426,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
   if ((GDB_MULTI_ARCH >= 1)
       && (gdbarch->long_double_bit == 0))
     internal_error ("gdbarch: verify_gdbarch: long_double_bit invalid");
+  /* Skip verify of ieee_float, invalid_p == 0 */
   if ((GDB_MULTI_ARCH >= 1)
       && (gdbarch->read_pc == 0))
     internal_error ("gdbarch: verify_gdbarch: read_pc invalid");
@@ -655,6 +659,9 @@ gdbarch_dump (void)
   fprintf_unfiltered (gdb_stdlog,
                       "gdbarch_update: TARGET_LONG_DOUBLE_BIT = %ld\n",
                       (long) TARGET_LONG_DOUBLE_BIT);
+  fprintf_unfiltered (gdb_stdlog,
+                      "gdbarch_update: IEEE_FLOAT = %ld\n",
+                      (long) IEEE_FLOAT);
   fprintf_unfiltered (gdb_stdlog,
                       "gdbarch_update: TARGET_READ_PC = 0x%08lx\n",
                       (long) current_gdbarch->read_pc
@@ -1120,6 +1127,22 @@ set_gdbarch_long_double_bit (struct gdbarch *gdbarch,
   gdbarch->long_double_bit = long_double_bit;
 }
 
+int
+gdbarch_ieee_float (struct gdbarch *gdbarch)
+{
+  /* Skip verify of ieee_float, invalid_p == 0 */
+  if (gdbarch_debug >= 2)
+    fprintf_unfiltered (gdb_stdlog, "gdbarch_ieee_float called\n");
+  return gdbarch->ieee_float;
+}
+
+void
+set_gdbarch_ieee_float (struct gdbarch *gdbarch,
+                        int ieee_float)
+{
+  gdbarch->ieee_float = ieee_float;
+}
+
 CORE_ADDR
 gdbarch_read_pc (struct gdbarch *gdbarch, int pid)
 {
index f24c26e76f88e9498b5e45f39cc235a345c8c86c..4f837c11768dd0b1545e584cc91121194754c647 100644 (file)
@@ -171,6 +171,14 @@ extern void set_gdbarch_long_double_bit (struct gdbarch *gdbarch, int long_doubl
 #endif
 #endif
 
+extern int gdbarch_ieee_float (struct gdbarch *gdbarch);
+extern void set_gdbarch_ieee_float (struct gdbarch *gdbarch, int ieee_float);
+#if GDB_MULTI_ARCH
+#if (GDB_MULTI_ARCH > 1) || !defined (IEEE_FLOAT)
+#define IEEE_FLOAT (gdbarch_ieee_float (current_gdbarch))
+#endif
+#endif
+
 typedef CORE_ADDR (gdbarch_read_pc_ftype) (int pid);
 extern CORE_ADDR gdbarch_read_pc (struct gdbarch *gdbarch, int pid);
 extern void set_gdbarch_read_pc (struct gdbarch *gdbarch, gdbarch_read_pc_ftype *read_pc);
index 9575e7fbac5edc8e1998e18b5c4c5f245fca729b..93d9871ec7191f2de4c1aa1da3556b76819000e8 100755 (executable)
@@ -193,6 +193,7 @@ v:1:TARGET_LONG_LONG_BIT:int:long_long_bit::::8 * sizeof (LONGEST):0
 v:1:TARGET_FLOAT_BIT:int:float_bit::::8 * sizeof (float):0
 v:1:TARGET_DOUBLE_BIT:int:double_bit::::8 * sizeof (double):0
 v:1:TARGET_LONG_DOUBLE_BIT:int:long_double_bit::::8 * sizeof (long double):0
+v:1:IEEE_FLOAT:int:ieee_float::::0:1:0
 #
 f:1:TARGET_READ_PC:CORE_ADDR:read_pc:int pid:pid::0:0
 f:1:TARGET_WRITE_PC:void:write_pc:CORE_ADDR val, int pid:val, pid::0:0
@@ -815,7 +816,7 @@ copyright
 cat <<EOF
 
 #include "defs.h"
-#include "gdbarch-utils.h"
+#include "arch-utils.h"
 
 #if GDB_MULTI_ARCH
 #include "gdbcmd.h"
index e1414792b79e2ce4673e2a1d92ab742fc82c069c..455d7eed27b74399e237d6d403de2ce77ecf23fa 100644 (file)
@@ -561,6 +561,13 @@ longest_to_int (arg)
   return (rtnval);
 }
 
+
+/* Provide a default value for IEEE_FLOAT.  */
+#ifndef IEEE_FLOAT
+#define IEEE_FLOAT (0)
+#endif
+
+
 /* Print a floating point value of type TYPE, pointed to in GDB by VALADDR,
    on STREAM.  */
 
@@ -574,85 +581,82 @@ print_floating (valaddr, type, stream)
   int inv;
   unsigned len = TYPE_LENGTH (type);
 
-#if defined (IEEE_FLOAT)
-
   /* Check for NaN's.  Note that this code does not depend on us being
      on an IEEE conforming system.  It only depends on the target
      machine using IEEE representation.  This means (a)
      cross-debugging works right, and (2) IEEE_FLOAT can (and should)
-     be defined for systems like the 68881, which uses IEEE
+     be non-zero for systems like the 68881, which uses IEEE
      representation, but is not IEEE conforming.  */
+  if (IEEE_FLOAT)
+    {
+      unsigned long low, high;
+      /* Is the sign bit 0?  */
+      int nonnegative;
+      /* Is it is a NaN (i.e. the exponent is all ones and
+        the fraction is nonzero)?  */
+      int is_nan;
+
+      /* For lint, initialize these two variables to suppress warning: */
+      low = high = nonnegative = 0;
+      if (len == 4)
+       {
+         /* It's single precision.  */
+         /* Assume that floating point byte order is the same as
+            integer byte order.  */
+         low = extract_unsigned_integer (valaddr, 4);
+         nonnegative = ((low & 0x80000000) == 0);
+         is_nan = ((((low >> 23) & 0xFF) == 0xFF)
+                   && 0 != (low & 0x7FFFFF));
+         low &= 0x7fffff;
+         high = 0;
+       }
+      else if (len == 8)
+       {
+         /* It's double precision.  Get the high and low words.  */
 
-  {
-    unsigned long low, high;
-    /* Is the sign bit 0?  */
-    int nonnegative;
-    /* Is it is a NaN (i.e. the exponent is all ones and
-       the fraction is nonzero)?  */
-    int is_nan;
-
-    /* For lint, initialize these two variables to suppress warning: */
-    low = high = nonnegative = 0;
-    if (len == 4)
-      {
-       /* It's single precision.  */
-       /* Assume that floating point byte order is the same as
-          integer byte order.  */
-       low = extract_unsigned_integer (valaddr, 4);
-       nonnegative = ((low & 0x80000000) == 0);
-       is_nan = ((((low >> 23) & 0xFF) == 0xFF)
-                 && 0 != (low & 0x7FFFFF));
-       low &= 0x7fffff;
-       high = 0;
-      }
-    else if (len == 8)
-      {
-       /* It's double precision.  Get the high and low words.  */
-
-       /* Assume that floating point byte order is the same as
-          integer byte order.  */
-       if (TARGET_BYTE_ORDER == BIG_ENDIAN)
-         {
-           low = extract_unsigned_integer (valaddr + 4, 4);
-           high = extract_unsigned_integer (valaddr, 4);
-         }
-       else
-         {
-           low = extract_unsigned_integer (valaddr, 4);
-           high = extract_unsigned_integer (valaddr + 4, 4);
-         }
-       nonnegative = ((high & 0x80000000) == 0);
-       is_nan = (((high >> 20) & 0x7ff) == 0x7ff
-                 && !((((high & 0xfffff) == 0)) && (low == 0)));
-       high &= 0xfffff;
-      }
-    else
-      {
+         /* Assume that floating point byte order is the same as
+            integer byte order.  */
+         if (TARGET_BYTE_ORDER == BIG_ENDIAN)
+           {
+             low = extract_unsigned_integer (valaddr + 4, 4);
+             high = extract_unsigned_integer (valaddr, 4);
+           }
+         else
+           {
+             low = extract_unsigned_integer (valaddr, 4);
+             high = extract_unsigned_integer (valaddr + 4, 4);
+           }
+         nonnegative = ((high & 0x80000000) == 0);
+         is_nan = (((high >> 20) & 0x7ff) == 0x7ff
+                   && !((((high & 0xfffff) == 0)) && (low == 0)));
+         high &= 0xfffff;
+       }
+      else
+       {
 #ifdef TARGET_ANALYZE_FLOATING
-       TARGET_ANALYZE_FLOATING;
+         TARGET_ANALYZE_FLOATING;
 #else
-       /* Extended.  We can't detect extended NaNs for this target.
-          Also note that currently extendeds get nuked to double in
-          REGISTER_CONVERTIBLE.  */
-       is_nan = 0;
+         /* Extended.  We can't detect extended NaNs for this target.
+            Also note that currently extendeds get nuked to double in
+            REGISTER_CONVERTIBLE.  */
+         is_nan = 0;
 #endif 
-      }
-
-    if (is_nan)
-      {
-       /* The meaning of the sign and fraction is not defined by IEEE.
-          But the user might know what they mean.  For example, they
-          (in an implementation-defined manner) distinguish between
-          signaling and quiet NaN's.  */
-       if (high)
-         fprintf_filtered (stream, "-NaN(0x%lx%.8lx)" + !!nonnegative,
-                           high, low);
-       else
-         fprintf_filtered (stream, "-NaN(0x%lx)" + nonnegative, low);
-       return;
-      }
-  }
-#endif /* IEEE_FLOAT.  */
+       }
+
+      if (is_nan)
+       {
+         /* The meaning of the sign and fraction is not defined by IEEE.
+            But the user might know what they mean.  For example, they
+            (in an implementation-defined manner) distinguish between
+            signaling and quiet NaN's.  */
+         if (high)
+           fprintf_filtered (stream, "-NaN(0x%lx%.8lx)" + !!nonnegative,
+                             high, low);
+         else
+           fprintf_filtered (stream, "-NaN(0x%lx)" + nonnegative, low);
+         return;
+       }
+    }
 
   doub = unpack_double (type, valaddr, &inv);
   if (inv)