]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb
authorDaniel Jacobowitz <drow@false.org>
Sun, 21 Sep 2003 19:11:47 +0000 (19:11 +0000)
committerDaniel Jacobowitz <drow@false.org>
Sun, 21 Sep 2003 19:11:47 +0000 (19:11 +0000)
2003-09-19  Daniel Jacobowitz  <drow@mvista.com>

Merge from mainline:
2003-09-15  Daniel Jacobowitz  <drow@mvista.com>

* values.c (unpack_double): Call floatformat_is_valid.

include
2003-09-15  Andrew Cagney  <cagney@redhat.com>

* floatformat.h (floatformat_to_double): Make input buffer constant.
(floatformat_from_double, floatformat_is_valid): Ditto.

2003-09-15  Daniel Jacobowitz  <drow@mvista.com>

* floatformat.h (floatformat_is_valid): Add prototype.

libiberty
2003-09-15  Andrew Cagney  <cagney@redhat.com>

* floatformat.c (get_field): Make "data" constant.
(floatformat_is_valid, floatformat_to_double): Make "from"
constant, fix casts.
(floatformat_from_double): Make "from" constant.

2003-09-15  Daniel Jacobowitz  <drow@mvista.com>

* floatformat.c (floatformat_is_valid): New function.
(get_field, put_field): Correct comments.

gdb/ChangeLog
gdb/values.c
include/ChangeLog
include/floatformat.h
libiberty/ChangeLog
libiberty/floatformat.c

index 5e84f50ca19bef25de3a0588f9cce19d57ec6652..fc360bbf7839d43f9add05ebbaa69d1a0464cbe8 100644 (file)
@@ -1,3 +1,10 @@
+2003-09-19  Daniel Jacobowitz  <drow@mvista.com>
+
+       Merge from mainline:
+       2003-09-15  Daniel Jacobowitz  <drow@mvista.com>
+
+       * values.c (unpack_double): Call floatformat_is_valid.
+
 2003-09-19  Jim Blandy  <jimb@redhat.com>
 
        Merge from mainline:
index 42395c886e2b4cf38b68f62468a87ed9a6308edd..912cd2b31524da6670c2b136a249812b161c45b7 100644 (file)
@@ -739,7 +739,14 @@ unpack_double (struct type *type, const char *valaddr, int *invp)
         also not defined either.  Oops!
 
          Hopefully someone will add both the missing floatformat
-         definitions and floatformat_is_invalid() function.  */
+         definitions and the new cases for floatformat_is_valid ().  */
+
+      if (!floatformat_is_valid (floatformat_from_type (type), valaddr))
+       {
+         *invp = 1;
+         return 0.0;
+       }
+
       return extract_typed_floating (valaddr, type);
     }
   else if (nosign)
index 5e9ac7a10f9ca718883948de49d9cc54b507f5e4..cecf35ca182a400fe03a5750f9d467bc47240487 100644 (file)
@@ -1,3 +1,12 @@
+2003-09-15  Andrew Cagney  <cagney@redhat.com>
+
+       * floatformat.h (floatformat_to_double): Make input buffer constant.
+       (floatformat_from_double, floatformat_is_valid): Ditto.
+       
+2003-09-15  Daniel Jacobowitz  <drow@mvista.com>
+
+       * floatformat.h (floatformat_is_valid): Add prototype.
+
 2003-06-22  Zack Weinberg  <zack@codesourcery.com>
 
        * safe-ctype.h (HC_UNKNOWN, HC_ASCII, HC_EBCDIC): Rename to
index 53ead3eee61a8622d47f8a0469b3edd9cd2b4d62..c92ab93f18a6a089c9034b90bfe6b0c896294ce2 100644 (file)
@@ -1,5 +1,5 @@
 /* IEEE floating point support declarations, for GDB, the GNU Debugger.
-   Copyright 1991, 1994, 1995, 1997, 2000 Free Software Foundation, Inc.
+   Copyright 1991, 1994, 1995, 1997, 2000, 2003 Free Software Foundation, Inc.
 
 This file is part of GDB.
 
@@ -109,13 +109,18 @@ extern const struct floatformat floatformat_ia64_quad_little;
    Store the double in *TO.  */
 
 extern void
-floatformat_to_double PARAMS ((const struct floatformat *, char *, double *));
+floatformat_to_double PARAMS ((const struct floatformat *, const char *, double *));
 
 /* The converse: convert the double *FROM to FMT
    and store where TO points.  */
 
 extern void
 floatformat_from_double PARAMS ((const struct floatformat *,
-                                double *, char *));
+                                const double *, char *));
+
+/* Return non-zero iff the data at FROM is a valid number in format FMT.  */
+
+extern int
+floatformat_is_valid PARAMS ((const struct floatformat *fmt, const char *from));
 
 #endif /* defined (FLOATFORMAT_H) */
