[RFA/mips] Fix crash trying to print long double float

Joel Brobecker brobecker@gnat.com
Sun Aug 8 06:59:00 GMT 2004


How's this?

2004-08-08  Joel Brobecker  <brobecker@gnat.com>

        * mips-tdep.c (mips_gdbarch_init): Set size of long double
        to 128 bits for N32 and N64 ABIs.
        * mips-irix-tdep.c: Include "floatformat.h".
        (mips_irix_floatformat_always_valid): New function.
        (floatformat_mips_irix_long_double_big): New constant.
        (mips_irix_init_abi): Set the long double floatformat.

Tested on mips-irix. OK to apply?

Thanks,
-- 
Joel
-------------- next part --------------
Index: mips-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-tdep.c,v
retrieving revision 1.309
diff -u -p -r1.309 mips-tdep.c
--- mips-tdep.c	3 Aug 2004 01:12:43 -0000	1.309
+++ mips-tdep.c	8 Aug 2004 06:51:01 -0000
@@ -6323,6 +6323,7 @@ mips_gdbarch_init (struct gdbarch_info i
       set_gdbarch_long_bit (gdbarch, 32);
       set_gdbarch_ptr_bit (gdbarch, 32);
       set_gdbarch_long_long_bit (gdbarch, 64);
+      set_gdbarch_long_double_bit (gdbarch, 128);
       break;
     case MIPS_ABI_N64:
       set_gdbarch_push_dummy_call (gdbarch, mips_n32n64_push_dummy_call);
@@ -6333,6 +6334,7 @@ mips_gdbarch_init (struct gdbarch_info i
       set_gdbarch_long_bit (gdbarch, 64);
       set_gdbarch_ptr_bit (gdbarch, 64);
       set_gdbarch_long_long_bit (gdbarch, 64);
+      set_gdbarch_long_double_bit (gdbarch, 128);
       break;
     default:
       internal_error (__FILE__, __LINE__, "unknown ABI in switch");
Index: mips-irix-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-irix-tdep.c,v
retrieving revision 1.2
diff -u -p -r1.2 mips-irix-tdep.c
--- mips-irix-tdep.c	21 Dec 2002 19:58:07 -0000	1.2
+++ mips-irix-tdep.c	8 Aug 2004 06:50:59 -0000
@@ -22,9 +22,36 @@
 
 #include "defs.h"
 #include "osabi.h"
+#include "floatformat.h"
 
 #include "elf-bfd.h"
 
+static int
+mips_irix_floatformat_always_valid (const struct floatformat *fmt,
+                                    const char *from)
+{
+  return 1;
+}
+
+/* FIXME: brobecker/2004-08-08: Long Double values are 128 bit long.
+   They are implemented as a pair of 64bit doubles where the high
+   part holds the result of the operation rounded to double, and
+   the low double holds the difference between the exact result and
+   the rounded result.  So "high" + "low" contains the result with
+   added precision.  Unfortunately, the floatformat structure used
+   by GDB is not powerful enough to describe this format.  As a temporary
+   measure, we define a 128bit floatformat that only uses the high part.
+   We lose a bit of precision but that's probably the best we can do
+   for now with the current infrastructure.  */
+
+static const struct floatformat floatformat_mips_irix_long_double_big =
+{
+  floatformat_big, 128, 0, 1, 11, 1023, 2047, 12, 52,
+  floatformat_intbit_no,
+  "floatformat_ieee_double_big",
+  mips_irix_floatformat_always_valid
+};
+
 static void
 mips_irix_elf_osabi_sniff_abi_tag_sections (bfd *abfd, asection *sect,
                                             void *obj)
@@ -80,6 +107,8 @@ static void
 mips_irix_init_abi (struct gdbarch_info info,
                     struct gdbarch *gdbarch)
 {
+  set_gdbarch_long_double_format (gdbarch,
+                                  &floatformat_mips_irix_long_double_big);
 }
 
 void
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.606
diff -u -p -r1.606 Makefile.in
--- Makefile.in	6 Aug 2004 19:14:44 -0000	1.606
+++ Makefile.in	8 Aug 2004 06:50:19 -0000
@@ -2186,7 +2186,8 @@ mem-break.o: mem-break.c $(defs_h) $(sym
 	$(target_h)
 minsyms.o: minsyms.c $(defs_h) $(gdb_string_h) $(symtab_h) $(bfd_h) \
 	$(symfile_h) $(objfiles_h) $(demangle_h) $(value_h) $(cp_abi_h)
-mips-irix-tdep.o: mips-irix-tdep.c $(defs_h) $(osabi_h) $(elf_bfd_h)
+mips-irix-tdep.o: mips-irix-tdep.c $(defs_h) $(osabi_h) $(elf_bfd_h) \
+        $(floatformat_h)
 mips-linux-nat.o: mips-linux-nat.c $(defs_h) $(mips_tdep_h)
 mips-linux-tdep.o: mips-linux-tdep.c $(defs_h) $(gdbcore_h) $(target_h) \
 	$(solib_svr4_h) $(osabi_h) $(mips_tdep_h) $(gdb_string_h) \


More information about the Gdb-patches mailing list