This is the mail archive of the gdb-patches@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]
Other format: [Raw text]

[patch/rfc] Eliminate INVALID_FLOAT (almost)


Hello,

Two targets define the macro INVALID_FLOAT: VAX and ns32k.

The ns32k definition was commented out long ago so I'm removing it.

The VAX definition is more interesting.  The current macro is very 
non-portable (byte order).  Further, studying the VAX source code 
suggests that its floating-point support is pretty bit-rotten.  For it 
to work correctly / portably it will need to do things like define 
TARGET_FLOAT_FORMAT et.al. to floatformat_vax_f et.al.  This being made 
more difficult since floatformat_vax_f, vax_d and vax_g (?) have yet to 
be specified (my manual is so old that the G format isn't documented :-)

The attached patch removes the macro INVALID_FLOAT from core code.
It also moves the VAXes definition of INVALID_FLOAT to vax-tdep.c adding 
comments explaining why it is problematic.

If someone would like to work on fixing the VAX target (which would 
include multi-arching it) they are most welcome.

I intend checking this in in a few days.

Andrew

PS: What _were_ all those people in the VAX 11 architecture manual smoking?
2002-01-19  Andrew Cagney  <ac131313@redhat.com>

	* config/vax/tm-vax.h (INVALID_FLOAT): Move macro from here...
	* vax-tdep.c (INVALID_FLOAT): To here.  Document why it is broken.

	* rs6000-tdep.c (rs6000_do_registers_info): Delete code wrapped in
	#ifdef INVALID_FLOAT.
	* infcmd.c (do_registers_info): Ditto.
	* values.c (unpack_double): Ditto.  Add comment.

	* config/ns32k/tm-umax.h (INVALID_FLOAT): Delete macro that was
	already commented out.

Index: infcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/infcmd.c,v
retrieving revision 1.37
diff -u -r1.37 infcmd.c
--- infcmd.c	2002/01/17 22:15:17	1.37
+++ infcmd.c	2002/01/19 22:56:51
@@ -1607,13 +1607,8 @@
 	{
 	  register int j;
 
-#ifdef INVALID_FLOAT
-	  if (INVALID_FLOAT (virtual_buffer, REGISTER_VIRTUAL_SIZE (i)))
-	    printf_filtered ("<invalid float>");
-	  else
-#endif
-	    val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, 0,
-		       gdb_stdout, 0, 1, 0, Val_pretty_default);
+	  val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, 0,
+		     gdb_stdout, 0, 1, 0, Val_pretty_default);
 
 	  printf_filtered ("\t(raw 0x");
 	  for (j = 0; j < REGISTER_RAW_SIZE (i); j++)
Index: rs6000-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
retrieving revision 1.36
diff -u -r1.36 rs6000-tdep.c
--- rs6000-tdep.c	2002/01/15 19:38:19	1.36
+++ rs6000-tdep.c	2002/01/19 22:57:11
@@ -1763,13 +1763,8 @@
         {
           register int j;
 
-#ifdef INVALID_FLOAT
-          if (INVALID_FLOAT (virtual_buffer, REGISTER_VIRTUAL_SIZE (i)))
-            printf_filtered ("<invalid float>");
-          else
-#endif
-            val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, 0,
-                       gdb_stdout, 0, 1, 0, Val_pretty_default);
+	  val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, 0,
+		     gdb_stdout, 0, 1, 0, Val_pretty_default);
 
           printf_filtered ("\t(raw 0x");
           for (j = 0; j < REGISTER_RAW_SIZE (i); j++)