index 913bf54a3e3d06a7954504d619e0ba539269f1e8..39bfcf2b082b7b0d5d83b4051b690a4c62e85d75 100644 (file)
@@ -1,3 +1,15 @@
+2003-09-15  Andrew Cagney  <cagney@redhat.com>
+
+       * floatformat.c (get_field): Make "data" constant.
+       (floatformat_is_valid, floatformat_to_double): Make "from"
+       constant, fix casts.
+       (floatformat_from_double): Make "from" constant.
+
+2003-09-15  Daniel Jacobowitz  <drow@mvista.com>
+
+       * floatformat.c (floatformat_is_valid): New function.
+       (get_field, put_field): Correct comments.
+
 2003-06-22  Zack Weinberg  <zack@codesourcery.com>
 
        * safe-ctype.c: Use HOST_CHARSET_ASCII and HOST_CHARSET_EBCDIC,
index d69024f739026dceaa6f37b3832ba9461e7a8206..ee87e273415003660696addbb9deb3b63db854ad 100644 (file)
@@ -1,5 +1,5 @@
 /* IEEE floating point support routines, for GDB, the GNU Debugger.
-   Copyright (C) 1991, 1994, 1999, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1991, 1994, 1999, 2000, 2003 Free Software Foundation, Inc.
 
 This file is part of GDB.
 
@@ -143,17 +143,17 @@ const struct floatformat floatformat_ia64_quad_little =
   "floatformat_ia64_quad_little"
 };
 \f
-static unsigned long get_field PARAMS ((unsigned char *,
+static unsigned long get_field PARAMS ((const unsigned char *,
                                        enum floatformat_byteorders,
                                        unsigned int,
                                        unsigned int,
                                        unsigned int));
 
-/* Extract a field which starts at START and is LEN bytes long.  DATA and
+/* Extract a field which starts at START and is LEN bits long.  DATA and
    TOTAL_LEN are the thing we are extracting it from, in byteorder ORDER.  */
 static unsigned long
 get_field (data, order, total_len, start, len)
-     unsigned char *data;
+     const unsigned char *data;
      enum floatformat_byteorders order;
      unsigned int total_len;
      unsigned int start;
@@ -207,10 +207,10 @@ get_field (data, order, total_len, start, len)
 void
 floatformat_to_double (fmt, from, to)
      const struct floatformat *fmt;
-     char *from;
+     const char *from;
      double *to;
 {
-  unsigned char *ufrom = (unsigned char *)from;
+  const unsigned char *ufrom = (const unsigned char *)from;
   double dto;
   long exponent;
   unsigned long mant;
@@ -273,7 +273,7 @@ static void put_field PARAMS ((unsigned char *, enum floatformat_byteorders,
                               unsigned int,
                               unsigned long));
 
-/* Set a field which starts at START and is LEN bytes long.  DATA and
+/* Set a field which starts at START and is LEN bits long.  DATA and
    TOTAL_LEN are the thing we are extracting it from, in byteorder ORDER.  */
 static void
 put_field (data, order, total_len, start, len, stuff_to_put)
@@ -331,7 +331,7 @@ put_field (data, order, total_len, start, len, stuff_to_put)
 void
 floatformat_from_double (fmt, from, to)
      const struct floatformat *fmt;
-     double *from;
+     const double *from;
      char *to;
 {
   double dfrom;
@@ -404,6 +404,39 @@ floatformat_from_double (fmt, from, to)
     }
 }
 
+/* Return non-zero iff the data at FROM is a valid number in format FMT.  */
+
+int
+floatformat_is_valid (fmt, from)
+     const struct floatformat *fmt;
+     const char *from;
+{
+  if (fmt == &floatformat_i387_ext)
+    {
+      /* In the i387 double-extended format, if the exponent is all
+        ones, then the integer bit must be set.  If the exponent
+        is neither 0 nor ~0, the intbit must also be set.  Only
+        if the exponent is zero can it be zero, and then it must
+        be zero.  */
+      unsigned long exponent, int_bit;
+      const unsigned char *ufrom = (const unsigned char *) from;
+
+      exponent = get_field (ufrom, fmt->byteorder, fmt->totalsize,
+                           fmt->exp_start, fmt->exp_len);
+      int_bit = get_field (ufrom, fmt->byteorder, fmt->totalsize,
+                          fmt->man_start, 1);
+
+      if ((exponent == 0) != (int_bit == 0))
+       return 0;
+      else
+       return 1;
+    }
+
+  /* Other formats with invalid representations should be added
+     here.  */
+  return 1;
+}
+
 
 #ifdef IEEE_DEBUG