Index: values.c
===================================================================
RCS file: /cvs/src/src/gdb/values.c,v
retrieving revision 1.33
diff -u -r1.33 values.c
--- values.c	2002/01/04 18:20:19	1.33
+++ values.c	2002/01/19 22:57:16
@@ -742,13 +742,22 @@
   nosign = TYPE_UNSIGNED (type);
   if (code == TYPE_CODE_FLT)
     {
-#ifdef INVALID_FLOAT
-      if (INVALID_FLOAT (valaddr, len))
-	{
-	  *invp = 1;
-	  return 1.234567891011121314;
-	}
-#endif
+      /* NOTE: cagney/2002-02-19: There was a test here to see if the
+	 floating-point value was valid (using the macro
+	 INVALID_FLOAT).  That test/macro have been removed.
+
+	 It turns out that only the VAX defined this macro and then
+	 only in a non-portable way.  Fixing the portability problem
+	 wouldn't help since the VAX floating-point code is also badly
+	 bit-rotten.  The target needs to add definitions for the
+	 methods TARGET_FLOAT_FORMAT and TARGET_DOUBLE_FORMAT - these
+	 exactly describe the target floating-point format.  The
+	 problem here is that the corresponding floatformat_vax_f and
+	 floatformat_vax_d values these methods should be set to are
+	 also not defined either.  Oops!
+
+         Hopefully someone will add both the missing floatformat
+         definitions and floatformat_is_invalid() function.  */
       return extract_typed_floating (valaddr, type);
     }
   else if (nosign)
Index: vax-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/vax-tdep.c,v
retrieving revision 1.4
diff -u -r1.4 vax-tdep.c
--- vax-tdep.c	2001/03/06 08:21:18	1.4
+++ vax-tdep.c	2002/01/19 22:57:16
@@ -26,6 +26,24 @@
 #include "frame.h"
 #include "value.h"
 
+/* Return 1 if P points to an invalid floating point value.
+   LEN is the length in bytes -- not relevant on the Vax.  */
+
+/* FIXME: cagney/2002-01-19: The macro below was originally defined in
+   tm-vax.h and used in values.c.  Two problems.  Firstly this is a
+   very non-portable and secondly it is wrong.  The VAX should be
+   using floatformat and associated methods to identify and handle
+   invalid floating-point values.  Adding to the poor target's woes
+   there is no floatformat_vax_{f,d} and no TARGET_FLOAT_FORMAT
+   et.al..  */
+
+/* FIXME: cagney/2002-01-19: It turns out that the only thing that
+   uses this macro is the vax disassembler code (so how old is this
+   target?).  This target should instead be using the opcodes
+   disassembler.  That allowing the macro to be eliminated.  */
+
+#define INVALID_FLOAT(p, len) ((*(short *) p & 0xff80) == 0x8000)
+
 /* Vax instructions are never longer than this.  */
 #define MAXLEN 62
 
Index: config/ns32k/tm-umax.h
===================================================================
RCS file: /cvs/src/src/gdb/config/ns32k/tm-umax.h,v
retrieving revision 1.7
diff -u -r1.7 tm-umax.h
--- tm-umax.h	2001/12/15 16:53:23	1.7
+++ tm-umax.h	2002/01/19 22:57:17
@@ -68,21 +68,6 @@
 
 #define DECR_PC_AFTER_BREAK 0
 
-#if 0				/* Disable until fixed *correctly*.  */
-#ifndef INVALID_FLOAT
-#ifndef NaN
-#include <nan.h>
-#endif /* NaN */
-
-/* Return 1 if P points to an invalid floating point value.  */
-/* Surely wrong for cross-debugging.  */
-#define INVALID_FLOAT(p, s) \
-	 ((s == sizeof (float))?	\
-		NaF (*(float *) p) :	\
-		NaD (*(double *) p))
-#endif /* INVALID_FLOAT */
-#endif
-
 /* Say how long (ordinary) registers are.  This is a piece of bogosity
    used in push_word and a few other places; REGISTER_RAW_SIZE is the
    real way to know how big a register is.  */
Index: config/vax/tm-vax.h
===================================================================
RCS file: /cvs/src/src/gdb/config/vax/tm-vax.h,v
retrieving revision 1.5
diff -u -r1.5 tm-vax.h
--- tm-vax.h	2001/12/15 16:53:24	1.5
+++ tm-vax.h	2002/01/19 22:57:17
@@ -65,11 +65,6 @@
 
 #define DECR_PC_AFTER_BREAK 0
 
-/* Return 1 if P points to an invalid floating point value.
-   LEN is the length in bytes -- not relevant on the Vax.  */
-
-#define INVALID_FLOAT(p, len) ((*(short *) p & 0xff80) == 0x8000)
-
 /* Say how long (ordinary) registers are.  This is a piece of bogosity
    used in push_word and a few other places; REGISTER_RAW_SIZE is the
    real way to know how big a register is.  */

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